[gtk/wip/matthiasc/popup4: 68/140] surface: Small cleanup



commit af5323cb415c2ddfd90e6e80395aa9c3d00db886
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/gdkdevice-core-x11.c   |  4 +-
 gdk/x11/gdksurface-x11.c       | 14 ------
 6 files changed, 22 insertions(+), 115 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 f70b73a0e4..191065b229 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -460,30 +460,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)
 {
@@ -700,14 +682,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;
@@ -1339,12 +1314,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++;
 }
 
 /**
@@ -1365,7 +1337,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
@@ -1610,32 +1582,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)
     {
@@ -1807,20 +1760,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)
     {
@@ -1857,12 +1798,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
@@ -2450,11 +2387,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
@@ -2901,12 +2835,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/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index d23c01a1bc..98a2d76a3b 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -133,7 +133,7 @@ gdk_x11_device_core_get_history (GdkDevice      *device,
   int tmp_n_events;
   int i, j;
 
-  impl_surface = _gdk_surface_get_impl_surface (surface);
+  impl_surface = gdk_surface_get_impl_surface (surface);
   impl =  GDK_SURFACE_IMPL_X11 (impl_surface->impl);
   xcoords = XGetMotionEvents (GDK_SURFACE_XDISPLAY (surface),
                               GDK_SURFACE_XID (impl_surface),
@@ -315,7 +315,7 @@ gdk_x11_device_core_grab (GdkDevice    *device,
   xwindow = GDK_SURFACE_XID (surface);
 
   if (confine_to)
-    confine_to = _gdk_surface_get_impl_surface (confine_to);
+    confine_to = gdk_surface_get_impl_surface (confine_to);
 
   if (!confine_to || GDK_SURFACE_DESTROYED (confine_to))
     xconfine_to = None;
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index b9204226dd..a2c82fc532 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -4451,13 +4451,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;
 }
 
@@ -4488,13 +4481,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]