Use GtkNative APIs instead of GtkRoot

This commit is contained in:
Matthias Clasen 2019-05-26 18:02:55 +00:00
parent 7dcb163ee6
commit c1d5e82d95
10 changed files with 19 additions and 34 deletions

View File

@ -74,7 +74,7 @@ find_toplevel_at_pointer (GdkDisplay *display)
pointer_window = gdk_device_get_surface_at_position (gtk_get_current_event_device (), NULL, NULL);
if (pointer_window)
widget = GTK_WIDGET (gtk_root_get_for_surface (pointer_window));
widget = GTK_WIDGET (gtk_native_get_for_surface (pointer_window));
return widget;
}

View File

@ -464,8 +464,7 @@ create_texture (NodeEditorWindow *self)
if (node == NULL)
return NULL;
/* ahem */
renderer = GTK_ROOT_GET_IFACE (gtk_widget_get_root (GTK_WIDGET (self)))->get_renderer (gtk_widget_get_root (GTK_WIDGET (self)));
renderer = gtk_native_get_renderer (gtk_widget_get_native (GTK_WIDGET (self)));
texture = gsk_renderer_render_texture (renderer, node, NULL);
gsk_render_node_unref (node);

View File

@ -22,7 +22,7 @@
#include "gtkimcontextxim.h"
#include "gtkimmoduleprivate.h"
#include "gtkroot.h"
#include "gtknative.h"
#include "gtk/gtkintl.h"
@ -1536,7 +1536,7 @@ update_client_widget (GtkIMContextXIM *context_xim)
GtkWidget *new_client_widget = NULL;
if (context_xim->client_surface)
new_client_widget = gtk_root_get_for_surface (context_xim->client_surface);
new_client_widget = gtk_native_get_for_surface (context_xim->client_surface);
if (new_client_widget != context_xim->client_widget)
{

View File

@ -132,6 +132,7 @@
#include "gtkprintbackendprivate.h"
#include "gtkimmodule.h"
#include "gtkroot.h"
#include "gtknative.h"
#include "a11y/gtkaccessibility.h"
#include "inspector/window.h"
@ -1329,7 +1330,7 @@ rewrite_event_for_grabs (GdkEvent *event)
}
event_widget = gtk_get_event_widget (event);
grab_widget = gtk_root_get_for_surface (grab_surface);
grab_widget = gtk_native_get_for_surface (grab_surface);
if (grab_widget &&
gtk_main_get_window_group (grab_widget) != gtk_main_get_window_group (event_widget))
@ -2473,7 +2474,7 @@ gtk_get_event_widget (const GdkEvent *event)
widget = NULL;
if (event && event->any.surface &&
(event->any.type == GDK_DESTROY || !gdk_surface_is_destroyed (event->any.surface)))
widget = gtk_root_get_for_surface (event->any.surface);
widget = gtk_native_get_for_surface (event->any.surface);
return widget;
}

View File

@ -429,7 +429,7 @@ _gtk_widget_find_at_coords (GdkSurface *surface,
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
event_widget = gtk_root_get_for_surface (surface);
event_widget = gtk_native_get_for_surface (surface);
if (!event_widget)
return NULL;
@ -500,7 +500,7 @@ gtk_tooltip_set_last_surface (GtkTooltip *tooltip,
(gpointer *) &tooltip->last_surface);
if (surface)
window_widget = gtk_root_get_for_surface (surface);
window_widget = gtk_native_get_for_surface (surface);
if (window_widget)
window_widget = gtk_widget_get_toplevel (window_widget);

View File

@ -70,6 +70,7 @@
#include "gtkwidgetpathprivate.h"
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
#include "gtknativeprivate.h"
#include "a11y/gtkwidgetaccessible.h"
#include "inspector/window.h"
@ -13050,19 +13051,19 @@ gtk_widget_render (GtkWidget *widget,
GskRenderNode *root;
int x, y;
if (!GTK_IS_ROOT (widget))
if (!GTK_IS_NATIVE (widget))
return;
/* We only render double buffered on native windows */
if (!gdk_surface_has_native (surface))
return;
renderer = gtk_root_get_renderer (GTK_ROOT (widget));
renderer = gtk_native_get_renderer (GTK_NATIVE (widget));
if (renderer == NULL)
return;
snapshot = gtk_snapshot_new ();
gtk_root_get_surface_transform (GTK_ROOT (widget), &x, &y);
gtk_native_get_surface_transform (GTK_NATIVE (widget), &x, &y);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
gtk_widget_snapshot (widget, snapshot);
root = gtk_snapshot_free_to_node (snapshot);

View File

@ -2378,12 +2378,6 @@ gtk_window_native_get_renderer (GtkNative *native)
return priv->renderer;
}
static GskRenderer *
gtk_window_root_get_renderer (GtkRoot *root)
{
return gtk_window_native_get_renderer (GTK_NATIVE (root));
}
static void
gtk_window_native_get_surface_transform (GtkNative *native,
int *x,
@ -2402,14 +2396,6 @@ gtk_window_native_get_surface_transform (GtkNative *native,
*y = margin.top + border.top + padding.top;
}
static void
gtk_window_root_get_surface_transform (GtkRoot *root,
int *x,
int *y)
{
gtk_window_native_get_surface_transform (GTK_NATIVE (root), x, y);
}
static void
gtk_window_native_check_resize (GtkNative *native)
{
@ -2420,8 +2406,6 @@ 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;
}
static void

View File

@ -35,7 +35,7 @@
#include "gtkgesturemultipress.h"
#include "gtkeventcontrollermotion.h"
#include "gtkeventcontrollerkey.h"
#include "gtkroot.h"
#include "gtknative.h"
static GtkWidget *
find_widget_at_pointer (GdkDevice *device)
@ -46,7 +46,7 @@ find_widget_at_pointer (GdkDevice *device)
pointer_surface = gdk_device_get_surface_at_position (device, NULL, NULL);
if (pointer_surface)
widget = gtk_root_get_for_surface (pointer_surface);
widget = gtk_native_get_for_surface (pointer_surface);
if (widget)
{

View File

@ -35,7 +35,7 @@
#include "gtkprivate.h"
#include "gtkdebug.h"
#include "gdkinternals.h"
#include "gtkrootprivate.h"
#include "gtknative.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_root_get_renderer (GTK_ROOT (toplevel));
renderer = gtk_native_get_renderer (GTK_NATIVE (toplevel));
if (!renderer)
continue;

View File

@ -48,7 +48,7 @@
#include "gtklabel.h"
#include "gtkmodulesprivate.h"
#include "gtkprivate.h"
#include "gtkrootprivate.h"
#include "gtknative.h"
#include "gtkstack.h"
#include "gtktreeviewcolumn.h"
#include "gtkwindowgroup.h"
@ -297,7 +297,7 @@ gtk_inspector_window_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget);
renderer = gtk_root_get_renderer (GTK_ROOT (widget));
renderer = gtk_native_get_renderer (GTK_NATIVE (widget));
gsk_renderer_set_debug_flags (renderer, 0);
provider = gtk_css_provider_new ();