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 24 #ifndef _VCL_GTKDATA_HXX 25 #define _VCL_GTKDATA_HXX 26 27 #include <map> 28 29 #include <tools/prex.h> 30 #include <gdk/gdk.h> 31 #include <gdk/gdkx.h> 32 #include <gtk/gtk.h> 33 #include <tools/postx.h> 34 35 #include <unx/saldisp.hxx> 36 #include <unx/saldata.hxx> 37 #include <vcl/ptrstyle.hxx> 38 39 class GtkData : public X11SalData 40 { 41 public: GtkData()42 GtkData() {} 43 virtual ~GtkData(); 44 45 virtual void Init(); 46 47 virtual void initNWF(); 48 virtual void deInitNWF(); 49 }; 50 51 class GtkSalFrame; 52 53 class GtkSalDisplay : public SalDisplay 54 { 55 GdkDisplay* m_pGdkDisplay; 56 GdkCursor *m_aCursors[ POINTER_COUNT ]; 57 bool m_bStartupCompleted; 58 /* 59 * Each live X11 window ID may be associated with at most one frame. 60 * Window IDs must be deregistered before destruction or reassignment. 61 * Duplicate registration is a lifecycle error and is not overwritten. 62 */ 63 std::map< XLIB_Window, GtkSalFrame* > m_aWindowFrameMap; 64 65 GdkCursor* getFromXPM( const char *pBitmap, const char *pMask, 66 int nWidth, int nHeight, int nXHot, int nYHot ); 67 public: 68 GtkSalDisplay( GdkDisplay* pDisplay ); 69 virtual ~GtkSalDisplay(); 70 GetGdkDisplay() const71 GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; } 72 73 virtual void deregisterFrame( SalFrame* pFrame ); 74 GtkSalFrame* findFrameByXWindow( XLIB_Window aWindow ) const; 75 void registerFrameWindow( XLIB_Window aWindow, GtkSalFrame* pFrame ); 76 void deregisterFrameWindow( XLIB_Window aWindow, GtkSalFrame* pFrame = NULL ); 77 GdkCursor *getCursor( PointerStyle ePointerStyle ); 78 virtual int CaptureMouse( SalFrame* pFrame ); 79 virtual long Dispatch( XEvent *pEvent ); 80 virtual void initScreen( int nScreen ) const; 81 82 virtual int GetDefaultMonitorNumber() const; 83 84 static GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event, 85 GdkEvent* event, 86 gpointer data ); HasMoreEvents()87 inline bool HasMoreEvents() { return m_aUserEvents.size() > 1; } EventGuardAcquire()88 inline void EventGuardAcquire() { osl_acquireMutex( hEventGuard_ ); } EventGuardRelease()89 inline void EventGuardRelease() { osl_releaseMutex( hEventGuard_ ); } startupNotificationCompleted()90 void startupNotificationCompleted() { m_bStartupCompleted = true; } 91 92 void screenSizeChanged( GdkScreen* ); 93 void monitorsChanged( GdkScreen* ); 94 }; 95 96 97 #endif // _VCL_GTKDATA_HXX 98