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