summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-06-14 14:29:11 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-06-14 16:34:05 +0100
commita410181efa2082b7ac1697f9aa62bc56b59234d4 (patch)
tree93886e0ef509f4d60b76349696d3606897fa041f /vcl
parent4b97ec3b5a846467d8c0bb9fa48cf704f3f7725c (diff)
Various fixes and stubs for gtk+ >= 3.0
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vclplug_gtk3.mk1
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx12
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx16
-rw-r--r--vcl/unx/gtk/app/gtkdata.cxx28
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx36
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx29
6 files changed, 117 insertions, 5 deletions
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 7fff2633f616..83fb8306468d 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -114,7 +114,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
vcl/unx/gtk3/app/gtk3gtkdata \
vcl/unx/gtk3/app/gtk3gtkinst \
vcl/unx/gtk3/app/gtk3gtksys \
- vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \
vcl/unx/gtk3/window/gtk3gtkframe \
vcl/unx/gtk3/window/gtk3gtkobject \
))
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 1bc3fc8b4346..de87c4b173c5 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -30,9 +30,12 @@
#define _VCL_GTKFRAME_HXX
#include <tools/prex.h>
-#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3,0,0)
+# include <gtk/gtkx.h>
+#endif
#include <gdk/gdkkeysyms.h>
#include <tools/postx.h>
@@ -47,6 +50,13 @@
class GtkSalGraphics;
class GtkSalDisplay;
+#if GTK_CHECK_VERSION(3,0,0)
+typedef XLIB_Window GdkNativeWindow;
+#define GDK_WINDOW_XWINDOW(o) GDK_WINDOW_XID(o)
+#define gdk_set_sm_client_id(i) gdk_x11_set_sm_client_id(i)
+#define gdk_window_foreign_new_for_display(a,b) gdk_x11_window_foreign_new_for_display(a,b)
+#endif
+
class GtkSalFrame : public SalFrame
{
static const int nMaxGraphics = 2;
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 9c22f016c87c..41e500c49027 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -37,13 +37,25 @@
#include <unx/salgdi.h>
+#if GTK_CHECK_VERSION(3,0,0)
+
+// Disabled for gtk3 - use legacy theming code
+#define GTK_GRAPHICS_DISABLED
+class GtkSalFrame;
+class GtkSalGraphics : public X11SalGraphics {
+public:
+ GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
+};
+
+#else
+
class GtkSalGraphics : public X11SalGraphics
{
GtkWidget *m_pWindow;
Region m_aClipRegion;
public:
- GtkSalGraphics( GtkWidget *window )
+ GtkSalGraphics( GtkSalFrame *, GtkWidget *window )
: m_pWindow( window ),
m_aClipRegion( REGION_NULL )
{}
@@ -183,6 +195,8 @@ protected:
const OUString& rCaption );
};
+#endif // !gtk3
+
#endif // _VCL_GTKGDI_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index c2c0b54faf78..0a71ad01dab0 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -286,9 +286,16 @@ void GtkSalDisplay::initScreen( int nScreen ) const
// choose visual for screen
SalDisplay::initScreen( nScreen );
+
+#if GTK_CHECK_VERSION(3,0,0)
+ // no colormaps handling in gtk 3
+#else
// now set a gdk default colormap matching the chosen visual to the screen
- GdkVisual* pVis = gdkx_visual_get( rSD.m_aVisual.visualid );
GdkScreen* pScreen = gdk_display_get_screen( m_pGdkDisplay, nScreen );
+// should really use this:
+// GdkVisual* pVis = gdk_x11_screen_lookup_visual_get( screen, rSD.m_aVisual.visualid );
+// and not this:
+ GdkVisual* pVis = gdkx_visual_get( rSD.m_aVisual.visualid );
if( pVis )
{
GdkColormap* pDefCol = gdk_screen_get_default_colormap( pScreen );
@@ -306,6 +313,7 @@ void GtkSalDisplay::initScreen( int nScreen ) const
else
fprintf( stderr, "not GdkVisual for visual id %d\n", (int)rSD.m_aVisual.visualid );
#endif
+#endif
}
long GtkSalDisplay::Dispatch( XEvent* pEvent )
@@ -330,6 +338,21 @@ GdkCursor* GtkSalDisplay::getFromXPM( const unsigned char *pBitmap,
int nWidth, int nHeight,
int nXHot, int nYHot )
{
+#if GTK_CHECK_VERSION(3,0,0)
+ g_warning ("FIXME: to use gdk_cursor_new_from_pixbuf instead of spiders");
+ // We need to do something like:
+ /*
+ GdkPixbuf *pPix = gdk_pixbuf_new_from_xpm_data (pBitmap);
+ GdkPixbuf *pMask = gdk_pixbuf_new_from_xpm_data (pMask);
+
+ GdkCursor* gdk_cursor_new_from_pixbuf (GdkDisplay *display,
+ GdkPixbuf *pixbuf,
+ gint x,
+ gint y);
+ */
+ return gdk_cursor_new_for_display (gdk_display_get_default(),
+ GDK_SPIDER);
+#else
GdkScreen *pScreen = gdk_display_get_default_screen( m_pGdkDisplay );
GdkDrawable *pDrawable = GDK_DRAWABLE( gdk_screen_get_root_window (pScreen) );
GdkBitmap *pBitmapPix = gdk_bitmap_create_from_data
@@ -347,6 +370,7 @@ GdkCursor* GtkSalDisplay::getFromXPM( const unsigned char *pBitmap,
return gdk_cursor_new_from_pixmap
( pBitmapPix, pMaskPix,
&aBlack, &aWhite, nXHot, nYHot);
+#endif
}
#define MAKE_CURSOR( vcl_name, name ) \
@@ -590,7 +614,9 @@ void GtkXLib::Init()
#endif
XrmInitialize();
+#if !GTK_CHECK_VERSION(3,0,0)
gtk_set_locale();
+#endif
/*
* open connection to X11 Display
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index 95547f20d933..69d3245dd15a 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -161,7 +161,11 @@ extern "C"
if ( hookLocks( pModule ) )
pYieldMutex = new GtkHookedYieldMutex();
else
+#if GTK_CHECK_VERSION(3,0,0)
+ g_error ("impossible case for gtk3");
+#else
pYieldMutex = new GtkYieldMutex();
+#endif
gdk_threads_init();
@@ -251,12 +255,23 @@ void GtkInstance::AddToRecentDocumentList(const rtl::OUString& rFileUrl, const r
#endif
}
+
+/*
+ * Obsolete, non-working, and crufty code from the
+ * beginning of time. When we update our base platform
+ * we should kill this with extreme prejudice.
+ */
+#if !GTK_CHECK_VERSION(3,0,0)
+# define HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
+#endif
+
GtkYieldMutex::GtkYieldMutex()
{
}
void GtkYieldMutex::acquire()
{
+#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier();
// protect member manipulation
SolarMutexObject::acquire();
@@ -276,10 +291,14 @@ void GtkYieldMutex::acquire()
mnCount = 1;
mnThreadId = aCurrentThread;
SolarMutexObject::release();
+#else
+ g_error ("never called");
+#endif
}
void GtkYieldMutex::release()
{
+#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier();
// protect member manipulation
SolarMutexObject::acquire();
@@ -294,10 +313,14 @@ void GtkYieldMutex::release()
}
}
SolarMutexObject::release();
+#else
+ g_error ("never called");
+#endif
}
sal_Bool GtkYieldMutex::tryToAcquire()
{
+#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier();
// protect member manipulation
SolarMutexObject::acquire();
@@ -328,11 +351,15 @@ sal_Bool GtkYieldMutex::tryToAcquire()
mnThreadId = aCurrentThread;
SolarMutexObject::release();
+#else
+ g_error ("never called");
+#endif
return sal_True;
}
int GtkYieldMutex::Grab()
{
+#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
// this MUST only be called by gdk/gtk callbacks:
// they are entered with gdk mutex locked; the mutex
// was unlocked by GtkYieldMutex befor yielding which
@@ -353,10 +380,15 @@ int GtkYieldMutex::Grab()
mnCount = 1;
SolarMutexObject::release();
return nRet;
+#else
+ g_error ("never called");
+ return sal_True;
+#endif
}
void GtkYieldMutex::Ungrab( int nGrabs )
{
+#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL
// this MUST only be called when leaving the callback
// that locked the mutex with Grab()
SolarMutexObject::acquire();
@@ -364,6 +396,10 @@ void GtkYieldMutex::Ungrab( int nGrabs )
if( mnCount == 0 )
mnThreadId = 0;
SolarMutexObject::release();
+#else
+ (void)nGrabs;
+ g_error ("never called");
+#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 9ade3ce1b855..9303c6478a71 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -65,6 +65,10 @@
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
+#if GTK_CHECK_VERSION(3,0,0)
+# include <gdk/gdkkeysyms-compat.h>
+#endif
+
#ifdef ENABLE_DBUS
#include <dbus/dbus-glib.h>
@@ -933,7 +937,11 @@ void GtkSalFrame::Init( SystemParentData* pSysData )
if( pSysData->nSize > sizeof(pSysData->nSize)+sizeof(pSysData->aWindow) && pSysData->bXEmbedSupport )
{
+#if GTK_CHECK_VERSION(3,0,0)
+ m_pWindow = gtk_plug_new_for_display( getGdkDisplay(), pSysData->aWindow );
+#else
m_pWindow = gtk_plug_new( pSysData->aWindow );
+#endif
m_bWindowIsGtkPlug = true;
widget_set_can_default( m_pWindow, true );
widget_set_can_focus( m_pWindow, true );
@@ -1010,7 +1018,7 @@ SalGraphics* GtkSalFrame::GetGraphics()
m_aGraphics[i].bInUse = true;
if( ! m_aGraphics[i].pGraphics )
{
- m_aGraphics[i].pGraphics = new GtkSalGraphics( m_pWindow );
+ m_aGraphics[i].pGraphics = new GtkSalGraphics( this, m_pWindow );
m_aGraphics[i].pGraphics->Init( this, GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)), m_nScreen );
}
return m_aGraphics[i].pGraphics;
@@ -2357,7 +2365,9 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
bFreeGraphics = true;
}
+#ifndef GTK_GRAPHICS_DISABLED
pGraphics->updateSettings( rSettings );
+#endif
if( bFreeGraphics )
ReleaseGraphics( pGraphics );
@@ -2476,7 +2486,9 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
if( m_aGraphics[i].bInUse )
{
m_aGraphics[i].pGraphics->SetDrawable( GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)), m_nScreen );
+#ifndef GTK_GRAPHICS_DISABLED
m_aGraphics[i].pGraphics->SetWindow( m_pWindow );
+#endif
}
}
@@ -3229,12 +3241,14 @@ void GtkSalFrame::signalStyleSet( GtkWidget*, GtkStyle* pPrevious, gpointer fram
pThis->m_hBackgroundPixmap );
}
+#ifndef GTK_GRAPHICS_DISABLED
if( ! pThis->m_pParent )
{
// signalize theme changed for NWF caches
// FIXME: should be called only once for a style change
GtkSalGraphics::bThemeChanged = sal_True;
}
+#endif
}
gboolean GtkSalFrame::signalState( GtkWidget*, GdkEvent* pEvent, gpointer frame )
@@ -3838,4 +3852,17 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
return sal_False;
}
+#ifdef GTK_GRAPHICS_DISABLED
+
+void GtkData::initNWF() {}
+void GtkData::deInitNWF() {}
+
+GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
+ : X11SalGraphics()
+{
+ Init( pFrame, GDK_WINDOW_XID( widget_get_window( pWindow ) ),
+ gdk_x11_screen_get_screen_number( gtk_widget_get_screen( pWindow ) ) );
+}
+
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */