1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salframe.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SV_SALFRAME_H
31 #define _SV_SALFRAME_H
33 // -=-= #includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
35 #include <vcl/salframe.hxx>
36 #include <vcl/salwtype.hxx>
37 #ifndef _SV_PTRSTYLE_HXX
38 #include <vcl/ptrstyle.hxx>
40 #include <vcl/salinst.hxx>
41 #include <vcl/sysdata.hxx>
42 #include <vcl/timer.hxx>
43 #include <vcl/dllapi.h>
48 // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
51 class SalGraphicsLayout
;
52 class SalI18N_InputContext
;
54 namespace vcl_sal
{ class WMAdaptor
; class NetWMAdaptor
; class GnomeWMAdaptor
; }
56 // -=-= X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
57 #define SHOWSTATE_UNKNOWN -1
58 #define SHOWSTATE_MINIMIZED 0
59 #define SHOWSTATE_NORMAL 1
60 #define SHOWSTATE_HIDDEN 2
62 class VCL_DLLPUBLIC X11SalFrame
: public SalFrame
64 friend class vcl_sal::WMAdaptor
;
65 friend class vcl_sal::NetWMAdaptor
;
66 friend class vcl_sal::GnomeWMAdaptor
;
68 static X11SalFrame
* s_pSaveYourselfFrame
;
70 X11SalFrame
* mpParent
; // pointer to parent frame
71 // which should never obscur this frame
72 bool mbTransientForRoot
;
73 std::list
< X11SalFrame
* > maChildren
; // List of child frames
75 SalDisplay
*pDisplay_
;
78 XLIB_Window mhShellWindow
;
79 XLIB_Window mhForeignParent
;
80 // window to fall back to when no longer in fullscreen mode
81 XLIB_Window mhStackingWindow
;
82 // window to listen for CirculateNotify events
84 Pixmap mhBackgroundPixmap
;
87 int nCaptured_
; // is captured
89 X11SalGraphics
*pGraphics_
; // current frame graphics
90 X11SalGraphics
*pFreeGraphics_
; // first free frame graphics
92 XLIB_Time nReleaseTime_
; // timestamp of last key release
93 USHORT nKeyCode_
; // last key code
94 USHORT nKeyState_
; // last key state
95 int nCompose_
; // compose state
97 bool mbSendExtKeyModChange
;
100 int nShowState_
; // show state
101 int nWidth_
; // client width
102 int nHeight_
; // client height
103 Rectangle maRestorePosSize
;
105 SalExtStyle mnExtStyle
;
110 BOOL bDefaultPosition_
; // client is centered initially
115 int nScreenSaversTimeout_
;
116 Rectangle maPaintRegion
;
118 Timer maAlwaysOnTopRaiseTimer
;
120 // data for WMAdaptor
122 int mnDecorationFlags
;
123 bool mbMaximizedVert
;
124 bool mbMaximizedHorz
;
133 SystemChildData maSystemChildData
;
135 SalI18N_InputContext
*mpInputContext
;
138 XRectangle
* m_pClipRectangles
;
143 void GetPosSize( Rectangle
&rPosSize
);
144 void SetSize ( const Size
&rSize
);
146 void SetPosSize( const Rectangle
&rPosSize
);
150 void SetWindowGravity (int nGravity
) const;
152 void RestackChildren( XLIB_Window
* pTopLevelWindows
, int nTopLevelWindows
);
153 void RestackChildren();
155 long HandleKeyEvent ( XKeyEvent
*pEvent
);
156 long HandleMouseEvent ( XEvent
*pEvent
);
157 long HandleFocusEvent ( XFocusChangeEvent
*pEvent
);
158 long HandleExposeEvent ( XEvent
*pEvent
);
159 long HandleSizeEvent ( XConfigureEvent
*pEvent
);
160 long HandleColormapEvent ( XColormapEvent
*pEvent
);
161 long HandleMapUnmapEvent ( XEvent
*pEvent
);
162 long HandleStateEvent ( XPropertyEvent
*pEvent
);
163 long HandleReparentEvent ( XReparentEvent
*pEvent
);
164 long HandleClientMessage ( XClientMessageEvent
*pEvent
);
166 DECL_LINK( HandleAlwaysOnTopRaise
, void* );
168 void passOnSaveYourSelf();
170 void createNewWindow( XLIB_Window aParent
, int nScreen
= -1 );
171 void updateScreenNumber();
173 void setXEmbedInfo();
174 void askForXEmbedFocus( sal_Int32 i_nTimeCode
);
176 X11SalFrame( SalFrame
* pParent
, ULONG nSalFrameStyle
, SystemParentData
* pSystemParent
= NULL
);
177 virtual ~X11SalFrame();
179 long Dispatch( XEvent
*pEvent
);
180 void Init( ULONG nSalFrameStyle
, int nScreen
= -1,
181 SystemParentData
* pParentData
= NULL
, bool bUseGeometry
= false );
183 SalDisplay
* GetDisplay() const { return pDisplay_
; }
184 Display
* GetXDisplay() const;
185 XLIB_Window
GetDrawable() const;
186 int GetScreenNumber() const { return m_nScreen
; }
187 XLIB_Window
GetWindow() const { return mhWindow
; }
188 XLIB_Window
GetShellWindow() const { return mhShellWindow
; }
189 XLIB_Window
GetForeignParent() const { return mhForeignParent
; }
190 XLIB_Window
GetStackingWindow() const { return mhStackingWindow
; }
191 long ShutDown() const { return CallCallback( SALEVENT_SHUTDOWN
, 0 ); }
192 long Close() const { return CallCallback( SALEVENT_CLOSE
, 0 ); }
193 ULONG
GetStyle() const { return nStyle_
; }
195 inline XLIB_Cursor
GetCursor() const { return hCursor_
; }
196 inline BOOL
IsCaptured() const { return nCaptured_
== 1; }
197 #if !defined(__synchronous_extinput__)
198 void HandleExtTextEvent (XClientMessageEvent
*pEvent
);
199 void PostExtTextEvent (sal_uInt16 nExtTextEventType
,
200 void *pExtTextEvent
);
202 bool IsOverrideRedirect() const;
203 bool IsChildWindow() const { return (nStyle_
& (SAL_FRAME_STYLE_PLUG
|SAL_FRAME_STYLE_SYSTEMCHILD
)) != 0; }
204 bool IsSysChildWindow() const { return (nStyle_
& (SAL_FRAME_STYLE_SYSTEMCHILD
)) != 0; }
205 bool IsFloatGrabWindow() const;
206 SalI18N_InputContext
* getInputContext() const { return mpInputContext
; }
207 void getPosSize( Rectangle
& rRect
) { GetPosSize( rRect
); }
208 void setPosSize( const Rectangle
& rRect
) { SetPosSize( rRect
); }
209 bool isMapped() const { return bMapped_
; }
210 bool hasFocus() const { return mbInputFocus
; }
212 virtual SalGraphics
* GetGraphics();
213 virtual void ReleaseGraphics( SalGraphics
* pGraphics
);
215 virtual void updateGraphics();
217 virtual BOOL
PostEvent( void* pData
);
219 virtual void SetTitle( const XubString
& rTitle
);
220 virtual void SetIcon( USHORT nIcon
);
221 virtual void SetMenu( SalMenu
* pMenu
);
222 virtual void DrawMenuBar();
224 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle
);
225 virtual void Show( BOOL bVisible
, BOOL bNoActivate
= FALSE
);
226 virtual void Enable( BOOL bEnable
);
227 virtual void SetMinClientSize( long nWidth
, long nHeight
);
228 virtual void SetMaxClientSize( long nWidth
, long nHeight
);
229 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, USHORT nFlags
);
230 virtual void GetClientSize( long& rWidth
, long& rHeight
);
231 virtual void GetWorkArea( Rectangle
& rRect
);
232 virtual SalFrame
* GetParent() const;
233 virtual void SetWindowState( const SalFrameState
* pState
);
234 virtual BOOL
GetWindowState( SalFrameState
* pState
);
235 virtual void ShowFullScreen( BOOL bFullScreen
, sal_Int32 nMonitor
);
236 virtual void StartPresentation( BOOL bStart
);
237 virtual void SetAlwaysOnTop( BOOL bOnTop
);
238 virtual void ToTop( USHORT nFlags
);
239 virtual void SetPointer( PointerStyle ePointerStyle
);
240 virtual void CaptureMouse( BOOL bMouse
);
241 virtual void SetPointerPos( long nX
, long nY
);
242 using SalFrame::Flush
;
243 virtual void Flush();
245 virtual void SetInputContext( SalInputContext
* pContext
);
246 virtual void EndExtTextInput( USHORT nFlags
);
247 virtual String
GetKeyName( USHORT nKeyCode
);
248 virtual String
GetSymbolKeyName( const XubString
& rFontName
, USHORT nKeyCode
);
249 virtual BOOL
MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, KeyCode
& rKeyCode
);
250 virtual LanguageType
GetInputLanguage();
251 virtual SalBitmap
* SnapShot();
252 virtual void UpdateSettings( AllSettings
& rSettings
);
253 virtual void Beep( SoundType eSoundType
);
254 virtual const SystemEnvData
* GetSystemData() const;
255 virtual SalPointerState
GetPointerState();
256 virtual SalIndicatorState
GetIndicatorState();
257 virtual void SimulateKeyPress( USHORT nKeyCode
);
258 virtual void SetParent( SalFrame
* pNewParent
);
259 virtual bool SetPluginParent( SystemParentData
* pNewParent
);
260 virtual void SetBackgroundBitmap( SalBitmap
* pBitmap
);
262 virtual void SetScreenNumber( unsigned int );
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( ULONG 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();
274 static void SaveYourselfDone( SalFrame
* );
275 static Bool
checkKeyReleaseForRepeat( Display
*, XEvent
*, XPointer pX11SalFrame
);
278 #ifdef _SV_SALDISP_HXX
280 inline Display
*X11SalFrame::GetXDisplay() const
281 { return pDisplay_
->GetDisplay(); }
283 inline XLIB_Window
X11SalFrame::GetDrawable() const
284 { return GetWindow(); }
288 #endif // _SV_SALFRAME_H