From 2c7b4848696944e8029d52c3b1435a3f3ba29a67 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 17 Feb 2010 23:15:58 +0000 Subject: [PATCH] Fix software plugin in linux. I broke it in revision 5048. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5077 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/PluginSpecs/pluginspecs_video.h | 1 + .../Plugin_VideoSoftware/Src/GLUtil.cpp | 37 +++++++------------ .../Plugin_VideoSoftware/Src/Renderer.cpp | 3 ++ .../Plugins/Plugin_VideoSoftware/Src/main.cpp | 1 + 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index 4b7e282758..c11b8b4db7 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -5,6 +5,7 @@ #ifndef _VIDEO_H_INCLUDED__ #define _VIDEO_H_INCLUDED__ +#include "Common.h" #include "PluginSpecs.h" #include "ExportProlog.h" diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index 76b20f4c41..5523d2eba0 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -385,7 +385,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight /* create a fullscreen window */ GLWin.attr.override_redirect = True; - GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | KeyReleaseMask | ButtonReleaseMask | StructureNotifyMask; + GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask; GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), 0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, @@ -393,7 +393,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight XWarpPointer(GLWin.dpy, None, GLWin.win, 0, 0, 0, 0, 0, 0); XMapRaised(GLWin.dpy, GLWin.win); XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); - XGrabPointer(GLWin.dpy, GLWin.win, True, ButtonPressMask, + XGrabPointer(GLWin.dpy, GLWin.win, True, NULL, GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); } else { @@ -413,7 +413,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight //int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2; // create a window in window mode - GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | KeyReleaseMask | ButtonReleaseMask | + GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | ResizeRedirectMask; GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), 0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual, @@ -425,6 +425,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight "GPU", None, NULL, 0, NULL); XMapRaised(GLWin.dpy, GLWin.win); } + g_VideoInitialize.pXWindow = (Window *) &GLWin.win; #endif return true; } @@ -455,8 +456,8 @@ bool OpenGL_MakeCurrent() } // better for pad plugin key input (thc) - XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | ButtonPressMask | KeyReleaseMask | ButtonReleaseMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask | - FocusChangeMask ); + XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask | + StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask ); #endif return true; } @@ -507,7 +508,6 @@ void OpenGL_Update() // We just check all of our events here XEvent event; KeySym key; - static RECT rcWindow; static bool ShiftPressed = false; static bool ControlPressed = false; static int FKeyPressed = -1; @@ -525,8 +525,6 @@ void OpenGL_Update() ShiftPressed = false; else if(key == XK_Control_L || key == XK_Control_R) ControlPressed = false; - else - XPutBackEvent(GLWin.dpy, &event); } break; case KeyPress: @@ -538,13 +536,10 @@ void OpenGL_Update() ShiftPressed = true; else if(key == XK_Control_L || key == XK_Control_R) ControlPressed = true; - else - XPutBackEvent(GLWin.dpy, &event); } break; case ButtonPress: case ButtonRelease: - XPutBackEvent(GLWin.dpy, &event); break; case ConfigureNotify: Window winDummy; @@ -553,20 +548,13 @@ void OpenGL_Update() &GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth); s_backbuffer_width = GLWin.width; s_backbuffer_height = GLWin.height; - rcWindow.left = 0; - rcWindow.top = 0; - rcWindow.right = GLWin.width; - rcWindow.bottom = GLWin.height; break; - case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest chance is that it's a close event though - Shutdown(); // Calling from here since returning false does nothing + case ClientMessage: + if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False)) + g_VideoInitialize.pKeyPress(0x1b, False, False); return; break; default: - //TODO: Should we put the event back if we don't handle it? - // I think we handle all the needed ones, the rest shouldn't matter - // But to be safe, let's but them back anyway - //XPutBackEvent(GLWin.dpy, &event); break; } } @@ -614,11 +602,12 @@ void OpenGL_Shutdown() if ((GLWin.dpy != NULL) && GLWin.fs) { XUngrabKeyboard (GLWin.dpy, CurrentTime); XUngrabPointer (GLWin.dpy, CurrentTime); - XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), - GLWin.deskSize, GLWin.screenRotation, CurrentTime); - XRRFreeScreenConfigInfo(GLWin.screenConfig); + XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen), + GLWin.deskSize, GLWin.screenRotation, CurrentTime); + XRRFreeScreenConfigInfo(GLWin.screenConfig); } #endif + printf ("Unmapping window\n"); if (GLWin.ctx) { if (!glXMakeCurrent(GLWin.dpy, None, NULL)) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp index 14b909f4fb..69fc22ce7f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp @@ -40,6 +40,9 @@ void Renderer::Init(SVideoInitialize *_pVideoInitialize) _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; +#if defined(HAVE_X11) && HAVE_X11 + _pVideoInitialize->pXWindow = g_VideoInitialize.pXWindow; +#endif } void Renderer::Shutdown() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp index c832c6270b..6640f1faa5 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp @@ -98,6 +98,7 @@ void EmuStateChange(PLUGIN_EMUSTATE newState) void Shutdown(void) { + OpenGL_Shutdown(); } // This is called after Video_Initialize() from the Core