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
This commit is contained in:
Glenn Rice 2010-02-17 17:53:08 +00:00
parent bd1b12e357
commit 634f6e512e
6 changed files with 54 additions and 18 deletions

View File

@ -148,7 +148,14 @@ void *GetWindowHandle()
{ {
return g_pWindowHandle; return g_pWindowHandle;
} }
#if defined HAVE_X11 && HAVE_X11
void *GetXWindow()
{
return g_pXWindow;
}
#endif
bool GetRealWiimote() bool GetRealWiimote()
{ {
return g_bRealWiimote; return g_bRealWiimote;

View File

@ -59,6 +59,9 @@ namespace Core
extern SCoreStartupParameter g_CoreStartupParameter; extern SCoreStartupParameter g_CoreStartupParameter;
void* GetWindowHandle(); void* GetWindowHandle();
#if defined HAVE_X11 && HAVE_X11
void* GetXWindow();
#endif
bool GetRealWiimote(); bool GetRealWiimote();
extern bool bReadTrace; extern bool bReadTrace;

View File

@ -50,6 +50,10 @@
#include <wx/datetime.h> // wxWidgets #include <wx/datetime.h> // wxWidgets
#if defined HAVE_X11 && HAVE_X11
#include <X11/Xlib.h>
#endif
// Resources // Resources
extern "C" { extern "C" {
@ -906,9 +910,32 @@ wxAuiNotebook* CFrame::CreateEmptyNotebook()
return NB; 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) 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 // 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 // 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. // the main window to become unresponsive, so we have to avoid that.

View File

@ -660,9 +660,7 @@ bool IsFocus()
Window FocusWin; Window FocusWin;
int Revert; int Revert;
XGetInputFocus(GCdisplay, &FocusWin, &Revert); XGetInputFocus(GCdisplay, &FocusWin, &Revert);
XWindowAttributes WinAttribs; return (GLWin != 0 && GLWin == FocusWin);
XGetWindowAttributes (GCdisplay, GLWin, &WinAttribs);
return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect));
#else #else
return true; return true;
#endif #endif

View File

@ -122,7 +122,7 @@ void UpdateFPSDisplay(const char *text)
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
void CreateXWindow (void) void CreateXWindow (void)
{ {
Atom wmDelete; Atom wmProtocols[3];
int width, height; int width, height;
if (GLWin.fs) if (GLWin.fs)
@ -153,8 +153,10 @@ void CreateXWindow (void)
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen), GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.vi->screen),
0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual, 0, 0, width, height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr); CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &GLWin.attr);
wmDelete = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
XSetWMProtocols(GLWin.dpy, GLWin.win, &wmDelete, 1); 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); XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
XMapRaised(GLWin.dpy, GLWin.win); XMapRaised(GLWin.dpy, GLWin.win);
if (GLWin.fs) if (GLWin.fs)
@ -162,6 +164,7 @@ void CreateXWindow (void)
XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
XGrabPointer(GLWin.dpy, GLWin.win, True, NULL, XGrabPointer(GLWin.dpy, GLWin.win, True, NULL,
GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime); GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime);
XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime);
} }
XSync(GLWin.dpy, True); XSync(GLWin.dpy, True);
} }
@ -186,16 +189,17 @@ void DestroyXWindow(void)
GLWin.deskSize, GLWin.screenRotation, CurrentTime); GLWin.deskSize, GLWin.screenRotation, CurrentTime);
#endif #endif
} }
XUndefineCursor(GLWin.dpy, GLWin.win);
XUnmapWindow(GLWin.dpy, GLWin.win); XUnmapWindow(GLWin.dpy, GLWin.win);
XSync(GLWin.dpy, True); XSync(GLWin.dpy, True);
} }
void ToggleFullscreenMode (void) void ToggleFullscreenMode (void)
{ {
DestroyXWindow(); DestroyXWindow();
GLWin.fs = !GLWin.fs; GLWin.fs = !GLWin.fs;
CreateXWindow(); CreateXWindow();
OpenGL_MakeCurrent(); OpenGL_MakeCurrent();
} }
#endif #endif
@ -623,6 +627,8 @@ void OpenGL_Update()
case ClientMessage: case ClientMessage:
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False)) if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
g_VideoInitialize.pKeyPress(0x1b, False, False); g_VideoInitialize.pKeyPress(0x1b, False, False);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False))
ToggleFullscreenMode();
return; return;
break; break;
default: default:
@ -678,10 +684,7 @@ void OpenGL_Shutdown()
XRRFreeScreenConfigInfo(GLWin.screenConfig); XRRFreeScreenConfigInfo(GLWin.screenConfig);
#endif #endif
if (g_Config.bHideCursor) if (g_Config.bHideCursor)
{ XFreeCursor(GLWin.dpy, GLWin.blankCursor);
XUndefineCursor(GLWin.dpy, GLWin.win);
XFreeCursor(GLWin.dpy, GLWin.blankCursor);
}
if (GLWin.ctx) if (GLWin.ctx)
{ {
glXDestroyContext(GLWin.dpy, GLWin.ctx); glXDestroyContext(GLWin.dpy, GLWin.ctx);

View File

@ -419,9 +419,7 @@ bool IsFocus()
Window FocusWin; Window FocusWin;
int Revert; int Revert;
XGetInputFocus(WMdisplay, &FocusWin, &Revert); XGetInputFocus(WMdisplay, &FocusWin, &Revert);
XWindowAttributes WinAttribs; return (GLWin != 0 && GLWin == FocusWin);
XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs);
return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect));
#else #else
return true; return true;
#endif #endif