[gnome-settings-daemon] Use cairo regions to set input shape
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Use cairo regions to set input shape
- Date: Sat, 2 Oct 2010 08:59:06 +0000 (UTC)
commit 6ecff9881e47aafa2715dd3451adf515f0d5230a
Author: William Jon McCann <jmccann redhat com>
Date: Wed Sep 29 19:42:56 2010 -0400
Use cairo regions to set input shape
Instead of bitmasks.
https://bugzilla.gnome.org/show_bug.cgi?id=630975
plugins/common/gsd-osd-window.c | 21 ++----------
plugins/mouse/gsd-locate-pointer.c | 61 ++++++++++++++++--------------------
2 files changed, 31 insertions(+), 51 deletions(-)
---
diff --git a/plugins/common/gsd-osd-window.c b/plugins/common/gsd-osd-window.c
index 223d6a9..d36c550 100644
--- a/plugins/common/gsd-osd-window.c
+++ b/plugins/common/gsd-osd-window.c
@@ -378,9 +378,7 @@ gsd_osd_window_real_hide (GtkWidget *widget)
static void
gsd_osd_window_real_realize (GtkWidget *widget)
{
- GtkAllocation allocation;
- GdkBitmap *mask;
- cairo_t *cr;
+ cairo_region_t *region;
GdkScreen *screen;
GdkVisual *visual;
@@ -396,21 +394,10 @@ gsd_osd_window_real_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gsd_osd_window_parent_class)->realize (widget);
}
- gtk_widget_get_allocation (widget, &allocation);
- mask = gdk_pixmap_new (gtk_widget_get_window (widget),
- allocation.width,
- allocation.height,
- 1);
- cr = gdk_cairo_create (mask);
-
- cairo_set_source_rgba (cr, 1., 1., 1., 0.);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
-
/* make the whole window ignore events */
- gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0);
- g_object_unref (mask);
- cairo_destroy (cr);
+ region = cairo_region_create ();
+ gtk_widget_input_shape_combine_region (widget, region);
+ cairo_region_destroy (region);
}
static void
diff --git a/plugins/mouse/gsd-locate-pointer.c b/plugins/mouse/gsd-locate-pointer.c
index 820d3d3..e9413b8 100644
--- a/plugins/mouse/gsd-locate-pointer.c
+++ b/plugins/mouse/gsd-locate-pointer.c
@@ -61,7 +61,9 @@ locate_pointer_paint (GsdLocatePointerData *data,
GtkStyle *style;
progress = data->progress;
- gdk_drawable_get_size (data->window, &width, &height);
+
+ width = gdk_window_get_width (data->window);
+ height = gdk_window_get_height (data->window);
style = gtk_widget_get_style (data->widget);
color = style->bg[GTK_STATE_SELECTED];
@@ -141,14 +143,20 @@ static void
update_shape (GsdLocatePointerData *data)
{
cairo_t *cr;
- GdkBitmap *mask;
+ cairo_region_t *region;
+ cairo_surface_t *mask;
+
+ mask = cairo_image_surface_create (CAIRO_FORMAT_A1, WINDOW_SIZE, WINDOW_SIZE);
+ cr = cairo_create (mask);
+
+ region = gdk_cairo_region_create_from_surface (mask);
- mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);
- cr = gdk_cairo_create (mask);
locate_pointer_paint (data, cr, FALSE);
- gdk_window_shape_combine_mask (data->window, mask, 0, 0);
- g_object_unref (mask);
+ gdk_window_shape_combine_region (data->window, region, 0, 0);
+
+ cairo_region_destroy (region);
cairo_destroy (cr);
+ cairo_surface_destroy (mask);
}
static void
@@ -173,7 +181,7 @@ timeline_frame_cb (GsdTimeline *timeline,
data->progress += CIRCLES_PROGRESS_INTERVAL;
}
- screen = gdk_drawable_get_screen (data->window);
+ screen = gdk_window_get_screen (data->window);
gdk_window_get_pointer (gdk_screen_get_root_window (screen),
&cursor_x, &cursor_y, NULL);
gdk_window_move (data->window,
@@ -184,25 +192,23 @@ timeline_frame_cb (GsdTimeline *timeline,
static void
set_transparent_shape (GdkWindow *window)
{
- GdkBitmap *mask;
- cairo_t *cr;
-
- mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);
- cr = gdk_cairo_create (mask);
+ cairo_rectangle_int_t rect;
+ cairo_region_t *region;
- cairo_set_source_rgba (cr, 1., 1., 1., 0.);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
+ rect.width = WINDOW_SIZE;
+ rect.height = WINDOW_SIZE;
+ rect.x = 0;
+ rect.y = 0;
+ region = cairo_region_create_rectangle (&rect);
- gdk_window_shape_combine_mask (data->window, mask, 0, 0);
- g_object_unref (mask);
- cairo_destroy (cr);
+ gdk_window_input_shape_combine_region (data->window, region, 0, 0);
+ cairo_region_destroy (region);
}
static void
unset_transparent_shape (GdkWindow *window)
{
- gdk_window_shape_combine_mask (data->window, NULL, 0, 0);
+ gdk_window_shape_combine_region (data->window, NULL, 0, 0);
}
static void
@@ -293,8 +299,6 @@ move_locate_pointer_window (GsdLocatePointerData *data,
GdkScreen *screen)
{
gint cursor_x, cursor_y;
- GdkBitmap *mask;
- cairo_t *cr;
gdk_window_get_pointer (gdk_screen_get_root_window (screen), &cursor_x, &cursor_y, NULL);
@@ -303,19 +307,8 @@ move_locate_pointer_window (GsdLocatePointerData *data,
cursor_y - WINDOW_SIZE / 2,
WINDOW_SIZE, WINDOW_SIZE);
- mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);
-
-
- cr = gdk_cairo_create (mask);
- cairo_set_source_rgb (cr, 0., 0., 0.);
- cairo_rectangle (cr, 0., 0., WINDOW_SIZE, WINDOW_SIZE);
- cairo_fill (cr);
- cairo_destroy (cr);
-
/* allow events to happen through the window */
- gdk_window_input_shape_combine_mask (data->window, mask, 0, 0);
-
- g_object_unref (mask);
+ gdk_window_input_shape_combine_region (data->window, NULL, 0, 0);
}
void
@@ -328,7 +321,7 @@ gsd_locate_pointer (GdkScreen *screen)
gsd_timeline_rewind (data->timeline);
/* Create again the window if it is not for the current screen */
- if (gdk_screen_get_number (screen) != gdk_screen_get_number (gdk_drawable_get_screen (data->window)))
+ if (gdk_screen_get_number (screen) != gdk_screen_get_number (gdk_window_get_screen (data->window)))
{
gdk_window_set_user_data (data->window, NULL);
gdk_window_destroy (data->window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]