]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: relocate cursor_emulate functions
authorJens Peters <jp7677@gmail.com>
Fri, 2 May 2025 12:19:08 +0000 (14:19 +0200)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Fri, 2 May 2025 20:34:05 +0000 (05:34 +0900)
src/input/cursor.c

index 27f776943f94d1f0cc928b67a3a5791330661b01..f50cd97411abcc4d200a51976ac2c5e4ac9ad071 100644 (file)
@@ -1189,66 +1189,6 @@ handle_button(struct wl_listener *listener, void *data)
        }
 }
 
-void
-cursor_emulate_move(struct seat *seat, struct wlr_input_device *device,
-               double dx, double dy, uint32_t time_msec)
-{
-       if (!dx && !dy) {
-               wlr_log(WLR_DEBUG, "dropping useless cursor_emulate: %.10f,%.10f", dx, dy);
-               return;
-       }
-
-       wlr_relative_pointer_manager_v1_send_relative_motion(
-               seat->server->relative_pointer_manager,
-               seat->seat, (uint64_t)time_msec * 1000,
-               dx, dy, dx, dy);
-
-       wlr_cursor_move(seat->cursor, device, dx, dy);
-       double sx, sy;
-       bool notify = cursor_process_motion(seat->server, time_msec, &sx, &sy);
-       if (notify) {
-               wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy);
-       }
-       wlr_seat_pointer_notify_frame(seat->seat);
-}
-
-void
-cursor_emulate_move_absolute(struct seat *seat, struct wlr_input_device *device,
-               double x, double y, uint32_t time_msec)
-{
-       double lx, ly;
-       wlr_cursor_absolute_to_layout_coords(seat->cursor,
-               device, x, y, &lx, &ly);
-
-       double dx = lx - seat->cursor->x;
-       double dy = ly - seat->cursor->y;
-
-       cursor_emulate_move(seat, device, dx, dy, time_msec);
-}
-
-void
-cursor_emulate_button(struct seat *seat, uint32_t button,
-               enum wl_pointer_button_state state, uint32_t time_msec)
-{
-       bool notify;
-       switch (state) {
-       case WL_POINTER_BUTTON_STATE_PRESSED:
-               notify = cursor_process_button_press(seat, button, time_msec);
-               if (notify) {
-                       wlr_seat_pointer_notify_button(seat->seat, time_msec, button, state);
-               }
-               break;
-       case WL_POINTER_BUTTON_STATE_RELEASED:
-               notify = cursor_process_button_release(seat, button, time_msec);
-               if (notify) {
-                       wlr_seat_pointer_notify_button(seat->seat, time_msec, button, state);
-               }
-               cursor_finish_button_release(seat, button);
-               break;
-       }
-       wlr_seat_pointer_notify_frame(seat->seat);
-}
-
 struct scroll_info {
        int direction;
        bool run_action;
@@ -1396,6 +1336,66 @@ handle_frame(struct wl_listener *listener, void *data)
        wlr_seat_pointer_notify_frame(seat->seat);
 }
 
+void
+cursor_emulate_move(struct seat *seat, struct wlr_input_device *device,
+               double dx, double dy, uint32_t time_msec)
+{
+       if (!dx && !dy) {
+               wlr_log(WLR_DEBUG, "dropping useless cursor_emulate: %.10f,%.10f", dx, dy);
+               return;
+       }
+
+       wlr_relative_pointer_manager_v1_send_relative_motion(
+               seat->server->relative_pointer_manager,
+               seat->seat, (uint64_t)time_msec * 1000,
+               dx, dy, dx, dy);
+
+       wlr_cursor_move(seat->cursor, device, dx, dy);
+       double sx, sy;
+       bool notify = cursor_process_motion(seat->server, time_msec, &sx, &sy);
+       if (notify) {
+               wlr_seat_pointer_notify_motion(seat->seat, time_msec, sx, sy);
+       }
+       wlr_seat_pointer_notify_frame(seat->seat);
+}
+
+void
+cursor_emulate_move_absolute(struct seat *seat, struct wlr_input_device *device,
+               double x, double y, uint32_t time_msec)
+{
+       double lx, ly;
+       wlr_cursor_absolute_to_layout_coords(seat->cursor,
+               device, x, y, &lx, &ly);
+
+       double dx = lx - seat->cursor->x;
+       double dy = ly - seat->cursor->y;
+
+       cursor_emulate_move(seat, device, dx, dy, time_msec);
+}
+
+void
+cursor_emulate_button(struct seat *seat, uint32_t button,
+               enum wl_pointer_button_state state, uint32_t time_msec)
+{
+       bool notify;
+       switch (state) {
+       case WL_POINTER_BUTTON_STATE_PRESSED:
+               notify = cursor_process_button_press(seat, button, time_msec);
+               if (notify) {
+                       wlr_seat_pointer_notify_button(seat->seat, time_msec, button, state);
+               }
+               break;
+       case WL_POINTER_BUTTON_STATE_RELEASED:
+               notify = cursor_process_button_release(seat, button, time_msec);
+               if (notify) {
+                       wlr_seat_pointer_notify_button(seat->seat, time_msec, button, state);
+               }
+               cursor_finish_button_release(seat, button);
+               break;
+       }
+       wlr_seat_pointer_notify_frame(seat->seat);
+}
+
 static void
 cursor_load(struct seat *seat)
 {