[mutter] wayland/pointer: Call wl_resource_get_version once



commit d703ba56c3447272963bbdd739fccded86985792
Author: José Expósito <jose exposito89 gmail com>
Date:   Mon Sep 20 19:53:31 2021 +0200

    wayland/pointer: Call wl_resource_get_version once
    
    Call wl_resource_get_version once for each pointer resource.
    
    Refactor, no functional changes.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>

 src/wayland/meta-wayland-pointer.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index ef76acb5db..0bcfc8dd37 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -784,12 +784,14 @@ handle_scroll_event (MetaWaylandPointer *pointer,
     {
       wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)
         {
-          if (wl_resource_get_version (resource) >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
+          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 &&
-              wl_resource_get_version (resource) >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+              client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
             wl_pointer_send_axis_discrete (resource,
                                            WL_POINTER_AXIS_HORIZONTAL_SCROLL,
                                            x_discrete);
@@ -799,13 +801,13 @@ handle_scroll_event (MetaWaylandPointer *pointer,
                                   WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
 
           if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL) &&
-              wl_resource_get_version (resource) >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
+              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 &&
-              wl_resource_get_version (resource) >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+              client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
             wl_pointer_send_axis_discrete (resource,
                                            WL_POINTER_AXIS_VERTICAL_SCROLL,
                                            y_discrete);
@@ -815,7 +817,7 @@ handle_scroll_event (MetaWaylandPointer *pointer,
                                   WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
 
           if ((event->scroll.finish_flags & CLUTTER_SCROLL_FINISHED_VERTICAL) &&
-              wl_resource_get_version (resource) >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
+              client_version >= WL_POINTER_AXIS_STOP_SINCE_VERSION)
             wl_pointer_send_axis_stop (resource,
                                        clutter_event_get_time (event),
                                        WL_POINTER_AXIS_VERTICAL_SCROLL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]