X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=vid_glx.c;h=291f5d5a10cdddeb5a4b414f3b9d936b56b5a850;hb=6c4d997a497cb5afde74b4bf16f6a9ade5aca37e;hp=150736df5b9ae4d5f874c33ad5cbf8cc1d406c5e;hpb=6ad9cece24f83d3cea1b1f161eccb188daa01fe3;p=xonotic%2Fdarkplaces.git diff --git a/vid_glx.c b/vid_glx.c index 150736df..291f5d5a 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -17,12 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -//#include -//#include -//#include -//#include -//#include -//#include #include #include @@ -199,6 +193,7 @@ static int XLateKey(XKeyEvent *ev, char *ascii) case XK_Alt_L: case XK_Meta_L: + case XK_ISO_Level3_Shift: case XK_Alt_R: case XK_Meta_R: key = K_ALT; break; @@ -207,7 +202,7 @@ static int XLateKey(XKeyEvent *ev, char *ascii) case XK_Insert:key = K_INS; break; case XK_KP_Insert: key = K_KP_INS; break; - case XK_KP_Multiply: key = '*'; break; + case XK_KP_Multiply: key = K_KP_MULTIPLY; break; case XK_KP_Add: key = K_KP_PLUS; break; case XK_KP_Subtract: key = K_KP_MINUS; break; case XK_KP_Divide: key = K_KP_SLASH; break; @@ -292,7 +287,8 @@ static void IN_Activate (qboolean grab) #endif XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); - XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); + if (vid_grabkeyboard.integer || vid_isfullscreen) + XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); mouse_x = mouse_y = 0; cl_ignoremousemove = true; @@ -429,23 +425,21 @@ static void HandleEvents(void) break; case DestroyNotify: // window has been destroyed - Sys_Quit(); + Sys_Quit(0); break; case ClientMessage: // window manager messages if ((event.xclient.format == 32) && ((unsigned int)event.xclient.data.l[0] == wm_delete_window_atom)) - Sys_Quit(); + Sys_Quit(0); break; case MapNotify: // window restored vid_hidden = false; - vid_activewindow = false; VID_RestoreSystemGamma(); break; case UnmapNotify: // window iconified/rolledup/whatever vid_hidden = true; - vid_activewindow = false; VID_RestoreSystemGamma(); break; case FocusIn: @@ -498,7 +492,7 @@ static int GL_OpenLibrary(const char *name) Con_Printf("Unable to open symbol list for %s\n", name); return false; } - strcpy(gl_driver, name); + strlcpy(gl_driver, name, sizeof(gl_driver)); return true; } @@ -543,8 +537,7 @@ void signal_handler(int sig) { Con_Printf("Received signal %d, exiting...\n", sig); VID_RestoreSystemGamma(); - Sys_Quit(); - exit(0); + Sys_Quit(1); } void InitSig(void) @@ -573,9 +566,9 @@ void VID_Finish (qboolean allowmousegrab) Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n"); } -// handle the mouse state when windowed if that's changed + // handle the mouse state when windowed if that's changed vid_usemouse = false; - if (allowmousegrab && vid_mouse.integer && !key_consoleactive && !cls.demoplayback) + if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback)) vid_usemouse = true; if (!vid_activewindow) vid_usemouse = false; @@ -585,9 +578,12 @@ void VID_Finish (qboolean allowmousegrab) if (r_render.integer) { + CHECKGLERROR if (r_speeds.integer || gl_finish.integer) - qglFinish(); - qglXSwapBuffers(vidx11_display, win); + { + qglFinish();CHECKGLERROR + } + qglXSwapBuffers(vidx11_display, win);CHECKGLERROR } if (vid_x11_hardwaregammasupported) @@ -612,11 +608,11 @@ void VID_Init(void) #endif InitSig(); // trap evil signals // COMMANDLINEOPTION: Input: -nomouse disables mouse support (see also vid_mouse cvar) - if (COM_CheckParm ("-nomouse") || COM_CheckParm("-safe")) + if (COM_CheckParm ("-nomouse")) mouse_avail = false; } -void VID_BuildGLXAttrib(int *attrib, int stencil) +void VID_BuildGLXAttrib(int *attrib, qboolean stencil, qboolean stereobuffer) { *attrib++ = GLX_RGBA; *attrib++ = GLX_RED_SIZE;*attrib++ = 1; @@ -630,10 +626,12 @@ void VID_BuildGLXAttrib(int *attrib, int stencil) *attrib++ = GLX_STENCIL_SIZE;*attrib++ = 8; *attrib++ = GLX_ALPHA_SIZE;*attrib++ = 1; } + if (stereobuffer) + *attrib++ = GLX_STEREO; *attrib++ = None; } -int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate) +int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer) { int i; int attrib[32]; @@ -691,7 +689,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate return false; } - VID_BuildGLXAttrib(attrib, bpp == 32); + VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer); visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib); if (!visinfo) { @@ -845,6 +843,20 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate void Sys_SendKeyEvents(void) { + static qboolean sound_active = true; + + // enable/disable sound on focus gain/loss + if (!vid_activewindow && sound_active) + { + S_BlockSound (); + sound_active = false; + } + else if (vid_activewindow && !sound_active) + { + S_UnblockSound (); + sound_active = true; + } + HandleEvents(); }