tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vcl / inc / unx / wmadaptor.hxx
blob6d3ee56277c4b184ba1ab3ae9adeca96b20e30cb
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 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <tools/gen.hxx>
25 #include <X11/Xlib.h>
27 #include "salframe.h"
28 #include <vector>
30 class SalDisplay;
31 class X11SalFrame;
33 namespace vcl_sal {
35 class WMAdaptor
37 public:
38 enum WMAtom {
39 // atoms for types
40 UTF8_STRING,
42 // atoms for extended WM hints
43 NET_ACTIVE_WINDOW,
44 NET_SUPPORTED,
45 NET_SUPPORTING_WM_CHECK,
46 NET_WM_NAME,
47 NET_WM_DESKTOP,
48 NET_WM_ICON_NAME,
49 NET_WM_PID,
50 NET_WM_PING,
51 NET_WM_STATE,
52 NET_WM_STATE_MAXIMIZED_HORZ,
53 NET_WM_STATE_MAXIMIZED_VERT,
54 NET_WM_STATE_MODAL,
55 NET_WM_STATE_SKIP_PAGER,
56 NET_WM_STATE_SKIP_TASKBAR,
57 NET_WM_STATE_STAYS_ON_TOP,
58 NET_WM_STATE_STICKY,
59 NET_WM_STATE_FULLSCREEN,
60 NET_WM_STRUT,
61 NET_WM_STRUT_PARTIAL,
62 NET_WM_USER_TIME,
63 NET_WM_WINDOW_TYPE,
64 NET_WM_WINDOW_TYPE_DESKTOP,
65 NET_WM_WINDOW_TYPE_DIALOG,
66 NET_WM_WINDOW_TYPE_DOCK,
67 NET_WM_WINDOW_TYPE_MENU,
68 NET_WM_WINDOW_TYPE_NORMAL,
69 NET_WM_WINDOW_TYPE_TOOLBAR,
70 KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
71 NET_WM_WINDOW_TYPE_SPLASH,
72 NET_WM_WINDOW_TYPE_UTILITY,
73 NET_NUMBER_OF_DESKTOPS,
74 NET_CURRENT_DESKTOP,
75 NET_WORKAREA,
76 NET_WM_ICON,
78 // atoms for Gnome WM hints
79 WIN_SUPPORTING_WM_CHECK,
80 WIN_PROTOCOLS,
81 WIN_WORKSPACE_COUNT,
82 WIN_WORKSPACE,
83 WIN_LAYER,
84 WIN_STATE,
85 WIN_HINTS,
86 WIN_APP_STATE,
87 WIN_EXPANDED_SIZE,
88 WIN_ICONS,
89 WIN_CLIENT_LIST,
91 // atoms for general WM hints
92 WM_STATE,
93 MOTIF_WM_HINTS,
94 WM_PROTOCOLS,
95 WM_DELETE_WINDOW,
96 WM_TAKE_FOCUS,
97 WM_CLIENT_LEADER,
98 WM_COMMAND,
99 WM_LOCALE_NAME,
100 WM_TRANSIENT_FOR,
102 // special atoms
103 SAL_QUITEVENT,
104 SAL_USEREVENT,
105 SAL_EXTTEXTEVENT,
106 SAL_GETTIMEEVENT,
107 VCL_SYSTEM_SETTINGS,
108 XSETTINGS,
109 XEMBED,
110 XEMBED_INFO,
111 NetAtomMax
115 * flags for frame decoration
117 static const int decoration_Title = 0x00000001;
118 static const int decoration_Border = 0x00000002;
119 static const int decoration_Resize = 0x00000004;
120 static const int decoration_MinimizeBtn = 0x00000008;
121 static const int decoration_MaximizeBtn = 0x00000010;
122 static const int decoration_CloseBtn = 0x00000020;
123 static const int decoration_All = 0x10000000;
125 protected:
126 SalDisplay* m_pSalDisplay; // Display to use
127 Display* m_pDisplay; // X Display of SalDisplay
128 OUString m_aWMName;
129 Atom m_aWMAtoms[ NetAtomMax];
130 int m_nDesktops;
131 bool m_bEqualWorkAreas;
132 ::std::vector< AbsoluteScreenPixelRectangle >
133 m_aWMWorkAreas;
134 bool m_bEnableAlwaysOnTopWorks;
135 bool m_bLegacyPartialFullscreen;
136 int m_nWinGravity;
137 int m_nInitWinGravity;
138 bool m_bWMshouldSwitchWorkspace;
139 bool m_bWMshouldSwitchWorkspaceInit;
141 WMAdaptor( SalDisplay * )
143 void initAtoms();
144 bool getNetWmName();
147 * returns whether this instance is useful
148 * only useful for createWMAdaptor
150 virtual bool isValid() const;
152 bool getWMshouldSwitchWorkspace() const;
153 public:
154 virtual ~WMAdaptor();
157 * creates a valid WMAdaptor instance for the SalDisplay
159 static std::unique_ptr<WMAdaptor> createWMAdaptor( SalDisplay* );
162 * may return an empty string if the window manager could
163 * not be identified.
165 const OUString& getWindowManagerName() const
166 { return m_aWMName; }
169 * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
171 int getCurrentWorkArea() const;
173 * gets the workarea the specified window is on (or -1)
175 int getWindowWorkArea( ::Window aWindow ) const;
177 * gets the specified workarea
179 const AbsoluteScreenPixelRectangle& getWorkArea( int n ) const
180 { return m_aWMWorkAreas[n]; }
183 * attempt to switch the desktop to a certain workarea (ie. virtual desktops)
185 void switchToWorkArea( int nWorkArea ) const;
188 * sets window title
190 virtual void setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const;
193 * set NET_WM_PID
195 void setPID( X11SalFrame const * pFrame ) const;
198 * set WM_CLIENT_MACHINE
200 void setClientMachine( X11SalFrame const * pFrame ) const;
202 void answerPing( X11SalFrame const *, XClientMessageEvent const * ) const;
205 * maximizes frame
206 * maximization can be toggled in either direction
207 * to get the original position and size
208 * use maximizeFrame( pFrame, false, false )
210 virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
212 * start/stop fullscreen mode on a frame
214 virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
216 * tell whether legacy partial full screen handling is necessary
217 * see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto
218 * modern WM's interpret it the "right" way, namely they make "full screen"
219 * taking twin view or Xinerama into account and honor the positioning hints
220 * to see which screen actually was meant to use for fullscreen.
222 bool isLegacyPartialFullscreen() const
223 { return m_bLegacyPartialFullscreen; }
225 * set _NET_WM_USER_TIME property, if NetWM
227 virtual void setUserTime( X11SalFrame* i_pFrame, tools::Long i_nUserTime ) const;
230 * tells whether fullscreen mode is supported by WM
232 bool supportsFullScreen() const { return m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] != 0; }
235 * set hints what decoration is needed;
236 * must be called before showing the frame
238 virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame ) const;
241 * tells whether there is WM support for splash screens
243 bool supportsSplash() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] != 0; }
246 * enables always on top or equivalent if possible
248 virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
251 * tells whether enableAlwaysOnTop actually works with this WM
253 bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks; }
256 * handle WM messages (especially WM state changes)
258 virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
261 * called by SalFrame::Show: time to update state properties
263 virtual void frameIsMapping( X11SalFrame* ) const;
266 * gets a WM atom
268 Atom getAtom( WMAtom eAtom ) const
269 { return m_aWMAtoms[ eAtom ]; }
271 int getPositionWinGravity () const
272 { return m_nWinGravity; }
273 int getInitWinGravity() const
274 { return m_nInitWinGravity; }
277 * changes the transient hint of a window to reference frame
278 * if reference frame is NULL the root window is used instead
280 void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame const * pReferenceFrame ) const;
283 * Requests the change of active window by sending
284 * _NET_ACTIVE_WINDOW message to the frame. The frame
285 * has to be mapped
287 void activateWindow( X11SalFrame const *pFrame, Time nTimestamp );
290 } // namespace
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */