[gtk/wip/matthiasc/popup5] Stop using gtk_widget_get_surface
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5] Stop using gtk_widget_get_surface
- Date: Mon, 20 May 2019 03:23:04 +0000 (UTC)
commit 627a46726f611ad4e449dbf725794b9415050ffb
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 20 00:38:08 2019 +0000
Stop using gtk_widget_get_surface
Replace all uses of gtk_widget_get_surface by
gtk_native_get_surface.
demos/gtk-demo/application.c | 6 +-
demos/gtk-demo/changedisplay.c | 2 +-
demos/gtk-demo/dnd.c | 2 +-
demos/node-editor/node-editor-window.c | 2 +-
demos/widget-factory/widget-factory.c | 4 +-
docs/tools/shooter.c | 2 +-
examples/drawing.c | 4 +-
gtk/a11y/gtktextcellaccessible.c | 2 +-
gtk/a11y/gtktreeviewaccessible.c | 14 +-
gtk/a11y/gtkwidgetaccessible.c | 5 -
gtk/a11y/gtkwindowaccessible.c | 7 +-
gtk/gtkapplication-wayland.c | 3 +-
gtk/gtkapplication-x11.c | 5 +-
gtk/gtkcellrendereraccel.c | 3 +-
gtk/gtkdnd.c | 11 +-
gtk/gtkdragdest.c | 13 +-
gtk/gtkentrycompletion.c | 3 +-
gtk/gtkfilechoosernativequartz.c | 2 +-
gtk/gtkfilechoosernativewin32.c | 2 +-
gtk/gtkgesture.c | 2 +-
gtk/gtkglarea.c | 3 +-
gtk/gtkheaderbar.c | 7 +-
gtk/gtkimcontextime.c | 4 +-
gtk/gtkimcontextxim.c | 2 +-
gtk/gtkmain.c | 9 +-
gtk/gtkmenu.c | 27 +--
gtk/gtkmenuitem.c | 2 +-
gtk/gtkmnemonichash.c | 5 +-
gtk/gtknotebook.c | 2 +-
gtk/gtkpopover.c | 17 +-
gtk/gtkprintoperation-win32.c | 13 +-
gtk/gtktextview.c | 2 +-
gtk/gtktooltip.c | 6 +-
gtk/gtktreeview.c | 3 +-
gtk/gtkvideo.c | 29 ++-
gtk/gtkwidget.c | 3 +-
gtk/gtkwindow.c | 315 ++++++++++++---------------------
gtk/inspector/fpsoverlay.c | 5 +-
gtk/inspector/inspect-button.c | 8 +-
gtk/inspector/updatesoverlay.c | 5 +-
tests/testfullscreen.c | 4 +-
tests/testgtk.c | 6 +-
tests/testwindowdrag.c | 4 +-
tests/testwindowsize.c | 2 +-
testsuite/gtk/gestures.c | 18 +-
45 files changed, 277 insertions(+), 318 deletions(-)
---
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 740e64ef40..7ed8ef6e1d 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -477,7 +477,7 @@ surface_state_changed (GtkWidget *widget)
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
GdkSurfaceState new_state;
- new_state = gdk_surface_get_state (gtk_widget_get_surface (widget));
+ new_state = gdk_surface_get_state (gtk_native_get_surface (GTK_NATIVE (widget)));
window->maximized = (new_state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
window->fullscreen = (new_state & GDK_SURFACE_STATE_FULLSCREEN) != 0;
}
@@ -487,14 +487,14 @@ demo_application_window_realize (GtkWidget *widget)
{
GTK_WIDGET_CLASS (demo_application_window_parent_class)->realize (widget);
- g_signal_connect_swapped (gtk_widget_get_surface (widget), "notify::state",
+ g_signal_connect_swapped (gtk_native_get_surface (GTK_NATIVE (widget)), "notify::state",
G_CALLBACK (surface_state_changed), widget);
}
static void
demo_application_window_unrealize (GtkWidget *widget)
{
- g_signal_handlers_disconnect_by_func (gtk_widget_get_surface (widget),
+ g_signal_handlers_disconnect_by_func (gtk_native_get_surface (GTK_NATIVE (widget)),
surface_state_changed, widget);
GTK_WIDGET_CLASS (demo_application_window_parent_class)->unrealize (widget);
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index 1ef592b21f..3b8f894371 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -120,7 +120,7 @@ query_for_toplevel (GdkDisplay *display,
device = gtk_get_current_event_device ();
if (gdk_seat_grab (gdk_device_get_seat (device),
- gtk_widget_get_surface (popup),
+ gtk_native_get_surface (GTK_NATIVE (popup)),
GDK_SEAT_CAPABILITY_ALL_POINTING,
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
{
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index e8c184cdcc..3e862e8175 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -299,7 +299,7 @@ pressed_cb (GtkGesture *gesture,
rect.height = 0;
gtk_menu_popup_at_rect (GTK_MENU (menu),
- gtk_widget_get_surface (widget),
+ gtk_native_get_surface (gtk_widget_get_native (widget)),
&rect,
GDK_GRAVITY_NORTH_WEST,
GDK_GRAVITY_NORTH_WEST,
diff --git a/demos/node-editor/node-editor-window.c b/demos/node-editor/node-editor-window.c
index b6f66eaf98..a936ecfcd4 100644
--- a/demos/node-editor/node-editor-window.c
+++ b/demos/node-editor/node-editor-window.c
@@ -548,7 +548,7 @@ node_editor_window_add_renderer (NodeEditorWindow *self,
GdkSurface *surface;
GdkPaintable *paintable;
- surface = gtk_widget_get_surface (GTK_WIDGET (self));
+ surface = gtk_native_get_surface (GTK_NATIVE (self));
g_assert (surface != NULL);
if (renderer != NULL && !gsk_renderer_realize (renderer, surface, NULL))
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 972a28c45d..a2732ecf42 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -64,7 +64,7 @@ get_idle (gpointer data)
GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window));
gtk_widget_set_sensitive (window, TRUE);
- gdk_surface_set_cursor (gtk_widget_get_surface (window), NULL);
+ gdk_surface_set_cursor (gtk_native_get_surface (GTK_NATIVE (window)), NULL);
g_application_unmark_busy (G_APPLICATION (app));
return G_SOURCE_REMOVE;
@@ -81,7 +81,7 @@ get_busy (GSimpleAction *action,
g_application_mark_busy (G_APPLICATION (app));
cursor = gdk_cursor_new_from_name ("wait", NULL);
- gdk_surface_set_cursor (gtk_widget_get_surface (window), cursor);
+ gdk_surface_set_cursor (gtk_native_get_surface (GTK_NATIVE (window)), cursor);
g_object_unref (cursor);
g_timeout_add (5000, get_idle, window);
diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c
index 2269b3fddf..6bbaccf19a 100644
--- a/docs/tools/shooter.c
+++ b/docs/tools/shooter.c
@@ -235,7 +235,7 @@ shoot_one (WidgetInfo *info)
gtk_main_quit ();
}
- window = gtk_widget_get_surface (info->window);
+ window = gtk_native_get_surface (GTK_NATIVE (info->window));
id = gdk_x11_surface_get_xid (window);
if (window_is_csd (window))
decor = (info->include_decorations) ? DECOR_NONE : DECOR_WINDOW_FRAME;
diff --git a/examples/drawing.c b/examples/drawing.c
index 08f2872105..da3eeabe73 100644
--- a/examples/drawing.c
+++ b/examples/drawing.c
@@ -29,9 +29,9 @@ size_allocate_cb (GtkWidget *widget,
surface = NULL;
}
- if (gtk_widget_get_surface (widget))
+ if (gtk_native_get_surface (gtk_widget_get_native (widget)))
{
- surface = gdk_surface_create_similar_surface (gtk_widget_get_surface (widget),
+ surface = gdk_surface_create_similar_surface (gtk_native_get_surface (gtk_widget_get_native (widget)),
CAIRO_CONTENT_COLOR,
gtk_widget_get_width (widget),
gtk_widget_get_height (widget));
diff --git a/gtk/a11y/gtktextcellaccessible.c b/gtk/a11y/gtktextcellaccessible.c
index c35ba285b5..2d84b3064e 100644
--- a/gtk/a11y/gtktextcellaccessible.c
+++ b/gtk/a11y/gtktextcellaccessible.c
@@ -487,7 +487,7 @@ get_origins (GtkWidget *widget,
{
GdkSurface *surface;
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
gdk_surface_get_origin (surface, x_surface, y_surface);
gdk_surface_get_origin (surface, x_toplevel, y_toplevel);
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index ac17d40860..1878c19cfc 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -1161,17 +1161,9 @@ gtk_tree_view_accessible_grab_cell_focus (GtkCellAccessibleParent *parent,
toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel))
{
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (toplevel)))
- gtk_window_present_with_time (GTK_WINDOW (toplevel),
- gdk_x11_get_server_time (gtk_widget_get_surface (widget)));
- else
-#endif
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_window_present (GTK_WINDOW (toplevel));
- G_GNUC_END_IGNORE_DEPRECATIONS
- }
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_window_present (GTK_WINDOW (toplevel));
+ G_GNUC_END_IGNORE_DEPRECATIONS
}
return TRUE;
diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c
index 05e1376c6e..2957dfeff6 100644
--- a/gtk/a11y/gtkwidgetaccessible.c
+++ b/gtk/a11y/gtkwidgetaccessible.c
@@ -587,14 +587,9 @@ gtk_widget_accessible_grab_focus (AtkComponent *component)
toplevel = gtk_widget_get_toplevel (widget);
if (gtk_widget_is_toplevel (toplevel))
{
-#ifdef GDK_WINDOWING_X11
- gtk_window_present_with_time (GTK_WINDOW (toplevel),
- gdk_x11_get_server_time (gtk_widget_get_surface (widget)));
-#else
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_window_present (GTK_WINDOW (toplevel));
G_GNUC_END_IGNORE_DEPRECATIONS
-#endif
}
return TRUE;
diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c
index 268f5b0c60..284c132281 100644
--- a/gtk/a11y/gtkwindowaccessible.c
+++ b/gtk/a11y/gtkwindowaccessible.c
@@ -27,6 +27,7 @@
#include "gtklabel.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
+#include "gtknative.h"
/* atkcomponent.h */
@@ -243,7 +244,7 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible)
if (gtk_window_is_active (window))
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
- gdk_surface = gtk_widget_get_surface (widget);
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
if (gdk_surface)
{
state = gdk_surface_get_state (gdk_surface);
@@ -388,7 +389,7 @@ gtk_window_accessible_get_extents (AtkComponent *component,
return;
}
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (GTK_NATIVE (widget));
if (surface == NULL)
return;
@@ -435,7 +436,7 @@ gtk_window_accessible_get_size (AtkComponent *component,
return;
}
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (GTK_NATIVE (widget));
if (surface == NULL)
return;
diff --git a/gtk/gtkapplication-wayland.c b/gtk/gtkapplication-wayland.c
index a5f48df251..34d85e31bb 100644
--- a/gtk/gtkapplication-wayland.c
+++ b/gtk/gtkapplication-wayland.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "gtkapplicationprivate.h"
+#include "gtknative.h"
#include <gdk/wayland/gdkwayland.h>
@@ -44,7 +45,7 @@ gtk_application_impl_wayland_handle_window_realize (GtkApplicationImpl *impl,
GdkSurface *gdk_surface;
gchar *window_path;
- gdk_surface = gtk_widget_get_surface (GTK_WIDGET (window));
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
if (!GDK_IS_WAYLAND_SURFACE (gdk_surface))
return;
diff --git a/gtk/gtkapplication-x11.c b/gtk/gtkapplication-x11.c
index 989e9c3380..933b160b25 100644
--- a/gtk/gtkapplication-x11.c
+++ b/gtk/gtkapplication-x11.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "gtkapplicationprivate.h"
+#include "gtknative.h"
#include <gdk/x11/gdkx.h>
@@ -42,7 +43,7 @@ gtk_application_impl_x11_handle_window_realize (GtkApplicationImpl *impl,
GdkSurface *gdk_surface;
gchar *window_path;
- gdk_surface = gtk_widget_get_surface (GTK_WIDGET (window));
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
if (!GDK_IS_X11_SURFACE (gdk_surface))
return;
@@ -65,7 +66,7 @@ gtk_application_impl_x11_get_window_system_id (GtkApplicationImplDBus *dbus,
{
GdkSurface *gdk_surface;
- gdk_surface = gtk_widget_get_surface (GTK_WIDGET (window));
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
if (GDK_IS_X11_SURFACE (gdk_surface))
return g_variant_new_uint32 (GDK_SURFACE_XID (gdk_surface));
diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c
index efb41e2142..8f5d49d61b 100644
--- a/gtk/gtkcellrendereraccel.c
+++ b/gtk/gtkcellrendereraccel.c
@@ -28,6 +28,7 @@
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkeventcontrollerkey.h"
+#include "gtknative.h"
/**
@@ -452,7 +453,7 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
if (!is_editable)
return NULL;
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
if (event)
seat = gdk_event_get_seat (event);
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 89d8f9625d..8b35cef978 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -38,6 +38,7 @@
#include "gtkwidgetprivate.h"
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
+#include "gtknative.h"
#include "gdk/gdkcontentformatsprivate.h"
#include "gdk/gdktextureprivate.h"
@@ -880,7 +881,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
int y)
{
GtkDragSourceInfo *info;
- GtkRoot *root;
+ GtkNative *native;
GdkDrag *drag;
double px, py;
int dx, dy;
@@ -889,9 +890,9 @@ gtk_drag_begin_internal (GtkWidget *widget,
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
- root = gtk_widget_get_root (widget);
- gtk_widget_translate_coordinates (widget, GTK_WIDGET (root), x, y, &x, &y);
- gdk_surface_get_device_position (gtk_widget_get_surface (widget),
+ native = gtk_widget_get_native (widget);
+ gtk_widget_translate_coordinates (widget, GTK_WIDGET (native), x, y, &x, &y);
+ gdk_surface_get_device_position (gtk_native_get_surface (native),
device,
&px, &py,
NULL);
@@ -902,7 +903,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
content->widget = g_object_ref (widget);
content->formats = gdk_content_formats_ref (target_list);
- drag = gdk_drag_begin (gtk_widget_get_surface (GTK_WIDGET (root)), device, GDK_CONTENT_PROVIDER (content),
actions, dx, dy);
+ drag = gdk_drag_begin (gtk_native_get_surface (native), device, GDK_CONTENT_PROVIDER (content), actions,
dx, dy);
if (drag == NULL)
{
g_object_unref (content);
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 5ce9f1e441..da2205e09d 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -29,14 +29,15 @@
#include "gtkdnd.h"
#include "gtkdndprivate.h"
#include "gtkintl.h"
+#include "gtknative.h"
static void
gtk_drag_dest_realized (GtkWidget *widget)
{
- GtkRoot *root = gtk_widget_get_root (widget);
+ GtkNative *native = gtk_widget_get_native (widget);
- gdk_surface_register_dnd (gtk_widget_get_surface (GTK_WIDGET (root)));
+ gdk_surface_register_dnd (gtk_native_get_surface (native));
}
static void
@@ -44,10 +45,10 @@ gtk_drag_dest_hierarchy_changed (GtkWidget *widget,
GParamSpec *pspec,
gpointer data)
{
- GtkRoot *root = gtk_widget_get_root (widget);
+ GtkNative *native = gtk_widget_get_native (widget);
- if (root && gtk_widget_get_realized (GTK_WIDGET (root)))
- gdk_surface_register_dnd (gtk_widget_get_surface (GTK_WIDGET (root)));
+ if (native && gtk_widget_get_realized (GTK_WIDGET (native)))
+ gdk_surface_register_dnd (gtk_native_get_surface (native));
}
static void
@@ -132,7 +133,7 @@ gtk_drag_dest_set_internal (GtkWidget *widget,
* {
* GdkModifierType mask;
*
- * gdk_surface_get_pointer (gtk_widget_get_surface (widget),
+ * gdk_surface_get_pointer (gtk_native_get_surface (gtk_widget_get_native (widget)),
* NULL, NULL, &mask);
* if (mask & GDK_CONTROL_MASK)
* gdk_drag_status (context, GDK_ACTION_COPY, time);
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 068a6b271c..4ec99e8f89 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -89,6 +89,7 @@
#include "gtkprivate.h"
#include "gtkwindowprivate.h"
#include "gtkwidgetprivate.h"
+#include "gtknative.h"
#include <string.h>
@@ -1345,7 +1346,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
GtkTreeViewColumn *action_column;
gint action_height;
- surface = gtk_widget_get_surface (completion->priv->entry);
+ surface = gtk_native_get_surface (gtk_widget_get_native (completion->priv->entry));
if (!surface)
return;
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index 08c7a74d2c..89fad7b3af 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -529,7 +529,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
if (transient_for)
{
gtk_widget_realize (GTK_WIDGET (transient_for));
- data->parent = gdk_quartz_surface_get_nswindow (gtk_widget_get_surface (GTK_WIDGET (transient_for)));
+ data->parent = gdk_quartz_surface_get_nswindow (gtk_native_get_surface (GTK_NATIVE (transient_for)));
if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
data->modal = TRUE;
diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c
index eb1dc1b5a5..50b787aed2 100644
--- a/gtk/gtkfilechoosernativewin32.c
+++ b/gtk/gtkfilechoosernativewin32.c
@@ -790,7 +790,7 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
if (transient_for)
{
gtk_widget_realize (GTK_WIDGET (transient_for));
- data->parent = gdk_win32_surface_get_handle (gtk_widget_get_surface (GTK_WIDGET (transient_for)));
+ data->parent = gdk_win32_surface_get_handle (gtk_native_get_surface (GTK_NATIVE (transient_for)));
if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
data->modal = TRUE;
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index 6296ba3444..87dd35cba1 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -605,7 +605,7 @@ gesture_within_surface (GtkGesture *gesture,
GtkWidget *widget;
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
- return surface == gtk_widget_get_surface (widget);
+ return surface == gtk_native_get_surface (gtk_widget_get_native (widget));
}
static gboolean
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c
index 3d5e47d6d9..5f91f32fef 100644
--- a/gtk/gtkglarea.c
+++ b/gtk/gtkglarea.c
@@ -28,6 +28,7 @@
#include "gtkprivate.h"
#include "gtkrender.h"
#include "gtksnapshot.h"
+#include "gtknative.h"
#include <epoxy/gl.h>
@@ -312,7 +313,7 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
GError *error = NULL;
GdkGLContext *context;
- context = gdk_surface_create_gl_context (gtk_widget_get_surface (widget), &error);
+ context = gdk_surface_create_gl_context (gtk_native_get_surface (gtk_widget_get_native (widget)), &error);
if (error != NULL)
{
gtk_gl_area_set_error (area, error);
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index d9930de818..9a65e2d16d 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -36,6 +36,7 @@
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowprivate.h"
+#include "gtknative.h"
#include "a11y/gtkcontaineraccessible.h"
@@ -1681,7 +1682,7 @@ gtk_header_bar_realize (GtkWidget *widget)
G_CALLBACK (_gtk_header_bar_update_window_buttons), widget);
g_signal_connect_swapped (settings, "notify::gtk-decoration-layout",
G_CALLBACK (_gtk_header_bar_update_window_buttons), widget);
- g_signal_connect_swapped (_gtk_widget_get_surface (widget), "notify::state",
+ g_signal_connect_swapped (gtk_native_get_surface (gtk_widget_get_native (widget)), "notify::state",
G_CALLBACK (surface_state_changed), widget);
_gtk_header_bar_update_window_buttons (GTK_HEADER_BAR (widget));
}
@@ -1694,7 +1695,7 @@ gtk_header_bar_unrealize (GtkWidget *widget)
settings = gtk_widget_get_settings (widget);
g_signal_handlers_disconnect_by_func (settings, _gtk_header_bar_update_window_buttons, widget);
- g_signal_handlers_disconnect_by_func (_gtk_widget_get_surface (widget), surface_state_changed, widget);
+ g_signal_handlers_disconnect_by_func (gtk_native_get_surface (gtk_widget_get_native (widget)),
surface_state_changed, widget);
GTK_WIDGET_CLASS (gtk_header_bar_parent_class)->unrealize (widget);
}
@@ -1706,7 +1707,7 @@ surface_state_changed (GtkWidget *widget)
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GdkSurfaceState changed, new_state;
- new_state = gdk_surface_get_state (_gtk_widget_get_surface (widget));
+ new_state = gdk_surface_get_state (gtk_native_get_surface (gtk_widget_get_native (widget)));
changed = new_state ^ priv->state;
priv->state = new_state;
diff --git a/gtk/gtkimcontextime.c b/gtk/gtkimcontextime.c
index 584ff41d9b..151d8b55f1 100644
--- a/gtk/gtkimcontextime.c
+++ b/gtk/gtkimcontextime.c
@@ -251,13 +251,11 @@ gtk_im_context_ime_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
{
GtkIMContextIME *context_ime;
- GtkWidget *toplevel;
GdkSurface *client_surface;
g_return_if_fail (GTK_IS_IM_CONTEXT_IME (context));
context_ime = GTK_IM_CONTEXT_IME (context);
- toplevel = gtk_widget_get_toplevel (widget);
- client_surface = gtk_widget_get_surface (toplevel);
+ client_surface = gtk_native_get_surface (gtk_widget_get_native (widget));
if (client_surface)
{
diff --git a/gtk/gtkimcontextxim.c b/gtk/gtkimcontextxim.c
index fe5f59e8eb..203bc6205b 100644
--- a/gtk/gtkimcontextxim.c
+++ b/gtk/gtkimcontextxim.c
@@ -576,7 +576,7 @@ gtk_im_context_xim_set_client_widget (GtkIMContext *context,
GdkSurface *surface = NULL;
if (widget != NULL)
- surface = gtk_widget_get_surface (gtk_widget_get_toplevel (widget));
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
set_ic_client_surface (context_xim, surface);
}
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 5c799a7dee..1c38d48069 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1469,7 +1469,12 @@ synth_crossing (GtkWidget *widget,
gdouble x, y;
event = gdk_event_new (enter ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
if (related_target)
- event->crossing.child_surface = g_object_ref (gtk_widget_get_surface (related_target));
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (related_target));
+ event->crossing.child_surface = g_object_ref (surface);
+ }
gdk_event_get_coords (source, &x, &y);
event->crossing.x = x;
event->crossing.y = y;
@@ -1484,7 +1489,7 @@ synth_crossing (GtkWidget *widget,
gdk_event_set_device (event, gdk_event_get_device (source));
gdk_event_set_source_device (event, gdk_event_get_source_device (source));
- event->any.surface = gtk_widget_get_surface (toplevel);
+ event->any.surface = gtk_native_get_surface (gtk_widget_get_native (toplevel));
if (event->any.surface)
g_object_ref (event->any.surface);
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index c856ae546c..f99126c864 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -116,6 +116,7 @@
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
#include "gtkeventcontrollerkey.h"
+#include "gtknative.h"
#include "a11y/gtkmenuaccessible.h"
@@ -1283,7 +1284,7 @@ associate_menu_grab_transfer_surface (GtkMenu *menu)
GdkSurface *toplevel_surface;
GdkSurface *transfer_surface;
- toplevel_surface = gtk_widget_get_surface (priv->toplevel);
+ toplevel_surface = gtk_native_get_surface (GTK_NATIVE (priv->toplevel));
transfer_surface = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-surface");
if (toplevel_surface == NULL || transfer_surface == NULL)
@@ -1388,7 +1389,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
if (xgrab_shell && xgrab_shell != widget)
{
- if (popup_grab_on_surface (gtk_widget_get_surface (xgrab_shell), pointer))
+ if (popup_grab_on_surface (gtk_native_get_surface (gtk_widget_get_native (xgrab_shell)), pointer))
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
@@ -1483,7 +1484,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
gtk_widget_show (priv->toplevel);
if (xgrab_shell == widget)
- popup_grab_on_surface (gtk_widget_get_surface (widget), pointer); /* Should always succeed */
+ popup_grab_on_surface (gtk_native_get_surface (gtk_widget_get_native (widget)), pointer); /* Should
always succeed */
gtk_grab_add (GTK_WIDGET (menu));
@@ -2221,7 +2222,7 @@ menu_grab_transfer_surface_destroy (GtkMenu *menu)
gdk_surface_destroy (surface);
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-transfer-surface"), NULL);
- widget_surface = gtk_widget_get_surface (GTK_WIDGET (menu));
+ widget_surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (menu)));
g_object_set_data (G_OBJECT (widget_surface), I_("gdk-attached-grab-surface"), surface);
}
}
@@ -2600,7 +2601,7 @@ pointer_in_menu_surface (GtkWidget *widget,
GtkMenuShell *menu_shell;
gint surface_x, surface_y;
- gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
+ gdk_surface_get_position (gtk_native_get_surface (GTK_NATIVE (priv->toplevel)),
&surface_x, &surface_y);
gtk_widget_get_allocation (widget, &allocation);
@@ -2825,7 +2826,7 @@ gtk_menu_scroll_by (GtkMenu *menu,
if ((priv->scroll_offset >= 0) && (offset < 0))
offset = 0;
- view_height = gdk_surface_get_height (gtk_widget_get_surface (widget));
+ view_height = gdk_surface_get_height (gtk_native_get_surface (gtk_widget_get_native (widget)));
if (priv->scroll_offset == 0 &&
view_height >= priv->requested_height)
@@ -2891,7 +2892,7 @@ get_arrows_sensitive_area (GtkMenu *menu,
&bottom_arrow_height, NULL,
NULL, NULL);
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
width = gdk_surface_get_width (surface);
height = gdk_surface_get_height (surface);
@@ -2929,7 +2930,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
menu_shell = GTK_MENU_SHELL (menu);
- gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
+ gdk_surface_get_position (gtk_native_get_surface (GTK_NATIVE (priv->toplevel)),
&top_x, &top_y);
x -= top_x;
y -= top_y;
@@ -3146,7 +3147,7 @@ pointer_on_menu_widget (GtkMenu *menu,
gint surface_x, surface_y;
gtk_widget_get_allocation (GTK_WIDGET (menu), &allocation);
- gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
+ gdk_surface_get_position (gtk_native_get_surface (GTK_NATIVE (priv->toplevel)),
&surface_x, &surface_y);
if (x_root >= surface_x && x_root < surface_x + allocation.width &&
@@ -3237,7 +3238,7 @@ gtk_menu_captured_event (GtkWidget *widget,
y_diff = y_root - priv->drag_start_y;
offset = priv->initial_drag_offset - y_diff;
- view_height = gdk_surface_get_height (gtk_widget_get_surface (widget));
+ view_height = gdk_surface_get_height (gtk_native_get_surface (gtk_widget_get_native (widget)));
get_arrows_border (menu, &arrow_border);
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
@@ -3414,7 +3415,7 @@ gtk_menu_position (GtkMenu *menu,
}
else if (priv->widget)
{
- rect_surface = gtk_widget_get_surface (priv->widget);
+ rect_surface = gtk_native_get_surface (gtk_widget_get_native (priv->widget));
gtk_widget_get_surface_allocation (priv->widget, &rect);
text_direction = gtk_widget_get_direction (priv->widget);
}
@@ -3440,7 +3441,7 @@ gtk_menu_position (GtkMenu *menu,
menu_anchor = get_horizontally_flipped_anchor (menu_anchor);
}
- toplevel = gtk_widget_get_surface (priv->toplevel);
+ toplevel = gtk_native_get_surface (GTK_NATIVE (priv->toplevel));
gdk_surface_set_transient_for (toplevel, rect_surface);
@@ -3565,7 +3566,7 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
if (compute_child_offset (menu, menu_item, &child_offset, &child_height))
{
y = priv->scroll_offset;
- height = gdk_surface_get_height (gtk_widget_get_surface (widget));
+ height = gdk_surface_get_height (gtk_native_get_surface (gtk_widget_get_native (widget)));
if (child_offset < y)
{
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 07f9dea4ff..e6579a2469 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1398,7 +1398,7 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
/* Position the submenu at the menu item if it is mapped.
* Otherwise, position the submenu at the pointer device.
*/
- if (gtk_widget_get_surface (widget))
+ if (gtk_native_get_surface (gtk_widget_get_native (widget)))
{
switch (priv->submenu_placement)
{
diff --git a/gtk/gtkmnemonichash.c b/gtk/gtkmnemonichash.c
index 03488e2887..e6504842e1 100644
--- a/gtk/gtkmnemonichash.c
+++ b/gtk/gtkmnemonichash.c
@@ -17,7 +17,10 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+
#include "gtkmnemonichash.h"
+#include "gtknative.h"
struct _GtkMnemnonicHash
{
@@ -124,7 +127,7 @@ _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
for (list = targets; list; list = list->next)
{
widget = GTK_WIDGET (list->data);
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
if (gtk_widget_is_sensitive (widget) &&
gtk_widget_get_mapped (widget) &&
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 16c033a553..6cc52fd6fe 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4205,7 +4205,7 @@ gtk_notebook_remove_tab_label (GtkNotebook *notebook,
page->mnemonic_activate_signal);
page->mnemonic_activate_signal = 0;
- if (gtk_widget_get_surface (page->tab_label) != gtk_widget_get_surface (GTK_WIDGET (notebook)) ||
+ if (gtk_widget_get_native (page->tab_label) != gtk_widget_get_native (GTK_WIDGET (notebook)) ||
!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page))
{
GtkWidget *parent;
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 00f6046cf7..f624276adc 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -359,7 +359,7 @@ surface_state_changed (GtkWidget *widget)
GdkSurfaceState new_surface_state;
GdkSurfaceState changed_mask;
- new_surface_state = gdk_surface_get_state (_gtk_widget_get_surface (widget));
+ new_surface_state = gdk_surface_get_state (priv->surface);
changed_mask = new_surface_state ^ priv->state;
priv->state = new_surface_state;
@@ -563,12 +563,14 @@ gtk_popover_realize (GtkWidget *widget)
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
GdkRectangle parent_rect;
GdkDisplay *display;
+ GdkSurface *parent;
gtk_widget_get_surface_allocation (priv->relative_to, &parent_rect);
display = gtk_widget_get_display (priv->relative_to);
- priv->surface = gdk_surface_new_popup (display, gtk_widget_get_surface (priv->relative_to),
priv->autohide);
+ parent = gtk_native_get_surface (gtk_widget_get_native (priv->relative_to));
+ priv->surface = gdk_surface_new_popup (display, parent, priv->autohide);
gdk_surface_set_widget (priv->surface, widget);
@@ -975,23 +977,22 @@ gtk_popover_fill_border_path (GtkPopover *popover,
static void
gtk_popover_update_shape (GtkPopover *popover)
{
+ GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
GtkWidget *widget = GTK_WIDGET (popover);
cairo_surface_t *cairo_surface;
cairo_region_t *region;
- GdkSurface *surface;
cairo_t *cr;
-#ifdef GDK_WINDOWING_WAYLAND
+#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
return;
#endif
- surface = gtk_widget_get_surface (widget);
cairo_surface =
- gdk_surface_create_similar_surface (surface,
+ gdk_surface_create_similar_surface (priv->surface,
CAIRO_CONTENT_COLOR_ALPHA,
- gdk_surface_get_width (surface),
- gdk_surface_get_height (surface));
+ gdk_surface_get_width (priv->surface),
+ gdk_surface_get_height (priv->surface));
cr = cairo_create (cairo_surface);
gtk_popover_fill_border_path (popover, cr);
diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c
index 4f21c1f17f..9a9a4e5fe5 100644
--- a/gtk/gtkprintoperation-win32.c
+++ b/gtk/gtkprintoperation-win32.c
@@ -676,8 +676,11 @@ op_win32_free (GtkPrintOperationWin32 *op_win32)
static HWND
get_parent_hwnd (GtkWidget *widget)
{
- gtk_widget_realize (widget);
- return gdk_win32_surface_get_handle (gtk_widget_get_surface (widget));
+ GtkNative *native;
+
+ native = gtk_widget_get_native (widget);
+ gtk_widget_realize (GTK_WIDGET (native));
+ return gdk_win32_surface_get_handle (gtk_native_get_surface (native));
}
static void
@@ -1361,7 +1364,7 @@ plug_grab_notify (GtkWidget *widget,
gboolean was_grabbed,
GtkPrintOperation *op)
{
- EnableWindow (GetAncestor (GDK_SURFACE_HWND (gtk_widget_get_surface (widget)), GA_ROOT),
+ EnableWindow (GetAncestor (GDK_SURFACE_HWND (gtk_native_get_surface (gtk_widget_get_native (widget))),
GA_ROOT),
was_grabbed);
}
@@ -1387,7 +1390,7 @@ pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
gtk_container_add (GTK_CONTAINER (plug), op->priv->custom_widget);
gtk_widget_show (op->priv->custom_widget);
gtk_widget_show (plug);
- gdk_surface_focus (gtk_widget_get_surface (plug), GDK_CURRENT_TIME);
+ gdk_surface_focus (gtk_native_get_surface (gtk_widget_get_native (plug)), GDK_CURRENT_TIME);
/* This dialog is modal, so we grab the embed widget */
gtk_grab_add (plug);
@@ -1720,7 +1723,7 @@ gtk_print_operation_run_with_dialog (GtkPrintOperation *op,
invisible = gtk_window_new (GTK_WINDOW_POPUP);
parentHWnd = get_parent_hwnd (invisible);
}
- else
+ else
parentHWnd = get_parent_hwnd (GTK_WIDGET (parent));
printdlgex = (LPPRINTDLGEXW)GlobalAlloc (GPTR, sizeof (PRINTDLGEXW));
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 6a4db5f041..6ce040676f 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -8650,7 +8650,7 @@ gtk_text_view_do_popup (GtkTextView *text_view,
&iter_location.y);
gtk_menu_popup_at_rect (GTK_MENU (priv->popup_menu),
- gtk_widget_get_surface (GTK_WIDGET (text_view)),
+ gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET
(text_view))),
&iter_location,
GDK_GRAVITY_SOUTH_EAST,
GDK_GRAVITY_NORTH_WEST,
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 0012e5039d..28c1c718a8 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -400,7 +400,7 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
toplevel = gtk_widget_get_toplevel (widget);
- if (gtk_widget_get_surface (toplevel) != surface)
+ if (gtk_native_get_surface (GTK_NATIVE (toplevel)) != surface)
return;
gtk_widget_translate_coordinates (toplevel, widget, round (x), round (y), &dx, &dy);
@@ -581,7 +581,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
int anchor_rect_padding;
gtk_widget_realize (GTK_WIDGET (tooltip->current_window));
- surface = _gtk_widget_get_surface (GTK_WIDGET (tooltip->current_window));
+ surface = gtk_native_get_surface (GTK_NATIVE (tooltip->current_window));
tooltip->tooltip_widget = new_tooltip_widget;
@@ -636,7 +636,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
* If the anchor rectangle isn't to tall, make sure the tooltip isn't too
* far away from the pointer position.
*/
- effective_toplevel = _gtk_widget_get_surface (toplevel);
+ effective_toplevel = gtk_native_get_surface (GTK_NATIVE (toplevel));
gdk_surface_get_device_position (effective_toplevel, device, &px, &py, NULL);
pointer_x = round (px);
pointer_y = round (py);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 53902a36d3..b72794c521 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -62,6 +62,7 @@
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowgroup.h"
+#include "gtknative.h"
#include "a11y/gtktreeviewaccessibleprivate.h"
@@ -10059,7 +10060,7 @@ send_focus_change (GtkWidget *widget,
GdkEvent *fevent;
GdkSurface *surface;
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
fevent = gdk_event_new (GDK_FOCUS_CHANGE);
diff --git a/gtk/gtkvideo.c b/gtk/gtkvideo.c
index 3543d458a4..3813d4e80c 100644
--- a/gtk/gtkvideo.c
+++ b/gtk/gtkvideo.c
@@ -26,6 +26,7 @@
#include "gtkintl.h"
#include "gtkmediacontrols.h"
#include "gtkmediafile.h"
+#include "gtknative.h"
#include "gtkpicture.h"
#include "gtkrevealer.h"
@@ -141,7 +142,12 @@ gtk_video_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_video_parent_class)->realize (widget);
if (self->media_stream)
- gtk_media_stream_realize (self->media_stream, gtk_widget_get_surface (GTK_WIDGET (self)));
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
+ gtk_media_stream_realize (self->media_stream, surface);
+ }
if (self->file)
gtk_media_file_set_file (GTK_MEDIA_FILE (self->media_stream), self->file);
@@ -153,7 +159,12 @@ gtk_video_unrealize (GtkWidget *widget)
GtkVideo *self = GTK_VIDEO (widget);
if (self->media_stream)
- gtk_media_stream_unrealize (self->media_stream, gtk_widget_get_surface (GTK_WIDGET (self)));
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
+ gtk_media_stream_unrealize (self->media_stream, surface);
+ }
GTK_WIDGET_CLASS (gtk_video_parent_class)->unrealize (widget);
}
@@ -580,7 +591,12 @@ gtk_video_set_media_stream (GtkVideo *self,
gtk_video_notify_cb,
self);
if (gtk_widget_get_realized (GTK_WIDGET (self)))
- gtk_media_stream_unrealize (self->media_stream, gtk_widget_get_surface (GTK_WIDGET (self)));
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
+ gtk_media_stream_unrealize (self->media_stream, surface);
+ }
g_object_unref (self->media_stream);
self->media_stream = NULL;
}
@@ -590,7 +606,12 @@ gtk_video_set_media_stream (GtkVideo *self,
self->media_stream = g_object_ref (stream);
gtk_media_stream_set_loop (stream, self->loop);
if (gtk_widget_get_realized (GTK_WIDGET (self)))
- gtk_media_stream_realize (stream, gtk_widget_get_surface (GTK_WIDGET (self)));
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
+ gtk_media_stream_realize (stream, surface);
+ }
g_signal_connect (self->media_stream,
"notify",
G_CALLBACK (gtk_video_notify_cb),
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 87e63f622a..b9a8eff59b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7219,6 +7219,7 @@ _gtk_widget_scale_changed (GtkWidget *widget)
gint
gtk_widget_get_scale_factor (GtkWidget *widget)
{
+ GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkRoot *root;
GdkDisplay *display;
GdkMonitor *monitor;
@@ -7226,7 +7227,7 @@ gtk_widget_get_scale_factor (GtkWidget *widget)
g_return_val_if_fail (GTK_IS_WIDGET (widget), 1);
if (_gtk_widget_get_realized (widget))
- return gdk_surface_get_scale_factor (_gtk_widget_get_surface (widget));
+ return gdk_surface_get_scale_factor (priv->surface);
root = _gtk_widget_get_root (widget);
if (root && GTK_WIDGET (root) != widget)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5ecd0c9ea2..6d2d76731b 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1305,6 +1305,7 @@ gtk_window_titlebar_action (GtkWindow *window,
guint button,
gint n_press)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkSettings *settings;
gchar *action = NULL;
gboolean retval = TRUE;
@@ -1343,9 +1344,9 @@ gtk_window_titlebar_action (GtkWindow *window,
_gtk_window_toggle_maximized (window);
}
else if (g_str_equal (action, "lower"))
- gdk_surface_lower (_gtk_widget_get_surface (GTK_WIDGET (window)));
+ gdk_surface_lower (priv->surface);
else if (g_str_equal (action, "minimize"))
- gdk_surface_iconify (_gtk_widget_get_surface (GTK_WIDGET (window)));
+ gdk_surface_iconify (priv->surface);
else if (g_str_equal (action, "menu"))
gtk_window_do_popup (window, (GdkEventButton*) event);
else
@@ -1366,16 +1367,15 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
gdouble y,
GtkWindow *window)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *event_widget, *widget;
GdkEventSequence *sequence;
GtkWindowRegion region;
- GtkWindowPrivate *priv;
const GdkEvent *event;
guint button;
gboolean window_drag = FALSE;
widget = GTK_WIDGET (window);
- priv = gtk_window_get_instance_private (window);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
@@ -1418,7 +1418,7 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
event_widget = gtk_get_event_widget ((GdkEvent *) event);
if (region == GTK_WINDOW_REGION_TITLE)
- gdk_surface_raise (_gtk_widget_get_surface (widget));
+ gdk_surface_raise (priv->surface);
switch (region)
{
@@ -1459,7 +1459,7 @@ multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gdk_event_get_coords (event, &tx, &ty);
- gdk_surface_begin_resize_drag_for_device (_gtk_widget_get_surface (widget),
+ gdk_surface_begin_resize_drag_for_device (priv->surface,
(GdkSurfaceEdge) region,
gdk_event_get_device ((GdkEvent *) event),
GDK_BUTTON_PRIMARY,
@@ -1569,7 +1569,7 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
- gdk_surface_begin_move_drag_for_device (_gtk_widget_get_surface (GTK_WIDGET (window)),
+ gdk_surface_begin_move_drag_for_device (priv->surface,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE
(gesture)),
(int)start_x, (int)start_y,
@@ -1664,7 +1664,7 @@ edge_under_coordinates (GtkWindow *window,
priv->maximized)
return FALSE;
- supports_edge_constraints = gdk_surface_supports_edge_constraints (_gtk_widget_get_surface (GTK_WIDGET
(window)));
+ supports_edge_constraints = gdk_surface_supports_edge_constraints (priv->surface);
constraints = constraints_for_edge (edge);
if (!supports_edge_constraints && priv->tiled)
@@ -2471,19 +2471,16 @@ gtk_window_set_title_internal (GtkWindow *window,
gboolean update_titlebar)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GtkWidget *widget;
char *new_title;
g_return_if_fail (GTK_IS_WINDOW (window));
- widget = GTK_WIDGET (window);
-
new_title = g_strdup (title);
g_free (priv->title);
priv->title = new_title;
- if (_gtk_widget_get_realized (widget))
- gdk_surface_set_title (_gtk_widget_get_surface (widget), new_title != NULL ? new_title : "");
+ if (_gtk_widget_get_realized (GTK_WIDGET (window)))
+ gdk_surface_set_title (priv->surface, new_title != NULL ? new_title : "");
if (update_titlebar && GTK_IS_HEADER_BAR (priv->title_box))
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->title_box), new_title != NULL ? new_title : "");
@@ -2567,14 +2564,11 @@ gtk_window_set_startup_id (GtkWindow *window,
if (_gtk_widget_get_realized (widget))
{
- GdkSurface *surface;
guint32 timestamp = extract_time_from_startup_id (priv->startup_id);
- surface = _gtk_widget_get_surface (widget);
-
#ifdef GDK_WINDOWING_X11
- if (timestamp != GDK_CURRENT_TIME && GDK_IS_X11_SURFACE(surface))
- gdk_x11_surface_set_user_time (surface, timestamp);
+ if (timestamp != GDK_CURRENT_TIME && GDK_IS_X11_SURFACE (priv->surface))
+ gdk_x11_surface_set_user_time (priv->surface, timestamp);
#endif
/* Here we differentiate real and "fake" startup notification IDs,
@@ -2584,7 +2578,7 @@ gtk_window_set_startup_id (GtkWindow *window,
gtk_window_present_with_time (window, timestamp);
else
{
- gdk_surface_set_startup_id (surface, priv->startup_id);
+ gdk_surface_set_startup_id (priv->surface, priv->startup_id);
/* If window is mapped, terminate the startup-notification too */
if (_gtk_widget_get_mapped (widget) && !disable_startup_notification)
@@ -2983,7 +2977,7 @@ gtk_window_set_modal (GtkWindow *window,
/* adjust desired modality state */
if (_gtk_widget_get_realized (widget))
- gdk_surface_set_modal_hint (_gtk_widget_get_surface (widget), priv->modal);
+ gdk_surface_set_modal_hint (priv->surface, priv->modal);
if (gtk_widget_get_visible (widget))
{
@@ -3141,17 +3135,19 @@ static void
gtk_window_transient_parent_realized (GtkWidget *parent,
GtkWidget *window)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
+ GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (GTK_WINDOW (parent));
if (_gtk_widget_get_realized (window))
- gdk_surface_set_transient_for (_gtk_widget_get_surface (window),
- _gtk_widget_get_surface (parent));
+ gdk_surface_set_transient_for (priv->surface, parent_priv->surface);
}
static void
gtk_window_transient_parent_unrealized (GtkWidget *parent,
GtkWidget *window)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
if (_gtk_widget_get_realized (window))
- gdk_surface_set_transient_for (_gtk_widget_get_surface (window), NULL);
+ gdk_surface_set_transient_for (priv->surface, NULL);
}
static void
@@ -3470,14 +3466,12 @@ gtk_window_set_application (GtkWindow *window,
*
* gtk_dialog_new_with_buttons() and other convenience functions in GTK+
* will sometimes call gtk_window_set_type_hint() on your behalf.
- *
**/
void
-gtk_window_set_type_hint (GtkWindow *window,
- GdkSurfaceTypeHint hint)
+gtk_window_set_type_hint (GtkWindow *window,
+ GdkSurfaceTypeHint hint)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *surface;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -3486,9 +3480,8 @@ gtk_window_set_type_hint (GtkWindow *window,
priv->type_hint = hint;
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
- if (surface)
- gdk_surface_set_type_hint (surface, hint);
+ if (priv->surface)
+ gdk_surface_set_type_hint (priv->surface, hint);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_TYPE_HINT]);
@@ -3535,8 +3528,7 @@ gtk_window_set_accept_focus (GtkWindow *window,
{
priv->accept_focus = setting;
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
- gdk_surface_set_accept_focus (_gtk_widget_get_surface (GTK_WIDGET (window)),
- priv->accept_focus);
+ gdk_surface_set_accept_focus (priv->surface, priv->accept_focus);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_ACCEPT_FOCUS]);
}
}
@@ -3582,8 +3574,7 @@ gtk_window_set_focus_on_map (GtkWindow *window,
{
priv->focus_on_map = setting;
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
- gdk_surface_set_focus_on_map (_gtk_widget_get_surface (GTK_WIDGET (window)),
- priv->focus_on_map);
+ gdk_surface_set_focus_on_map (priv->surface, priv->focus_on_map);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_FOCUS_ON_MAP]);
}
}
@@ -3935,7 +3926,6 @@ gtk_window_set_decorated (GtkWindow *window,
gboolean setting)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *surface;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -3946,18 +3936,17 @@ gtk_window_set_decorated (GtkWindow *window,
priv->decorated = setting;
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
- if (surface)
+ if (priv->surface)
{
if (priv->decorated)
{
if (priv->client_decorated)
- gdk_surface_set_decorations (surface, 0);
+ gdk_surface_set_decorations (priv->surface, 0);
else
- gdk_surface_set_decorations (surface, GDK_DECOR_ALL);
+ gdk_surface_set_decorations (priv->surface, GDK_DECOR_ALL);
}
else
- gdk_surface_set_decorations (surface, 0);
+ gdk_surface_set_decorations (priv->surface, 0);
}
update_window_buttons (window);
@@ -4006,7 +3995,6 @@ gtk_window_set_deletable (GtkWindow *window,
gboolean setting)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *surface;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -4017,15 +4005,13 @@ gtk_window_set_deletable (GtkWindow *window,
priv->deletable = setting;
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
- if (surface)
+ if (priv->surface)
{
if (priv->deletable)
- gdk_surface_set_functions (surface,
- GDK_FUNC_ALL);
+ gdk_surface_set_functions (priv->surface, GDK_FUNC_ALL);
else
- gdk_surface_set_functions (surface,
- GDK_FUNC_ALL | GDK_FUNC_CLOSE);
+ gdk_surface_set_functions (priv->surface,
+ GDK_FUNC_ALL | GDK_FUNC_CLOSE);
}
update_window_buttons (window);
@@ -4136,15 +4122,10 @@ static void
gtk_window_realize_icon (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GtkWidget *widget;
GtkWindowIconInfo *info;
- GdkSurface *surface;
GList *icon_list = NULL;
- widget = GTK_WIDGET (window);
- surface = _gtk_widget_get_surface (widget);
-
- g_return_if_fail (surface != NULL);
+ g_return_if_fail (priv->surface != NULL);
/* no point setting an icon on override-redirect */
if (priv->type == GTK_WINDOW_POPUP)
@@ -4176,14 +4157,12 @@ gtk_window_realize_icon (GtkWindow *window)
info->realized = TRUE;
- gdk_surface_set_icon_list (surface, icon_list);
+ gdk_surface_set_icon_list (priv->surface, icon_list);
if (GTK_IS_HEADER_BAR (priv->title_box))
_gtk_header_bar_update_window_icon (GTK_HEADER_BAR (priv->title_box), window);
- if (info->using_themed_icon)
- {
- g_list_free_full (icon_list, g_object_unref);
- }
+ if (info->using_themed_icon)
+ g_list_free_full (icon_list, g_object_unref);
}
GdkTexture *
@@ -4489,7 +4468,7 @@ gtk_window_set_default_size_internal (GtkWindow *window,
* gtk_window_get_size(). Using the window allocation directly will not
* work in all circumstances and can lead to growing or shrinking windows.
*/
-void
+void
gtk_window_set_default_size (GtkWindow *window,
gint width,
gint height)
@@ -4674,8 +4653,9 @@ gtk_window_get_size (GtkWindow *window,
gint *width,
gint *height)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gint w, h;
-
+
g_return_if_fail (GTK_IS_WINDOW (window));
if (width == NULL && height == NULL)
@@ -4683,8 +4663,8 @@ gtk_window_get_size (GtkWindow *window,
if (_gtk_widget_get_mapped (GTK_WIDGET (window)))
{
- w = gdk_surface_get_width (_gtk_widget_get_surface (GTK_WIDGET (window)));
- h = gdk_surface_get_height (_gtk_widget_get_surface (GTK_WIDGET (window)));
+ w = gdk_surface_get_width (priv->surface);
+ h = gdk_surface_get_height (priv->surface);
}
else
{
@@ -5128,7 +5108,6 @@ gtk_window_unmap (GtkWidget *widget)
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *child;
GtkWindowGeometryInfo *info;
- GdkSurface *surface;
GdkSurfaceState state;
if (!_gtk_widget_is_toplevel (GTK_WIDGET (widget)))
@@ -5137,15 +5116,13 @@ gtk_window_unmap (GtkWidget *widget)
return;
}
- surface = priv->surface;
-
GTK_WIDGET_CLASS (gtk_window_parent_class)->unmap (widget);
- gdk_surface_hide (surface);
+ gdk_surface_hide (priv->surface);
while (priv->configure_request_count > 0)
{
priv->configure_request_count--;
- gdk_surface_thaw_toplevel_updates (_gtk_widget_get_surface (widget));
+ gdk_surface_thaw_toplevel_updates (priv->surface);
}
priv->configure_notify_received = FALSE;
@@ -5162,7 +5139,7 @@ gtk_window_unmap (GtkWidget *widget)
info->position_constraints_changed = FALSE;
}
- state = gdk_surface_get_state (surface);
+ state = gdk_surface_get_state (priv->surface);
priv->iconify_initially = (state & GDK_SURFACE_STATE_ICONIFIED) != 0;
priv->maximize_initially = (state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
priv->stick_initially = (state & GDK_SURFACE_STATE_STICKY) != 0;
@@ -5252,17 +5229,16 @@ gtk_window_get_remembered_size (GtkWindow *window,
int *width,
int *height)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWindowGeometryInfo *info;
- GdkSurface *surface;
*width = 0;
*height = 0;
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
- if (surface)
+ if (priv->surface)
{
- *width = gdk_surface_get_width (surface);
- *height = gdk_surface_get_height (surface);
+ *width = gdk_surface_get_width (priv->surface);
+ *height = gdk_surface_get_height (priv->surface);
return;
}
@@ -5527,12 +5503,10 @@ static void
update_shadow_width (GtkWindow *window,
GtkBorder *border)
{
- GdkSurface *surface;
-
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- if (surface)
- gdk_surface_set_shadow_width (surface,
+ if (priv->surface)
+ gdk_surface_set_shadow_width (priv->surface,
border->left,
border->right,
border->top,
@@ -5586,6 +5560,7 @@ update_opaque_region (GtkWindow *window,
const GtkBorder *border,
const GtkAllocation *allocation)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *widget = GTK_WIDGET (window);
cairo_region_t *opaque_region;
GtkStyleContext *context;
@@ -5619,7 +5594,7 @@ update_opaque_region (GtkWindow *window,
opaque_region = NULL;
}
- gdk_surface_set_opaque_region (_gtk_widget_get_surface (widget), opaque_region);
+ gdk_surface_set_opaque_region (priv->surface, opaque_region);
cairo_region_destroy (opaque_region);
}
@@ -5712,8 +5687,10 @@ gtk_window_realize (GtkWidget *widget)
if (priv->transient_parent &&
_gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)))
- gdk_surface_set_transient_for (surface,
- _gtk_widget_get_surface (GTK_WIDGET (priv->transient_parent)));
+ {
+ GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (priv->transient_parent);
+ gdk_surface_set_transient_for (surface, parent_priv->surface);
+ }
gdk_surface_set_type_hint (surface, priv->type_hint);
@@ -5999,7 +5976,7 @@ _gtk_window_set_allocation (GtkWindow *window,
if (!_gtk_widget_is_toplevel (widget) && _gtk_widget_get_realized (widget))
{
- gdk_surface_move_resize (_gtk_widget_get_surface (widget), 0, 0, width, height);
+ gdk_surface_move_resize (priv->surface, 0, 0, width, height);
}
*allocation_out = child_allocation;
@@ -6074,7 +6051,7 @@ gtk_window_configure (GtkWindow *window,
{
priv->configure_request_count -= 1;
- gdk_surface_thaw_toplevel_updates (_gtk_widget_get_surface (widget));
+ gdk_surface_thaw_toplevel_updates (priv->surface);
}
/*
@@ -6119,7 +6096,7 @@ surface_state_changed (GtkWidget *widget)
GdkSurfaceState new_surface_state;
GdkSurfaceState changed_mask;
- new_surface_state = gdk_surface_get_state (_gtk_widget_get_surface (widget));
+ new_surface_state = gdk_surface_get_state (priv->surface);
changed_mask = new_surface_state ^ priv->state;
priv->state = new_surface_state;
@@ -6333,8 +6310,7 @@ gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
GdkDevice *dev = gdk_seat_get_pointer (s->data);
GdkModifierType mask;
- gdk_device_get_state (dev, _gtk_widget_get_surface (GTK_WIDGET (window)),
- NULL, &mask);
+ gdk_device_get_state (dev, priv->surface, NULL, &mask);
if (priv->mnemonic_modifier == (mask & gtk_accelerator_get_default_mod_mask ()))
{
retval = TRUE;
@@ -6571,7 +6547,7 @@ gtk_window_set_focus (GtkWindow *window,
event = gdk_event_new (GDK_FOCUS_CHANGE);
gdk_event_set_display (event, gtk_widget_get_display (GTK_WIDGET (window)));
gdk_event_set_device (event, device);
- event->any.surface = _gtk_widget_get_surface (GTK_WIDGET (window));
+ event->any.surface = priv->surface;
if (event->any.surface)
g_object_ref (event->any.surface);
@@ -6680,17 +6656,12 @@ popup_menu_detach (GtkWidget *widget,
static GdkSurfaceState
gtk_window_get_state (GtkWindow *window)
{
- GdkSurfaceState state;
- GdkSurface *surface;
-
- surface = gtk_widget_get_surface (GTK_WIDGET (window));
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- state = 0;
+ if (priv->surface)
+ return gdk_surface_get_state (priv->surface);
- if (surface)
- state = gdk_surface_get_state (surface);
-
- return state;
+ return 0;
}
static void
@@ -6896,8 +6867,9 @@ static void
gtk_window_do_popup (GtkWindow *window,
GdkEventButton *event)
{
- if (!gdk_surface_show_window_menu (_gtk_widget_get_surface (GTK_WIDGET (window)),
- (GdkEvent *) event))
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
+
+ if (!gdk_surface_show_window_menu (priv->surface, (GdkEvent *) event))
gtk_window_do_popup_fallback (window, event);
}
@@ -6906,7 +6878,7 @@ gtk_window_do_popup (GtkWindow *window,
*********************************/
/* This function doesn't constrain to geometry hints */
-static void
+static void
gtk_window_compute_configure_request_size (GtkWindow *window,
GdkGeometry *geometry,
guint flags,
@@ -7148,17 +7120,16 @@ gtk_window_compute_configure_request (GtkWindow *window,
case GTK_WIN_POS_CENTER_ON_PARENT:
{
GtkAllocation allocation;
- GdkSurface *surface;
GdkMonitor *monitor;
GdkRectangle area;
gint ox, oy;
+ GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (priv->transient_parent);
g_assert (_gtk_widget_get_mapped (parent_widget)); /* established earlier */
- surface = _gtk_widget_get_surface (parent_widget);
- monitor = gdk_display_get_monitor_at_surface (priv->display, surface);
+ monitor = gdk_display_get_monitor_at_surface (priv->display, parent_priv->surface);
- gdk_surface_get_origin (surface, &ox, &oy);
+ gdk_surface_get_origin (parent_priv->surface, &ox, &oy);
gtk_widget_get_allocation (parent_widget, &allocation);
x = ox + (allocation.width - w) / 2;
@@ -7296,7 +7267,7 @@ gtk_window_move_resize (GtkWindow *window)
widget = GTK_WIDGET (window);
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
info = gtk_window_get_geometry_info (window, TRUE);
configure_request_size_changed = FALSE;
@@ -7972,7 +7943,7 @@ gtk_window_present_with_time (GtkWindow *window,
if (gtk_widget_get_visible (widget))
{
- surface = _gtk_widget_get_surface (widget);
+ surface = priv->surface;
g_assert (surface != NULL);
@@ -8025,16 +7996,13 @@ void
gtk_window_iconify (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->iconify_initially = TRUE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_iconify (toplevel);
+ if (priv->surface)
+ gdk_surface_iconify (priv->surface);
}
/**
@@ -8053,16 +8021,13 @@ void
gtk_window_deiconify (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->iconify_initially = FALSE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_deiconify (toplevel);
+ if (priv->surface)
+ gdk_surface_deiconify (priv->surface);
}
/**
@@ -8085,16 +8050,13 @@ void
gtk_window_stick (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->stick_initially = TRUE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_stick (toplevel);
+ if (priv->surface)
+ gdk_surface_stick (priv->surface);
}
/**
@@ -8114,16 +8076,13 @@ void
gtk_window_unstick (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->stick_initially = FALSE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_unstick (toplevel);
+ if (priv->surface)
+ gdk_surface_unstick (priv->surface);
}
/**
@@ -8149,16 +8108,13 @@ void
gtk_window_maximize (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->maximize_initially = TRUE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_maximize (toplevel);
+ if (priv->surface)
+ gdk_surface_maximize (priv->surface);
}
/**
@@ -8178,16 +8134,13 @@ void
gtk_window_unmaximize (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->maximize_initially = FALSE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_unmaximize (toplevel);
+ if (priv->surface)
+ gdk_surface_unmaximize (priv->surface);
}
/**
@@ -8208,16 +8161,13 @@ void
gtk_window_fullscreen (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
priv->fullscreen_initially = TRUE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_fullscreen (toplevel);
+ if (priv->surface)
+ gdk_surface_fullscreen (priv->surface);
}
static void
@@ -8248,15 +8198,11 @@ gtk_window_fullscreen_on_monitor (GtkWindow *window,
GdkMonitor *monitor)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GtkWidget *widget;
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (GDK_IS_MONITOR (monitor));
g_return_if_fail (gdk_monitor_is_valid (monitor));
- widget = GTK_WIDGET (window);
-
gtk_window_set_display (window, gdk_monitor_get_display (monitor));
unset_fullscreen_monitor (window);
@@ -8267,10 +8213,8 @@ gtk_window_fullscreen_on_monitor (GtkWindow *window,
priv->fullscreen_initially = TRUE;
- toplevel = _gtk_widget_get_surface (widget);
-
- if (toplevel != NULL)
- gdk_surface_fullscreen_on_monitor (toplevel, monitor);
+ if (priv->surface)
+ gdk_surface_fullscreen_on_monitor (priv->surface, monitor);
}
/**
@@ -8291,17 +8235,14 @@ void
gtk_window_unfullscreen (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
unset_fullscreen_monitor (window);
priv->fullscreen_initially = FALSE;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_unfullscreen (toplevel);
+ if (priv->surface)
+ gdk_surface_unfullscreen (priv->surface);
}
/**
@@ -8334,7 +8275,6 @@ gtk_window_set_keep_above (GtkWindow *window,
gboolean setting)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -8343,10 +8283,8 @@ gtk_window_set_keep_above (GtkWindow *window,
priv->above_initially = setting;
priv->below_initially &= !setting;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_set_keep_above (toplevel, setting);
+ if (priv->surface)
+ gdk_surface_set_keep_above (priv->surface, setting);
}
/**
@@ -8379,7 +8317,6 @@ gtk_window_set_keep_below (GtkWindow *window,
gboolean setting)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *toplevel;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -8388,10 +8325,8 @@ gtk_window_set_keep_below (GtkWindow *window,
priv->below_initially = setting;
priv->above_initially &= !setting;
- toplevel = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (toplevel != NULL)
- gdk_surface_set_keep_below (toplevel, setting);
+ if (priv->surface)
+ gdk_surface_set_keep_below (priv->surface, setting);
}
/**
@@ -8462,16 +8397,12 @@ gtk_window_begin_resize_drag (GtkWindow *window,
gint y,
guint32 timestamp)
{
- GtkWidget *widget;
- GdkSurface *toplevel;
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
- widget = GTK_WIDGET (window);
- g_return_if_fail (gtk_widget_get_visible (widget));
-
- toplevel = _gtk_widget_get_surface (widget);
+ g_return_if_fail (gtk_widget_get_visible (GTK_WIDGET (window)));
- gdk_surface_begin_resize_drag (toplevel, edge, button, x, y, timestamp);
+ gdk_surface_begin_resize_drag (priv->surface, edge, button, x, y, timestamp);
}
/**
@@ -8492,16 +8423,12 @@ gtk_window_begin_move_drag (GtkWindow *window,
gint y,
guint32 timestamp)
{
- GtkWidget *widget;
- GdkSurface *toplevel;
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
- widget = GTK_WIDGET (window);
- g_return_if_fail (gtk_widget_get_visible (widget));
+ g_return_if_fail (gtk_widget_get_visible (GTK_WIDGET (window)));
- toplevel = _gtk_widget_get_surface (widget);
-
- gdk_surface_begin_move_drag (toplevel, button, x, y, timestamp);
+ gdk_surface_begin_move_drag (priv->surface, button, x, y, timestamp);
}
/**
@@ -8571,18 +8498,15 @@ gtk_window_set_theme_variant (GtkWindow *window)
{
#ifdef GDK_WINDOWING_X11
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
- GdkSurface *surface;
gboolean dark_theme_requested;
g_object_get (gtk_settings_get_for_display (priv->display),
"gtk-application-prefer-dark-theme", &dark_theme_requested,
NULL);
- surface = _gtk_widget_get_surface (GTK_WIDGET (window));
-
- if (GDK_IS_X11_SURFACE (surface))
- gdk_x11_surface_set_theme_variant (surface,
- dark_theme_requested ? "dark" : NULL);
+ if (GDK_IS_X11_SURFACE (priv->surface))
+ gdk_x11_surface_set_theme_variant (priv->surface,
+ dark_theme_requested ? "dark" : NULL);
#endif
}
@@ -9202,12 +9126,10 @@ gtk_window_set_has_user_ref_count (GtkWindow *window,
static void
ensure_state_flag_backdrop (GtkWidget *widget)
{
- GdkSurface *surface;
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (widget));
gboolean surface_focused = TRUE;
- surface = _gtk_widget_get_surface (widget);
-
- surface_focused = gdk_surface_get_state (surface) & GDK_SURFACE_STATE_FOCUSED;
+ surface_focused = gdk_surface_get_state (priv->surface) & GDK_SURFACE_STATE_FOCUSED;
if (!surface_focused)
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_BACKDROP, FALSE);
@@ -9643,13 +9565,13 @@ gtk_window_export_handle (GtkWindow *window,
GtkWindowHandleExported callback,
gpointer user_data)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
{
- GdkSurface *surface = gtk_widget_get_surface (GTK_WIDGET (window));
char *handle_str;
- guint32 xid = (guint32) gdk_x11_surface_get_xid (surface);
+ guint32 xid = (guint32) gdk_x11_surface_get_xid (priv->surface);
handle_str = g_strdup_printf ("x11:%x", xid);
callback (window, handle_str, user_data);
@@ -9661,7 +9583,6 @@ gtk_window_export_handle (GtkWindow *window,
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
{
- GdkSurface *surface = gtk_widget_get_surface (GTK_WIDGET (window));
WaylandSurfaceHandleExportedData *data;
data = g_new0 (WaylandSurfaceHandleExportedData, 1);
@@ -9669,7 +9590,7 @@ gtk_window_export_handle (GtkWindow *window,
data->callback = callback;
data->user_data = user_data;
- if (!gdk_wayland_surface_export_handle (surface,
+ if (!gdk_wayland_surface_export_handle (priv->surface,
wayland_surface_handle_exported,
data,
g_free))
@@ -9692,12 +9613,12 @@ gtk_window_export_handle (GtkWindow *window,
void
gtk_window_unexport_handle (GtkWindow *window)
{
+ GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
+
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
{
- GdkSurface *surface = gtk_widget_get_surface (GTK_WIDGET (window));
-
- gdk_wayland_surface_unexport_handle (surface);
+ gdk_wayland_surface_unexport_handle (priv->surface);
}
#endif
}
@@ -9904,14 +9825,14 @@ update_cursor (GtkWindow *toplevel,
GdkCursor *cursor = NULL;
GdkSurface *surface;
- surface = gtk_widget_get_surface (target);
+ surface = gtk_native_get_surface (gtk_widget_get_native (target));
if (grab_widget && !gtk_widget_is_ancestor (target, grab_widget))
{
/* Outside the grab widget, cursor stays to whatever the grab
* widget says.
*/
- if (gtk_widget_get_surface (grab_widget) == gtk_widget_get_surface (target))
+ if (gtk_native_get_surface (gtk_widget_get_native (grab_widget)) == surface)
cursor = gtk_widget_get_cursor (grab_widget);
else
cursor = NULL;
@@ -9927,7 +9848,7 @@ update_cursor (GtkWindow *toplevel,
break;
/* Don't inherit cursors across surfaces */
- if (surface != gtk_widget_get_surface (target))
+ if (surface != gtk_native_get_surface (gtk_widget_get_native (target)))
break;
cursor = gtk_widget_get_cursor (target);
diff --git a/gtk/inspector/fpsoverlay.c b/gtk/inspector/fpsoverlay.c
index 092e5b30c5..dadf1ffe14 100644
--- a/gtk/inspector/fpsoverlay.c
+++ b/gtk/inspector/fpsoverlay.c
@@ -24,6 +24,7 @@
#include "gtkintl.h"
#include "gtkwidget.h"
#include "gtkwindow.h"
+#include "gtknative.h"
/* duration before we start fading in us */
#define GDK_FPS_OVERLAY_LINGER_DURATION (1000 * 1000)
@@ -140,7 +141,7 @@ gtk_fps_overlay_force_redraw (GtkWidget *widget,
GdkFrameClock *clock,
gpointer unused)
{
- gdk_surface_queue_expose (gtk_widget_get_surface (widget));
+ gdk_surface_queue_expose (gtk_native_get_surface (gtk_widget_get_native (widget)));
return G_SOURCE_REMOVE;
}
@@ -243,7 +244,7 @@ gtk_fps_overlay_queue_draw (GtkInspectorOverlay *overlay)
g_hash_table_iter_init (&iter, self->infos);
while (g_hash_table_iter_next (&iter, &widget, NULL))
- gdk_surface_queue_expose (gtk_widget_get_surface (widget));
+ gdk_surface_queue_expose (gtk_native_get_surface (gtk_widget_get_native (widget)));
}
static void
diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c
index 0ebb226845..e7538e8d10 100644
--- a/gtk/inspector/inspect-button.c
+++ b/gtk/inspector/inspect-button.c
@@ -52,7 +52,7 @@ find_widget_at_pointer (GdkDevice *device)
{
double x, y;
- gdk_surface_get_device_position (gtk_widget_get_surface (widget),
+ gdk_surface_get_device_position (gtk_native_get_surface (GTK_NATIVE (widget)),
device, &x, &y, NULL);
widget = gtk_widget_pick (widget, x, y, GTK_PICK_INSENSITIVE|GTK_PICK_NON_TARGETABLE);
@@ -99,7 +99,7 @@ on_inspect_widget (GtkInspectorWindow *iw,
{
GtkWidget *widget;
- gdk_surface_raise (gtk_widget_get_surface (GTK_WIDGET (iw)));
+ gdk_surface_raise (gtk_native_get_surface (GTK_NATIVE (iw)));
clear_flash (iw);
@@ -159,7 +159,7 @@ deemphasize_window (GtkWidget *window)
cairo_region_destroy (region);
}
else
- gdk_surface_lower (gtk_widget_get_surface (window));
+ gdk_surface_lower (gtk_native_get_surface (GTK_NATIVE (window)));
}
static void
@@ -174,7 +174,7 @@ reemphasize_window (GtkWidget *window)
gtk_widget_input_shape_combine_region (window, NULL);
}
else
- gdk_surface_raise (gtk_widget_get_surface (window));
+ gdk_surface_raise (gtk_native_get_surface (GTK_NATIVE (window)));
}
static gboolean handle_event (GtkInspectorWindow *iw, GdkEvent *event);
diff --git a/gtk/inspector/updatesoverlay.c b/gtk/inspector/updatesoverlay.c
index 9a5d3069b7..21d810689b 100644
--- a/gtk/inspector/updatesoverlay.c
+++ b/gtk/inspector/updatesoverlay.c
@@ -23,6 +23,7 @@
#include "gtkintl.h"
#include "gtkwidget.h"
+#include "gtknative.h"
#include "gsk/gskrendernodeprivate.h"
@@ -109,7 +110,7 @@ gtk_widget_updates_tick (GtkWidget *widget,
gtk_update_free (draw);
}
- gdk_surface_queue_expose (gtk_widget_get_surface (widget));
+ gdk_surface_queue_expose (gtk_native_get_surface (gtk_widget_get_native (widget)));
if (draw)
{
g_queue_push_tail (updates->updates, draw);
@@ -241,7 +242,7 @@ gtk_updates_overlay_queue_draw (GtkInspectorOverlay *overlay)
g_hash_table_iter_init (&iter, self->toplevels);
while (g_hash_table_iter_next (&iter, &widget, NULL))
- gdk_surface_queue_expose (gtk_widget_get_surface (widget));
+ gdk_surface_queue_expose (gtk_native_get_surface (gtk_widget_get_native (widget)));
}
static void
diff --git a/tests/testfullscreen.c b/tests/testfullscreen.c
index 0ed79b91c2..64d8e31d20 100644
--- a/tests/testfullscreen.c
+++ b/tests/testfullscreen.c
@@ -25,7 +25,7 @@ set_fullscreen_monitor_cb (GtkWidget *widget, gpointer user_data)
GdkFullscreenMode mode = (GdkFullscreenMode) GPOINTER_TO_INT (user_data);
GdkSurface *window;
- window = gtk_widget_get_surface (gtk_widget_get_parent (widget));
+ window = gtk_native_get_surface (gtk_widget_get_native (widget));
gdk_surface_set_fullscreen_mode (window, mode);
gdk_surface_fullscreen (window);
}
@@ -35,7 +35,7 @@ remove_fullscreen_cb (GtkWidget *widget, gpointer user_data)
{
GdkSurface *window;
- window = gtk_widget_get_surface (gtk_widget_get_parent (widget));
+ window = gtk_native_get_surface (gtk_widget_get_native (widget));
gdk_surface_unfullscreen (window);
}
diff --git a/tests/testgtk.c b/tests/testgtk.c
index c3664b0139..4e0146718a 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1245,7 +1245,7 @@ create_pixbuf (GtkWidget *widget)
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (box2), button);
- gdk_surface = gtk_widget_get_surface (window);
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
pixbufwid = new_pixbuf ("test.xpm", gdk_surface);
@@ -4855,7 +4855,7 @@ create_wmhints (GtkWidget *widget)
gtk_widget_realize (window);
- gdk_surface = gtk_widget_get_surface (window);
+ gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
texture = gdk_texture_new_for_pixbuf (pixbuf);
@@ -4963,7 +4963,7 @@ tracking_label (GtkWidget *window)
gtk_container_add (GTK_CONTAINER (hbox), label);
g_object_set_data (G_OBJECT (label), "title", (gpointer)gtk_window_get_title (GTK_WINDOW (window)));
- g_signal_connect (gtk_widget_get_surface (window), "notify::state",
+ g_signal_connect (gtk_native_get_surface (GTK_NATIVE (window)), "notify::state",
G_CALLBACK (surface_state_callback),
label);
diff --git a/tests/testwindowdrag.c b/tests/testwindowdrag.c
index 6b15731811..fdae5d19fc 100644
--- a/tests/testwindowdrag.c
+++ b/tests/testwindowdrag.c
@@ -18,7 +18,7 @@ start_resize (GtkGestureMultiPress *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event ();
gdk_event_get_button (event, &button);
timestamp = gdk_event_get_time (event);
@@ -63,7 +63,7 @@ start_move (GtkGestureMultiPress *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
- surface = gtk_widget_get_surface (widget);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event ();
gdk_event_get_button (event, &button);
timestamp = gdk_event_get_time (event);
diff --git a/tests/testwindowsize.c b/tests/testwindowsize.c
index 22a8b4d792..ef8a5ddc31 100644
--- a/tests/testwindowsize.c
+++ b/tests/testwindowsize.c
@@ -65,7 +65,7 @@ show_dialog (void)
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
gtk_widget_realize (dialog);
- g_signal_connect (gtk_widget_get_surface (dialog), "size-changed",
+ g_signal_connect (gtk_native_get_surface (GTK_NATIVE (dialog)), "size-changed",
G_CALLBACK (size_changed_cb), label);
gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/testsuite/gtk/gestures.c b/testsuite/gtk/gestures.c
index 5591f1ad48..1f80eeb7a0 100644
--- a/testsuite/gtk/gestures.c
+++ b/testsuite/gtk/gestures.c
@@ -26,16 +26,18 @@ point_press (PointState *point,
GdkDisplay *display;
GdkDevice *device;
GdkSeat *seat;
+ GdkSurface *surface;
GdkEvent *ev;
display = gtk_widget_get_display (widget);
seat = gdk_display_get_default_seat (display);
device = gdk_seat_get_pointer (seat);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
if (point == &mouse_state)
{
ev = gdk_event_new (GDK_BUTTON_PRESS);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (widget));
+ ev->any.surface = g_object_ref (surface);
ev->button.time = GDK_CURRENT_TIME;
ev->button.x = point->x;
ev->button.y = point->y;
@@ -47,7 +49,7 @@ point_press (PointState *point,
else
{
ev = gdk_event_new (GDK_TOUCH_BEGIN);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (widget));
+ ev->any.surface = g_object_ref (surface);
ev->touch.time = GDK_CURRENT_TIME;
ev->touch.x = point->x;
ev->touch.y = point->y;
@@ -75,11 +77,13 @@ point_update (PointState *point,
GdkDisplay *display;
GdkDevice *device;
GdkSeat *seat;
+ GdkSurface *surface;
GdkEvent *ev;
display = gtk_widget_get_display (widget);
seat = gdk_display_get_default_seat (display);
device = gdk_seat_get_pointer (seat);
+ surface = gtk_native_get_surface (gtk_widget_get_native (widget));
point->x = x;
point->y = y;
@@ -87,7 +91,7 @@ point_update (PointState *point,
if (point == &mouse_state)
{
ev = gdk_event_new (GDK_MOTION_NOTIFY);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (widget));
+ ev->any.surface = g_object_ref (surface);
ev->button.time = GDK_CURRENT_TIME;
ev->motion.x = x;
ev->motion.y = y;
@@ -99,7 +103,7 @@ point_update (PointState *point,
return;
ev = gdk_event_new (GDK_TOUCH_UPDATE);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (widget));
+ ev->any.surface = g_object_ref (surface);
ev->touch.time = GDK_CURRENT_TIME;
ev->touch.x = x;
ev->touch.y = y;
@@ -124,6 +128,7 @@ point_release (PointState *point,
GdkDisplay *display;
GdkDevice *device;
GdkSeat *seat;
+ GdkSurface *surface;
GdkEvent *ev;
if (point->widget == NULL)
@@ -132,6 +137,7 @@ point_release (PointState *point,
display = gtk_widget_get_display (point->widget);
seat = gdk_display_get_default_seat (display);
device = gdk_seat_get_pointer (seat);
+ surface = gtk_native_get_surface (gtk_widget_get_native (point->widget));
if (!point->widget)
return;
@@ -142,7 +148,7 @@ point_release (PointState *point,
return;
ev = gdk_event_new (GDK_BUTTON_RELEASE);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (point->widget));
+ ev->any.surface = g_object_ref (surface);
ev->button.time = GDK_CURRENT_TIME;
ev->button.x = point->x;
ev->button.y = point->y;
@@ -153,7 +159,7 @@ point_release (PointState *point,
else
{
ev = gdk_event_new (GDK_TOUCH_END);
- ev->any.surface = g_object_ref (gtk_widget_get_surface (point->widget));
+ ev->any.surface = g_object_ref (surface);
ev->touch.time = GDK_CURRENT_TIME;
ev->touch.x = point->x;
ev->touch.y = point->y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]