diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 5b7d13d4e8..ebcfb3ccc4 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -532,40 +532,6 @@ gdk_wayland_device_set_surface_cursor (GdkDevice *device, } } -static void -get_coordinates (GdkDevice *device, - double *x, - double *y, - double *x_root, - double *y_root) -{ - GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer; - int root_x, root_y; - - if (x) - *x = pointer->surface_x; - if (y) - *y = pointer->surface_y; - - if (pointer->focus) - { - gdk_surface_get_root_coords (pointer->focus, - pointer->surface_x, - pointer->surface_y, - &root_x, &root_y); - } - else - { - root_x = pointer->surface_x; - root_y = pointer->surface_y; - } - - if (x_root) - *x_root = root_x; - if (y_root) - *y_root = root_y; -} - static GdkModifierType device_get_modifiers (GdkDevice *device) { @@ -583,8 +549,8 @@ device_get_modifiers (GdkDevice *device) static void gdk_wayland_device_query_state (GdkDevice *device, - GdkSurface *surface, - GdkSurface **child_surface, + GdkSurface *surface, + GdkSurface **child_surface, gdouble *root_x, gdouble *root_y, gdouble *win_x, @@ -593,6 +559,7 @@ gdk_wayland_device_query_state (GdkDevice *device, { GdkWaylandPointerData *pointer; GList *children = NULL; + int x_root, y_root; if (surface == NULL) children = gdk_wayland_display_get_toplevel_surfaces (gdk_device_get_display (device)); @@ -605,7 +572,28 @@ gdk_wayland_device_query_state (GdkDevice *device, if (mask) *mask = device_get_modifiers (device); - get_coordinates (device, win_x, win_y, root_x, root_y); + if (win_x) + *win_x = pointer->surface_x; + if (win_y) + *win_y = pointer->surface_y; + + if (pointer->focus) + { + gdk_surface_get_root_coords (pointer->focus, + pointer->surface_x, + pointer->surface_y, + &x_root, &y_root); + } + else + { + x_root = pointer->surface_x; + y_root = pointer->surface_y; + } + + if (root_x) + *root_x = x_root; + if (root_y) + *root_y = y_root; } static void @@ -1503,7 +1491,6 @@ pointer_handle_enter (void *data, GdkWaylandSeat *seat = data; GdkEvent *event; GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display); - double x, y, x_root, y_root; if (!surface) return; @@ -1522,14 +1509,14 @@ pointer_handle_enter (void *data, seat->pointer_info.surface_y = wl_fixed_to_double (sy); seat->pointer_info.enter_serial = serial; - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); event = gdk_event_crossing_new (GDK_ENTER_NOTIFY, seat->pointer_info.focus, seat->master_pointer, seat->pointer, 0, 0, - x, y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, GDK_CROSSING_NORMAL, GDK_NOTIFY_NONLINEAR); gdk_wayland_seat_set_frame_event (seat, event); @@ -1553,7 +1540,6 @@ pointer_handle_leave (void *data, GdkWaylandSeat *seat = data; GdkEvent *event; GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display); - double x, y, x_root, y_root; if (!surface) return; @@ -1566,14 +1552,14 @@ pointer_handle_leave (void *data, _gdk_wayland_display_update_serial (display_wayland, serial); - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); event = gdk_event_crossing_new (GDK_LEAVE_NOTIFY, seat->pointer_info.focus, seat->master_pointer, seat->pointer, 0, 0, - x, y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, GDK_CROSSING_NORMAL, GDK_NOTIFY_NONLINEAR); gdk_wayland_seat_set_frame_event (seat, event); @@ -1603,7 +1589,6 @@ pointer_handle_motion (void *data, GdkWaylandSeat *seat = data; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display); GdkEvent *event; - double x, y, x_root, y_root; if (!seat->pointer_info.focus) return; @@ -1612,20 +1597,19 @@ pointer_handle_motion (void *data, seat->pointer_info.surface_x = wl_fixed_to_double (sx); seat->pointer_info.surface_y = wl_fixed_to_double (sy); - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); - event = gdk_event_motion_new (seat->pointer_info.focus, seat->master_pointer, seat->pointer, NULL, time, device_get_modifiers (seat->master_pointer), - x, y); + seat->pointer_info.surface_x, + seat->pointer_info.surface_y); gdk_wayland_seat_set_frame_event (seat, event); GDK_SEAT_NOTE (seat, EVENTS, g_message ("motion %f %f, seat %p state %d", - wl_fixed_to_double (sx), wl_fixed_to_double (sy), + event->motion.x, event->motion.y, seat, event->motion.state)); if (display->seat_version < WL_POINTER_HAS_FRAME) @@ -1645,7 +1629,6 @@ pointer_handle_button (void *data, GdkEvent *event; uint32_t modifier; int gdk_button; - double x, y, x_root, y_root; if (!seat->pointer_info.focus) return; @@ -1673,15 +1656,14 @@ pointer_handle_button (void *data, if (state) seat->pointer_info.press_serial = serial; - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); - event = gdk_event_button_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE, seat->pointer_info.focus, seat->master_pointer, seat->pointer, NULL, time, - x, y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, gdk_button, device_get_modifiers (seat->master_pointer)); @@ -2438,20 +2420,19 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat, gdouble dy) { GdkEvent *event; - double x, y, x_root, y_root; if (!seat->pointer_info.focus) return; seat->pointer_info.time = _time; - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); event = gdk_event_touchpad_swipe_new (seat->pointer_info.focus, seat->master_pointer, seat->pointer, _time, device_get_modifiers (seat->master_pointer), - x, y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, n_fingers, dx, dy); @@ -2532,22 +2513,20 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat, gdouble angle_delta) { GdkEvent *event; - double x, y, x_root, y_root; if (!seat->pointer_info.focus) return; seat->pointer_info.time = _time; - get_coordinates (seat->master_pointer, &x, &y, &x_root, &y_root); - event = gdk_event_touchpad_pinch_new (seat->pointer_info.focus, seat->master_pointer, seat->pointer, _time, device_get_modifiers (seat->master_pointer), phase, - x, y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, n_fingers, dx, dy, scale, angle_delta * G_PI / 180); @@ -3462,16 +3441,15 @@ tablet_create_button_event_frame (GdkWaylandTabletData *tablet, { GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat); GdkEvent *event; - double x, y, x_root, y_root; - get_coordinates (tablet->master, &x, &y, &x_root, &y_root); event = gdk_event_button_new (evtype, tablet->pointer_info.focus, tablet->master, tablet->current_device, tablet->current_tool->tool, tablet->pointer_info.time, - x, y, + tablet->pointer_info.surface_x, + tablet->pointer_info.surface_y, button, device_get_modifiers (seat->master_pointer)); gdk_wayland_tablet_set_frame_event (tablet, event); @@ -3521,7 +3499,6 @@ tablet_tool_handle_motion (void *data, GdkWaylandTabletData *tablet = tool->current_tablet; GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat); GdkEvent *event; - double x, y, x_root, y_root; tablet->pointer_info.surface_x = wl_fixed_to_double (sx); tablet->pointer_info.surface_y = wl_fixed_to_double (sy); @@ -3531,14 +3508,14 @@ tablet_tool_handle_motion (void *data, tablet->pointer_info.surface_x, tablet->pointer_info.surface_y)); - get_coordinates (tablet->master, &x, &y, &x_root, &y_root); event = gdk_event_motion_new (tablet->pointer_info.focus, tablet->master, tablet->current_device, tool->tool, tablet->pointer_info.time, device_get_modifiers (tablet->master), - x, y); + tablet->pointer_info.surface_x, + tablet->pointer_info.surface_y); gdk_wayland_tablet_set_frame_event (tablet, event); }