From 0ce19eed083c79c5fb4091db3ecaf528346e610f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 21 Mar 2018 03:42:34 +0100 Subject: [PATCH] gdk: Remove gdk_surface_shape_combine_region() If you want transparent region, you can just render them transparent. If you want input shaping, use gdk_surface_input_shape_combine_region(). Also remove gtk_widget_shape_combine_region(). --- docs/reference/gdk/gdk4-sections.txt | 4 - docs/reference/gtk/gtk4-sections.txt | 1 - gdk/gdkinternals.h | 2 - gdk/gdksurface.c | 194 --------------------------- gdk/gdksurface.h | 32 ----- gtk/gtkpopover.c | 4 +- gtk/gtktreeview.c | 11 -- gtk/gtkwidget.c | 58 -------- gtk/gtkwidget.h | 3 - gtk/gtkwidgetprivate.h | 1 - 10 files changed, 2 insertions(+), 308 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index e3383e9c30..6492cd2f0e 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -193,7 +193,6 @@ gdk_surface_is_destroyed gdk_surface_is_visible gdk_surface_is_viewable gdk_surface_is_input_only -gdk_surface_is_shaped gdk_surface_get_state gdk_surface_withdraw gdk_surface_iconify @@ -252,9 +251,6 @@ gdk_surface_set_accept_focus gdk_surface_get_accept_focus gdk_surface_set_focus_on_map gdk_surface_get_focus_on_map -gdk_surface_shape_combine_region -gdk_surface_set_child_shapes -gdk_surface_merge_child_shapes gdk_surface_input_shape_combine_region gdk_surface_set_child_input_shapes gdk_surface_merge_child_input_shapes diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 6d1c4b6225..eea8e368b9 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4254,7 +4254,6 @@ GtkTextDirection gtk_widget_get_direction gtk_widget_set_default_direction gtk_widget_get_default_direction -gtk_widget_shape_combine_region gtk_widget_input_shape_combine_region gtk_widget_create_pango_context gtk_widget_get_pango_context diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 555fdaf93f..40f13969ad 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -197,7 +197,6 @@ struct _GdkSurface guint accept_focus : 1; guint focus_on_map : 1; - guint shaped : 1; guint support_multidevice : 1; guint synthesize_crossing_event_queued : 1; guint viewable : 1; /* mapped and all parents mapped */ @@ -226,7 +225,6 @@ struct _GdkSurface GdkCursor *cursor; GHashTable *device_cursor; - cairo_region_t *shape; cairo_region_t *input_shape; GList *devices_inside; diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index e93cb64925..b3d9e5671d 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -373,9 +373,6 @@ gdk_surface_finalize (GObject *object) surface->impl_surface = NULL; } - if (surface->shape) - cairo_region_destroy (surface->shape); - if (surface->input_shape) cairo_region_destroy (surface->input_shape); @@ -523,14 +520,6 @@ remove_sibling_overlapped_area (GdkSurface *surface, child_region = cairo_region_create_rectangle (&r); - if (sibling->shape) - { - /* Adjust shape region to parent surface coords */ - cairo_region_translate (sibling->shape, sibling->x, sibling->y); - cairo_region_intersect (child_region, sibling->shape); - cairo_region_translate (sibling->shape, -sibling->x, -sibling->y); - } - cairo_region_subtract (region, child_region); cairo_region_destroy (child_region); } @@ -574,14 +563,6 @@ remove_child_area (GdkSurface *surface, child_region = cairo_region_create_rectangle (&r); - if (child->shape) - { - /* Adjust shape region to parent surface coords */ - cairo_region_translate (child->shape, child->x, child->y); - cairo_region_intersect (child_region, child->shape); - cairo_region_translate (child->shape, -child->x, -child->y); - } - if (for_input) { if (child->input_shape) @@ -4127,157 +4108,6 @@ gdk_surface_coords_from_parent (GdkSurface *surface, *y = parent_y - surface->y; } -/** - * gdk_surface_shape_combine_region: - * @surface: a #GdkSurface - * @shape_region: (allow-none): region of surface to be non-transparent - * @offset_x: X position of @shape_region in @surface coordinates - * @offset_y: Y position of @shape_region in @surface coordinates - * - * Makes pixels in @surface outside @shape_region be transparent, - * so that the surface may be nonrectangular. - * - * If @shape_region is %NULL, the shape will be unset, so the whole - * surface will be opaque again. @offset_x and @offset_y are ignored - * if @shape_region is %NULL. - * - * On the X11 platform, this uses an X server extension which is - * widely available on most common platforms, but not available on - * very old X servers, and occasionally the implementation will be - * buggy. On servers without the shape extension, this function - * will do nothing. - * - * This function works on both toplevel and child surfaces. - */ -void -gdk_surface_shape_combine_region (GdkSurface *surface, - const cairo_region_t *shape_region, - gint offset_x, - gint offset_y) -{ - cairo_region_t *old_region, *new_region, *diff; - - g_return_if_fail (GDK_IS_SURFACE (surface)); - - if (GDK_SURFACE_DESTROYED (surface)) - return; - - if (!surface->shape && shape_region == NULL) - return; - - surface->shaped = (shape_region != NULL); - - if (surface->shape) - cairo_region_destroy (surface->shape); - - old_region = NULL; - if (GDK_SURFACE_IS_MAPPED (surface)) - old_region = cairo_region_copy (surface->clip_region); - - if (shape_region) - { - surface->shape = cairo_region_copy (shape_region); - cairo_region_translate (surface->shape, offset_x, offset_y); - } - else - surface->shape = NULL; - - recompute_visible_regions (surface, FALSE); - - if (old_region) - { - new_region = cairo_region_copy (surface->clip_region); - - /* New area in the surface, needs invalidation */ - diff = cairo_region_copy (new_region); - cairo_region_subtract (diff, old_region); - - gdk_surface_invalidate_region_full (surface, diff, TRUE); - - cairo_region_destroy (diff); - - if (!gdk_surface_is_toplevel (surface)) - { - /* New area in the non-root parent surface, needs invalidation */ - diff = cairo_region_copy (old_region); - cairo_region_subtract (diff, new_region); - - /* Adjust region to parent surface coords */ - cairo_region_translate (diff, surface->x, surface->y); - - gdk_surface_invalidate_region_full (surface->parent, diff, TRUE); - - cairo_region_destroy (diff); - } - - cairo_region_destroy (new_region); - cairo_region_destroy (old_region); - } -} - -static void -do_child_shapes (GdkSurface *surface, - gboolean merge) -{ - GdkRectangle r; - cairo_region_t *region; - - r.x = 0; - r.y = 0; - r.width = surface->width; - r.height = surface->height; - - region = cairo_region_create_rectangle (&r); - remove_child_area (surface, FALSE, region); - - if (merge && surface->shape) - cairo_region_subtract (region, surface->shape); - - cairo_region_xor_rectangle (region, &r); - - gdk_surface_shape_combine_region (surface, region, 0, 0); - - cairo_region_destroy (region); -} - -/** - * gdk_surface_set_child_shapes: - * @surface: a #GdkSurface - * - * Sets the shape mask of @surface to the union of shape masks - * for all children of @surface, ignoring the shape mask of @surface - * itself. Contrast with gdk_surface_merge_child_shapes() which includes - * the shape mask of @surface in the masks to be merged. - **/ -void -gdk_surface_set_child_shapes (GdkSurface *surface) -{ - g_return_if_fail (GDK_IS_SURFACE (surface)); - - do_child_shapes (surface, FALSE); -} - -/** - * gdk_surface_merge_child_shapes: - * @surface: a #GdkSurface - * - * Merges the shape masks for any child surfaces into the - * shape mask for @surface. i.e. the union of all masks - * for @surface and its children will become the new mask - * for @surface. See gdk_surface_shape_combine_region(). - * - * This function is distinct from gdk_surface_set_child_shapes() - * because it includes @surface’s shape mask in the set of shapes to - * be merged. - */ -void -gdk_surface_merge_child_shapes (GdkSurface *surface) -{ - g_return_if_fail (GDK_IS_SURFACE (surface)); - - do_child_shapes (surface, TRUE); -} - /** * gdk_surface_input_shape_combine_region: * @surface: a #GdkSurface @@ -4348,8 +4178,6 @@ do_child_input_shapes (GdkSurface *surface, region = cairo_region_create_rectangle (&r); remove_child_area (surface, TRUE, region); - if (merge && surface->shape) - cairo_region_subtract (region, surface->shape); if (merge && surface->input_shape) cairo_region_subtract (region, surface->input_shape); @@ -4516,22 +4344,6 @@ gdk_surface_is_input_only (GdkSurface *surface) return surface->input_only; } -/** - * gdk_surface_is_shaped: - * @surface: a toplevel #GdkSurface - * - * Determines whether or not the surface is shaped. - * - * Returns: %TRUE if @surface is shaped - */ -gboolean -gdk_surface_is_shaped (GdkSurface *surface) -{ - g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE); - - return surface->shaped; -} - /* Gets the toplevel for a surface as used for events, i.e. including offscreen parents going up to the native toplevel */ @@ -4620,9 +4432,6 @@ point_in_surface (GdkSurface *surface, return x >= 0 && x < surface->width && y >= 0 && y < surface->height && - (surface->shape == NULL || - cairo_region_contains_point (surface->shape, - x, y)) && (surface->input_shape == NULL || cairo_region_contains_point (surface->input_shape, x, y)); @@ -5023,9 +4832,6 @@ gdk_surface_print (GdkSurface *surface, if (surface->input_only) g_print (" input-only"); - if (surface->shaped) - g_print (" shaped"); - if (!gdk_surface_is_visible ((GdkSurface *)surface)) g_print (" hidden"); diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h index 8ea5cfaa93..b077ed3744 100644 --- a/gdk/gdksurface.h +++ b/gdk/gdksurface.h @@ -511,36 +511,6 @@ GDK_AVAILABLE_IN_ALL void gdk_surface_set_focus_on_map (GdkSurface *surface, gboolean focus_on_map); -/* - * This allows for making shaped (partially transparent) surfaces - * - cool feature, needed for Drag and Drag for example. - */ -GDK_AVAILABLE_IN_ALL -void gdk_surface_shape_combine_region (GdkSurface *surface, - const cairo_region_t *shape_region, - gint offset_x, - gint offset_y); - -/* - * This routine allows you to quickly take the shapes of all the child surfaces - * of a surface and use their shapes as the shape mask for this surface - useful - * for container surfaces that dont want to look like a big box - * - * - Raster - */ -GDK_AVAILABLE_IN_ALL -void gdk_surface_set_child_shapes (GdkSurface *surface); - -/* - * This routine allows you to merge (ie ADD) child shapes to your - * own surface’s shape keeping its current shape and ADDING the child - * shapes to it. - * - * - Raster - */ -GDK_AVAILABLE_IN_ALL -void gdk_surface_merge_child_shapes (GdkSurface *surface); - GDK_AVAILABLE_IN_ALL void gdk_surface_input_shape_combine_region (GdkSurface *surface, const cairo_region_t *shape_region, @@ -570,8 +540,6 @@ GDK_AVAILABLE_IN_ALL gboolean gdk_surface_is_viewable (GdkSurface *surface); GDK_AVAILABLE_IN_ALL gboolean gdk_surface_is_input_only (GdkSurface *surface); -GDK_AVAILABLE_IN_ALL -gboolean gdk_surface_is_shaped (GdkSurface *surface); GDK_AVAILABLE_IN_ALL GdkSurfaceState gdk_surface_get_state (GdkSurface *surface); diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 0d26728cb3..f6faecc3e6 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -1040,10 +1040,10 @@ gtk_popover_update_shape (GtkPopover *popover) region = gdk_cairo_region_create_from_surface (surface); cairo_surface_destroy (surface); - gtk_widget_shape_combine_region (widget, region); + gtk_widget_input_shape_combine_region (widget, region); cairo_region_destroy (region); - gdk_surface_set_child_shapes (gtk_widget_get_surface (widget)); + gdk_surface_set_child_input_shapes (gtk_widget_get_surface (widget)); } static void diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 68613ea597..4dedb1c044 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -3594,7 +3594,6 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) GtkTreeViewColumnReorder *reorder = tree_view->priv->cur_reorder; GtkWidget *widget = GTK_WIDGET (tree_view); cairo_surface_t *mask_image; - cairo_region_t *mask_region; gint x; gint y; gint width; @@ -3717,11 +3716,6 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) cairo_fill (cr); cairo_destroy (cr); - mask_region = gdk_cairo_region_create_from_surface (mask_image); - gdk_surface_shape_combine_region (tree_view->priv->drag_highlight_window, - mask_region, 0, 0); - - cairo_region_destroy (mask_region); cairo_surface_destroy (mask_image); } @@ -3793,11 +3787,6 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view) cairo_fill (cr); cairo_destroy (cr); - mask_region = gdk_cairo_region_create_from_surface (mask_image); - gdk_surface_shape_combine_region (tree_view->priv->drag_highlight_window, - mask_region, 0, 0); - - cairo_region_destroy (mask_region); cairo_surface_destroy (mask_image); } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 38e1db7088..989b2d09d6 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -707,7 +707,6 @@ GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR; static GQuark quark_accel_path = 0; static GQuark quark_accel_closures = 0; static GQuark quark_parent_surface = 0; -static GQuark quark_shape_info = 0; static GQuark quark_input_shape_info = 0; static GQuark quark_pango_context = 0; static GQuark quark_mnemonic_labels = 0; @@ -925,7 +924,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_accel_path = g_quark_from_static_string ("gtk-accel-path"); quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures"); quark_parent_surface = g_quark_from_static_string ("gtk-parent-surface"); - quark_shape_info = g_quark_from_static_string ("gtk-shape-info"); quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info"); quark_pango_context = g_quark_from_static_string ("gtk-pango-context"); quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels"); @@ -3871,7 +3869,6 @@ void gtk_widget_realize (GtkWidget *widget) { GtkWidgetPrivate *priv; - cairo_region_t *region; g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (widget->priv->anchored || @@ -3901,12 +3898,6 @@ gtk_widget_realize (GtkWidget *widget) gtk_widget_real_set_has_tooltip (widget, gtk_widget_get_has_tooltip (widget), TRUE); - if (priv->has_shape_mask) - { - region = g_object_get_qdata (G_OBJECT (widget), quark_shape_info); - gdk_surface_shape_combine_region (priv->surface, region, 0, 0); - } - gtk_widget_update_input_shape (widget); if (priv->multidevice) @@ -3939,9 +3930,6 @@ gtk_widget_unrealize (GtkWidget *widget) g_object_ref (widget); gtk_widget_push_verify_invariants (widget); - if (widget->priv->has_shape_mask) - gtk_widget_shape_combine_region (widget, NULL); - if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info)) gtk_widget_input_shape_combine_region (widget, NULL); @@ -9719,52 +9707,6 @@ gtk_widget_propagate_state (GtkWidget *widget, } } -/** - * gtk_widget_shape_combine_region: - * @widget: a #GtkWidget - * @region: (allow-none): shape to be added, or %NULL to remove an existing shape - * - * Sets a shape for this widget’s GDK surface. This allows for - * transparent windows etc., see gdk_surface_shape_combine_region() - * for more information. - **/ -void -gtk_widget_shape_combine_region (GtkWidget *widget, - cairo_region_t *region) -{ - GtkWidgetPrivate *priv; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - /* set_shape doesn't work on widgets without GDK surface */ - g_return_if_fail (_gtk_widget_get_has_surface (widget)); - - priv = widget->priv; - - if (region == NULL) - { - priv->has_shape_mask = FALSE; - - if (priv->surface) - gdk_surface_shape_combine_region (priv->surface, NULL, 0, 0); - - g_object_set_qdata (G_OBJECT (widget), quark_shape_info, NULL); - } - else - { - priv->has_shape_mask = TRUE; - - g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info, - cairo_region_copy (region), - (GDestroyNotify) cairo_region_destroy); - - /* set shape if widget has a GDK surface already. - * otherwise the shape is scheduled to be set by gtk_widget_realize(). - */ - if (priv->surface) - gdk_surface_shape_combine_region (priv->surface, region, 0, 0); - } -} - static void gtk_widget_update_input_shape (GtkWidget *widget) { diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 10fd37fd3d..093ffefc37 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -820,9 +820,6 @@ GtkTextDirection gtk_widget_get_default_direction (void); /* Counterpart to gdk_surface_shape_combine_region. */ GDK_AVAILABLE_IN_ALL -void gtk_widget_shape_combine_region (GtkWidget *widget, - cairo_region_t *region); -GDK_AVAILABLE_IN_ALL void gtk_widget_input_shape_combine_region (GtkWidget *widget, cairo_region_t *region); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 509e76724e..dbe9ded71d 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -69,7 +69,6 @@ struct _GtkWidgetPrivate guint shadowed : 1; guint child_visible : 1; guint multidevice : 1; - guint has_shape_mask : 1; guint pass_through : 1; /* Queue-resize related flags */