From 17d39e3db289ba4cd535c8f2558501420c65ee99 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 12 May 2017 16:26:07 +0100 Subject: [PATCH] From Don Burns, add use of Xinerama to ensure full screen goes across all screens. --- src/osgViewer/CMakeLists.txt | 16 +++++ src/osgViewer/GraphicsWindowX11.cpp | 102 ++++++++++++++++++++++++---- 2 files changed, 106 insertions(+), 12 deletions(-) diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index f2283947b..3a13934f4 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -173,14 +173,23 @@ ELSE() # X11 for everybody else INCLUDE(FindPkgConfig OPTIONAL) IF(PKG_CONFIG_FOUND) + PKG_CHECK_MODULES(XRANDR xrandr) IF(XRANDR_FOUND) OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support for GraphicsWindowX11." ON) ELSE() SET(OSGVIEWER_USE_XRANDR OFF) ENDIF() + + PKG_CHECK_MODULES(XINERAMA xinerama) + IF(XINERAMA_FOUND) + SET(OSGVIEWER_USE_XINERAMA ON) + ELSE() + SET(OSGVIEWER_USE_XINERAMA OFF) + ENDIF() ELSE() SET(OSGVIEWER_USE_XRANDR OFF) + SET(OSGVIEWER_USE_XINERAMA OFF) ENDIF() SET(TARGET_H_NO_MODULE_INSTALL @@ -205,6 +214,13 @@ ELSE() ENDIF() ENDIF() + IF(OSGVIEWER_USE_XINERAMA) + ADD_DEFINITIONS(-DOSGVIEWER_USE_XINERAMA) + SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XINERAMA_INCLUDE_DIRS} ) + SET(LIB_EXTRA_LIBS -lXinerama ${LIB_EXTRA_LIBS}) + ENDIF() + + # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard IF(APPLE) # hack for finding the iphone opengl es lib IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp index a3d4552ca..02729a8dd 100644 --- a/src/osgViewer/GraphicsWindowX11.cpp +++ b/src/osgViewer/GraphicsWindowX11.cpp @@ -38,6 +38,10 @@ #include #endif +#ifdef OSGVIEWER_USE_XINERAMA +#include +#endif + #include using namespace osgViewer; @@ -382,23 +386,95 @@ bool GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded(Display* display, in Atom netWMStateAtom = XInternAtom(display, "_NET_WM_STATE", True); Atom netWMStateFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True); + OSG_NOTICE<<"GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded()"< maxx ) + { + span[RightMost] = xi[i].screen_number; + maxx = xi[i].x_org; + } + + if( xi[i].y_org < miny ) + { + span[TopMost] = xi[i].screen_number; + miny = xi[i].y_org; + } + + if( xi[i].y_org > maxy ) + { + span[BottomMost] = xi[i].screen_number; + maxy = xi[i].y_org; + } + } + XFree(xi); + + Atom fullmons = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", True); + if( fullmons != None ) + { + XEvent xev; + xev.type = ClientMessage; + xev.xclient.window = _window; + xev.xclient.message_type = fullmons; + xev.xclient.format = 32; + xev.xclient.data.l[0] = span[TopMost]; + xev.xclient.data.l[1] = span[BottomMost]; + xev.xclient.data.l[2] = span[LeftMost]; + xev.xclient.data.l[3] = span[RightMost]; + xev.xclient.data.l[4] = 0; + + XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); + } + } +#endif return true; } + return false; } @@ -1328,6 +1404,7 @@ bool GraphicsWindowX11::checkEvents() bool isModifier = keyMapGetKey(modMap, key); if (!isModifier) forceKey(key, eventTime, false); } + needNewWindowSize = true; // release modifier keys for (unsigned int key = 8; key < 256; key++) @@ -1367,6 +1444,7 @@ bool GraphicsWindowX11::checkEvents() bool isPressed = keyMapGetKey(keyMap, key); if (!isPressed) forceKey(key, eventTime, false); } + needNewWindowSize = true; // press/release modifier keys for (unsigned int key = 8; key < 256; key++)