From 694d7c378b23bbe79acd0a2a848c343e11fff76f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 10 Feb 2019 01:06:39 +0100 Subject: [PATCH] root: Move the renderer to the root --- gtk/gtkroot.c | 17 +++++++++++++++++ gtk/gtkroot.h | 1 + gtk/gtkrootprivate.h | 1 + gtk/gtkwidget.c | 17 ++++------------- gtk/gtkwindow.c | 18 ++++++++++-------- gtk/gtkwindowprivate.h | 2 -- gtk/inspector/logs.c | 4 ++-- gtk/inspector/window.c | 4 ++-- 8 files changed, 37 insertions(+), 27 deletions(-) diff --git a/gtk/gtkroot.c b/gtk/gtkroot.c index d94dd2e273..1907786e95 100644 --- a/gtk/gtkroot.c +++ b/gtk/gtkroot.c @@ -43,6 +43,12 @@ gtk_root_default_get_display (GtkRoot *self) return gdk_display_get_default (); } +static GskRenderer * +gtk_root_default_get_renderer (GtkRoot *self) +{ + return NULL; +} + static void gtk_root_default_get_surface_transform (GtkRoot *self, int *x, @@ -56,6 +62,7 @@ static void gtk_root_default_init (GtkRootInterface *iface) { iface->get_display = gtk_root_default_get_display; + iface->get_renderer = gtk_root_default_get_renderer; iface->get_surface_transform = gtk_root_default_get_surface_transform; } @@ -70,6 +77,16 @@ gtk_root_get_display (GtkRoot *self) return iface->get_display (self); } +GskRenderer * +gtk_root_get_renderer (GtkRoot *self) +{ + GtkRootInterface *iface; + + g_return_val_if_fail (GTK_IS_ROOT (self), NULL); + + iface = GTK_ROOT_GET_IFACE (self); + return iface->get_renderer (self); +} void gtk_root_get_surface_transform (GtkRoot *self, diff --git a/gtk/gtkroot.h b/gtk/gtkroot.h index b0680462a5..e3494fcc7a 100644 --- a/gtk/gtkroot.h +++ b/gtk/gtkroot.h @@ -46,6 +46,7 @@ struct _GtkRootInterface /*< public >*/ GdkDisplay * (* get_display) (GtkRoot *self); + GskRenderer * (* get_renderer) (GtkRoot *self); void (* get_surface_transform) (GtkRoot *root, int *x, diff --git a/gtk/gtkrootprivate.h b/gtk/gtkrootprivate.h index 964e832ba0..07ddc380e5 100644 --- a/gtk/gtkrootprivate.h +++ b/gtk/gtkrootprivate.h @@ -6,6 +6,7 @@ G_BEGIN_DECLS GdkDisplay * gtk_root_get_display (GtkRoot *root); +GskRenderer * gtk_root_get_renderer (GtkRoot *self); void gtk_root_get_surface_transform (GtkRoot *self, int *x, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 96b932c4a1..518a3b8c14 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5085,18 +5085,6 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget, return TRUE; } -static GskRenderer * -gtk_widget_get_renderer (GtkWidget *widget) -{ - GtkWidget *toplevel; - - toplevel = _gtk_widget_get_toplevel (widget); - if (_gtk_widget_is_toplevel (toplevel)) - return gtk_window_get_renderer (GTK_WINDOW (toplevel)); - - return NULL; -} - #define WIDGET_REALIZED_FOR_EVENT(widget, event) \ (event->any.type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget)) @@ -13230,11 +13218,14 @@ gtk_widget_render (GtkWidget *widget, GskRenderer *renderer; GskRenderNode *root; + if (!GTK_IS_ROOT (widget)) + return; + /* We only render double buffered on native windows */ if (!gdk_surface_has_native (surface)) return; - renderer = gtk_widget_get_renderer (widget); + renderer = gtk_root_get_renderer (GTK_ROOT (widget)); if (renderer == NULL) return; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index ba2b37c315..ed9c63f938 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -2507,6 +2507,15 @@ gtk_window_root_get_display (GtkRoot *root) return priv->display; } +static GskRenderer * +gtk_window_root_get_renderer (GtkRoot *root) +{ + GtkWindow *self = GTK_WINDOW (root); + GtkWindowPrivate *priv = gtk_window_get_instance_private (self); + + return priv->renderer; +} + static void gtk_window_root_get_surface_transform (GtkRoot *root, int *x, @@ -2520,6 +2529,7 @@ static void gtk_window_root_interface_init (GtkRootInterface *iface) { iface->get_display = gtk_window_root_get_display; + iface->get_renderer = gtk_window_root_get_renderer; iface->get_surface_transform = gtk_window_root_get_surface_transform; } @@ -10578,14 +10588,6 @@ gtk_window_unexport_handle (GtkWindow *window) #endif } -GskRenderer * -gtk_window_get_renderer (GtkWindow *window) -{ - GtkWindowPrivate *priv = gtk_window_get_instance_private (window); - - return priv->renderer; -} - static void gtk_window_add_pointer_focus (GtkWindow *window, GtkPointerFocus *focus) diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h index ce91bfa59f..de0c853f77 100644 --- a/gtk/gtkwindowprivate.h +++ b/gtk/gtkwindowprivate.h @@ -132,8 +132,6 @@ gboolean gtk_window_export_handle (GtkWindow *window, gpointer user_data); void gtk_window_unexport_handle (GtkWindow *window); -GskRenderer *gtk_window_get_renderer (GtkWindow *window); - GtkWidget * gtk_window_lookup_pointer_focus_widget (GtkWindow *window, GdkDevice *device, GdkEventSequence *sequence); diff --git a/gtk/inspector/logs.c b/gtk/inspector/logs.c index a8c59ceba6..1bc73c7629 100644 --- a/gtk/inspector/logs.c +++ b/gtk/inspector/logs.c @@ -35,7 +35,7 @@ #include "gtkprivate.h" #include "gtkdebug.h" #include "gdkinternals.h" -#include "gtkwindowprivate.h" +#include "gtkrootprivate.h" #include "gskdebugprivate.h" #include "gskrendererprivate.h" @@ -146,7 +146,7 @@ flag_toggled (GtkWidget *button, if (toplevel == gtk_widget_get_toplevel (button)) /* skip the inspector */ continue; - renderer = gtk_window_get_renderer (GTK_WINDOW (toplevel)); + renderer = gtk_root_get_renderer (GTK_ROOT (toplevel)); if (!renderer) continue; diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index 3239cd5770..9bdced31e4 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -51,10 +51,10 @@ #include "gtklabel.h" #include "gtkmodulesprivate.h" #include "gtkprivate.h" +#include "gtkrootprivate.h" #include "gtkstack.h" #include "gtktreeviewcolumn.h" #include "gtkwindowgroup.h" -#include "gtkwindowprivate.h" G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) @@ -273,7 +273,7 @@ gtk_inspector_window_realize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget); - renderer = gtk_window_get_renderer (GTK_WINDOW (widget)); + renderer = gtk_root_get_renderer (GTK_ROOT (widget)); gsk_renderer_set_debug_flags (renderer, 0); }