Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SV_SALFRAME_H
29 : : #define _SV_SALFRAME_H
30 : :
31 : : #include <unx/salstd.hxx>
32 : : #include <unx/salunx.h>
33 : : #include <unx/saltype.h>
34 : :
35 : : #include <salframe.hxx>
36 : : #include <salwtype.hxx>
37 : : #include <salinst.hxx>
38 : :
39 : : #include <vcl/ptrstyle.hxx>
40 : : #include <vcl/sysdata.hxx>
41 : : #include <vcl/timer.hxx>
42 : : #include <vclpluginapi.h>
43 : :
44 : : #include <list>
45 : :
46 : : // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
47 : : class SalDisplay;
48 : : class X11SalGraphics;
49 : : class SalI18N_InputContext;
50 : :
51 : : namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; }
52 : :
53 : : // -=-= X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
54 : : #define SHOWSTATE_UNKNOWN -1
55 : : #define SHOWSTATE_MINIMIZED 0
56 : : #define SHOWSTATE_NORMAL 1
57 : : #define SHOWSTATE_HIDDEN 2
58 : :
59 : : class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame
60 : : {
61 : : friend class vcl_sal::WMAdaptor;
62 : : friend class vcl_sal::NetWMAdaptor;
63 : : friend class vcl_sal::GnomeWMAdaptor;
64 : :
65 : : X11SalFrame* mpParent; // pointer to parent frame
66 : : // which should never obscur this frame
67 : : bool mbTransientForRoot;
68 : : std::list< X11SalFrame* > maChildren; // List of child frames
69 : :
70 : : SalDisplay *pDisplay_;
71 : : SalX11Screen m_nXScreen;
72 : : XLIB_Window mhWindow;
73 : : XLIB_Window mhShellWindow;
74 : : XLIB_Window mhForeignParent;
75 : : // window to fall back to when no longer in fullscreen mode
76 : : XLIB_Window mhStackingWindow;
77 : : // window to listen for CirculateNotify events
78 : :
79 : : Pixmap mhBackgroundPixmap;
80 : :
81 : : XLIB_Cursor hCursor_;
82 : : int nCaptured_; // is captured
83 : :
84 : : X11SalGraphics *pGraphics_; // current frame graphics
85 : : X11SalGraphics *pFreeGraphics_; // first free frame graphics
86 : :
87 : : XLIB_Time nReleaseTime_; // timestamp of last key release
88 : : sal_uInt16 nKeyCode_; // last key code
89 : : sal_uInt16 nKeyState_; // last key state
90 : : int nCompose_; // compose state
91 : : bool mbSendExtKeyModChange;
92 : : sal_uInt16 mnExtKeyMod;
93 : :
94 : : int nShowState_; // show state
95 : : int nWidth_; // client width
96 : : int nHeight_; // client height
97 : : Rectangle maRestorePosSize;
98 : : sal_uIntPtr nStyle_;
99 : : SalExtStyle mnExtStyle;
100 : : sal_Bool bAlwaysOnTop_;
101 : : sal_Bool bViewable_;
102 : : sal_Bool bMapped_;
103 : : sal_Bool mbInShow;
104 : : sal_Bool bDefaultPosition_; // client is centered initially
105 : : bool m_bXEmbed;
106 : : int nVisibility_;
107 : : int m_nWorkArea;
108 : : bool m_bSetFocusOnMap;
109 : :
110 : :
111 : : int nScreenSaversTimeout_;
112 : : Rectangle maPaintRegion;
113 : :
114 : : Timer maAlwaysOnTopRaiseTimer;
115 : :
116 : : // data for WMAdaptor
117 : : int meWindowType;
118 : : int mnDecorationFlags;
119 : : bool mbMaximizedVert;
120 : : bool mbMaximizedHorz;
121 : : bool mbShaded;
122 : : bool mbFullScreen;
123 : :
124 : : // icon id
125 : : int mnIconID;
126 : :
127 : : rtl::OUString m_aTitle;
128 : :
129 : : rtl::OUString m_sWMClass;
130 : :
131 : : SystemChildData maSystemChildData;
132 : :
133 : : SalI18N_InputContext *mpInputContext;
134 : : Bool mbInputFocus;
135 : :
136 : : XRectangle* m_pClipRectangles;
137 : : int m_nCurClipRect;
138 : : int m_nMaxClipRect;
139 : :
140 : : bool mPendingSizeEvent;
141 : :
142 : : void GetPosSize( Rectangle &rPosSize );
143 : : void SetSize ( const Size &rSize );
144 : : void Center();
145 : : void SetPosSize( const Rectangle &rPosSize );
146 : : void Minimize();
147 : : void Maximize();
148 : : void Restore();
149 : :
150 : : void RestackChildren( XLIB_Window* pTopLevelWindows, int nTopLevelWindows );
151 : : void RestackChildren();
152 : :
153 : : long HandleKeyEvent ( XKeyEvent *pEvent );
154 : : long HandleMouseEvent ( XEvent *pEvent );
155 : : long HandleFocusEvent ( XFocusChangeEvent *pEvent );
156 : : long HandleExposeEvent ( XEvent *pEvent );
157 : : long HandleSizeEvent ( XConfigureEvent *pEvent );
158 : : long HandleColormapEvent ( XColormapEvent *pEvent );
159 : : long HandleMapUnmapEvent ( XEvent *pEvent );
160 : : long HandleStateEvent ( XPropertyEvent *pEvent );
161 : : long HandleReparentEvent ( XReparentEvent *pEvent );
162 : : long HandleClientMessage ( XClientMessageEvent*pEvent );
163 : :
164 : : DECL_LINK( HandleAlwaysOnTopRaise, void* );
165 : :
166 : : void createNewWindow( XLIB_Window aParent, SalX11Screen nXScreen = SalX11Screen( -1 ) );
167 : : void updateScreenNumber();
168 : :
169 : : void setXEmbedInfo();
170 : : void askForXEmbedFocus( sal_Int32 i_nTimeCode );
171 : :
172 : : void updateWMClass();
173 : : public:
174 : : X11SalFrame( SalFrame* pParent, sal_uIntPtr nSalFrameStyle, SystemParentData* pSystemParent = NULL );
175 : : virtual ~X11SalFrame();
176 : :
177 : : long Dispatch( XEvent *pEvent );
178 : : void Init( sal_uIntPtr nSalFrameStyle, SalX11Screen nScreen = SalX11Screen( -1 ),
179 : : SystemParentData* pParentData = NULL, bool bUseGeometry = false );
180 : :
181 : 0 : SalDisplay* GetDisplay() const { return pDisplay_; }
182 : : Display* GetXDisplay() const;
183 : : XLIB_Window GetDrawable() const;
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 : inline XLIB_Cursor GetCursor() const { return hCursor_; }
194 : 0 : inline sal_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* GetGraphics();
213 : : virtual void ReleaseGraphics( SalGraphics* pGraphics );
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 sal_Bool PostEvent( void* pData );
220 : :
221 : : virtual void SetTitle( const rtl::OUString& rTitle );
222 : : virtual void SetIcon( sal_uInt16 nIcon );
223 : : virtual void SetMenu( SalMenu* pMenu );
224 : : virtual void DrawMenuBar();
225 : :
226 : : virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle );
227 : : virtual void Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False );
228 : : virtual void Enable( sal_Bool bEnable );
229 : : virtual void SetMinClientSize( long nWidth, long nHeight );
230 : : virtual void SetMaxClientSize( long nWidth, long nHeight );
231 : : virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags );
232 : : virtual void GetClientSize( long& rWidth, long& rHeight );
233 : : virtual void GetWorkArea( Rectangle& rRect );
234 : : virtual SalFrame* GetParent() const;
235 : : virtual void SetWindowState( const SalFrameState* pState );
236 : : virtual sal_Bool GetWindowState( SalFrameState* pState );
237 : : virtual void ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nMonitor );
238 : : virtual void StartPresentation( sal_Bool bStart );
239 : : virtual void SetAlwaysOnTop( sal_Bool bOnTop );
240 : : virtual void ToTop( sal_uInt16 nFlags );
241 : : virtual void SetPointer( PointerStyle ePointerStyle );
242 : : virtual void CaptureMouse( sal_Bool bMouse );
243 : : virtual void SetPointerPos( long nX, long nY );
244 : : using SalFrame::Flush;
245 : : virtual void Flush();
246 : : virtual void Sync();
247 : : virtual void SetInputContext( SalInputContext* pContext );
248 : : virtual void EndExtTextInput( sal_uInt16 nFlags );
249 : : virtual rtl::OUString GetKeyName( sal_uInt16 nKeyCode );
250 : : virtual sal_Bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
251 : : virtual LanguageType GetInputLanguage();
252 : : virtual void UpdateSettings( AllSettings& rSettings );
253 : : virtual const SystemEnvData* GetSystemData() const;
254 : : virtual SalPointerState GetPointerState();
255 : : virtual SalIndicatorState GetIndicatorState();
256 : : virtual void SimulateKeyPress( sal_uInt16 nKeyCode );
257 : : virtual void SetParent( SalFrame* pNewParent );
258 : : virtual bool SetPluginParent( SystemParentData* pNewParent );
259 : : virtual void SetBackgroundBitmap( SalBitmap* pBitmap );
260 : :
261 : : virtual void SetScreenNumber( unsigned int );
262 : : virtual void SetApplicationID( const rtl::OUString &rWMClass );
263 : :
264 : : // shaped system windows
265 : : // set clip region to none (-> rectangular windows, normal state)
266 : : virtual void ResetClipRegion();
267 : : // start setting the clipregion consisting of nRects rectangles
268 : : virtual void BeginSetClipRegion( sal_uIntPtr nRects );
269 : : // add a rectangle to the clip region
270 : : virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
271 : : // done setting up the clipregion
272 : : virtual void EndSetClipRegion();
273 : :
274 : : static Bool checkKeyReleaseForRepeat( Display*, XEvent*, XPointer pX11SalFrame );
275 : :
276 : : /// @internal
277 : : void setPendingSizeEvent();
278 : : };
279 : :
280 : : #ifdef _SV_SALDISP_HXX
281 : :
282 : 0 : inline Display *X11SalFrame::GetXDisplay() const
283 : 0 : { return pDisplay_->GetDisplay(); }
284 : :
285 : : inline XLIB_Window X11SalFrame::GetDrawable() const
286 : : { return GetWindow(); }
287 : :
288 : : #endif
289 : :
290 : : #endif // _SV_SALFRAME_H
291 : :
292 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|