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