Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / vcl / inc / unx / salframe.h
blobf5773c0e8fa8afff64e8a505cfaa814bb40e48a2
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 class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame, public NativeWindowHandleProvider
55 friend class vcl_sal::WMAdaptor;
56 friend class vcl_sal::NetWMAdaptor;
57 friend class vcl_sal::GnomeWMAdaptor;
59 X11SalFrame* mpParent; // pointer to parent frame
60 // which should never obscure this frame
61 bool mbTransientForRoot;
62 std::list< X11SalFrame* > maChildren; // List of child frames
64 SalDisplay *pDisplay_;
65 SalX11Screen m_nXScreen;
66 ::Window mhWindow;
67 ::Window mhShellWindow;
68 ::Window mhForeignParent;
69 // window to fall back to when no longer in fullscreen mode
70 ::Window mhStackingWindow;
71 // window to listen for CirculateNotify events
73 Pixmap mhBackgroundPixmap;
75 Cursor hCursor_;
76 int nCaptured_; // is captured
78 X11SalGraphics *pGraphics_; // current frame graphics
79 X11SalGraphics *pFreeGraphics_; // first free frame graphics
81 sal_uInt16 nKeyCode_; // last key code
82 sal_uInt16 nKeyState_; // last key state
83 int nCompose_; // compose state
84 bool mbSendExtKeyModChange;
85 sal_uInt16 mnExtKeyMod;
87 int nShowState_; // show state
88 int nWidth_; // client width
89 int nHeight_; // client height
90 Rectangle maRestorePosSize;
91 SalFrameStyleFlags nStyle_;
92 SalExtStyle mnExtStyle;
93 bool bAlwaysOnTop_;
94 bool bViewable_;
95 bool bMapped_;
96 bool mbInShow;
97 bool bDefaultPosition_; // client is centered initially
98 bool m_bXEmbed;
99 int nVisibility_;
100 int m_nWorkArea;
101 bool m_bSetFocusOnMap;
103 ScreenSaverInhibitor maScreenSaverInhibitor;
104 Rectangle maPaintRegion;
106 Timer maAlwaysOnTopRaiseTimer;
108 // data for WMAdaptor
109 int meWindowType;
110 int mnDecorationFlags;
111 bool mbMaximizedVert;
112 bool mbMaximizedHorz;
113 bool mbShaded;
114 bool mbFullScreen;
116 // icon id
117 int mnIconID;
119 OUString m_aTitle;
121 OUString m_sWMClass;
123 SystemEnvData maSystemChildData;
125 SalI18N_InputContext *mpInputContext;
126 Bool mbInputFocus;
128 XRectangle* m_pClipRectangles;
129 int m_nCurClipRect;
130 int m_nMaxClipRect;
132 bool mPendingSizeEvent;
134 void GetPosSize( Rectangle &rPosSize );
135 void SetSize ( const Size &rSize );
136 void Center();
137 void SetPosSize( const Rectangle &rPosSize );
138 void Minimize();
139 void Maximize();
140 void Restore();
142 void RestackChildren( ::Window* pTopLevelWindows, int nTopLevelWindows );
143 void RestackChildren();
145 long HandleKeyEvent ( XKeyEvent *pEvent );
146 long HandleMouseEvent ( XEvent *pEvent );
147 long HandleFocusEvent ( XFocusChangeEvent *pEvent );
148 long HandleExposeEvent ( XEvent *pEvent );
149 long HandleSizeEvent ( XConfigureEvent *pEvent );
150 long HandleStateEvent ( XPropertyEvent *pEvent );
151 long HandleReparentEvent ( XReparentEvent *pEvent );
152 long HandleClientMessage ( XClientMessageEvent*pEvent );
154 DECL_LINK_TYPED( HandleAlwaysOnTopRaise, Timer*, void );
156 void createNewWindow( ::Window aParent, SalX11Screen nXScreen = SalX11Screen( -1 ) );
157 void updateScreenNumber();
159 void setXEmbedInfo();
160 void askForXEmbedFocus( sal_Int32 i_nTimeCode );
162 void updateWMClass();
163 public:
164 X11SalFrame( SalFrame* pParent, SalFrameStyleFlags nSalFrameStyle, SystemParentData* pSystemParent = NULL );
165 virtual ~X11SalFrame();
167 long Dispatch( XEvent *pEvent );
168 void Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nScreen = SalX11Screen( -1 ),
169 SystemParentData* pParentData = NULL, bool bUseGeometry = false );
171 SalDisplay* GetDisplay() const
173 return pDisplay_;
175 Display *GetXDisplay() const
177 return pDisplay_->GetDisplay();
179 const SalX11Screen& GetScreenNumber() const { return m_nXScreen; }
180 ::Window GetWindow() const { return mhWindow; }
181 ::Window GetShellWindow() const { return mhShellWindow; }
182 ::Window GetForeignParent() const { return mhForeignParent; }
183 ::Window GetStackingWindow() const { return mhStackingWindow; }
184 void Close() const { CallCallback( SalEvent::Close, NULL ); }
185 SalFrameStyleFlags GetStyle() const { return nStyle_; }
187 Cursor GetCursor() const { return hCursor_; }
188 bool IsCaptured() const { return nCaptured_ == 1; }
189 #if !defined(__synchronous_extinput__)
190 void HandleExtTextEvent (XClientMessageEvent *pEvent);
191 #endif
192 bool IsOverrideRedirect() const;
193 bool IsChildWindow() const { return bool(nStyle_ & (SalFrameStyleFlags::PLUG|SalFrameStyleFlags::SYSTEMCHILD)); }
194 bool IsSysChildWindow() const { return bool(nStyle_ & (SalFrameStyleFlags::SYSTEMCHILD)); }
195 bool IsFloatGrabWindow() const;
196 SalI18N_InputContext* getInputContext() const { return mpInputContext; }
197 bool isMapped() const { return bMapped_; }
198 bool hasFocus() const { return mbInputFocus; }
200 void beginUnicodeSequence();
201 bool appendUnicodeSequence( sal_Unicode );
202 bool endUnicodeSequence();
204 virtual SalGraphics* AcquireGraphics() override;
205 virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
207 // call with true to clear graphics (setting None as drawable)
208 // call with false to setup graphics with window (GetWindow())
209 virtual void updateGraphics( bool bClear );
211 virtual bool PostEvent(ImplSVEvent* pData) override;
213 virtual void SetTitle( const OUString& rTitle ) override;
214 virtual void SetIcon( sal_uInt16 nIcon ) override;
215 virtual void SetMenu( SalMenu* pMenu ) override;
216 virtual void DrawMenuBar() override;
218 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
219 virtual void Show( bool bVisible, bool bNoActivate = false ) override;
220 virtual void SetMinClientSize( long nWidth, long nHeight ) override;
221 virtual void SetMaxClientSize( long nWidth, long nHeight ) override;
222 virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override;
223 virtual void GetClientSize( long& rWidth, long& rHeight ) override;
224 virtual void GetWorkArea( Rectangle& rRect ) override;
225 virtual SalFrame* GetParent() const override;
226 virtual void SetWindowState( const SalFrameState* pState ) override;
227 virtual bool GetWindowState( SalFrameState* pState ) override;
228 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nMonitor ) override;
229 virtual void StartPresentation( bool bStart ) override;
230 virtual void SetAlwaysOnTop( bool bOnTop ) override;
231 virtual void ToTop( SalFrameToTop nFlags ) override;
232 virtual void SetPointer( PointerStyle ePointerStyle ) override;
233 virtual void CaptureMouse( bool bMouse ) override;
234 virtual void SetPointerPos( long nX, long nY ) override;
235 using SalFrame::Flush;
236 virtual void Flush() override;
237 virtual void SetInputContext( SalInputContext* pContext ) override;
238 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
239 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
240 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
241 virtual LanguageType GetInputLanguage() override;
242 virtual void UpdateSettings( AllSettings& rSettings ) override;
243 virtual void Beep() override;
244 virtual const SystemEnvData* GetSystemData() const override;
245 virtual SalPointerState GetPointerState() override;
246 virtual KeyIndicatorState GetIndicatorState() override;
247 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
248 virtual void SetParent( SalFrame* pNewParent ) override;
249 virtual bool SetPluginParent( SystemParentData* pNewParent ) override;
251 virtual void SetScreenNumber( unsigned int ) override;
252 virtual void SetApplicationID( const OUString &rWMClass ) override;
254 // shaped system windows
255 // set clip region to none (-> rectangular windows, normal state)
256 virtual void ResetClipRegion() override;
257 // start setting the clipregion consisting of nRects rectangles
258 virtual void BeginSetClipRegion( sal_uIntPtr nRects ) override;
259 // add a rectangle to the clip region
260 virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override;
261 // done setting up the clipregion
262 virtual void EndSetClipRegion() override;
264 virtual sal_uIntPtr GetNativeWindowHandle() override;
266 /// @internal
267 void setPendingSizeEvent();
270 #endif // INCLUDED_VCL_INC_UNX_SALFRAME_H
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */