From 634f6e512ee5a546c262a9bda4d3a0cb5a39f887 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 17 Feb 2010 17:53:08 +0000 Subject: [PATCH] Minor tweaks to fullscreen in linux, and make FullScr button in GUI work. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5074 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 9 ++++++- Source/Core/Core/Src/Core.h | 3 +++ Source/Core/DolphinWX/Src/Frame.cpp | 27 +++++++++++++++++++ Source/Plugins/Plugin_GCPad/Src/GCPad.cpp | 4 +-- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 25 +++++++++-------- Source/Plugins/Plugin_Wiimote/Src/main.cpp | 4 +-- 6 files changed, 54 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 4a0d092595..6e38a658eb 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -148,7 +148,14 @@ void *GetWindowHandle() { return g_pWindowHandle; } - + +#if defined HAVE_X11 && HAVE_X11 +void *GetXWindow() + { + return g_pXWindow; + } +#endif + bool GetRealWiimote() { return g_bRealWiimote; diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index a63aa8c60b..4096cc191f 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -59,6 +59,9 @@ namespace Core extern SCoreStartupParameter g_CoreStartupParameter; void* GetWindowHandle(); +#if defined HAVE_X11 && HAVE_X11 + void* GetXWindow(); +#endif bool GetRealWiimote(); extern bool bReadTrace; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 71c3b055bb..48b254382e 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -50,6 +50,10 @@ #include // wxWidgets +#if defined HAVE_X11 && HAVE_X11 +#include +#endif + // Resources extern "C" { @@ -906,9 +910,32 @@ wxAuiNotebook* CFrame::CreateEmptyNotebook() return NB; } +#if defined HAVE_X11 && HAVE_X11 +void X11_ShowFullScreen(bool bF) +{ + XEvent event; + Display *dpy = (Display *)Core::GetWindowHandle(); + Window win = *(Window *)Core::GetXWindow(); + + // Init X event structure for TOGGLE_FULLSCREEN client message + event.xclient.type = ClientMessage; + event.xclient.format = 32; + event.xclient.data.l[0] = XInternAtom(dpy, "TOGGLE_FULLSCREEN", False);; + + // Send the event + if (!XSendEvent(dpy, win, False, False, &event)) + { + ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n"); + } +} +#endif void CFrame::DoFullscreen(bool bF) { +#if defined HAVE_X11 && HAVE_X11 + if ((Core::GetState() == Core::CORE_RUN) && !m_bModalDialogOpen) + X11_ShowFullScreen(bF); +#endif // Only switch this to fullscreen if we're rendering to main AND if we're running a game // plus if a modal dialog is open, this will still process the keyboard events, and may cause // the main window to become unresponsive, so we have to avoid that. diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp index 53c95084e6..4f4282a363 100644 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp @@ -660,9 +660,7 @@ bool IsFocus() Window FocusWin; int Revert; XGetInputFocus(GCdisplay, &FocusWin, &Revert); - XWindowAttributes WinAttribs; - XGetWindowAttributes (GCdisplay, GLWin, &WinAttribs); - return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect)); + return (GLWin != 0 && GLWin == FocusWin); #else return true; #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index a677e99141..48e8d2f1cc 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -122,7 +122,7 @@ void UpdateFPSDisplay(const char *text) #if defined(HAVE_X11) && HAVE_X11 void CreateXWindow (void) { - Atom wmDelete; + Atom wmProtocols[3]; int width, height; if (GLWin.fs) @@ -153,8 +153,10 @@ void CreateXWindow (void) GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen), 0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr); - wmDelete = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); - XSetWMProtocols(GLWin.dpy, GLWin.win, &wmDelete, 1); + wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); + wmProtocols[1] = XInternAtom(GLWin.dpy, "WM_TAKE_FOCUS", True); + wmProtocols[2] = XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False); + XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3); XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL); XMapRaised(GLWin.dpy, GLWin.win); if (GLWin.fs) @@ -162,6 +164,7 @@ void CreateXWindow (void) XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabPointer(GLWin.dpy, GLWin.win, True, NULL, GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); + XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime); } XSync(GLWin.dpy, True); } @@ -186,16 +189,17 @@ void DestroyXWindow(void) GLWin.deskSize, GLWin.screenRotation, CurrentTime); #endif } + XUndefineCursor(GLWin.dpy, GLWin.win); XUnmapWindow(GLWin.dpy, GLWin.win); XSync(GLWin.dpy, True); } void ToggleFullscreenMode (void) { - DestroyXWindow(); - GLWin.fs = !GLWin.fs; - CreateXWindow(); - OpenGL_MakeCurrent(); + DestroyXWindow(); + GLWin.fs = !GLWin.fs; + CreateXWindow(); + OpenGL_MakeCurrent(); } #endif @@ -623,6 +627,8 @@ void OpenGL_Update() case ClientMessage: if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False)) g_VideoInitialize.pKeyPress(0x1b, False, False); + if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False)) + ToggleFullscreenMode(); return; break; default: @@ -678,10 +684,7 @@ void OpenGL_Shutdown() XRRFreeScreenConfigInfo(GLWin.screenConfig); #endif if (g_Config.bHideCursor) - { - XUndefineCursor(GLWin.dpy, GLWin.win); - XFreeCursor(GLWin.dpy, GLWin.blankCursor); - } + XFreeCursor(GLWin.dpy, GLWin.blankCursor); if (GLWin.ctx) { glXDestroyContext(GLWin.dpy, GLWin.ctx); diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 3bcb2cf177..6656d35ec9 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -419,9 +419,7 @@ bool IsFocus() Window FocusWin; int Revert; XGetInputFocus(WMdisplay, &FocusWin, &Revert); - XWindowAttributes WinAttribs; - XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs); - return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect)); + return (GLWin != 0 && GLWin == FocusWin); #else return true; #endif