]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: update cursor image on scale change
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Thu, 26 Jan 2023 00:21:43 +0000 (01:21 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 26 Jan 2023 22:02:13 +0000 (22:02 +0000)
include/cursor.h
src/cursor.c
src/output.c

index 757a14dba5bfcdb5e9683122b74ad8059006cbfa..0f42cfb4272e4e624abae831cc3a0f69b23dbea3 100644 (file)
@@ -106,6 +106,16 @@ enum lab_cursors cursor_get_from_edge(uint32_t resize_edges);
  */
 void cursor_update_focus(struct server *server);
 
+/**
+ * cursor_update_image - re-set the labwc cursor image
+ * @seat - seat
+ *
+ * This can be used to update the cursor image on output scale changes.
+ * If the current cursor image was not set by labwc but some client
+ * this is a no-op.
+ */
+void cursor_update_image(struct seat *seat);
+
 void cursor_init(struct seat *seat);
 void cursor_finish(struct seat *seat);
 
index 9be1e4748eb1bbac07ed3ad42ae50bfbbeec955e..cac5dd8e645b94bcb9f252c1fc9303a30619610d 100644 (file)
@@ -259,6 +259,17 @@ cursor_set(struct seat *seat, enum lab_cursors cursor)
        seat->server_cursor = cursor;
 }
 
+void
+cursor_update_image(struct seat *seat)
+{
+       enum lab_cursors cursor = seat->server_cursor;
+       if (cursor == LAB_CURSOR_CLIENT) {
+               return;
+       }
+       wlr_xcursor_manager_set_cursor_image(
+               seat->xcursor_manager, cursor_names[cursor], seat->cursor);
+}
+
 bool
 input_inhibit_blocks_surface(struct seat *seat, struct wl_resource *resource)
 {
index 18a481f5c0b7c6a718fb5d36ab5928157714a0b1..3b6482a8d69e07d4bcff530f2a7fd8b220dcdca7 100644 (file)
@@ -264,15 +264,11 @@ output_update_for_layout_change(struct server *server)
 
        /*
         * "Move" each wlr_output_cursor (in per-output coordinates) to
-        * align with the seat cursor. Set a default cursor image so
-        * that the cursor isn't invisible on new outputs.
-        *
-        * TODO: remember the most recent cursor image (see cursor.c)
-        * and set that rather than XCURSOR_DEFAULT
+        * align with the seat cursor. Re-set the cursor image so that
+        * the cursor isn't invisible on new outputs.
         */
        wlr_cursor_move(server->seat.cursor, NULL, 0, 0);
-       wlr_xcursor_manager_set_cursor_image(server->seat.xcursor_manager,
-               XCURSOR_DEFAULT, server->seat.cursor);
+       cursor_update_image(&server->seat);
 }
 
 static void
@@ -364,6 +360,7 @@ handle_output_manager_apply(struct wl_listener *listener, void *data)
 
        /* Re-set cursor image in case scale changed */
        cursor_update_focus(server);
+       cursor_update_image(&server->seat);
 }
 
 /*