[gtk/wip/matthiasc/popup5: 114/120] Work toward dropping widget->surface
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 114/120] Work toward dropping widget->surface
- Date: Sun, 19 May 2019 20:28:34 +0000 (UTC)
commit f0e1e525dd1fc02aeed388af8623582b04bf835b
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 | 5 +++--
gtk/gtkwidget.c | 39 +++++++--------------------------------
gtk/gtkwindow.c | 13 ++++++++-----
3 files changed, 18 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 51c83536d1..ada55380a0 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);
}
@@ -678,6 +678,8 @@ gtk_popover_map (GtkWidget *widget)
seat = gdk_display_get_default_seat (display),
gdk_surface_show_with_auto_dismissal (priv->surface, seat);
}
+ else
+ gdk_surface_show (priv->surface);
gtk_widget_get_surface_allocation (priv->relative_to, &parent_rect);
move_to_rect (popover);
@@ -707,7 +709,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 e092fbfbe3..e4a59db8c8 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
{
@@ -8168,9 +8156,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))
@@ -8201,9 +8186,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))
@@ -8235,6 +8217,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
{
@@ -8275,16 +8259,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 693f544c27..8ee1e4bbbb 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]