Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_WMADAPTOR_HXX_
30 : : #define _VCL_WMADAPTOR_HXX_
31 : :
32 : : #include <tools/string.hxx>
33 : : #include <tools/gen.hxx>
34 : : #ifndef _PREX_H
35 : : #include <tools/prex.h>
36 : : #include <X11/Xlib.h>
37 : : #include <tools/postx.h>
38 : : #endif
39 : : #include <vclpluginapi.h>
40 : : #include <vector>
41 : :
42 : : class SalDisplay;
43 : : class X11SalFrame;
44 : :
45 : : namespace vcl_sal {
46 : :
47 : : class VCLPLUG_GEN_PUBLIC WMAdaptor
48 : : {
49 : : public:
50 : : enum WMAtom {
51 : : // atoms for types
52 : : UTF8_STRING,
53 : :
54 : : // atoms for extended WM hints
55 : : NET_SUPPORTED,
56 : : NET_SUPPORTING_WM_CHECK,
57 : : NET_WM_NAME,
58 : : NET_WM_DESKTOP,
59 : : NET_WM_ICON_NAME,
60 : : NET_WM_PID,
61 : : NET_WM_PING,
62 : : NET_WM_STATE,
63 : : NET_WM_STATE_MAXIMIZED_HORZ,
64 : : NET_WM_STATE_MAXIMIZED_VERT,
65 : : NET_WM_STATE_MODAL,
66 : : NET_WM_STATE_SHADED,
67 : : NET_WM_STATE_SKIP_PAGER,
68 : : NET_WM_STATE_SKIP_TASKBAR,
69 : : NET_WM_STATE_STAYS_ON_TOP,
70 : : NET_WM_STATE_STICKY,
71 : : NET_WM_STATE_FULLSCREEN,
72 : : NET_WM_STRUT,
73 : : NET_WM_STRUT_PARTIAL,
74 : : NET_WM_USER_TIME,
75 : : NET_WM_WINDOW_TYPE,
76 : : NET_WM_WINDOW_TYPE_DESKTOP,
77 : : NET_WM_WINDOW_TYPE_DIALOG,
78 : : NET_WM_WINDOW_TYPE_DOCK,
79 : : NET_WM_WINDOW_TYPE_MENU,
80 : : NET_WM_WINDOW_TYPE_NORMAL,
81 : : NET_WM_WINDOW_TYPE_TOOLBAR,
82 : : KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
83 : : NET_WM_WINDOW_TYPE_SPLASH,
84 : : NET_WM_WINDOW_TYPE_UTILITY,
85 : : NET_NUMBER_OF_DESKTOPS,
86 : : NET_CURRENT_DESKTOP,
87 : : NET_WORKAREA,
88 : :
89 : : // atoms for Gnome WM hints
90 : : WIN_SUPPORTING_WM_CHECK,
91 : : WIN_PROTOCOLS,
92 : : WIN_WORKSPACE_COUNT,
93 : : WIN_WORKSPACE,
94 : : WIN_LAYER,
95 : : WIN_STATE,
96 : : WIN_HINTS,
97 : : WIN_APP_STATE,
98 : : WIN_EXPANDED_SIZE,
99 : : WIN_ICONS,
100 : : WIN_WORKSPACE_NAMES,
101 : : WIN_CLIENT_LIST,
102 : :
103 : : // atoms for general WM hints
104 : : WM_STATE,
105 : : MOTIF_WM_HINTS,
106 : : WM_PROTOCOLS,
107 : : WM_DELETE_WINDOW,
108 : : WM_TAKE_FOCUS,
109 : : WM_CLIENT_LEADER,
110 : : WM_COMMAND,
111 : : WM_LOCALE_NAME,
112 : : WM_TRANSIENT_FOR,
113 : :
114 : : // special atoms
115 : : SAL_QUITEVENT,
116 : : SAL_USEREVENT,
117 : : SAL_EXTTEXTEVENT,
118 : : SAL_GETTIMEEVENT,
119 : : DTWM_IS_RUNNING,
120 : : VCL_SYSTEM_SETTINGS,
121 : : XSETTINGS,
122 : : XEMBED,
123 : : XEMBED_INFO,
124 : : NetAtomMax
125 : : };
126 : :
127 : : /*
128 : : * flags for frame decoration
129 : : */
130 : : static const int decoration_Title = 0x00000001;
131 : : static const int decoration_Border = 0x00000002;
132 : : static const int decoration_Resize = 0x00000004;
133 : : static const int decoration_MinimizeBtn = 0x00000008;
134 : : static const int decoration_MaximizeBtn = 0x00000010;
135 : : static const int decoration_CloseBtn = 0x00000020;
136 : : static const int decoration_All = 0x10000000;
137 : :
138 : : /*
139 : : * window type
140 : : */
141 : : enum WMWindowType
142 : : {
143 : : windowType_Normal,
144 : : windowType_ModalDialogue,
145 : : windowType_ModelessDialogue,
146 : : windowType_Utility,
147 : : windowType_Splash,
148 : : windowType_Toolbar,
149 : : windowType_Dock
150 : : };
151 : :
152 : : protected:
153 : : SalDisplay* m_pSalDisplay; // Display to use
154 : : Display* m_pDisplay; // X Display of SalDisplay
155 : : String m_aWMName;
156 : : Atom m_aWMAtoms[ NetAtomMax];
157 : : int m_nDesktops;
158 : : bool m_bEqualWorkAreas;
159 : : ::std::vector< Rectangle >
160 : : m_aWMWorkAreas;
161 : : bool m_bTransientBehaviour;
162 : : bool m_bEnableAlwaysOnTopWorks;
163 : : bool m_bLegacyPartialFullscreen;
164 : : int m_nWinGravity;
165 : : int m_nInitWinGravity;
166 : : bool m_bWMshouldSwitchWorkspace;
167 : : bool m_bWMshouldSwitchWorkspaceInit;
168 : :
169 : : WMAdaptor( SalDisplay * )
170 : : ;
171 : : void initAtoms();
172 : : bool getNetWmName();
173 : :
174 : : /*
175 : : * returns whether this instance is useful
176 : : * only useful for createWMAdaptor
177 : : */
178 : : virtual bool isValid() const;
179 : :
180 : : bool getWMshouldSwitchWorkspace() const;
181 : : public:
182 : : virtual ~WMAdaptor();
183 : :
184 : : /*
185 : : * creates a vaild WMAdaptor instance for the SalDisplay
186 : : */
187 : : static WMAdaptor* createWMAdaptor( SalDisplay* );
188 : :
189 : : /*
190 : : * may return an empty string if the window manager could
191 : : * not be identified.
192 : : */
193 : 0 : const String& getWindowManagerName() const
194 : 0 : { return m_aWMName; }
195 : :
196 : : /*
197 : : * gets the number of workareas
198 : : */
199 : : int getWorkAreaCount() const
200 : : { return m_aWMWorkAreas.size(); }
201 : :
202 : : /*
203 : : * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
204 : : */
205 : : int getCurrentWorkArea() const;
206 : : /*
207 : : * gets the workarea the specified window is on (or -1)
208 : : */
209 : : int getWindowWorkArea( XLIB_Window aWindow ) const;
210 : : /*
211 : : * gets the specified workarea
212 : : */
213 : 0 : const Rectangle& getWorkArea( int n ) const
214 : 0 : { return m_aWMWorkAreas[n]; }
215 : :
216 : : /*
217 : : * attemp to switch the desktop to a certain workarea
218 : : * if bConsiderWM is true, then on some WMs the call will not result in any action
219 : : */
220 : : void switchToWorkArea( int nWorkArea, bool bConsiderWM = true ) const;
221 : :
222 : : /*
223 : : * sets window title
224 : : */
225 : : virtual void setWMName( X11SalFrame* pFrame, const String& rWMName ) const;
226 : :
227 : : /*
228 : : * set NET_WM_PID
229 : : */
230 : : virtual void setPID( X11SalFrame* pFrame ) const;
231 : :
232 : : /*
233 : : * set WM_CLIENT_MACHINE
234 : : */
235 : : virtual void setClientMachine( X11SalFrame* pFrame ) const;
236 : :
237 : : virtual void answerPing( X11SalFrame*, XClientMessageEvent* ) const;
238 : :
239 : : /*
240 : : * maximizes frame
241 : : * maximization can be toggled in either direction
242 : : * to get the original position and size
243 : : * use maximizeFrame( pFrame, false, false )
244 : : */
245 : : virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
246 : : /*
247 : : * start/stop fullscreen mode on a frame
248 : : */
249 : : virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
250 : : /*
251 : : * tell whether legacy partial full screen handling is necessary
252 : : * see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto
253 : : * modern WM's interpret it the "right" way, namely they make "full screen"
254 : : * taking twin view or Xinerama into accound and honor the positioning hints
255 : : * to see which screen actually was meant to use for fullscreen.
256 : : */
257 : 0 : bool isLegacyPartialFullscreen() const
258 : 0 : { return m_bLegacyPartialFullscreen; }
259 : : /*
260 : : * set window struts
261 : : */
262 : : virtual void setFrameStruts( X11SalFrame*pFrame,
263 : : int left, int right, int top, int bottom,
264 : : int left_start_y, int left_end_y,
265 : : int right_start_y, int right_end_y,
266 : : int top_start_x, int top_end_x,
267 : : int bottom_start_x, int bottom_end_x ) const;
268 : : /*
269 : : * set _NET_WM_USER_TIME property, if NetWM
270 : : */
271 : : virtual void setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const;
272 : :
273 : : /*
274 : : * tells whether fullscreen mode is supported by WM
275 : : */
276 : 0 : bool supportsFullScreen() const { return m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] != 0; }
277 : :
278 : : /*
279 : : * shade/unshade frame
280 : : */
281 : : virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
282 : :
283 : : /*
284 : : * set hints what decoration is needed;
285 : : * must be called before showing the frame
286 : : */
287 : : virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame = NULL ) const;
288 : :
289 : : /*
290 : : * tells whether there is WM support for splash screens
291 : : */
292 : 0 : bool supportsSplash() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] != 0; }
293 : :
294 : : /*
295 : : * tells whteher there is WM support for NET_WM_WINDOW_TYPE_TOOLBAR
296 : : */
297 : : bool supportsToolbar() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_TOOLBAR ] != 0; }
298 : :
299 : : /*
300 : : * enables always on top or equivalent if possible
301 : : */
302 : : virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
303 : :
304 : : /*
305 : : * tells whether enableAlwaysOnTop actually works with this WM
306 : : */
307 : 0 : bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks; }
308 : :
309 : : /*
310 : : * handle WM messages (especially WM state changes)
311 : : */
312 : : virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
313 : :
314 : : /*
315 : : * called by SalFrame::Show: time to update state properties
316 : : */
317 : : virtual void frameIsMapping( X11SalFrame* ) const;
318 : :
319 : : /*
320 : : * gets a WM atom
321 : : */
322 : 0 : Atom getAtom( WMAtom eAtom ) const
323 : 0 : { return m_aWMAtoms[ eAtom ]; }
324 : :
325 : 0 : int getPositionWinGravity () const
326 : 0 : { return m_nWinGravity; }
327 : 0 : int getInitWinGravity() const
328 : 0 : { return m_nInitWinGravity; }
329 : :
330 : : /*
331 : : * expected behaviour is that the WM will not allow transient
332 : : * windows to get stacked behind the windows they are transient for
333 : : */
334 : 0 : bool isTransientBehaviourAsExpected() const
335 : 0 : { return m_bTransientBehaviour; }
336 : :
337 : : /*
338 : : * changes the transient hint of a window to reference frame
339 : : * if reference frame is NULL the root window is used instead
340 : : */
341 : : void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame* pReferenceFrame ) const;
342 : : };
343 : :
344 : : } // namespace
345 : :
346 : : #endif
347 : :
348 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|