1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*c82f2877SAndrew Rist * distributed with this work for additional information
6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17*c82f2877SAndrew Rist * specific language governing permissions and limitations
18*c82f2877SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*c82f2877SAndrew Rist *************************************************************/
21*c82f2877SAndrew Rist
22*c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <string.h>
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir #include <stdlib.h>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "sal/alloca.h"
32cdf0e10cSrcweir #include "rtl/locale.h"
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include "osl/thread.h"
35cdf0e10cSrcweir #include "osl/process.h"
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include "vcl/configsettings.hxx"
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "unx/wmadaptor.hxx"
40cdf0e10cSrcweir #include "unx/saldisp.hxx"
41cdf0e10cSrcweir #include "unx/saldata.hxx"
42cdf0e10cSrcweir #include "unx/salframe.h"
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include "salgdi.hxx"
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include "tools/prex.h"
47cdf0e10cSrcweir #include <X11/X.h>
48cdf0e10cSrcweir #include <X11/Xatom.h>
49cdf0e10cSrcweir #include <X11/Xresource.h>
50cdf0e10cSrcweir #include "tools/postx.h"
51cdf0e10cSrcweir
52cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
53cdf0e10cSrcweir #include <stdio.h>
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir
56cdf0e10cSrcweir namespace vcl_sal {
57cdf0e10cSrcweir
58cdf0e10cSrcweir class NetWMAdaptor : public WMAdaptor
59cdf0e10cSrcweir {
60cdf0e10cSrcweir void setNetWMState( X11SalFrame* pFrame ) const;
61cdf0e10cSrcweir void initAtoms();
62cdf0e10cSrcweir virtual bool isValid() const;
63cdf0e10cSrcweir public:
64cdf0e10cSrcweir NetWMAdaptor( SalDisplay* );
65cdf0e10cSrcweir virtual ~NetWMAdaptor();
66cdf0e10cSrcweir
67cdf0e10cSrcweir virtual void setWMName( X11SalFrame* pFrame, const String& rWMName ) const;
68cdf0e10cSrcweir virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
69cdf0e10cSrcweir virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
70cdf0e10cSrcweir virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame = NULL ) const;
71cdf0e10cSrcweir virtual bool supportsICCCMPos() const;
72cdf0e10cSrcweir virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
73cdf0e10cSrcweir virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
74cdf0e10cSrcweir virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
75cdf0e10cSrcweir virtual void frameIsMapping( X11SalFrame* pFrame ) const;
76cdf0e10cSrcweir virtual void setFrameStruts( X11SalFrame* pFrame,
77cdf0e10cSrcweir int left, int right, int top, int bottom,
78cdf0e10cSrcweir int left_start_y, int left_end_y,
79cdf0e10cSrcweir int right_start_y, int right_end_y,
80cdf0e10cSrcweir int top_start_x, int top_end_x,
81cdf0e10cSrcweir int bottom_start_x, int bottom_end_x ) const;
82cdf0e10cSrcweir virtual void setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const;
83cdf0e10cSrcweir virtual void setFullScreenMonitors( XLIB_Window i_aWindow, sal_Int32 i_nScreen );
84cdf0e10cSrcweir };
85cdf0e10cSrcweir
86cdf0e10cSrcweir class GnomeWMAdaptor : public WMAdaptor
87cdf0e10cSrcweir {
88cdf0e10cSrcweir bool m_bValid;
89cdf0e10cSrcweir
90cdf0e10cSrcweir void setGnomeWMState( X11SalFrame* pFrame ) const;
91cdf0e10cSrcweir void initAtoms();
92cdf0e10cSrcweir virtual bool isValid() const;
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir GnomeWMAdaptor( SalDisplay * );
95cdf0e10cSrcweir virtual ~GnomeWMAdaptor();
96cdf0e10cSrcweir
97cdf0e10cSrcweir virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
98cdf0e10cSrcweir virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
99cdf0e10cSrcweir virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
100cdf0e10cSrcweir virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
101cdf0e10cSrcweir };
102cdf0e10cSrcweir
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir using namespace vcl_sal;
106cdf0e10cSrcweir
107cdf0e10cSrcweir struct WMAdaptorProtocol
108cdf0e10cSrcweir {
109cdf0e10cSrcweir const char* pProtocol;
110cdf0e10cSrcweir int nProtocol;
111cdf0e10cSrcweir };
112cdf0e10cSrcweir
113cdf0e10cSrcweir
114cdf0e10cSrcweir /*
115cdf0e10cSrcweir * table must be sorted ascending in strings
116cdf0e10cSrcweir * since it is use with bsearch
117cdf0e10cSrcweir */
118cdf0e10cSrcweir static const WMAdaptorProtocol aProtocolTab[] =
119cdf0e10cSrcweir {
120cdf0e10cSrcweir { "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", WMAdaptor::KDE_NET_WM_WINDOW_TYPE_OVERRIDE },
121cdf0e10cSrcweir { "_NET_CURRENT_DESKTOP", WMAdaptor::NET_CURRENT_DESKTOP },
122cdf0e10cSrcweir { "_NET_NUMBER_OF_DESKTOPS", WMAdaptor::NET_NUMBER_OF_DESKTOPS },
123cdf0e10cSrcweir { "_NET_WM_DESKTOP", WMAdaptor::NET_WM_DESKTOP },
124cdf0e10cSrcweir { "_NET_WM_FULLSCREEN_MONITORS", WMAdaptor::NET_WM_FULLSCREEN_MONITORS },
125cdf0e10cSrcweir { "_NET_WM_ICON_NAME", WMAdaptor::NET_WM_ICON_NAME },
126cdf0e10cSrcweir { "_NET_WM_PING", WMAdaptor::NET_WM_PING },
127cdf0e10cSrcweir { "_NET_WM_STATE", WMAdaptor::NET_WM_STATE },
128cdf0e10cSrcweir { "_NET_WM_STATE_ABOVE", WMAdaptor::NET_WM_STATE_STAYS_ON_TOP },
129cdf0e10cSrcweir { "_NET_WM_STATE_FULLSCREEN", WMAdaptor::NET_WM_STATE_FULLSCREEN },
130cdf0e10cSrcweir { "_NET_WM_STATE_MAXIMIZED_HORIZ", WMAdaptor::NET_WM_STATE_MAXIMIZED_HORZ }, // common bug in e.g. older kwin and sawfish implementations
131cdf0e10cSrcweir { "_NET_WM_STATE_MAXIMIZED_HORZ", WMAdaptor::NET_WM_STATE_MAXIMIZED_HORZ },
132cdf0e10cSrcweir { "_NET_WM_STATE_MAXIMIZED_VERT", WMAdaptor::NET_WM_STATE_MAXIMIZED_VERT },
133cdf0e10cSrcweir { "_NET_WM_STATE_MODAL", WMAdaptor::NET_WM_STATE_MODAL },
134cdf0e10cSrcweir { "_NET_WM_STATE_SHADED", WMAdaptor::NET_WM_STATE_SHADED },
135cdf0e10cSrcweir { "_NET_WM_STATE_SKIP_PAGER", WMAdaptor::NET_WM_STATE_SKIP_PAGER },
136cdf0e10cSrcweir { "_NET_WM_STATE_SKIP_TASKBAR", WMAdaptor::NET_WM_STATE_SKIP_TASKBAR },
137cdf0e10cSrcweir { "_NET_WM_STATE_STAYS_ON_TOP", WMAdaptor::NET_WM_STATE_STAYS_ON_TOP },
138cdf0e10cSrcweir { "_NET_WM_STATE_STICKY", WMAdaptor::NET_WM_STATE_STICKY },
139cdf0e10cSrcweir { "_NET_WM_STRUT", WMAdaptor::NET_WM_STRUT },
140cdf0e10cSrcweir { "_NET_WM_STRUT_PARTIAL", WMAdaptor::NET_WM_STRUT_PARTIAL },
141cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE", WMAdaptor::NET_WM_WINDOW_TYPE },
142cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_DESKTOP", WMAdaptor::NET_WM_WINDOW_TYPE_DESKTOP },
143cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_DIALOG", WMAdaptor::NET_WM_WINDOW_TYPE_DIALOG },
144cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_DOCK", WMAdaptor::NET_WM_WINDOW_TYPE_DOCK },
145cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_MENU", WMAdaptor::NET_WM_WINDOW_TYPE_MENU },
146cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_NORMAL", WMAdaptor::NET_WM_WINDOW_TYPE_NORMAL },
147cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_SPLASH", WMAdaptor::NET_WM_WINDOW_TYPE_SPLASH },
148cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_SPLASHSCREEN", WMAdaptor::NET_WM_WINDOW_TYPE_SPLASH }, // bug in Metacity 2.4.1
149cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_TOOLBAR", WMAdaptor::NET_WM_WINDOW_TYPE_TOOLBAR },
150cdf0e10cSrcweir { "_NET_WM_WINDOW_TYPE_UTILITY", WMAdaptor::NET_WM_WINDOW_TYPE_UTILITY },
151cdf0e10cSrcweir { "_NET_WORKAREA", WMAdaptor::NET_WORKAREA },
152cdf0e10cSrcweir { "_WIN_APP_STATE", WMAdaptor::WIN_APP_STATE },
153cdf0e10cSrcweir { "_WIN_CLIENT_LIST", WMAdaptor::WIN_CLIENT_LIST },
154cdf0e10cSrcweir { "_WIN_EXPANDED_SIZE", WMAdaptor::WIN_EXPANDED_SIZE },
155cdf0e10cSrcweir { "_WIN_HINTS", WMAdaptor::WIN_HINTS },
156cdf0e10cSrcweir { "_WIN_ICONS", WMAdaptor::WIN_ICONS },
157cdf0e10cSrcweir { "_WIN_LAYER", WMAdaptor::WIN_LAYER },
158cdf0e10cSrcweir { "_WIN_STATE", WMAdaptor::WIN_STATE },
159cdf0e10cSrcweir { "_WIN_WORKSPACE", WMAdaptor::WIN_WORKSPACE },
160cdf0e10cSrcweir { "_WIN_WORKSPACE_COUNT", WMAdaptor::WIN_WORKSPACE_COUNT }
161cdf0e10cSrcweir };
162cdf0e10cSrcweir
163cdf0e10cSrcweir /*
164cdf0e10cSrcweir * table containing atoms to get anyway
165cdf0e10cSrcweir */
166cdf0e10cSrcweir
167cdf0e10cSrcweir static const WMAdaptorProtocol aAtomTab[] =
168cdf0e10cSrcweir {
169cdf0e10cSrcweir { "WM_STATE", WMAdaptor::WM_STATE },
170cdf0e10cSrcweir { "_MOTIF_WM_HINTS", WMAdaptor::MOTIF_WM_HINTS },
171cdf0e10cSrcweir { "WM_PROTOCOLS", WMAdaptor::WM_PROTOCOLS },
172cdf0e10cSrcweir { "WM_DELETE_WINDOW", WMAdaptor::WM_DELETE_WINDOW },
173cdf0e10cSrcweir { "WM_TAKE_FOCUS", WMAdaptor::WM_TAKE_FOCUS },
174cdf0e10cSrcweir { "WM_SAVE_YOURSELF", WMAdaptor::WM_SAVE_YOURSELF },
175cdf0e10cSrcweir { "WM_COMMAND", WMAdaptor::WM_COMMAND },
176cdf0e10cSrcweir { "WM_CLIENT_LEADER", WMAdaptor::WM_CLIENT_LEADER },
177cdf0e10cSrcweir { "WM_LOCALE_NAME", WMAdaptor::WM_LOCALE_NAME },
178cdf0e10cSrcweir { "WM_TRANSIENT_FOR", WMAdaptor::WM_TRANSIENT_FOR },
179cdf0e10cSrcweir { "SAL_QUITEVENT", WMAdaptor::SAL_QUITEVENT },
180cdf0e10cSrcweir { "SAL_USEREVENT", WMAdaptor::SAL_USEREVENT },
181cdf0e10cSrcweir { "SAL_EXTTEXTEVENT", WMAdaptor::SAL_EXTTEXTEVENT },
182cdf0e10cSrcweir { "SAL_GETTIMEEVENT", WMAdaptor::SAL_GETTIMEEVENT },
183cdf0e10cSrcweir { "VCL_SYSTEM_SETTINGS", WMAdaptor::VCL_SYSTEM_SETTINGS },
184cdf0e10cSrcweir { "DTWM_IS_RUNNING", WMAdaptor::DTWM_IS_RUNNING },
185cdf0e10cSrcweir { "_XSETTINGS_SETTINGS", WMAdaptor::XSETTINGS },
186cdf0e10cSrcweir { "_XEMBED", WMAdaptor::XEMBED },
187cdf0e10cSrcweir { "_XEMBED_INFO", WMAdaptor::XEMBED_INFO },
188cdf0e10cSrcweir { "_NET_WM_USER_TIME", WMAdaptor::NET_WM_USER_TIME },
189cdf0e10cSrcweir { "_NET_WM_PID", WMAdaptor::NET_WM_PID }
190cdf0e10cSrcweir };
191cdf0e10cSrcweir
192cdf0e10cSrcweir extern "C" {
compareProtocol(const void * pLeft,const void * pRight)193cdf0e10cSrcweir static int compareProtocol( const void* pLeft, const void* pRight )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir return strcmp( ((const WMAdaptorProtocol*)pLeft)->pProtocol, ((const WMAdaptorProtocol*)pRight)->pProtocol );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
createWMAdaptor(SalDisplay * pSalDisplay)199cdf0e10cSrcweir WMAdaptor* WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir WMAdaptor* pAdaptor = NULL;
202cdf0e10cSrcweir
203cdf0e10cSrcweir // try a NetWM
204cdf0e10cSrcweir pAdaptor = new NetWMAdaptor( pSalDisplay );
205cdf0e10cSrcweir if( ! pAdaptor->isValid() )
206cdf0e10cSrcweir delete pAdaptor, pAdaptor = NULL;
207cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
208cdf0e10cSrcweir else
209cdf0e10cSrcweir fprintf( stderr, "WM supports extended WM hints\n" );
210cdf0e10cSrcweir #endif
211cdf0e10cSrcweir
212cdf0e10cSrcweir // try a GnomeWM
213cdf0e10cSrcweir if( ! pAdaptor )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir pAdaptor = new GnomeWMAdaptor( pSalDisplay );
216cdf0e10cSrcweir if( ! pAdaptor->isValid() )
217cdf0e10cSrcweir delete pAdaptor, pAdaptor = NULL;
218cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
219cdf0e10cSrcweir else
220cdf0e10cSrcweir fprintf( stderr, "WM supports GNOME WM hints\n" );
221cdf0e10cSrcweir #endif
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir if( ! pAdaptor )
225cdf0e10cSrcweir pAdaptor = new WMAdaptor( pSalDisplay );
226cdf0e10cSrcweir
227cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
228cdf0e10cSrcweir fprintf( stderr, "Window Manager's name is \"%s\"\n",
229cdf0e10cSrcweir ByteString( pAdaptor->getWindowManagerName(), RTL_TEXTENCODING_ISO_8859_1 ).GetBuffer() );
230cdf0e10cSrcweir #endif
231cdf0e10cSrcweir return pAdaptor;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir
235cdf0e10cSrcweir /*
236cdf0e10cSrcweir * WMAdaptor constructor
237cdf0e10cSrcweir */
238cdf0e10cSrcweir
WMAdaptor(SalDisplay * pDisplay)239cdf0e10cSrcweir WMAdaptor::WMAdaptor( SalDisplay* pDisplay ) :
240cdf0e10cSrcweir m_pSalDisplay( pDisplay ),
241cdf0e10cSrcweir m_bTransientBehaviour( true ),
242cdf0e10cSrcweir m_bEnableAlwaysOnTopWorks( false ),
243cdf0e10cSrcweir m_bLegacyPartialFullscreen( false ),
244cdf0e10cSrcweir m_nWinGravity( StaticGravity ),
245cdf0e10cSrcweir m_nInitWinGravity( StaticGravity ),
246cdf0e10cSrcweir m_bWMshouldSwitchWorkspace( true ),
247cdf0e10cSrcweir m_bWMshouldSwitchWorkspaceInit( false )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir Atom aRealType = None;
250cdf0e10cSrcweir int nFormat = 8;
251cdf0e10cSrcweir unsigned long nItems = 0;
252cdf0e10cSrcweir unsigned long nBytesLeft = 0;
253cdf0e10cSrcweir unsigned char* pProperty = NULL;
254cdf0e10cSrcweir
255cdf0e10cSrcweir // default desktops
256cdf0e10cSrcweir m_nDesktops = 1;
257cdf0e10cSrcweir m_aWMWorkAreas = ::std::vector< Rectangle >
258cdf0e10cSrcweir ( 1, Rectangle( Point(), m_pSalDisplay->GetScreenSize( m_pSalDisplay->GetDefaultScreenNumber() ) ) );
259cdf0e10cSrcweir m_bEqualWorkAreas = true;
260cdf0e10cSrcweir
261cdf0e10cSrcweir memset( m_aWMAtoms, 0, sizeof( m_aWMAtoms ) );
262cdf0e10cSrcweir m_pDisplay = m_pSalDisplay->GetDisplay();
263cdf0e10cSrcweir
264cdf0e10cSrcweir initAtoms();
265cdf0e10cSrcweir getNetWmName(); // try to discover e.g. Sawfish
266cdf0e10cSrcweir
267cdf0e10cSrcweir // check for dtwm running
268cdf0e10cSrcweir if( m_aWMAtoms[ DTWM_IS_RUNNING ] )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir if ( (XGetWindowProperty( m_pDisplay,
271cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
272cdf0e10cSrcweir m_aWMAtoms[ DTWM_IS_RUNNING ],
273cdf0e10cSrcweir 0, 1,
274cdf0e10cSrcweir False,
275cdf0e10cSrcweir XA_INTEGER,
276cdf0e10cSrcweir &aRealType,
277cdf0e10cSrcweir &nFormat,
278cdf0e10cSrcweir &nItems,
279cdf0e10cSrcweir &nBytesLeft,
280cdf0e10cSrcweir &pProperty) == 0
281cdf0e10cSrcweir && nItems)
282cdf0e10cSrcweir || (XGetWindowProperty( m_pDisplay,
283cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
284cdf0e10cSrcweir m_aWMAtoms[ DTWM_IS_RUNNING ],
285cdf0e10cSrcweir 0, 1,
286cdf0e10cSrcweir False,
287cdf0e10cSrcweir m_aWMAtoms[ DTWM_IS_RUNNING ],
288cdf0e10cSrcweir &aRealType,
289cdf0e10cSrcweir &nFormat,
290cdf0e10cSrcweir &nItems,
291cdf0e10cSrcweir &nBytesLeft,
292cdf0e10cSrcweir &pProperty) == 0
293cdf0e10cSrcweir && nItems))
294cdf0e10cSrcweir {
295cdf0e10cSrcweir if (*pProperty)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir m_aWMName = String(RTL_CONSTASCII_USTRINGPARAM("Dtwm"));
298cdf0e10cSrcweir m_bTransientBehaviour = false;
299cdf0e10cSrcweir m_nWinGravity = CenterGravity;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir XFree (pProperty);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir else if( pProperty )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir XFree( pProperty );
306cdf0e10cSrcweir pProperty = NULL;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir if( m_aWMName.Len() == 0 )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir // check for window maker - needs different gravity
312cdf0e10cSrcweir Atom aWMakerRunning = XInternAtom( m_pDisplay, "_WINDOWMAKER_WM_PROTOCOLS", True );
313cdf0e10cSrcweir if( aWMakerRunning != None &&
314cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
315cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
316cdf0e10cSrcweir aWMakerRunning,
317cdf0e10cSrcweir 0, 32,
318cdf0e10cSrcweir False,
319cdf0e10cSrcweir XA_ATOM,
320cdf0e10cSrcweir &aRealType,
321cdf0e10cSrcweir &nFormat,
322cdf0e10cSrcweir &nItems,
323cdf0e10cSrcweir &nBytesLeft,
324cdf0e10cSrcweir &pProperty ) == 0 )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir if( aRealType == XA_ATOM )
327cdf0e10cSrcweir m_aWMName = String( RTL_CONSTASCII_USTRINGPARAM("Windowmaker" ) );
328cdf0e10cSrcweir XFree( pProperty );
329cdf0e10cSrcweir m_nInitWinGravity = NorthWestGravity;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir else if( pProperty )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir XFree( pProperty );
334cdf0e10cSrcweir pProperty = NULL;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir if( m_aWMName.Len() == 0 )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir if( XInternAtom( m_pDisplay, "_OL_WIN_ATTR", True ) )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir m_aWMName = String( RTL_CONSTASCII_USTRINGPARAM( "Olwm" ) );
342cdf0e10cSrcweir m_nInitWinGravity = NorthWestGravity;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir if( m_aWMName.Len() == 0 )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // check for ReflectionX wm (as it needs a workaround in Windows mode
348cdf0e10cSrcweir Atom aRwmRunning = XInternAtom( m_pDisplay, "RWM_RUNNING", True );
349cdf0e10cSrcweir if( aRwmRunning != None &&
350cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
351cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
352cdf0e10cSrcweir aRwmRunning,
353cdf0e10cSrcweir 0, 32,
354cdf0e10cSrcweir False,
355cdf0e10cSrcweir aRwmRunning,
356cdf0e10cSrcweir &aRealType,
357cdf0e10cSrcweir &nFormat,
358cdf0e10cSrcweir &nItems,
359cdf0e10cSrcweir &nBytesLeft,
360cdf0e10cSrcweir &pProperty ) == 0 )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir if( aRealType == aRwmRunning )
363cdf0e10cSrcweir m_aWMName = String( RTL_CONSTASCII_USTRINGPARAM("ReflectionX" ) );
364cdf0e10cSrcweir XFree( pProperty );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir else if( (aRwmRunning = XInternAtom( m_pDisplay, "_WRQ_WM_RUNNING", True )) != None &&
367cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
368cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
369cdf0e10cSrcweir aRwmRunning,
370cdf0e10cSrcweir 0, 32,
371cdf0e10cSrcweir False,
372cdf0e10cSrcweir XA_STRING,
373cdf0e10cSrcweir &aRealType,
374cdf0e10cSrcweir &nFormat,
375cdf0e10cSrcweir &nItems,
376cdf0e10cSrcweir &nBytesLeft,
377cdf0e10cSrcweir &pProperty ) == 0 )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir if( aRealType == XA_STRING )
380cdf0e10cSrcweir m_aWMName = String( RTL_CONSTASCII_USTRINGPARAM( "ReflectionX Windows" ) );
381cdf0e10cSrcweir XFree( pProperty );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir }
384cdf0e10cSrcweir if( m_aWMName.Len() == 0 )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir Atom aTTAPlatform = XInternAtom( m_pDisplay, "TTA_CLIENT_PLATFORM", True );
387cdf0e10cSrcweir if( aTTAPlatform != None &&
388cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
389cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
390cdf0e10cSrcweir aTTAPlatform,
391cdf0e10cSrcweir 0, 32,
392cdf0e10cSrcweir False,
393cdf0e10cSrcweir XA_STRING,
394cdf0e10cSrcweir &aRealType,
395cdf0e10cSrcweir &nFormat,
396cdf0e10cSrcweir &nItems,
397cdf0e10cSrcweir &nBytesLeft,
398cdf0e10cSrcweir &pProperty ) == 0 )
399cdf0e10cSrcweir {
400cdf0e10cSrcweir if( aRealType == XA_STRING )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir m_aWMName = String( RTL_CONSTASCII_USTRINGPARAM("Tarantella" ) );
403cdf0e10cSrcweir // #i62319# pretend that AlwaysOnTop works since
404cdf0e10cSrcweir // the alwaysontop workaround in salframe.cxx results
405cdf0e10cSrcweir // in a raise/lower loop on a Windows tarantella client
406cdf0e10cSrcweir // FIXME: this property contains an identification string that
407cdf0e10cSrcweir // in theory should be good enough to recognize running on a
408cdf0e10cSrcweir // Windows client; however this string does not seem to be
409cdf0e10cSrcweir // documented as well as the property itself.
410cdf0e10cSrcweir m_bEnableAlwaysOnTopWorks = true;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir XFree( pProperty );
413cdf0e10cSrcweir }
414cdf0e10cSrcweir }
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir /*
418cdf0e10cSrcweir * WMAdaptor destructor
419cdf0e10cSrcweir */
420cdf0e10cSrcweir
~WMAdaptor()421cdf0e10cSrcweir WMAdaptor::~WMAdaptor()
422cdf0e10cSrcweir {
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
425cdf0e10cSrcweir /*
426cdf0e10cSrcweir * NetWMAdaptor constructor
427cdf0e10cSrcweir */
428cdf0e10cSrcweir
NetWMAdaptor(SalDisplay * pSalDisplay)429cdf0e10cSrcweir NetWMAdaptor::NetWMAdaptor( SalDisplay* pSalDisplay ) :
430cdf0e10cSrcweir WMAdaptor( pSalDisplay )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir // currently all _NET WMs do transient like expected
433cdf0e10cSrcweir m_bTransientBehaviour = true;
434cdf0e10cSrcweir
435cdf0e10cSrcweir Atom aRealType = None;
436cdf0e10cSrcweir int nFormat = 8;
437cdf0e10cSrcweir unsigned long nItems = 0;
438cdf0e10cSrcweir unsigned long nBytesLeft = 0;
439cdf0e10cSrcweir unsigned char* pProperty = NULL;
440cdf0e10cSrcweir bool bNetWM = false;
441cdf0e10cSrcweir
442cdf0e10cSrcweir initAtoms();
443cdf0e10cSrcweir
444cdf0e10cSrcweir // check for NetWM
445cdf0e10cSrcweir bNetWM = getNetWmName();
446cdf0e10cSrcweir if( bNetWM
447cdf0e10cSrcweir && XGetWindowProperty( m_pDisplay,
448cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
449cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTED ],
450cdf0e10cSrcweir 0, 0,
451cdf0e10cSrcweir False,
452cdf0e10cSrcweir XA_ATOM,
453cdf0e10cSrcweir &aRealType,
454cdf0e10cSrcweir &nFormat,
455cdf0e10cSrcweir &nItems,
456cdf0e10cSrcweir &nBytesLeft,
457cdf0e10cSrcweir &pProperty ) == 0
458cdf0e10cSrcweir && aRealType == XA_ATOM
459cdf0e10cSrcweir && nFormat == 32
460cdf0e10cSrcweir )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir if( pProperty )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir XFree( pProperty );
465cdf0e10cSrcweir pProperty = NULL;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir // collect supported protocols
468cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
469cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
470cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTED ],
471cdf0e10cSrcweir 0, nBytesLeft/4,
472cdf0e10cSrcweir False,
473cdf0e10cSrcweir XA_ATOM,
474cdf0e10cSrcweir &aRealType,
475cdf0e10cSrcweir &nFormat,
476cdf0e10cSrcweir &nItems,
477cdf0e10cSrcweir &nBytesLeft,
478cdf0e10cSrcweir &pProperty ) == 0
479cdf0e10cSrcweir && nItems
480cdf0e10cSrcweir )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir Atom* pAtoms = (Atom*)pProperty;
483cdf0e10cSrcweir char** pAtomNames = (char**)alloca( sizeof(char*)*nItems );
484cdf0e10cSrcweir if( XGetAtomNames( m_pDisplay, pAtoms, nItems, pAtomNames ) )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
487cdf0e10cSrcweir fprintf( stderr, "supported protocols:\n" );
488cdf0e10cSrcweir #endif
489cdf0e10cSrcweir for( unsigned int i = 0; i < nItems; i++ )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir // #i80971# protect against invalid atoms
492cdf0e10cSrcweir if( pAtomNames[i] == NULL )
493cdf0e10cSrcweir continue;
494cdf0e10cSrcweir
495cdf0e10cSrcweir int nProtocol = -1;
496cdf0e10cSrcweir WMAdaptorProtocol aSearch;
497cdf0e10cSrcweir aSearch.pProtocol = pAtomNames[i];
498cdf0e10cSrcweir WMAdaptorProtocol* pMatch = (WMAdaptorProtocol*)
499cdf0e10cSrcweir bsearch( &aSearch,
500cdf0e10cSrcweir aProtocolTab,
501cdf0e10cSrcweir sizeof( aProtocolTab )/sizeof( aProtocolTab[0] ),
502cdf0e10cSrcweir sizeof( struct WMAdaptorProtocol ),
503cdf0e10cSrcweir compareProtocol );
504cdf0e10cSrcweir if( pMatch )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir nProtocol = pMatch->nProtocol;
507cdf0e10cSrcweir m_aWMAtoms[ nProtocol ] = pAtoms[ i ];
508cdf0e10cSrcweir if( pMatch->nProtocol == NET_WM_STATE_STAYS_ON_TOP )
509cdf0e10cSrcweir m_bEnableAlwaysOnTopWorks = true;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
512cdf0e10cSrcweir fprintf( stderr, " %s%s\n", pAtomNames[i], nProtocol != -1 ? "" : " (unsupported)" );
513cdf0e10cSrcweir #endif
514cdf0e10cSrcweir
515cdf0e10cSrcweir XFree( pAtomNames[i] );
516cdf0e10cSrcweir }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir XFree( pProperty );
519cdf0e10cSrcweir pProperty = NULL;
520cdf0e10cSrcweir }
521cdf0e10cSrcweir else if( pProperty )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir XFree( pProperty );
524cdf0e10cSrcweir pProperty = NULL;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir
527cdf0e10cSrcweir // get number of desktops
528cdf0e10cSrcweir if( m_aWMAtoms[ NET_NUMBER_OF_DESKTOPS ]
529cdf0e10cSrcweir && XGetWindowProperty( m_pDisplay,
530cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
531cdf0e10cSrcweir m_aWMAtoms[ NET_NUMBER_OF_DESKTOPS ],
532cdf0e10cSrcweir 0, 1,
533cdf0e10cSrcweir False,
534cdf0e10cSrcweir XA_CARDINAL,
535cdf0e10cSrcweir &aRealType,
536cdf0e10cSrcweir &nFormat,
537cdf0e10cSrcweir &nItems,
538cdf0e10cSrcweir &nBytesLeft,
539cdf0e10cSrcweir &pProperty ) == 0
540cdf0e10cSrcweir && pProperty
541cdf0e10cSrcweir )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir m_nDesktops = *(long*)pProperty;
544cdf0e10cSrcweir XFree( pProperty );
545cdf0e10cSrcweir pProperty = NULL;
546cdf0e10cSrcweir // get work areas
547cdf0e10cSrcweir if( m_aWMAtoms[ NET_WORKAREA ]
548cdf0e10cSrcweir && XGetWindowProperty( m_pDisplay,
549cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
550cdf0e10cSrcweir m_aWMAtoms[ NET_WORKAREA ],
551cdf0e10cSrcweir 0, 4*m_nDesktops,
552cdf0e10cSrcweir False,
553cdf0e10cSrcweir XA_CARDINAL,
554cdf0e10cSrcweir &aRealType,
555cdf0e10cSrcweir &nFormat,
556cdf0e10cSrcweir &nItems,
557cdf0e10cSrcweir &nBytesLeft,
558cdf0e10cSrcweir &pProperty
559cdf0e10cSrcweir ) == 0
560cdf0e10cSrcweir && nItems == 4*(unsigned)m_nDesktops
561cdf0e10cSrcweir )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir m_aWMWorkAreas = ::std::vector< Rectangle > ( m_nDesktops );
564cdf0e10cSrcweir long* pValues = (long*)pProperty;
565cdf0e10cSrcweir for( int i = 0; i < m_nDesktops; i++ )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir Point aPoint( pValues[4*i],
568cdf0e10cSrcweir pValues[4*i+1] );
569cdf0e10cSrcweir Size aSize( pValues[4*i+2],
570cdf0e10cSrcweir pValues[4*i+3] );
571cdf0e10cSrcweir Rectangle aWorkArea( aPoint, aSize );
572cdf0e10cSrcweir m_aWMWorkAreas[i] = aWorkArea;
573cdf0e10cSrcweir if( aWorkArea != m_aWMWorkAreas[0] )
574cdf0e10cSrcweir m_bEqualWorkAreas = false;
575cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
576cdf0e10cSrcweir fprintf( stderr, "workarea %d: %ldx%ld+%ld+%ld\n",
577cdf0e10cSrcweir i,
578cdf0e10cSrcweir m_aWMWorkAreas[i].GetWidth(),
579cdf0e10cSrcweir m_aWMWorkAreas[i].GetHeight(),
580cdf0e10cSrcweir m_aWMWorkAreas[i].Left(),
581cdf0e10cSrcweir m_aWMWorkAreas[i].Top() );
582cdf0e10cSrcweir #endif
583cdf0e10cSrcweir }
584cdf0e10cSrcweir XFree( pProperty );
585cdf0e10cSrcweir }
586cdf0e10cSrcweir else
587cdf0e10cSrcweir {
588cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
589cdf0e10cSrcweir fprintf( stderr, "%ld workareas for %d desktops !\n", nItems/4, m_nDesktops );
590cdf0e10cSrcweir #endif
591cdf0e10cSrcweir if( pProperty )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir XFree(pProperty);
594cdf0e10cSrcweir pProperty = NULL;
595cdf0e10cSrcweir }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir }
598cdf0e10cSrcweir else if( pProperty )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir XFree( pProperty );
601cdf0e10cSrcweir pProperty = NULL;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir else if( pProperty )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir XFree( pProperty );
607cdf0e10cSrcweir pProperty = NULL;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir }
610cdf0e10cSrcweir
611cdf0e10cSrcweir /*
612cdf0e10cSrcweir * NetWMAdaptor destructor
613cdf0e10cSrcweir */
~NetWMAdaptor()614cdf0e10cSrcweir NetWMAdaptor::~NetWMAdaptor()
615cdf0e10cSrcweir {
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
618cdf0e10cSrcweir /*
619cdf0e10cSrcweir * GnomeWMAdaptor constructor
620cdf0e10cSrcweir */
621cdf0e10cSrcweir
GnomeWMAdaptor(SalDisplay * pSalDisplay)622cdf0e10cSrcweir GnomeWMAdaptor::GnomeWMAdaptor( SalDisplay* pSalDisplay ) :
623cdf0e10cSrcweir WMAdaptor( pSalDisplay ),
624cdf0e10cSrcweir m_bValid( false )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir // currently all Gnome WMs do transient like expected
627cdf0e10cSrcweir m_bTransientBehaviour = true;
628cdf0e10cSrcweir
629cdf0e10cSrcweir Atom aRealType = None;
630cdf0e10cSrcweir int nFormat = 8;
631cdf0e10cSrcweir unsigned long nItems = 0;
632cdf0e10cSrcweir unsigned long nBytesLeft = 0;
633cdf0e10cSrcweir unsigned char* pProperty = NULL;
634cdf0e10cSrcweir
635cdf0e10cSrcweir initAtoms();
636cdf0e10cSrcweir
637cdf0e10cSrcweir // check for GnomeWM
638cdf0e10cSrcweir if( m_aWMAtoms[ WIN_SUPPORTING_WM_CHECK ] && m_aWMAtoms[ WIN_PROTOCOLS ] )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir XLIB_Window aWMChild = None;
641cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
642cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
643cdf0e10cSrcweir m_aWMAtoms[ WIN_SUPPORTING_WM_CHECK ],
644cdf0e10cSrcweir 0, 1,
645cdf0e10cSrcweir False,
646cdf0e10cSrcweir XA_CARDINAL,
647cdf0e10cSrcweir &aRealType,
648cdf0e10cSrcweir &nFormat,
649cdf0e10cSrcweir &nItems,
650cdf0e10cSrcweir &nBytesLeft,
651cdf0e10cSrcweir &pProperty ) == 0
652cdf0e10cSrcweir && aRealType == XA_CARDINAL
653cdf0e10cSrcweir && nFormat == 32
654cdf0e10cSrcweir && nItems != 0
655cdf0e10cSrcweir )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir aWMChild = *(XLIB_Window*)pProperty;
658cdf0e10cSrcweir XFree( pProperty );
659cdf0e10cSrcweir pProperty = NULL;
660cdf0e10cSrcweir XLIB_Window aCheckWindow = None;
661cdf0e10cSrcweir m_pSalDisplay->GetXLib()->PushXErrorLevel( true );
662cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
663cdf0e10cSrcweir aWMChild,
664cdf0e10cSrcweir m_aWMAtoms[ WIN_SUPPORTING_WM_CHECK ],
665cdf0e10cSrcweir 0, 1,
666cdf0e10cSrcweir False,
667cdf0e10cSrcweir XA_CARDINAL,
668cdf0e10cSrcweir &aRealType,
669cdf0e10cSrcweir &nFormat,
670cdf0e10cSrcweir &nItems,
671cdf0e10cSrcweir &nBytesLeft,
672cdf0e10cSrcweir &pProperty ) == 0
673cdf0e10cSrcweir && aRealType == XA_CARDINAL
674cdf0e10cSrcweir && nFormat == 32
675cdf0e10cSrcweir && nItems != 0
676cdf0e10cSrcweir && ! m_pSalDisplay->GetXLib()->HasXErrorOccured()
677cdf0e10cSrcweir )
678cdf0e10cSrcweir {
679cdf0e10cSrcweir aCheckWindow = *(XLIB_Window*)pProperty;
680cdf0e10cSrcweir XFree( pProperty );
681cdf0e10cSrcweir pProperty = NULL;
682cdf0e10cSrcweir if( aCheckWindow == aWMChild )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir m_bValid = true;
685cdf0e10cSrcweir /*
686cdf0e10cSrcweir * get name of WM
687cdf0e10cSrcweir * this is NOT part of the GNOME WM hints, but e.g. Sawfish
688cdf0e10cSrcweir * already supports this part of the extended WM hints
689cdf0e10cSrcweir */
690cdf0e10cSrcweir m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
691cdf0e10cSrcweir getNetWmName();
692cdf0e10cSrcweir }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir m_pSalDisplay->GetXLib()->PopXErrorLevel();
695cdf0e10cSrcweir }
696cdf0e10cSrcweir else if( pProperty )
697cdf0e10cSrcweir {
698cdf0e10cSrcweir XFree( pProperty );
699cdf0e10cSrcweir pProperty = NULL;
700cdf0e10cSrcweir }
701cdf0e10cSrcweir }
702cdf0e10cSrcweir if( m_bValid
703cdf0e10cSrcweir && XGetWindowProperty( m_pDisplay,
704cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
705cdf0e10cSrcweir m_aWMAtoms[ WIN_PROTOCOLS ],
706cdf0e10cSrcweir 0, 0,
707cdf0e10cSrcweir False,
708cdf0e10cSrcweir XA_ATOM,
709cdf0e10cSrcweir &aRealType,
710cdf0e10cSrcweir &nFormat,
711cdf0e10cSrcweir &nItems,
712cdf0e10cSrcweir &nBytesLeft,
713cdf0e10cSrcweir &pProperty ) == 0
714cdf0e10cSrcweir && aRealType == XA_ATOM
715cdf0e10cSrcweir && nFormat == 32
716cdf0e10cSrcweir )
717cdf0e10cSrcweir {
718cdf0e10cSrcweir if( pProperty )
719cdf0e10cSrcweir {
720cdf0e10cSrcweir XFree( pProperty );
721cdf0e10cSrcweir pProperty = NULL;
722cdf0e10cSrcweir }
723cdf0e10cSrcweir // collect supported protocols
724cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
725cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
726cdf0e10cSrcweir m_aWMAtoms[ WIN_PROTOCOLS ],
727cdf0e10cSrcweir 0, nBytesLeft/4,
728cdf0e10cSrcweir False,
729cdf0e10cSrcweir XA_ATOM,
730cdf0e10cSrcweir &aRealType,
731cdf0e10cSrcweir &nFormat,
732cdf0e10cSrcweir &nItems,
733cdf0e10cSrcweir &nBytesLeft,
734cdf0e10cSrcweir &pProperty ) == 0
735cdf0e10cSrcweir && pProperty
736cdf0e10cSrcweir )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir Atom* pAtoms = (Atom*)pProperty;
739cdf0e10cSrcweir char** pAtomNames = (char**)alloca( sizeof(char*)*nItems );
740cdf0e10cSrcweir if( XGetAtomNames( m_pDisplay, pAtoms, nItems, pAtomNames ) )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
743cdf0e10cSrcweir fprintf( stderr, "supported protocols:\n" );
744cdf0e10cSrcweir #endif
745cdf0e10cSrcweir for( unsigned int i = 0; i < nItems; i++ )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir // #i80971# protect against invalid atoms
748cdf0e10cSrcweir if( pAtomNames[i] == NULL )
749cdf0e10cSrcweir continue;
750cdf0e10cSrcweir
751cdf0e10cSrcweir int nProtocol = -1;
752cdf0e10cSrcweir WMAdaptorProtocol aSearch;
753cdf0e10cSrcweir aSearch.pProtocol = pAtomNames[i];
754cdf0e10cSrcweir WMAdaptorProtocol* pMatch = (WMAdaptorProtocol*)
755cdf0e10cSrcweir bsearch( &aSearch,
756cdf0e10cSrcweir aProtocolTab,
757cdf0e10cSrcweir sizeof( aProtocolTab )/sizeof( aProtocolTab[0] ),
758cdf0e10cSrcweir sizeof( struct WMAdaptorProtocol ),
759cdf0e10cSrcweir compareProtocol );
760cdf0e10cSrcweir if( pMatch )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir nProtocol = pMatch->nProtocol;
763cdf0e10cSrcweir m_aWMAtoms[ nProtocol ] = pAtoms[ i ];
764cdf0e10cSrcweir if( pMatch->nProtocol == WIN_LAYER )
765cdf0e10cSrcweir m_bEnableAlwaysOnTopWorks = true;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir if( strncmp( "_ICEWM_TRAY", pAtomNames[i], 11 ) == 0 )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir m_aWMName = String(RTL_CONSTASCII_USTRINGPARAM("IceWM" ));
770cdf0e10cSrcweir m_nWinGravity = NorthWestGravity;
771cdf0e10cSrcweir m_nInitWinGravity = NorthWestGravity;
772cdf0e10cSrcweir }
773cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
774cdf0e10cSrcweir fprintf( stderr, " %s%s\n", pAtomNames[i], nProtocol != -1 ? "" : " (unsupported)" );
775cdf0e10cSrcweir #endif
776cdf0e10cSrcweir
777cdf0e10cSrcweir XFree( pAtomNames[i] );
778cdf0e10cSrcweir }
779cdf0e10cSrcweir }
780cdf0e10cSrcweir XFree( pProperty );
781cdf0e10cSrcweir pProperty = NULL;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir else if( pProperty )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir XFree( pProperty );
786cdf0e10cSrcweir pProperty = NULL;
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
789cdf0e10cSrcweir // get number of desktops
790cdf0e10cSrcweir if( m_aWMAtoms[ WIN_WORKSPACE_COUNT ]
791cdf0e10cSrcweir && XGetWindowProperty( m_pDisplay,
792cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
793cdf0e10cSrcweir m_aWMAtoms[ WIN_WORKSPACE_COUNT ],
794cdf0e10cSrcweir 0, 1,
795cdf0e10cSrcweir False,
796cdf0e10cSrcweir XA_CARDINAL,
797cdf0e10cSrcweir &aRealType,
798cdf0e10cSrcweir &nFormat,
799cdf0e10cSrcweir &nItems,
800cdf0e10cSrcweir &nBytesLeft,
801cdf0e10cSrcweir &pProperty ) == 0
802cdf0e10cSrcweir && pProperty
803cdf0e10cSrcweir )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir m_nDesktops = *(long*)pProperty;
806cdf0e10cSrcweir XFree( pProperty );
807cdf0e10cSrcweir pProperty = NULL;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir else if( pProperty )
810cdf0e10cSrcweir {
811cdf0e10cSrcweir XFree( pProperty );
812cdf0e10cSrcweir pProperty = NULL;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir else if( pProperty )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir XFree( pProperty );
818cdf0e10cSrcweir pProperty = NULL;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir /*
823cdf0e10cSrcweir * GnomeWMAdaptor destructor
824cdf0e10cSrcweir */
~GnomeWMAdaptor()825cdf0e10cSrcweir GnomeWMAdaptor::~GnomeWMAdaptor()
826cdf0e10cSrcweir {
827cdf0e10cSrcweir }
828cdf0e10cSrcweir
829cdf0e10cSrcweir /*
830cdf0e10cSrcweir * getNetWmName()
831cdf0e10cSrcweir */
getNetWmName()832cdf0e10cSrcweir bool WMAdaptor::getNetWmName()
833cdf0e10cSrcweir {
834cdf0e10cSrcweir Atom aRealType = None;
835cdf0e10cSrcweir int nFormat = 8;
836cdf0e10cSrcweir unsigned long nItems = 0;
837cdf0e10cSrcweir unsigned long nBytesLeft = 0;
838cdf0e10cSrcweir unsigned char* pProperty = NULL;
839cdf0e10cSrcweir bool bNetWM = false;
840cdf0e10cSrcweir
841cdf0e10cSrcweir if( m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ] && m_aWMAtoms[ NET_WM_NAME ] )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir XLIB_Window aWMChild = None;
844cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
845cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
846cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ],
847cdf0e10cSrcweir 0, 1,
848cdf0e10cSrcweir False,
849cdf0e10cSrcweir XA_WINDOW,
850cdf0e10cSrcweir &aRealType,
851cdf0e10cSrcweir &nFormat,
852cdf0e10cSrcweir &nItems,
853cdf0e10cSrcweir &nBytesLeft,
854cdf0e10cSrcweir &pProperty ) == 0
855cdf0e10cSrcweir && aRealType == XA_WINDOW
856cdf0e10cSrcweir && nFormat == 32
857cdf0e10cSrcweir && nItems != 0
858cdf0e10cSrcweir )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir aWMChild = *(XLIB_Window*)pProperty;
861cdf0e10cSrcweir XFree( pProperty );
862cdf0e10cSrcweir pProperty = NULL;
863cdf0e10cSrcweir XLIB_Window aCheckWindow = None;
864cdf0e10cSrcweir m_pSalDisplay->GetXLib()->PushXErrorLevel( true );
865cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
866cdf0e10cSrcweir aWMChild,
867cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ],
868cdf0e10cSrcweir 0, 1,
869cdf0e10cSrcweir False,
870cdf0e10cSrcweir XA_WINDOW,
871cdf0e10cSrcweir &aRealType,
872cdf0e10cSrcweir &nFormat,
873cdf0e10cSrcweir &nItems,
874cdf0e10cSrcweir &nBytesLeft,
875cdf0e10cSrcweir &pProperty ) == 0
876cdf0e10cSrcweir && aRealType == XA_WINDOW
877cdf0e10cSrcweir && nFormat == 32
878cdf0e10cSrcweir && nItems != 0
879cdf0e10cSrcweir && ! m_pSalDisplay->GetXLib()->HasXErrorOccured()
880cdf0e10cSrcweir )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir aCheckWindow = *(XLIB_Window*)pProperty;
883cdf0e10cSrcweir XFree( pProperty );
884cdf0e10cSrcweir pProperty = NULL;
885cdf0e10cSrcweir if( aCheckWindow == aWMChild )
886cdf0e10cSrcweir {
887cdf0e10cSrcweir bNetWM = true;
888cdf0e10cSrcweir // get name of WM
889cdf0e10cSrcweir m_aWMAtoms[ UTF8_STRING ] = XInternAtom( m_pDisplay, "UTF8_STRING", False );
890cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
891cdf0e10cSrcweir aWMChild,
892cdf0e10cSrcweir m_aWMAtoms[ NET_WM_NAME ],
893cdf0e10cSrcweir 0, 256,
894cdf0e10cSrcweir False,
895cdf0e10cSrcweir AnyPropertyType, /* m_aWMAtoms[ UTF8_STRING ],*/
896cdf0e10cSrcweir &aRealType,
897cdf0e10cSrcweir &nFormat,
898cdf0e10cSrcweir &nItems,
899cdf0e10cSrcweir &nBytesLeft,
900cdf0e10cSrcweir &pProperty ) == 0
901cdf0e10cSrcweir && nItems != 0
902cdf0e10cSrcweir )
903cdf0e10cSrcweir {
904cdf0e10cSrcweir if (aRealType == m_aWMAtoms[ UTF8_STRING ])
905cdf0e10cSrcweir {
906cdf0e10cSrcweir m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
907cdf0e10cSrcweir }
908cdf0e10cSrcweir else
909cdf0e10cSrcweir if (aRealType == XA_STRING)
910cdf0e10cSrcweir {
911cdf0e10cSrcweir m_aWMName = String( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_ISO_8859_1 );
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir XFree( pProperty );
915cdf0e10cSrcweir pProperty = NULL;
916cdf0e10cSrcweir }
917cdf0e10cSrcweir else if( pProperty )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir XFree( pProperty );
920cdf0e10cSrcweir pProperty = NULL;
921cdf0e10cSrcweir }
922cdf0e10cSrcweir // if this is metacity, check for version to enable a legacy workaround
923cdf0e10cSrcweir if( m_aWMName.EqualsAscii( "Metacity" ) )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir int nVersionMajor = 0, nVersionMinor = 0;
926cdf0e10cSrcweir Atom nVersionAtom = XInternAtom( m_pDisplay, "_METACITY_VERSION", True );
927cdf0e10cSrcweir if( nVersionAtom )
928cdf0e10cSrcweir {
929cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
930cdf0e10cSrcweir aWMChild,
931cdf0e10cSrcweir nVersionAtom,
932cdf0e10cSrcweir 0, 256,
933cdf0e10cSrcweir False,
934cdf0e10cSrcweir m_aWMAtoms[ UTF8_STRING ],
935cdf0e10cSrcweir &aRealType,
936cdf0e10cSrcweir &nFormat,
937cdf0e10cSrcweir &nItems,
938cdf0e10cSrcweir &nBytesLeft,
939cdf0e10cSrcweir &pProperty ) == 0
940cdf0e10cSrcweir && nItems != 0
941cdf0e10cSrcweir )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir String aMetaVersion( (sal_Char*)pProperty, nItems, RTL_TEXTENCODING_UTF8 );
944cdf0e10cSrcweir nVersionMajor = aMetaVersion.GetToken( 0, '.' ).ToInt32();
945cdf0e10cSrcweir nVersionMinor = aMetaVersion.GetToken( 1, '.' ).ToInt32();
946cdf0e10cSrcweir }
947cdf0e10cSrcweir if( pProperty )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir XFree( pProperty );
950cdf0e10cSrcweir pProperty = NULL;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir }
953cdf0e10cSrcweir if( nVersionMajor < 2 || (nVersionMajor == 2 && nVersionMinor < 12) )
954cdf0e10cSrcweir m_bLegacyPartialFullscreen = true;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir }
957cdf0e10cSrcweir }
958cdf0e10cSrcweir else if( pProperty )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir XFree( pProperty );
961cdf0e10cSrcweir pProperty = NULL;
962cdf0e10cSrcweir }
963cdf0e10cSrcweir m_pSalDisplay->GetXLib()->PopXErrorLevel();
964cdf0e10cSrcweir }
965cdf0e10cSrcweir else if( pProperty )
966cdf0e10cSrcweir {
967cdf0e10cSrcweir XFree( pProperty );
968cdf0e10cSrcweir pProperty = NULL;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir }
971cdf0e10cSrcweir return bNetWM;
972cdf0e10cSrcweir }
973cdf0e10cSrcweir
getWMshouldSwitchWorkspace() const974cdf0e10cSrcweir bool WMAdaptor::getWMshouldSwitchWorkspace() const
975cdf0e10cSrcweir {
976cdf0e10cSrcweir if( ! m_bWMshouldSwitchWorkspaceInit )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir WMAdaptor * pWMA = const_cast<WMAdaptor*>(this);
979cdf0e10cSrcweir
980cdf0e10cSrcweir pWMA->m_bWMshouldSwitchWorkspace = true;
981cdf0e10cSrcweir vcl::SettingsConfigItem* pItem = vcl::SettingsConfigItem::get();
982cdf0e10cSrcweir rtl::OUString aSetting( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WM" ) ),
983cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ShouldSwitchWorkspace" ) ) ) );
984cdf0e10cSrcweir if( aSetting.getLength() == 0 )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir if( m_aWMName.EqualsAscii( "awesome" ) )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir pWMA->m_bWMshouldSwitchWorkspace = false;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir }
991cdf0e10cSrcweir else
992cdf0e10cSrcweir pWMA->m_bWMshouldSwitchWorkspace = aSetting.toBoolean();
993cdf0e10cSrcweir pWMA->m_bWMshouldSwitchWorkspaceInit = true;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir return m_bWMshouldSwitchWorkspace;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir
998cdf0e10cSrcweir /*
999cdf0e10cSrcweir * WMAdaptor::isValid()
1000cdf0e10cSrcweir */
isValid() const1001cdf0e10cSrcweir bool WMAdaptor::isValid() const
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir return true;
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir /*
1007cdf0e10cSrcweir * NetWMAdaptor::isValid()
1008cdf0e10cSrcweir */
isValid() const1009cdf0e10cSrcweir bool NetWMAdaptor::isValid() const
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir // some necessary sanity checks; there are WMs out there
1012cdf0e10cSrcweir // which implement some of the WM hints spec without
1013cdf0e10cSrcweir // real functionality
1014cdf0e10cSrcweir return
1015cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTED ]
1016cdf0e10cSrcweir && m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ]
1017cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_NAME ]
1018cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_WINDOW_TYPE_NORMAL ]
1019cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_WINDOW_TYPE_DIALOG ]
1020cdf0e10cSrcweir ;
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir /*
1024cdf0e10cSrcweir * GnomeWMAdaptor::isValid()
1025cdf0e10cSrcweir */
isValid() const1026cdf0e10cSrcweir bool GnomeWMAdaptor::isValid() const
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir return m_bValid;
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir /*
1032cdf0e10cSrcweir * WMAdaptor::initAtoms
1033cdf0e10cSrcweir */
1034cdf0e10cSrcweir
initAtoms()1035cdf0e10cSrcweir void WMAdaptor::initAtoms()
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir // get basic atoms
1038cdf0e10cSrcweir for( unsigned int i = 0; i < sizeof( aAtomTab )/sizeof( aAtomTab[0] ); i++ )
1039cdf0e10cSrcweir m_aWMAtoms[ aAtomTab[i].nProtocol ] = XInternAtom( m_pDisplay, aAtomTab[i].pProtocol, False );
1040cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTING_WM_CHECK ] = XInternAtom( m_pDisplay, "_NET_SUPPORTING_WM_CHECK", True );
1041cdf0e10cSrcweir m_aWMAtoms[ NET_WM_NAME ] = XInternAtom( m_pDisplay, "_NET_WM_NAME", True );
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir
1044cdf0e10cSrcweir /*
1045cdf0e10cSrcweir * NetWMAdaptor::initAtoms
1046cdf0e10cSrcweir */
1047cdf0e10cSrcweir
initAtoms()1048cdf0e10cSrcweir void NetWMAdaptor::initAtoms()
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir WMAdaptor::initAtoms();
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir m_aWMAtoms[ NET_SUPPORTED ] = XInternAtom( m_pDisplay, "_NET_SUPPORTED", True );
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir /*
1056cdf0e10cSrcweir * GnomeWMAdaptor::initAtoms
1057cdf0e10cSrcweir */
1058cdf0e10cSrcweir
initAtoms()1059cdf0e10cSrcweir void GnomeWMAdaptor::initAtoms()
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir WMAdaptor::initAtoms();
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir m_aWMAtoms[ WIN_PROTOCOLS ] = XInternAtom( m_pDisplay, "_WIN_PROTOCOLS", True );
1064cdf0e10cSrcweir m_aWMAtoms[ WIN_SUPPORTING_WM_CHECK ] = XInternAtom( m_pDisplay, "_WIN_SUPPORTING_WM_CHECK", True );
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir /*
1068cdf0e10cSrcweir * WMAdaptor::setWMName
1069cdf0e10cSrcweir * sets WM_NAME
1070cdf0e10cSrcweir * WM_ICON_NAME
1071cdf0e10cSrcweir */
1072cdf0e10cSrcweir
setWMName(X11SalFrame * pFrame,const String & rWMName) const1073cdf0e10cSrcweir void WMAdaptor::setWMName( X11SalFrame* pFrame, const String& rWMName ) const
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir ByteString aTitle( rWMName, osl_getThreadTextEncoding() );
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir if( ! rWMName.Len() && m_aWMName.EqualsAscii( "Dtwm" ) )
1078cdf0e10cSrcweir aTitle = " ";
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir ::rtl::OString aWMLocale;
1081cdf0e10cSrcweir rtl_Locale* pLocale = NULL;
1082cdf0e10cSrcweir osl_getProcessLocale( &pLocale );
1083cdf0e10cSrcweir if( pLocale )
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir ::rtl::OUString aLocaleString( pLocale->Language );
1086cdf0e10cSrcweir ::rtl::OUString aCountry( pLocale->Country );
1087cdf0e10cSrcweir ::rtl::OUString aVariant( pLocale->Variant );
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir if( aCountry.getLength() )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir aLocaleString += ::rtl::OUString::createFromAscii( "_" );
1092cdf0e10cSrcweir aLocaleString += aCountry;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir if( aVariant.getLength() )
1095cdf0e10cSrcweir aLocaleString += aVariant;
1096cdf0e10cSrcweir aWMLocale = ::rtl::OUStringToOString( aLocaleString, RTL_TEXTENCODING_ISO_8859_1 );
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir else
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir static const char* pLang = getenv( "LANG" );
1101cdf0e10cSrcweir aWMLocale = pLang ? pLang : "C";
1102cdf0e10cSrcweir }
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir static bool bTrustXmb = true;
1105cdf0e10cSrcweir #ifdef SOLARIS
1106cdf0e10cSrcweir /* #i64273# there are some weird cases when using IIIMP on Solaris
1107cdf0e10cSrcweir * where for unknown reasons XmbTextListToTextProperty results in
1108cdf0e10cSrcweir * garbage. Test one string once to ensure safety.
1109cdf0e10cSrcweir *
1110cdf0e10cSrcweir * FIXME: This must be a bug in xiiimp.so.2 somewhere. However
1111cdf0e10cSrcweir * it was not possible to recreate this in a small sample program.
1112cdf0e10cSrcweir * This reeks of memory corruption somehow.
1113cdf0e10cSrcweir */
1114cdf0e10cSrcweir static bool bOnce = true;
1115cdf0e10cSrcweir if( bOnce )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir bOnce = false;
1118cdf0e10cSrcweir XTextProperty aTestProp = { NULL, None, 0, 0 };
1119cdf0e10cSrcweir const char *pText = "trustme";
1120cdf0e10cSrcweir XmbTextListToTextProperty( m_pDisplay,
1121cdf0e10cSrcweir &const_cast<char*>(pText),
1122cdf0e10cSrcweir 1,
1123cdf0e10cSrcweir XStdICCTextStyle,
1124cdf0e10cSrcweir &aTestProp );
1125cdf0e10cSrcweir bTrustXmb = (aTestProp.nitems == 7) &&
1126cdf0e10cSrcweir (aTestProp.value != NULL ) &&
1127cdf0e10cSrcweir (strncmp( (char*)aTestProp.value, pText, 7 ) == 0) &&
1128cdf0e10cSrcweir (aTestProp.encoding == XA_STRING);
1129cdf0e10cSrcweir if( aTestProp.value )
1130cdf0e10cSrcweir XFree( aTestProp.value );
1131cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1132cdf0e10cSrcweir fprintf( stderr, "%s\n",
1133cdf0e10cSrcweir bTrustXmb ?
1134cdf0e10cSrcweir "XmbTextListToTextProperty seems to work" :
1135cdf0e10cSrcweir "XmbTextListToTextProperty does not seem to work" );
1136cdf0e10cSrcweir #endif
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir #endif
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir char* pT = const_cast<char*>(aTitle.GetBuffer());
1141cdf0e10cSrcweir XTextProperty aProp = { NULL, None, 0, 0 };
1142cdf0e10cSrcweir if( bTrustXmb )
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir XmbTextListToTextProperty( m_pDisplay,
1145cdf0e10cSrcweir &pT,
1146cdf0e10cSrcweir 1,
1147cdf0e10cSrcweir XStdICCTextStyle,
1148cdf0e10cSrcweir &aProp );
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir unsigned char* pData = aProp.nitems ? aProp.value : (unsigned char*)aTitle.GetBuffer();
1152cdf0e10cSrcweir Atom nType = aProp.nitems ? aProp.encoding : XA_STRING;
1153cdf0e10cSrcweir int nFormat = aProp.nitems ? aProp.format : 8;
1154cdf0e10cSrcweir int nBytes = aProp.nitems ? aProp.nitems : aTitle.Len();
1155cdf0e10cSrcweir const SystemEnvData* pEnv = pFrame->GetSystemData();
1156cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1157cdf0e10cSrcweir (XLIB_Window)pEnv->aShellWindow,
1158cdf0e10cSrcweir XA_WM_NAME,
1159cdf0e10cSrcweir nType,
1160cdf0e10cSrcweir nFormat,
1161cdf0e10cSrcweir PropModeReplace,
1162cdf0e10cSrcweir pData,
1163cdf0e10cSrcweir nBytes );
1164cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1165cdf0e10cSrcweir (XLIB_Window)pEnv->aShellWindow,
1166cdf0e10cSrcweir XA_WM_ICON_NAME,
1167cdf0e10cSrcweir nType,
1168cdf0e10cSrcweir nFormat,
1169cdf0e10cSrcweir PropModeReplace,
1170cdf0e10cSrcweir pData,
1171cdf0e10cSrcweir nBytes );
1172cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1173cdf0e10cSrcweir (XLIB_Window)pEnv->aShellWindow,
1174cdf0e10cSrcweir m_aWMAtoms[ WM_LOCALE_NAME ],
1175cdf0e10cSrcweir XA_STRING,
1176cdf0e10cSrcweir 8,
1177cdf0e10cSrcweir PropModeReplace,
1178cdf0e10cSrcweir (unsigned char*)aWMLocale.getStr(),
1179cdf0e10cSrcweir aWMLocale.getLength() );
1180cdf0e10cSrcweir if (aProp.value != NULL)
1181cdf0e10cSrcweir XFree( aProp.value );
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir
1184cdf0e10cSrcweir /*
1185cdf0e10cSrcweir * NetWMAdaptor::setWMName
1186cdf0e10cSrcweir * sets WM_NAME
1187cdf0e10cSrcweir * _NET_WM_NAME
1188cdf0e10cSrcweir * WM_ICON_NAME
1189cdf0e10cSrcweir * _NET_WM_ICON_NAME
1190cdf0e10cSrcweir */
setWMName(X11SalFrame * pFrame,const String & rWMName) const1191cdf0e10cSrcweir void NetWMAdaptor::setWMName( X11SalFrame* pFrame, const String& rWMName ) const
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir WMAdaptor::setWMName( pFrame, rWMName );
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir ByteString aTitle( rWMName, RTL_TEXTENCODING_UTF8 );
1196cdf0e10cSrcweir const SystemEnvData* pEnv = pFrame->GetSystemData();
1197cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_NAME ] )
1198cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1199cdf0e10cSrcweir (XLIB_Window)pEnv->aShellWindow,
1200cdf0e10cSrcweir m_aWMAtoms[ NET_WM_NAME ],
1201cdf0e10cSrcweir m_aWMAtoms[ UTF8_STRING ],
1202cdf0e10cSrcweir 8,
1203cdf0e10cSrcweir PropModeReplace,
1204cdf0e10cSrcweir (unsigned char*)aTitle.GetBuffer(),
1205cdf0e10cSrcweir aTitle.Len()+1 );
1206cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_ICON_NAME ] )
1207cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1208cdf0e10cSrcweir (XLIB_Window)pEnv->aShellWindow,
1209cdf0e10cSrcweir m_aWMAtoms[ NET_WM_ICON_NAME ],
1210cdf0e10cSrcweir m_aWMAtoms[ UTF8_STRING ],
1211cdf0e10cSrcweir 8,
1212cdf0e10cSrcweir PropModeReplace,
1213cdf0e10cSrcweir (unsigned char*)aTitle.GetBuffer(),
1214cdf0e10cSrcweir aTitle.Len()+1 );
1215cdf0e10cSrcweir // The +1 copies the terminating null byte. Although
1216cdf0e10cSrcweir // the spec says, this should not be necessary
1217cdf0e10cSrcweir // at least the kwin implementation seems to depend
1218cdf0e10cSrcweir // on the null byte
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir /*
1222cdf0e10cSrcweir * NetWMAdaptor::setNetWMState
1223cdf0e10cSrcweir * sets _NET_WM_STATE
1224cdf0e10cSrcweir */
setNetWMState(X11SalFrame * pFrame) const1225cdf0e10cSrcweir void NetWMAdaptor::setNetWMState( X11SalFrame* pFrame ) const
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE ] )
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir Atom aStateAtoms[ 10 ];
1230cdf0e10cSrcweir int nStateAtoms = 0;
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir // set NET_WM_STATE_MODAL
1233cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE_MODAL ]
1234cdf0e10cSrcweir && pFrame->meWindowType == windowType_ModalDialogue )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MODAL ];
1237cdf0e10cSrcweir /*
1238cdf0e10cSrcweir * #90998# NET_WM_STATE_SKIP_TASKBAR set on a frame will
1239cdf0e10cSrcweir * cause kwin not to give it the focus on map request
1240cdf0e10cSrcweir * this seems to be a bug in kwin
1241cdf0e10cSrcweir * aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ];
1242cdf0e10cSrcweir */
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir if( pFrame->mbMaximizedVert
1245cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] )
1246cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ];
1247cdf0e10cSrcweir if( pFrame->mbMaximizedHorz
1248cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ] )
1249cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ];
1250cdf0e10cSrcweir if( pFrame->bAlwaysOnTop_ && m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ] )
1251cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ];
1252cdf0e10cSrcweir if( pFrame->mbShaded && m_aWMAtoms[ NET_WM_STATE_SHADED ] )
1253cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SHADED ];
1254cdf0e10cSrcweir if( pFrame->mbFullScreen && m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] )
1255cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ];
1256cdf0e10cSrcweir if( pFrame->meWindowType == windowType_Utility && m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ] )
1257cdf0e10cSrcweir aStateAtoms[ nStateAtoms++ ] = m_aWMAtoms[ NET_WM_STATE_SKIP_TASKBAR ];
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir if( nStateAtoms )
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1262cdf0e10cSrcweir pFrame->GetShellWindow(),
1263cdf0e10cSrcweir m_aWMAtoms[ NET_WM_STATE ],
1264cdf0e10cSrcweir XA_ATOM,
1265cdf0e10cSrcweir 32,
1266cdf0e10cSrcweir PropModeReplace,
1267cdf0e10cSrcweir (unsigned char*)aStateAtoms,
1268cdf0e10cSrcweir nStateAtoms
1269cdf0e10cSrcweir );
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir else
1272cdf0e10cSrcweir XDeleteProperty( m_pDisplay,
1273cdf0e10cSrcweir pFrame->GetShellWindow(),
1274cdf0e10cSrcweir m_aWMAtoms[ NET_WM_STATE ] );
1275cdf0e10cSrcweir if( pFrame->mbMaximizedHorz
1276cdf0e10cSrcweir && pFrame->mbMaximizedVert
1277cdf0e10cSrcweir && ! ( pFrame->nStyle_ & SAL_FRAME_STYLE_SIZEABLE ) )
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir /*
1280cdf0e10cSrcweir * for maximizing use NorthWestGravity (including decoration)
1281cdf0e10cSrcweir */
1282cdf0e10cSrcweir XSizeHints hints;
1283cdf0e10cSrcweir long supplied;
1284cdf0e10cSrcweir bool bHint = false;
1285cdf0e10cSrcweir if( XGetWMNormalHints( m_pDisplay,
1286cdf0e10cSrcweir pFrame->GetShellWindow(),
1287cdf0e10cSrcweir &hints,
1288cdf0e10cSrcweir &supplied ) )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir bHint = true;
1291cdf0e10cSrcweir hints.flags |= PWinGravity;
1292cdf0e10cSrcweir hints.win_gravity = NorthWestGravity;
1293cdf0e10cSrcweir XSetWMNormalHints( m_pDisplay,
1294cdf0e10cSrcweir pFrame->GetShellWindow(),
1295cdf0e10cSrcweir &hints );
1296cdf0e10cSrcweir XSync( m_pDisplay, False );
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir // SetPosSize necessary to set width/height, min/max w/h
1300cdf0e10cSrcweir sal_Int32 nCurrent = 0;
1301cdf0e10cSrcweir /*
1302cdf0e10cSrcweir * get current desktop here if work areas have different size
1303cdf0e10cSrcweir * (does this happen on any platform ?)
1304cdf0e10cSrcweir */
1305cdf0e10cSrcweir if( ! m_bEqualWorkAreas )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir nCurrent = getCurrentWorkArea();
1308cdf0e10cSrcweir if( nCurrent < 0 )
1309cdf0e10cSrcweir nCurrent = 0;
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir Rectangle aPosSize = m_aWMWorkAreas[nCurrent];
1312cdf0e10cSrcweir const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
1313cdf0e10cSrcweir aPosSize = Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration,
1314cdf0e10cSrcweir aPosSize.Top() + rGeom.nTopDecoration ),
1315cdf0e10cSrcweir Size( aPosSize.GetWidth()
1316cdf0e10cSrcweir - rGeom.nLeftDecoration
1317cdf0e10cSrcweir - rGeom.nRightDecoration,
1318cdf0e10cSrcweir aPosSize.GetHeight()
1319cdf0e10cSrcweir - rGeom.nTopDecoration
1320cdf0e10cSrcweir - rGeom.nBottomDecoration )
1321cdf0e10cSrcweir );
1322cdf0e10cSrcweir pFrame->SetPosSize( aPosSize );
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir /*
1325cdf0e10cSrcweir * reset gravity hint to static gravity
1326cdf0e10cSrcweir * (this should not move window according to ICCCM)
1327cdf0e10cSrcweir */
1328cdf0e10cSrcweir if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN )
1329cdf0e10cSrcweir {
1330cdf0e10cSrcweir hints.win_gravity = StaticGravity;
1331cdf0e10cSrcweir XSetWMNormalHints( m_pDisplay,
1332cdf0e10cSrcweir pFrame->GetShellWindow(),
1333cdf0e10cSrcweir &hints );
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir /*
1340cdf0e10cSrcweir * GnomeWMAdaptor::setNetWMState
1341cdf0e10cSrcweir * sets _WIN_STATE
1342cdf0e10cSrcweir */
setGnomeWMState(X11SalFrame * pFrame) const1343cdf0e10cSrcweir void GnomeWMAdaptor::setGnomeWMState( X11SalFrame* pFrame ) const
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir if( m_aWMAtoms[ WIN_STATE ] )
1346cdf0e10cSrcweir {
1347cdf0e10cSrcweir sal_uInt32 nWinWMState = 0;
1348cdf0e10cSrcweir
1349cdf0e10cSrcweir if( pFrame->mbMaximizedVert )
1350cdf0e10cSrcweir nWinWMState |= 1 << 2;
1351cdf0e10cSrcweir if( pFrame->mbMaximizedHorz )
1352cdf0e10cSrcweir nWinWMState |= 1 << 3;
1353cdf0e10cSrcweir if( pFrame->mbShaded )
1354cdf0e10cSrcweir nWinWMState |= 1 << 5;
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1357cdf0e10cSrcweir pFrame->GetShellWindow(),
1358cdf0e10cSrcweir m_aWMAtoms[ WIN_STATE ],
1359cdf0e10cSrcweir XA_CARDINAL,
1360cdf0e10cSrcweir 32,
1361cdf0e10cSrcweir PropModeReplace,
1362cdf0e10cSrcweir (unsigned char*)&nWinWMState,
1363cdf0e10cSrcweir 1
1364cdf0e10cSrcweir );
1365cdf0e10cSrcweir if( pFrame->mbMaximizedHorz
1366cdf0e10cSrcweir && pFrame->mbMaximizedVert
1367cdf0e10cSrcweir && ! ( pFrame->nStyle_ & SAL_FRAME_STYLE_SIZEABLE ) )
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir /*
1370cdf0e10cSrcweir * for maximizing use NorthWestGravity (including decoration)
1371cdf0e10cSrcweir */
1372cdf0e10cSrcweir XSizeHints hints;
1373cdf0e10cSrcweir long supplied;
1374cdf0e10cSrcweir bool bHint = false;
1375cdf0e10cSrcweir if( XGetWMNormalHints( m_pDisplay,
1376cdf0e10cSrcweir pFrame->GetShellWindow(),
1377cdf0e10cSrcweir &hints,
1378cdf0e10cSrcweir &supplied ) )
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir bHint = true;
1381cdf0e10cSrcweir hints.flags |= PWinGravity;
1382cdf0e10cSrcweir hints.win_gravity = NorthWestGravity;
1383cdf0e10cSrcweir XSetWMNormalHints( m_pDisplay,
1384cdf0e10cSrcweir pFrame->GetShellWindow(),
1385cdf0e10cSrcweir &hints );
1386cdf0e10cSrcweir XSync( m_pDisplay, False );
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir
1389cdf0e10cSrcweir // SetPosSize necessary to set width/height, min/max w/h
1390cdf0e10cSrcweir sal_Int32 nCurrent = 0;
1391cdf0e10cSrcweir /*
1392cdf0e10cSrcweir * get current desktop here if work areas have different size
1393cdf0e10cSrcweir * (does this happen on any platform ?)
1394cdf0e10cSrcweir */
1395cdf0e10cSrcweir if( ! m_bEqualWorkAreas )
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir nCurrent = getCurrentWorkArea();
1398cdf0e10cSrcweir if( nCurrent < 0 )
1399cdf0e10cSrcweir nCurrent = 0;
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir Rectangle aPosSize = m_aWMWorkAreas[nCurrent];
1402cdf0e10cSrcweir const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
1403cdf0e10cSrcweir aPosSize = Rectangle( Point( aPosSize.Left() + rGeom.nLeftDecoration,
1404cdf0e10cSrcweir aPosSize.Top() + rGeom.nTopDecoration ),
1405cdf0e10cSrcweir Size( aPosSize.GetWidth()
1406cdf0e10cSrcweir - rGeom.nLeftDecoration
1407cdf0e10cSrcweir - rGeom.nRightDecoration,
1408cdf0e10cSrcweir aPosSize.GetHeight()
1409cdf0e10cSrcweir - rGeom.nTopDecoration
1410cdf0e10cSrcweir - rGeom.nBottomDecoration )
1411cdf0e10cSrcweir );
1412cdf0e10cSrcweir pFrame->SetPosSize( aPosSize );
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir /*
1415cdf0e10cSrcweir * reset gravity hint to static gravity
1416cdf0e10cSrcweir * (this should not move window according to ICCCM)
1417cdf0e10cSrcweir */
1418cdf0e10cSrcweir if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN )
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir hints.win_gravity = StaticGravity;
1421cdf0e10cSrcweir XSetWMNormalHints( m_pDisplay,
1422cdf0e10cSrcweir pFrame->GetShellWindow(),
1423cdf0e10cSrcweir &hints );
1424cdf0e10cSrcweir }
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir /*
1430cdf0e10cSrcweir * WMAdaptor::setFrameDecoration
1431cdf0e10cSrcweir * sets _MOTIF_WM_HINTS
1432cdf0e10cSrcweir * WM_TRANSIENT_FOR
1433cdf0e10cSrcweir */
1434cdf0e10cSrcweir
setFrameTypeAndDecoration(X11SalFrame * pFrame,WMWindowType eType,int nDecorationFlags,X11SalFrame * pReferenceFrame) const1435cdf0e10cSrcweir void WMAdaptor::setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pReferenceFrame ) const
1436cdf0e10cSrcweir {
1437cdf0e10cSrcweir pFrame->meWindowType = eType;
1438cdf0e10cSrcweir pFrame->mnDecorationFlags = nDecorationFlags;
1439cdf0e10cSrcweir
1440cdf0e10cSrcweir if( ! pFrame->mbFullScreen )
1441cdf0e10cSrcweir {
1442cdf0e10cSrcweir // set mwm hints
1443cdf0e10cSrcweir struct _mwmhints {
1444cdf0e10cSrcweir unsigned long flags, func, deco;
1445cdf0e10cSrcweir long input_mode;
1446cdf0e10cSrcweir unsigned long status;
1447cdf0e10cSrcweir } aHint;
1448cdf0e10cSrcweir
1449cdf0e10cSrcweir aHint.flags = 15; /* flags for functions, decoration, input mode and status */
1450cdf0e10cSrcweir aHint.deco = 0;
1451cdf0e10cSrcweir aHint.func = 1L << 2;
1452cdf0e10cSrcweir aHint.status = 0;
1453cdf0e10cSrcweir aHint.input_mode = 0;
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir // evaluate decoration flags
1456cdf0e10cSrcweir if( nDecorationFlags & decoration_All )
1457cdf0e10cSrcweir aHint.deco = 1, aHint.func = 1;
1458cdf0e10cSrcweir else
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir if( nDecorationFlags & decoration_Title )
1461cdf0e10cSrcweir aHint.deco |= 1L << 3;
1462cdf0e10cSrcweir if( nDecorationFlags & decoration_Border )
1463cdf0e10cSrcweir aHint.deco |= 1L << 1;
1464cdf0e10cSrcweir if( nDecorationFlags & decoration_Resize )
1465cdf0e10cSrcweir aHint.deco |= 1L << 2, aHint.func |= 1L << 1;
1466cdf0e10cSrcweir if( nDecorationFlags & decoration_MinimizeBtn )
1467cdf0e10cSrcweir aHint.deco |= 1L << 5, aHint.func |= 1L << 3;
1468cdf0e10cSrcweir if( nDecorationFlags & decoration_MaximizeBtn )
1469cdf0e10cSrcweir aHint.deco |= 1L << 6, aHint.func |= 1L << 4;
1470cdf0e10cSrcweir if( nDecorationFlags & decoration_CloseBtn )
1471cdf0e10cSrcweir aHint.deco |= 1L << 4, aHint.func |= 1L << 5;
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir // evaluate window type
1474cdf0e10cSrcweir switch( eType )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir case windowType_ModalDialogue:
1477cdf0e10cSrcweir aHint.input_mode = 1;
1478cdf0e10cSrcweir break;
1479cdf0e10cSrcweir default:
1480cdf0e10cSrcweir break;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir
1483cdf0e10cSrcweir // set the hint
1484cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1485cdf0e10cSrcweir pFrame->GetShellWindow(),
1486cdf0e10cSrcweir m_aWMAtoms[ MOTIF_WM_HINTS ],
1487cdf0e10cSrcweir m_aWMAtoms[ MOTIF_WM_HINTS ],
1488cdf0e10cSrcweir 32,
1489cdf0e10cSrcweir PropModeReplace,
1490cdf0e10cSrcweir (unsigned char*)&aHint,
1491cdf0e10cSrcweir 5 );
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir
1494cdf0e10cSrcweir // set transientFor hint
1495cdf0e10cSrcweir /* #91030# dtwm will not map a dialogue if the transient
1496cdf0e10cSrcweir * window is iconified. This is deemed undesireable because
1497cdf0e10cSrcweir * message boxes do not get mapped, so use the root as transient
1498cdf0e10cSrcweir * instead.
1499cdf0e10cSrcweir */
1500cdf0e10cSrcweir if( pReferenceFrame )
1501cdf0e10cSrcweir {
1502cdf0e10cSrcweir XSetTransientForHint( m_pDisplay,
1503cdf0e10cSrcweir pFrame->GetShellWindow(),
1504cdf0e10cSrcweir pReferenceFrame->bMapped_ ?
1505cdf0e10cSrcweir pReferenceFrame->GetShellWindow() :
1506cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() )
1507cdf0e10cSrcweir );
1508cdf0e10cSrcweir if( ! pReferenceFrame->bMapped_ )
1509cdf0e10cSrcweir pFrame->mbTransientForRoot = true;
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir // #110333# in case no one ever sets a title prevent
1512cdf0e10cSrcweir // the Dtwm taking the class instead
1513cdf0e10cSrcweir if( m_aWMName.EqualsAscii( "Dtwm" ) )
1514cdf0e10cSrcweir setWMName( pFrame, String() );
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir /*
1518cdf0e10cSrcweir * NetWMAdaptor::setFrameDecoration
1519cdf0e10cSrcweir * sets _MOTIF_WM_HINTS
1520cdf0e10cSrcweir * _NET_WM_WINDOW_TYPE
1521cdf0e10cSrcweir * _NET_WM_STATE
1522cdf0e10cSrcweir * WM_TRANSIENT_FOR
1523cdf0e10cSrcweir */
1524cdf0e10cSrcweir
setFrameTypeAndDecoration(X11SalFrame * pFrame,WMWindowType eType,int nDecorationFlags,X11SalFrame * pReferenceFrame) const1525cdf0e10cSrcweir void NetWMAdaptor::setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pReferenceFrame ) const
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir WMAdaptor::setFrameTypeAndDecoration( pFrame, eType, nDecorationFlags, pReferenceFrame );
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir setNetWMState( pFrame );
1530cdf0e10cSrcweir
1531cdf0e10cSrcweir // set NET_WM_WINDOW_TYPE
1532cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_WINDOW_TYPE ] )
1533cdf0e10cSrcweir {
1534cdf0e10cSrcweir Atom aWindowTypes[4];
1535cdf0e10cSrcweir int nWindowTypes = 0;
1536cdf0e10cSrcweir switch( eType )
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir case windowType_Utility:
1539cdf0e10cSrcweir aWindowTypes[nWindowTypes++] =
1540cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_UTILITY ] ?
1541cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_UTILITY ] :
1542cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_DIALOG ];
1543cdf0e10cSrcweir break;
1544cdf0e10cSrcweir case windowType_ModelessDialogue:
1545cdf0e10cSrcweir case windowType_ModalDialogue:
1546cdf0e10cSrcweir aWindowTypes[nWindowTypes++] =
1547cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_DIALOG ];
1548cdf0e10cSrcweir break;
1549cdf0e10cSrcweir case windowType_Splash:
1550cdf0e10cSrcweir aWindowTypes[nWindowTypes++] =
1551cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] ?
1552cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] :
1553cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_NORMAL ];
1554cdf0e10cSrcweir break;
1555cdf0e10cSrcweir case windowType_Toolbar:
1556cdf0e10cSrcweir if( m_aWMAtoms[ KDE_NET_WM_WINDOW_TYPE_OVERRIDE ] )
1557cdf0e10cSrcweir aWindowTypes[nWindowTypes++] = m_aWMAtoms[ KDE_NET_WM_WINDOW_TYPE_OVERRIDE ];
1558cdf0e10cSrcweir aWindowTypes[nWindowTypes++] =
1559cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_TOOLBAR ] ?
1560cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_TOOLBAR ] :
1561cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_NORMAL];
1562cdf0e10cSrcweir break;
1563cdf0e10cSrcweir case windowType_Dock:
1564cdf0e10cSrcweir aWindowTypes[nWindowTypes++] =
1565cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_DOCK ] ?
1566cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_DOCK ] :
1567cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE_NORMAL];
1568cdf0e10cSrcweir break;
1569cdf0e10cSrcweir default:
1570cdf0e10cSrcweir aWindowTypes[nWindowTypes++] = m_aWMAtoms[ NET_WM_WINDOW_TYPE_NORMAL ];
1571cdf0e10cSrcweir break;
1572cdf0e10cSrcweir }
1573cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1574cdf0e10cSrcweir pFrame->GetShellWindow(),
1575cdf0e10cSrcweir m_aWMAtoms[ NET_WM_WINDOW_TYPE ],
1576cdf0e10cSrcweir XA_ATOM,
1577cdf0e10cSrcweir 32,
1578cdf0e10cSrcweir PropModeReplace,
1579cdf0e10cSrcweir (unsigned char*)aWindowTypes,
1580cdf0e10cSrcweir nWindowTypes );
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir if( ( eType == windowType_ModalDialogue ||
1583cdf0e10cSrcweir eType == windowType_ModelessDialogue )
1584cdf0e10cSrcweir && ! pReferenceFrame )
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir XSetTransientForHint( m_pDisplay,
1587cdf0e10cSrcweir pFrame->GetShellWindow(),
1588cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ) );
1589cdf0e10cSrcweir pFrame->mbTransientForRoot = true;
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir
1593cdf0e10cSrcweir /*
1594cdf0e10cSrcweir * WMAdaptor::maximizeFrame
1595cdf0e10cSrcweir */
1596cdf0e10cSrcweir
maximizeFrame(X11SalFrame * pFrame,bool bHorizontal,bool bVertical) const1597cdf0e10cSrcweir void WMAdaptor::maximizeFrame( X11SalFrame* pFrame, bool bHorizontal, bool bVertical ) const
1598cdf0e10cSrcweir {
1599cdf0e10cSrcweir pFrame->mbMaximizedVert = bVertical;
1600cdf0e10cSrcweir pFrame->mbMaximizedHorz = bHorizontal;
1601cdf0e10cSrcweir
1602cdf0e10cSrcweir const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
1603cdf0e10cSrcweir
1604cdf0e10cSrcweir // discard pending configure notifies for this frame
1605cdf0e10cSrcweir XSync( m_pDisplay, False );
1606cdf0e10cSrcweir XEvent aDiscard;
1607cdf0e10cSrcweir while( XCheckTypedWindowEvent( m_pDisplay,
1608cdf0e10cSrcweir pFrame->GetShellWindow(),
1609cdf0e10cSrcweir ConfigureNotify,
1610cdf0e10cSrcweir &aDiscard ) )
1611cdf0e10cSrcweir ;
1612cdf0e10cSrcweir while( XCheckTypedWindowEvent( m_pDisplay,
1613cdf0e10cSrcweir pFrame->GetWindow(),
1614cdf0e10cSrcweir ConfigureNotify,
1615cdf0e10cSrcweir &aDiscard ) )
1616cdf0e10cSrcweir ;
1617cdf0e10cSrcweir
1618cdf0e10cSrcweir if( bHorizontal || bVertical )
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir Size aScreenSize( m_pSalDisplay->GetScreenSize( pFrame->GetScreenNumber() ) );
1621cdf0e10cSrcweir Point aTL( rGeom.nLeftDecoration, rGeom.nTopDecoration );
1622cdf0e10cSrcweir if( m_pSalDisplay->IsXinerama() )
1623cdf0e10cSrcweir {
1624cdf0e10cSrcweir Point aMed( aTL.X() + rGeom.nWidth/2, aTL.Y() + rGeom.nHeight/2 );
1625cdf0e10cSrcweir const std::vector< Rectangle >& rScreens = m_pSalDisplay->GetXineramaScreens();
1626cdf0e10cSrcweir for( unsigned int i = 0; i < rScreens.size(); i++ )
1627cdf0e10cSrcweir if( rScreens[i].IsInside( aMed ) )
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir aTL += rScreens[i].TopLeft();
1630cdf0e10cSrcweir aScreenSize = rScreens[i].GetSize();
1631cdf0e10cSrcweir break;
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir Rectangle aTarget( aTL,
1635cdf0e10cSrcweir Size( aScreenSize.Width() - rGeom.nLeftDecoration - rGeom.nTopDecoration,
1636cdf0e10cSrcweir aScreenSize.Height() - rGeom.nTopDecoration - rGeom.nBottomDecoration )
1637cdf0e10cSrcweir );
1638cdf0e10cSrcweir if( ! bHorizontal )
1639cdf0e10cSrcweir {
1640cdf0e10cSrcweir aTarget.SetSize(
1641cdf0e10cSrcweir Size(
1642cdf0e10cSrcweir pFrame->maRestorePosSize.IsEmpty() ?
1643cdf0e10cSrcweir rGeom.nWidth : pFrame->maRestorePosSize.GetWidth(),
1644cdf0e10cSrcweir aTarget.GetHeight()
1645cdf0e10cSrcweir )
1646cdf0e10cSrcweir );
1647cdf0e10cSrcweir aTarget.Left() =
1648cdf0e10cSrcweir pFrame->maRestorePosSize.IsEmpty() ?
1649cdf0e10cSrcweir rGeom.nX : pFrame->maRestorePosSize.Left();
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir else if( ! bVertical )
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir aTarget.SetSize(
1654cdf0e10cSrcweir Size(
1655cdf0e10cSrcweir aTarget.GetWidth(),
1656cdf0e10cSrcweir pFrame->maRestorePosSize.IsEmpty() ?
1657cdf0e10cSrcweir rGeom.nHeight : pFrame->maRestorePosSize.GetHeight()
1658cdf0e10cSrcweir )
1659cdf0e10cSrcweir );
1660cdf0e10cSrcweir aTarget.Top() =
1661cdf0e10cSrcweir pFrame->maRestorePosSize.IsEmpty() ?
1662cdf0e10cSrcweir rGeom.nY : pFrame->maRestorePosSize.Top();
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir
1665cdf0e10cSrcweir Rectangle aRestore( Point( rGeom.nX, rGeom.nY ), Size( rGeom.nWidth, rGeom.nHeight ) );
1666cdf0e10cSrcweir if( pFrame->bMapped_ )
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir XSetInputFocus( m_pDisplay,
1669cdf0e10cSrcweir pFrame->GetShellWindow(),
1670cdf0e10cSrcweir RevertToNone,
1671cdf0e10cSrcweir CurrentTime
1672cdf0e10cSrcweir );
1673cdf0e10cSrcweir if( m_aWMName.EqualsAscii( "Dtwm" ) )
1674cdf0e10cSrcweir {
1675cdf0e10cSrcweir /*
1676cdf0e10cSrcweir * Dtwm will only position correctly with center gravity
1677cdf0e10cSrcweir * and in this case the request actually changes the frame
1678cdf0e10cSrcweir * not the shell window
1679cdf0e10cSrcweir */
1680cdf0e10cSrcweir aTarget = Rectangle( Point( 0, 0 ), aScreenSize );
1681cdf0e10cSrcweir aRestore.Move( -rGeom.nLeftDecoration, -rGeom.nTopDecoration );
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir }
1684cdf0e10cSrcweir
1685cdf0e10cSrcweir if( pFrame->maRestorePosSize.IsEmpty() )
1686cdf0e10cSrcweir pFrame->maRestorePosSize = aRestore;
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir pFrame->SetPosSize( aTarget );
1689cdf0e10cSrcweir pFrame->nWidth_ = aTarget.GetWidth();
1690cdf0e10cSrcweir pFrame->nHeight_ = aTarget.GetHeight();
1691cdf0e10cSrcweir XRaiseWindow( m_pDisplay,
1692cdf0e10cSrcweir pFrame->GetShellWindow()
1693cdf0e10cSrcweir );
1694cdf0e10cSrcweir if( pFrame->GetStackingWindow() )
1695cdf0e10cSrcweir XRaiseWindow( m_pDisplay,
1696cdf0e10cSrcweir pFrame->GetStackingWindow()
1697cdf0e10cSrcweir );
1698cdf0e10cSrcweir
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir else
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir pFrame->SetPosSize( pFrame->maRestorePosSize );
1703cdf0e10cSrcweir pFrame->maRestorePosSize = Rectangle();
1704cdf0e10cSrcweir pFrame->nWidth_ = rGeom.nWidth;
1705cdf0e10cSrcweir pFrame->nHeight_ = rGeom.nHeight;
1706cdf0e10cSrcweir if( m_aWMName.EqualsAscii( "Dtwm" ) && pFrame->bMapped_ )
1707cdf0e10cSrcweir {
1708cdf0e10cSrcweir pFrame->maGeometry.nX += rGeom.nLeftDecoration;
1709cdf0e10cSrcweir pFrame->maGeometry.nY += rGeom.nTopDecoration;
1710cdf0e10cSrcweir }
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir
1714cdf0e10cSrcweir /*
1715cdf0e10cSrcweir * NetWMAdaptor::maximizeFrame
1716cdf0e10cSrcweir * changes _NET_WM_STATE by sending a client message
1717cdf0e10cSrcweir */
1718cdf0e10cSrcweir
maximizeFrame(X11SalFrame * pFrame,bool bHorizontal,bool bVertical) const1719cdf0e10cSrcweir void NetWMAdaptor::maximizeFrame( X11SalFrame* pFrame, bool bHorizontal, bool bVertical ) const
1720cdf0e10cSrcweir {
1721cdf0e10cSrcweir pFrame->mbMaximizedVert = bVertical;
1722cdf0e10cSrcweir pFrame->mbMaximizedHorz = bHorizontal;
1723cdf0e10cSrcweir
1724cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE ]
1725cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ]
1726cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ]
1727cdf0e10cSrcweir && ( pFrame->nStyle_ & ~SAL_FRAME_STYLE_DEFAULT )
1728cdf0e10cSrcweir )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir if( pFrame->bMapped_ )
1731cdf0e10cSrcweir {
1732cdf0e10cSrcweir // window already mapped, send WM a message
1733cdf0e10cSrcweir XEvent aEvent;
1734cdf0e10cSrcweir aEvent.type = ClientMessage;
1735cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
1736cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
1737cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ];
1738cdf0e10cSrcweir aEvent.xclient.format = 32;
1739cdf0e10cSrcweir aEvent.xclient.data.l[0] = bHorizontal ? 1 : 0;
1740cdf0e10cSrcweir aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ];
1741cdf0e10cSrcweir aEvent.xclient.data.l[2] = bHorizontal == bVertical ? m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] : 0;
1742cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
1743cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
1744cdf0e10cSrcweir XSendEvent( m_pDisplay,
1745cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
1746cdf0e10cSrcweir False,
1747cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
1748cdf0e10cSrcweir &aEvent
1749cdf0e10cSrcweir );
1750cdf0e10cSrcweir if( bHorizontal != bVertical )
1751cdf0e10cSrcweir {
1752cdf0e10cSrcweir aEvent.xclient.data.l[0]= bVertical ? 1 : 0;
1753cdf0e10cSrcweir aEvent.xclient.data.l[1]= m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ];
1754cdf0e10cSrcweir aEvent.xclient.data.l[2]= 0;
1755cdf0e10cSrcweir XSendEvent( m_pDisplay,
1756cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
1757cdf0e10cSrcweir False,
1758cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
1759cdf0e10cSrcweir &aEvent
1760cdf0e10cSrcweir );
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir else
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir // window not mapped yet, set _NET_WM_STATE directly
1766cdf0e10cSrcweir setNetWMState( pFrame );
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir if( !bHorizontal && !bVertical )
1769cdf0e10cSrcweir pFrame->maRestorePosSize = Rectangle();
1770cdf0e10cSrcweir else if( pFrame->maRestorePosSize.IsEmpty() )
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
1773cdf0e10cSrcweir pFrame->maRestorePosSize =
1774cdf0e10cSrcweir Rectangle( Point( rGeom.nX, rGeom.nY ), Size( rGeom.nWidth, rGeom.nHeight ) );
1775cdf0e10cSrcweir }
1776cdf0e10cSrcweir }
1777cdf0e10cSrcweir else
1778cdf0e10cSrcweir WMAdaptor::maximizeFrame( pFrame, bHorizontal, bVertical );
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir
1781cdf0e10cSrcweir /*
1782cdf0e10cSrcweir * GnomeWMAdaptor::maximizeFrame
1783cdf0e10cSrcweir * changes _WIN_STATE by sending a client message
1784cdf0e10cSrcweir */
1785cdf0e10cSrcweir
maximizeFrame(X11SalFrame * pFrame,bool bHorizontal,bool bVertical) const1786cdf0e10cSrcweir void GnomeWMAdaptor::maximizeFrame( X11SalFrame* pFrame, bool bHorizontal, bool bVertical ) const
1787cdf0e10cSrcweir {
1788cdf0e10cSrcweir pFrame->mbMaximizedVert = bVertical;
1789cdf0e10cSrcweir pFrame->mbMaximizedHorz = bHorizontal;
1790cdf0e10cSrcweir
1791cdf0e10cSrcweir if( m_aWMAtoms[ WIN_STATE ]
1792cdf0e10cSrcweir && ( pFrame->nStyle_ & ~SAL_FRAME_STYLE_DEFAULT )
1793cdf0e10cSrcweir )
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir if( pFrame->bMapped_ )
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir // window already mapped, send WM a message
1798cdf0e10cSrcweir XEvent aEvent;
1799cdf0e10cSrcweir aEvent.type = ClientMessage;
1800cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
1801cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
1802cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ WIN_STATE ];
1803cdf0e10cSrcweir aEvent.xclient.format = 32;
1804cdf0e10cSrcweir aEvent.xclient.data.l[0] = (1<<2)|(1<<3);
1805cdf0e10cSrcweir aEvent.xclient.data.l[1] =
1806cdf0e10cSrcweir (bVertical ? (1<<2) : 0)
1807cdf0e10cSrcweir | (bHorizontal ? (1<<3) : 0);
1808cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
1809cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
1810cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
1811cdf0e10cSrcweir XSendEvent( m_pDisplay,
1812cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
1813cdf0e10cSrcweir False,
1814cdf0e10cSrcweir SubstructureNotifyMask,
1815cdf0e10cSrcweir &aEvent
1816cdf0e10cSrcweir );
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir else
1819cdf0e10cSrcweir // window not mapped yet, set _WIN_STATE directly
1820cdf0e10cSrcweir setGnomeWMState( pFrame );
1821cdf0e10cSrcweir
1822cdf0e10cSrcweir if( !bHorizontal && !bVertical )
1823cdf0e10cSrcweir pFrame->maRestorePosSize = Rectangle();
1824cdf0e10cSrcweir else if( pFrame->maRestorePosSize.IsEmpty() )
1825cdf0e10cSrcweir {
1826cdf0e10cSrcweir const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
1827cdf0e10cSrcweir pFrame->maRestorePosSize =
1828cdf0e10cSrcweir Rectangle( Point( rGeom.nX, rGeom.nY ), Size( rGeom.nWidth, rGeom.nHeight ) );
1829cdf0e10cSrcweir }
1830cdf0e10cSrcweir }
1831cdf0e10cSrcweir else
1832cdf0e10cSrcweir WMAdaptor::maximizeFrame( pFrame, bHorizontal, bVertical );
1833cdf0e10cSrcweir }
1834cdf0e10cSrcweir
1835cdf0e10cSrcweir /*
1836cdf0e10cSrcweir * WMAdaptor::supportsICCCMPos
1837cdf0e10cSrcweir */
1838cdf0e10cSrcweir
supportsICCCMPos() const1839cdf0e10cSrcweir bool WMAdaptor::supportsICCCMPos() const
1840cdf0e10cSrcweir {
1841cdf0e10cSrcweir return
1842cdf0e10cSrcweir m_aWMName.EqualsAscii( "Sawfish" )
1843cdf0e10cSrcweir || m_aWMName.EqualsAscii( "Dtwm" );
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir
1846cdf0e10cSrcweir /*
1847cdf0e10cSrcweir * NetWMAdaptor::supportsICCCMPos
1848cdf0e10cSrcweir */
1849cdf0e10cSrcweir
supportsICCCMPos() const1850cdf0e10cSrcweir bool NetWMAdaptor::supportsICCCMPos() const
1851cdf0e10cSrcweir {
1852cdf0e10cSrcweir return true;
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir /*
1857cdf0e10cSrcweir * WMAdaptor::enableAlwaysOnTop
1858cdf0e10cSrcweir */
enableAlwaysOnTop(X11SalFrame *,bool) const1859cdf0e10cSrcweir void WMAdaptor::enableAlwaysOnTop( X11SalFrame*, bool /*bEnable*/ ) const
1860cdf0e10cSrcweir {
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir
1863cdf0e10cSrcweir /*
1864cdf0e10cSrcweir * NetWMAdaptor::enableAlwaysOnTop
1865cdf0e10cSrcweir */
enableAlwaysOnTop(X11SalFrame * pFrame,bool bEnable) const1866cdf0e10cSrcweir void NetWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir pFrame->bAlwaysOnTop_ = bEnable;
1869cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ] )
1870cdf0e10cSrcweir {
1871cdf0e10cSrcweir if( pFrame->bMapped_ )
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir // window already mapped, send WM a message
1874cdf0e10cSrcweir XEvent aEvent;
1875cdf0e10cSrcweir aEvent.type = ClientMessage;
1876cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
1877cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
1878cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ];
1879cdf0e10cSrcweir aEvent.xclient.format = 32;
1880cdf0e10cSrcweir aEvent.xclient.data.l[0] = bEnable ? 1 : 0;
1881cdf0e10cSrcweir aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_STAYS_ON_TOP ];
1882cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
1883cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
1884cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
1885cdf0e10cSrcweir XSendEvent( m_pDisplay,
1886cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
1887cdf0e10cSrcweir False,
1888cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
1889cdf0e10cSrcweir &aEvent
1890cdf0e10cSrcweir );
1891cdf0e10cSrcweir }
1892cdf0e10cSrcweir else
1893cdf0e10cSrcweir setNetWMState( pFrame );
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir }
1896cdf0e10cSrcweir
1897cdf0e10cSrcweir /*
1898cdf0e10cSrcweir * GnomeWMAdaptor::enableAlwaysOnTop
1899cdf0e10cSrcweir */
enableAlwaysOnTop(X11SalFrame * pFrame,bool bEnable) const1900cdf0e10cSrcweir void GnomeWMAdaptor::enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const
1901cdf0e10cSrcweir {
1902cdf0e10cSrcweir pFrame->bAlwaysOnTop_ = bEnable;
1903cdf0e10cSrcweir if( m_aWMAtoms[ WIN_LAYER ] )
1904cdf0e10cSrcweir {
1905cdf0e10cSrcweir if( pFrame->bMapped_ )
1906cdf0e10cSrcweir {
1907cdf0e10cSrcweir // window already mapped, send WM a message
1908cdf0e10cSrcweir XEvent aEvent;
1909cdf0e10cSrcweir aEvent.type = ClientMessage;
1910cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
1911cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
1912cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ WIN_LAYER ];
1913cdf0e10cSrcweir aEvent.xclient.format = 32;
1914cdf0e10cSrcweir aEvent.xclient.data.l[0] = bEnable ? 6 : 4;
1915cdf0e10cSrcweir aEvent.xclient.data.l[1] = 0;
1916cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
1917cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
1918cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
1919cdf0e10cSrcweir XSendEvent( m_pDisplay,
1920cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
1921cdf0e10cSrcweir False,
1922cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
1923cdf0e10cSrcweir &aEvent
1924cdf0e10cSrcweir );
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir else
1927cdf0e10cSrcweir {
1928cdf0e10cSrcweir sal_uInt32 nNewLayer = bEnable ? 6 : 4;
1929cdf0e10cSrcweir XChangeProperty( m_pDisplay,
1930cdf0e10cSrcweir pFrame->GetShellWindow(),
1931cdf0e10cSrcweir m_aWMAtoms[ WIN_LAYER ],
1932cdf0e10cSrcweir XA_CARDINAL,
1933cdf0e10cSrcweir 32,
1934cdf0e10cSrcweir PropModeReplace,
1935cdf0e10cSrcweir (unsigned char*)&nNewLayer,
1936cdf0e10cSrcweir 1
1937cdf0e10cSrcweir );
1938cdf0e10cSrcweir }
1939cdf0e10cSrcweir }
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir
1942cdf0e10cSrcweir /*
1943cdf0e10cSrcweir * WMAdaptor::changeReferenceFrame
1944cdf0e10cSrcweir */
changeReferenceFrame(X11SalFrame * pFrame,X11SalFrame * pReferenceFrame) const1945cdf0e10cSrcweir void WMAdaptor::changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame* pReferenceFrame ) const
1946cdf0e10cSrcweir {
1947cdf0e10cSrcweir if( ! ( pFrame->nStyle_ & SAL_FRAME_STYLE_PLUG )
1948cdf0e10cSrcweir && ! pFrame->IsOverrideRedirect()
1949cdf0e10cSrcweir && ! pFrame->IsFloatGrabWindow()
1950cdf0e10cSrcweir )
1951cdf0e10cSrcweir {
1952cdf0e10cSrcweir XLIB_Window aTransient = pFrame->pDisplay_->GetRootWindow( pFrame->GetScreenNumber() );
1953cdf0e10cSrcweir pFrame->mbTransientForRoot = true;
1954cdf0e10cSrcweir if( pReferenceFrame )
1955cdf0e10cSrcweir {
1956cdf0e10cSrcweir aTransient = pReferenceFrame->GetShellWindow();
1957cdf0e10cSrcweir pFrame->mbTransientForRoot = false;
1958cdf0e10cSrcweir }
1959cdf0e10cSrcweir XSetTransientForHint( m_pDisplay,
1960cdf0e10cSrcweir pFrame->GetShellWindow(),
1961cdf0e10cSrcweir aTransient );
1962cdf0e10cSrcweir }
1963cdf0e10cSrcweir }
1964cdf0e10cSrcweir
1965cdf0e10cSrcweir /*
1966cdf0e10cSrcweir * WMAdaptor::handlePropertyNotify
1967cdf0e10cSrcweir */
handlePropertyNotify(X11SalFrame *,XPropertyEvent *) const1968cdf0e10cSrcweir int WMAdaptor::handlePropertyNotify( X11SalFrame*, XPropertyEvent* ) const
1969cdf0e10cSrcweir {
1970cdf0e10cSrcweir return 0;
1971cdf0e10cSrcweir }
1972cdf0e10cSrcweir
1973cdf0e10cSrcweir /*
1974cdf0e10cSrcweir * NetWMAdaptor::handlePropertyNotify
1975cdf0e10cSrcweir */
handlePropertyNotify(X11SalFrame * pFrame,XPropertyEvent * pEvent) const1976cdf0e10cSrcweir int NetWMAdaptor::handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const
1977cdf0e10cSrcweir {
1978cdf0e10cSrcweir int nHandled = 1;
1979cdf0e10cSrcweir if( pEvent->atom == m_aWMAtoms[ NET_WM_STATE ] )
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir pFrame->mbMaximizedHorz = pFrame->mbMaximizedVert = false;
1982cdf0e10cSrcweir pFrame->mbShaded = false;
1983cdf0e10cSrcweir
1984cdf0e10cSrcweir if( pEvent->state == PropertyNewValue )
1985cdf0e10cSrcweir {
1986cdf0e10cSrcweir Atom nType, *pStates;
1987cdf0e10cSrcweir int nFormat;
1988cdf0e10cSrcweir unsigned long nItems, nBytesLeft;
1989cdf0e10cSrcweir unsigned char* pData = NULL;
1990cdf0e10cSrcweir long nOffset = 0;
1991cdf0e10cSrcweir do
1992cdf0e10cSrcweir {
1993cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
1994cdf0e10cSrcweir pEvent->window,
1995cdf0e10cSrcweir m_aWMAtoms[ NET_WM_STATE ],
1996cdf0e10cSrcweir nOffset, 64,
1997cdf0e10cSrcweir False,
1998cdf0e10cSrcweir XA_ATOM,
1999cdf0e10cSrcweir &nType,
2000cdf0e10cSrcweir &nFormat,
2001cdf0e10cSrcweir &nItems, &nBytesLeft,
2002cdf0e10cSrcweir &pData );
2003cdf0e10cSrcweir if( pData )
2004cdf0e10cSrcweir {
2005cdf0e10cSrcweir if( nType == XA_ATOM && nFormat == 32 && nItems > 0 )
2006cdf0e10cSrcweir {
2007cdf0e10cSrcweir pStates = (Atom*)pData;
2008cdf0e10cSrcweir for( unsigned long i = 0; i < nItems; i++ )
2009cdf0e10cSrcweir {
2010cdf0e10cSrcweir if( pStates[i] == m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_VERT ] )
2011cdf0e10cSrcweir pFrame->mbMaximizedVert = true;
2012cdf0e10cSrcweir else if( pStates[i] == m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ] && m_aWMAtoms[ NET_WM_STATE_MAXIMIZED_HORZ ] )
2013cdf0e10cSrcweir pFrame->mbMaximizedHorz = true;
2014cdf0e10cSrcweir else if( pStates[i] == m_aWMAtoms[ NET_WM_STATE_SHADED ] && m_aWMAtoms[ NET_WM_STATE_SHADED ] )
2015cdf0e10cSrcweir pFrame->mbShaded = true;
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir XFree( pData );
2019cdf0e10cSrcweir pData = NULL;
2020cdf0e10cSrcweir nOffset += nItems * nFormat / 32;
2021cdf0e10cSrcweir }
2022cdf0e10cSrcweir else
2023cdf0e10cSrcweir break;
2024cdf0e10cSrcweir } while( nBytesLeft > 0 );
2025cdf0e10cSrcweir }
2026cdf0e10cSrcweir
2027cdf0e10cSrcweir if( ! (pFrame->mbMaximizedHorz || pFrame->mbMaximizedVert ) )
2028cdf0e10cSrcweir pFrame->maRestorePosSize = Rectangle();
2029cdf0e10cSrcweir else
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir const SalFrameGeometry& rGeom = pFrame->GetUnmirroredGeometry();
2032cdf0e10cSrcweir // the current geometry may already be changed by the corresponding
2033cdf0e10cSrcweir // ConfigureNotify, but this cannot be helped
2034cdf0e10cSrcweir pFrame->maRestorePosSize =
2035cdf0e10cSrcweir Rectangle( Point( rGeom.nX, rGeom.nY ),
2036cdf0e10cSrcweir Size( rGeom.nWidth, rGeom.nHeight ) );
2037cdf0e10cSrcweir }
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir else if( pEvent->atom == m_aWMAtoms[ NET_WM_DESKTOP ] )
2040cdf0e10cSrcweir {
2041cdf0e10cSrcweir pFrame->m_nWorkArea = getWindowWorkArea( pFrame->GetShellWindow() );
2042cdf0e10cSrcweir }
2043cdf0e10cSrcweir else
2044cdf0e10cSrcweir nHandled = 0;
2045cdf0e10cSrcweir
2046cdf0e10cSrcweir return nHandled;
2047cdf0e10cSrcweir }
2048cdf0e10cSrcweir
2049cdf0e10cSrcweir /*
2050cdf0e10cSrcweir * GnomeWMAdaptor::handlePropertyNotify
2051cdf0e10cSrcweir */
handlePropertyNotify(X11SalFrame * pFrame,XPropertyEvent * pEvent) const2052cdf0e10cSrcweir int GnomeWMAdaptor::handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const
2053cdf0e10cSrcweir {
2054cdf0e10cSrcweir int nHandled = 1;
2055cdf0e10cSrcweir if( pEvent->atom == m_aWMAtoms[ WIN_STATE ] )
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir pFrame->mbMaximizedHorz = pFrame->mbMaximizedVert = false;
2058cdf0e10cSrcweir pFrame->mbShaded = false;
2059cdf0e10cSrcweir
2060cdf0e10cSrcweir if( pEvent->state == PropertyNewValue )
2061cdf0e10cSrcweir {
2062cdf0e10cSrcweir Atom nType;
2063cdf0e10cSrcweir int nFormat = 0;
2064cdf0e10cSrcweir unsigned long nItems = 0;
2065cdf0e10cSrcweir unsigned long nBytesLeft = 0;
2066cdf0e10cSrcweir unsigned char* pData = 0;
2067cdf0e10cSrcweir XGetWindowProperty( m_pDisplay,
2068cdf0e10cSrcweir pEvent->window,
2069cdf0e10cSrcweir m_aWMAtoms[ WIN_STATE ],
2070cdf0e10cSrcweir 0, 1,
2071cdf0e10cSrcweir False,
2072cdf0e10cSrcweir XA_CARDINAL,
2073cdf0e10cSrcweir &nType,
2074cdf0e10cSrcweir &nFormat,
2075cdf0e10cSrcweir &nItems, &nBytesLeft,
2076cdf0e10cSrcweir &pData );
2077cdf0e10cSrcweir if( pData )
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir if( nType == XA_CARDINAL && nFormat == 32 && nItems == 1 )
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir sal_uInt32 nWinState = *(sal_uInt32*)pData;
2082cdf0e10cSrcweir if( nWinState & (1<<2) )
2083cdf0e10cSrcweir pFrame->mbMaximizedVert = true;
2084cdf0e10cSrcweir if( nWinState & (1<<3) )
2085cdf0e10cSrcweir pFrame->mbMaximizedHorz = true;
2086cdf0e10cSrcweir if( nWinState & (1<<5) )
2087cdf0e10cSrcweir pFrame->mbShaded = true;
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir XFree( pData );
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir }
2092cdf0e10cSrcweir
2093cdf0e10cSrcweir if( ! (pFrame->mbMaximizedHorz || pFrame->mbMaximizedVert ) )
2094cdf0e10cSrcweir pFrame->maRestorePosSize = Rectangle();
2095cdf0e10cSrcweir else
2096cdf0e10cSrcweir {
2097cdf0e10cSrcweir const SalFrameGeometry& rGeom = pFrame->GetUnmirroredGeometry();
2098cdf0e10cSrcweir // the current geometry may already be changed by the corresponding
2099cdf0e10cSrcweir // ConfigureNotify, but this cannot be helped
2100cdf0e10cSrcweir pFrame->maRestorePosSize =
2101cdf0e10cSrcweir Rectangle( Point( rGeom.nX, rGeom.nY ),
2102cdf0e10cSrcweir Size( rGeom.nWidth, rGeom.nHeight ) );
2103cdf0e10cSrcweir }
2104cdf0e10cSrcweir }
2105cdf0e10cSrcweir else if( pEvent->atom == m_aWMAtoms[ NET_WM_DESKTOP ] )
2106cdf0e10cSrcweir {
2107cdf0e10cSrcweir pFrame->m_nWorkArea = getWindowWorkArea( pFrame->GetShellWindow() );
2108cdf0e10cSrcweir }
2109cdf0e10cSrcweir else
2110cdf0e10cSrcweir nHandled = 0;
2111cdf0e10cSrcweir
2112cdf0e10cSrcweir return nHandled;
2113cdf0e10cSrcweir }
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir /*
2116cdf0e10cSrcweir * WMAdaptor::shade
2117cdf0e10cSrcweir */
shade(X11SalFrame *,bool) const2118cdf0e10cSrcweir void WMAdaptor::shade( X11SalFrame*, bool /*bToShaded*/ ) const
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir }
2121cdf0e10cSrcweir
2122cdf0e10cSrcweir /*
2123cdf0e10cSrcweir * NetWMAdaptor::shade
2124cdf0e10cSrcweir */
shade(X11SalFrame * pFrame,bool bToShaded) const2125cdf0e10cSrcweir void NetWMAdaptor::shade( X11SalFrame* pFrame, bool bToShaded ) const
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE ]
2128cdf0e10cSrcweir && m_aWMAtoms[ NET_WM_STATE_SHADED ]
2129cdf0e10cSrcweir && ( pFrame->nStyle_ & ~SAL_FRAME_STYLE_DEFAULT )
2130cdf0e10cSrcweir )
2131cdf0e10cSrcweir {
2132cdf0e10cSrcweir pFrame->mbShaded = bToShaded;
2133cdf0e10cSrcweir if( pFrame->bMapped_ )
2134cdf0e10cSrcweir {
2135cdf0e10cSrcweir // window already mapped, send WM a message
2136cdf0e10cSrcweir XEvent aEvent;
2137cdf0e10cSrcweir aEvent.type = ClientMessage;
2138cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
2139cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
2140cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ];
2141cdf0e10cSrcweir aEvent.xclient.format = 32;
2142cdf0e10cSrcweir aEvent.xclient.data.l[0] = bToShaded ? 1 : 0;
2143cdf0e10cSrcweir aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_SHADED ];
2144cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
2145cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
2146cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
2147cdf0e10cSrcweir XSendEvent( m_pDisplay,
2148cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
2149cdf0e10cSrcweir False,
2150cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
2151cdf0e10cSrcweir &aEvent
2152cdf0e10cSrcweir );
2153cdf0e10cSrcweir }
2154cdf0e10cSrcweir else
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir // window not mapped yet, set _NET_WM_STATE directly
2157cdf0e10cSrcweir setNetWMState( pFrame );
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir }
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir
2162cdf0e10cSrcweir /*
2163cdf0e10cSrcweir * GnomeWMAdaptor::shade
2164cdf0e10cSrcweir */
shade(X11SalFrame * pFrame,bool bToShaded) const2165cdf0e10cSrcweir void GnomeWMAdaptor::shade( X11SalFrame* pFrame, bool bToShaded ) const
2166cdf0e10cSrcweir {
2167cdf0e10cSrcweir if( m_aWMAtoms[ WIN_STATE ] )
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir pFrame->mbShaded = bToShaded;
2170cdf0e10cSrcweir if( pFrame->bMapped_ )
2171cdf0e10cSrcweir {
2172cdf0e10cSrcweir // window already mapped, send WM a message
2173cdf0e10cSrcweir XEvent aEvent;
2174cdf0e10cSrcweir aEvent.type = ClientMessage;
2175cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
2176cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
2177cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ WIN_STATE ];
2178cdf0e10cSrcweir aEvent.xclient.format = 32;
2179cdf0e10cSrcweir aEvent.xclient.data.l[0] = (1<<5);
2180cdf0e10cSrcweir aEvent.xclient.data.l[1] = bToShaded ? (1<<5) : 0;
2181cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
2182cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
2183cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
2184cdf0e10cSrcweir XSendEvent( m_pDisplay,
2185cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
2186cdf0e10cSrcweir False,
2187cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
2188cdf0e10cSrcweir &aEvent
2189cdf0e10cSrcweir );
2190cdf0e10cSrcweir }
2191cdf0e10cSrcweir else
2192cdf0e10cSrcweir setGnomeWMState( pFrame );
2193cdf0e10cSrcweir }
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir /*
2197cdf0e10cSrcweir * WMAdaptor::showFullScreen
2198cdf0e10cSrcweir */
showFullScreen(X11SalFrame * pFrame,bool bFullScreen) const2199cdf0e10cSrcweir void WMAdaptor::showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const
2200cdf0e10cSrcweir {
2201cdf0e10cSrcweir pFrame->mbFullScreen = bFullScreen;
2202cdf0e10cSrcweir maximizeFrame( pFrame, bFullScreen, bFullScreen );
2203cdf0e10cSrcweir }
2204cdf0e10cSrcweir
2205cdf0e10cSrcweir /*
2206cdf0e10cSrcweir * NetWMAdaptor::showFullScreen
2207cdf0e10cSrcweir */
showFullScreen(X11SalFrame * pFrame,bool bFullScreen) const2208cdf0e10cSrcweir void NetWMAdaptor::showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const
2209cdf0e10cSrcweir {
2210cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] )
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir pFrame->mbFullScreen = bFullScreen;
2213cdf0e10cSrcweir if( bFullScreen )
2214cdf0e10cSrcweir {
2215cdf0e10cSrcweir if( m_aWMAtoms[ MOTIF_WM_HINTS ] )
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir XDeleteProperty( m_pDisplay,
2218cdf0e10cSrcweir pFrame->GetShellWindow(),
2219cdf0e10cSrcweir m_aWMAtoms[ MOTIF_WM_HINTS ] );
2220cdf0e10cSrcweir }
2221cdf0e10cSrcweir }
2222cdf0e10cSrcweir if( pFrame->bMapped_ )
2223cdf0e10cSrcweir {
2224cdf0e10cSrcweir // window already mapped, send WM a message
2225cdf0e10cSrcweir XEvent aEvent;
2226cdf0e10cSrcweir aEvent.type = ClientMessage;
2227cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
2228cdf0e10cSrcweir aEvent.xclient.window = pFrame->GetShellWindow();
2229cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ NET_WM_STATE ];
2230cdf0e10cSrcweir aEvent.xclient.format = 32;
2231cdf0e10cSrcweir aEvent.xclient.data.l[0] = bFullScreen ? 1 : 0;
2232cdf0e10cSrcweir aEvent.xclient.data.l[1] = m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ];
2233cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
2234cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
2235cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
2236cdf0e10cSrcweir XSendEvent( m_pDisplay,
2237cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
2238cdf0e10cSrcweir False,
2239cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
2240cdf0e10cSrcweir &aEvent
2241cdf0e10cSrcweir );
2242cdf0e10cSrcweir }
2243cdf0e10cSrcweir else
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir // window not mapped yet, set _NET_WM_STATE directly
2246cdf0e10cSrcweir setNetWMState( pFrame );
2247cdf0e10cSrcweir }
2248cdf0e10cSrcweir // #i42750# guess size before resize event shows up
2249cdf0e10cSrcweir if( bFullScreen )
2250cdf0e10cSrcweir {
2251cdf0e10cSrcweir if( m_pSalDisplay->IsXinerama() )
2252cdf0e10cSrcweir {
2253cdf0e10cSrcweir XLIB_Window aRoot, aChild;
2254cdf0e10cSrcweir int root_x = 0, root_y = 0, lx, ly;
2255cdf0e10cSrcweir unsigned int mask;
2256cdf0e10cSrcweir XQueryPointer( m_pDisplay,
2257cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ),
2258cdf0e10cSrcweir &aRoot, &aChild,
2259cdf0e10cSrcweir &root_x, &root_y, &lx, &ly, &mask );
2260cdf0e10cSrcweir const std::vector< Rectangle >& rScreens = m_pSalDisplay->GetXineramaScreens();
2261cdf0e10cSrcweir Point aMousePoint( root_x, root_y );
2262cdf0e10cSrcweir for( unsigned int i = 0; i < rScreens.size(); i++ )
2263cdf0e10cSrcweir {
2264cdf0e10cSrcweir if( rScreens[i].IsInside( aMousePoint ) )
2265cdf0e10cSrcweir {
2266cdf0e10cSrcweir pFrame->maGeometry.nX = rScreens[i].Left();
2267cdf0e10cSrcweir pFrame->maGeometry.nY = rScreens[i].Top();
2268cdf0e10cSrcweir pFrame->maGeometry.nWidth = rScreens[i].GetWidth();
2269cdf0e10cSrcweir pFrame->maGeometry.nHeight = rScreens[i].GetHeight();
2270cdf0e10cSrcweir break;
2271cdf0e10cSrcweir }
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir }
2274cdf0e10cSrcweir else
2275cdf0e10cSrcweir {
2276cdf0e10cSrcweir Size aSize = m_pSalDisplay->GetScreenSize( pFrame->GetScreenNumber() );
2277cdf0e10cSrcweir pFrame->maGeometry.nX = 0;
2278cdf0e10cSrcweir pFrame->maGeometry.nY = 0;
2279cdf0e10cSrcweir pFrame->maGeometry.nWidth = aSize.Width();
2280cdf0e10cSrcweir pFrame->maGeometry.nHeight = aSize.Height();
2281cdf0e10cSrcweir }
2282cdf0e10cSrcweir pFrame->CallCallback( SALEVENT_MOVERESIZE, NULL );
2283cdf0e10cSrcweir }
2284cdf0e10cSrcweir }
2285cdf0e10cSrcweir else WMAdaptor::showFullScreen( pFrame, bFullScreen );
2286cdf0e10cSrcweir }
2287cdf0e10cSrcweir
2288cdf0e10cSrcweir /*
2289cdf0e10cSrcweir * WMAdaptor::getCurrentWorkArea
2290cdf0e10cSrcweir */
2291cdf0e10cSrcweir // FIXME: multiscreen case
getCurrentWorkArea() const2292cdf0e10cSrcweir int WMAdaptor::getCurrentWorkArea() const
2293cdf0e10cSrcweir {
2294cdf0e10cSrcweir int nCurrent = -1;
2295cdf0e10cSrcweir if( m_aWMAtoms[ NET_CURRENT_DESKTOP ] )
2296cdf0e10cSrcweir {
2297cdf0e10cSrcweir Atom aRealType = None;
2298cdf0e10cSrcweir int nFormat = 8;
2299cdf0e10cSrcweir unsigned long nItems = 0;
2300cdf0e10cSrcweir unsigned long nBytesLeft = 0;
2301cdf0e10cSrcweir unsigned char* pProperty = NULL;
2302cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
2303cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
2304cdf0e10cSrcweir m_aWMAtoms[ NET_CURRENT_DESKTOP ],
2305cdf0e10cSrcweir 0, 1,
2306cdf0e10cSrcweir False,
2307cdf0e10cSrcweir XA_CARDINAL,
2308cdf0e10cSrcweir &aRealType,
2309cdf0e10cSrcweir &nFormat,
2310cdf0e10cSrcweir &nItems,
2311cdf0e10cSrcweir &nBytesLeft,
2312cdf0e10cSrcweir &pProperty ) == 0
2313cdf0e10cSrcweir && pProperty
2314cdf0e10cSrcweir )
2315cdf0e10cSrcweir {
2316cdf0e10cSrcweir nCurrent = int(*(sal_Int32*)pProperty);
2317cdf0e10cSrcweir XFree( pProperty );
2318cdf0e10cSrcweir }
2319cdf0e10cSrcweir else if( pProperty )
2320cdf0e10cSrcweir {
2321cdf0e10cSrcweir XFree( pProperty );
2322cdf0e10cSrcweir pProperty = NULL;
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir }
2325cdf0e10cSrcweir return nCurrent;
2326cdf0e10cSrcweir }
2327cdf0e10cSrcweir
2328cdf0e10cSrcweir /*
2329cdf0e10cSrcweir * WMAdaptor::getWindowWorkArea
2330cdf0e10cSrcweir */
getWindowWorkArea(XLIB_Window aWindow) const2331cdf0e10cSrcweir int WMAdaptor::getWindowWorkArea( XLIB_Window aWindow ) const
2332cdf0e10cSrcweir {
2333cdf0e10cSrcweir int nCurrent = -1;
2334cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_DESKTOP ] )
2335cdf0e10cSrcweir {
2336cdf0e10cSrcweir Atom aRealType = None;
2337cdf0e10cSrcweir int nFormat = 8;
2338cdf0e10cSrcweir unsigned long nItems = 0;
2339cdf0e10cSrcweir unsigned long nBytesLeft = 0;
2340cdf0e10cSrcweir unsigned char* pProperty = NULL;
2341cdf0e10cSrcweir if( XGetWindowProperty( m_pDisplay,
2342cdf0e10cSrcweir aWindow,
2343cdf0e10cSrcweir m_aWMAtoms[ NET_WM_DESKTOP ],
2344cdf0e10cSrcweir 0, 1,
2345cdf0e10cSrcweir False,
2346cdf0e10cSrcweir XA_CARDINAL,
2347cdf0e10cSrcweir &aRealType,
2348cdf0e10cSrcweir &nFormat,
2349cdf0e10cSrcweir &nItems,
2350cdf0e10cSrcweir &nBytesLeft,
2351cdf0e10cSrcweir &pProperty ) == 0
2352cdf0e10cSrcweir && pProperty
2353cdf0e10cSrcweir )
2354cdf0e10cSrcweir {
2355cdf0e10cSrcweir nCurrent = int(*(sal_Int32*)pProperty);
2356cdf0e10cSrcweir XFree( pProperty );
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir else if( pProperty )
2359cdf0e10cSrcweir {
2360cdf0e10cSrcweir XFree( pProperty );
2361cdf0e10cSrcweir pProperty = NULL;
2362cdf0e10cSrcweir }
2363cdf0e10cSrcweir }
2364cdf0e10cSrcweir return nCurrent;
2365cdf0e10cSrcweir }
2366cdf0e10cSrcweir
2367cdf0e10cSrcweir /*
2368cdf0e10cSrcweir * WMAdaptor::getCurrentWorkArea
2369cdf0e10cSrcweir */
2370cdf0e10cSrcweir // fixme: multi screen case
switchToWorkArea(int nWorkArea,bool bConsiderWM) const2371cdf0e10cSrcweir void WMAdaptor::switchToWorkArea( int nWorkArea, bool bConsiderWM ) const
2372cdf0e10cSrcweir {
2373cdf0e10cSrcweir if( bConsiderWM && ! getWMshouldSwitchWorkspace() )
2374cdf0e10cSrcweir return;
2375cdf0e10cSrcweir
2376cdf0e10cSrcweir if( m_aWMAtoms[ NET_CURRENT_DESKTOP ] )
2377cdf0e10cSrcweir {
2378cdf0e10cSrcweir XEvent aEvent;
2379cdf0e10cSrcweir aEvent.type = ClientMessage;
2380cdf0e10cSrcweir aEvent.xclient.display = m_pDisplay;
2381cdf0e10cSrcweir aEvent.xclient.window = m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() );
2382cdf0e10cSrcweir aEvent.xclient.message_type = m_aWMAtoms[ NET_CURRENT_DESKTOP ];
2383cdf0e10cSrcweir aEvent.xclient.format = 32;
2384cdf0e10cSrcweir aEvent.xclient.data.l[0] = nWorkArea;
2385cdf0e10cSrcweir aEvent.xclient.data.l[1] = 0;
2386cdf0e10cSrcweir aEvent.xclient.data.l[2] = 0;
2387cdf0e10cSrcweir aEvent.xclient.data.l[3] = 0;
2388cdf0e10cSrcweir aEvent.xclient.data.l[4] = 0;
2389cdf0e10cSrcweir XSendEvent( m_pDisplay,
2390cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( m_pSalDisplay->GetDefaultScreenNumber() ),
2391cdf0e10cSrcweir False,
2392cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
2393cdf0e10cSrcweir &aEvent
2394cdf0e10cSrcweir );
2395cdf0e10cSrcweir }
2396cdf0e10cSrcweir }
2397cdf0e10cSrcweir
2398cdf0e10cSrcweir /*
2399cdf0e10cSrcweir * WMAdaptor::frameIsMapping
2400cdf0e10cSrcweir */
frameIsMapping(X11SalFrame *) const2401cdf0e10cSrcweir void WMAdaptor::frameIsMapping( X11SalFrame* ) const
2402cdf0e10cSrcweir {
2403cdf0e10cSrcweir }
2404cdf0e10cSrcweir
2405cdf0e10cSrcweir /*
2406cdf0e10cSrcweir * NetWMAdaptor::frameIsMapping
2407cdf0e10cSrcweir */
frameIsMapping(X11SalFrame * pFrame) const2408cdf0e10cSrcweir void NetWMAdaptor::frameIsMapping( X11SalFrame* pFrame ) const
2409cdf0e10cSrcweir {
2410cdf0e10cSrcweir setNetWMState( pFrame );
2411cdf0e10cSrcweir }
2412cdf0e10cSrcweir
2413cdf0e10cSrcweir /*
2414cdf0e10cSrcweir * WMAdaptor::setFrameStruts
2415cdf0e10cSrcweir */
setFrameStruts(X11SalFrame *,int,int,int,int,int,int,int,int,int,int,int,int) const2416cdf0e10cSrcweir void WMAdaptor::setFrameStruts( X11SalFrame*,
2417cdf0e10cSrcweir int, int, int, int,
2418cdf0e10cSrcweir int, int, int, int,
2419cdf0e10cSrcweir int, int, int, int ) const
2420cdf0e10cSrcweir {
2421cdf0e10cSrcweir }
2422cdf0e10cSrcweir
2423cdf0e10cSrcweir /*
2424cdf0e10cSrcweir * NetWMAdaptor::setFrameStruts
2425cdf0e10cSrcweir */
setFrameStruts(X11SalFrame * pFrame,int left,int right,int top,int bottom,int left_start_y,int left_end_y,int right_start_y,int right_end_y,int top_start_x,int top_end_x,int bottom_start_x,int bottom_end_x) const2426cdf0e10cSrcweir void NetWMAdaptor::setFrameStruts( X11SalFrame* pFrame,
2427cdf0e10cSrcweir int left, int right, int top, int bottom,
2428cdf0e10cSrcweir int left_start_y, int left_end_y,
2429cdf0e10cSrcweir int right_start_y, int right_end_y,
2430cdf0e10cSrcweir int top_start_x, int top_end_x,
2431cdf0e10cSrcweir int bottom_start_x, int bottom_end_x ) const
2432cdf0e10cSrcweir {
2433cdf0e10cSrcweir long nData[12];
2434cdf0e10cSrcweir nData[0] = left;
2435cdf0e10cSrcweir nData[1] = right;
2436cdf0e10cSrcweir nData[2] = top;
2437cdf0e10cSrcweir nData[3] = bottom;
2438cdf0e10cSrcweir nData[4] = left_start_y;
2439cdf0e10cSrcweir nData[5] = left_end_y;
2440cdf0e10cSrcweir nData[6] = right_start_y;
2441cdf0e10cSrcweir nData[7] = right_end_y;
2442cdf0e10cSrcweir nData[8] = top_start_x;
2443cdf0e10cSrcweir nData[9] = top_end_x;
2444cdf0e10cSrcweir nData[10]= bottom_start_x;
2445cdf0e10cSrcweir nData[11]= bottom_end_x;
2446cdf0e10cSrcweir Atom aProperty = None;
2447cdf0e10cSrcweir int nSetData = 0;
2448cdf0e10cSrcweir
2449cdf0e10cSrcweir if( m_aWMAtoms[NET_WM_STRUT_PARTIAL] )
2450cdf0e10cSrcweir {
2451cdf0e10cSrcweir aProperty = m_aWMAtoms[NET_WM_STRUT_PARTIAL];
2452cdf0e10cSrcweir nSetData = 12;
2453cdf0e10cSrcweir }
2454cdf0e10cSrcweir else if( m_aWMAtoms[NET_WM_STRUT] )
2455cdf0e10cSrcweir {
2456cdf0e10cSrcweir aProperty = m_aWMAtoms[NET_WM_STRUT];
2457cdf0e10cSrcweir nSetData = 4;
2458cdf0e10cSrcweir }
2459cdf0e10cSrcweir if( nSetData )
2460cdf0e10cSrcweir {
2461cdf0e10cSrcweir XChangeProperty( m_pDisplay,
2462cdf0e10cSrcweir pFrame->GetShellWindow(),
2463cdf0e10cSrcweir aProperty,
2464cdf0e10cSrcweir XA_CARDINAL,
2465cdf0e10cSrcweir 32,
2466cdf0e10cSrcweir PropModeReplace,
2467cdf0e10cSrcweir (unsigned char*)&nData,
2468cdf0e10cSrcweir nSetData
2469cdf0e10cSrcweir );
2470cdf0e10cSrcweir }
2471cdf0e10cSrcweir }
2472cdf0e10cSrcweir
2473cdf0e10cSrcweir /*
2474cdf0e10cSrcweir * WMAdaptor::setUserTime
2475cdf0e10cSrcweir */
setUserTime(X11SalFrame *,long) const2476cdf0e10cSrcweir void WMAdaptor::setUserTime( X11SalFrame*, long ) const
2477cdf0e10cSrcweir {
2478cdf0e10cSrcweir }
2479cdf0e10cSrcweir
2480cdf0e10cSrcweir /*
2481cdf0e10cSrcweir * NetWMAdaptor::setUserTime
2482cdf0e10cSrcweir */
setUserTime(X11SalFrame * i_pFrame,long i_nUserTime) const2483cdf0e10cSrcweir void NetWMAdaptor::setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const
2484cdf0e10cSrcweir {
2485cdf0e10cSrcweir if( m_aWMAtoms[NET_WM_USER_TIME] )
2486cdf0e10cSrcweir {
2487cdf0e10cSrcweir XChangeProperty( m_pDisplay,
2488cdf0e10cSrcweir i_pFrame->GetShellWindow(),
2489cdf0e10cSrcweir m_aWMAtoms[NET_WM_USER_TIME],
2490cdf0e10cSrcweir XA_CARDINAL,
2491cdf0e10cSrcweir 32,
2492cdf0e10cSrcweir PropModeReplace,
2493cdf0e10cSrcweir (unsigned char*)&i_nUserTime,
2494cdf0e10cSrcweir 1
2495cdf0e10cSrcweir );
2496cdf0e10cSrcweir }
2497cdf0e10cSrcweir }
2498cdf0e10cSrcweir
2499cdf0e10cSrcweir /*
2500cdf0e10cSrcweir * WMAdaptor::setPID
2501cdf0e10cSrcweir */
setPID(X11SalFrame * i_pFrame) const2502cdf0e10cSrcweir void WMAdaptor::setPID( X11SalFrame* i_pFrame ) const
2503cdf0e10cSrcweir {
2504cdf0e10cSrcweir if( m_aWMAtoms[NET_WM_PID] )
2505cdf0e10cSrcweir {
2506cdf0e10cSrcweir long nPID = (long)getpid();
2507cdf0e10cSrcweir XChangeProperty( m_pDisplay,
2508cdf0e10cSrcweir i_pFrame->GetShellWindow(),
2509cdf0e10cSrcweir m_aWMAtoms[NET_WM_PID],
2510cdf0e10cSrcweir XA_CARDINAL,
2511cdf0e10cSrcweir 32,
2512cdf0e10cSrcweir PropModeReplace,
2513cdf0e10cSrcweir (unsigned char*)&nPID,
2514cdf0e10cSrcweir 1
2515cdf0e10cSrcweir );
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir
2519cdf0e10cSrcweir /*
2520cdf0e10cSrcweir * WMAdaptor::setClientMachine
2521cdf0e10cSrcweir */
setClientMachine(X11SalFrame * i_pFrame) const2522cdf0e10cSrcweir void WMAdaptor::setClientMachine( X11SalFrame* i_pFrame ) const
2523cdf0e10cSrcweir {
2524cdf0e10cSrcweir rtl::OString aWmClient( rtl::OUStringToOString( GetX11SalData()->GetLocalHostName(), RTL_TEXTENCODING_ASCII_US ) );
2525cdf0e10cSrcweir XTextProperty aClientProp = { (unsigned char*)aWmClient.getStr(), XA_STRING, 8, aWmClient.getLength() };
2526cdf0e10cSrcweir XSetWMClientMachine( m_pDisplay, i_pFrame->GetShellWindow(), &aClientProp );
2527cdf0e10cSrcweir }
2528cdf0e10cSrcweir
answerPing(X11SalFrame * i_pFrame,XClientMessageEvent * i_pEvent) const2529cdf0e10cSrcweir void WMAdaptor::answerPing( X11SalFrame* i_pFrame, XClientMessageEvent* i_pEvent ) const
2530cdf0e10cSrcweir {
2531cdf0e10cSrcweir if( m_aWMAtoms[NET_WM_PING] &&
2532cdf0e10cSrcweir i_pEvent->message_type == m_aWMAtoms[ WM_PROTOCOLS ] &&
2533cdf0e10cSrcweir (Atom)i_pEvent->data.l[0] == m_aWMAtoms[ NET_WM_PING ] )
2534cdf0e10cSrcweir {
2535cdf0e10cSrcweir XEvent aEvent;
2536cdf0e10cSrcweir aEvent.xclient = *i_pEvent;
2537cdf0e10cSrcweir aEvent.xclient.window = m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() );
2538cdf0e10cSrcweir XSendEvent( m_pDisplay,
2539cdf0e10cSrcweir m_pSalDisplay->GetRootWindow( i_pFrame->GetScreenNumber() ),
2540cdf0e10cSrcweir False,
2541cdf0e10cSrcweir SubstructureNotifyMask | SubstructureRedirectMask,
2542cdf0e10cSrcweir &aEvent
2543cdf0e10cSrcweir );
2544cdf0e10cSrcweir XFlush( m_pDisplay );
2545cdf0e10cSrcweir }
2546cdf0e10cSrcweir }
2547cdf0e10cSrcweir
2548cdf0e10cSrcweir /*
2549cdf0e10cSrcweir * WMAdaptor::setFullScreenMonitors
2550cdf0e10cSrcweir */
setFullScreenMonitors(XLIB_Window,sal_Int32)2551cdf0e10cSrcweir void WMAdaptor::setFullScreenMonitors( XLIB_Window, sal_Int32 )
2552cdf0e10cSrcweir {
2553cdf0e10cSrcweir }
2554cdf0e10cSrcweir
2555cdf0e10cSrcweir /*
2556cdf0e10cSrcweir * NetWMAdaptor::setFullScreenMonitors
2557cdf0e10cSrcweir */
setFullScreenMonitors(XLIB_Window i_aWindow,sal_Int32 i_nScreen)2558cdf0e10cSrcweir void NetWMAdaptor::setFullScreenMonitors( XLIB_Window i_aWindow, sal_Int32 i_nScreen )
2559cdf0e10cSrcweir {
2560cdf0e10cSrcweir if( m_aWMAtoms[ NET_WM_FULLSCREEN_MONITORS ] )
2561cdf0e10cSrcweir {
2562cdf0e10cSrcweir const std::vector< Rectangle >& rScreens( m_pSalDisplay->GetXineramaScreens() );
2563cdf0e10cSrcweir if( m_pSalDisplay->IsXinerama() && rScreens.size() > 1 )
2564cdf0e10cSrcweir {
2565cdf0e10cSrcweir long nSpannedMonitors[4] = {0,0,0,0};
2566cdf0e10cSrcweir if( i_nScreen == -1 ) // all screens
2567cdf0e10cSrcweir {
2568cdf0e10cSrcweir long nLeft = rScreens.front().Left();
2569cdf0e10cSrcweir long nRight = rScreens.front().Right();
2570cdf0e10cSrcweir long nTop = rScreens.front().Top();
2571cdf0e10cSrcweir long nBottom = rScreens.front().Bottom();
2572cdf0e10cSrcweir for( long i = 1; i < long(rScreens.size()); ++ i )
2573cdf0e10cSrcweir {
2574cdf0e10cSrcweir if( rScreens[i].Left() < nLeft )
2575cdf0e10cSrcweir {
2576cdf0e10cSrcweir nLeft = rScreens[i].Left();
2577cdf0e10cSrcweir nSpannedMonitors[2] = i;
2578cdf0e10cSrcweir }
2579cdf0e10cSrcweir if( rScreens[i].Top() < nTop )
2580cdf0e10cSrcweir {
2581cdf0e10cSrcweir nTop = rScreens[i].Top();
2582cdf0e10cSrcweir nSpannedMonitors[0] = i;
2583cdf0e10cSrcweir }
2584cdf0e10cSrcweir if( rScreens[i].Bottom() > nBottom )
2585cdf0e10cSrcweir {
2586cdf0e10cSrcweir nBottom = rScreens[i].Bottom();
2587cdf0e10cSrcweir nSpannedMonitors[1] = i;
2588cdf0e10cSrcweir }
2589cdf0e10cSrcweir if( rScreens[i].Right() > nRight )
2590cdf0e10cSrcweir {
2591cdf0e10cSrcweir nRight = rScreens[i].Right();
2592cdf0e10cSrcweir nSpannedMonitors[3] = i;
2593cdf0e10cSrcweir }
2594cdf0e10cSrcweir }
2595cdf0e10cSrcweir }
2596cdf0e10cSrcweir else
2597cdf0e10cSrcweir {
2598cdf0e10cSrcweir if( i_nScreen < 0 || i_nScreen >= sal_Int32(rScreens.size()) )
2599cdf0e10cSrcweir i_nScreen = 0;
2600cdf0e10cSrcweir nSpannedMonitors[0] = nSpannedMonitors[1] = nSpannedMonitors[2] = nSpannedMonitors[3] = i_nScreen;
2601cdf0e10cSrcweir }
2602cdf0e10cSrcweir XChangeProperty( m_pDisplay, i_aWindow,
2603cdf0e10cSrcweir m_aWMAtoms[ NET_WM_FULLSCREEN_MONITORS ],
2604cdf0e10cSrcweir XA_CARDINAL, 32,
2605cdf0e10cSrcweir PropModeReplace, (unsigned char*)nSpannedMonitors, 4 );
2606cdf0e10cSrcweir
2607cdf0e10cSrcweir }
2608cdf0e10cSrcweir }
2609cdf0e10cSrcweir }
2610cdf0e10cSrcweir
2611