bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / unx / wmadaptor.hxx
blob7df7ca25cd19eca874a21230e71d697997e04a3c
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>
26 #include <X11/Xlib.h>
28 #include <vclpluginapi.h>
29 #include "salframe.h"
30 #include <vector>
32 class SalDisplay;
33 class X11SalFrame;
35 namespace vcl_sal {
37 class VCLPLUG_GEN_PUBLIC WMAdaptor
39 public:
40 enum WMAtom {
41 // atoms for types
42 UTF8_STRING,
44 // atoms for extended WM hints
45 NET_ACTIVE_WINDOW,
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_CLIENT_LIST,
94 // atoms for general WM hints
95 WM_STATE,
96 MOTIF_WM_HINTS,
97 WM_PROTOCOLS,
98 WM_DELETE_WINDOW,
99 WM_TAKE_FOCUS,
100 WM_CLIENT_LEADER,
101 WM_COMMAND,
102 WM_LOCALE_NAME,
103 WM_TRANSIENT_FOR,
105 // special atoms
106 SAL_QUITEVENT,
107 SAL_USEREVENT,
108 SAL_EXTTEXTEVENT,
109 SAL_GETTIMEEVENT,
110 VCL_SYSTEM_SETTINGS,
111 XSETTINGS,
112 XEMBED,
113 XEMBED_INFO,
114 NetAtomMax
118 * flags for frame decoration
120 static const int decoration_Title = 0x00000001;
121 static const int decoration_Border = 0x00000002;
122 static const int decoration_Resize = 0x00000004;
123 static const int decoration_MinimizeBtn = 0x00000008;
124 static const int decoration_MaximizeBtn = 0x00000010;
125 static const int decoration_CloseBtn = 0x00000020;
126 static const int decoration_All = 0x10000000;
128 protected:
129 SalDisplay* const m_pSalDisplay; // Display to use
130 Display* m_pDisplay; // X Display of SalDisplay
131 OUString m_aWMName;
132 Atom m_aWMAtoms[ NetAtomMax];
133 int m_nDesktops;
134 bool m_bEqualWorkAreas;
135 ::std::vector< tools::Rectangle >
136 m_aWMWorkAreas;
137 bool m_bEnableAlwaysOnTopWorks;
138 bool m_bLegacyPartialFullscreen;
139 int m_nWinGravity;
140 int m_nInitWinGravity;
141 bool m_bWMshouldSwitchWorkspace;
142 bool m_bWMshouldSwitchWorkspaceInit;
144 WMAdaptor( SalDisplay * )
146 void initAtoms();
147 bool getNetWmName();
150 * returns whether this instance is useful
151 * only useful for createWMAdaptor
153 virtual bool isValid() const;
155 bool getWMshouldSwitchWorkspace() const;
156 public:
157 virtual ~WMAdaptor();
160 * creates a valid WMAdaptor instance for the SalDisplay
162 static std::unique_ptr<WMAdaptor> createWMAdaptor( SalDisplay* );
165 * may return an empty string if the window manager could
166 * not be identified.
168 const OUString& getWindowManagerName() const
169 { return m_aWMName; }
172 * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
174 int getCurrentWorkArea() const;
176 * gets the workarea the specified window is on (or -1)
178 int getWindowWorkArea( ::Window aWindow ) const;
180 * gets the specified workarea
182 const tools::Rectangle& getWorkArea( int n ) const
183 { return m_aWMWorkAreas[n]; }
186 * attempt to switch the desktop to a certain workarea (ie. virtual desktops)
188 void switchToWorkArea( int nWorkArea ) const;
191 * sets window title
193 virtual void setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const;
196 * set NET_WM_PID
198 void setPID( X11SalFrame const * pFrame ) const;
201 * set WM_CLIENT_MACHINE
203 void setClientMachine( X11SalFrame const * pFrame ) const;
205 void answerPing( X11SalFrame const *, XClientMessageEvent const * ) const;
208 * maximizes frame
209 * maximization can be toggled in either direction
210 * to get the original position and size
211 * use maximizeFrame( pFrame, false, false )
213 virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
215 * start/stop fullscreen mode on a frame
217 virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
219 * tell whether legacy partial full screen handling is necessary
220 * see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto
221 * modern WM's interpret it the "right" way, namely they make "full screen"
222 * taking twin view or Xinerama into account and honor the positioning hints
223 * to see which screen actually was meant to use for fullscreen.
225 bool isLegacyPartialFullscreen() const
226 { return m_bLegacyPartialFullscreen; }
228 * set _NET_WM_USER_TIME property, if NetWM
230 virtual void setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const;
233 * tells whether fullscreen mode is supported by WM
235 bool supportsFullScreen() const { return m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] != 0; }
238 * shade/unshade frame
240 virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
243 * set hints what decoration is needed;
244 * must be called before showing the frame
246 virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame ) const;
249 * tells whether there is WM support for splash screens
251 bool supportsSplash() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] != 0; }
254 * enables always on top or equivalent if possible
256 virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
259 * tells whether enableAlwaysOnTop actually works with this WM
261 bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks; }
264 * handle WM messages (especially WM state changes)
266 virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
269 * called by SalFrame::Show: time to update state properties
271 virtual void frameIsMapping( X11SalFrame* ) const;
274 * gets a WM atom
276 Atom getAtom( WMAtom eAtom ) const
277 { return m_aWMAtoms[ eAtom ]; }
279 int getPositionWinGravity () const
280 { return m_nWinGravity; }
281 int getInitWinGravity() const
282 { return m_nInitWinGravity; }
285 * changes the transient hint of a window to reference frame
286 * if reference frame is NULL the root window is used instead
288 void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame const * pReferenceFrame ) const;
291 * Requests the change of active window by sending
292 * _NET_ACTIVE_WINDOW message to the frame. The frame
293 * has to be mapped
295 void activateWindow( X11SalFrame const *pFrame, Time nTimestamp );
298 } // namespace
300 #endif
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */