mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 12:40:42 +00:00
break out some duplicated code into a function and get the window coords
"properly" (for this mess I'm not sure I'm willing to call code:)
This commit is contained in:
parent
5a944f4098
commit
6f88e4e343
1 changed files with 20 additions and 35 deletions
|
@ -106,7 +106,6 @@ static qboolean vidmode_avail = false;
|
||||||
|
|
||||||
static qboolean vidmode_active = false;
|
static qboolean vidmode_active = false;
|
||||||
|
|
||||||
qboolean vid_fullscreen_active;
|
|
||||||
static qboolean vid_context_created = false;
|
static qboolean vid_context_created = false;
|
||||||
static int window_x, window_y, window_saved;
|
static int window_x, window_y, window_saved;
|
||||||
|
|
||||||
|
@ -156,6 +155,21 @@ X11_ProcessEventProxy(XEvent *x_event)
|
||||||
event_handlers[x_event->type] (x_event);
|
event_handlers[x_event->type] (x_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
X11_WaitForEvent (int event)
|
||||||
|
{
|
||||||
|
XEvent ev;
|
||||||
|
int type;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
XMaskEvent (x_disp, StructureNotifyMask, &ev);
|
||||||
|
type = ev.type;
|
||||||
|
X11_ProcessEventProxy (&ev);
|
||||||
|
if (type == event)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
X11_ProcessEvent (void)
|
X11_ProcessEvent (void)
|
||||||
{
|
{
|
||||||
|
@ -255,18 +269,8 @@ X11_ForceMove (int x, int y)
|
||||||
|
|
||||||
XMoveWindow (x_disp, x_win, x, y);
|
XMoveWindow (x_disp, x_win, x, y);
|
||||||
XFlush(x_disp);
|
XFlush(x_disp);
|
||||||
while (1) {
|
X11_WaitForEvent (ConfigureNotify);
|
||||||
XEvent ev;
|
X11_GetWindowCoords (&nx, &ny);
|
||||||
XMaskEvent (x_disp,StructureNotifyMask,&ev);
|
|
||||||
if (ev.type == ConfigureNotify) {
|
|
||||||
nx = ev.xconfigure.x;
|
|
||||||
ny = ev.xconfigure.y;
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
}
|
|
||||||
// X11_GetWindowCoords (&nx, &ny);
|
|
||||||
nx -= x;
|
nx -= x;
|
||||||
ny -= y;
|
ny -= y;
|
||||||
if (nx == 0 || ny == 0) {
|
if (nx == 0 || ny == 0) {
|
||||||
|
@ -285,15 +289,7 @@ X11_ForceMove (int x, int y)
|
||||||
XMoveWindow (x_disp, x_win, x, y);
|
XMoveWindow (x_disp, x_win, x, y);
|
||||||
XSync (x_disp, false);
|
XSync (x_disp, false);
|
||||||
// this is the best we can do.
|
// this is the best we can do.
|
||||||
while (1) {
|
X11_WaitForEvent (ConfigureNotify);
|
||||||
XEvent ev;
|
|
||||||
XMaskEvent (x_disp, StructureNotifyMask, &ev);
|
|
||||||
if (ev.type == ConfigureNotify) {
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -394,15 +390,12 @@ X11_UpdateFullscreen (cvar_t *fullscreen)
|
||||||
IN_UpdateGrab (in_grab);
|
IN_UpdateGrab (in_grab);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
IN_UpdateGrab (in_grab);
|
|
||||||
|
|
||||||
if (X11_GetWindowCoords (&window_x, &window_y))
|
if (X11_GetWindowCoords (&window_x, &window_y))
|
||||||
window_saved = 1;
|
window_saved = 1;
|
||||||
|
|
||||||
X11_SetVidMode (scr_width, scr_height);
|
X11_SetVidMode (scr_width, scr_height);
|
||||||
|
|
||||||
IN_UpdateGrab (in_grab); // FIXME: why are there two of these?
|
|
||||||
|
|
||||||
if (!vidmode_active) {
|
if (!vidmode_active) {
|
||||||
window_saved = 0;
|
window_saved = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -411,6 +404,7 @@ X11_UpdateFullscreen (cvar_t *fullscreen)
|
||||||
X11_ForceMove (0, 0);
|
X11_ForceMove (0, 0);
|
||||||
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, scr_width / 2,
|
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, scr_width / 2,
|
||||||
scr_height / 2);
|
scr_height / 2);
|
||||||
|
IN_UpdateGrab (in_grab);
|
||||||
// Done in X11_SetVidMode but moved the window since then
|
// Done in X11_SetVidMode but moved the window since then
|
||||||
X11_ForceViewPort ();
|
X11_ForceViewPort ();
|
||||||
}
|
}
|
||||||
|
@ -476,16 +470,7 @@ X11_CreateWindow (int width, int height)
|
||||||
|
|
||||||
XMapWindow (x_disp, x_win);
|
XMapWindow (x_disp, x_win);
|
||||||
|
|
||||||
while (1) {
|
X11_WaitForEvent (MapNotify);
|
||||||
XEvent ev;
|
|
||||||
|
|
||||||
XMaskEvent (x_disp, StructureNotifyMask, &ev);
|
|
||||||
if (ev.type == MapNotify) {
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
X11_ProcessEventProxy (&ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
vid_context_created = true;
|
vid_context_created = true;
|
||||||
if (vid_fullscreen->int_val) {
|
if (vid_fullscreen->int_val) {
|
||||||
|
|
Loading…
Reference in a new issue