1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wmadaptor.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _VCL_WMADAPTOR_HXX_
32 #define _VCL_WMADAPTOR_HXX_
34 #ifndef _TL_STRING_HXX
35 #include <tools/string.hxx>
37 #include <tools/gen.hxx>
38 #include <vcl/dllapi.h>
40 #include <tools/prex.h>
42 #include <tools/postx.h>
51 class VCL_DLLPUBLIC WMAdaptor
58 // atoms for extended WM hints
60 NET_SUPPORTING_WM_CHECK
,
65 NET_WM_STATE_MAXIMIZED_HORZ
,
66 NET_WM_STATE_MAXIMIZED_VERT
,
69 NET_WM_STATE_SKIP_PAGER
,
70 NET_WM_STATE_SKIP_TASKBAR
,
71 NET_WM_STATE_STAYS_ON_TOP
,
73 NET_WM_STATE_FULLSCREEN
,
78 NET_WM_WINDOW_TYPE_DESKTOP
,
79 NET_WM_WINDOW_TYPE_DIALOG
,
80 NET_WM_WINDOW_TYPE_DOCK
,
81 NET_WM_WINDOW_TYPE_MENU
,
82 NET_WM_WINDOW_TYPE_NORMAL
,
83 NET_WM_WINDOW_TYPE_TOOLBAR
,
84 KDE_NET_WM_WINDOW_TYPE_OVERRIDE
,
85 NET_WM_WINDOW_TYPE_SPLASH
,
86 NET_WM_WINDOW_TYPE_UTILITY
,
87 NET_NUMBER_OF_DESKTOPS
,
91 // atoms for Gnome WM hints
92 WIN_SUPPORTING_WM_CHECK
,
105 // atoms for general WM hints
131 * flags for frame decoration
133 static const int decoration_Title
= 0x00000001;
134 static const int decoration_Border
= 0x00000002;
135 static const int decoration_Resize
= 0x00000004;
136 static const int decoration_MinimizeBtn
= 0x00000008;
137 static const int decoration_MaximizeBtn
= 0x00000010;
138 static const int decoration_CloseBtn
= 0x00000020;
139 static const int decoration_All
= 0x10000000;
147 windowType_ModalDialogue
,
148 windowType_ModelessDialogue
,
156 SalDisplay
* m_pSalDisplay
; // Display to use
157 Display
* m_pDisplay
; // X Display of SalDisplay
159 Atom m_aWMAtoms
[ NetAtomMax
];
161 bool m_bEqualWorkAreas
;
162 ::std::vector
< Rectangle
>
164 bool m_bTransientBehaviour
;
165 bool m_bEnableAlwaysOnTopWorks
;
167 int m_nInitWinGravity
;
169 WMAdaptor( SalDisplay
* )
175 * returns whether this instance is useful
176 * only useful for createWMAdaptor
178 virtual bool isValid() const;
181 virtual ~WMAdaptor();
184 * creates a vaild WMAdaptor instance for the SalDisplay
186 static WMAdaptor
* createWMAdaptor( SalDisplay
* );
189 * may return an empty string if the window manager could
192 const String
& getWindowManagerName() const
193 { return m_aWMName
; }
196 * gets the number of workareas
198 int getWorkAreaCount() const
199 { return m_aWMWorkAreas
.size(); }
202 * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
204 int getCurrentWorkArea() const;
206 * gets the workarea the specified window is on (or -1)
208 int getWindowWorkArea( XLIB_Window aWindow
) const;
210 * gets the specified workarea
212 const Rectangle
& getWorkArea( int n
) const
213 { return m_aWMWorkAreas
[n
]; }
216 * attemp to switch the desktop to a certain workarea
218 void switchToWorkArea( int nWorkArea
) const;
223 virtual void setWMName( X11SalFrame
* pFrame
, const String
& rWMName
) const;
227 * maximization can be toggled in either direction
228 * to get the original position and size
229 * use maximizeFrame( pFrame, false, false )
231 virtual void maximizeFrame( X11SalFrame
* pFrame
, bool bHorizontal
= true, bool bVertical
= true ) const;
233 * start/stop fullscreen mode on a frame
235 virtual void showFullScreen( X11SalFrame
* pFrame
, bool bFullScreen
) const;
239 virtual void setFrameStruts( X11SalFrame
*pFrame
,
240 int left
, int right
, int top
, int bottom
,
241 int left_start_y
, int left_end_y
,
242 int right_start_y
, int right_end_y
,
243 int top_start_x
, int top_end_x
,
244 int bottom_start_x
, int bottom_end_x
) const;
246 * set _NET_WM_USER_TIME property, if NetWM
248 virtual void setUserTime( X11SalFrame
* i_pFrame
, long i_nUserTime
) const;
251 * tells whether fullscreen mode is supported by WM
253 bool supportsFullScreen() const { return m_aWMAtoms
[ NET_WM_STATE_FULLSCREEN
] != 0; }
256 * shade/unshade frame
258 virtual void shade( X11SalFrame
* pFrame
, bool bToShaded
) const;
261 * set hints what decoration is needed;
262 * must be called before showing the frame
264 virtual void setFrameTypeAndDecoration( X11SalFrame
* pFrame
, WMWindowType eType
, int nDecorationFlags
, X11SalFrame
* pTransientFrame
= NULL
) const;
267 * tells whether there is WM support for splash screens
269 bool supportsSplash() const { return m_aWMAtoms
[ NET_WM_WINDOW_TYPE_SPLASH
] != 0; }
272 * tells whteher there is WM support for NET_WM_WINDOW_TYPE_TOOLBAR
274 bool supportsToolbar() const { return m_aWMAtoms
[ NET_WM_WINDOW_TYPE_TOOLBAR
] != 0; }
277 * enables always on top or equivalent if possible
279 virtual void enableAlwaysOnTop( X11SalFrame
* pFrame
, bool bEnable
) const;
282 * tells whether enableAlwaysOnTop actually works with this WM
284 bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks
; }
287 * handle WM messages (especially WM state changes)
289 virtual int handlePropertyNotify( X11SalFrame
* pFrame
, XPropertyEvent
* pEvent
) const;
292 * called by SalFrame::Show: time to update state properties
294 virtual void frameIsMapping( X11SalFrame
* ) const;
299 Atom
getAtom( WMAtom eAtom
) const
300 { return m_aWMAtoms
[ eAtom
]; }
303 * supports correct positioning
306 virtual bool supportsICCCMPos () const;
308 int getPositionWinGravity () const
309 { return m_nWinGravity
; }
310 int getInitWinGravity() const
311 { return m_nInitWinGravity
; }
314 * expected behaviour is that the WM will not allow transient
315 * windows to get stacked behind the windows they are transient for
317 bool isTransientBehaviourAsExpected() const
318 { return m_bTransientBehaviour
; }
321 * changes the transient hint of a window to reference frame
322 * if reference frame is NULL the root window is used instead
324 void changeReferenceFrame( X11SalFrame
* pFrame
, X11SalFrame
* pReferenceFrame
) const;