diff --git a/cage.c b/cage.c index 7a4bd9f..f0526be 100644 --- a/cage.c +++ b/cage.c @@ -579,11 +579,7 @@ main(int argc, char *argv[]) goto end; } - /* Place the cursor in the center of the output layout. */ - struct wlr_box layout_box; - wlr_output_layout_get_box(server.output_layout, NULL, &layout_box); - wlr_cursor_warp(server.seat->cursor, NULL, layout_box.width / 2, layout_box.height / 2); - + seat_center_cursor(server.seat); wl_display_run(server.wl_display); #if CAGE_HAS_XWAYLAND diff --git a/seat.c b/seat.c index 80fd86a..d456834 100644 --- a/seat.c +++ b/seat.c @@ -944,3 +944,12 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) process_cursor_motion(seat, -1); } + +void +seat_center_cursor(struct cg_seat *seat) +{ + /* Place the cursor in the center of the output layout. */ + struct wlr_box layout_box; + wlr_output_layout_get_box(seat->server->output_layout, NULL, &layout_box); + wlr_cursor_warp(seat->cursor, NULL, layout_box.width / 2, layout_box.height / 2); +} diff --git a/seat.h b/seat.h index 19ed936..b27b912 100644 --- a/seat.h +++ b/seat.h @@ -91,5 +91,6 @@ struct cg_seat *seat_create(struct cg_server *server, struct wlr_backend *backen void seat_destroy(struct cg_seat *seat); struct cg_view *seat_get_focus(struct cg_seat *seat); void seat_set_focus(struct cg_seat *seat, struct cg_view *view); +void seat_center_cursor(struct cg_seat *seat); #endif