[Libreoffice-commits] .: Branch 'feature/gtk3' - vcl/inc vcl/Library_vclplug_gtk3.mk vcl/unx
Michael Meeks
michael at kemper.freedesktop.org
Fri Jul 1 12:53:33 PDT 2011
vcl/Library_vclplug_gtk3.mk | 3 +
vcl/inc/unx/gtk/gtkdata.hxx | 33 ++++++++++++++++++
vcl/inc/unx/gtk/gtkinst.hxx | 17 +++++++++
vcl/unx/gtk/app/gtkdata.cxx | 40 +++-------------------
vcl/unx/gtk/app/gtkinst.cxx | 71 ++++++++++++++++++++++++++++++++++++++++
vcl/unx/gtk/window/gtkframe.cxx | 13 +++----
vcl/unx/headless/svpinst.cxx | 6 +++
7 files changed, 143 insertions(+), 40 deletions(-)
New commits:
commit bcf5a26d1c8a5615e842afa53ef9f93e5ab34c97
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri Jul 1 20:24:10 2011 +0100
misc bug fixes, more shocking cut/paste to finally making things semi work.
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index bb6af40..88dbaed 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -126,7 +126,10 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
vcl/unx/gtk3/window/gtk3gtkframe \
vcl/unx/gtk3/window/gtk3gtkobject \
vcl/unx/headless/svpbmp \
+ vcl/unx/headless/svpdummies \
vcl/unx/headless/svpelement \
+ vcl/unx/headless/svpframe \
+ vcl/unx/headless/svpprn \
vcl/unx/headless/svptext \
vcl/unx/headless/svpvd \
))
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index 14b1eba..ad7ac8f 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -38,6 +38,7 @@
#include <unx/saldisp.hxx>
#include <unx/saldata.hxx>
#include <vcl/ptrstyle.hxx>
+#include <osl/conditn.h>
#include <list>
@@ -77,6 +78,37 @@ inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
#endif
}
+class GtkXLib : public SalXLib
+{
+ GtkSalDisplay *m_pGtkSalDisplay;
+ std::list<GSource *> m_aSources;
+ GSource *m_pTimeout;
+ GSource *m_pUserEvent;
+ oslMutex m_aDispatchMutex;
+ oslCondition m_aDispatchCondition;
+ XIOErrorHandler m_aOrigGTKXIOErrorHandler;
+
+public:
+ static gboolean timeoutFn(gpointer data);
+ static gboolean userEventFn(gpointer data);
+
+ GtkXLib();
+ virtual ~GtkXLib();
+
+ 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) && !defined GTK3_X11_RENDER
class GtkData : public SalData
#else
@@ -96,6 +128,7 @@ public:
GtkSalDisplay *GetDisplay() { return pDisplay; }
#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
GtkXLib *pXLib_;
+ SalXLib *GetLib() { return pXLib_; }
#endif
};
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 2d34cc7..0e01b77 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -31,6 +31,7 @@
#include <unx/salinst.h>
#include <unx/salsys.h>
+#include <unx/headless/svpinst.hxx>
#include <gtk/gtk.h>
class GtkYieldMutex : public SalYieldMutex
@@ -78,11 +79,20 @@ public:
#define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) )
+#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
+class GtkInstance : public SvpSalInstance
+{
+ SalYieldMutex *mpSalYieldMutex;
+public:
+ GtkInstance( SalYieldMutex* pMutex )
+ : SvpSalInstance(), mpSalYieldMutex( pMutex )
+#else
class GtkInstance : public X11SalInstance
{
public:
GtkInstance( SalYieldMutex* pMutex )
: X11SalInstance( pMutex )
+#endif
{}
virtual ~GtkInstance();
@@ -96,6 +106,13 @@ public:
sal_uInt16 nBitCount,
const SystemGraphicsData* );
virtual SalBitmap* CreateSalBitmap();
+
+ virtual osl::SolarMutex* GetYieldMutex();
+ virtual sal_uIntPtr ReleaseYieldMutex();
+ virtual void AcquireYieldMutex( sal_uIntPtr nCount );
+ virtual bool CheckYieldMutex();
+ virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
+ virtual bool AnyInput( sal_uInt16 nType );
};
#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 6c2f946..b8e2a18 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -54,7 +54,6 @@
#include <osl/thread.h>
#include <osl/process.h>
-#include <osl/conditn.h>
#include <tools/debug.hxx>
#include "unx/i18n_im.hxx"
#include "unx/i18n_xkb.hxx"
@@ -92,6 +91,7 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
m_aCursors[ i ] = NULL;
#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
m_pCapture = NULL;
+ hEventGuard_ = osl_createMutex();
#else
m_bUseRandRWrapper = false; // use gdk signal instead
Init ();
@@ -118,6 +118,9 @@ GtkSalDisplay::~GtkSalDisplay()
for(int i = 0; i < POINTER_COUNT; i++)
if( m_aCursors[ i ] )
gdk_cursor_unref( m_aCursors[ i ] );
+
+ osl_destroyMutex( hEventGuard_ );
+ hEventGuard_ = NULL;
}
void GtkSalDisplay::errorTrapPush()
@@ -642,37 +645,6 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
* class GtkXLib *
***************************************************************************/
-class GtkXLib : public SalXLib
-{
- GtkSalDisplay *m_pGtkSalDisplay;
- std::list<GSource *> m_aSources;
- GSource *m_pTimeout;
- GSource *m_pUserEvent;
- oslMutex m_aDispatchMutex;
- oslCondition m_aDispatchCondition;
- XIOErrorHandler m_aOrigGTKXIOErrorHandler;
-
-public:
- static gboolean timeoutFn(gpointer data);
- static gboolean userEventFn(gpointer data);
-
- GtkXLib();
- virtual ~GtkXLib();
-
- 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();
-};
-
GtkXLib::GtkXLib()
{
#if OSL_DEBUG_LEVEL > 1
@@ -809,12 +781,12 @@ void GtkXLib::Init()
rtl::OUString envValue(name, strlen(name), aEnc);
osl_setEnvironment(envVar.pData, envValue.pData);
- Display *pDisp = gdk_x11_display_get_xdisplay( pGdkDisp );
-
m_pGtkSalDisplay = new GtkSalDisplay( pGdkDisp );
GetGtkSalData()->pDisplay = m_pGtkSalDisplay;
#if !GTK_CHECK_VERSION(3,0,0)
+ Display *pDisp = gdk_x11_display_get_xdisplay( pGdkDisp );
+
m_pGtkSalDisplay->errorTrapPush();
SalI18N_KeyboardExtension *pKbdExtension = new SalI18N_KeyboardExtension( pDisp );
XSync( pDisp, False );
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index 81135fb..0462b8f 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -436,4 +436,75 @@ SalBitmap* GtkInstance::CreateSalBitmap()
#endif
}
+// FIXME: these should all be in a more generic, shared base of unix's salinst.cxx
+
+osl::SolarMutex* GtkInstance::GetYieldMutex()
+{
+ return mpSalYieldMutex;
+}
+
+sal_uIntPtr GtkInstance::ReleaseYieldMutex()
+{
+ SalYieldMutex* pYieldMutex = mpSalYieldMutex;
+ if ( pYieldMutex->GetThreadId() ==
+ osl::Thread::getCurrentIdentifier() )
+ {
+ sal_uLong nCount = pYieldMutex->GetAcquireCount();
+ sal_uLong n = nCount;
+ while ( n )
+ {
+ pYieldMutex->release();
+ n--;
+ }
+
+ return nCount;
+ }
+ else
+ return 0;
+}
+
+void GtkInstance::AcquireYieldMutex( sal_uIntPtr nCount )
+{
+ SalYieldMutex* pYieldMutex = mpSalYieldMutex;
+ while ( nCount )
+ {
+ pYieldMutex->acquire();
+ nCount--;
+ }
+}
+
+bool GtkInstance::CheckYieldMutex()
+{
+ bool bRet = true;
+
+ SalYieldMutex* pYieldMutex = mpSalYieldMutex;
+ if ( pYieldMutex->GetThreadId() != osl::Thread::getCurrentIdentifier() )
+ bRet = false;
+
+ return bRet;
+}
+
+void GtkInstance::Yield( bool bWait, bool bHandleAllCurrentEvents )
+{
+ GetGtkSalData()->GetLib()->Yield( bWait, bHandleAllCurrentEvents );
+}
+
+bool GtkInstance::AnyInput( sal_uInt16 nType )
+{
+#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
+ g_warning ("any input returning false");
+ return false;
+#else
+ return X11SalInstance::AnyInput( nType );
+#endif
+}
+
+// FIXME: these above should all be in a more generic, shared base of unix's salinst.cxx
+
+
+#if GTK_CHECK_VERSION(3,0,0) && !defined GTK3_X11_RENDER
+#define GTK3_INCLUDED
+#include "../../headless/svpinst.cxx"
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index fe2e6a2..c6f9e37 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -494,16 +494,16 @@ GtkSalFrame::~GtkSalFrame()
delete m_pIMHandler;
if( m_pFixedContainer )
- gtk_widget_destroy( GTK_WIDGET(m_pFixedContainer) );
+ gtk_widget_destroy( GTK_WIDGET( m_pFixedContainer ) );
if( m_pWindow )
{
g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", NULL );
gtk_widget_destroy( m_pWindow );
}
if( m_pForeignParent )
- g_object_unref( G_OBJECT(m_pForeignParent) );
+ g_object_unref( G_OBJECT( m_pForeignParent ) );
if( m_pForeignTopLevel )
- g_object_unref(G_OBJECT( m_pForeignTopLevel) );
+ g_object_unref( G_OBJECT( m_pForeignTopLevel) );
}
void GtkSalFrame::moveWindow( long nX, long nY )
@@ -655,8 +655,8 @@ void GtkSalFrame::InitCommon()
m_aSystemData.pVisual = pDisp->GetVisual( m_nScreen ).GetVisual();
m_aSystemData.nDepth = pDisp->GetVisual( m_nScreen ).GetDepth();
m_aSystemData.aColormap = pDisp->GetColormap( m_nScreen ).GetXColormap();
-#endif
m_aSystemData.aWindow = GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow));
+#endif
m_aSystemData.pSalFrame = this;
m_aSystemData.pWidget = m_pWindow;
m_aSystemData.nScreen = m_nScreen;
@@ -1106,6 +1106,7 @@ void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
sal_Bool GtkSalFrame::PostEvent( void* pData )
{
+ g_warning ("post event");
getDisplay()->SendInternalEvent( this, pData );
return sal_True;
}
@@ -2616,9 +2617,9 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
if( m_pWindow )
gtk_widget_destroy( m_pWindow );
if( m_pForeignParent )
- g_object_unref( G_OBJECT(m_pForeignParent) );
+ g_object_unref( G_OBJECT( m_pForeignParent ) );
if( m_pForeignTopLevel )
- g_object_unref( G_OBJECT(m_pForeignTopLevel) );
+ g_object_unref( G_OBJECT( m_pForeignTopLevel ) );
// init new window
m_bDefaultPos = m_bDefaultSize = false;
diff --git a/vcl/unx/headless/svpinst.cxx b/vcl/unx/headless/svpinst.cxx
index 3adb5ce..546ed6a 100644
--- a/vcl/unx/headless/svpinst.cxx
+++ b/vcl/unx/headless/svpinst.cxx
@@ -46,6 +46,8 @@
#include <saldatabasic.hxx>
#include <vcl/solarmutex.hxx>
+// FIXME: split off into a separate, standalone module to aid linking
+#ifndef GTK3_INCLUDED
// plugin factory function
extern "C"
{
@@ -58,6 +60,7 @@ extern "C"
return pInstance;
}
}
+#endif
bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const
{
@@ -188,6 +191,8 @@ void SvpSalInstance::Wakeup()
OSL_VERIFY(write (m_pTimeoutFDS[1], "", 1) == 1);
}
+// FIXME: share this with unx/generic [!] ....
+#ifndef GTK3_INCLUDED
// -=-= timeval =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
inline int operator >= ( const timeval &t1, const timeval &t2 )
{
@@ -212,6 +217,7 @@ inline int operator > ( const timeval &t1, const timeval &t2 )
return t1.tv_usec > t2.tv_usec;
return t1.tv_sec > t2.tv_sec;
}
+#endif
bool SvpSalInstance::CheckTimeout( bool bExecuteTimers )
{
More information about the Libreoffice-commits
mailing list