From 1f4a80aa9399fa56d45a8fcbfae0ef1d7d17c7d8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 9 Aug 2023 19:44:55 -0700 Subject: [PATCH] apprt/embedded: keymap state is per surface, not per app --- src/apprt/embedded.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 6d3dd7f43..3c8ba0ff3 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -76,7 +76,6 @@ pub const App = struct { config: *const Config, opts: Options, keymap: input.Keymap, - keymap_state: input.Keymap.State, pub fn init(core_app: *CoreApp, config: *const Config, opts: Options) !App { return .{ @@ -84,7 +83,6 @@ pub const App = struct { .config = config, .opts = opts, .keymap = try input.Keymap.init(), - .keymap_state = .{}, }; } @@ -100,7 +98,9 @@ pub const App = struct { // Clear the dead key state since we changed the keymap, any // dead key state is just forgotten. i.e. if you type ' on us-intl // and then switch to us and type a, you'll get a rather than รก. - self.keymap_state = .{}; + for (self.core_app.surfaces.items) |surface| { + surface.keymap_state = .{}; + } } pub fn reloadConfig(self: *App) !?*const Config { @@ -155,6 +155,7 @@ pub const Surface = struct { size: apprt.SurfaceSize, cursor_pos: apprt.CursorPos, opts: Options, + keymap_state: input.Keymap.State, pub const Options = extern struct { /// Userdata passed to some of the callbacks. @@ -179,6 +180,7 @@ pub const Surface = struct { .size = .{ .width = 800, .height = 600 }, .cursor_pos = .{ .x = 0, .y = 0 }, .opts = opts, + .keymap_state = .{}, }; // Add ourselves to the list of surfaces on the app. @@ -577,7 +579,7 @@ pub const CAPI = struct { const mods: input.Mods = @bitCast(@as(u8, @truncate(@as(c_uint, @bitCast(c_mods))))); const result = surface.app.keymap.translate( &buf, - &surface.app.keymap_state, + &surface.keymap_state, @intCast(keycode), mods, ) catch |err| {