Kaydet (Commit) a39f4e5b authored tarafından Michael Meeks's avatar Michael Meeks

gtk3: substantial re-work and cleanup of event handling

Implement SalTimer ourselves rather more cleanly
Remove nasty GtkXLib cruft inherited from X backend
Merge and cleanup most Yield / mainloop bits into GtkData
üst 0fd37a71
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
#include <unx/gtk/gtksys.hxx> #include <unx/gtk/gtksys.hxx>
#include <vcl/ptrstyle.hxx> #include <vcl/ptrstyle.hxx>
#include <osl/conditn.h> #include <osl/conditn.h>
#include "saltimer.hxx"
#include <list> #include <list>
class GtkXLib;
class GtkSalDisplay; class GtkSalDisplay;
inline GdkWindow * widget_get_window(GtkWidget *widget) inline GdkWindow * widget_get_window(GtkWidget *widget)
...@@ -79,45 +79,27 @@ inline void widget_set_can_default(GtkWidget *widget, gboolean can_default) ...@@ -79,45 +79,27 @@ inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
#endif #endif
} }
class GtkXLib : public SalXLib class GtkSalTimer : public SalTimer
{ {
GtkSalDisplay *m_pGtkSalDisplay; GSource *m_pTimeout;
std::list<GSource *> m_aSources;
GSource *m_pTimeout;
GSource *m_pUserEvent;
oslMutex m_aDispatchMutex;
oslCondition m_aDispatchCondition;
XIOErrorHandler m_aOrigGTKXIOErrorHandler;
public: public:
static gboolean timeoutFn(gpointer data); GtkSalTimer();
static gboolean userEventFn(gpointer data); ~GtkSalTimer();
sal_uLong m_nTimeoutMS;
GtkXLib(); virtual void Start( sal_uLong nMS );
virtual ~GtkXLib(); virtual void Stop();
virtual void Init();
virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
virtual void Insert( int fd, void* data,
YieldFunc pending,
YieldFunc queued,
YieldFunc handle );
virtual void Remove( int fd );
virtual void StartTimer( sal_uLong nMS );
virtual void StopTimer();
virtual void Wakeup();
virtual void PostUserEvent();
}; };
#if GTK_CHECK_VERSION(3,0,0)
class GtkData : public SalData class GtkData : public SalData
#else
class GtkData : public X11SalData
#endif
{ {
oslMutex m_aDispatchMutex;
oslCondition m_aDispatchCondition;
GSource *m_pUserEvent;
GtkSalDisplay *m_pGtkSalDisplay;
public: public:
GtkData() {} GtkData();
virtual ~GtkData(); virtual ~GtkData();
virtual void Init(); virtual void Init();
...@@ -125,12 +107,12 @@ public: ...@@ -125,12 +107,12 @@ public:
virtual void initNWF(); virtual void initNWF();
virtual void deInitNWF(); virtual void deInitNWF();
GtkSalDisplay *pDisplay; static gboolean userEventFn( gpointer data );
GtkSalDisplay *GetDisplay() { return pDisplay; }
#if GTK_CHECK_VERSION(3,0,0) void PostUserEvent();
GtkXLib *pXLib_; void Yield( bool bWait, bool bHandleAllCurrentEvents );
SalXLib *GetLib() { return pXLib_; } GtkSalDisplay *GetDisplay() { return m_pGtkSalDisplay; }
#endif inline GdkDisplay *GetGdkDisplay();
}; };
inline GtkData* GetGtkSalData() inline GtkData* GetGtkSalData()
...@@ -210,10 +192,12 @@ public: ...@@ -210,10 +192,12 @@ public:
oslMutex hEventGuard_; oslMutex hEventGuard_;
std::list< SalUserEvent > m_aUserEvents; std::list< SalUserEvent > m_aUserEvents;
guint32 GetLastUserEventTime( bool b ) { return GDK_CURRENT_TIME; } // horrible hack guint32 GetLastUserEventTime( bool /* b */ ) { return GDK_CURRENT_TIME; } // horrible hack
#endif #endif
}; };
inline GdkDisplay *GtkData::GetGdkDisplay() { return m_pGtkSalDisplay->GetGdkDisplay(); }
#endif // _VCL_GTKDATA_HXX #endif // _VCL_GTKDATA_HXX
......
...@@ -180,6 +180,7 @@ class GtkSalFrame : public SalFrame, basebmp::BitmapDeviceDamageTracker ...@@ -180,6 +180,7 @@ class GtkSalFrame : public SalFrame, basebmp::BitmapDeviceDamageTracker
int m_nScreen; int m_nScreen;
GtkWidget* m_pWindow; GtkWidget* m_pWindow;
guint m_nIdleFullScreen;
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
basebmp::BitmapDeviceSharedPtr m_aFrame; basebmp::BitmapDeviceSharedPtr m_aFrame;
#endif #endif
......
...@@ -100,6 +100,7 @@ public: ...@@ -100,6 +100,7 @@ public:
virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ); virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ); virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True );
virtual SalSystem* CreateSalSystem(); virtual SalSystem* CreateSalSystem();
virtual SalTimer* CreateSalTimer();
virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*, virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*,
long nDX, long nDY, long nDX, long nDY,
......
This diff is collapsed.
...@@ -419,6 +419,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG, ...@@ -419,6 +419,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
const SystemGraphicsData *pGd ) const SystemGraphicsData *pGd )
{ {
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
(void)pG; (void) pGd;
SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount ); SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount );
pNew->SetSize( nDX, nDY ); pNew->SetSize( nDX, nDY );
return pNew; return pNew;
...@@ -436,6 +437,15 @@ SalBitmap* GtkInstance::CreateSalBitmap() ...@@ -436,6 +437,15 @@ SalBitmap* GtkInstance::CreateSalBitmap()
#endif #endif
} }
SalTimer* GtkInstance::CreateSalTimer()
{
#if GTK_CHECK_VERSION(3,0,0)
return new GtkSalTimer();
#else
return X11SalInstance::CreateSalTimer();
#endif
}
// FIXME: these should all be in a more generic, shared base of unix's salinst.cxx // FIXME: these should all be in a more generic, shared base of unix's salinst.cxx
osl::SolarMutex* GtkInstance::GetYieldMutex() osl::SolarMutex* GtkInstance::GetYieldMutex()
...@@ -486,7 +496,7 @@ bool GtkInstance::CheckYieldMutex() ...@@ -486,7 +496,7 @@ bool GtkInstance::CheckYieldMutex()
void GtkInstance::Yield( bool bWait, bool bHandleAllCurrentEvents ) void GtkInstance::Yield( bool bWait, bool bHandleAllCurrentEvents )
{ {
GetGtkSalData()->GetLib()->Yield( bWait, bHandleAllCurrentEvents ); GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents );
} }
bool GtkInstance::AnyInput( sal_uInt16 nType ) bool GtkInstance::AnyInput( sal_uInt16 nType )
......
...@@ -441,6 +441,7 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, sal_uLong nStyle ) ...@@ -441,6 +441,7 @@ GtkSalFrame::GtkSalFrame( SalFrame* pParent, sal_uLong nStyle )
{ {
m_nScreen = getDisplay()->GetDefaultScreenNumber(); m_nScreen = getDisplay()->GetDefaultScreenNumber();
getDisplay()->registerFrame( this ); getDisplay()->registerFrame( this );
m_nIdleFullScreen = 0;
m_nDuringRender = 0; m_nDuringRender = 0;
m_bDefaultPos = true; m_bDefaultPos = true;
m_bDefaultSize = ( (nStyle & SAL_FRAME_STYLE_SIZEABLE) && ! pParent ); m_bDefaultSize = ( (nStyle & SAL_FRAME_STYLE_SIZEABLE) && ! pParent );
...@@ -457,11 +458,14 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData ) ...@@ -457,11 +458,14 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
#endif #endif
m_bDefaultPos = true; m_bDefaultPos = true;
m_bDefaultSize = true; m_bDefaultSize = true;
m_nIdleFullScreen = 0;
Init( pSysData ); Init( pSysData );
} }
GtkSalFrame::~GtkSalFrame() GtkSalFrame::~GtkSalFrame()
{ {
g_idle_remove_by_data (this);
for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i ) for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i )
{ {
if( !m_aGraphics[i].pGraphics ) if( !m_aGraphics[i].pGraphics )
...@@ -640,9 +644,9 @@ void GtkSalFrame::InitCommon() ...@@ -640,9 +644,9 @@ void GtkSalFrame::InitCommon()
gtk_widget_realize( m_pWindow ); gtk_widget_realize( m_pWindow );
//system data //system data
GtkSalDisplay* pDisp = GetGtkSalData()->GetDisplay();
m_aSystemData.nSize = sizeof( SystemChildData ); m_aSystemData.nSize = sizeof( SystemChildData );
#if !GTK_CHECK_VERSION(3,0,0) #if !GTK_CHECK_VERSION(3,0,0)
GtkSalDisplay* pDisp = GetGtkSalData()->GetDisplay();
m_aSystemData.pDisplay = pDisp->GetDisplay(); m_aSystemData.pDisplay = pDisp->GetDisplay();
m_aSystemData.pVisual = pDisp->GetVisual( m_nScreen ).GetVisual(); m_aSystemData.pVisual = pDisp->GetVisual( m_nScreen ).GetVisual();
m_aSystemData.nDepth = pDisp->GetVisual( m_nScreen ).GetDepth(); m_aSystemData.nDepth = pDisp->GetVisual( m_nScreen ).GetDepth();
...@@ -2335,12 +2339,12 @@ String GtkSalFrame::GetKeyName( sal_uInt16 nKeyCode ) ...@@ -2335,12 +2339,12 @@ String GtkSalFrame::GetKeyName( sal_uInt16 nKeyCode )
GdkDisplay *GtkSalFrame::getGdkDisplay() GdkDisplay *GtkSalFrame::getGdkDisplay()
{ {
return GetGtkSalData()->pDisplay->GetGdkDisplay(); return GetGtkSalData()->GetGdkDisplay();
} }
GtkSalDisplay *GtkSalFrame::getDisplay() GtkSalDisplay *GtkSalFrame::getDisplay()
{ {
return GetGtkSalData()->pDisplay; return GetGtkSalData()->GetDisplay();
} }
SalFrame::SalPointerState GtkSalFrame::GetPointerState() SalFrame::SalPointerState GtkSalFrame::GetPointerState()
...@@ -3180,8 +3184,11 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f ...@@ -3180,8 +3184,11 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f
return sal_False; return sal_False;
} }
IMPL_LINK( GtkSalFrame, ImplDelayedFullScreenHdl, void*, EMPTYARG ) extern "C" {
gboolean implDelayedFullScreenHdl (void *)
{ {
g_warning ("FIXME: nasty delayed full-screen hdl workaround !");
#if 0
#if !GTK_CHECK_VERSION(3,0,0) #if !GTK_CHECK_VERSION(3,0,0)
Atom nStateAtom = getDisplay()->getWMAdaptor()->getAtom(vcl_sal::WMAdaptor::NET_WM_STATE); Atom nStateAtom = getDisplay()->getWMAdaptor()->getAtom(vcl_sal::WMAdaptor::NET_WM_STATE);
Atom nFSAtom = getDisplay()->getWMAdaptor()->getAtom(vcl_sal::WMAdaptor::NET_WM_STATE_FULLSCREEN ); Atom nFSAtom = getDisplay()->getWMAdaptor()->getAtom(vcl_sal::WMAdaptor::NET_WM_STATE_FULLSCREEN );
...@@ -3210,7 +3217,9 @@ IMPL_LINK( GtkSalFrame, ImplDelayedFullScreenHdl, void*, EMPTYARG ) ...@@ -3210,7 +3217,9 @@ IMPL_LINK( GtkSalFrame, ImplDelayedFullScreenHdl, void*, EMPTYARG )
); );
} }
#endif #endif
return 0; #endif
return FALSE;
}
} }
gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame ) gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame )
...@@ -3224,7 +3233,7 @@ gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame ) ...@@ -3224,7 +3233,7 @@ gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame )
/* #i110881# workaorund a gtk issue (see https://bugzilla.redhat.com/show_bug.cgi?id=623191#c8) /* #i110881# workaorund a gtk issue (see https://bugzilla.redhat.com/show_bug.cgi?id=623191#c8)
gtk_window_fullscreen can run into a race condition with the window's showstate gtk_window_fullscreen can run into a race condition with the window's showstate
*/ */
Application::PostUserEvent( LINK( pThis, GtkSalFrame, ImplDelayedFullScreenHdl ) ); g_idle_add_full( G_PRIORITY_HIGH, implDelayedFullScreenHdl, pThis, NULL );
} }
bool bSetFocus = pThis->m_bSetFocusOnMap; bool bSetFocus = pThis->m_bSetFocusOnMap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment