[gtk/wip/matthiasc/popup5: 37/115] surface: Small cleanup



commit fda870f7559cf9aae1fbef50517e925f2691eb06
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 24 15:26:55 2019 -0400

    surface: Small cleanup
    
    Every surface has an impl now, no need to check.

 gdk/gdkinternals.h             |  3 +-
 gdk/gdksurface.c               | 99 +++++++-----------------------------------
 gdk/quartz/gdksurface-quartz.c |  7 +--
 gdk/win32/gdkgeometry-win32.c  | 10 +----
 gdk/x11/gdksurface-x11.c       | 14 ------
 5 files changed, 20 insertions(+), 113 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index cfe55445d1..28ecf41e42 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -330,8 +330,7 @@ void _gdk_display_set_surface_under_pointer (GdkDisplay *display,
                                              GdkDevice  *device,
                                              GdkSurface  *surface);
 
-gboolean    _gdk_surface_has_impl (GdkSurface *surface);
-GdkSurface * _gdk_surface_get_impl_surface (GdkSurface *surface);
+GdkSurface * gdk_surface_get_impl_surface (GdkSurface *surface);
 
 void gdk_surface_destroy_notify       (GdkSurface *surface);
 
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index fe7575d0af..1ec5e251ca 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -476,30 +476,12 @@ gdk_surface_get_property (GObject    *object,
     }
 }
 
-static GdkSurface *
+GdkSurface *
 gdk_surface_get_impl_surface (GdkSurface *surface)
 {
   return surface->impl_surface;
 }
 
-GdkSurface *
-_gdk_surface_get_impl_surface (GdkSurface *surface)
-{
-  return gdk_surface_get_impl_surface (surface);
-}
-
-static gboolean
-gdk_surface_has_impl (GdkSurface *surface)
-{
-  return surface->impl_surface == surface;
-}
-
-gboolean
-_gdk_surface_has_impl (GdkSurface *surface)
-{
-  return gdk_surface_has_impl (surface);
-}
-
 void
 _gdk_surface_update_size (GdkSurface *surface)
 {
@@ -728,14 +710,7 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
       _gdk_surface_clear_update_area (surface);
 
       impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-
-      if (gdk_surface_has_impl (surface))
-        impl_class->destroy (surface, recursing_native, foreign_destroy);
-      else
-        {
-          /* hide to make sure we repaint and break grabs */
-          gdk_surface_hide (surface);
-        }
+      impl_class->destroy (surface, recursing_native, foreign_destroy);
 
       surface->state |= GDK_SURFACE_STATE_WITHDRAWN;
       surface->destroyed = TRUE;
@@ -1367,12 +1342,9 @@ _gdk_surface_clear_update_area (GdkSurface *surface)
 void
 gdk_surface_freeze_updates (GdkSurface *surface)
 {
-  GdkSurface *impl_surface;
-
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  impl_surface = gdk_surface_get_impl_surface (surface);
-  impl_surface->update_freeze_count++;
+  surface->impl_surface->update_freeze_count++;
 }
 
 /**
@@ -1393,7 +1365,7 @@ gdk_surface_thaw_updates (GdkSurface *surface)
   g_return_if_fail (impl_surface->update_freeze_count > 0);
 
   if (--impl_surface->update_freeze_count == 0)
-    gdk_surface_schedule_update (GDK_SURFACE (impl_surface));
+    gdk_surface_schedule_update (impl_surface);
 }
 
 void
@@ -1638,32 +1610,13 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
   if (raise)
     gdk_surface_raise_internal (surface);
 
-  if (gdk_surface_has_impl (surface))
-    {
-      if (!was_mapped)
-        gdk_synthesize_surface_state (surface,
-                                     GDK_SURFACE_STATE_WITHDRAWN,
-                                     0);
-    }
-  else
-    {
-      surface->state = 0;
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
-    }
+  if (!was_mapped)
+    gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
   did_show = _gdk_surface_update_viewable (surface);
 
-  /* If it was already viewable the backend show op won't be called, call it
-     again to ensure things happen right if the mapped tracking was not right
-     for e.g. a foreign surface.
-     Dunno if this is strictly needed but its what happened pre-csw.
-     Also show if not done by gdk_surface_update_viewable. */
-  if (gdk_surface_has_impl (surface) && (was_viewable || !did_show))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->show (surface, !did_show ? was_mapped : TRUE);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->show (surface, !did_show ? was_mapped : TRUE);
 
   if (!was_mapped)
     {
@@ -1835,20 +1788,8 @@ gdk_surface_hide (GdkSurface *surface)
 
   was_mapped = GDK_SURFACE_IS_MAPPED (surface);
 
-  if (gdk_surface_has_impl (surface))
-    {
-
-      if (GDK_SURFACE_IS_MAPPED (surface))
-        gdk_synthesize_surface_state (surface,
-                                     0,
-                                     GDK_SURFACE_STATE_WITHDRAWN);
-    }
-  else if (was_mapped)
-    {
-      surface->state = GDK_SURFACE_STATE_WITHDRAWN;
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
-    }
+  if (GDK_SURFACE_IS_MAPPED (surface))
+    gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_WITHDRAWN);
 
   if (was_mapped)
     {
@@ -1885,12 +1826,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
   did_hide = _gdk_surface_update_viewable (surface);
 
-  /* Hide foreign surface as those are not handled by update_viewable. */
-  if (gdk_surface_has_impl (surface) && (!did_hide))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->hide (surface);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->hide (surface);
 }
 
 static void
@@ -2478,11 +2415,8 @@ gdk_surface_input_shape_combine_region (GdkSurface       *surface,
   else
     surface->input_shape = NULL;
 
-  if (gdk_surface_has_impl (surface))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->input_shape_combine_region (surface, surface->input_shape, 0, 0);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->input_shape_combine_region (surface, surface->input_shape, 0, 0);
 }
 
 static void
@@ -2929,12 +2863,9 @@ gdk_surface_print (GdkSurface *surface,
            surface->width, surface->height
            );
 
-  if (gdk_surface_has_impl (surface))
-    {
 #ifdef GDK_WINDOWING_X11
-      g_print (" impl(0x%lx)", gdk_x11_surface_get_xid (window));
+  g_print (" impl(0x%lx)", gdk_x11_surface_get_xid (window));
 #endif
-    }
 
   g_print (" %s", surface_types[surface->surface_type]);
 
diff --git a/gdk/quartz/gdksurface-quartz.c b/gdk/quartz/gdksurface-quartz.c
index a3af7844fe..b955e8c021 100644
--- a/gdk/quartz/gdksurface-quartz.c
+++ b/gdk/quartz/gdksurface-quartz.c
@@ -1505,11 +1505,8 @@ gdk_surface_quartz_get_root_coords (GdkSurface *window,
 
   while (window != toplevel)
     {
-      if (_gdk_surface_has_impl ((GdkSurface *)window))
-        {
-          tmp_x += window->x;
-          tmp_y += window->y;
-        }
+      tmp_x += window->x;
+      tmp_y += window->y;
 
       window = window->parent;
     }
diff --git a/gdk/win32/gdkgeometry-win32.c b/gdk/win32/gdkgeometry-win32.c
index f800fa8cc6..ad17a4a852 100644
--- a/gdk/win32/gdkgeometry-win32.c
+++ b/gdk/win32/gdkgeometry-win32.c
@@ -130,9 +130,7 @@ _gdk_win32_surface_tmp_unset_bg (GdkSurface *window,
   if (window->input_only || window->destroyed || !GDK_SURFACE_IS_MAPPED (window))
     return;
 
-  if (_gdk_surface_has_impl (window) &&
-      GDK_SURFACE_IS_WIN32 (window))
-    tmp_unset_bg (window);
+  tmp_unset_bg (window);
 
   if (recurse)
     {
@@ -162,11 +160,7 @@ _gdk_win32_surface_tmp_reset_bg (GdkSurface *window,
   if (window->input_only || window->destroyed || !GDK_SURFACE_IS_MAPPED (window))
     return;
 
-  if (_gdk_surface_has_impl (window) &&
-      GDK_SURFACE_IS_WIN32 (window))
-    {
-      tmp_reset_bg (window);
-    }
+  tmp_reset_bg (window);
 
   if (recurse)
     {
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 6f23e9ee48..0da023a09d 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -4475,13 +4475,6 @@ gdk_x11_get_server_time (GdkSurface *surface)
 XID
 gdk_x11_surface_get_xid (GdkSurface *surface)
 {
-  if (!GDK_SURFACE_IS_X11 (surface) ||
-      !_gdk_surface_has_impl (surface))
-    {
-      g_warning (G_STRLOC " drawable is not a native X11 window");
-      return None;
-    }
-  
   return GDK_SURFACE_IMPL_X11 (surface->impl)->xid;
 }
 
@@ -4512,13 +4505,6 @@ void
 gdk_x11_surface_set_frame_sync_enabled (GdkSurface *surface,
                                        gboolean   frame_sync_enabled)
 {
-  if (!GDK_SURFACE_IS_X11 (surface) ||
-      !_gdk_surface_has_impl (surface))
-    {
-      g_warning (G_STRLOC " drawable is not a native X11 window");
-      return;
-    }
-
   GDK_SURFACE_IMPL_X11 (surface->impl)->frame_sync_enabled = FALSE;
 }
 


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