xref: /aoo41x/main/vcl/inc/unx/salframe.h (revision 24f6443d)
1*24f6443dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*24f6443dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*24f6443dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*24f6443dSAndrew Rist  * distributed with this work for additional information
6*24f6443dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*24f6443dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*24f6443dSAndrew Rist  * "License"); you may not use this file except in compliance
9*24f6443dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*24f6443dSAndrew Rist  *
11*24f6443dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*24f6443dSAndrew Rist  *
13*24f6443dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*24f6443dSAndrew Rist  * software distributed under the License is distributed on an
15*24f6443dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24f6443dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*24f6443dSAndrew Rist  * specific language governing permissions and limitations
18*24f6443dSAndrew Rist  * under the License.
19*24f6443dSAndrew Rist  *
20*24f6443dSAndrew Rist  *************************************************************/
21*24f6443dSAndrew Rist 
22*24f6443dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SV_SALFRAME_H
24cdf0e10cSrcweir #define _SV_SALFRAME_H
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // -=-= #includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
27cdf0e10cSrcweir #include <unx/salstd.hxx>
28cdf0e10cSrcweir #include <unx/salunx.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <salframe.hxx>
31cdf0e10cSrcweir #include <salwtype.hxx>
32cdf0e10cSrcweir #include <salinst.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <vcl/ptrstyle.hxx>
35cdf0e10cSrcweir #include <vcl/sysdata.hxx>
36cdf0e10cSrcweir #include <vcl/timer.hxx>
37cdf0e10cSrcweir #include <vclpluginapi.h>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <list>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
43cdf0e10cSrcweir class	SalDisplay;
44cdf0e10cSrcweir class	X11SalGraphics;
45cdf0e10cSrcweir class SalGraphicsLayout;
46cdf0e10cSrcweir class   SalI18N_InputContext;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // -=-= X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
51cdf0e10cSrcweir #define SHOWSTATE_UNKNOWN		-1
52cdf0e10cSrcweir #define SHOWSTATE_MINIMIZED 	0
53cdf0e10cSrcweir #define SHOWSTATE_NORMAL		1
54cdf0e10cSrcweir #define SHOWSTATE_HIDDEN		2
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame
57cdf0e10cSrcweir {
58cdf0e10cSrcweir     friend class vcl_sal::WMAdaptor;
59cdf0e10cSrcweir     friend class vcl_sal::NetWMAdaptor;
60cdf0e10cSrcweir     friend class vcl_sal::GnomeWMAdaptor;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     static X11SalFrame* s_pSaveYourselfFrame;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     X11SalFrame*	mpParent;            // pointer to parent frame
65cdf0e10cSrcweir 	                                // which should never obscur this frame
66cdf0e10cSrcweir     bool			mbTransientForRoot;
67cdf0e10cSrcweir     std::list< X11SalFrame* > maChildren;         // List of child frames
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     SalDisplay	   *pDisplay_;
70cdf0e10cSrcweir     int             m_nScreen;
71cdf0e10cSrcweir     XLIB_Window		mhWindow;
72cdf0e10cSrcweir     XLIB_Window		mhShellWindow;
73cdf0e10cSrcweir     XLIB_Window		mhForeignParent;
74cdf0e10cSrcweir     // window to fall back to when no longer in fullscreen mode
75cdf0e10cSrcweir     XLIB_Window		mhStackingWindow;
76cdf0e10cSrcweir     // window to listen for CirculateNotify events
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     Pixmap          mhBackgroundPixmap;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     XLIB_Cursor		hCursor_;
81cdf0e10cSrcweir     int				nCaptured_;			// is captured
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     X11SalGraphics	*pGraphics_;			// current frame graphics
84cdf0e10cSrcweir     X11SalGraphics	*pFreeGraphics_;		// first free frame graphics
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     XLIB_Time		nReleaseTime_;		// timestamp of last key release
87cdf0e10cSrcweir     sal_uInt16			nKeyCode_;			// last key code
88cdf0e10cSrcweir     sal_uInt16			nKeyState_;			// last key state
89cdf0e10cSrcweir     int				nCompose_;			// compose state
90cdf0e10cSrcweir     bool			mbKeyMenu;
91cdf0e10cSrcweir     bool			mbSendExtKeyModChange;
92cdf0e10cSrcweir     sal_uInt16			mnExtKeyMod;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     int				nShowState_;		// show state
95cdf0e10cSrcweir     int				nWidth_;			// client width
96cdf0e10cSrcweir     int				nHeight_;			// client height
97cdf0e10cSrcweir     Rectangle		maRestorePosSize;
98cdf0e10cSrcweir     sal_uIntPtr			nStyle_;
99cdf0e10cSrcweir     SalExtStyle     mnExtStyle;
100cdf0e10cSrcweir     sal_Bool			bAlwaysOnTop_;
101cdf0e10cSrcweir     sal_Bool			bViewable_;
102cdf0e10cSrcweir     sal_Bool			bMapped_;
103cdf0e10cSrcweir     sal_Bool			mbInShow;
104cdf0e10cSrcweir     sal_Bool			bDefaultPosition_;	// client is centered initially
105cdf0e10cSrcweir     bool            m_bXEmbed;
106cdf0e10cSrcweir     int				nVisibility_;
107cdf0e10cSrcweir     int             m_nWorkArea;
108cdf0e10cSrcweir     bool            m_bSetFocusOnMap;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     int				nScreenSaversTimeout_;
112cdf0e10cSrcweir     Rectangle		maPaintRegion;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     Timer			maAlwaysOnTopRaiseTimer;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     // data for WMAdaptor
117cdf0e10cSrcweir     int				meWindowType;
118cdf0e10cSrcweir     int				mnDecorationFlags;
119cdf0e10cSrcweir     bool			mbMaximizedVert;
120cdf0e10cSrcweir     bool			mbMaximizedHorz;
121cdf0e10cSrcweir     bool			mbShaded;
122cdf0e10cSrcweir     bool			mbFullScreen;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     // icon id
125cdf0e10cSrcweir     int			    mnIconID;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     String          m_aTitle;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     SystemChildData maSystemChildData;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     SalI18N_InputContext *mpInputContext;
132cdf0e10cSrcweir     Bool			mbInputFocus;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     XRectangle*     m_pClipRectangles;
135cdf0e10cSrcweir     int             m_nCurClipRect;
136cdf0e10cSrcweir     int             m_nMaxClipRect;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     void			GetPosSize( Rectangle &rPosSize );
140cdf0e10cSrcweir     void			SetSize   ( const Size      &rSize );
141cdf0e10cSrcweir     void            Center();
142cdf0e10cSrcweir     void			SetPosSize( const Rectangle &rPosSize );
143cdf0e10cSrcweir     void			Minimize();
144cdf0e10cSrcweir     void			Maximize();
145cdf0e10cSrcweir     void			Restore();
146cdf0e10cSrcweir     void            SetWindowGravity (int nGravity ) const;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     void			RestackChildren( XLIB_Window* pTopLevelWindows, int nTopLevelWindows );
149cdf0e10cSrcweir     void			RestackChildren();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     long			HandleKeyEvent		( XKeyEvent			*pEvent );
152cdf0e10cSrcweir     long			HandleMouseEvent	( XEvent			*pEvent );
153cdf0e10cSrcweir     long			HandleFocusEvent	( XFocusChangeEvent *pEvent );
154cdf0e10cSrcweir     long			HandleExposeEvent	( XEvent			*pEvent );
155cdf0e10cSrcweir     long			HandleSizeEvent		( XConfigureEvent	*pEvent );
156cdf0e10cSrcweir     long			HandleColormapEvent	( XColormapEvent	*pEvent );
157cdf0e10cSrcweir     long			HandleMapUnmapEvent	( XEvent			*pEvent );
158cdf0e10cSrcweir     long			HandleStateEvent	( XPropertyEvent	*pEvent );
159cdf0e10cSrcweir     long			HandleReparentEvent	( XReparentEvent	*pEvent );
160cdf0e10cSrcweir     long			HandleClientMessage	( XClientMessageEvent*pEvent );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     DECL_LINK( HandleAlwaysOnTopRaise, void* );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     void			passOnSaveYourSelf();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     void            createNewWindow( XLIB_Window aParent, int nScreen = -1 );
167cdf0e10cSrcweir     void            updateScreenNumber();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     void            setXEmbedInfo();
170cdf0e10cSrcweir     void            askForXEmbedFocus( sal_Int32 i_nTimeCode );
171cdf0e10cSrcweir public:
172cdf0e10cSrcweir 	X11SalFrame( SalFrame* pParent, sal_uIntPtr nSalFrameStyle, SystemParentData* pSystemParent = NULL );
173cdf0e10cSrcweir 	virtual ~X11SalFrame();
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     long			Dispatch( XEvent *pEvent );
176cdf0e10cSrcweir     void			Init( sal_uIntPtr nSalFrameStyle, int nScreen = -1,
177cdf0e10cSrcweir                           SystemParentData* pParentData = NULL, bool bUseGeometry = false );
178cdf0e10cSrcweir 
GetDisplay() const179cdf0e10cSrcweir     SalDisplay*				GetDisplay() const { return pDisplay_; }
180cdf0e10cSrcweir 	Display*				GetXDisplay() const;
181cdf0e10cSrcweir 	XLIB_Window				GetDrawable() const;
GetScreenNumber() const182cdf0e10cSrcweir     int                     GetScreenNumber() const { return m_nScreen; }
GetWindow() const183cdf0e10cSrcweir     XLIB_Window				GetWindow() const { return mhWindow; }
GetShellWindow() const184cdf0e10cSrcweir     XLIB_Window				GetShellWindow() const { return mhShellWindow; }
GetForeignParent() const185cdf0e10cSrcweir 	XLIB_Window				GetForeignParent() const { return mhForeignParent; }
GetStackingWindow() const186cdf0e10cSrcweir 	XLIB_Window				GetStackingWindow() const { return mhStackingWindow; }
ShutDown() const187cdf0e10cSrcweir 	long					ShutDown() const { return CallCallback( SALEVENT_SHUTDOWN, 0 ); }
Close() const188cdf0e10cSrcweir 	long					Close() const { return CallCallback( SALEVENT_CLOSE, 0 ); }
GetStyle() const189cdf0e10cSrcweir           	sal_uIntPtr           GetStyle() const { return nStyle_; }
190cdf0e10cSrcweir 
GetCursor() const191cdf0e10cSrcweir 	inline	XLIB_Cursor		GetCursor() const { return hCursor_; }
IsCaptured() const192cdf0e10cSrcweir 	inline	sal_Bool			IsCaptured() const { return nCaptured_ == 1; }
193cdf0e10cSrcweir #if !defined(__synchronous_extinput__)
194cdf0e10cSrcweir     void 			HandleExtTextEvent (XClientMessageEvent *pEvent);
195cdf0e10cSrcweir     void			PostExtTextEvent (sal_uInt16 nExtTextEventType,
196cdf0e10cSrcweir                                       void *pExtTextEvent);
197cdf0e10cSrcweir #endif
198cdf0e10cSrcweir     bool					IsOverrideRedirect() const;
IsChildWindow() const199cdf0e10cSrcweir     bool                    IsChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_PLUG|SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
IsSysChildWindow() const200cdf0e10cSrcweir     bool                    IsSysChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
201cdf0e10cSrcweir     bool					IsFloatGrabWindow() const;
getInputContext() const202cdf0e10cSrcweir     SalI18N_InputContext* getInputContext() const { return mpInputContext; }
getPosSize(Rectangle & rRect)203cdf0e10cSrcweir     void			        getPosSize( Rectangle& rRect ) { GetPosSize( rRect ); }
setPosSize(const Rectangle & rRect)204cdf0e10cSrcweir     void					setPosSize( const Rectangle& rRect ) { SetPosSize( rRect ); }
isMapped() const205cdf0e10cSrcweir     bool					isMapped() const { return bMapped_; }
hasFocus() const206cdf0e10cSrcweir     bool                    hasFocus() const { return mbInputFocus; }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     void                    beginUnicodeSequence();
209cdf0e10cSrcweir     bool                    appendUnicodeSequence( sal_Unicode );
210cdf0e10cSrcweir     bool                    endUnicodeSequence();
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     virtual SalGraphics*		GetGraphics();
213cdf0e10cSrcweir     virtual void				ReleaseGraphics( SalGraphics* pGraphics );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     // call with true to clear graphics (setting None as drawable)
216cdf0e10cSrcweir     // call with false to setup graphics with window (GetWindow())
217cdf0e10cSrcweir     virtual void                updateGraphics( bool bClear );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     virtual sal_Bool				PostEvent( void* pData );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     virtual void				SetTitle( const XubString& rTitle );
222cdf0e10cSrcweir     virtual void				SetIcon( sal_uInt16 nIcon );
223cdf0e10cSrcweir     virtual void				SetMenu( SalMenu* pMenu );
224cdf0e10cSrcweir     virtual void                                DrawMenuBar();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     virtual void                SetExtendedFrameStyle( SalExtStyle nExtStyle );
227cdf0e10cSrcweir     virtual void				Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False );
228cdf0e10cSrcweir     virtual void				Enable( sal_Bool bEnable );
229cdf0e10cSrcweir     virtual void              SetMinClientSize( long nWidth, long nHeight );
230cdf0e10cSrcweir     virtual void              SetMaxClientSize( long nWidth, long nHeight );
231cdf0e10cSrcweir     virtual void				SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags );
232cdf0e10cSrcweir     virtual void				GetClientSize( long& rWidth, long& rHeight );
233cdf0e10cSrcweir     virtual void				GetWorkArea( Rectangle& rRect );
234cdf0e10cSrcweir     virtual SalFrame*			GetParent() const;
235cdf0e10cSrcweir     virtual void				SetWindowState( const SalFrameState* pState );
236cdf0e10cSrcweir     virtual sal_Bool				GetWindowState( SalFrameState* pState );
237cdf0e10cSrcweir     virtual void				ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nMonitor );
238cdf0e10cSrcweir     virtual void				StartPresentation( sal_Bool bStart );
239cdf0e10cSrcweir     virtual void				SetAlwaysOnTop( sal_Bool bOnTop );
240cdf0e10cSrcweir     virtual void				ToTop( sal_uInt16 nFlags );
241cdf0e10cSrcweir     virtual void				SetPointer( PointerStyle ePointerStyle );
242cdf0e10cSrcweir     virtual void				CaptureMouse( sal_Bool bMouse );
243cdf0e10cSrcweir     virtual void				SetPointerPos( long nX, long nY );
244cdf0e10cSrcweir     using SalFrame::Flush;
245cdf0e10cSrcweir     virtual void				Flush();
246cdf0e10cSrcweir     virtual void				Sync();
247cdf0e10cSrcweir     virtual void				SetInputContext( SalInputContext* pContext );
248cdf0e10cSrcweir     virtual void				EndExtTextInput( sal_uInt16 nFlags );
249cdf0e10cSrcweir     virtual String				GetKeyName( sal_uInt16 nKeyCode );
250cdf0e10cSrcweir     virtual String				GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode );
251cdf0e10cSrcweir     virtual sal_Bool                MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
252cdf0e10cSrcweir     virtual LanguageType		GetInputLanguage();
253cdf0e10cSrcweir     virtual SalBitmap*			SnapShot();
254cdf0e10cSrcweir     virtual void				UpdateSettings( AllSettings& rSettings );
255cdf0e10cSrcweir     virtual void				Beep( SoundType eSoundType );
256cdf0e10cSrcweir     virtual const SystemEnvData*	GetSystemData() const;
257cdf0e10cSrcweir     virtual SalPointerState     GetPointerState();
258cdf0e10cSrcweir     virtual void				SetParent( SalFrame* pNewParent );
259cdf0e10cSrcweir     virtual bool				SetPluginParent( SystemParentData* pNewParent );
260cdf0e10cSrcweir     virtual void                SetBackgroundBitmap( SalBitmap* pBitmap );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     virtual void                SetScreenNumber( unsigned int );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     // shaped system windows
265cdf0e10cSrcweir     // set clip region to none (-> rectangular windows, normal state)
266cdf0e10cSrcweir 	virtual void					ResetClipRegion();
267cdf0e10cSrcweir     // start setting the clipregion consisting of nRects rectangles
268cdf0e10cSrcweir 	virtual void					BeginSetClipRegion( sal_uIntPtr nRects );
269cdf0e10cSrcweir     // add a rectangle to the clip region
270cdf0e10cSrcweir 	virtual void					UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
271cdf0e10cSrcweir     // done setting up the clipregion
272cdf0e10cSrcweir 	virtual void					EndSetClipRegion();
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     static void SaveYourselfDone( SalFrame* );
275cdf0e10cSrcweir 	static Bool checkKeyReleaseForRepeat( Display*, XEvent*, XPointer pX11SalFrame );
276cdf0e10cSrcweir };
277cdf0e10cSrcweir 
278cdf0e10cSrcweir #ifdef _SV_SALDISP_HXX
279cdf0e10cSrcweir 
GetXDisplay() const280cdf0e10cSrcweir inline Display *X11SalFrame::GetXDisplay() const
281cdf0e10cSrcweir { return pDisplay_->GetDisplay(); }
282cdf0e10cSrcweir 
GetDrawable() const283cdf0e10cSrcweir inline XLIB_Window X11SalFrame::GetDrawable() const
284cdf0e10cSrcweir { return GetWindow(); }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir 
288cdf0e10cSrcweir #endif // _SV_SALFRAME_H
289cdf0e10cSrcweir 
290