surface: Remove gdk_surface_is_viewable()
authorBenjamin Otte <otte@redhat.com>
Sat, 16 May 2020 22:41:44 +0000 (00:41 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 16 May 2020 22:41:44 +0000 (00:41 +0200)
It returns the same value as gdk_surface_get_mapped(), so use that
instead.

docs/reference/gdk/gdk4-sections.txt
gdk/broadway/gdksurface-broadway.c
gdk/gdkinternals.h
gdk/gdksurface.c
gdk/gdksurface.h
gdk/gdksurfaceprivate.h
gdk/wayland/gdksurface-wayland.c
gdk/win32/gdksurface-win32.c
gdk/x11/gdksurface-x11.c
gtk/gtkshortcutcontroller.c
gtk/gtkwidget.c

index 19ac368ccfad8f9ea016f816460fb4f05dd94886..d5c6ffdf3fdf3635599df778c99e58dd4097ff11 100644 (file)
@@ -185,7 +185,6 @@ gdk_surface_destroy
 gdk_surface_is_destroyed
 gdk_surface_get_display
 gdk_surface_hide
-gdk_surface_is_viewable
 gdk_surface_get_mapped
 gdk_surface_translate_coordinates
 gdk_surface_begin_resize_drag
index 64ae49ccafaae0f28686f4e088c02f88e1e4b3f7..09eddb5aae7cbddff3da3d270d878a0cb7b5aa2f 100644 (file)
@@ -585,7 +585,6 @@ static void
 show_popup (GdkSurface *surface)
 {
   gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
-  _gdk_surface_update_viewable (surface);
   gdk_broadway_surface_show (surface, FALSE);
   gdk_surface_invalidate_rect (surface, NULL);
 }
@@ -1569,15 +1568,10 @@ show_surface (GdkSurface *surface)
   if (!was_mapped)
     gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
-  _gdk_surface_update_viewable (surface);
-
   gdk_broadway_surface_show (surface, FALSE);
 
   if (!was_mapped)
-    {
-      if (gdk_surface_is_viewable (surface))
-        gdk_surface_invalidate_rect (surface, NULL);
-    }
+    gdk_surface_invalidate_rect (surface, NULL);
 }
 
 static gboolean
index 5357bd6b1bc7436d703d3964ddd6af05f3d82f67..12f140b6099cc1375599abc959223baa95bea32f 100644 (file)
@@ -175,7 +175,6 @@ void       gdk_surface_invalidate_region  (GdkSurface           *surface,
                                            const cairo_region_t *region);
 void       _gdk_surface_clear_update_area (GdkSurface      *surface);
 void       _gdk_surface_update_size       (GdkSurface      *surface);
-gboolean   _gdk_surface_update_viewable   (GdkSurface      *surface);
 GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface,
                                                  GError   **error);
 void gdk_surface_get_unscaled_size (GdkSurface *surface,
index b6ee8f577ad6482ade0b2e92e734a670a3bd18bc..47a9e7b53a0b2084ea9cc3b2a3831149d162b643 100644 (file)
@@ -960,28 +960,6 @@ gdk_surface_get_mapped (GdkSurface *surface)
   return GDK_SURFACE_IS_MAPPED (surface);
 }
 
-/**
- * gdk_surface_is_viewable:
- * @surface: a #GdkSurface
- *
- * Check if the surface and all ancestors of the surface are
- * mapped. (This is not necessarily "viewable" in the X sense, since
- * we only check as far as we have GDK surface parents, not to the root
- * surface.)
- *
- * Returns: %TRUE if the surface is viewable
- **/
-gboolean
-gdk_surface_is_viewable (GdkSurface *surface)
-{
-  g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
-
-  if (surface->destroyed)
-    return FALSE;
-
-  return surface->viewable;
-}
-
 GdkGLContext *
 gdk_surface_get_shared_data_gl_context (GdkSurface *surface)
 {
@@ -1253,7 +1231,7 @@ gdk_surface_process_updates_internal (GdkSurface *surface)
       surface->active_update_area = surface->update_area;
       surface->update_area = NULL;
 
-      if (gdk_surface_is_viewable (surface))
+      if (GDK_SURFACE_IS_MAPPED (surface))
         {
           cairo_region_t *expose_region;
           gboolean handled;
@@ -1321,10 +1299,7 @@ gdk_surface_invalidate_rect (GdkSurface        *surface,
 
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  if (GDK_SURFACE_DESTROYED (surface))
-    return;
-
-  if (!surface->viewable)
+  if (!GDK_SURFACE_IS_MAPPED (surface))
     return;
 
   if (!rect)
@@ -1400,10 +1375,10 @@ gdk_surface_invalidate_region (GdkSurface          *surface,
 
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  if (GDK_SURFACE_DESTROYED (surface))
+  if (!GDK_SURFACE_IS_MAPPED (surface))
     return;
 
-  if (!surface->viewable || cairo_region_is_empty (region))
+  if (cairo_region_is_empty (region))
     return;
 
   r.x = 0;
@@ -1694,25 +1669,6 @@ gdk_surface_get_device_position (GdkSurface       *surface,
     *mask = tmp_mask;
 }
 
-/* Returns TRUE If the native surface was mapped or unmapped */
-static gboolean
-set_viewable (GdkSurface *w,
-              gboolean val)
-{
-  if (w->viewable == val)
-    return FALSE;
-
-  w->viewable = val;
-
-  return FALSE;
-}
-
-gboolean
-_gdk_surface_update_viewable (GdkSurface *surface)
-{
-  return set_viewable (surface, GDK_SURFACE_IS_MAPPED (surface));
-}
-
 /**
  * gdk_surface_hide:
  * @surface: a #GdkSurface
@@ -2783,8 +2739,6 @@ gdk_surface_set_state (GdkSurface      *surface,
   mapped = GDK_SURFACE_IS_MAPPED (surface);
   sticky = GDK_SURFACE_IS_STICKY (surface);
 
-  _gdk_surface_update_viewable (surface);
-
   if (GDK_IS_TOPLEVEL (surface))
     g_object_notify (G_OBJECT (surface), "state");
 
index 75d6d9eba128767be1e17e8a6695e0e7dc4840db..109bec5f76aaaa114d884c94689bfdab3da91627 100644 (file)
@@ -160,9 +160,6 @@ GDK_AVAILABLE_IN_ALL
 void          gdk_surface_set_input_region      (GdkSurface     *surface,
                                                  cairo_region_t *region);
 
-GDK_AVAILABLE_IN_ALL
-gboolean gdk_surface_is_viewable    (GdkSurface *surface);
-
 GDK_AVAILABLE_IN_ALL
 gboolean      gdk_surface_get_mapped   (GdkSurface *surface);
 
index cbc6e53094f52a4861035f344c8b2741b7c8757a..e6959cf21d90499840a7d73c0a4ae77be8d31f1b 100644 (file)
@@ -71,7 +71,6 @@ struct _GdkSurface
   guint destroyed : 2;
 
   guint support_multidevice : 1;
-  guint viewable : 1; /* mapped and all parents mapped */
   guint in_update : 1;
   guint frame_clock_events_paused : 1;
   guint autohide : 1;
index 451d0bb70311324d77a8feb9a4d76f2fb7defa8a..9155d0b340dec0ec9973c8b7c8e15906bc793fa9 100644 (file)
@@ -4603,15 +4603,10 @@ show_surface (GdkSurface *surface)
   if (!was_mapped)
     gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
-  _gdk_surface_update_viewable (surface);
-
   gdk_wayland_surface_show (surface, FALSE);
 
   if (!was_mapped)
-    {
-      if (gdk_surface_is_viewable (surface))
-        gdk_surface_invalidate_rect (surface, NULL);
-    }
+    gdk_surface_invalidate_rect (surface, NULL);
 }
 
 static gboolean
index 196fd2a775638055c9fbe02ac443c6937997430b..7455e8d06554ce8b6bbb54b2e046f7e4eb59d5fa 100644 (file)
@@ -1327,7 +1327,6 @@ show_popup (GdkSurface *surface)
 {
   gdk_win32_surface_raise (surface);
   gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
-  _gdk_surface_update_viewable (surface);
   show_window_internal (surface, FALSE, FALSE);
   gdk_surface_invalidate_rect (surface, NULL);
 }
@@ -4990,15 +4989,10 @@ show_surface (GdkSurface *surface)
   if (!was_mapped)
     gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
-  _gdk_surface_update_viewable (surface);
-
   gdk_win32_surface_show (surface, FALSE);
 
   if (!was_mapped)
-    {
-      if (gdk_surface_is_viewable (surface))
-        gdk_surface_invalidate_rect (surface, NULL);
-    }
+    gdk_surface_invalidate_rect (surface, NULL);
 }
 
 static gboolean
index 19f8911f91173122728af3745faac3f4b8d598a6..2e5113346b635628ca65f827afcd5bb9bb920c72 100644 (file)
@@ -1515,7 +1515,6 @@ show_popup (GdkSurface *surface)
 {
   gdk_x11_surface_raise (surface);
   gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
-  _gdk_surface_update_viewable (surface);
   gdk_x11_surface_show (surface, FALSE);
   gdk_surface_invalidate_rect (surface, NULL);
 }
@@ -4929,6 +4928,7 @@ gdk_x11_toplevel_present (GdkToplevel       *toplevel,
   GdkSurface *surface = GDK_SURFACE (toplevel);
   GdkGeometry geometry;
   GdkSurfaceHints mask;
+  gboolean was_mapped;
 
   gdk_x11_surface_unminimize (surface);
 
@@ -4964,10 +4964,6 @@ gdk_x11_toplevel_present (GdkToplevel       *toplevel,
   else
     gdk_x11_surface_unfullscreen (surface);
 
-  {
-  gboolean was_mapped;
-  gboolean did_show;
-
   if (surface->destroyed)
     return TRUE;
 
@@ -4976,16 +4972,10 @@ gdk_x11_toplevel_present (GdkToplevel       *toplevel,
   if (!was_mapped)
     gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
-  did_show = _gdk_surface_update_viewable (surface);
-
-  gdk_x11_surface_show (surface, !did_show ? was_mapped : TRUE);
+  gdk_x11_surface_show (surface, was_mapped);
 
   if (!was_mapped)
-    {
-      if (gdk_surface_is_viewable (surface))
-        gdk_surface_invalidate_rect (surface, NULL);
-    }
-  }
+    gdk_surface_invalidate_rect (surface, NULL);
 
   return TRUE;
 }
index 99fa997b767c046e8f8ee8f4699d716262a2b53d..7813e0c968166e4b16063b7acd12b96822492fc8 100644 (file)
@@ -351,7 +351,7 @@ gtk_shortcut_controller_run_controllers (GtkEventController *controller,
 
       native = gtk_widget_get_native (widget);
       if (!native ||
-          !gdk_surface_is_viewable(gtk_native_get_surface (native)))
+          !gdk_surface_get_mapped (gtk_native_get_surface (native)))
         {
           g_object_unref (shortcut);
           continue;
index 08a729abd4bd4fd962b105e838cee2fd16faac99..315b9dfe1989aca2a190fff22859277b64a788aa 100644 (file)
@@ -4519,7 +4519,7 @@ event_surface_is_still_viewable (GdkEvent *event)
     case GDK_ENTER_NOTIFY:
     case GDK_PROXIMITY_IN:
     case GDK_SCROLL:
-      return gdk_surface_is_viewable (gdk_event_get_surface (event));
+      return gdk_surface_get_mapped (gdk_event_get_surface (event));
 
 #if 0
     /* The following events are the second half of paired events;
@@ -4578,7 +4578,7 @@ gtk_widget_event (GtkWidget *widget,
   double x, y;
 
   /* We check only once for is-still-visible; if someone
-   * hides the window in on of the signals on the widget,
+   * hides the window in one of the signals on the widget,
    * they are responsible for returning TRUE to terminate
    * handling.
    */