From d6818475d728acc861c57da4ffb741b4108e0bc6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 22:05:24 -0400 Subject: [PATCH] gdk: Simplify gdk_display_supports_input_shapes Make this a display property, and do away with the vfunc in favor of a private setter, to match how we handle other display characteristics. --- gdk/broadway/gdkdisplay-broadway.c | 9 ++------ gdk/gdkdisplay.c | 35 +++++++++++++++++++++++++++++- gdk/gdkdisplay.h | 4 ++-- gdk/gdkdisplayprivate.h | 4 +++- gdk/wayland/gdkdisplay-wayland.c | 7 ------ gdk/win32/gdkdisplay-win32.c | 11 ---------- gdk/x11/gdkdisplay-x11.c | 10 ++------- 7 files changed, 43 insertions(+), 37 deletions(-) diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index 00d4a79b38..5a88b82064 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -56,6 +56,8 @@ G_DEFINE_TYPE (GdkBroadwayDisplay, gdk_broadway_display, GDK_TYPE_DISPLAY) static void gdk_broadway_display_init (GdkBroadwayDisplay *display) { + gdk_display_set_input_shapes (GDK_DISPLAY (display), FALSE); + display->id_ht = g_hash_table_new (NULL, NULL); display->monitor = g_object_new (GDK_TYPE_BROADWAY_MONITOR, @@ -313,12 +315,6 @@ gdk_broadway_display_notify_startup_complete (GdkDisplay *display, { } -static gboolean -gdk_broadway_display_supports_input_shapes (GdkDisplay *display) -{ - return FALSE; -} - static gulong gdk_broadway_display_get_next_serial (GdkDisplay *display) { @@ -446,7 +442,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class) display_class->has_pending = gdk_broadway_display_has_pending; display_class->queue_events = _gdk_broadway_display_queue_events; display_class->get_default_group = gdk_broadway_display_get_default_group; - display_class->supports_input_shapes = gdk_broadway_display_supports_input_shapes; display_class->get_next_serial = gdk_broadway_display_get_next_serial; display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete; diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index de17527e15..e67471e20d 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -71,6 +71,7 @@ enum PROP_0, PROP_COMPOSITED, PROP_RGBA, + PROP_INPUT_SHAPES, LAST_PROP }; @@ -113,6 +114,10 @@ gdk_display_get_property (GObject *object, g_value_set_boolean (value, gdk_display_is_rgba (display)); break; + case PROP_INPUT_SHAPES: + g_value_set_boolean (value, gdk_display_supports_input_shapes (display)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -193,6 +198,19 @@ gdk_display_class_init (GdkDisplayClass *class) TRUE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * GdkDisplay:input-shapes: + * + * %TRUE if the display supports input shapes. See + * gdk_display_supports_input_shapes() for details. + */ + props[PROP_INPUT_SHAPES] = + g_param_spec_boolean ("input-shapes", + P_("Input shapes"), + P_("Input shapes"), + TRUE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, LAST_PROP, props); /** @@ -322,6 +340,7 @@ gdk_display_init (GdkDisplay *display) display->composited = TRUE; display->rgba = TRUE; + display->input_shapes = TRUE; } static void @@ -1108,7 +1127,21 @@ gdk_display_supports_input_shapes (GdkDisplay *display) { g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); - return GDK_DISPLAY_GET_CLASS (display)->supports_input_shapes (display); + return display->input_shapes; +} + +void +gdk_display_set_input_shapes (GdkDisplay *display, + gboolean input_shapes) +{ + g_return_if_fail (GDK_IS_DISPLAY (display)); + + if (display->input_shapes == input_shapes) + return; + + display->input_shapes = input_shapes; + + g_object_notify_by_pspec (G_OBJECT (display), props[PROP_INPUT_SHAPES]); } static GdkAppLaunchContext * diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h index 4dd046e91d..0a6f6ef2c0 100644 --- a/gdk/gdkdisplay.h +++ b/gdk/gdkdisplay.h @@ -65,6 +65,8 @@ GDK_AVAILABLE_IN_ALL gboolean gdk_display_is_composited (GdkDisplay *display); GDK_AVAILABLE_IN_ALL gboolean gdk_display_is_rgba (GdkDisplay *display); +GDK_AVAILABLE_IN_ALL +gboolean gdk_display_supports_input_shapes (GdkDisplay *display); GDK_AVAILABLE_IN_ALL GdkEvent* gdk_display_get_event (GdkDisplay *display); @@ -87,8 +89,6 @@ GdkClipboard * gdk_display_get_clipboard (GdkDisplay GDK_AVAILABLE_IN_ALL GdkClipboard * gdk_display_get_primary_clipboard (GdkDisplay *display); -GDK_AVAILABLE_IN_ALL -gboolean gdk_display_supports_input_shapes (GdkDisplay *display); GDK_AVAILABLE_IN_ALL void gdk_display_notify_startup_complete (GdkDisplay *display, const gchar *startup_id); diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 0ba63c3358..c1247d1954 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -102,6 +102,7 @@ struct _GdkDisplay #endif /* GDK_RENDERING_VULKAN */ guint rgba : 1; guint composited : 1; + guint input_shapes : 1; GdkDebugFlags debug_flags; @@ -124,7 +125,6 @@ struct _GdkDisplayClass void (*queue_events) (GdkDisplay *display); void (*make_default) (GdkDisplay *display); GdkSurface * (*get_default_group) (GdkDisplay *display); - gboolean (*supports_input_shapes) (GdkDisplay *display); GdkAppLaunchContext * (*get_app_launch_context) (GdkDisplay *display); @@ -232,6 +232,8 @@ void gdk_display_set_rgba (GdkDisplay *display gboolean rgba); void gdk_display_set_composited (GdkDisplay *display, gboolean composited); +void gdk_display_set_input_shapes (GdkDisplay *display, + gboolean input_shapes); void gdk_display_add_seat (GdkDisplay *display, GdkSeat *seat); diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index ca608cee0a..f323a732f6 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -848,12 +848,6 @@ gdk_wayland_display_get_default_group (GdkDisplay *display) return NULL; } -static gboolean -gdk_wayland_display_supports_input_shapes (GdkDisplay *display) -{ - return TRUE; -} - static gulong gdk_wayland_display_get_next_serial (GdkDisplay *display) { @@ -1013,7 +1007,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->has_pending = gdk_wayland_display_has_pending; display_class->queue_events = _gdk_wayland_display_queue_events; display_class->get_default_group = gdk_wayland_display_get_default_group; - display_class->supports_input_shapes = gdk_wayland_display_supports_input_shapes; display_class->get_app_launch_context = _gdk_wayland_display_get_app_launch_context; display_class->get_next_serial = gdk_wayland_display_get_next_serial; display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id; diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index ed579f34dc..11fc4aecd7 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -622,15 +622,6 @@ gdk_win32_display_get_default_group (GdkDisplay *display) return NULL; } -static gboolean -gdk_win32_display_supports_input_shapes (GdkDisplay *display) -{ - g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); - - /* Partially supported, see WM_NCHITTEST handler. */ - return TRUE; -} - static void gdk_win32_display_beep (GdkDisplay *display) { @@ -1072,8 +1063,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass) display_class->queue_events = _gdk_win32_display_queue_events; display_class->get_default_group = gdk_win32_display_get_default_group; - display_class->supports_input_shapes = gdk_win32_display_supports_input_shapes; - //? display_class->get_app_launch_context = _gdk_win32_display_get_app_launch_context; display_class->get_next_serial = gdk_win32_display_get_next_serial; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index f5c4f630a3..f172f94553 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1493,6 +1493,8 @@ gdk_x11_display_open (const gchar *display_name) #endif } + gdk_display_set_input_shapes (display, display_x11->have_input_shapes); + display_x11->trusted_client = TRUE; { Window root, child; @@ -2309,13 +2311,6 @@ gdk_x11_display_get_user_time (GdkDisplay *display) return GDK_X11_DISPLAY (display)->user_time; } -static gboolean -gdk_x11_display_supports_input_shapes (GdkDisplay *display) -{ - return GDK_X11_DISPLAY (display)->have_input_shapes; -} - - /** * gdk_x11_display_get_startup_notification_id: * @display: (type GdkX11Display): a #GdkDisplay @@ -2939,7 +2934,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->has_pending = gdk_x11_display_has_pending; display_class->queue_events = _gdk_x11_display_queue_events; display_class->get_default_group = gdk_x11_display_get_default_group; - display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes; display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context; display_class->get_next_serial = gdk_x11_display_get_next_serial;