mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 17:21:46 +00:00
Move the mouse cursor hiding code from in_x11 to vid_{x11,glx} so it is
guaranteed to be done /before/ the glx context is created. Hopefully this fixes knghtbrd's ugly cursor problem.
This commit is contained in:
parent
1d5ced14dc
commit
4f0e4c858a
3 changed files with 81 additions and 49 deletions
|
@ -48,7 +48,6 @@
|
||||||
#include <X11/extensions/xf86dga.h>
|
#include <X11/extensions/xf86dga.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
#include "d_local.h"
|
#include "d_local.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
@ -78,7 +77,6 @@ static float mouse_x, mouse_y;
|
||||||
static float old_mouse_x, old_mouse_y;
|
static float old_mouse_x, old_mouse_y;
|
||||||
static int p_mouse_x, p_mouse_y;
|
static int p_mouse_x, p_mouse_y;
|
||||||
static float old__windowed_mouse;
|
static float old__windowed_mouse;
|
||||||
static Cursor nullcursor = None;
|
|
||||||
|
|
||||||
|
|
||||||
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
||||||
|
@ -86,36 +84,6 @@ static Cursor nullcursor = None;
|
||||||
#define INPUT_MASK (KEY_MASK | MOUSE_MASK)
|
#define INPUT_MASK (KEY_MASK | MOUSE_MASK)
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
======================
|
|
||||||
Create an empty cursor
|
|
||||||
======================
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
CreateNullCursor(Display *display, Window root)
|
|
||||||
{
|
|
||||||
Pixmap cursormask;
|
|
||||||
XGCValues xgc;
|
|
||||||
GC gc;
|
|
||||||
XColor dummycolour;
|
|
||||||
|
|
||||||
if (nullcursor != None) return;
|
|
||||||
|
|
||||||
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
|
|
||||||
xgc.function = GXclear;
|
|
||||||
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
|
||||||
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
|
||||||
dummycolour.pixel = 0;
|
|
||||||
dummycolour.red = 0;
|
|
||||||
dummycolour.flags = 04;
|
|
||||||
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
|
||||||
&dummycolour,&dummycolour, 0,0);
|
|
||||||
XFreePixmap(display,cursormask);
|
|
||||||
XFreeGC(display,gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
XLateKey(XKeyEvent *ev)
|
XLateKey(XKeyEvent *ev)
|
||||||
{
|
{
|
||||||
|
@ -423,10 +391,6 @@ IN_Shutdown(void)
|
||||||
mouse_avail = 0;
|
mouse_avail = 0;
|
||||||
if (x_disp) {
|
if (x_disp) {
|
||||||
XAutoRepeatOn(x_disp);
|
XAutoRepeatOn(x_disp);
|
||||||
if (nullcursor != None) {
|
|
||||||
XFreeCursor(x_disp, nullcursor);
|
|
||||||
nullcursor = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_DGA
|
#ifdef HAVE_DGA
|
||||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
|
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp), 0);
|
||||||
|
@ -477,8 +441,8 @@ IN_Init(void)
|
||||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp),
|
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp),
|
||||||
XF86DGADirectMouse|XF86DGADirectKeyb);
|
XF86DGADirectMouse|XF86DGADirectKeyb);
|
||||||
|
|
||||||
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
|
//XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
|
||||||
vid.width, vid.height);
|
// vid.width+2, vid.height+2);
|
||||||
|
|
||||||
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
||||||
GrabModeAsync, x_win, None, CurrentTime);
|
GrabModeAsync, x_win, None, CurrentTime);
|
||||||
|
@ -490,17 +454,6 @@ IN_Init(void)
|
||||||
mouse_x = mouse_y = 0.0;
|
mouse_x = mouse_y = 0.0;
|
||||||
mouse_avail = 1;
|
mouse_avail = 1;
|
||||||
|
|
||||||
/* Invisible cursor */
|
|
||||||
#ifdef HAVE_DGA
|
|
||||||
if (!in_dgamouse->value)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
CreateNullCursor(x_disp, x_win);
|
|
||||||
XDefineCursor(x_disp, x_win, nullcursor);
|
|
||||||
#ifdef HAVE_DGA
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
x11_add_event(KeyPress, &event_key);
|
x11_add_event(KeyPress, &event_key);
|
||||||
x11_add_event(KeyRelease, &event_key);
|
x11_add_event(KeyRelease, &event_key);
|
||||||
x11_add_event(ButtonPress, &event_button);
|
x11_add_event(ButtonPress, &event_button);
|
||||||
|
|
|
@ -87,6 +87,7 @@ static qboolean vid_initialized = false;
|
||||||
static int screen;
|
static int screen;
|
||||||
Window x_win;
|
Window x_win;
|
||||||
static GLXContext ctx = NULL;
|
static GLXContext ctx = NULL;
|
||||||
|
static Cursor nullcursor = None;
|
||||||
|
|
||||||
#define X_MASK (VisibilityChangeMask | StructureNotifyMask)
|
#define X_MASK (VisibilityChangeMask | StructureNotifyMask)
|
||||||
|
|
||||||
|
@ -148,6 +149,36 @@ int gl_mtex_enum = TEXTURE0_SGIS;
|
||||||
qboolean gl_arb_mtex = false;
|
qboolean gl_arb_mtex = false;
|
||||||
qboolean gl_mtexable = false;
|
qboolean gl_mtexable = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
======================
|
||||||
|
Create an empty cursor
|
||||||
|
======================
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
CreateNullCursor(Display *display, Window root)
|
||||||
|
{
|
||||||
|
Pixmap cursormask;
|
||||||
|
XGCValues xgc;
|
||||||
|
GC gc;
|
||||||
|
XColor dummycolour;
|
||||||
|
|
||||||
|
if (nullcursor != None) return;
|
||||||
|
|
||||||
|
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
|
||||||
|
xgc.function = GXclear;
|
||||||
|
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
||||||
|
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
||||||
|
dummycolour.pixel = 0;
|
||||||
|
dummycolour.red = 0;
|
||||||
|
dummycolour.flags = 04;
|
||||||
|
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
||||||
|
&dummycolour,&dummycolour, 0,0);
|
||||||
|
XFreePixmap(display,cursormask);
|
||||||
|
XFreeGC(display,gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +216,10 @@ VID_Shutdown(void)
|
||||||
dlhand = NULL;
|
dlhand = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (nullcursor != None) {
|
||||||
|
XFreeCursor(x_disp, nullcursor);
|
||||||
|
nullcursor = None;
|
||||||
|
}
|
||||||
x11_close_display();
|
x11_close_display();
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -627,6 +662,11 @@ void VID_Init(unsigned char *palette)
|
||||||
visinfo->visual, mask, &attr);
|
visinfo->visual, mask, &attr);
|
||||||
XMapWindow(x_disp, x_win);
|
XMapWindow(x_disp, x_win);
|
||||||
XRaiseWindow(x_disp, x_win);
|
XRaiseWindow(x_disp, x_win);
|
||||||
|
|
||||||
|
/* Invisible cursor */
|
||||||
|
CreateNullCursor(x_disp, x_win);
|
||||||
|
XDefineCursor(x_disp, x_win, nullcursor);
|
||||||
|
|
||||||
#ifdef HAVE_VIDMODE
|
#ifdef HAVE_VIDMODE
|
||||||
if (hasvidmode && vid_fullscreen->value) {
|
if (hasvidmode && vid_fullscreen->value) {
|
||||||
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
|
XGrabKeyboard(x_disp, x_win, 1, GrabModeAsync, GrabModeAsync,
|
||||||
|
|
|
@ -85,6 +85,7 @@ static GC x_gc;
|
||||||
static Visual *x_vis;
|
static Visual *x_vis;
|
||||||
static XVisualInfo *x_visinfo;
|
static XVisualInfo *x_visinfo;
|
||||||
static Atom aWMDelete = 0;
|
static Atom aWMDelete = 0;
|
||||||
|
static Cursor nullcursor = None;
|
||||||
|
|
||||||
#ifdef HAVE_VIDMODE
|
#ifdef HAVE_VIDMODE
|
||||||
static XF86VidModeModeInfo **vidmodes;
|
static XF86VidModeModeInfo **vidmodes;
|
||||||
|
@ -124,6 +125,36 @@ int scr_width, scr_height;
|
||||||
( VisibilityChangeMask | ExposureMask | StructureNotifyMask)
|
( VisibilityChangeMask | ExposureMask | StructureNotifyMask)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
======================
|
||||||
|
Create an empty cursor
|
||||||
|
======================
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
CreateNullCursor(Display *display, Window root)
|
||||||
|
{
|
||||||
|
Pixmap cursormask;
|
||||||
|
XGCValues xgc;
|
||||||
|
GC gc;
|
||||||
|
XColor dummycolour;
|
||||||
|
|
||||||
|
if (nullcursor != None) return;
|
||||||
|
|
||||||
|
cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/);
|
||||||
|
xgc.function = GXclear;
|
||||||
|
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
|
||||||
|
XFillRectangle(display, cursormask, gc, 0, 0, 1, 1);
|
||||||
|
dummycolour.pixel = 0;
|
||||||
|
dummycolour.red = 0;
|
||||||
|
dummycolour.flags = 04;
|
||||||
|
nullcursor = XCreatePixmapCursor(display, cursormask, cursormask,
|
||||||
|
&dummycolour,&dummycolour, 0,0);
|
||||||
|
XFreePixmap(display,cursormask);
|
||||||
|
XFreeGC(display,gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shiftmask_init( void )
|
shiftmask_init( void )
|
||||||
{
|
{
|
||||||
|
@ -637,6 +668,10 @@ void VID_Init (unsigned char *palette)
|
||||||
/* Make window respond to Delete events */
|
/* Make window respond to Delete events */
|
||||||
aWMDelete = XInternAtom(x_disp, "WM_DELETE_WINDOW", False);
|
aWMDelete = XInternAtom(x_disp, "WM_DELETE_WINDOW", False);
|
||||||
XSetWMProtocols(x_disp, x_win, &aWMDelete, 1);
|
XSetWMProtocols(x_disp, x_win, &aWMDelete, 1);
|
||||||
|
|
||||||
|
/* Invisible cursor */
|
||||||
|
CreateNullCursor(x_disp, x_win);
|
||||||
|
XDefineCursor(x_disp, x_win, nullcursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_visinfo->depth == 8) {
|
if (x_visinfo->depth == 8) {
|
||||||
|
@ -775,6 +810,10 @@ VID_Shutdown(void)
|
||||||
XFree(vidmodes);
|
XFree(vidmodes);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (nullcursor != None) {
|
||||||
|
XFreeCursor(x_disp, nullcursor);
|
||||||
|
nullcursor = None;
|
||||||
|
}
|
||||||
XAutoRepeatOn(x_disp);
|
XAutoRepeatOn(x_disp);
|
||||||
x11_close_display();
|
x11_close_display();
|
||||||
x_disp = 0;
|
x_disp = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue