diff --git a/output.c b/output.c index 0f933e2..0f49c6e 100644 --- a/output.c +++ b/output.c @@ -163,4 +163,15 @@ handle_new_output(struct wl_listener *listener, void *data) /* Disconnect the signal now, because we only use one static output. */ wl_list_remove(&server->new_output.link); + + if (wlr_xcursor_manager_load(server->seat->xcursor_manager, wlr_output->scale)) { + wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", + wlr_output->name, + wlr_output->scale); + } + wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager, DEFAULT_XCURSOR, + server->seat->cursor); + + /* Place the cursor in the center of the screen. */ + wlr_cursor_warp(server->seat->cursor, NULL, wlr_output->width / 2, wlr_output->height / 2); } diff --git a/seat.c b/seat.c index 96c98b7..73b2d82 100644 --- a/seat.c +++ b/seat.c @@ -20,7 +20,6 @@ #include "server.h" #include "view.h" -#define DEFAULT_XCURSOR "left_ptr" #define XCURSOR_SIZE 24 static inline bool @@ -452,20 +451,6 @@ cg_seat_create(struct cg_server *server) } } - float scale = 1.f; // TODO: segault because server->output->wlr_output->scale does not exist yet; - if (wlr_xcursor_manager_load(seat->xcursor_manager, scale)) { - wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", - server->output->wlr_output->name, - server->output->wlr_output->scale); - } - - wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager, DEFAULT_XCURSOR, seat->cursor); - - // TODO: warp to the center? - /* /\* Place the cursor in the center of the screen and make it visible. *\/ */ - /* wlr_cursor_warp_absolute(seat->cursor, NULL, .5, .5); */ - wlr_cursor_warp(seat->cursor, NULL, seat->cursor->x, seat->cursor->y); - seat->cursor_motion.notify = handle_cursor_motion; wl_signal_add(&seat->cursor->events.motion, &seat->cursor_motion); seat->cursor_motion_absolute.notify = handle_cursor_motion_absolute; diff --git a/seat.h b/seat.h index e7304c0..c25c03a 100644 --- a/seat.h +++ b/seat.h @@ -10,6 +10,8 @@ #include "server.h" #include "view.h" +#define DEFAULT_XCURSOR "left_ptr" + struct cg_seat { struct wlr_seat *seat; struct cg_server *server;