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