[mutter] wayland/pointer: Return on scroll without client
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/pointer: Return on scroll without client
- Date: Tue, 14 Dec 2021 16:15:44 +0000 (UTC)
commit cea5c476718b4a5c6a45134363ce81c056be68c7
Author: José Expósito <jose exposito89 gmail com>
Date: Mon Sep 20 19:53:39 2021 +0200
wayland/pointer: Return on scroll without client
Return early from handle_scroll_event if no client is focused to avoid
redundant calculations.
Refactor, no functional changes.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
src/wayland/meta-wayland-pointer.c | 88 +++++++++++++++++++-------------------
1 file changed, 45 insertions(+), 43 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 0bcfc8dd37..3ae907a546 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -721,10 +721,15 @@ handle_scroll_event (MetaWaylandPointer *pointer,
wl_fixed_t x_value = 0, y_value = 0;
int x_discrete = 0, y_discrete = 0;
enum wl_pointer_axis_source source = -1;
+ MetaWaylandPointerClient *client;
if (clutter_event_is_pointer_emulated (event))
return;
+ client = pointer->focus_client;
+ if (!client)
+ return;
+
switch (event->scroll.scroll_source)
{
case CLUTTER_SCROLL_SOURCE_WHEEL:
@@ -780,51 +785,48 @@ handle_scroll_event (MetaWaylandPointer *pointer,
return;
}
- if (pointer->focus_client)
+ wl_resource_for_each (resource, &client->pointer_resources)
{
- wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)
- {
- int client_version = wl_resource_get_version (resource);
-
- if (client_version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
- wl_pointer_send_axis_source (resource, source);
-
- /* X axis */
- if (x_discrete != 0 &&
- client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
- wl_pointer_send_axis_discrete (resource,
- WL_POINTER_AXIS_HORIZONTAL_SCROLL,
- x_discrete);
-
- if (x_value)
- wl_pointer_send_axis (resource, clutter_event_get_time (event),
- WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
-
- if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL) &&
- client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
- wl_pointer_send_axis_stop (resource,
- clutter_event_get_time (event),
- WL_POINTER_AXIS_HORIZONTAL_SCROLL);
- /* Y axis */
- if (y_discrete != 0 &&
- client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
- wl_pointer_send_axis_discrete (resource,
- WL_POINTER_AXIS_VERTICAL_SCROLL,
- y_discrete);
-
- if (y_value)
- wl_pointer_send_axis (resource, clutter_event_get_time (event),
- WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
-
- if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_VERTICAL) &&
- client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
- wl_pointer_send_axis_stop (resource,
- clutter_event_get_time (event),
- WL_POINTER_AXIS_VERTICAL_SCROLL);
- }
-
- meta_wayland_pointer_broadcast_frame (pointer);
+ int client_version = wl_resource_get_version (resource);
+
+ if (client_version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
+ wl_pointer_send_axis_source (resource, source);
+
+ /* X axis */
+ if (x_discrete != 0 &&
+ client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+ wl_pointer_send_axis_discrete (resource,
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL,
+ x_discrete);
+
+ if (x_value)
+ wl_pointer_send_axis (resource, clutter_event_get_time (event),
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
+
+ if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL) &&
+ client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
+ wl_pointer_send_axis_stop (resource,
+ clutter_event_get_time (event),
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL);
+ /* Y axis */
+ if (y_discrete != 0 &&
+ client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+ wl_pointer_send_axis_discrete (resource,
+ WL_POINTER_AXIS_VERTICAL_SCROLL,
+ y_discrete);
+
+ if (y_value)
+ wl_pointer_send_axis (resource, clutter_event_get_time (event),
+ WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
+
+ if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_VERTICAL) &&
+ client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
+ wl_pointer_send_axis_stop (resource,
+ clutter_event_get_time (event),
+ WL_POINTER_AXIS_VERTICAL_SCROLL);
}
+
+ meta_wayland_pointer_broadcast_frame (pointer);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]