Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 54214) +++ CMakeLists.txt (working copy) @@ -166,6 +166,7 @@ if(UNIX AND NOT APPLE) option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON) + option(WITH_X11_XINERAMA "Enable multi-head support" ON) option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON) option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON) @@ -414,6 +415,7 @@ set(WITH_GHOST_XDND OFF) set(WITH_X11_XF86VMODE OFF) set(WITH_X11_XINPUT OFF) + set(WITH_X11_XINERAMA OFF) endif() if(MINGW) @@ -800,6 +802,10 @@ set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinput_LIB}") endif() + if(WITH_X11_XINERAMA) + set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinerama_LIB}") + endif() + if(WITH_X11_XF86VMODE) # XXX, why dont cmake make this available? FIND_LIBRARY(X11_Xxf86vmode_LIB Xxf86vm ${X11_LIB_SEARCH_PATH}) Index: intern/ghost/CMakeLists.txt =================================================================== --- intern/ghost/CMakeLists.txt (revision 54214) +++ intern/ghost/CMakeLists.txt (working copy) @@ -273,6 +273,10 @@ add_definitions(-DWITH_X11_XINPUT) endif() + if(WITH_X11_XINERAMA) + add_definitions(-DWITH_X11_XINERAMA) + endif() + elseif(WIN32) ## Warnings as errors, this is too strict! #if(MSVC) Index: intern/ghost/intern/GHOST_SystemX11.cpp =================================================================== --- intern/ghost/intern/GHOST_SystemX11.cpp (revision 54214) +++ intern/ghost/intern/GHOST_SystemX11.cpp (working copy) @@ -50,6 +50,10 @@ # include "GHOST_DropTargetX11.h" #endif +#ifdef WITH_X11_XINERAMA +# include "X11/extensions/Xinerama.h" +#endif + #include "GHOST_Debug.h" #include @@ -237,6 +241,32 @@ GHOST_TUns32& height) const { if (m_display) { + +#ifdef WITH_X11_XINERAMA + /* 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); + if (heads > 0) { + for (int x = 0; x < heads; x++) { + width = p[x].width; + height = p[x].height; + break; + } + success = true; + } + XFree(p); + } + } + + if (success) { + return; + } +#endif + width = DisplayWidth(m_display, DefaultScreen(m_display)); height = DisplayHeight(m_display, DefaultScreen(m_display)); }