1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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>
43 class SalI18N_InputContext
;
45 namespace vcl_sal
{ class WMAdaptor
; class NetWMAdaptor
; class GnomeWMAdaptor
; }
48 #define SHOWSTATE_UNKNOWN -1
49 #define SHOWSTATE_MINIMIZED 0
50 #define SHOWSTATE_NORMAL 1
51 #define SHOWSTATE_HIDDEN 2
53 enum class WMWindowType
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
;
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
84 int nCaptured_
; // is captured
86 std::unique_ptr
<X11SalGraphics
> pGraphics_
; // current frame graphics
87 std::unique_ptr
<X11SalGraphics
> pFreeGraphics_
; // first free frame graphics
89 bool mbSendExtKeyModChange
;
90 ModKeyFlags mnExtKeyMod
;
92 int nShowState_
; // show state
93 int nWidth_
; // client width
94 int nHeight_
; // client height
95 tools::Rectangle maRestorePosSize
;
96 SalFrameStyleFlags nStyle_
;
97 SalExtStyle mnExtStyle
;
102 bool bDefaultPosition_
; // client is centered initially
106 bool m_bSetFocusOnMap
;
108 ScreenSaverInhibitor maScreenSaverInhibitor
;
109 tools::Rectangle maPaintRegion
;
111 Timer maAlwaysOnTopRaiseTimer
;
113 // data for WMAdaptor
114 WMWindowType meWindowType
;
115 bool mbMaximizedVert
;
116 bool mbMaximizedHorz
;
127 SystemEnvData maSystemChildData
;
129 std::unique_ptr
<SalI18N_InputContext
> mpInputContext
;
132 std::vector
<XRectangle
> m_vClipRectangles
;
134 bool mPendingSizeEvent
;
136 void GetPosSize( tools::Rectangle
&rPosSize
);
137 void SetSize ( const Size
&rSize
);
139 void SetPosSize( const tools::Rectangle
&rPosSize
);
144 void RestackChildren( ::Window
* pTopLevelWindows
, int nTopLevelWindows
);
145 void RestackChildren();
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
);
156 DECL_LINK( HandleAlwaysOnTopRaise
, Timer
*, void );
158 void createNewWindow( ::Window aParent
, SalX11Screen nXScreen
= SalX11Screen( -1 ) );
159 void updateScreenNumber();
161 void setXEmbedInfo();
162 void askForXEmbedFocus( sal_Int32 i_nTimeCode
);
164 void updateWMClass();
166 X11SalFrame( SalFrame
* pParent
, SalFrameStyleFlags nSalFrameStyle
, SystemParentData
const * pSystemParent
= nullptr );
167 virtual ~X11SalFrame() override
;
169 bool Dispatch( XEvent
*pEvent
);
170 void Init( SalFrameStyleFlags nSalFrameStyle
, SalX11Screen nScreen
,
171 SystemParentData
const * pParentData
, bool bUseGeometry
= false );
173 SalDisplay
* GetDisplay() const
177 Display
*GetXDisplay() const
179 return pDisplay_
->GetDisplay();
181 const SalX11Screen
& GetScreenNumber() const { return m_nXScreen
; }
182 ::Window
GetWindow() const { return mhWindow
; }
183 ::Window
GetShellWindow() const { return mhShellWindow
; }
184 ::Window
GetForeignParent() const { return mhForeignParent
; }
185 ::Window
GetStackingWindow() const { return mhStackingWindow
; }
186 void Close() const { CallCallback( SalEvent::Close
, nullptr ); }
187 SalFrameStyleFlags
GetStyle() const { return nStyle_
; }
189 Cursor
GetCursor() const { return hCursor_
; }
190 bool IsCaptured() const { return nCaptured_
== 1; }
191 #if !defined(__synchronous_extinput__)
192 void HandleExtTextEvent (XClientMessageEvent
const *pEvent
);
194 bool IsOverrideRedirect() const;
195 bool IsChildWindow() const { return bool(nStyle_
& (SalFrameStyleFlags::PLUG
|SalFrameStyleFlags::SYSTEMCHILD
)); }
196 bool IsSysChildWindow() const { return bool(nStyle_
& SalFrameStyleFlags::SYSTEMCHILD
); }
197 bool IsFloatGrabWindow() const;
198 SalI18N_InputContext
* getInputContext() const { return mpInputContext
.get(); }
199 bool hasFocus() const { return mbInputFocus
; }
201 void beginUnicodeSequence();
202 bool appendUnicodeSequence( sal_Unicode
);
203 bool endUnicodeSequence();
205 virtual SalGraphics
* AcquireGraphics() override
;
206 virtual void ReleaseGraphics( SalGraphics
* pGraphics
) override
;
208 // call with true to clear graphics (setting None as drawable)
209 // call with false to setup graphics with window (GetWindow())
210 virtual void updateGraphics( bool bClear
);
212 virtual bool PostEvent(ImplSVEvent
* pData
) override
;
214 virtual void SetTitle( const OUString
& rTitle
) override
;
215 virtual void SetIcon( sal_uInt16 nIcon
) override
;
216 virtual void SetMenu( SalMenu
* pMenu
) override
;
217 virtual void DrawMenuBar() override
;
219 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle
) override
;
220 virtual void Show( bool bVisible
, bool bNoActivate
= false ) override
;
221 virtual void SetMinClientSize( long nWidth
, long nHeight
) override
;
222 virtual void SetMaxClientSize( long nWidth
, long nHeight
) override
;
223 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
) override
;
224 virtual void GetClientSize( long& rWidth
, long& rHeight
) override
;
225 virtual void GetWorkArea( tools::Rectangle
& rRect
) override
;
226 virtual SalFrame
* GetParent() const override
;
227 virtual void SetWindowState( const SalFrameState
* pState
) override
;
228 virtual bool GetWindowState( SalFrameState
* pState
) 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( long nX
, 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
;
246 virtual SalPointerState
GetPointerState() override
;
247 virtual KeyIndicatorState
GetIndicatorState() override
;
248 virtual void SimulateKeyPress( sal_uInt16 nKeyCode
) override
;
249 virtual void SetParent( SalFrame
* pNewParent
) override
;
250 virtual bool SetPluginParent( SystemParentData
* pNewParent
) override
;
252 virtual void SetScreenNumber( unsigned int ) override
;
253 virtual void SetApplicationID( const OUString
&rWMClass
) override
;
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_uIntPtr nRects
) override
;
260 // add a rectangle to the clip region
261 virtual void UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
) override
;
262 // done setting up the clipregion
263 virtual void EndSetClipRegion() override
;
265 virtual sal_uIntPtr
GetNativeWindowHandle() override
;
268 void setPendingSizeEvent();
271 #endif // INCLUDED_VCL_INC_UNX_SALFRAME_H
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */