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