merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / inc / wmadaptor.hxx
blob10fec50cd8208e26517bcc0e92ce1b6c12ebc7c0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wmadaptor.hxx,v $
10 * $Revision: 1.28 $
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>
36 #endif
37 #include <tools/gen.hxx>
38 #include <vcl/dllapi.h>
39 #ifndef _PREX_H
40 #include <tools/prex.h>
41 #include <X11/Xlib.h>
42 #include <tools/postx.h>
43 #endif
44 #include <vector>
46 class SalDisplay;
47 class X11SalFrame;
49 namespace vcl_sal {
51 class VCL_DLLPUBLIC WMAdaptor
53 public:
54 enum WMAtom {
55 // atoms for types
56 UTF8_STRING,
58 // atoms for extended WM hints
59 NET_SUPPORTED,
60 NET_SUPPORTING_WM_CHECK,
61 NET_WM_NAME,
62 NET_WM_DESKTOP,
63 NET_WM_ICON_NAME,
64 NET_WM_STATE,
65 NET_WM_STATE_MAXIMIZED_HORZ,
66 NET_WM_STATE_MAXIMIZED_VERT,
67 NET_WM_STATE_MODAL,
68 NET_WM_STATE_SHADED,
69 NET_WM_STATE_SKIP_PAGER,
70 NET_WM_STATE_SKIP_TASKBAR,
71 NET_WM_STATE_STAYS_ON_TOP,
72 NET_WM_STATE_STICKY,
73 NET_WM_STATE_FULLSCREEN,
74 NET_WM_STRUT,
75 NET_WM_STRUT_PARTIAL,
76 NET_WM_USER_TIME,
77 NET_WM_WINDOW_TYPE,
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,
88 NET_CURRENT_DESKTOP,
89 NET_WORKAREA,
91 // atoms for Gnome WM hints
92 WIN_SUPPORTING_WM_CHECK,
93 WIN_PROTOCOLS,
94 WIN_WORKSPACE_COUNT,
95 WIN_WORKSPACE,
96 WIN_LAYER,
97 WIN_STATE,
98 WIN_HINTS,
99 WIN_APP_STATE,
100 WIN_EXPANDED_SIZE,
101 WIN_ICONS,
102 WIN_WORKSPACE_NAMES,
103 WIN_CLIENT_LIST,
105 // atoms for general WM hints
106 WM_STATE,
107 MOTIF_WM_HINTS,
108 WM_PROTOCOLS,
109 WM_DELETE_WINDOW,
110 WM_TAKE_FOCUS,
111 WM_SAVE_YOURSELF,
112 WM_CLIENT_LEADER,
113 WM_COMMAND,
114 WM_LOCALE_NAME,
115 WM_TRANSIENT_FOR,
117 // special atoms
118 SAL_QUITEVENT,
119 SAL_USEREVENT,
120 SAL_EXTTEXTEVENT,
121 SAL_GETTIMEEVENT,
122 DTWM_IS_RUNNING,
123 VCL_SYSTEM_SETTINGS,
124 XSETTINGS,
125 XEMBED,
126 XEMBED_INFO,
127 NetAtomMax
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;
142 * window type
144 enum WMWindowType
146 windowType_Normal,
147 windowType_ModalDialogue,
148 windowType_ModelessDialogue,
149 windowType_Utility,
150 windowType_Splash,
151 windowType_Toolbar,
152 windowType_Dock
155 protected:
156 SalDisplay* m_pSalDisplay; // Display to use
157 Display* m_pDisplay; // X Display of SalDisplay
158 String m_aWMName;
159 Atom m_aWMAtoms[ NetAtomMax];
160 int m_nDesktops;
161 bool m_bEqualWorkAreas;
162 ::std::vector< Rectangle >
163 m_aWMWorkAreas;
164 bool m_bTransientBehaviour;
165 bool m_bEnableAlwaysOnTopWorks;
166 int m_nWinGravity;
167 int m_nInitWinGravity;
169 WMAdaptor( SalDisplay * )
171 void initAtoms();
172 bool getNetWmName();
175 * returns whether this instance is useful
176 * only useful for createWMAdaptor
178 virtual bool isValid() const;
180 public:
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
190 * not be identified.
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;
221 * sets window title
223 virtual void setWMName( X11SalFrame* pFrame, const String& rWMName ) const;
226 * maximizes frame
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;
237 * set window struts
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;
297 * gets a WM atom
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;
327 } // namespace
329 #endif