Commit 73375f3abeaa9564f2bd12594f9a454cded220b3 Parent: 26b55b94179193b45c29e7255526dc82e2aab275 Author: mcol <mcol@posteo.net> Date: 2021-02-10 22:28:31 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-02-10 22:28:31 +0000 Warp cursor to centre of output layout upon start closes #28
src/main.c Modified
@@ -182,6 +182,7 @@ setenv("WAYLAND_DISPLAY", socket, true); wlr_log(WLR_INFO, "Starting with WAYLAND_DISPLAY=%s", socket); schedule_auto_start(); + centre_cursor(); wl_display_run(wimp.display); // stop
src/cursor.h Modified
@@ -3,6 +3,7 @@ #include "types.h" +void centre_cursor(); void *under_pointer(struct wlr_surface **surface, double *sx, double *sy, bool *is_layer); void set_up_cursor();
src/cursor.c Modified
@@ -12,6 +12,16 @@ #include "types.h" +void centre_cursor() { + struct wlr_box *extents = wlr_output_layout_get_box(wimp.output_layout, NULL); + double cx, cy; + wlr_output_layout_closest_point( + wimp.output_layout, NULL, extents->width / 2, extents->height / 2, &cx, &cy + ); + wlr_cursor_warp_closest(wimp.cursor, NULL, cx, cy); +} + + static void process_cursor_move(uint32_t time, double zoom) { wimp.grabbed_view->x = (wimp.cursor->x - wimp.grab_x) / zoom; wimp.grabbed_view->y = (wimp.cursor->y - wimp.grab_y) / zoom;