Commits

Philipp Lohmann [pl]  committed 9b4ee3f

vcl116: #i112421# use gdk default monitor if available (thanks cmc!)

  • Participants
  • Parent commits 22a9273

Comments (0)

Files changed (5)

File vcl/unx/gtk/app/gtkdata.cxx

             {
                 gint nMonitors = gdk_screen_get_n_monitors(pScreen);
                 m_aXineramaScreens = std::vector<Rectangle>();
+                m_aXineramaScreenIndexMap = std::vector<int>(nMonitors);
                 for (gint i = 0; i < nMonitors; ++i)
                 {
                     GdkRectangle dest;
                     gdk_screen_get_monitor_geometry(pScreen, i, &dest);
-                    addXineramaScreenUnique( dest.x, dest.y, dest.width, dest.height );
+                    m_aXineramaScreenIndexMap[i] = addXineramaScreenUnique( dest.x, dest.y, dest.width, dest.height );
                 }
                 m_bXinerama = m_aXineramaScreens.size() > 1;
                 if( ! m_aFrames.empty() )
     }
 }
 
+extern "C"
+{
+    typedef gint(* screen_get_primary_monitor)(GdkScreen *screen);
+}
+
+int GtkSalDisplay::GetDefaultMonitorNumber() const
+{
+    int n = 0;
+    GdkScreen* pScreen = gdk_display_get_screen( m_pGdkDisplay, m_nDefaultScreen );
+#if GTK_CHECK_VERSION(2,20,0)
+    n = m_aXineramaScreenIndexMap[gdk_screen_get_primary_monitor(pScreen)];
+#else
+    static screen_get_primary_monitor sym_gdk_screen_get_primary_monitor =
+        (screen_get_primary_monitor)osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_screen_get_primary_monitor" );
+    if (sym_gdk_screen_get_primary_monitor)
+        n = sym_gdk_screen_get_primary_monitor( pScreen );
+#endif
+    return n;
+}
+
 void GtkSalDisplay::initScreen( int nScreen ) const
 {
     if( nScreen < 0 || nScreen >= static_cast<int>(m_aScreens.size()) )

File vcl/unx/inc/plugins/gtk/gtkdata.hxx

     GdkDisplay*						m_pGdkDisplay;
 	GdkCursor                      *m_aCursors[ POINTER_COUNT ];
     bool                            m_bStartupCompleted;
+    std::vector< int >              m_aXineramaScreenIndexMap;
+
 	GdkCursor* getFromXPM( const char *pBitmap, const char *pMask,
 						   int nWidth, int nHeight, int nXHot, int nYHot );
 public:
     virtual long Dispatch( XEvent *pEvent );
     virtual void initScreen( int nScreen ) const;
 
+    virtual int GetDefaultMonitorNumber() const;
+
     static GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event,
                                            GdkEvent* event,
                                            gpointer data );

File vcl/unx/inc/saldisp.hxx

     int             processRandREvent( XEvent* );
 
     void			doDestruct();
-    void            addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight );
+    int             addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight );
 public:
 	static	SalDisplay	   *GetSalDisplay( Display* display );
 	static	BOOL			BestVisual( Display     *pDisp,
 	XLIB_Window		GetDrawable( int nScreen ) const { return getDataForScreen( nScreen ).m_aRefWindow; }
 	Display		   *GetDisplay() const { return pDisp_; }
 	int				GetDefaultScreenNumber() const { return m_nDefaultScreen; }
+	virtual int		GetDefaultMonitorNumber() const { return 0; }
     const Size&     GetScreenSize( int nScreen ) const { return getDataForScreen( nScreen ).m_aSize; }
 	srv_vendor_t	GetServerVendor() const { return meServerVendor; }
 	void			SetServerVendor() { meServerVendor = sal_GetServerVendor(pDisp_); }

File vcl/unx/source/app/saldisp.cxx

              sal::static_int_cast< unsigned int >(GetVisual(m_nDefaultScreen).GetVisualId()) );
 }
 
-void SalDisplay::addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight )
+int SalDisplay::addXineramaScreenUnique( long i_nX, long i_nY, long i_nWidth, long i_nHeight )
 {
     // see if any frame buffers are at the same coordinates
     // this can happen with weird configuration e.g. on
             {
                 m_aXineramaScreens[n].SetSize( Size( i_nWidth, i_nHeight ) );
             }
-            return;
+            return (int)n;
         }
     }
     m_aXineramaScreens.push_back( Rectangle( Point( i_nX, i_nY ), Size( i_nWidth, i_nHeight ) ) );
+    return (int)m_aXineramaScreens.size()-1;
 }
 
 void SalDisplay::InitXinerama()

File vcl/unx/source/app/salsys.cxx

 unsigned int X11SalSystem::GetDefaultDisplayNumber()
 {
     SalDisplay* pSalDisp = GetX11SalData()->GetDisplay();
-    return pSalDisp->GetDefaultScreenNumber();
+    return pSalDisp->IsXinerama() ? pSalDisp->GetDefaultMonitorNumber() : pSalDisp->GetDefaultScreenNumber();
 }
 
 Rectangle X11SalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )