X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=vid_glx.c;h=5035a182c07b6dc2c9970591377946ef2a0e61dc;hb=2eb49366c015ba5554486d118d2e5793cd996453;hp=48ab6c8210d8fc2725a22920002707a0408bb5f9;hpb=df8727697622029dd7a03047999ffc19b49e44ea;p=xonotic%2Fdarkplaces.git diff --git a/vid_glx.c b/vid_glx.c index 48ab6c82..5035a182 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -88,10 +88,8 @@ Atom wm_delete_window_atom; static qboolean mouse_avail = true; static qboolean vid_usingmouse = false; -static qboolean vid_usemouse = false; static qboolean vid_usingvsync = false; static qboolean vid_usevsync = false; -static qboolean ignoremousemove = false; static float mouse_x, mouse_y; static int p_mouse_x, p_mouse_y; @@ -104,8 +102,6 @@ qboolean vidmode_ext = false; static int win_x, win_y; -static int scr_width, scr_height; - static XF86VidModeModeInfo **vidmodes; static int num_vidmodes; static qboolean vid_isfullscreen = false; @@ -249,12 +245,11 @@ static Cursor CreateNullCursor(Display *display, Window root) static void IN_Activate (qboolean grab) { - if (!mouse_avail || !vidx11_display || !win) + if (!vidx11_display) return; - if (grab) { - if (!vid_usingmouse) + if (!vid_usingmouse && mouse_avail && win) { XWindowAttributes attribs_1; XSetWindowAttributes attribs_2; @@ -278,7 +273,7 @@ static void IN_Activate (qboolean grab) // unable to query, probably not supported Con_Print( "Failed to detect XF86DGA Mouse\n" ); Cvar_SetValueQuick(&vid_dga, 0); - XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, scr_width / 2, scr_height / 2); + XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); } else { @@ -288,12 +283,12 @@ static void IN_Activate (qboolean grab) } else #endif - XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, scr_width / 2, scr_height / 2); + XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); mouse_x = mouse_y = 0; - ignoremousemove = true; + cl_ignoremousemove = true; vid_usingmouse = true; } } @@ -302,17 +297,18 @@ static void IN_Activate (qboolean grab) if (vid_usingmouse) { #ifndef __APPLE__ - if (vid_dga.integer == 1) + if (vid_dga.integer) XF86DGADirectVideo(vidx11_display, DefaultScreen(vidx11_display), 0); #endif XUngrabPointer(vidx11_display, CurrentTime); XUngrabKeyboard(vidx11_display, CurrentTime); - // inviso cursor - XUndefineCursor(vidx11_display, win); + // inviso cursor + if (win) + XUndefineCursor(vidx11_display, win); - ignoremousemove = true; + cl_ignoremousemove = true; vid_usingmouse = false; } } @@ -364,7 +360,7 @@ static void HandleEvents(void) { mouse_x += event.xmotion.x - p_mouse_x; mouse_y += event.xmotion.y - p_mouse_y; - if (abs(scr_width/2 - event.xmotion.x) > scr_width / 4 || abs(scr_height/2 - event.xmotion.y) > scr_height / 4) + if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4) dowarp = true; } p_mouse_x = event.xmotion.x; @@ -520,18 +516,10 @@ static void HandleEvents(void) if (dowarp) { /* move the mouse to the window center again */ - p_mouse_x = scr_width / 2; - p_mouse_y = scr_height / 2; + p_mouse_x = vid.width / 2; + p_mouse_y = vid.height / 2; XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, p_mouse_x, p_mouse_y); } - - // if told to ignore one mouse move, do so - if (ignoremousemove) - { - ignoremousemove = false; - mouse_x = 0; - mouse_y = 0; - } } static void *prjobj = NULL; @@ -576,12 +564,10 @@ void VID_Shutdown(void) if (!ctx || !vidx11_display) return; - vid_hidden = true; - vid_usingmouse = false; if (vidx11_display) { - VID_RestoreSystemGamma(); IN_Activate(false); + VID_RestoreSystemGamma(); // FIXME: glXDestroyContext here? if (vid_isfullscreen) @@ -590,6 +576,7 @@ void VID_Shutdown(void) XDestroyWindow(vidx11_display, win); XCloseDisplay(vidx11_display); } + vid_hidden = true; vid_isfullscreen = false; vidx11_display = NULL; win = 0; @@ -621,20 +608,10 @@ void InitSig(void) signal(SIGTERM, signal_handler); } -/* -================= -VID_GetWindowSize -================= -*/ -void VID_GetWindowSize (int *x, int *y, int *width, int *height) -{ - *x = *y = 0; - *width = scr_width; - *height = scr_height; -} - void VID_Finish (void) { + qboolean vid_usemouse; + vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable; if (vid_usingvsync != vid_usevsync && gl_videosyncavailable) { @@ -860,9 +837,6 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) XSync(vidx11_display, False); - scr_width = width; - scr_height = height; - if ((qglGetString = GL_GetProcAddress("glGetString")) == NULL) Sys_Error("glGetString not found in %s", gl_driver); @@ -886,7 +860,6 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) vid_usingmouse = false; vid_usingvsync = false; - ignoremousemove = true; vid_hidden = false; vid_activewindow = true; GL_Init();