[gtk/wip/matthiasc/popup5: 145/187] Work toward dropping widget->surface
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 145/187] Work toward dropping widget->surface
- Date: Thu, 23 May 2019 11:05:45 +0000 (UTC)
commit fbe85c3f57a264cdeb0669f14bbb9e1eff335dc7
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 17 21:25:36 2019 +0000
Work toward dropping widget->surface
Drop special-casing of GtkNative in
most widget vfuncs. GtkNative implementations
need to override these anyway.
gtk/gtkpopover.c | 3 +--
gtk/gtkwidget.c | 39 +++++++--------------------------------
gtk/gtkwindow.c | 13 ++++++++-----
3 files changed, 16 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 70b6d472fa..0cd7110191 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -601,7 +601,7 @@ gtk_popover_unrealize (GtkWidget *widget)
g_signal_handlers_disconnect_by_func (priv->surface, surface_event, widget);
g_signal_handlers_disconnect_by_func (priv->surface, surface_moved_to_rect, widget);
gdk_surface_set_widget (priv->surface, NULL);
-
+ gdk_surface_destroy (priv->surface);
g_clear_object (&priv->surface);
}
@@ -698,7 +698,6 @@ gtk_popover_unmap (GtkWidget *widget)
priv->surface_transform_changed_cb = 0;
GTK_WIDGET_CLASS (gtk_popover_parent_class)->unmap (widget);
-
gdk_surface_hide (priv->surface);
child = gtk_bin_get_child (GTK_BIN (widget));
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d444979ce1..2e09ced170 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3265,8 +3265,7 @@ gtk_widget_map (GtkWidget *widget)
update_cursor_on_state_change (widget);
- if (!GTK_IS_NATIVE (widget))
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
gtk_widget_pop_verify_invariants (widget);
}
@@ -4016,9 +4015,8 @@ gtk_widget_queue_draw (GtkWidget *widget)
priv->draw_needed = TRUE;
g_clear_pointer (&priv->render_node, gsk_render_node_unref);
- if (GTK_IS_NATIVE (widget) &&
- _gtk_widget_get_realized (widget))
- gdk_surface_queue_expose (gtk_widget_get_surface (widget));
+ if (GTK_IS_NATIVE (widget) && _gtk_widget_get_realized (widget))
+ gdk_surface_queue_expose (gtk_native_get_surface (GTK_NATIVE (widget)));
}
}
@@ -4176,17 +4174,7 @@ gtk_widget_get_frame_clock (GtkWidget *widget)
if (priv->realized)
{
- /* We use gtk_widget_get_root() here to make it explicit that
- * the frame clock is a property of the toplevel that a widget
- * is anchored to; gdk_surface_get_toplevel() will go up the
- * hierarchy anyways, but should squash any funny business with
- * reparenting windows and widgets.
- */
- GtkRoot *root = _gtk_widget_get_root (widget);
- GdkSurface *surface = _gtk_widget_get_surface (GTK_WIDGET (root));
- g_assert (surface != NULL);
-
- return gdk_surface_get_frame_clock (surface);
+ return gdk_surface_get_frame_clock (priv->surface);
}
else
{
@@ -8165,9 +8153,6 @@ gtk_widget_real_map (GtkWidget *widget)
GtkWidget *p;
priv->mapped = TRUE;
- if (GTK_IS_NATIVE (widget))
- gdk_surface_show (priv->surface);
-
for (p = gtk_widget_get_first_child (widget);
p != NULL;
p = gtk_widget_get_next_sibling (p))
@@ -8198,9 +8183,6 @@ gtk_widget_real_unmap (GtkWidget *widget)
GtkWidget *child;
priv->mapped = FALSE;
- if (GTK_IS_NATIVE (widget))
- gdk_surface_hide (priv->surface);
-
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
@@ -8232,6 +8214,8 @@ gtk_widget_real_realize (GtkWidget *widget)
if (GTK_IS_NATIVE (widget))
{
g_assert (priv->surface != NULL);
+ priv->surface = gtk_native_get_surface (GTK_NATIVE (widget));
+ g_object_ref (priv->surface);
}
else
{
@@ -8272,16 +8256,7 @@ gtk_widget_real_unrealize (GtkWidget *widget)
priv->realized = FALSE;
- if (GTK_IS_NATIVE (widget))
- {
- gdk_surface_destroy (priv->surface);
- priv->surface = NULL;
- }
- else
- {
- g_object_unref (priv->surface);
- priv->surface = NULL;
- }
+ g_clear_object (&priv->surface);
}
void
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 84a4304b78..a21ef03cd1 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5046,7 +5046,7 @@ gtk_window_map (GtkWidget *widget)
gtk_widget_get_child_visible (priv->title_box))
gtk_widget_map (priv->title_box);
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
if (priv->maximize_initially)
gdk_surface_maximize (surface);
@@ -5137,7 +5137,7 @@ gtk_window_unmap (GtkWidget *widget)
return;
}
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
GTK_WIDGET_CLASS (gtk_window_parent_class)->unmap (widget);
gdk_surface_hide (surface);
@@ -5197,16 +5197,17 @@ gtk_window_guess_default_size (GtkWindow *window,
gint *width,
gint *height)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *widget;
- GdkDisplay *display;
GdkSurface *surface;
+ GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle workarea;
int minimum, natural;
widget = GTK_WIDGET (window);
display = gtk_widget_get_display (widget);
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
if (surface)
monitor = gdk_display_get_monitor_at_surface (display, surface);
@@ -5831,13 +5832,15 @@ gtk_window_unrealize (GtkWidget *widget)
gsk_renderer_unrealize (priv->renderer);
g_clear_object (&priv->renderer);
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
g_signal_handlers_disconnect_by_func (surface, surface_state_changed, widget);
g_signal_handlers_disconnect_by_func (surface, surface_size_changed, widget);
g_signal_handlers_disconnect_by_func (surface, surface_render, widget);
g_signal_handlers_disconnect_by_func (surface, surface_event, widget);
gdk_surface_set_widget (surface, NULL);
+ gdk_surface_destroy (surface);
+ g_clear_object (&priv->surface);
GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]