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