static void _update_input_shape (GtkWidget* window, int width, int height) { static GdkBitmap* pShapeBitmap = NULL; static cairo_t* pCairoContext = NULL; g_return_if_fail (GTK_IS_WINDOW (window)); pShapeBitmap = (GdkBitmap*) gdk_pixmap_new (NULL, width, height, 1); if (pShapeBitmap) { pCairoContext = gdk_cairo_create (pShapeBitmap); if (cairo_status (pCairoContext) == CAIRO_STATUS_SUCCESS) { render_pixmap (pCairoContext, width, height); cairo_destroy (pCairoContext); #if !GTK_CHECK_VERSION(2,9,0) do_shape_combine_mask (window->window, NULL, 0, 0); do_shape_combine_mask (window->window, pShapeBitmap, 0, 0); #else gtk_widget_input_shape_combine_mask (window, NULL, 0, 0); gtk_widget_input_shape_combine_mask (window, pShapeBitmap, 0, 0); #endif } if (pShapeBitmap) g_object_unref ((gpointer) pShapeBitmap); } }
static VALUE rg_input_shape_combine_mask(VALUE self, VALUE shape_mask, VALUE offset_x, VALUE offset_y) { gtk_widget_input_shape_combine_mask(_SELF(self), GDK_BITMAP(RVAL2GOBJ(shape_mask)), NUM2INT(offset_x), NUM2INT(offset_y)); return self; }
static void update_input_shape (GtkWidget* window, gint width, gint height) { GdkBitmap* mask = NULL; cairo_t* cr = NULL; mask = (GdkBitmap*) gdk_pixmap_new (NULL, width, height, 1); if (mask) { cr = gdk_cairo_create (mask); if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) { cairo_scale (cr, 1.0f, 1.0f); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_source_rgb (cr, 1.0f, 1.0f, 1.0f); /* just draw something */ draw_round_rect (cr, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); cairo_fill (cr); cairo_destroy (cr); gtk_widget_input_shape_combine_mask (window,NULL, 0, 0); gtk_widget_input_shape_combine_mask (window,mask, 0, 0); } g_object_unref ((gpointer) mask); } }
void update_input_shape (GtkWidget* pWindow, int iWidth, int iHeight) { static GdkBitmap* pShapeBitmap = NULL; static cairo_t* pCairoContext = NULL; pShapeBitmap = (GdkBitmap*) gdk_pixmap_new (NULL, iWidth, iHeight, 1); if (pShapeBitmap) { pCairoContext = gdk_cairo_create (pShapeBitmap); if (cairo_status (pCairoContext) == CAIRO_STATUS_SUCCESS) { render (pCairoContext, iWidth, iHeight); cairo_destroy (pCairoContext); #if !GTK_CHECK_VERSION(2,9,0) do_shape_combine_mask (pWindow->window, NULL, 0, 0); do_shape_combine_mask (pWindow->window, pShapeBitmap, 0, 0); #else gtk_widget_input_shape_combine_mask (pWindow, NULL, 0, 0); gtk_widget_input_shape_combine_mask (pWindow, pShapeBitmap, 0, 0); #endif } g_object_unref ((gpointer) pShapeBitmap); } }