From d904abe0768293b2322dbf355b6e41d94e769d78 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 25 Apr 2021 23:13:52 +0200 Subject: gnu: kmscon: Open a new keymap-update FIFO once a request has been processed. Fixes . Reported by Maxim Cournoyer . Until now, as soon as you had selected the keyboard layout in the Guix System installer, kmscon would start spinning on epoll_wait(2) calls because of an event on the initial FIFO file descriptor (corresponding to the fact that the client closed it.) * gnu/packages/patches/kmscon-runtime-keymap-switch.patch: In 'uxkb_keymap_update_handler', add calls to 'ev_eloop_rm_fd', 'close', and 'uxkb_dev_keymap_update' In 'uxkb_dev_keymap_update', add call to 'unlink'. --- .../patches/kmscon-runtime-keymap-switch.patch | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'gnu/packages/patches/kmscon-runtime-keymap-switch.patch') diff --git a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch index deb5688daf..480aaecad2 100644 --- a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch +++ b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch @@ -1,5 +1,9 @@ -By Mathieu Othacehe . -Modified by Florian Pelz . +Make kmscon listen to a FIFO in /tmp that clients can write to +to request a keymap change. + +Patch by Mathieu Othacehe . +Modified by Florian Pelz +and Ludovic Courtès . diff --git a/src/pty.c b/src/pty.c index 1443f4a..f64cb5b 100644 @@ -115,7 +119,7 @@ index 04e6cc9..ec44459 100644 uint16_t key_state, uint16_t code); diff --git a/src/uterm_input_uxkb.c b/src/uterm_input_uxkb.c -index 925c755..5d5c22e 100644 +index 925c755..8fe08f8 100644 --- a/src/uterm_input_uxkb.c +++ b/src/uterm_input_uxkb.c @@ -31,6 +31,9 @@ @@ -128,7 +132,7 @@ index 925c755..5d5c22e 100644 #include #include "shl_hook.h" #include "shl_llog.h" -@@ -178,6 +181,87 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data) +@@ -178,6 +181,95 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data) shl_hook_call(dev->input->hook, dev->input, &dev->repeat_event); } @@ -169,6 +173,13 @@ index 925c755..5d5c22e 100644 + model, layout, variant); + uxkb_desc_init(dev->input, model, layout, variant, options, NULL); + ++ /* The client will now close the FIFO. Close it too, and re-create a ++ * FIFO so other clients can eventually connect. */ ++ ev_eloop_rm_fd(fd); ++ close(dev->rupdate_fd); ++ dev->rupdate_fd = -1; ++ uxkb_dev_keymap_update(dev); ++ + dev->state = xkb_state_new(dev->input->keymap); + if (!dev->state) { + llog_error(dev->input, "cannot create XKB state"); @@ -186,6 +197,7 @@ index 925c755..5d5c22e 100644 + if (ret < 0) + return ret; + ++ (void) unlink(file); + ret = mkfifo(file, S_IRWXU); + if (ret < 0) { + llog_warn(dev->input, "could not open fifo"); -- cgit v1.2.3 From a6a36059d5c06d7177edcfd1cff45bcb9e880d24 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Thu, 29 Apr 2021 11:11:32 +0200 Subject: gnu: kmscon: Fix layout setup. Kmscon may discover multiple inputs, corresponding to multiple devices. This means that the uxkb_dev_keymap_update function may be called multiple times, and the FIFO is registered on each input poll loop. When a new layout is written on the FIFO by the installer, the first input picking up the message, will apply the new layout. However, that input may not be the input that the user is currently using. To fix it, register the FIFO on the first input poll loop, but apply the new layout on all the inputs in the uxkb_keymap_update_handler function. * gnu/packages/patches/kmscon-runtime-keymap-switch.patch (uxkb_keymap_update_handler): Apply the new layout to all the inputs. (input_new_dev): Register the FIFO fd only on the first input poll loop. --- .../patches/kmscon-runtime-keymap-switch.patch | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'gnu/packages/patches/kmscon-runtime-keymap-switch.patch') diff --git a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch index 480aaecad2..6692e761bc 100644 --- a/gnu/packages/patches/kmscon-runtime-keymap-switch.patch +++ b/gnu/packages/patches/kmscon-runtime-keymap-switch.patch @@ -79,11 +79,13 @@ diff --git a/src/uterm_input.c b/src/uterm_input.c index 6fcbc4b..990a09d 100644 --- a/src/uterm_input.c +++ b/src/uterm_input.c -@@ -178,6 +178,8 @@ static void input_new_dev(struct uterm_input *input, +@@ -178,6 +178,10 @@ static void input_new_dev(struct uterm_input *input, if (ret) goto err_rcodepoints; -+ uxkb_dev_keymap_update(dev); ++ /* Add the FIFO fd only to the first input poll loop. */ ++ if (shl_dlist_empty(&input->devices)) ++ uxkb_dev_keymap_update(dev); + if (input->awake > 0) { ret = input_wake_up_dev(dev); @@ -132,7 +134,7 @@ index 925c755..8fe08f8 100644 #include #include "shl_hook.h" #include "shl_llog.h" -@@ -178,6 +181,95 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data) +@@ -178,6 +181,106 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data) shl_hook_call(dev->input->hook, dev->input, &dev->repeat_event); } @@ -171,7 +173,23 @@ index 925c755..8fe08f8 100644 + + llog_info(dev->input, "HANDLER CALLED %s|%s|%s\n", + model, layout, variant); -+ uxkb_desc_init(dev->input, model, layout, variant, options, NULL); ++ ++ struct uterm_input *input = dev->input; ++ struct shl_dlist *iter; ++ ++ /* Apply the new layout to all the inputs. */ ++ shl_dlist_for_each(iter, &input->devices) { ++ struct uterm_input_dev *dev; ++ dev = shl_dlist_entry(iter, ++ struct uterm_input_dev, ++ list); ++ uxkb_desc_init(dev->input, model, layout, variant, options, NULL); ++ dev->state = xkb_state_new(dev->input->keymap); ++ if (!dev->state) { ++ llog_error(dev->input, "cannot create XKB state"); ++ return; ++ } ++ } + + /* The client will now close the FIFO. Close it too, and re-create a + * FIFO so other clients can eventually connect. */ @@ -180,11 +198,6 @@ index 925c755..8fe08f8 100644 + dev->rupdate_fd = -1; + uxkb_dev_keymap_update(dev); + -+ dev->state = xkb_state_new(dev->input->keymap); -+ if (!dev->state) { -+ llog_error(dev->input, "cannot create XKB state"); -+ return; -+ } +} + +int uxkb_dev_keymap_update(struct uterm_input_dev *dev) -- cgit v1.2.3