Merge branch 'wip/otte/wayland-versions' into 'main'

wayland: Use proper get_version() functions

See merge request GNOME/gtk!5761
This commit is contained in:
Benjamin Otte 2023-04-01 00:52:11 +00:00
commit 2fb11765c7
9 changed files with 23 additions and 50 deletions

View File

@ -93,7 +93,7 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
id = app_launch_data.token;
wl_event_queue_destroy (event_queue);
}
else if (display->gtk_shell_version >= 3)
else if (gtk_shell1_get_version (display->gtk_shell) >= GTK_SHELL1_NOTIFY_LAUNCH_SINCE_VERSION)
{
id = g_uuid_string_random ();
gtk_shell1_notify_launch (display->gtk_shell, id);

View File

@ -235,10 +235,9 @@ _gdk_wayland_display_add_seat (GdkWaylandDisplay *display_wayland,
{
struct wl_seat *seat;
display_wayland->seat_version = MIN (version, 8);
seat = wl_registry_bind (display_wayland->wl_registry,
id, &wl_seat_interface,
display_wayland->seat_version);
MIN (version, 8));
_gdk_wayland_display_create_seat (display_wayland, id, seat);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
@ -370,7 +369,6 @@ gdk_registry_handle_global (void *data,
display_wayland->compositor =
wl_registry_bind (display_wayland->wl_registry, id,
&wl_compositor_interface, MIN (version, 5));
display_wayland->compositor_version = MIN (version, 4);
}
else if (strcmp (interface, "wl_shm") == 0)
{
@ -394,7 +392,6 @@ gdk_registry_handle_global (void *data,
&gtk_shell1_interface,
MIN (version, GTK_SHELL1_VERSION));
gdk_wayland_display_set_has_gtk_shell (display_wayland);
display_wayland->gtk_shell_version = version;
}
else if (strcmp (interface, "wl_output") == 0)
{
@ -423,10 +420,9 @@ gdk_registry_handle_global (void *data,
}
else if (strcmp (interface, "wl_data_device_manager") == 0)
{
display_wayland->data_device_manager_version = MIN (version, 3);
display_wayland->data_device_manager =
wl_registry_bind (display_wayland->wl_registry, id, &wl_data_device_manager_interface,
display_wayland->data_device_manager_version);
MIN (version, 3));
}
else if (strcmp (interface, "wl_subcompositor") == 0)
{
@ -435,9 +431,6 @@ gdk_registry_handle_global (void *data,
}
else if (strcmp (interface, "zwp_pointer_gestures_v1") == 0)
{
display_wayland->pointer_gestures_version =
MIN (version, GDK_ZWP_POINTER_GESTURES_V1_VERSION);
display_wayland->pointer_gestures =
wl_registry_bind (display_wayland->wl_registry,
id, &zwp_pointer_gestures_v1_interface,
@ -496,11 +489,10 @@ gdk_registry_handle_global (void *data,
}
else if (strcmp(interface, "zxdg_output_manager_v1") == 0)
{
display_wayland->xdg_output_manager_version = MIN (version, 3);
display_wayland->xdg_output_manager =
wl_registry_bind (display_wayland->wl_registry, id,
&zxdg_output_manager_v1_interface,
display_wayland->xdg_output_manager_version);
MIN (version, 3));
gdk_wayland_display_init_xdg_output (display_wayland);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
@ -512,12 +504,10 @@ gdk_registry_handle_global (void *data,
}
else if (strcmp (interface, "xdg_activation_v1") == 0)
{
display_wayland->xdg_activation_version =
MIN (version, XDG_ACTIVATION_VERSION);
display_wayland->xdg_activation =
wl_registry_bind (display_wayland->wl_registry, id,
&xdg_activation_v1_interface,
display_wayland->xdg_activation_version);
MIN (version, XDG_ACTIVATION_VERSION));
}
g_hash_table_insert (display_wayland->known_globals,
@ -2312,7 +2302,7 @@ should_expect_xdg_output_done (GdkWaylandMonitor *monitor)
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
return (monitor_has_xdg_output (monitor) &&
display_wayland->xdg_output_manager_version < NO_XDG_OUTPUT_DONE_SINCE_VERSION);
zxdg_output_manager_v1_get_version (display_wayland->xdg_output_manager) < NO_XDG_OUTPUT_DONE_SINCE_VERSION);
}
static void

View File

@ -133,14 +133,6 @@ struct _GdkWaylandDisplay
GSource *event_source;
int compositor_version;
int seat_version;
int data_device_manager_version;
int gtk_shell_version;
int xdg_output_manager_version;
int pointer_gestures_version;
int xdg_activation_version;
uint32_t server_decoration_mode;
struct xkb_context *xkb_context;

View File

@ -387,7 +387,7 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
gdk_wayland_drag_create_data_source (drag);
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >= WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
if (wl_data_device_manager_get_version (GDK_WAYLAND_DISPLAY (display)->data_device_manager) >= WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
wl_data_source_set_actions (drag_wayland->data_source, gdk_to_wl_actions (actions));
gdk_wayland_seat_set_drag (seat, drag);

View File

@ -128,7 +128,7 @@ gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
display = gdk_drop_get_display (GDK_DROP (wayland_drop));
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
if (wl_data_device_manager_get_version (GDK_WAYLAND_DISPLAY (display)->data_device_manager) >=
WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
{
uint32_t dnd_actions;
@ -159,13 +159,12 @@ gdk_wayland_drop_finish (GdkDrop *drop,
{
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
GdkDisplay *display = gdk_drop_get_display (drop);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
if (action)
{
gdk_wayland_drop_commit_status (wayland_drop, action, action);
if (display_wayland->data_device_manager_version >=
if (wl_data_device_manager_get_version (GDK_WAYLAND_DISPLAY (display)->data_device_manager) >=
WL_DATA_OFFER_FINISH_SINCE_VERSION)
wl_data_offer_finish (wayland_drop->offer);
}

View File

@ -38,7 +38,6 @@
#include <xkbcommon/xkbcommon.h>
#define WL_SURFACE_HAS_BUFFER_SCALE 3
#define WL_POINTER_HAS_FRAME 5
/* the magic mime type we use for local DND operations.

View File

@ -523,7 +523,6 @@ flush_discrete_scroll_event (GdkWaylandSeat *seat,
gint value120_x,
gint value120_y)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkEvent *event = NULL;
GdkDevice *source;
GdkScrollDirection direction;
@ -539,7 +538,7 @@ flush_discrete_scroll_event (GdkWaylandSeat *seat,
source = get_scroll_device (seat, seat->pointer_info.frame.source);
if (display_wayland->seat_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
if (wl_seat_get_version (seat->wl_seat) >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
{
event = gdk_scroll_event_new_value120 (seat->pointer_info.focus,
source,
@ -668,7 +667,6 @@ pointer_handle_enter (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
if (!surface)
return;
@ -702,7 +700,7 @@ pointer_handle_enter (void *data,
"enter, seat %p surface %p",
seat, seat->pointer_info.focus);
if (display_wayland->seat_version < WL_POINTER_HAS_FRAME)
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
}
@ -714,7 +712,6 @@ pointer_handle_leave (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkDeviceGrabInfo *grab;
if (!seat->pointer_info.focus)
@ -758,7 +755,7 @@ pointer_handle_leave (void *data,
if (seat->cursor)
gdk_wayland_seat_stop_cursor_animation (seat, &seat->pointer_info);
if (display_wayland->seat_version < WL_POINTER_HAS_FRAME)
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
}
@ -770,7 +767,6 @@ pointer_handle_motion (void *data,
wl_fixed_t sy)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkEvent *event;
if (!seat->pointer_info.focus)
@ -798,7 +794,7 @@ pointer_handle_motion (void *data,
x, y, seat, gdk_event_get_modifier_state (event));
}
if (display->seat_version < WL_POINTER_HAS_FRAME)
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
}
@ -811,7 +807,6 @@ pointer_handle_button (void *data,
uint32_t state)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkEvent *event;
uint32_t modifier;
int gdk_button;
@ -878,7 +873,7 @@ pointer_handle_button (void *data,
seat,
gdk_event_get_modifier_state (event));
if (display->seat_version < WL_POINTER_HAS_FRAME)
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
}
@ -909,7 +904,6 @@ pointer_handle_axis (void *data,
{
GdkWaylandSeat *seat = data;
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!seat->pointer_info.focus)
return;
@ -934,7 +928,7 @@ pointer_handle_axis (void *data,
get_axis_name (axis), wl_fixed_to_double (value),
seat);
if (display->seat_version < WL_POINTER_HAS_FRAME)
if (wl_seat_get_version (seat->wl_seat) < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
}
@ -2372,7 +2366,7 @@ seat_handle_capabilities (void *data,
zwp_pointer_gesture_pinch_v1_add_listener (seat->wp_pointer_gesture_pinch,
&gesture_pinch_listener, seat);
if (display_wayland->pointer_gestures_version >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE_SINCE_VERSION)
if (zwp_pointer_gestures_v1_get_version (display_wayland->pointer_gestures) >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE_SINCE_VERSION)
{
seat->wp_pointer_gesture_hold =
zwp_pointer_gestures_v1_get_hold_gesture (display_wayland->pointer_gestures,
@ -3771,7 +3765,7 @@ pointer_surface_update_scale (GdkDevice *device)
guint32 scale;
GSList *l;
if (display_wayland->compositor_version < WL_SURFACE_HAS_BUFFER_SCALE)
if (wl_surface_get_version (pointer->pointer_surface) < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{
/* We can't set the scale on this surface */
return;

View File

@ -426,7 +426,8 @@ gdk_wayland_surface_update_scale (GdkSurface *surface)
guint32 scale;
GSList *l;
if (display_wayland->compositor_version < WL_SURFACE_HAS_BUFFER_SCALE)
if (!impl->display_server.wl_surface ||
wl_surface_get_version (impl->display_server.wl_surface) < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{
/* We can't set the scale on this surface */
return;
@ -524,7 +525,7 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
g_object_ref (surface);
/* More likely to be right than just assuming 1 */
if (display_wayland->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
if (wl_compositor_get_version (display_wayland->compositor) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
if (monitor)
@ -782,7 +783,6 @@ static void
gdk_wayland_surface_sync_buffer_scale (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandDisplay *display;
if (!impl->display_server.wl_surface)
return;
@ -791,8 +791,7 @@ gdk_wayland_surface_sync_buffer_scale (GdkSurface *surface)
return;
/* Only set the buffer scale if supported by the compositor */
display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
if (display->compositor_version >= WL_SURFACE_HAS_BUFFER_SCALE)
if (wl_surface_get_version (impl->display_server.wl_surface) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
wl_surface_set_buffer_scale (impl->display_server.wl_surface, impl->scale);
impl->buffer_scale_dirty = FALSE;

View File

@ -217,7 +217,7 @@ gdk_wayland_toplevel_hide_surface (GdkWaylandSurface *wayland_surface)
if (toplevel->display_server.gtk_surface)
{
if (display_wayland->gtk_shell_version >= GTK_SURFACE1_RELEASE_SINCE_VERSION)
if (gtk_shell1_get_version (display_wayland->gtk_shell) >= GTK_SURFACE1_RELEASE_SINCE_VERSION)
gtk_surface1_release (toplevel->display_server.gtk_surface);
else
gtk_surface1_destroy (toplevel->display_server.gtk_surface);
@ -2136,7 +2136,7 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
{
if (timestamp != GDK_CURRENT_TIME)
gtk_surface1_present (wayland_toplevel->display_server.gtk_surface, timestamp);
else if (startup_id && display_wayland->gtk_shell_version >= 3)
else if (startup_id && gtk_surface1_get_version (wayland_toplevel->display_server.gtk_surface) >= GTK_SURFACE1_REQUEST_FOCUS_SINCE_VERSION)
gtk_surface1_request_focus (wayland_toplevel->display_server.gtk_surface,
startup_id);
}