From 5071206d60d11416b67fb7ac1c9771de06626274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sun, 30 Oct 2016 17:01:19 +0100 Subject: [PATCH] widget: Remove app-paintable --- demos/gtk-demo/foreigndrawing.c | 1 - demos/gtk-demo/toolpalette.c | 2 - docs/reference/gtk/gtk4-sections.txt | 2 - docs/tools/widgets.c | 1 - gtk/gtkdnd.c | 9 ++-- gtk/gtkeventbox.c | 3 +- gtk/gtkglarea.c | 1 - gtk/gtkwidget.c | 71 ---------------------------- gtk/gtkwidget.h | 12 ++--- gtk/gtkwidgetprivate.h | 1 - gtk/gtkwindow.c | 52 +++++++++----------- tests/animated-resizing.c | 1 - tests/motion-compression.c | 2 - tests/testellipsise.c | 1 - tests/testgtk.c | 1 - tests/testpopup.c | 1 - tests/testtooltips.c | 1 - tests/video-timer.c | 1 - 18 files changed, 30 insertions(+), 133 deletions(-) diff --git a/demos/gtk-demo/foreigndrawing.c b/demos/gtk-demo/foreigndrawing.c index d0248472d4..11b8b44068 100644 --- a/demos/gtk-demo/foreigndrawing.c +++ b/demos/gtk-demo/foreigndrawing.c @@ -971,7 +971,6 @@ do_foreigndrawing (GtkWidget *do_widget) gtk_widget_set_size_request (da, 400, 400); gtk_widget_set_hexpand (da, TRUE); gtk_widget_set_vexpand (da, TRUE); - gtk_widget_set_app_paintable (da, TRUE); gtk_container_add (GTK_CONTAINER (box), da); g_signal_connect (da, "draw", G_CALLBACK (draw_cb), NULL); diff --git a/demos/gtk-demo/toolpalette.c b/demos/gtk-demo/toolpalette.c index 7ebaf25244..da6dfa2571 100644 --- a/demos/gtk-demo/toolpalette.c +++ b/demos/gtk-demo/toolpalette.c @@ -567,7 +567,6 @@ do_toolpalette (GtkWidget *do_widget) /* ===== passive DnD dest ===== */ contents = gtk_drawing_area_new (); - gtk_widget_set_app_paintable (contents, TRUE); g_object_connect (contents, "signal::draw", canvas_draw, NULL, @@ -594,7 +593,6 @@ do_toolpalette (GtkWidget *do_widget) /* ===== interactive DnD dest ===== */ contents = gtk_drawing_area_new (); - gtk_widget_set_app_paintable (contents, TRUE); g_object_connect (contents, "signal::draw", canvas_draw, NULL, diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index f76eb567ab..eb7bebc2dd 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4705,7 +4705,6 @@ gtk_widget_render_icon gtk_widget_render_icon_pixbuf gtk_widget_queue_draw_area gtk_widget_queue_draw_region -gtk_widget_set_app_paintable gtk_widget_set_redraw_on_allocate gtk_widget_mnemonic_activate gtk_widget_class_install_style_property @@ -4763,7 +4762,6 @@ gtk_widget_get_allocated_baseline gtk_widget_get_allocated_size gtk_widget_get_clip gtk_widget_set_clip -gtk_widget_get_app_paintable gtk_widget_get_can_default gtk_widget_set_can_default gtk_widget_get_can_focus diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c index 5c2a7a21d0..412fa9bfeb 100644 --- a/docs/tools/widgets.c +++ b/docs/tools/widgets.c @@ -798,7 +798,6 @@ create_page_setup_dialog (void) settings); info = new_widget_info ("pagesetupdialog", widget, ASIS); - gtk_widget_set_app_paintable (info->window, FALSE); info->include_decorations = TRUE; return info; diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 56ea797f46..608dfaa30d 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1579,20 +1579,16 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context, if (!info->icon_window) { - GdkDisplay *display; GdkScreen *screen; screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); - display = gdk_window_get_display (gdk_drag_context_get_source_window (context)); info->icon_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_WINDOW_TYPE_HINT_DND); gtk_window_set_screen (GTK_WINDOW (info->icon_window), screen); gtk_widget_set_size_request (info->icon_window, 24, 24); gtk_widget_set_events (info->icon_window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - - if (gdk_display_is_composited (display)) - gtk_widget_set_app_paintable (info->icon_window, TRUE); + gtk_style_context_remove_class (gtk_widget_get_style_context (info->icon_window), "background"); gtk_window_set_hardcoded_window (GTK_WINDOW (info->icon_window), gdk_drag_context_get_drag_window (context)); @@ -1802,11 +1798,12 @@ gtk_drag_set_icon_surface (GdkDragContext *context, gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND); gtk_widget_set_events (window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - gtk_widget_set_app_paintable (window, TRUE); gtk_widget_set_size_request (window, extents.width, extents.height); gtk_widget_realize (window); + gtk_style_context_remove_class (gtk_widget_get_style_context (window), "background"); + pattern = cairo_pattern_create_for_surface (surface); cairo_matrix_init_translate (&matrix, extents.x, extents.y); cairo_pattern_set_matrix (pattern, &matrix); diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 99f5b5fd5f..518a28dda8 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -521,8 +521,7 @@ static gboolean gtk_event_box_draw (GtkWidget *widget, cairo_t *cr) { - if (gtk_widget_get_has_window (widget) && - !gtk_widget_get_app_paintable (widget)) + if (gtk_widget_get_has_window (widget)) { GtkStyleContext *context; diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c index 80312cf5c0..8f8f9f5cca 100644 --- a/gtk/gtkglarea.c +++ b/gtk/gtkglarea.c @@ -969,7 +969,6 @@ gtk_gl_area_init (GtkGLArea *area) GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); gtk_widget_set_has_window (GTK_WIDGET (area), FALSE); - gtk_widget_set_app_paintable (GTK_WIDGET (area), TRUE); priv->auto_render = TRUE; priv->needs_render = TRUE; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 90df011290..da36c58f3f 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -566,7 +566,6 @@ enum { PROP_HEIGHT_REQUEST, PROP_VISIBLE, PROP_SENSITIVE, - PROP_APP_PAINTABLE, PROP_CAN_FOCUS, PROP_HAS_FOCUS, PROP_IS_FOCUS, @@ -1115,13 +1114,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) TRUE, GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); - widget_props[PROP_APP_PAINTABLE] = - g_param_spec_boolean ("app-paintable", - P_("Application paintable"), - P_("Whether the application will paint directly on the widget"), - FALSE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); - widget_props[PROP_CAN_FOCUS] = g_param_spec_boolean ("can-focus", P_("Can focus"), @@ -3266,9 +3258,6 @@ gtk_widget_set_property (GObject *object, case PROP_SENSITIVE: gtk_widget_set_sensitive (widget, g_value_get_boolean (value)); break; - case PROP_APP_PAINTABLE: - gtk_widget_set_app_paintable (widget, g_value_get_boolean (value)); - break; case PROP_CAN_FOCUS: gtk_widget_set_can_focus (widget, g_value_get_boolean (value)); break; @@ -3441,9 +3430,6 @@ gtk_widget_get_property (GObject *object, case PROP_SENSITIVE: g_value_set_boolean (value, gtk_widget_get_sensitive (widget)); break; - case PROP_APP_PAINTABLE: - g_value_set_boolean (value, gtk_widget_get_app_paintable (widget)); - break; case PROP_CAN_FOCUS: g_value_set_boolean (value, gtk_widget_get_can_focus (widget)); break; @@ -8413,63 +8399,6 @@ gtk_widget_set_mapped (GtkWidget *widget, widget->priv->mapped = mapped; } -/** - * gtk_widget_set_app_paintable: - * @widget: a #GtkWidget - * @app_paintable: %TRUE if the application will paint on the widget - * - * Sets whether the application intends to draw on the widget in - * an #GtkWidget::draw handler. - * - * This is a hint to the widget and does not affect the behavior of - * the GTK+ core; many widgets ignore this flag entirely. For widgets - * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow, - * the effect is to suppress default themed drawing of the widget's - * background. (Children of the widget will still be drawn.) The application - * is then entirely responsible for drawing the widget background. - * - * Note that the background is still drawn when the widget is mapped. - **/ -void -gtk_widget_set_app_paintable (GtkWidget *widget, - gboolean app_paintable) -{ - g_return_if_fail (GTK_IS_WIDGET (widget)); - - app_paintable = (app_paintable != FALSE); - - if (widget->priv->app_paintable != app_paintable) - { - widget->priv->app_paintable = app_paintable; - - if (_gtk_widget_is_drawable (widget)) - gtk_widget_queue_draw (widget); - - g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_APP_PAINTABLE]); - } -} - -/** - * gtk_widget_get_app_paintable: - * @widget: a #GtkWidget - * - * Determines whether the application intends to draw on the widget in - * an #GtkWidget::draw handler. - * - * See gtk_widget_set_app_paintable() - * - * Returns: %TRUE if the widget is app paintable - * - * Since: 2.18 - **/ -gboolean -gtk_widget_get_app_paintable (GtkWidget *widget) -{ - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - - return widget->priv->app_paintable; -} - /** * gtk_widget_set_redraw_on_allocate: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index b1ab5409a0..7187c5d9e5 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -195,9 +195,9 @@ struct _GtkWidget * width-for-height geometry management for a said widget and is the * default return. * It’s important to note (as described below) that any widget - * which trades height-for-width or width-for-height must respond properly + * which trades height-for-width or width-for-height must respond properly * to both of the virtual methods #GtkWidgetClass.get_preferred_height_for_width() - * and #GtkWidgetClass.get_preferred_width_for_height() since it might be + * and #GtkWidgetClass.get_preferred_width_for_height() since it might be * queried in either #GtkSizeRequestMode by its parent container. * @measure: This is called by containers to obtain the minimum and natural * size of the widget. Depending on the orientation parameter, the passed @@ -712,7 +712,7 @@ gboolean gtk_widget_send_focus_change (GtkWidget *widget, GDK_AVAILABLE_IN_ALL gboolean gtk_widget_activate (GtkWidget *widget); - + GDK_AVAILABLE_IN_ALL gboolean gtk_widget_intersect (GtkWidget *widget, const GdkRectangle *area, @@ -823,12 +823,6 @@ void gtk_widget_set_mapped (GtkWidget *widget, GDK_AVAILABLE_IN_ALL gboolean gtk_widget_get_mapped (GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_widget_set_app_paintable (GtkWidget *widget, - gboolean app_paintable); -GDK_AVAILABLE_IN_ALL -gboolean gtk_widget_get_app_paintable (GtkWidget *widget); - GDK_AVAILABLE_IN_ALL void gtk_widget_set_redraw_on_allocate (GtkWidget *widget, gboolean redraw_on_allocate); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index fe7e05aada..039dc1b076 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -65,7 +65,6 @@ struct _GtkWidgetPrivate guint receives_default : 1; guint has_grab : 1; guint shadowed : 1; - guint app_paintable : 1; guint redraw_on_alloc : 1; guint no_show_all : 1; guint child_visible : 1; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index e48ed6b7f9..1eeb746450 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6808,18 +6808,15 @@ update_opaque_region (GtkWindow *window, cairo_region_t *opaque_region; GtkStyleContext *context; gboolean is_opaque = FALSE; + const GdkRGBA *color; if (!_gtk_widget_get_realized (widget)) return; context = gtk_widget_get_style_context (widget); - if (!gtk_widget_get_app_paintable (widget)) - { - const GdkRGBA *color; - color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); - is_opaque = (color->alpha >= 1.0); - } + color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)); + is_opaque = (color->alpha >= 1.0); if (gtk_widget_get_opacity (widget) < 1.0) is_opaque = FALSE; @@ -9456,30 +9453,27 @@ gtk_window_get_render_node (GtkWidget *widget, gtk_style_context_restore (context); } - if (!gtk_widget_get_app_paintable (widget)) - { - if (priv->title_box && - gtk_widget_get_visible (priv->title_box) && - gtk_widget_get_child_visible (priv->title_box)) - title_height = priv->title_height; - else - title_height = 0; + if (priv->title_box && + gtk_widget_get_visible (priv->title_box) && + gtk_widget_get_child_visible (priv->title_box)) + title_height = priv->title_height; + else + title_height = 0; - gtk_render_background (context, cr, - window_border.left, - window_border.top + title_height, - allocation.width - - (window_border.left + window_border.right), - allocation.height - - (window_border.top + window_border.bottom + title_height)); - gtk_render_frame (context, cr, - window_border.left, - window_border.top + title_height, - allocation.width - - (window_border.left + window_border.right), - allocation.height - - (window_border.top + window_border.bottom + title_height)); - } + gtk_render_background (context, cr, + window_border.left, + window_border.top + title_height, + allocation.width - + (window_border.left + window_border.right), + allocation.height - + (window_border.top + window_border.bottom + title_height)); + gtk_render_frame (context, cr, + window_border.left, + window_border.top + title_height, + allocation.width - + (window_border.left + window_border.right), + allocation.height - + (window_border.top + window_border.bottom + title_height)); cairo_destroy (cr); diff --git a/tests/animated-resizing.c b/tests/animated-resizing.c index 2c37857ae9..042ed6130a 100644 --- a/tests/animated-resizing.c +++ b/tests/animated-resizing.c @@ -194,7 +194,6 @@ main(int argc, char **argv) gtk_window_set_keep_above (GTK_WINDOW (window), TRUE); gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER); - gtk_widget_set_app_paintable (window, TRUE); g_signal_connect (window, "draw", G_CALLBACK (on_window_draw), NULL); diff --git a/tests/motion-compression.c b/tests/motion-compression.c index 1aa26602d7..31512d6bbe 100644 --- a/tests/motion-compression.c +++ b/tests/motion-compression.c @@ -43,9 +43,7 @@ main (int argc, char **argv) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 300, 300); - gtk_widget_set_app_paintable (window, TRUE); gtk_widget_add_events (window, GDK_POINTER_MOTION_MASK); - gtk_widget_set_app_paintable (window, TRUE); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), vbox); diff --git a/tests/testellipsise.c b/tests/testellipsise.c index 18b650852e..e8d4220890 100644 --- a/tests/testellipsise.c +++ b/tests/testellipsise.c @@ -149,7 +149,6 @@ main (int argc, char *argv[]) gtk_widget_set_valign (label, GTK_ALIGN_CENTER); ebox = gtk_event_box_new (); - gtk_widget_set_app_paintable (ebox, TRUE); gtk_container_add (GTK_CONTAINER (ebox), label); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, TRUE); diff --git a/tests/testgtk.c b/tests/testgtk.c index beabc0c084..3d092d649c 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -256,7 +256,6 @@ create_alpha_window (GtkWidget *widget) "_Close", 0, NULL); - gtk_widget_set_app_paintable (window, TRUE); g_signal_connect (window, "draw", G_CALLBACK (on_alpha_window_draw), NULL); diff --git a/tests/testpopup.c b/tests/testpopup.c index cd82468c49..bb126cbd6a 100644 --- a/tests/testpopup.c +++ b/tests/testpopup.c @@ -37,7 +37,6 @@ on_map_event (GtkWidget *parent, popup = gtk_window_new (GTK_WINDOW_POPUP); gtk_widget_set_size_request (GTK_WIDGET (popup), 20, 20); - gtk_widget_set_app_paintable (GTK_WIDGET (popup), TRUE); gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent)); g_signal_connect (popup, "draw", G_CALLBACK (draw_popup), NULL); g_signal_connect (parent, "motion-notify-event", G_CALLBACK (place_popup), popup); diff --git a/tests/testtooltips.c b/tests/testtooltips.c index 4a8884d1eb..93b3dedbf0 100644 --- a/tests/testtooltips.c +++ b/tests/testtooltips.c @@ -59,7 +59,6 @@ query_tooltip_custom_cb (GtkWidget *widget, { GtkWindow *window = gtk_widget_get_tooltip_window (widget); - gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); g_signal_connect (window, "draw", G_CALLBACK (draw_tooltip), NULL); return TRUE; diff --git a/tests/video-timer.c b/tests/video-timer.c index bc5de1e5fe..e8b7e0cf42 100644 --- a/tests/video-timer.c +++ b/tests/video-timer.c @@ -374,7 +374,6 @@ main(int argc, char **argv) } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_app_paintable (window, TRUE); gtk_window_set_default_size (GTK_WINDOW (window), 300, 300); g_signal_connect (window, "draw",