update emoji autocorrect entries from po-files
[LibreOffice.git] / vcl / inc / unx / wmadaptor.hxx
blob35fb4590b5085f26646e32d4ac9747fd5cb629f8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_UNX_WMADAPTOR_HXX
21 #define INCLUDED_VCL_INC_UNX_WMADAPTOR_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/gen.hxx>
25 #ifndef _PREX_H
26 #include <prex.h>
27 #include <X11/Xlib.h>
28 #include <postx.h>
29 #endif
30 #include <vclpluginapi.h>
31 #include <vector>
33 class SalDisplay;
34 class X11SalFrame;
36 namespace vcl_sal {
38 class VCLPLUG_GEN_PUBLIC WMAdaptor
40 public:
41 enum WMAtom {
42 // atoms for types
43 UTF8_STRING,
45 // atoms for extended WM hints
46 NET_SUPPORTED,
47 NET_SUPPORTING_WM_CHECK,
48 NET_WM_NAME,
49 NET_WM_DESKTOP,
50 NET_WM_ICON_NAME,
51 NET_WM_PID,
52 NET_WM_PING,
53 NET_WM_STATE,
54 NET_WM_STATE_MAXIMIZED_HORZ,
55 NET_WM_STATE_MAXIMIZED_VERT,
56 NET_WM_STATE_MODAL,
57 NET_WM_STATE_SHADED,
58 NET_WM_STATE_SKIP_PAGER,
59 NET_WM_STATE_SKIP_TASKBAR,
60 NET_WM_STATE_STAYS_ON_TOP,
61 NET_WM_STATE_STICKY,
62 NET_WM_STATE_FULLSCREEN,
63 NET_WM_STRUT,
64 NET_WM_STRUT_PARTIAL,
65 NET_WM_USER_TIME,
66 NET_WM_WINDOW_TYPE,
67 NET_WM_WINDOW_TYPE_DESKTOP,
68 NET_WM_WINDOW_TYPE_DIALOG,
69 NET_WM_WINDOW_TYPE_DOCK,
70 NET_WM_WINDOW_TYPE_MENU,
71 NET_WM_WINDOW_TYPE_NORMAL,
72 NET_WM_WINDOW_TYPE_TOOLBAR,
73 KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
74 NET_WM_WINDOW_TYPE_SPLASH,
75 NET_WM_WINDOW_TYPE_UTILITY,
76 NET_NUMBER_OF_DESKTOPS,
77 NET_CURRENT_DESKTOP,
78 NET_WORKAREA,
79 NET_WM_ICON,
81 // atoms for Gnome WM hints
82 WIN_SUPPORTING_WM_CHECK,
83 WIN_PROTOCOLS,
84 WIN_WORKSPACE_COUNT,
85 WIN_WORKSPACE,
86 WIN_LAYER,
87 WIN_STATE,
88 WIN_HINTS,
89 WIN_APP_STATE,
90 WIN_EXPANDED_SIZE,
91 WIN_ICONS,
92 WIN_WORKSPACE_NAMES,
93 WIN_CLIENT_LIST,
95 // atoms for general WM hints
96 WM_STATE,
97 MOTIF_WM_HINTS,
98 WM_PROTOCOLS,
99 WM_DELETE_WINDOW,
100 WM_TAKE_FOCUS,
101 WM_CLIENT_LEADER,
102 WM_COMMAND,
103 WM_LOCALE_NAME,
104 WM_TRANSIENT_FOR,
106 // special atoms
107 SAL_QUITEVENT,
108 SAL_USEREVENT,
109 SAL_EXTTEXTEVENT,
110 SAL_GETTIMEEVENT,
111 DTWM_IS_RUNNING,
112 VCL_SYSTEM_SETTINGS,
113 XSETTINGS,
114 XEMBED,
115 XEMBED_INFO,
116 NetAtomMax
120 * flags for frame decoration
122 static const int decoration_Title = 0x00000001;
123 static const int decoration_Border = 0x00000002;
124 static const int decoration_Resize = 0x00000004;
125 static const int decoration_MinimizeBtn = 0x00000008;
126 static const int decoration_MaximizeBtn = 0x00000010;
127 static const int decoration_CloseBtn = 0x00000020;
128 static const int decoration_All = 0x10000000;
131 * window type
133 enum WMWindowType
135 windowType_Normal,
136 windowType_ModalDialogue,
137 windowType_ModelessDialogue,
138 windowType_Utility,
139 windowType_Splash,
140 windowType_Toolbar,
141 windowType_Dock
144 protected:
145 SalDisplay* m_pSalDisplay; // Display to use
146 Display* m_pDisplay; // X Display of SalDisplay
147 OUString m_aWMName;
148 Atom m_aWMAtoms[ NetAtomMax];
149 int m_nDesktops;
150 bool m_bEqualWorkAreas;
151 ::std::vector< Rectangle >
152 m_aWMWorkAreas;
153 bool m_bTransientBehaviour;
154 bool m_bEnableAlwaysOnTopWorks;
155 bool m_bLegacyPartialFullscreen;
156 int m_nWinGravity;
157 int m_nInitWinGravity;
158 bool m_bWMshouldSwitchWorkspace;
159 bool m_bWMshouldSwitchWorkspaceInit;
161 WMAdaptor( SalDisplay * )
163 void initAtoms();
164 bool getNetWmName();
167 * returns whether this instance is useful
168 * only useful for createWMAdaptor
170 virtual bool isValid() const;
172 bool getWMshouldSwitchWorkspace() const;
173 public:
174 virtual ~WMAdaptor();
177 * creates a valid WMAdaptor instance for the SalDisplay
179 static WMAdaptor* createWMAdaptor( SalDisplay* );
182 * may return an empty string if the window manager could
183 * not be identified.
185 const OUString& getWindowManagerName() const
186 { return m_aWMName; }
189 * gets the number of workareas (virtual desktops)
191 int getWorkAreaCount() const
192 { return m_aWMWorkAreas.size(); }
195 * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
197 int getCurrentWorkArea() const;
199 * gets the workarea the specified window is on (or -1)
201 int getWindowWorkArea( ::Window aWindow ) const;
203 * gets the specified workarea
205 const Rectangle& getWorkArea( int n ) const
206 { return m_aWMWorkAreas[n]; }
209 * attempt to switch the desktop to a certain workarea (ie. virtual desktops)
210 * if bConsiderWM is true, then on some WMs the call will not result in any action
212 void switchToWorkArea( int nWorkArea, bool bConsiderWM = true ) const;
215 * sets window title
217 virtual void setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const;
220 * set NET_WM_PID
222 void setPID( X11SalFrame* pFrame ) const;
225 * set WM_CLIENT_MACHINE
227 void setClientMachine( X11SalFrame* pFrame ) const;
229 void answerPing( X11SalFrame*, XClientMessageEvent* ) const;
232 * maximizes frame
233 * maximization can be toggled in either direction
234 * to get the original position and size
235 * use maximizeFrame( pFrame, false, false )
237 virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
239 * start/stop fullscreen mode on a frame
241 virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
243 * tell whether legacy partial full screen handling is necessary
244 * see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto
245 * modern WM's interpret it the "right" way, namely they make "full screen"
246 * taking twin view or Xinerama into accound and honor the positioning hints
247 * to see which screen actually was meant to use for fullscreen.
249 bool isLegacyPartialFullscreen() const
250 { return m_bLegacyPartialFullscreen; }
252 * set window struts
254 virtual void setFrameStruts( X11SalFrame*pFrame,
255 int left, int right, int top, int bottom,
256 int left_start_y, int left_end_y,
257 int right_start_y, int right_end_y,
258 int top_start_x, int top_end_x,
259 int bottom_start_x, int bottom_end_x ) const;
261 * set _NET_WM_USER_TIME property, if NetWM
263 virtual void setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const;
266 * tells whether fullscreen mode is supported by WM
268 bool supportsFullScreen() const { return m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] != 0; }
271 * shade/unshade frame
273 virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
276 * set hints what decoration is needed;
277 * must be called before showing the frame
279 virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame = NULL ) const;
282 * tells whether there is WM support for splash screens
284 bool supportsSplash() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] != 0; }
287 * tells whteher there is WM support for NET_WM_WINDOW_TYPE_TOOLBAR
289 bool supportsToolbar() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_TOOLBAR ] != 0; }
292 * enables always on top or equivalent if possible
294 virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
297 * tells whether enableAlwaysOnTop actually works with this WM
299 bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks; }
302 * handle WM messages (especially WM state changes)
304 virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
307 * called by SalFrame::Show: time to update state properties
309 virtual void frameIsMapping( X11SalFrame* ) const;
312 * gets a WM atom
314 Atom getAtom( WMAtom eAtom ) const
315 { return m_aWMAtoms[ eAtom ]; }
317 int getPositionWinGravity () const
318 { return m_nWinGravity; }
319 int getInitWinGravity() const
320 { return m_nInitWinGravity; }
323 * expected behaviour is that the WM will not allow transient
324 * windows to get stacked behind the windows they are transient for
326 bool isTransientBehaviourAsExpected() const
327 { return m_bTransientBehaviour; }
330 * changes the transient hint of a window to reference frame
331 * if reference frame is NULL the root window is used instead
333 void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame* pReferenceFrame ) const;
336 } // namespace
338 #endif
340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */