[gtk/present-toplevel-2: 26/70] gtk: use toplevel state getter



commit 300e5b12b31697d0964ad00f968953e43e6a1185
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 29 20:32:15 2020 -0500

    gtk: use toplevel state getter

 gtk/gtkheaderbar.c     |  2 +-
 gtk/gtkpopover.c       | 20 ++++----------------
 gtk/gtktooltipwindow.c |  2 +-
 gtk/gtkwindow.c        |  8 ++++----
 4 files changed, 10 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index ca56f4fba1..e618ff7a68 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -1084,7 +1084,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 e004a6562a..04a4e17aee 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;
@@ -591,23 +590,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
@@ -751,7 +739,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);
@@ -773,7 +761,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 0f6272bfbc..466f14b965 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5055,7 +5055,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;
@@ -5974,7 +5974,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;
 
@@ -6711,7 +6711,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;
 }
@@ -8798,7 +8798,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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]