[PATCH] Fix hang in SCR_ModalMessage for X11

SCR_ModalMessage relies on Sys_SendKeyEvents to return a keypress in response
to the message. The however, X11 software renderer wasn't doing this. This
patch fixes the software X11 renderer (heh, probably should be in the input
driver), bringing it closer into line with the GLX renderer.

Bug reported by Steven A <stevenaaus@yahoo.com>.

Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
Tyrann 2007-07-15 15:15:13 +09:30
parent 689baf5129
commit 9c9c385cce
2 changed files with 58 additions and 52 deletions

View File

@ -1,4 +1,3 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
@ -367,7 +366,7 @@ HandleEvents(void)
XEvent event;
qboolean dowarp = false;
if (x_disp == NULL)
if (!x_disp)
return;
while (XPending(x_disp)) {

View File

@ -1049,64 +1049,70 @@ static int config_notify_width;
static int config_notify_height;
static void
GetEvent(void)
HandleEvents(void)
{
XEvent x_event;
qboolean dowarp = false;
XNextEvent(x_disp, &x_event);
switch (x_event.type) {
case KeyPress:
Key_Event(XLateKey(&x_event.xkey), true);
break;
if (!x_disp)
return;
case KeyRelease:
Key_Event(XLateKey(&x_event.xkey), false);
break;
while (XPending(x_disp)) {
XNextEvent(x_disp, &x_event);
case MotionNotify:
if (mouse_grab_active) {
if (dga_mouse_active) {
mouse_x += x_event.xmotion.x_root;
mouse_y += x_event.xmotion.y_root;
} else {
mouse_x = x_event.xmotion.x - (int)(vid.width / 2);
mouse_y = x_event.xmotion.y - (int)(vid.height / 2);
switch (x_event.type) {
case KeyPress:
case KeyRelease:
Key_Event(XLateKey(&x_event.xkey), x_event.type == KeyPress);
break;
/* move the mouse to the window center again */
IN_CenterMouse();
case MotionNotify:
if (mouse_grab_active) {
if (dga_mouse_active) {
mouse_x += x_event.xmotion.x_root;
mouse_y += x_event.xmotion.y_root;
} else {
mouse_x = x_event.xmotion.x - (int)(vid.width / 2);
mouse_y = x_event.xmotion.y - (int)(vid.height / 2);
if (mouse_x || mouse_y)
dowarp = true;
}
}
break;
case ButtonPress:
if (x_event.xbutton.button == 1)
Key_Event(K_MOUSE1, true);
else if (x_event.xbutton.button == 2)
Key_Event(K_MOUSE3, true);
else if (x_event.xbutton.button == 3)
Key_Event(K_MOUSE2, true);
break;
case ButtonRelease:
if (x_event.xbutton.button == 1)
Key_Event(K_MOUSE1, false);
else if (x_event.xbutton.button == 2)
Key_Event(K_MOUSE3, false);
else if (x_event.xbutton.button == 3)
Key_Event(K_MOUSE2, false);
break;
case ConfigureNotify:
config_notify_width = x_event.xconfigure.width;
config_notify_height = x_event.xconfigure.height;
config_notify = 1;
break;
default:
if (doShm && x_event.type == x_shmeventtype)
oktodraw = true;
}
break;
case ButtonPress:
if (x_event.xbutton.button == 1)
Key_Event(K_MOUSE1, true);
else if (x_event.xbutton.button == 2)
Key_Event(K_MOUSE3, true);
else if (x_event.xbutton.button == 3)
Key_Event(K_MOUSE2, true);
break;
case ButtonRelease:
if (x_event.xbutton.button == 1)
Key_Event(K_MOUSE1, false);
else if (x_event.xbutton.button == 2)
Key_Event(K_MOUSE3, false);
else if (x_event.xbutton.button == 3)
Key_Event(K_MOUSE2, false);
break;
case ConfigureNotify:
//printf("config notify\n");
config_notify_width = x_event.xconfigure.width;
config_notify_height = x_event.xconfigure.height;
config_notify = 1;
break;
default:
if (doShm && x_event.type == x_shmeventtype)
oktodraw = true;
}
if (dowarp)
IN_CenterMouse();
}
// flushes the given rectangles from the view buffer to the screen
@ -1157,7 +1163,7 @@ VID_Update(vrect_t *rects)
Sys_Error("VID_Update: XShmPutImage failed");
oktodraw = false;
while (!oktodraw)
GetEvent();
HandleEvents();
rects = rects->pnext;
}
current_framebuffer = !current_framebuffer;
@ -1230,6 +1236,7 @@ Sys_DisplayWindow (int window)
void
Sys_SendKeyEvents(void)
{
HandleEvents();
}
#if 0