diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-31 15:05:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-31 15:05:09 +0400 |
commit | dbf54dacf7e3fabe6ccb0e36a1743c91ac445b28 (patch) | |
tree | 6bdfa69792ad78750fe5bee51a63e1fd70e3d2ff /intern | |
parent | 73f301c3a8a28dd25ea850a54d968fc6c4f2b83e (diff) |
Add Xinerama support for GHOST_GetMainDisplayDimensions() so X11 works as it should (previously would include all monitors).
Now the active monitor size is used on startup.
Currently the cursor position is checked for intersection with the monitor bounds to find the active screen.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/CMakeLists.txt | 10 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 48 |
2 files changed, 56 insertions, 2 deletions
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index ea09987c564..c6269d49b47 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -271,6 +271,16 @@ elseif(UNIX) if(WITH_X11_XINPUT) add_definitions(-DWITH_X11_XINPUT) + list(APPEND INC_SYS + ${X11_Xinput_INCLUDE_PATH} + ) + endif() + + if(WITH_X11_XINERAMA) + add_definitions(-DWITH_X11_XINERAMA) + list(APPEND INC_SYS + ${X11_Xinerama_INCLUDE_PATH} + ) endif() elseif(WIN32) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 1e815870fc9..6902b2e8347 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -50,6 +50,10 @@ # include "GHOST_DropTargetX11.h" #endif +#ifdef WITH_X11_XINERAMA +# include "X11/extensions/Xinerama.h" +#endif + #include "GHOST_Debug.h" #include <X11/Xatom.h> @@ -237,8 +241,48 @@ getMainDisplayDimensions( GHOST_TUns32& height) const { if (m_display) { - width = DisplayWidth(m_display, DefaultScreen(m_display)); - height = DisplayHeight(m_display, DefaultScreen(m_display)); + +#ifdef WITH_X11_XINERAMA + GHOST_TInt32 m_x = 1, m_y = 1; + getCursorPosition(m_x, m_y); + + /* NOTE, no way to select a primary monitor, uses the first */ + bool success = false; + int dummy1, dummy2; + if (XineramaQueryExtension(m_display, &dummy1, &dummy2)) { + if (XineramaIsActive(m_display)) { + int heads = 0; + XineramaScreenInfo *p = XineramaQueryScreens(m_display, &heads); + /* with a single head, all dimensions is fine */ + if (heads > 1) { + int i; + for (i = 0; i < heads; i++) { + if ((m_x >= p[i].x_org) && (m_x <= p[i].x_org + p[i].width) && + (m_y >= p[i].y_org) && (m_y <= p[i].y_org + p[i].height)) + { + width = p[i].width; + height = p[i].height; + break; + } + } + /* highly unlikely! */ + if (i == heads) { + width = p[0].width; + height = p[0].height; + } + success = true; + } + XFree(p); + } + } + + if (success) { + return; + } +#endif + + /* fallback to all */ + getAllDisplayDimensions(width, height); } } |