diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-02-29 20:32:15 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-03-12 14:56:20 -0400 |
commit | 6edff8cd67b18a085418891667e11d620b3fa4d5 (patch) | |
tree | f7711411a5b10f27fe266e096fe4b3c6dae3c03b | |
parent | 92668816911ed4ae3a105b48e5ffc74a79132356 (diff) | |
download | gtk+-6edff8cd67b18a085418891667e11d620b3fa4d5.tar.gz |
gtk: use toplevel state getter
-rw-r--r-- | gtk/gtkheaderbar.c | 2 | ||||
-rw-r--r-- | gtk/gtkpopover.c | 20 | ||||
-rw-r--r-- | gtk/gtktooltipwindow.c | 2 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 8 |
4 files changed, 10 insertions, 22 deletions
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 46454f8f68..eb5bca55a4 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -1083,7 +1083,7 @@ surface_state_changed (GtkWidget *widget) GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GdkSurfaceState changed, new_state; - new_state = gdk_surface_get_state (gtk_native_get_surface (gtk_widget_get_native (widget))); + new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (gtk_native_get_surface (gtk_widget_get_native (widget)))); changed = new_state ^ priv->state; priv->state = new_state; diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 0224b21a42..d1dfd74f34 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -141,7 +141,6 @@ typedef struct { GskRenderer *renderer; GtkWidget *default_widget; - GdkSurfaceState state; GdkRectangle pointing_to; gboolean has_pointing_to; guint surface_transform_changed_cb; @@ -592,23 +591,12 @@ gtk_popover_key_pressed (GtkWidget *widget, } static void -surface_state_changed (GtkWidget *widget) +surface_mapped_changed (GtkWidget *widget) { GtkPopover *popover = GTK_POPOVER (widget); GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover); - GdkSurfaceState new_surface_state; - GdkSurfaceState changed_mask; - new_surface_state = gdk_surface_get_state (priv->surface); - changed_mask = new_surface_state ^ priv->state; - priv->state = new_surface_state; - - if (changed_mask & GDK_SURFACE_STATE_WITHDRAWN) - { - if (priv->state & GDK_SURFACE_STATE_WITHDRAWN && - gtk_widget_is_visible (widget)) - gtk_widget_hide (widget); - } + gtk_widget_set_visible (widget, gdk_surface_get_mapped (priv->surface)); } static void @@ -752,7 +740,7 @@ gtk_popover_realize (GtkWidget *widget) gdk_surface_set_widget (priv->surface, widget); - g_signal_connect_swapped (priv->surface, "notify::state", G_CALLBACK (surface_state_changed), widget); + g_signal_connect_swapped (priv->surface, "notify::mapped", G_CALLBACK (surface_mapped_changed), widget); g_signal_connect_swapped (priv->surface, "size-changed", G_CALLBACK (surface_size_changed), widget); g_signal_connect (priv->surface, "render", G_CALLBACK (surface_render), widget); g_signal_connect (priv->surface, "event", G_CALLBACK (surface_event), widget); @@ -774,7 +762,7 @@ gtk_popover_unrealize (GtkWidget *widget) gsk_renderer_unrealize (priv->renderer); g_clear_object (&priv->renderer); - g_signal_handlers_disconnect_by_func (priv->surface, surface_state_changed, widget); + g_signal_handlers_disconnect_by_func (priv->surface, surface_mapped_changed, widget); g_signal_handlers_disconnect_by_func (priv->surface, surface_size_changed, widget); g_signal_handlers_disconnect_by_func (priv->surface, surface_render, widget); g_signal_handlers_disconnect_by_func (priv->surface, surface_event, widget); diff --git a/gtk/gtktooltipwindow.c b/gtk/gtktooltipwindow.c index 10dfdad65d..1b86bef664 100644 --- a/gtk/gtktooltipwindow.c +++ b/gtk/gtktooltipwindow.c @@ -178,7 +178,7 @@ surface_state_changed (GtkWidget *widget) GdkSurfaceState new_surface_state; GdkSurfaceState changed_mask; - new_surface_state = gdk_surface_get_state (window->surface); + new_surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (window->surface)); changed_mask = new_surface_state ^ window->state; window->state = new_surface_state; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index ad8089049d..f59b9429da 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4956,7 +4956,7 @@ gtk_window_unmap (GtkWidget *widget) } priv->configure_notify_received = FALSE; - state = gdk_surface_get_state (priv->surface); + state = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface)); priv->minimize_initially = (state & GDK_SURFACE_STATE_MINIMIZED) != 0; priv->maximize_initially = (state & GDK_SURFACE_STATE_MAXIMIZED) != 0; priv->stick_initially = (state & GDK_SURFACE_STATE_STICKY) != 0; @@ -5868,7 +5868,7 @@ surface_state_changed (GtkWidget *widget) GdkSurfaceState new_surface_state; GdkSurfaceState changed_mask; - new_surface_state = gdk_surface_get_state (priv->surface); + new_surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface)); changed_mask = new_surface_state ^ priv->state; priv->state = new_surface_state; @@ -6605,7 +6605,7 @@ gtk_window_get_state (GtkWindow *window) GtkWindowPrivate *priv = gtk_window_get_instance_private (window); if (priv->surface) - return gdk_surface_get_state (priv->surface); + return gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface)); return 0; } @@ -8679,7 +8679,7 @@ ensure_state_flag_backdrop (GtkWidget *widget) GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (widget)); gboolean surface_focused = TRUE; - surface_focused = gdk_surface_get_state (priv->surface) & GDK_SURFACE_STATE_FOCUSED; + surface_focused = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface)) & GDK_SURFACE_STATE_FOCUSED; if (!surface_focused) gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_BACKDROP, FALSE); |