LibreOffice Module vcl (master) 1
unx/salframe.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_UNX_SALFRAME_H
21#define INCLUDED_VCL_INC_UNX_SALFRAME_H
22
23#include <X11/Xlib.h>
24
25#include <unx/saltype.h>
26#include <unx/saldisp.hxx>
28#include <salframe.hxx>
29#include <salwtype.hxx>
30#include <salinst.hxx>
31
32#include <vcl/ptrstyle.hxx>
33#include <vcl/sysdata.hxx>
34#include <vcl/timer.hxx>
35#include <vclpluginapi.h>
36
37#include <list>
38
39class X11SalGraphics;
41
42namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; }
43
44// X11SalFrame
45enum class X11ShowState
46{
47 Unknown = -1,
48 Minimized = 0,
49 Normal = 1,
50 Hidden = 2
51};
52
53enum class WMWindowType
54{
55 Normal,
57 Utility,
58 Splash,
59 Toolbar,
60 Dock
61};
62
63class X11SalFrame final : public SalFrame
64{
65 friend class vcl_sal::WMAdaptor;
68
69 X11SalFrame* mpParent; // pointer to parent frame
70 // which should never obscure this frame
72 std::list< X11SalFrame* > maChildren; // List of child frames
73
76 ::Window mhWindow;
78 ::Window mhShellWindow;
80 // window to fall back to when no longer in fullscreen mode
82 // window to listen for CirculateNotify events
83
85 int nCaptured_; // is captured
86
87 std::unique_ptr<X11SalGraphics> pGraphics_; // current frame graphics
88 std::unique_ptr<X11SalGraphics> pFreeGraphics_; // first free frame graphics
89
92
94 int nWidth_; // client width
95 int nHeight_; // client height
102 bool bDefaultPosition_; // client is centered initially
107
110
112
113 // data for WMAdaptor
119
120 // icon id
122
123 OUString m_aTitle;
124
125 OUString m_sWMClass;
126
128
129 std::unique_ptr<SalI18N_InputContext> mpInputContext;
131
132 std::vector<XRectangle> m_vClipRectangles;
133
135
136 void GetPosSize( tools::Rectangle &rPosSize );
137 void SetSize ( const Size &rSize );
138 void Center();
139 void SetPosSize( const tools::Rectangle &rPosSize );
140 void Minimize();
141 void Maximize();
142 void Restore();
143
144 void RestackChildren( ::Window* pTopLevelWindows, int nTopLevelWindows );
146
147 bool HandleKeyEvent ( XKeyEvent *pEvent );
148 bool HandleMouseEvent ( XEvent *pEvent );
149 bool HandleFocusEvent ( XFocusChangeEvent const *pEvent );
150 bool HandleExposeEvent ( XEvent const *pEvent );
151 bool HandleSizeEvent ( XConfigureEvent *pEvent );
152 bool HandleStateEvent ( XPropertyEvent const *pEvent );
153 bool HandleReparentEvent ( XReparentEvent *pEvent );
154 bool HandleClientMessage ( XClientMessageEvent*pEvent );
155
156 DECL_LINK( HandleAlwaysOnTopRaise, Timer*, void );
157
158 void createNewWindow( ::Window aParent, SalX11Screen nXScreen = SalX11Screen( -1 ) );
160
162 void askForXEmbedFocus( sal_Int32 i_nTimeCode );
163
165public:
166 X11SalFrame( SalFrame* pParent, SalFrameStyleFlags nSalFrameStyle, SystemParentData const * pSystemParent = nullptr );
167 virtual ~X11SalFrame() override;
168
169 bool Dispatch( XEvent *pEvent );
170 void Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nScreen,
171 SystemParentData const * pParentData, bool bUseGeometry = false );
172
174 {
175 return pDisplay_;
176 }
178 {
179 return pDisplay_->GetDisplay();
180 }
181 const SalX11Screen& GetScreenNumber() const { return m_nXScreen; }
182 ::Window GetWindow() const { return mhWindow; }
184 ::Window GetShellWindow() const { return mhShellWindow; }
185 ::Window GetForeignParent() const { return mhForeignParent; }
186 ::Window GetStackingWindow() const { return mhStackingWindow; }
187 void Close() const { CallCallback( SalEvent::Close, nullptr ); }
189
190 Cursor GetCursor() const { return hCursor_; }
191 bool IsCaptured() const { return nCaptured_ == 1; }
192#if !defined(__synchronous_extinput__)
193 void HandleExtTextEvent (XClientMessageEvent const *pEvent);
194#endif
195 bool IsOverrideRedirect() const;
198 bool IsFloatGrabWindow() const;
200 bool hasFocus() const { return mbInputFocus; }
201
205
206 virtual SalGraphics* AcquireGraphics() override;
207 virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
208
209 // call with true to clear graphics (setting None as drawable)
210 // call with false to setup graphics with window (GetWindow())
211 virtual void updateGraphics( bool bClear );
212
213 virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
214
215 virtual void SetTitle( const OUString& rTitle ) override;
216 virtual void SetIcon( sal_uInt16 nIcon ) override;
217 virtual void SetMenu( SalMenu* pMenu ) override;
218
219 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
220 virtual void Show( bool bVisible, bool bNoActivate = false ) override;
221 virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
222 virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
223 virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
224 virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
225 virtual void GetWorkArea( tools::Rectangle& rRect ) override;
226 virtual SalFrame* GetParent() const override;
227 virtual void SetWindowState(const vcl::WindowData*) override;
228 virtual bool GetWindowState(vcl::WindowData*) override;
229 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nMonitor ) override;
230 virtual void StartPresentation( bool bStart ) override;
231 virtual void SetAlwaysOnTop( bool bOnTop ) override;
232 virtual void ToTop( SalFrameToTop nFlags ) override;
233 virtual void SetPointer( PointerStyle ePointerStyle ) override;
234 virtual void CaptureMouse( bool bMouse ) override;
235 virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
236 using SalFrame::Flush;
237 virtual void Flush() override;
238 virtual void SetInputContext( SalInputContext* pContext ) override;
239 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
240 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
241 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
242 virtual LanguageType GetInputLanguage() override;
243 virtual void UpdateSettings( AllSettings& rSettings ) override;
244 virtual void Beep() override;
245 virtual const SystemEnvData* GetSystemData() const override;
248 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
249 virtual void SetParent( SalFrame* pNewParent ) override;
250 virtual void SetPluginParent( SystemParentData* pNewParent ) override;
251
252 virtual void SetScreenNumber( unsigned int ) override;
253 virtual void SetApplicationID( const OUString &rWMClass ) override;
254
255 // shaped system windows
256 // set clip region to none (-> rectangular windows, normal state)
257 virtual void ResetClipRegion() override;
258 // start setting the clipregion consisting of nRects rectangles
259 virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
260 // add a rectangle to the clip region
261 virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
262 // done setting up the clipregion
263 virtual void EndSetClipRegion() override;
264
267};
268
269#endif // INCLUDED_VCL_INC_UNX_SALFRAME_H
270
271/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _cairo_surface cairo_surface_t
Definition: CairoCommon.hxx:46
Display * GetDisplay() const
Definition: saldisp.hxx:326
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
virtual void Flush()=0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: salframe.hxx:309
Definition: timer.hxx:27
std::unique_ptr< X11SalGraphics > pFreeGraphics_
Definition: unx/salframe.h:88
WMWindowType meWindowType
Definition: unx/salframe.h:114
virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override
OUString m_aTitle
Definition: unx/salframe.h:123
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override
virtual void StartPresentation(bool bStart) override
::Window GetForeignParent() const
Definition: unx/salframe.h:185
void Init(SalFrameStyleFlags nSalFrameStyle, SalX11Screen nScreen, SystemParentData const *pParentData, bool bUseGeometry=false)
Display * GetXDisplay() const
Definition: unx/salframe.h:177
void RestackChildren(::Window *pTopLevelWindows, int nTopLevelWindows)
ModKeyFlags mnExtKeyMod
Definition: unx/salframe.h:91
virtual void EndSetClipRegion() override
std::vector< XRectangle > m_vClipRectangles
Definition: unx/salframe.h:132
virtual void updateGraphics(bool bClear)
virtual void ResetClipRegion() override
virtual void ToTop(SalFrameToTop nFlags) override
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override
::Window mhWindow
Definition: unx/salframe.h:76
bool HandleSizeEvent(XConfigureEvent *pEvent)
bool HandleReparentEvent(XReparentEvent *pEvent)
X11SalFrame * mpParent
Definition: unx/salframe.h:69
cairo_surface_t * mpSurface
Definition: unx/salframe.h:77
virtual void SetPointer(PointerStyle ePointerStyle) override
X11SalFrame(SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle, SystemParentData const *pSystemParent=nullptr)
virtual const SystemEnvData * GetSystemData() const override
DECL_LINK(HandleAlwaysOnTopRaise, Timer *, void)
bool IsSysChildWindow() const
Definition: unx/salframe.h:197
virtual void SetPointerPos(tools::Long nX, tools::Long nY) override
void updateWMClass()
std::list< X11SalFrame * > maChildren
Definition: unx/salframe.h:72
SalExtStyle mnExtStyle
Definition: unx/salframe.h:98
void updateScreenNumber()
void Maximize()
tools::Rectangle maRestorePosSize
Definition: unx/salframe.h:96
::Window GetStackingWindow() const
Definition: unx/salframe.h:186
bool HandleStateEvent(XPropertyEvent const *pEvent)
virtual void CaptureMouse(bool bMouse) override
bool mbTransientForRoot
Definition: unx/salframe.h:71
virtual void SetTitle(const OUString &rTitle) override
bool appendUnicodeSequence(sal_Unicode)
bool bDefaultPosition_
Definition: unx/salframe.h:102
::Window mhStackingWindow
Definition: unx/salframe.h:81
bool HandleFocusEvent(XFocusChangeEvent const *pEvent)
void beginUnicodeSequence()
SalX11Screen m_nXScreen
Definition: unx/salframe.h:75
bool mbSendExtKeyModChange
Definition: unx/salframe.h:90
virtual void SetParent(SalFrame *pNewParent) override
bool HandleMouseEvent(XEvent *pEvent)
virtual void SetAlwaysOnTop(bool bOnTop) override
Cursor hCursor_
Definition: unx/salframe.h:84
SystemEnvData maSystemChildData
Definition: unx/salframe.h:127
void Restore()
bool m_bIsPartialFullScreen
Definition: unx/salframe.h:118
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight) override
::Window mhForeignParent
Definition: unx/salframe.h:79
SalDisplay * GetDisplay() const
Definition: unx/salframe.h:173
bool Dispatch(XEvent *pEvent)
bool IsFloatGrabWindow() const
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode) override
bool HandleKeyEvent(XKeyEvent *pEvent)
::Window GetShellWindow() const
Definition: unx/salframe.h:184
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags) override
bool bAlwaysOnTop_
Definition: unx/salframe.h:99
Cursor GetCursor() const
Definition: unx/salframe.h:190
void setXEmbedInfo()
bool HandleExposeEvent(XEvent const *pEvent)
virtual SalPointerState GetPointerState() override
SalI18N_InputContext * getInputContext() const
Definition: unx/salframe.h:199
bool mbMaximizedVert
Definition: unx/salframe.h:115
void Center()
void SetSize(const Size &rSize)
virtual void SetPluginParent(SystemParentData *pNewParent) override
std::unique_ptr< X11SalGraphics > pGraphics_
Definition: unx/salframe.h:87
OUString m_sWMClass
Definition: unx/salframe.h:125
virtual ~X11SalFrame() override
void askForXEmbedFocus(sal_Int32 i_nTimeCode)
virtual void SetMenu(SalMenu *pMenu) override
virtual void UpdateSettings(AllSettings &rSettings) override
virtual SalGraphics * AcquireGraphics() override
::Window GetWindow() const
Definition: unx/salframe.h:182
Timer maAlwaysOnTopRaiseTimer
Definition: unx/salframe.h:111
SalFrameStyleFlags nStyle_
Definition: unx/salframe.h:97
bool IsCaptured() const
Definition: unx/salframe.h:191
friend class vcl_sal::GnomeWMAdaptor
Definition: unx/salframe.h:67
::Window mhShellWindow
Definition: unx/salframe.h:78
virtual KeyIndicatorState GetIndicatorState() override
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nMonitor) override
bool mbFullScreen
Definition: unx/salframe.h:117
SalFrameStyleFlags GetStyle() const
Definition: unx/salframe.h:188
void GetPosSize(tools::Rectangle &rPosSize)
void Minimize()
virtual void SetApplicationID(const OUString &rWMClass) override
cairo_surface_t * GetSurface() const
Definition: unx/salframe.h:183
tools::Rectangle maPaintRegion
Definition: unx/salframe.h:109
virtual void ReleaseGraphics(SalGraphics *pGraphics) override
void setPendingSizeEvent()
virtual void SetIcon(sal_uInt16 nIcon) override
void createNewWindow(::Window aParent, SalX11Screen nXScreen=SalX11Screen(-1))
bool hasFocus() const
Definition: unx/salframe.h:200
void Close() const
Definition: unx/salframe.h:187
bool HandleClientMessage(XClientMessageEvent *pEvent)
bool endUnicodeSequence()
void RestackChildren()
virtual void Beep() override
bool IsChildWindow() const
Definition: unx/salframe.h:196
X11ShowState nShowState_
Definition: unx/salframe.h:93
void SetPosSize(const tools::Rectangle &rPosSize)
Bool mbInputFocus
Definition: unx/salframe.h:130
virtual void SetInputContext(SalInputContext *pContext) override
bool IsOverrideRedirect() const
friend class vcl_sal::NetWMAdaptor
Definition: unx/salframe.h:66
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
virtual void Flush() override
virtual LanguageType GetInputLanguage() override
virtual void GetWorkArea(tools::Rectangle &rRect) override
virtual void SetWindowState(const vcl::WindowData *) override
const SalX11Screen & GetScreenNumber() const
Definition: unx/salframe.h:181
std::unique_ptr< SalI18N_InputContext > mpInputContext
Definition: unx/salframe.h:129
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override
virtual void SetScreenNumber(unsigned int) override
SalDisplay * pDisplay_
Definition: unx/salframe.h:74
virtual bool GetWindowState(vcl::WindowData *) override
virtual SalFrame * GetParent() const override
virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override
SessionManagerInhibitor maSessionManagerInhibitor
Definition: unx/salframe.h:108
virtual OUString GetKeyName(sal_uInt16 nKeyCode) override
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
bool m_bSetFocusOnMap
Definition: unx/salframe.h:106
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData) override
bool mbMaximizedHorz
Definition: unx/salframe.h:116
virtual void Show(bool bVisible, bool bNoActivate=false) override
void HandleExtTextEvent(XClientMessageEvent const *pEvent)
bool mPendingSizeEvent
Definition: unx/salframe.h:134
KeyIndicatorState
Definition: keycodes.hxx:187
ModKeyFlags
Definition: keycodes.hxx:166
Unknown
Display
long Long
PointerStyle
Definition: ptrstyle.hxx:26
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
SalFrameToTop
Definition: salframe.hxx:43
SalFrameStyleFlags
Definition: salframe.hxx:65
sal_uInt16 sal_Unicode
X11ShowState
Definition: unx/salframe.h:46
WMWindowType
Definition: unx/salframe.h:54
EndExtTextInputFlags
Definition: window.hxx:346