[Libreoffice-commits] .: 2 commits - vcl/inc vcl/unx
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Jun 15 08:49:33 PDT 2011
vcl/inc/unx/gtk/gtkdata.hxx | 2 -
vcl/unx/gtk/app/gtkdata.cxx | 75 ++++++++++++++++++++++++++++++++--------
vcl/unx/gtk/window/gtkframe.cxx | 2 +
3 files changed, 63 insertions(+), 16 deletions(-)
New commits:
commit ed80b7abf6bedbcebb0afc5f755fe9eb25fdc5a4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 15 16:45:09 2011 +0100
they are xbms, not xpms, hence my bafflement
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index a14782c..0ec802d 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -95,7 +95,7 @@ class GtkSalDisplay : public SalDisplay
bool m_bStartupCompleted;
std::vector< int > m_aXineramaScreenIndexMap;
- GdkCursor* getFromXPM( const unsigned char *pBitmap, const unsigned char *pMask,
+ GdkCursor* getFromXBM( const unsigned char *pBitmap, const unsigned char *pMask,
int nWidth, int nHeight, int nXHot, int nYHot );
public:
GtkSalDisplay( GdkDisplay* pDisplay );
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 4fbf0f1..225af85 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -362,7 +362,7 @@ namespace
}
#endif
-GdkCursor* GtkSalDisplay::getFromXPM( const unsigned char *pBitmap,
+GdkCursor* GtkSalDisplay::getFromXBM( const unsigned char *pBitmap,
const unsigned char *pMask,
int nWidth, int nHeight,
int nXHot, int nYHot )
@@ -420,7 +420,7 @@ GdkCursor* GtkSalDisplay::getFromXPM( const unsigned char *pBitmap,
#define MAKE_CURSOR( vcl_name, name ) \
case vcl_name: \
- pCursor = getFromXPM( name##curs##_bits, name##mask##_bits, \
+ pCursor = getFromXBM( name##curs##_bits, name##mask##_bits, \
name##curs_width, name##curs_height, \
name##curs_x_hot, name##curs_y_hot ); \
break
commit 590e17a62c740b4488f4ecabef836e58d2cbf7ce
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 15 16:42:27 2011 +0100
figure out how to make new-style cursors from ye-oldy xbms
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 2be7c84..4fbf0f1 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -333,25 +333,70 @@ long GtkSalDisplay::Dispatch( XEvent* pEvent )
return GDK_FILTER_CONTINUE;
}
+#if GTK_CHECK_VERSION(3,0,0)
+namespace
+{
+ //cairo annoyingly won't take raw xbm data unless it fits
+ //the required cairo stride
+ unsigned char* ensurePaddedForCairo(const unsigned char *pXBM,
+ int nWidth, int nHeight, int nStride)
+ {
+ unsigned char *pPaddedXBM = const_cast<unsigned char*>(pXBM);
+
+ int bytes_per_row = (nWidth + 7) / 8;
+
+ if (nStride != bytes_per_row)
+ {
+ pPaddedXBM = new unsigned char[nStride * nHeight];
+ for (int row = 0; row < nHeight; ++row)
+ {
+ memcpy(pPaddedXBM + (nStride * row),
+ pXBM + (bytes_per_row * row), bytes_per_row);
+ memset(pPaddedXBM + (nStride * row) + bytes_per_row,
+ 0, nStride - bytes_per_row);
+ }
+ }
+
+ return pPaddedXBM;
+ }
+}
+#endif
+
GdkCursor* GtkSalDisplay::getFromXPM( const unsigned char *pBitmap,
const unsigned char *pMask,
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);
+ int cairo_stride = cairo_format_stride_for_width(CAIRO_FORMAT_A1, nWidth);
+
+ unsigned char *pPaddedXBM = ensurePaddedForCairo(pBitmap, nWidth, nHeight, cairo_stride);
+ cairo_surface_t *s = cairo_image_surface_create_for_data(
+ pPaddedXBM,
+ CAIRO_FORMAT_A1, nWidth, nHeight,
+ cairo_stride);
+
+ cairo_t *cr = cairo_create(s);
+ unsigned char *pPaddedMaskXBM = ensurePaddedForCairo(pMask, nWidth, nHeight, cairo_stride);
+ cairo_surface_t *mask = cairo_image_surface_create_for_data(
+ pPaddedMaskXBM,
+ CAIRO_FORMAT_A1, nWidth, nHeight,
+ cairo_stride);
+ cairo_mask_surface(cr, mask, 0, 0);
+ cairo_destroy(cr);
+ cairo_surface_destroy(mask);
+ if (pPaddedMaskXBM != pMask)
+ delete [] pPaddedMaskXBM;
+
+ GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(s, 0, 0, nWidth, nHeight);
+ cairo_surface_destroy(s);
+ if (pPaddedXBM != pBitmap)
+ delete [] pPaddedXBM;
+
+ GdkCursor *cursor = gdk_cursor_new_from_pixbuf(m_pGdkDisplay, pixbuf, nXHot, nYHot);
+ g_object_unref(pixbuf);
+
+ return cursor;
#else
GdkScreen *pScreen = gdk_display_get_default_screen( m_pGdkDisplay );
GdkDrawable *pDrawable = GDK_DRAWABLE( gdk_screen_get_root_window (pScreen) );
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index fc95365..ac71570 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -2371,6 +2371,8 @@ void GtkSalFrame::UpdateSettings( AllSettings& rSettings )
#ifndef GTK_GRAPHICS_DISABLED
pGraphics->updateSettings( rSettings );
+#else
+ (void)rSettings;
#endif
if( bFreeGraphics )
More information about the Libreoffice-commits
mailing list