[gtk/present-toplevel-2: 7/79] gtk: use toplevel state getter



commit 9704f0dec828c71a10e21dae203d9a89e7bcedb4
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 b3e3e79b3b..90ab3927c0 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 72417182d2..839aae7915 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5054,7 +5054,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;
@@ -5973,7 +5973,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;
 
@@ -6710,7 +6710,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;
 }
@@ -8797,7 +8797,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]