fix the screen offset caused by moving the mouse at just the wrong moment

This commit is contained in:
Bill Currie 2000-10-28 05:08:11 +00:00
parent 0ec5c00c18
commit a3dbf0f9da
3 changed files with 20 additions and 24 deletions

View file

@ -59,5 +59,6 @@ void x11_restore_vidmode (void);
void x11_create_window (int, int);
void x11_grab_keyboard (void);
void x11_set_caption (char *);
void x11_force_view_port (void);
#endif // __CONTEXT_X11_H__

View file

@ -98,8 +98,6 @@ static int xss_interval;
static int xss_blanking;
static int xss_exposures;
static int need_screen_warp;
qboolean
x11_add_event (int event, void (*event_handler) (XEvent *))
{
@ -138,17 +136,6 @@ x11_process_event (void)
oktodraw = 1;
return;
}
#ifdef xHAVE_VIDMODE
if (need_screen_warp) {
int x, y;
XF86VidModeGetViewPort (x_disp, x_screen, &x, &y);
if (x || y) {
XF86VidModeSetViewPort (x_disp, x_screen, 0, 0);
} else {
need_screen_warp = 0;
}
}
#endif
if (event_handlers[x_event.type])
event_handlers[x_event.type] (&x_event);
}
@ -304,7 +291,7 @@ x11_set_vidmode(int width, int height)
printf("%dx%d\n", vidmodes[i]->hdisplay, vidmodes[i]->vdisplay);
}
XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[best_mode]);
XF86VidModeSetViewPort (x_disp, x_screen, 0, 0);
x11_force_view_port ();
}
#endif
}
@ -369,19 +356,10 @@ x11_create_window (int width, int height)
XSetWMProtocols (x_disp, x_win, &aWMDelete, 1);
if (vid_fullscreen->int_val) {
int x, y;
XMoveWindow (x_disp, x_win, 0, 0);
XWarpPointer(x_disp, None, x_win, 0, 0, 0, 0,
vid.width+2, vid.height+2);
need_screen_warp = 1;
#ifdef HAVE_VIDMODE
do {
XF86VidModeSetViewPort (x_disp, x_screen, 0, 0);
poll (0, 0, 50);
XF86VidModeGetViewPort (x_disp, x_screen, &x, &y);
} while (x || y);
#endif
x11_force_view_port ();
}
XMapWindow (x_disp, x_win);
@ -420,3 +398,19 @@ x11_set_caption (char *text)
if (x_disp && x_win && text)
XStoreName (x_disp, x_win, text);
}
void
x11_force_view_port (void)
{
#ifdef HAVE_VIDMODE
int x, y;
if (vid_fullscreen->int_val) {
do {
XF86VidModeSetViewPort (x_disp, x_screen, 0, 0);
poll (0, 0, 50);
XF86VidModeGetViewPort (x_disp, x_screen, &x, &y);
} while (x || y);
}
#endif
}

View file

@ -312,6 +312,7 @@ IN_Commands (void)
if (_windowed_mouse->int_val) { // grab the pointer
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
x11_force_view_port();
#ifdef HAVE_DGA
if (dga_avail && in_dga->int_val && !dga_active) {
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),