From 125968302721572885bb6ec8eb5bb74c790c55da Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 12 Aug 2025 11:31:54 +0800 Subject: [PATCH 1/2] fix: set wrong keyboard_grab in handle_input_method_grab_keyboard This results in the inability to continuously use the mod key and mouse to drag the window the problem also in axisbind and gesturebind --- src/ext-protocol/text-input.h | 6 +++++- src/mango.c | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ext-protocol/text-input.h b/src/ext-protocol/text-input.h index ee647a2..0577d02 100644 --- a/src/ext-protocol/text-input.h +++ b/src/ext-protocol/text-input.h @@ -111,6 +111,8 @@ get_keyboard_grab(KeyboardGroup *keyboard) { return NULL; } + // 如果键盘不是物理键盘组的键盘,则返回NULL + // kb_group是一个物理键盘组,它的键盘是物理键盘 if (keyboard != kb_group) return NULL; @@ -347,7 +349,9 @@ static void handle_input_method_grab_keyboard(struct wl_listener *listener, wl_container_of(listener, relay, input_method_grab_keyboard); struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data; - struct wlr_keyboard *active_keyboard = wlr_seat_get_keyboard(seat); + // 活动键盘应该是从物理键盘组中获取的, + // wlr_seat_get_keyboard可能获取到的是虚拟键盘,所以会造成设置错误 + struct wlr_keyboard *active_keyboard = &kb_group->wlr_group->keyboard; if (!is_keyboard_emulated_by_input_method(active_keyboard, relay->input_method)) { diff --git a/src/mango.c b/src/mango.c index 55b1a78..184ca7f 100644 --- a/src/mango.c +++ b/src/mango.c @@ -1545,7 +1545,7 @@ axisnotify(struct wl_listener *listener, void *data) { // IDLE_NOTIFY_ACTIVITY; handlecursoractivity(); wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); - keyboard = wlr_seat_get_keyboard(seat); + keyboard = &kb_group->wlr_group->keyboard; // 获取当前按键的mask,比如alt+super或者alt+ctrl mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; @@ -1610,7 +1610,7 @@ int ongesture(struct wlr_pointer_swipe_end_event *event) { motion = swipe_dy < 0 ? SWIPE_UP : SWIPE_DOWN; } - keyboard = wlr_seat_get_keyboard(seat); + keyboard = &kb_group->wlr_group->keyboard; mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; for (ji = 0; ji < config.gesture_bindings_count; ji++) { @@ -1773,7 +1773,7 @@ buttonpress(struct wl_listener *listener, void *data) { } } - keyboard = wlr_seat_get_keyboard(seat); + keyboard = &kb_group->wlr_group->keyboard; mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; for (ji = 0; ji < config.mouse_bindings_count; ji++) { if (config.mouse_bindings_count < 1) @@ -3164,7 +3164,10 @@ void keypressmod(struct wl_listener *listener, void *data) { * pressed. We simply communicate this to the client. */ KeyboardGroup *group = wl_container_of(listener, group, modifiers); + wlr_log(WLR_ERROR, "0"); if (!dwl_im_keyboard_grab_forward_modifiers(group)) { + wlr_log(WLR_ERROR, "1"); + wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard); /* Send modifiers to the client. */ wlr_seat_keyboard_notify_modifiers( From b6c4f59a071671822675ec54818fa49686436e7b Mon Sep 17 00:00:00 2001 From: Lin Xianyi Date: Tue, 12 Aug 2025 17:07:45 +0800 Subject: [PATCH 2/2] nix: add package option for home-manager --- nix/hm-modules.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nix/hm-modules.nix b/nix/hm-modules.nix index 1d1edd4..72628b1 100644 --- a/nix/hm-modules.nix +++ b/nix/hm-modules.nix @@ -4,7 +4,6 @@ self: { pkgs, ... }: let - inherit (self.packages.${pkgs.system}) mango; cfg = config.wayland.windowManager.mango; variables = lib.concatStringsSep " " cfg.systemd.variables; extraCommands = lib.concatStringsSep " && " cfg.systemd.extraCommands; @@ -20,6 +19,11 @@ in { type = types.bool; default = false; }; + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${pkgs.system}.mango; + description = "The mango package to use"; + }; systemd = { enable = mkOption { type = types.bool; @@ -92,7 +96,7 @@ in { }; config = lib.mkIf cfg.enable { - home.packages = [mango]; + home.packages = [ cfg.package ]; home.activation = lib.optionalAttrs (cfg.autostart_sh != "") { createMangoScript = lib.hm.dag.entryAfter ["clearMangoConfig"] ''