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