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