mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
apprt/embedded: keymap state is per surface, not per app
This commit is contained in:
@ -76,7 +76,6 @@ pub const App = struct {
|
|||||||
config: *const Config,
|
config: *const Config,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
keymap: input.Keymap,
|
keymap: input.Keymap,
|
||||||
keymap_state: input.Keymap.State,
|
|
||||||
|
|
||||||
pub fn init(core_app: *CoreApp, config: *const Config, opts: Options) !App {
|
pub fn init(core_app: *CoreApp, config: *const Config, opts: Options) !App {
|
||||||
return .{
|
return .{
|
||||||
@ -84,7 +83,6 @@ pub const App = struct {
|
|||||||
.config = config,
|
.config = config,
|
||||||
.opts = opts,
|
.opts = opts,
|
||||||
.keymap = try input.Keymap.init(),
|
.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
|
// 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
|
// 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 á.
|
// 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 {
|
pub fn reloadConfig(self: *App) !?*const Config {
|
||||||
@ -155,6 +155,7 @@ pub const Surface = struct {
|
|||||||
size: apprt.SurfaceSize,
|
size: apprt.SurfaceSize,
|
||||||
cursor_pos: apprt.CursorPos,
|
cursor_pos: apprt.CursorPos,
|
||||||
opts: Options,
|
opts: Options,
|
||||||
|
keymap_state: input.Keymap.State,
|
||||||
|
|
||||||
pub const Options = extern struct {
|
pub const Options = extern struct {
|
||||||
/// Userdata passed to some of the callbacks.
|
/// Userdata passed to some of the callbacks.
|
||||||
@ -179,6 +180,7 @@ pub const Surface = struct {
|
|||||||
.size = .{ .width = 800, .height = 600 },
|
.size = .{ .width = 800, .height = 600 },
|
||||||
.cursor_pos = .{ .x = 0, .y = 0 },
|
.cursor_pos = .{ .x = 0, .y = 0 },
|
||||||
.opts = opts,
|
.opts = opts,
|
||||||
|
.keymap_state = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add ourselves to the list of surfaces on the app.
|
// 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 mods: input.Mods = @bitCast(@as(u8, @truncate(@as(c_uint, @bitCast(c_mods)))));
|
||||||
const result = surface.app.keymap.translate(
|
const result = surface.app.keymap.translate(
|
||||||
&buf,
|
&buf,
|
||||||
&surface.app.keymap_state,
|
&surface.keymap_state,
|
||||||
@intCast(keycode),
|
@intCast(keycode),
|
||||||
mods,
|
mods,
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
|
Reference in New Issue
Block a user