2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
context_x11.c
|
|
|
|
|
|
|
|
general x11 context layer
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
Copyright (C) 2000 Zephaniah E. Hull <warp@whitestar.soark.net>
|
2001-05-20 00:56:09 +00:00
|
|
|
Copyright (C) 2000, 2001 Jeff Teunissen <deek@quakeforge.net>
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2002-08-21 00:04:35 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-08-23 23:34:38 +00:00
|
|
|
|
2001-11-07 06:59:10 +00:00
|
|
|
#include <stdlib.h>
|
2001-04-15 04:18:22 +00:00
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
# include <X11/extensions/xf86vmode.h>
|
|
|
|
#endif
|
|
|
|
|
2010-11-27 06:10:34 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/qtypes.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
#include "QF/vid.h"
|
|
|
|
|
2021-11-22 04:11:37 +00:00
|
|
|
#include "QF/input/event.h"
|
|
|
|
|
2001-11-07 06:59:10 +00:00
|
|
|
#include "context_x11.h"
|
|
|
|
#include "dga_check.h"
|
2021-11-21 12:22:11 +00:00
|
|
|
#include "in_x11.h"
|
2012-02-17 07:13:56 +00:00
|
|
|
#include "vid_internal.h"
|
2001-11-07 06:59:10 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
static void (*event_handlers[LASTEvent]) (XEvent *);
|
|
|
|
qboolean oktodraw = false;
|
|
|
|
int x_shmeventtype;
|
|
|
|
|
|
|
|
static int x_disp_ref_count = 0;
|
2004-03-19 20:24:26 +00:00
|
|
|
static Cursor nullcursor = None;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
Display *x_disp = NULL;
|
|
|
|
int x_screen;
|
2021-11-25 11:01:13 +00:00
|
|
|
int x_width;
|
|
|
|
int x_height;
|
2001-04-15 04:18:22 +00:00
|
|
|
Window x_root = None;
|
|
|
|
XVisualInfo *x_visinfo;
|
|
|
|
Visual *x_vis;
|
|
|
|
Window x_win;
|
2012-02-18 12:33:54 +00:00
|
|
|
Colormap x_cmap;
|
2002-01-08 20:07:19 +00:00
|
|
|
Time x_time;
|
2004-03-21 05:21:27 +00:00
|
|
|
Time x_mouse_time;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2003-02-13 18:24:30 +00:00
|
|
|
qboolean x_have_focus = false;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
static XF86VidModeModeInfo **vidmodes;
|
2002-04-25 20:53:15 +00:00
|
|
|
static int nummodes;
|
|
|
|
static int original_mode = 0;
|
|
|
|
static vec3_t x_gamma = {-1, -1, -1};
|
|
|
|
static qboolean vidmode_avail = false;
|
2001-04-15 04:18:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static qboolean vidmode_active = false;
|
|
|
|
|
2001-05-17 06:55:47 +00:00
|
|
|
static qboolean vid_context_created = false;
|
2004-03-19 20:24:26 +00:00
|
|
|
static int pos_x, pos_y;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2006-05-24 09:24:00 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
2003-01-16 21:44:42 +00:00
|
|
|
static int xss_timeout;
|
|
|
|
static int xss_interval;
|
|
|
|
static int xss_blanking;
|
|
|
|
static int xss_exposures;
|
2006-05-24 09:24:00 +00:00
|
|
|
#endif
|
2003-01-16 21:44:42 +00:00
|
|
|
|
2003-09-04 22:29:40 +00:00
|
|
|
static qboolean accel_saved = false;
|
|
|
|
static int accel_numerator;
|
|
|
|
static int accel_denominator;
|
|
|
|
static int accel_threshold;
|
|
|
|
|
2010-11-27 07:19:04 +00:00
|
|
|
#define _NET_WM_STATE_REMOVE 0
|
|
|
|
#define _NET_WM_STATE_ADD 1
|
|
|
|
#define _NET_WM_STATE_TOGGLE 2
|
|
|
|
static Atom x_net_state;
|
|
|
|
static Atom x_net_fullscreen;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
static int x11_vidmode;
|
|
|
|
static cvar_t x11_vidmode_cvar = {
|
|
|
|
.name = "x11_vidmode",
|
|
|
|
.description =
|
|
|
|
"Use x11 vidmode extension to set video mode (not recommended for "
|
|
|
|
"modern systems)",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ROM,
|
|
|
|
.value = { .type = &cexpr_int, .value = &x11_vidmode },
|
|
|
|
};
|
2019-07-10 13:15:39 +00:00
|
|
|
|
2010-11-27 07:19:04 +00:00
|
|
|
static void
|
|
|
|
set_fullscreen (int full)
|
|
|
|
{
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.window = x_win;
|
|
|
|
xev.xclient.message_type = x_net_state;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
|
|
|
|
if (full)
|
|
|
|
xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
|
|
|
|
else
|
|
|
|
xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
|
|
|
|
|
|
|
|
xev.xclient.data.l[1] = x_net_fullscreen;
|
|
|
|
xev.xclient.data.l[2] = 0;
|
|
|
|
xev.xclient.data.l[3] = 0;
|
|
|
|
xev.xclient.data.l[4] = 0;
|
|
|
|
XSendEvent (x_disp, x_root, False,
|
|
|
|
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
|
|
|
}
|
|
|
|
|
2004-03-19 20:24:26 +00:00
|
|
|
static void
|
|
|
|
configure_notify (XEvent *event)
|
|
|
|
{
|
|
|
|
XConfigureEvent *c = &event->xconfigure;
|
|
|
|
pos_x = c->x;
|
|
|
|
pos_y = c->y;
|
2004-03-22 02:16:41 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
if (vidmode_active)
|
|
|
|
X11_ForceViewPort ();
|
|
|
|
#endif
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid,
|
2010-11-23 05:09:30 +00:00
|
|
|
"ConfigureNotify: %ld %d %ld %ld %d,%d (%d,%d) "
|
|
|
|
"%d %ld %d\n",
|
|
|
|
c->serial, c->send_event, c->event, c->window, c->x, c->y,
|
|
|
|
c->width, c->height, c->border_width, c->above,
|
|
|
|
c->override_redirect);
|
2021-11-22 04:11:37 +00:00
|
|
|
IE_event_t ie_event = {
|
|
|
|
.type = ie_app_window,
|
|
|
|
.when = Sys_LongTime (),
|
|
|
|
.app_window = {
|
|
|
|
.xpos = c->x,
|
|
|
|
.ypos = c->y,
|
|
|
|
.xlen = c->width,
|
|
|
|
.ylen = c->height,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
IE_Send_Event (&ie_event);
|
2022-09-21 16:09:27 +00:00
|
|
|
VID_SetWindowSize (c->width, c->height);
|
2004-03-19 20:24:26 +00:00
|
|
|
}
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
qboolean
|
|
|
|
X11_AddEvent (int event, void (*event_handler) (XEvent *))
|
|
|
|
{
|
|
|
|
if (event >= LASTEvent) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "event: %d, LASTEvent: %d\n", event,
|
2010-11-23 05:09:30 +00:00
|
|
|
LASTEvent);
|
2001-04-15 04:18:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
if (event_handlers[event])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
event_handlers[event] = event_handler;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
X11_RemoveEvent (int event, void (*event_handler) (XEvent *))
|
|
|
|
{
|
|
|
|
if (event >= LASTEvent)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (event_handlers[event] != event_handler)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
event_handlers[event] = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-03-18 06:05:59 +00:00
|
|
|
static inline void
|
2001-09-18 09:30:59 +00:00
|
|
|
X11_ProcessEventProxy(XEvent *x_event)
|
|
|
|
{
|
|
|
|
if (x_event->type >= LASTEvent) {
|
|
|
|
if (x_event->type == x_shmeventtype)
|
|
|
|
oktodraw = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event_handlers[x_event->type])
|
|
|
|
event_handlers[x_event->type] (x_event);
|
2012-05-21 23:23:22 +00:00
|
|
|
}
|
2001-09-18 09:30:59 +00:00
|
|
|
|
2003-08-04 01:28:30 +00:00
|
|
|
static void
|
|
|
|
X11_WaitForEvent (int event)
|
|
|
|
{
|
|
|
|
XEvent ev;
|
|
|
|
int type;
|
|
|
|
|
|
|
|
while (1) {
|
2004-03-21 00:34:24 +00:00
|
|
|
XMaskEvent (x_disp, X11_WINDOW_MASK, &ev);
|
2003-08-04 01:28:30 +00:00
|
|
|
type = ev.type;
|
|
|
|
X11_ProcessEventProxy (&ev);
|
2012-05-21 23:23:22 +00:00
|
|
|
if (type == event)
|
2003-08-04 01:28:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-18 06:05:59 +00:00
|
|
|
inline void
|
2001-04-15 04:18:22 +00:00
|
|
|
X11_ProcessEvent (void)
|
|
|
|
{
|
|
|
|
XEvent x_event;
|
|
|
|
|
|
|
|
XNextEvent (x_disp, &x_event);
|
2002-01-08 20:07:19 +00:00
|
|
|
X11_ProcessEventProxy (&x_event);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
X11_ProcessEvents (void)
|
|
|
|
{
|
2004-03-18 06:05:59 +00:00
|
|
|
while (XPending (x_disp))
|
2001-04-15 04:18:22 +00:00
|
|
|
X11_ProcessEvent ();
|
|
|
|
}
|
|
|
|
|
2006-05-24 09:20:53 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
2004-03-19 20:24:26 +00:00
|
|
|
static void
|
|
|
|
X11_SetScreenSaver (void)
|
|
|
|
{
|
|
|
|
XGetScreenSaver (x_disp, &xss_timeout, &xss_interval, &xss_blanking,
|
|
|
|
&xss_exposures);
|
|
|
|
XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking, xss_exposures);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
X11_RestoreScreenSaver (void)
|
|
|
|
{
|
|
|
|
XSetScreenSaver (x_disp, xss_timeout, xss_interval, xss_blanking,
|
|
|
|
xss_exposures);
|
|
|
|
}
|
2006-05-24 09:20:53 +00:00
|
|
|
#endif
|
2004-03-19 20:24:26 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
|
|
|
X11_OpenDisplay (void)
|
|
|
|
{
|
|
|
|
if (!x_disp) {
|
|
|
|
x_disp = XOpenDisplay (NULL);
|
|
|
|
if (!x_disp) {
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("X11_OpenDisplay: Could not open display [%s]",
|
2001-04-15 04:18:22 +00:00
|
|
|
XDisplayName (NULL));
|
|
|
|
}
|
|
|
|
|
2010-11-27 07:19:04 +00:00
|
|
|
x_net_state = XInternAtom (x_disp, "_NET_WM_STATE", False);
|
|
|
|
x_net_fullscreen = XInternAtom (x_disp, "_NET_WM_STATE_FULLSCREEN",
|
|
|
|
False);
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
x_screen = DefaultScreen (x_disp);
|
2021-11-25 11:01:13 +00:00
|
|
|
x_width = DisplayWidth (x_disp, x_screen);
|
|
|
|
x_height = DisplayHeight (x_disp, x_screen);
|
2001-04-15 04:18:22 +00:00
|
|
|
x_root = RootWindow (x_disp, x_screen);
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
XSynchronize (x_disp, true); // only for debugging
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
x_disp_ref_count = 1;
|
|
|
|
} else {
|
|
|
|
x_disp_ref_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
X11_CloseDisplay (void)
|
|
|
|
{
|
2004-03-19 20:24:26 +00:00
|
|
|
if (!--x_disp_ref_count) {
|
|
|
|
X11_RestoreVidMode ();
|
2002-04-26 20:25:01 +00:00
|
|
|
|
2004-03-19 20:24:26 +00:00
|
|
|
X11_RestoreGamma ();
|
|
|
|
|
|
|
|
if (nullcursor != None) {
|
|
|
|
XFreeCursor (x_disp, nullcursor);
|
|
|
|
nullcursor = None;
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
XCloseDisplay (x_disp);
|
|
|
|
x_disp = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
X11_CreateNullCursor
|
|
|
|
|
|
|
|
Create an empty cursor (in other words, make it disappear)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
X11_CreateNullCursor (void)
|
|
|
|
{
|
|
|
|
Pixmap cursormask;
|
2021-03-21 10:56:17 +00:00
|
|
|
XGCValues xgc = { };
|
2001-04-15 04:18:22 +00:00
|
|
|
GC gc;
|
2021-03-21 10:56:17 +00:00
|
|
|
XColor dummycolour = { };
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (nullcursor != None)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cursormask = XCreatePixmap (x_disp, x_root, 1, 1, 1);
|
|
|
|
xgc.function = GXclear;
|
|
|
|
|
|
|
|
gc = XCreateGC (x_disp, cursormask, GCFunction, &xgc);
|
|
|
|
|
|
|
|
XFillRectangle (x_disp, cursormask, gc, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
dummycolour.pixel = 0;
|
|
|
|
dummycolour.red = 0;
|
|
|
|
dummycolour.flags = 04;
|
|
|
|
nullcursor = XCreatePixmapCursor (x_disp, cursormask, cursormask,
|
|
|
|
&dummycolour, &dummycolour, 0, 0);
|
|
|
|
XFreePixmap (x_disp, cursormask);
|
|
|
|
XFreeGC (x_disp, gc);
|
|
|
|
XDefineCursor (x_disp, x_win, nullcursor);
|
|
|
|
}
|
|
|
|
|
2006-05-24 09:20:53 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
2004-03-18 06:05:59 +00:00
|
|
|
static vec3_t *
|
|
|
|
X11_GetGamma (void)
|
|
|
|
{
|
|
|
|
XF86VidModeGamma xgamma;
|
|
|
|
vec3_t *temp;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vid_gamma_avail && vid_system_gamma) {
|
2004-03-18 06:05:59 +00:00
|
|
|
if (XF86VidModeGetGamma (x_disp, x_screen, &xgamma)) {
|
|
|
|
if ((temp = malloc (sizeof (vec3_t)))) {
|
|
|
|
(*temp)[0] = xgamma.red;
|
|
|
|
(*temp)[1] = xgamma.green;
|
|
|
|
(*temp)[2] = xgamma.blue;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vid_gamma_avail = false;
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-05-24 09:20:53 +00:00
|
|
|
#endif
|
2004-03-18 06:05:59 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
|
|
|
X11_SetVidMode (int width, int height)
|
|
|
|
{
|
|
|
|
const char *str = getenv ("MESA_GLX_FX");
|
|
|
|
|
2001-05-17 20:57:29 +00:00
|
|
|
if (vidmode_active)
|
|
|
|
return;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!x11_vidmode) {
|
2019-07-10 13:15:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
if (str && (tolower (*str) == 'f')) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Set ("vid_fullscreen", "1");
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_VIDMODE
|
2002-06-10 22:30:30 +00:00
|
|
|
{
|
|
|
|
static int initialized = 0;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
if (!vidmode_avail)
|
|
|
|
vidmode_avail = VID_CheckVMode (x_disp, NULL, NULL);
|
2002-04-25 20:53:15 +00:00
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
if (!initialized && vidmode_avail) {
|
|
|
|
vec3_t *temp;
|
2002-05-17 03:17:33 +00:00
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
initialized = 1;
|
2002-05-17 03:17:33 +00:00
|
|
|
|
2002-04-25 20:28:15 +00:00
|
|
|
vid_gamma_avail = true;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
temp = X11_GetGamma ();
|
2016-10-24 15:10:30 +00:00
|
|
|
if (temp && (*temp)[0] > 0) {
|
2002-06-10 22:30:30 +00:00
|
|
|
x_gamma[0] = (*temp)[0];
|
|
|
|
x_gamma[1] = (*temp)[1];
|
|
|
|
x_gamma[2] = (*temp)[2];
|
|
|
|
vid_gamma_avail = true;
|
|
|
|
free (temp);
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vid_fullscreen && vidmode_avail) {
|
2002-06-10 22:30:30 +00:00
|
|
|
int i, dotclock;
|
|
|
|
int best_mode = 0;
|
|
|
|
qboolean found_mode = false;
|
|
|
|
XF86VidModeModeLine orig_data;
|
|
|
|
|
2002-08-21 00:04:35 +00:00
|
|
|
XF86VidModeGetAllModeLines (x_disp, x_screen, &nummodes,
|
|
|
|
&vidmodes);
|
2002-06-10 22:30:30 +00:00
|
|
|
XF86VidModeGetModeLine (x_disp, x_screen, &dotclock, &orig_data);
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "VID: %d modes\n", nummodes);
|
2020-02-12 02:04:28 +00:00
|
|
|
original_mode = -1;
|
2002-06-10 22:30:30 +00:00
|
|
|
for (i = 0; i < nummodes; i++) {
|
2020-02-12 02:04:28 +00:00
|
|
|
if (original_mode == -1
|
|
|
|
&& (vidmodes[i]->hdisplay == orig_data.hdisplay) &&
|
|
|
|
(vidmodes[i]->vdisplay == orig_data.vdisplay)) {
|
2002-06-10 22:30:30 +00:00
|
|
|
original_mode = i;
|
2020-02-12 02:04:28 +00:00
|
|
|
}
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (developer & SYS_vid) {
|
2020-02-12 02:04:28 +00:00
|
|
|
Sys_Printf ("VID:%c%dx%d\n",
|
|
|
|
original_mode == i ? '*' : ' ',
|
|
|
|
vidmodes[i]->hdisplay, vidmodes[i]->vdisplay);
|
|
|
|
Sys_Printf ("\t%d %d %d %d:%d %d %d:%d\n",
|
|
|
|
vidmodes[i]->hsyncstart, vidmodes[i]->hsyncend,
|
|
|
|
vidmodes[i]->htotal, vidmodes[i]->hskew,
|
|
|
|
vidmodes[i]->vsyncstart, vidmodes[i]->vsyncend,
|
|
|
|
vidmodes[i]->vtotal, vidmodes[i]->flags);
|
2002-06-10 22:30:30 +00:00
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
for (i = 0; i < nummodes; i++) {
|
2012-02-14 10:47:02 +00:00
|
|
|
if ((vidmodes[i]->hdisplay == viddef.width) &&
|
|
|
|
(vidmodes[i]->vdisplay == viddef.height)) {
|
2002-06-10 22:30:30 +00:00
|
|
|
found_mode = true;
|
|
|
|
best_mode = i;
|
|
|
|
break;
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:30:30 +00:00
|
|
|
if (found_mode) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "VID: Chose video mode: %dx%d\n",
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.width, viddef.height);
|
2002-06-10 22:30:30 +00:00
|
|
|
|
2020-02-12 02:04:28 +00:00
|
|
|
if (0) {
|
2002-08-21 00:04:35 +00:00
|
|
|
XF86VidModeSwitchToMode (x_disp, x_screen,
|
|
|
|
vidmodes[best_mode]);
|
2020-02-12 02:04:28 +00:00
|
|
|
}
|
2002-06-10 22:30:30 +00:00
|
|
|
vidmode_active = true;
|
2003-01-16 21:44:42 +00:00
|
|
|
X11_SetScreenSaver ();
|
2002-06-10 22:30:30 +00:00
|
|
|
} else {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("VID: Mode %dx%d can't go fullscreen.\n",
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.width, viddef.height);
|
2002-06-10 22:30:30 +00:00
|
|
|
vidmode_avail = vidmode_active = false;
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
void
|
|
|
|
X11_UpdateFullscreen (int fullscreen)
|
2001-05-17 09:56:43 +00:00
|
|
|
{
|
2001-11-07 06:59:10 +00:00
|
|
|
if (!vid_context_created)
|
2001-05-17 09:56:43 +00:00
|
|
|
return;
|
2001-09-08 05:43:52 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!fullscreen) {
|
2001-05-20 00:56:09 +00:00
|
|
|
X11_RestoreVidMode ();
|
2010-11-27 07:19:04 +00:00
|
|
|
set_fullscreen (0);
|
2003-02-25 06:04:42 +00:00
|
|
|
IN_UpdateGrab (in_grab);
|
2001-05-17 09:56:43 +00:00
|
|
|
} else {
|
2010-11-27 07:19:04 +00:00
|
|
|
set_fullscreen (1);
|
2012-02-14 10:47:02 +00:00
|
|
|
X11_SetVidMode (viddef.width, viddef.height);
|
2003-08-04 01:28:30 +00:00
|
|
|
IN_UpdateGrab (in_grab);
|
2001-05-17 09:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-27 06:10:34 +00:00
|
|
|
static void
|
|
|
|
VID_Center_f (void)
|
|
|
|
{
|
|
|
|
X11_ForceViewPort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
|
|
|
X11_Init_Cvars (void)
|
|
|
|
{
|
2010-11-27 06:10:34 +00:00
|
|
|
Cmd_AddCommand ("vid_center", VID_Center_f, "Center the view port on the "
|
|
|
|
"quake window in a virtual desktop.\n");
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&x11_vidmode_cvar, 0, 0);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
|
|
|
X11_CreateWindow (int width, int height)
|
|
|
|
{
|
2004-02-09 04:11:13 +00:00
|
|
|
char *resname;
|
2002-04-26 20:25:01 +00:00
|
|
|
unsigned long mask;
|
2004-02-09 04:11:13 +00:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
XClassHint *ClassHint;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2004-03-19 20:24:26 +00:00
|
|
|
X11_AddEvent (ConfigureNotify, configure_notify);
|
|
|
|
|
2002-08-21 00:04:35 +00:00
|
|
|
// window attributes
|
2001-04-15 04:18:22 +00:00
|
|
|
attr.background_pixel = 0;
|
2002-10-11 21:32:17 +00:00
|
|
|
attr.border_pixel = 0;
|
2012-02-18 12:33:54 +00:00
|
|
|
attr.colormap = x_cmap;
|
2021-11-21 12:09:00 +00:00
|
|
|
if (!attr.colormap) {
|
2012-02-18 12:33:54 +00:00
|
|
|
attr.colormap = XCreateColormap (x_disp, x_root, x_vis, AllocNone);
|
2021-11-21 12:09:00 +00:00
|
|
|
}
|
2021-11-21 12:22:11 +00:00
|
|
|
attr.event_mask = X11_MASK | IN_X11_Preinit ();
|
|
|
|
|
2002-10-11 21:32:17 +00:00
|
|
|
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2021-11-21 12:22:11 +00:00
|
|
|
|
2001-11-07 06:59:10 +00:00
|
|
|
x_win = XCreateWindow (x_disp, x_root, 0, 0, width, height, 0,
|
|
|
|
x_visinfo->depth, InputOutput, x_vis, mask, &attr);
|
2021-11-21 12:22:11 +00:00
|
|
|
IN_X11_Postinit ();
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
// Set window size hints
|
2022-09-21 16:09:27 +00:00
|
|
|
XSizeHints SizeHints = {
|
|
|
|
.flags = PMinSize,
|
|
|
|
.min_width = 32,
|
|
|
|
.min_height = 20,
|
|
|
|
};
|
|
|
|
XSetWMNormalHints (x_disp, x_win, &SizeHints);
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
// Set window title
|
2021-01-31 07:01:20 +00:00
|
|
|
X11_SetCaption (va (0, "%s", PACKAGE_STRING));
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
// Set icon name
|
2010-08-19 06:01:43 +00:00
|
|
|
XSetIconName (x_disp, x_win, PACKAGE_NAME);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
// Set window class
|
|
|
|
ClassHint = XAllocClassHint ();
|
|
|
|
if (ClassHint) {
|
|
|
|
resname = strrchr (com_argv[0], '/');
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
ClassHint->res_name = (char *)(resname ? resname + 1 : com_argv[0]);
|
|
|
|
ClassHint->res_class = (char *)PACKAGE;
|
2001-04-15 04:18:22 +00:00
|
|
|
XSetClassHint (x_disp, x_win, ClassHint);
|
|
|
|
XFree (ClassHint);
|
|
|
|
}
|
2002-04-26 20:25:01 +00:00
|
|
|
|
2001-09-18 09:30:59 +00:00
|
|
|
XMapWindow (x_disp, x_win);
|
2001-05-17 06:55:47 +00:00
|
|
|
|
2004-03-19 20:24:26 +00:00
|
|
|
X11_WaitForEvent (ConfigureNotify);
|
2002-04-26 20:25:01 +00:00
|
|
|
|
2001-09-18 04:53:01 +00:00
|
|
|
vid_context_created = true;
|
2019-07-10 13:18:51 +00:00
|
|
|
XRaiseWindow (x_disp, x_win);
|
|
|
|
X11_WaitForEvent (VisibilityNotify);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
X11_UpdateFullscreen (vid_fullscreen);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
X11_RestoreVidMode (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
if (vidmode_active) {
|
2003-01-16 21:44:42 +00:00
|
|
|
X11_RestoreScreenSaver ();
|
2020-02-12 02:04:28 +00:00
|
|
|
//XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[original_mode]);
|
2001-04-15 04:18:22 +00:00
|
|
|
XFree (vidmodes);
|
2002-04-26 20:25:01 +00:00
|
|
|
vidmode_active = false;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
X11_SetCaption (const char *text)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
if (x_disp && x_win && text)
|
|
|
|
XStoreName (x_disp, x_win, text);
|
|
|
|
}
|
|
|
|
|
2001-09-10 16:53:33 +00:00
|
|
|
void
|
|
|
|
X11_ForceViewPort (void)
|
|
|
|
{
|
2001-10-06 22:57:54 +00:00
|
|
|
#ifdef HAVE_VIDMODE
|
2001-09-10 16:53:33 +00:00
|
|
|
if (!vidmode_avail || !vid_context_created)
|
|
|
|
return;
|
|
|
|
|
2004-03-19 20:24:26 +00:00
|
|
|
XF86VidModeSetViewPort (x_disp, x_screen, pos_x, pos_y);
|
2001-10-06 22:57:54 +00:00
|
|
|
#endif
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
X11_SetGamma (double gamma)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
XF86VidModeGamma xgamma;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (vid_gamma_avail && vid_system_gamma && x_have_focus) {
|
2001-04-15 04:18:22 +00:00
|
|
|
xgamma.red = xgamma.green = xgamma.blue = (float) gamma;
|
|
|
|
if (XF86VidModeSetGamma (x_disp, x_screen, &xgamma))
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-23 03:44:21 +00:00
|
|
|
#else
|
|
|
|
Sys_MaskPrintf (SYS_vid, "X11_SetGamma: cannot adjust gamma\n");
|
2001-04-15 04:18:22 +00:00
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
2001-05-17 20:57:29 +00:00
|
|
|
|
2001-05-20 00:56:09 +00:00
|
|
|
void
|
|
|
|
X11_RestoreGamma (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
XF86VidModeGamma xgamma;
|
|
|
|
|
2002-04-28 09:03:50 +00:00
|
|
|
if (vid_gamma_avail && x_gamma[0] > 0) {
|
2002-04-25 20:53:15 +00:00
|
|
|
xgamma.red = x_gamma[0];
|
|
|
|
xgamma.green = x_gamma[1];
|
|
|
|
xgamma.blue = x_gamma[2];
|
2001-05-20 00:56:09 +00:00
|
|
|
XF86VidModeSetGamma (x_disp, x_screen, &xgamma);
|
|
|
|
}
|
2021-11-23 03:44:21 +00:00
|
|
|
#else
|
|
|
|
Sys_MaskPrintf (SYS_vid, "X11_RestoreGamma: cannot adjust gamma\n");
|
2001-05-20 00:56:09 +00:00
|
|
|
#endif
|
|
|
|
}
|
2003-01-16 21:44:42 +00:00
|
|
|
|
2003-09-04 22:29:40 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
X11_SaveMouseAcceleration (void)
|
|
|
|
{
|
|
|
|
accel_saved = true;
|
|
|
|
XGetPointerControl(x_disp, &accel_numerator, &accel_denominator,
|
|
|
|
&accel_threshold);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
X11_RemoveMouseAcceleration (void)
|
|
|
|
{
|
2004-05-10 01:17:55 +00:00
|
|
|
XChangePointerControl(x_disp, true, false, 0, 1, 0);
|
2003-09-04 22:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
X11_RestoreMouseAcceleration (void)
|
|
|
|
{
|
|
|
|
if (!accel_saved)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XChangePointerControl(x_disp, true, true, accel_numerator,
|
|
|
|
accel_denominator, accel_threshold);
|
|
|
|
accel_saved = false;
|
|
|
|
}
|
2021-08-27 00:10:21 +00:00
|
|
|
|
|
|
|
extern int x11_force_link;
|
|
|
|
static __attribute__((used)) int *context_x11_force_link = &x11_force_link;
|