[gtk+] gdk: Stop using gdk_event_set_screen



commit 525e2a7944f8aa9e492b42668396fda2cb0c8748
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 30 22:15:29 2017 -0400

    gdk: Stop using gdk_event_set_screen
    
    Use gdk_event_set_display instead.

 gdk/mir/gdkmireventsource.c         |    5 ++-
 gdk/mir/gdkmirwindowimpl.c          |    2 +-
 gdk/wayland/gdkdevice-wayland.c     |   22 +++++----------
 gdk/x11/gdkdevicemanager-core-x11.c |   49 ++++------------------------------
 gdk/x11/gdkdevicemanager-xi2.c      |   31 +--------------------
 5 files changed, 20 insertions(+), 89 deletions(-)
---
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c
index ea0cc52..666047a 100644
--- a/gdk/mir/gdkmireventsource.c
+++ b/gdk/mir/gdkmireventsource.c
@@ -54,12 +54,13 @@ send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
   GdkDisplay *display;
   GList *node;
 
+  display = gdk_window_get_display (window);
+
   gdk_event_set_device (event, device);
   gdk_event_set_source_device (event, device);
-  gdk_event_set_screen (event, gdk_display_get_default_screen (gdk_window_get_display (window)));
+  gdk_event_set_display (event, display);
   event->any.window = g_object_ref (window);
 
-  display = gdk_window_get_display (window);
   node = _gdk_event_queue_append (display, event);
   _gdk_windowing_got_event (display, node, event, _gdk_display_get_next_serial (display));
 }
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index 2e5669f..075c3b0 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -549,7 +549,7 @@ send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
   display = gdk_window_get_display (window);
   gdk_event_set_device (event, device);
   gdk_event_set_source_device (event, device);
-  gdk_event_set_screen (event, gdk_display_get_default_screen (display));
+  gdk_event_set_display (event, display);
   event->any.window = g_object_ref (window);
 
   node = _gdk_event_queue_append (display, event);
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 31f2f08..1a2ddcf 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1307,7 +1307,6 @@ create_scroll_event (GdkWaylandSeat        *seat,
                      GdkDevice             *source_device,
                      gboolean               emulated)
 {
-  GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
   GdkEvent *event;
 
   event = gdk_event_new (GDK_SCROLL);
@@ -1316,7 +1315,7 @@ create_scroll_event (GdkWaylandSeat        *seat,
   gdk_event_set_source_device (event, source_device);
   event->scroll.time = pointer_info->time;
   event->scroll.state = device_get_modifiers (device);
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
 
   gdk_event_set_pointer_emulated (event, emulated);
 
@@ -1579,7 +1578,7 @@ pointer_handle_motion (void              *data,
   event->motion.axes = NULL;
   event->motion.state = device_get_modifiers (seat->master_pointer);
   event->motion.is_hint = 0;
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
 
   get_coordinates (seat->master_pointer,
                    &event->motion.x,
@@ -1647,7 +1646,7 @@ pointer_handle_button (void              *data,
   event->button.axes = NULL;
   event->button.state = device_get_modifiers (seat->master_pointer);
   event->button.button = gdk_button;
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
 
   get_coordinates (seat->master_pointer,
                    &event->button.x,
@@ -2324,7 +2323,6 @@ _create_touch_event (GdkWaylandSeat       *seat,
                      GdkEventType          evtype,
                      uint32_t              time)
 {
-  GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
   gint x_root, y_root;
   GdkEvent *event;
 
@@ -2335,7 +2333,7 @@ _create_touch_event (GdkWaylandSeat       *seat,
   gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touch.time = time;
   event->touch.state = device_get_modifiers (seat->touch_master);
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
   event->touch.sequence = GDK_SLOT_TO_EVENT_SEQUENCE (touch->id);
 
   if (touch->initial_touch)
@@ -2530,7 +2528,6 @@ emit_gesture_swipe_event (GdkWaylandSeat          *seat,
                           gdouble                  dx,
                           gdouble                  dy)
 {
-  GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
   GdkEvent *event;
 
   if (!seat->pointer_info.focus)
@@ -2546,7 +2543,7 @@ emit_gesture_swipe_event (GdkWaylandSeat          *seat,
   gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touchpad_swipe.time = _time;
   event->touchpad_swipe.state = device_get_modifiers (seat->master_pointer);
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
   event->touchpad_swipe.dx = dx;
   event->touchpad_swipe.dy = dy;
   event->touchpad_swipe.n_fingers = n_fingers;
@@ -2633,7 +2630,6 @@ emit_gesture_pinch_event (GdkWaylandSeat          *seat,
                           gdouble                  scale,
                           gdouble                  angle_delta)
 {
-  GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
   GdkEvent *event;
 
   if (!seat->pointer_info.focus)
@@ -2649,7 +2645,7 @@ emit_gesture_pinch_event (GdkWaylandSeat          *seat,
   gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touchpad_pinch.time = _time;
   event->touchpad_pinch.state = device_get_modifiers (seat->master_pointer);
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
   event->touchpad_pinch.dx = dx;
   event->touchpad_pinch.dy = dy;
   event->touchpad_pinch.scale = scale;
@@ -3648,7 +3644,6 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
                                   guint                 button)
 {
   GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
-  GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
   GdkEvent *event;
 
   event = gdk_wayland_tablet_get_frame_event (tablet, evtype);
@@ -3659,7 +3654,7 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
   event->button.time = tablet->pointer_info.time;
   event->button.state = device_get_modifiers (tablet->master);
   event->button.button = button;
-  gdk_event_set_screen (event, display_wayland->screen);
+  gdk_event_set_display (event, seat->display);
 
   get_coordinates (tablet->master,
                    &event->button.x,
@@ -3711,7 +3706,6 @@ tablet_tool_handle_motion (void                      *data,
   GdkWaylandTabletToolData *tool = data;
   GdkWaylandTabletData *tablet = tool->current_tablet;
   GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
-  GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
   GdkEvent *event;
 
   tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
@@ -3730,7 +3724,7 @@ tablet_tool_handle_motion (void                      *data,
   event->motion.time = tablet->pointer_info.time;
   event->motion.state = device_get_modifiers (tablet->master);
   event->motion.is_hint = FALSE;
-  gdk_event_set_screen (event, display->screen);
+  gdk_event_set_display (event, seat->display);
 
   get_coordinates (tablet->master,
                    &event->motion.x,
diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c
index c662d21..11ab5c2 100644
--- a/gdk/x11/gdkdevicemanager-core-x11.c
+++ b/gdk/x11/gdkdevicemanager-core-x11.c
@@ -233,25 +233,6 @@ set_user_time (GdkWindow *window,
                                   gdk_event_get_time (event));
 }
 
-static gboolean
-set_screen_from_root (GdkDisplay *display,
-                      GdkEvent   *event,
-                      Window      xrootwin)
-{
-  GdkScreen *screen;
-
-  screen = _gdk_x11_display_screen_for_xrootwin (display, xrootwin);
-
-  if (screen)
-    {
-      gdk_event_set_screen (event, screen);
-
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
 static GdkCrossingMode
 translate_crossing_mode (int mode)
 {
@@ -488,11 +469,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
           event->scroll.delta_x = 0;
           event->scroll.delta_y = 0;
 
-          if (!set_screen_from_root (display, event, xevent->xbutton.root))
-            {
-              return_val = FALSE;
-              break;
-            }
+          gdk_event_set_display (event, display);
 
           break;
 
@@ -509,8 +486,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
           event->button.button = xevent->xbutton.button;
           event->button.device = device_manager->core_pointer;
 
-          if (!set_screen_from_root (display, event, xevent->xbutton.root))
-            return_val = FALSE;
+          gdk_event_set_display (event, display);
 
           break;
         }
@@ -552,8 +528,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
       event->button.button = xevent->xbutton.button;
       event->button.device = device_manager->core_pointer;
 
-      if (!set_screen_from_root (display, event, xevent->xbutton.root))
-        return_val = FALSE;
+      gdk_event_set_display (event, display);
 
       break;
 
@@ -582,11 +557,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
       event->motion.is_hint = xevent->xmotion.is_hint;
       event->motion.device = device_manager->core_pointer;
 
-      if (!set_screen_from_root (display, event, xevent->xbutton.root))
-        {
-          return_val = FALSE;
-          break;
-        }
+      gdk_event_set_display (event, display);
 
       break;
 
@@ -603,11 +574,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
           break;
         }
 
-      if (!set_screen_from_root (display, event, xevent->xbutton.root))
-        {
-          return_val = FALSE;
-          break;
-        }
+      gdk_event_set_display (event, display);
 
       event->crossing.type = GDK_ENTER_NOTIFY;
       event->crossing.window = window;
@@ -647,11 +614,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
           break;
         }
 
-      if (!set_screen_from_root (display, event, xevent->xbutton.root))
-        {
-          return_val = FALSE;
-          break;
-        }
+      gdk_event_set_display (event, display);
 
       event->crossing.type = GDK_LEAVE_NOTIFY;
       event->crossing.window = window;
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 56fb2c8..9ae5d5c 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1093,25 +1093,6 @@ translate_notify_type (gint detail)
     }
 }
 
-static gboolean
-set_screen_from_root (GdkDisplay *display,
-                      GdkEvent   *event,
-                      Window      xrootwin)
-{
-  GdkScreen *screen;
-
-  screen = _gdk_x11_display_screen_for_xrootwin (display, xrootwin);
-
-  if (screen)
-    {
-      gdk_event_set_screen (event, screen);
-
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
 static void
 set_user_time (GdkEvent *event)
 {
@@ -1626,11 +1607,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         if (return_val == FALSE)
           break;
 
-        if (!set_screen_from_root (display, event, xev->root))
-          {
-            return_val = FALSE;
-            break;
-          }
+        gdk_event_set_display (event, display);
 
         if (ev->evtype == XI_ButtonPress)
          set_user_time (event);
@@ -1792,11 +1769,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         if (return_val == FALSE)
           break;
 
-        if (!set_screen_from_root (display, event, xev->root))
-          {
-            return_val = FALSE;
-            break;
-          }
+        gdk_event_set_display (event, display);
 
         if (ev->evtype == XI_TouchBegin)
           set_user_time (event);


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