xref: /aoo42x/main/vcl/inc/unx/salframe.h (revision 24f6443d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SV_SALFRAME_H
24 #define _SV_SALFRAME_H
25 
26 // -=-= #includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
27 #include <unx/salstd.hxx>
28 #include <unx/salunx.h>
29 
30 #include <salframe.hxx>
31 #include <salwtype.hxx>
32 #include <salinst.hxx>
33 
34 #include <vcl/ptrstyle.hxx>
35 #include <vcl/sysdata.hxx>
36 #include <vcl/timer.hxx>
37 #include <vclpluginapi.h>
38 
39 
40 #include <list>
41 
42 // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
43 class	SalDisplay;
44 class	X11SalGraphics;
45 class SalGraphicsLayout;
46 class   SalI18N_InputContext;
47 
48 namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; }
49 
50 // -=-= X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
51 #define SHOWSTATE_UNKNOWN		-1
52 #define SHOWSTATE_MINIMIZED 	0
53 #define SHOWSTATE_NORMAL		1
54 #define SHOWSTATE_HIDDEN		2
55 
56 class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame
57 {
58     friend class vcl_sal::WMAdaptor;
59     friend class vcl_sal::NetWMAdaptor;
60     friend class vcl_sal::GnomeWMAdaptor;
61 
62     static X11SalFrame* s_pSaveYourselfFrame;
63 
64     X11SalFrame*	mpParent;            // pointer to parent frame
65 	                                // which should never obscur this frame
66     bool			mbTransientForRoot;
67     std::list< X11SalFrame* > maChildren;         // List of child frames
68 
69     SalDisplay	   *pDisplay_;
70     int             m_nScreen;
71     XLIB_Window		mhWindow;
72     XLIB_Window		mhShellWindow;
73     XLIB_Window		mhForeignParent;
74     // window to fall back to when no longer in fullscreen mode
75     XLIB_Window		mhStackingWindow;
76     // window to listen for CirculateNotify events
77 
78     Pixmap          mhBackgroundPixmap;
79 
80     XLIB_Cursor		hCursor_;
81     int				nCaptured_;			// is captured
82 
83     X11SalGraphics	*pGraphics_;			// current frame graphics
84     X11SalGraphics	*pFreeGraphics_;		// first free frame graphics
85 
86     XLIB_Time		nReleaseTime_;		// timestamp of last key release
87     sal_uInt16			nKeyCode_;			// last key code
88     sal_uInt16			nKeyState_;			// last key state
89     int				nCompose_;			// compose state
90     bool			mbKeyMenu;
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     String          m_aTitle;
128 
129     SystemChildData maSystemChildData;
130 
131     SalI18N_InputContext *mpInputContext;
132     Bool			mbInputFocus;
133 
134     XRectangle*     m_pClipRectangles;
135     int             m_nCurClipRect;
136     int             m_nMaxClipRect;
137 
138 
139     void			GetPosSize( Rectangle &rPosSize );
140     void			SetSize   ( const Size      &rSize );
141     void            Center();
142     void			SetPosSize( const Rectangle &rPosSize );
143     void			Minimize();
144     void			Maximize();
145     void			Restore();
146     void            SetWindowGravity (int nGravity ) const;
147 
148     void			RestackChildren( XLIB_Window* pTopLevelWindows, int nTopLevelWindows );
149     void			RestackChildren();
150 
151     long			HandleKeyEvent		( XKeyEvent			*pEvent );
152     long			HandleMouseEvent	( XEvent			*pEvent );
153     long			HandleFocusEvent	( XFocusChangeEvent *pEvent );
154     long			HandleExposeEvent	( XEvent			*pEvent );
155     long			HandleSizeEvent		( XConfigureEvent	*pEvent );
156     long			HandleColormapEvent	( XColormapEvent	*pEvent );
157     long			HandleMapUnmapEvent	( XEvent			*pEvent );
158     long			HandleStateEvent	( XPropertyEvent	*pEvent );
159     long			HandleReparentEvent	( XReparentEvent	*pEvent );
160     long			HandleClientMessage	( XClientMessageEvent*pEvent );
161 
162     DECL_LINK( HandleAlwaysOnTopRaise, void* );
163 
164     void			passOnSaveYourSelf();
165 
166     void            createNewWindow( XLIB_Window aParent, int nScreen = -1 );
167     void            updateScreenNumber();
168 
169     void            setXEmbedInfo();
170     void            askForXEmbedFocus( sal_Int32 i_nTimeCode );
171 public:
172 	X11SalFrame( SalFrame* pParent, sal_uIntPtr nSalFrameStyle, SystemParentData* pSystemParent = NULL );
173 	virtual ~X11SalFrame();
174 
175     long			Dispatch( XEvent *pEvent );
176     void			Init( sal_uIntPtr nSalFrameStyle, int nScreen = -1,
177                           SystemParentData* pParentData = NULL, bool bUseGeometry = false );
178 
GetDisplay() const179     SalDisplay*				GetDisplay() const { return pDisplay_; }
180 	Display*				GetXDisplay() const;
181 	XLIB_Window				GetDrawable() const;
GetScreenNumber() const182     int                     GetScreenNumber() const { return m_nScreen; }
GetWindow() const183     XLIB_Window				GetWindow() const { return mhWindow; }
GetShellWindow() const184     XLIB_Window				GetShellWindow() const { return mhShellWindow; }
GetForeignParent() const185 	XLIB_Window				GetForeignParent() const { return mhForeignParent; }
GetStackingWindow() const186 	XLIB_Window				GetStackingWindow() const { return mhStackingWindow; }
ShutDown() const187 	long					ShutDown() const { return CallCallback( SALEVENT_SHUTDOWN, 0 ); }
Close() const188 	long					Close() const { return CallCallback( SALEVENT_CLOSE, 0 ); }
GetStyle() const189           	sal_uIntPtr           GetStyle() const { return nStyle_; }
190 
GetCursor() const191 	inline	XLIB_Cursor		GetCursor() const { return hCursor_; }
IsCaptured() const192 	inline	sal_Bool			IsCaptured() const { return nCaptured_ == 1; }
193 #if !defined(__synchronous_extinput__)
194     void 			HandleExtTextEvent (XClientMessageEvent *pEvent);
195     void			PostExtTextEvent (sal_uInt16 nExtTextEventType,
196                                       void *pExtTextEvent);
197 #endif
198     bool					IsOverrideRedirect() const;
IsChildWindow() const199     bool                    IsChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_PLUG|SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
IsSysChildWindow() const200     bool                    IsSysChildWindow() const { return (nStyle_ & (SAL_FRAME_STYLE_SYSTEMCHILD)) != 0; }
201     bool					IsFloatGrabWindow() const;
getInputContext() const202     SalI18N_InputContext* getInputContext() const { return mpInputContext; }
getPosSize(Rectangle & rRect)203     void			        getPosSize( Rectangle& rRect ) { GetPosSize( rRect ); }
setPosSize(const Rectangle & rRect)204     void					setPosSize( const Rectangle& rRect ) { SetPosSize( rRect ); }
isMapped() const205     bool					isMapped() const { return bMapped_; }
hasFocus() const206     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 XubString& 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 String				GetKeyName( sal_uInt16 nKeyCode );
250     virtual String				GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode );
251     virtual sal_Bool                MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
252     virtual LanguageType		GetInputLanguage();
253     virtual SalBitmap*			SnapShot();
254     virtual void				UpdateSettings( AllSettings& rSettings );
255     virtual void				Beep( SoundType eSoundType );
256     virtual const SystemEnvData*	GetSystemData() const;
257     virtual SalPointerState     GetPointerState();
258     virtual void				SetParent( SalFrame* pNewParent );
259     virtual bool				SetPluginParent( SystemParentData* pNewParent );
260     virtual void                SetBackgroundBitmap( SalBitmap* pBitmap );
261 
262     virtual void                SetScreenNumber( unsigned int );
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 void SaveYourselfDone( SalFrame* );
275 	static Bool checkKeyReleaseForRepeat( Display*, XEvent*, XPointer pX11SalFrame );
276 };
277 
278 #ifdef _SV_SALDISP_HXX
279 
GetXDisplay() const280 inline Display *X11SalFrame::GetXDisplay() const
281 { return pDisplay_->GetDisplay(); }
282 
GetDrawable() const283 inline XLIB_Window X11SalFrame::GetDrawable() const
284 { return GetWindow(); }
285 
286 #endif
287 
288 #endif // _SV_SALFRAME_H
289 
290