xref: /aoo42x/main/vcl/unx/generic/app/randrwrapper.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifdef USE_RANDR
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <tools/prex.h>
31*cdf0e10cSrcweir #include <X11/extensions/Xrandr.h>
32*cdf0e10cSrcweir #include <tools/postx.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "osl/module.h"
35*cdf0e10cSrcweir #include "rtl/ustring.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir # ifdef XRANDR_DLOPEN
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir class RandRWrapper
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir     oslModule m_pRandRLib;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir     // function pointers
47*cdf0e10cSrcweir     Bool(*m_pXRRQueryExtension)(Display*,int*,int*);
48*cdf0e10cSrcweir     Status(*m_pXRRQueryVersion)(Display*,int*,int*);
49*cdf0e10cSrcweir     XRRScreenConfiguration*(*m_pXRRGetScreenInfo)(Display*,Drawable);
50*cdf0e10cSrcweir     void(*m_pXRRFreeScreenConfigInfo)(XRRScreenConfiguration*);
51*cdf0e10cSrcweir     void(*m_pXRRSelectInput)(Display*,XLIB_Window,int);
52*cdf0e10cSrcweir     int(*m_pXRRUpdateConfiguration)(XEvent*);
53*cdf0e10cSrcweir     XRRScreenSize*(*m_pXRRSizes)(Display*,int,int*);
54*cdf0e10cSrcweir     XRRScreenSize*(*m_pXRRConfigSizes)(XRRScreenConfiguration*,int*);
55*cdf0e10cSrcweir     SizeID(*m_pXRRConfigCurrentConfiguration)(XRRScreenConfiguration*,Rotation*);
56*cdf0e10cSrcweir     int(*m_pXRRRootToScreen)(Display*, XLIB_Window);
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     bool m_bValid;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir     void initFromModule();
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     RandRWrapper(Display*);
63*cdf0e10cSrcweir     ~RandRWrapper();
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir     static RandRWrapper& get(Display*);
66*cdf0e10cSrcweir     static void releaseWrapper();
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     Bool XRRQueryExtension(Display* i_pDisp, int* o_event_base, int* o_error_base )
69*cdf0e10cSrcweir     {
70*cdf0e10cSrcweir         Bool bRet = False;
71*cdf0e10cSrcweir         if( m_bValid )
72*cdf0e10cSrcweir             bRet = m_pXRRQueryExtension( i_pDisp, o_event_base, o_error_base );
73*cdf0e10cSrcweir         return bRet;
74*cdf0e10cSrcweir     }
75*cdf0e10cSrcweir     Status XRRQueryVersion( Display* i_pDisp, int* o_major, int* o_minor )
76*cdf0e10cSrcweir     {
77*cdf0e10cSrcweir         return m_bValid ? m_pXRRQueryVersion( i_pDisp, o_major, o_minor ) : 0;
78*cdf0e10cSrcweir     }
79*cdf0e10cSrcweir     XRRScreenConfiguration* XRRGetScreenInfo( Display* i_pDisp, Drawable i_aDrawable )
80*cdf0e10cSrcweir     {
81*cdf0e10cSrcweir         return m_bValid ? m_pXRRGetScreenInfo( i_pDisp, i_aDrawable ) : NULL;
82*cdf0e10cSrcweir     }
83*cdf0e10cSrcweir     void XRRFreeScreenConfigInfo( XRRScreenConfiguration* i_pConfig )
84*cdf0e10cSrcweir     {
85*cdf0e10cSrcweir         if( m_bValid )
86*cdf0e10cSrcweir             m_pXRRFreeScreenConfigInfo( i_pConfig );
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir     void XRRSelectInput( Display* i_pDisp, XLIB_Window i_window, int i_nMask )
89*cdf0e10cSrcweir     {
90*cdf0e10cSrcweir         if( m_bValid )
91*cdf0e10cSrcweir             m_pXRRSelectInput( i_pDisp, i_window, i_nMask );
92*cdf0e10cSrcweir     }
93*cdf0e10cSrcweir     int XRRUpdateConfiguration( XEvent* i_pEvent )
94*cdf0e10cSrcweir     {
95*cdf0e10cSrcweir         return m_bValid ? m_pXRRUpdateConfiguration( i_pEvent ) : 0;
96*cdf0e10cSrcweir     }
97*cdf0e10cSrcweir     XRRScreenSize* XRRSizes( Display* i_pDisp, int i_screen, int* o_nscreens )
98*cdf0e10cSrcweir     {
99*cdf0e10cSrcweir         return m_bValid ? m_pXRRSizes( i_pDisp, i_screen, o_nscreens ) : NULL;
100*cdf0e10cSrcweir     }
101*cdf0e10cSrcweir     XRRScreenSize* XRRConfigSizes( XRRScreenConfiguration* i_pConfig, int* o_nSizes )
102*cdf0e10cSrcweir     {
103*cdf0e10cSrcweir         return m_bValid ? m_pXRRConfigSizes( i_pConfig, o_nSizes ) : NULL;
104*cdf0e10cSrcweir     }
105*cdf0e10cSrcweir     SizeID XRRConfigCurrentConfiguration( XRRScreenConfiguration* i_pConfig, Rotation* o_pRot )
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         return m_bValid ? m_pXRRConfigCurrentConfiguration( i_pConfig, o_pRot ) : 0;
108*cdf0e10cSrcweir     }
109*cdf0e10cSrcweir     int XRRRootToScreen( Display *dpy, XLIB_Window root )
110*cdf0e10cSrcweir     {
111*cdf0e10cSrcweir         return m_bValid ? m_pXRRRootToScreen( dpy, root ) : -1;
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir };
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void RandRWrapper::initFromModule()
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir     m_pXRRQueryExtension = (Bool(*)(Display*,int*,int*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRQueryExtension" );
118*cdf0e10cSrcweir     m_pXRRQueryVersion = (Status(*)(Display*,int*,int*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRQueryVersion" );
119*cdf0e10cSrcweir     m_pXRRGetScreenInfo = (XRRScreenConfiguration*(*)(Display*,Drawable))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRGetScreenInfo" );
120*cdf0e10cSrcweir     m_pXRRFreeScreenConfigInfo = (void(*)(XRRScreenConfiguration*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRFreeScreenConfigInfo" );
121*cdf0e10cSrcweir     m_pXRRSelectInput = (void(*)(Display*,XLIB_Window,int))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRSelectInput" );
122*cdf0e10cSrcweir     m_pXRRUpdateConfiguration = (int(*)(XEvent*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRUpdateConfiguration" );
123*cdf0e10cSrcweir     m_pXRRSizes = (XRRScreenSize*(*)(Display*,int,int*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRSizes" );
124*cdf0e10cSrcweir     m_pXRRConfigSizes = (XRRScreenSize*(*)(XRRScreenConfiguration*,int*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRConfigSizes" );
125*cdf0e10cSrcweir     m_pXRRConfigCurrentConfiguration = (SizeID(*)(XRRScreenConfiguration*,Rotation*))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRConfigCurrentConfiguration" );
126*cdf0e10cSrcweir     m_pXRRRootToScreen = (int(*)(Display*,XLIB_Window))osl_getAsciiFunctionSymbol( m_pRandRLib, "XRRRootToScreen" );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     m_bValid = m_pXRRQueryExtension             &&
129*cdf0e10cSrcweir                m_pXRRQueryVersion               &&
130*cdf0e10cSrcweir                m_pXRRGetScreenInfo              &&
131*cdf0e10cSrcweir                m_pXRRFreeScreenConfigInfo       &&
132*cdf0e10cSrcweir                m_pXRRSelectInput                &&
133*cdf0e10cSrcweir                m_pXRRUpdateConfiguration        &&
134*cdf0e10cSrcweir                m_pXRRSizes                      &&
135*cdf0e10cSrcweir                m_pXRRConfigSizes                &&
136*cdf0e10cSrcweir                m_pXRRConfigCurrentConfiguration &&
137*cdf0e10cSrcweir                m_pXRRRootToScreen
138*cdf0e10cSrcweir                ;
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir RandRWrapper::RandRWrapper( Display* pDisplay ) :
142*cdf0e10cSrcweir         m_pRandRLib( NULL ),
143*cdf0e10cSrcweir         m_pXRRQueryExtension( NULL ),
144*cdf0e10cSrcweir         m_pXRRQueryVersion( NULL ),
145*cdf0e10cSrcweir         m_pXRRGetScreenInfo( NULL ),
146*cdf0e10cSrcweir         m_pXRRFreeScreenConfigInfo( NULL ),
147*cdf0e10cSrcweir         m_pXRRSelectInput( NULL ),
148*cdf0e10cSrcweir         m_pXRRUpdateConfiguration( NULL ),
149*cdf0e10cSrcweir         m_pXRRSizes( NULL ),
150*cdf0e10cSrcweir         m_pXRRConfigSizes( NULL ),
151*cdf0e10cSrcweir         m_pXRRConfigCurrentConfiguration( NULL ),
152*cdf0e10cSrcweir         m_pXRRRootToScreen( NULL ),
153*cdf0e10cSrcweir         m_bValid( false )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     // first try in process space (e.g. gtk links that ?)
156*cdf0e10cSrcweir     initFromModule();
157*cdf0e10cSrcweir     if( ! m_bValid )
158*cdf0e10cSrcweir     {
159*cdf0e10cSrcweir         rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( "libXrandr.so.2" ) );
160*cdf0e10cSrcweir         // load and resolve dependencies immediately
161*cdf0e10cSrcweir         // rationale: there are older distributions where libXrandr.so.2 is not linked
162*cdf0e10cSrcweir         // with libXext.so, resulting in a missing symbol and terminating the office
163*cdf0e10cSrcweir         // obviously they expected libXext to be linked in global symbolspace (that is
164*cdf0e10cSrcweir         // linked by the application), which is not the case with us (because we want
165*cdf0e10cSrcweir         // to be able to run in headless mode even without an installed X11 library)
166*cdf0e10cSrcweir         m_pRandRLib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_DEFAULT | SAL_LOADMODULE_NOW );
167*cdf0e10cSrcweir         initFromModule();
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir     if( m_bValid )
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         int nEventBase = 0, nErrorBase = 0;
172*cdf0e10cSrcweir         if( ! m_pXRRQueryExtension( pDisplay, &nEventBase, &nErrorBase ) )
173*cdf0e10cSrcweir             m_bValid = false;
174*cdf0e10cSrcweir     }
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir RandRWrapper::~RandRWrapper()
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir     if( m_pRandRLib )
180*cdf0e10cSrcweir         osl_unloadModule( m_pRandRLib );
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir static RandRWrapper* pWrapper = NULL;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir RandRWrapper& RandRWrapper::get( Display* i_pDisplay )
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     if( ! pWrapper )
188*cdf0e10cSrcweir         pWrapper = new RandRWrapper( i_pDisplay );
189*cdf0e10cSrcweir     return *pWrapper;
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir void RandRWrapper::releaseWrapper()
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     delete pWrapper;
195*cdf0e10cSrcweir     pWrapper = NULL;
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir # else
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir class RandRWrapper
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     bool m_bValid;
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     RandRWrapper(Display*);
205*cdf0e10cSrcweir public:
206*cdf0e10cSrcweir     static RandRWrapper& get(Display*);
207*cdf0e10cSrcweir     static void releaseWrapper();
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     Bool XRRQueryExtension(Display* i_pDisp, int* o_event_base, int* o_error_base )
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         Bool bRet = False;
212*cdf0e10cSrcweir         if( m_bValid )
213*cdf0e10cSrcweir             bRet = ::XRRQueryExtension( i_pDisp, o_event_base, o_error_base );
214*cdf0e10cSrcweir         return bRet;
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir     Status XRRQueryVersion( Display* i_pDisp, int* o_major, int* o_minor )
217*cdf0e10cSrcweir     {
218*cdf0e10cSrcweir         return m_bValid ? ::XRRQueryVersion( i_pDisp, o_major, o_minor ) : 0;
219*cdf0e10cSrcweir     }
220*cdf0e10cSrcweir     XRRScreenConfiguration* XRRGetScreenInfo( Display* i_pDisp, Drawable i_aDrawable )
221*cdf0e10cSrcweir     {
222*cdf0e10cSrcweir         return m_bValid ? ::XRRGetScreenInfo( i_pDisp, i_aDrawable ) : NULL;
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir     void XRRFreeScreenConfigInfo( XRRScreenConfiguration* i_pConfig )
225*cdf0e10cSrcweir     {
226*cdf0e10cSrcweir         if( m_bValid )
227*cdf0e10cSrcweir             ::XRRFreeScreenConfigInfo( i_pConfig );
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir     void XRRSelectInput( Display* i_pDisp, XLIB_Window i_window, int i_nMask )
230*cdf0e10cSrcweir     {
231*cdf0e10cSrcweir         if( m_bValid )
232*cdf0e10cSrcweir             ::XRRSelectInput( i_pDisp, i_window, i_nMask );
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir     int XRRUpdateConfiguration( XEvent* i_pEvent )
235*cdf0e10cSrcweir     {
236*cdf0e10cSrcweir         return m_bValid ? ::XRRUpdateConfiguration( i_pEvent ) : 0;
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir     XRRScreenSize* XRRSizes( Display* i_pDisp, int i_screen, int* o_nscreens )
239*cdf0e10cSrcweir     {
240*cdf0e10cSrcweir         return m_bValid ? ::XRRSizes( i_pDisp, i_screen, o_nscreens ) : NULL;
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir     XRRScreenSize* XRRConfigSizes( XRRScreenConfiguration* i_pConfig, int* o_nSizes )
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         return m_bValid ? ::XRRConfigSizes( i_pConfig, o_nSizes ) : NULL;
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir     SizeID XRRConfigCurrentConfiguration( XRRScreenConfiguration* i_pConfig, Rotation* o_pRot )
247*cdf0e10cSrcweir     {
248*cdf0e10cSrcweir         return m_bValid ? ::XRRConfigCurrentConfiguration( i_pConfig, o_pRot ) : 0;
249*cdf0e10cSrcweir     }
250*cdf0e10cSrcweir     int XRRRootToScreen( Display *dpy, XLIB_Window root )
251*cdf0e10cSrcweir     {
252*cdf0e10cSrcweir         return m_bValid ? ::XRRRootToScreen( dpy, root ) : -1;
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir };
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir RandRWrapper::RandRWrapper( Display* pDisplay ) :
257*cdf0e10cSrcweir     m_bValid( true )
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     int nEventBase = 0, nErrorBase = 0;
260*cdf0e10cSrcweir     if( !XRRQueryExtension( pDisplay, &nEventBase, &nErrorBase ) )
261*cdf0e10cSrcweir         m_bValid = false;
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir static RandRWrapper* pWrapper = NULL;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir RandRWrapper& RandRWrapper::get( Display* i_pDisplay )
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir     if( ! pWrapper )
269*cdf0e10cSrcweir         pWrapper = new RandRWrapper( i_pDisplay );
270*cdf0e10cSrcweir     return *pWrapper;
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir void RandRWrapper::releaseWrapper()
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir     delete pWrapper;
276*cdf0e10cSrcweir     pWrapper = NULL;
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir #endif
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir } // namespace
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir #endif
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir #include "unx/saldisp.hxx"
286*cdf0e10cSrcweir #include "unx/salframe.h"
287*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
288*cdf0e10cSrcweir #include <cstdio>
289*cdf0e10cSrcweir #endif
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir void SalDisplay::InitRandR( XLIB_Window aRoot ) const
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     #ifdef USE_RANDR
294*cdf0e10cSrcweir     if( m_bUseRandRWrapper )
295*cdf0e10cSrcweir         RandRWrapper::get( GetDisplay() ).XRRSelectInput( GetDisplay(), aRoot, RRScreenChangeNotifyMask );
296*cdf0e10cSrcweir     #else
297*cdf0e10cSrcweir     (void)aRoot;
298*cdf0e10cSrcweir     #endif
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir void SalDisplay::DeInitRandR()
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     #ifdef USE_RANDR
304*cdf0e10cSrcweir     if( m_bUseRandRWrapper )
305*cdf0e10cSrcweir         RandRWrapper::releaseWrapper();
306*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
307*cdf0e10cSrcweir     fprintf( stderr, "SalDisplay::DeInitRandR()\n" );
308*cdf0e10cSrcweir #endif
309*cdf0e10cSrcweir     #endif
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir int SalDisplay::processRandREvent( XEvent* pEvent )
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     int nRet = 0;
315*cdf0e10cSrcweir     #ifdef USE_RANDR
316*cdf0e10cSrcweir     XConfigureEvent* pCnfEvent=(XConfigureEvent*)pEvent;
317*cdf0e10cSrcweir     if( m_bUseRandRWrapper && pWrapper && pWrapper->XRRRootToScreen(GetDisplay(),pCnfEvent->window) != -1 )
318*cdf0e10cSrcweir     {
319*cdf0e10cSrcweir         nRet = pWrapper->XRRUpdateConfiguration( pEvent );
320*cdf0e10cSrcweir         if( nRet == 1 && pEvent->type != ConfigureNotify) // this should then be a XRRScreenChangeNotifyEvent
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             // update screens
323*cdf0e10cSrcweir             bool bNotify = false;
324*cdf0e10cSrcweir             for( size_t i = 0; i < m_aScreens.size(); i++ )
325*cdf0e10cSrcweir             {
326*cdf0e10cSrcweir                 if( m_aScreens[i].m_bInit )
327*cdf0e10cSrcweir                 {
328*cdf0e10cSrcweir                     XRRScreenConfiguration *pConfig = NULL;
329*cdf0e10cSrcweir                     XRRScreenSize *pSizes = NULL;
330*cdf0e10cSrcweir                     int nSizes = 0;
331*cdf0e10cSrcweir                     Rotation nRot = 0;
332*cdf0e10cSrcweir                     SizeID nId = 0;
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir                     pConfig = pWrapper->XRRGetScreenInfo( GetDisplay(), m_aScreens[i].m_aRoot );
335*cdf0e10cSrcweir                     nId = pWrapper->XRRConfigCurrentConfiguration( pConfig, &nRot );
336*cdf0e10cSrcweir                     pSizes = pWrapper->XRRConfigSizes( pConfig, &nSizes );
337*cdf0e10cSrcweir                     XRRScreenSize *pTargetSize = pSizes + nId;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir                     bNotify = bNotify ||
340*cdf0e10cSrcweir                               m_aScreens[i].m_aSize.Width() != pTargetSize->width ||
341*cdf0e10cSrcweir                               m_aScreens[i].m_aSize.Height() != pTargetSize->height;
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir                     m_aScreens[i].m_aSize = Size( pTargetSize->width, pTargetSize->height );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir                     pWrapper->XRRFreeScreenConfigInfo( pConfig );
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir                     #if OSL_DEBUG_LEVEL > 1
348*cdf0e10cSrcweir                     fprintf( stderr, "screen %d changed to size %dx%d\n", (int)i, (int)pTargetSize->width, (int)pTargetSize->height );
349*cdf0e10cSrcweir                     #endif
350*cdf0e10cSrcweir                 }
351*cdf0e10cSrcweir             }
352*cdf0e10cSrcweir             if( bNotify && ! m_aFrames.empty() )
353*cdf0e10cSrcweir                 m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
354*cdf0e10cSrcweir         }
355*cdf0e10cSrcweir     }
356*cdf0e10cSrcweir     #else
357*cdf0e10cSrcweir     (void)pEvent;
358*cdf0e10cSrcweir     #endif
359*cdf0e10cSrcweir     return nRet;
360*cdf0e10cSrcweir }
361