]> git.mdlowis.com Git - proto/labwc.git/commitdiff
seat: support WLR_{WL,X11}_OUTPUTS >= 2
authorJohan Malm <jgm323@gmail.com>
Thu, 6 Jan 2022 21:40:10 +0000 (21:40 +0000)
committerJohan Malm <jgm323@gmail.com>
Thu, 6 Jan 2022 21:40:10 +0000 (21:40 +0000)
When running nested in X11 or a wlroots compositor with the respective
environment variables WLR_X11_OUTPUTS or WLR_WL_OUTPUTS set to value >= 2,
cursors need to be mapped to the respective outputs.

Closes issue #196

Suggested-by: @Consolatis
Written-by: @johanmalm
src/seat.c

index e9e8a99504fe3d9f53aed7dba13411e5fe1764c0..c27551ec5c109841bc8e3e7b2b870c84fe6abe43 100644 (file)
@@ -112,13 +112,33 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
        }
 }
 
+static struct wlr_output *
+output_by_name(struct server *server, const char *name)
+{
+       struct output *output;
+       wl_list_for_each(output, &server->outputs, link) {
+               if (!strcasecmp(output->wlr_output->name, name)) {
+                       return output->wlr_output;
+               }
+       }
+       return NULL;
+}
+
 void
 new_pointer(struct seat *seat, struct input *input)
 {
-       if (wlr_input_device_is_libinput(input->wlr_input_device)) {
-               configure_libinput(input->wlr_input_device);
+       struct wlr_input_device *dev = input->wlr_input_device;
+       if (wlr_input_device_is_libinput(dev)) {
+               configure_libinput(dev);
        }
-       wlr_cursor_attach_input_device(seat->cursor, input->wlr_input_device);
+       wlr_cursor_attach_input_device(seat->cursor, dev);
+
+       /* In support of running with WLR_WL_OUTPUTS set to >=2 */
+       wlr_log(WLR_INFO, "map pointer to output %s\n", dev->output_name);
+       struct wlr_output *output =
+               output_by_name(seat->server, dev->output_name);
+       wlr_cursor_map_input_to_output(seat->cursor, dev, output);
+       wlr_cursor_map_input_to_region(seat->cursor, dev, NULL);
 }
 
 void
@@ -227,7 +247,6 @@ seat_init(struct server *server)
                &seat->idle_inhibitor_create);
        seat->idle_inhibitor_create.notify = new_idle_inhibitor;
 
-
        seat->cursor = wlr_cursor_create();
        if (!seat->cursor) {
                wlr_log(WLR_ERROR, "unable to create cursor");