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 : #ifndef _SV_SALFRAME_H
20 : #define _SV_SALFRAME_H
21 :
22 : #include <unx/salstd.hxx>
23 : #include <unx/salunx.h>
24 : #include <unx/saltype.h>
25 :
26 : #include <salframe.hxx>
27 : #include <salwtype.hxx>
28 : #include <salinst.hxx>
29 :
30 : #include <vcl/ptrstyle.hxx>
31 : #include <vcl/sysdata.hxx>
32 : #include <vcl/timer.hxx>
33 : #include <vclpluginapi.h>
34 :
35 : #include <list>
36 :
37 : // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
38 : class SalDisplay;
39 : class X11SalGraphics;
40 : class SalI18N_InputContext;
41 :
42 : namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; }
43 :
44 : // -=-= X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
45 : #define SHOWSTATE_UNKNOWN -1
46 : #define SHOWSTATE_MINIMIZED 0
47 : #define SHOWSTATE_NORMAL 1
48 : #define SHOWSTATE_HIDDEN 2
49 :
50 : class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame
51 : {
52 : friend class vcl_sal::WMAdaptor;
53 : friend class vcl_sal::NetWMAdaptor;
54 : friend class vcl_sal::GnomeWMAdaptor;
55 :
56 : X11SalFrame* mpParent; // pointer to parent frame
57 : // which should never obscur this frame
58 : bool mbTransientForRoot;
59 : std::list< X11SalFrame* > maChildren; // List of child frames
60 :
61 : SalDisplay *pDisplay_;
62 : SalX11Screen m_nXScreen;
63 : XLIB_Window mhWindow;
64 : XLIB_Window mhShellWindow;
65 : XLIB_Window mhForeignParent;
66 : // window to fall back to when no longer in fullscreen mode
67 : XLIB_Window mhStackingWindow;
68 : // window to listen for CirculateNotify events
69 :
70 : Pixmap mhBackgroundPixmap;
71 :
72 : XLIB_Cursor hCursor_;
73 : int nCaptured_; // is captured
74 :
75 : X11SalGraphics *pGraphics_; // current frame graphics
76 : X11SalGraphics *pFreeGraphics_; // first free frame graphics
77 :
78 : XLIB_Time nReleaseTime_; // timestamp of last key release
79 : sal_uInt16 nKeyCode_; // last key code
80 : sal_uInt16 nKeyState_; // last key state
81 : int nCompose_; // compose state
82 : bool mbSendExtKeyModChange;
83 : sal_uInt16 mnExtKeyMod;
84 :
85 : int nShowState_; // show state
86 : int nWidth_; // client width
87 : int nHeight_; // client height
88 : Rectangle maRestorePosSize;
89 : sal_uIntPtr nStyle_;
90 : SalExtStyle mnExtStyle;
91 : sal_Bool bAlwaysOnTop_;
92 : sal_Bool bViewable_;
93 : sal_Bool bMapped_;
94 : sal_Bool mbInShow;
95 : sal_Bool bDefaultPosition_; // client is centered initially
96 : bool m_bXEmbed;
97 : int nVisibility_;
98 : int m_nWorkArea;
99 : bool m_bSetFocusOnMap;
100 :
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 : rtl::OUString m_aTitle;
119 :
120 : rtl::OUString m_sWMClass;
121 :
122 : SystemChildData 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 { return pDisplay_; }
173 : Display* GetXDisplay() const;
174 : XLIB_Window GetDrawable() const;
175 0 : SalX11Screen GetScreenNumber() const { return m_nXScreen; }
176 0 : XLIB_Window GetWindow() const { return mhWindow; }
177 0 : XLIB_Window GetShellWindow() const { return mhShellWindow; }
178 0 : XLIB_Window GetForeignParent() const { return mhForeignParent; }
179 0 : XLIB_Window GetStackingWindow() const { return mhStackingWindow; }
180 : long ShutDown() const { return CallCallback( SALEVENT_SHUTDOWN, 0 ); }
181 0 : long Close() const { return CallCallback( SALEVENT_CLOSE, 0 ); }
182 : sal_uIntPtr GetStyle() const { return nStyle_; }
183 :
184 0 : inline XLIB_Cursor GetCursor() const { return hCursor_; }
185 0 : inline sal_Bool IsCaptured() const { return nCaptured_ == 1; }
186 : #if !defined(__synchronous_extinput__)
187 : void HandleExtTextEvent (XClientMessageEvent *pEvent);
188 : #endif
189 : bool IsOverrideRedirect() const;
190 0 : bool IsChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_PLUG|SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
191 0 : bool IsSysChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
192 : bool IsFloatGrabWindow() const;
193 0 : SalI18N_InputContext* getInputContext() const { return mpInputContext; }
194 : void getPosSize( Rectangle& rRect ) { GetPosSize( rRect ); }
195 : void setPosSize( const Rectangle& rRect ) { SetPosSize( rRect ); }
196 0 : bool isMapped() const { return bMapped_; }
197 0 : bool hasFocus() const { return mbInputFocus; }
198 :
199 : void beginUnicodeSequence();
200 : bool appendUnicodeSequence( sal_Unicode );
201 : bool endUnicodeSequence();
202 :
203 : virtual SalGraphics* GetGraphics();
204 : virtual void ReleaseGraphics( SalGraphics* pGraphics );
205 :
206 : // call with true to clear graphics (setting None as drawable)
207 : // call with false to setup graphics with window (GetWindow())
208 : virtual void updateGraphics( bool bClear );
209 :
210 : virtual sal_Bool PostEvent( void* pData );
211 :
212 : virtual void SetTitle( const rtl::OUString& rTitle );
213 : virtual void SetIcon( sal_uInt16 nIcon );
214 : virtual void SetMenu( SalMenu* pMenu );
215 : virtual void DrawMenuBar();
216 :
217 : virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle );
218 : virtual void Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False );
219 : virtual void Enable( sal_Bool bEnable );
220 : virtual void SetMinClientSize( long nWidth, long nHeight );
221 : virtual void SetMaxClientSize( long nWidth, long nHeight );
222 : virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags );
223 : virtual void GetClientSize( long& rWidth, long& rHeight );
224 : virtual void GetWorkArea( Rectangle& rRect );
225 : virtual SalFrame* GetParent() const;
226 : virtual void SetWindowState( const SalFrameState* pState );
227 : virtual sal_Bool GetWindowState( SalFrameState* pState );
228 : virtual void ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nMonitor );
229 : virtual void StartPresentation( sal_Bool bStart );
230 : virtual void SetAlwaysOnTop( sal_Bool bOnTop );
231 : virtual void ToTop( sal_uInt16 nFlags );
232 : virtual void SetPointer( PointerStyle ePointerStyle );
233 : virtual void CaptureMouse( sal_Bool bMouse );
234 : virtual void SetPointerPos( long nX, long nY );
235 : using SalFrame::Flush;
236 : virtual void Flush();
237 : virtual void Sync();
238 : virtual void SetInputContext( SalInputContext* pContext );
239 : virtual void EndExtTextInput( sal_uInt16 nFlags );
240 : virtual rtl::OUString GetKeyName( sal_uInt16 nKeyCode );
241 : virtual sal_Bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
242 : virtual LanguageType GetInputLanguage();
243 : virtual void UpdateSettings( AllSettings& rSettings );
244 : virtual const SystemEnvData* GetSystemData() const;
245 : virtual SalPointerState GetPointerState();
246 : virtual SalIndicatorState GetIndicatorState();
247 : virtual void SimulateKeyPress( sal_uInt16 nKeyCode );
248 : virtual void SetParent( SalFrame* pNewParent );
249 : virtual bool SetPluginParent( SystemParentData* pNewParent );
250 :
251 : virtual void SetScreenNumber( unsigned int );
252 : virtual void SetApplicationID( const rtl::OUString &rWMClass );
253 :
254 : // shaped system windows
255 : // set clip region to none (-> rectangular windows, normal state)
256 : virtual void ResetClipRegion();
257 : // start setting the clipregion consisting of nRects rectangles
258 : virtual void BeginSetClipRegion( sal_uIntPtr nRects );
259 : // add a rectangle to the clip region
260 : virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
261 : // done setting up the clipregion
262 : virtual void EndSetClipRegion();
263 :
264 : static Bool checkKeyReleaseForRepeat( Display*, XEvent*, XPointer pX11SalFrame );
265 :
266 : /// @internal
267 : void setPendingSizeEvent();
268 : };
269 :
270 : #ifdef _SV_SALDISP_HXX
271 :
272 0 : inline Display *X11SalFrame::GetXDisplay() const
273 0 : { return pDisplay_->GetDisplay(); }
274 :
275 : inline XLIB_Window X11SalFrame::GetDrawable() const
276 : { return GetWindow(); }
277 :
278 : #endif
279 :
280 : #endif // _SV_SALFRAME_H
281 :
282 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|