mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt/embedded: make performAction return the performable state
This commit is contained in:
@ -644,7 +644,7 @@ typedef void (*ghostty_runtime_write_clipboard_cb)(void*,
|
|||||||
ghostty_clipboard_e,
|
ghostty_clipboard_e,
|
||||||
bool);
|
bool);
|
||||||
typedef void (*ghostty_runtime_close_surface_cb)(void*, bool);
|
typedef void (*ghostty_runtime_close_surface_cb)(void*, bool);
|
||||||
typedef void (*ghostty_runtime_action_cb)(ghostty_app_t,
|
typedef bool (*ghostty_runtime_action_cb)(ghostty_app_t,
|
||||||
ghostty_target_s,
|
ghostty_target_s,
|
||||||
ghostty_action_s);
|
ghostty_action_s);
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ extension Ghostty {
|
|||||||
|
|
||||||
// MARK: Actions (macOS)
|
// MARK: Actions (macOS)
|
||||||
|
|
||||||
static func action(_ app: ghostty_app_t, target: ghostty_target_s, action: ghostty_action_s) {
|
static func action(_ app: ghostty_app_t, target: ghostty_target_s, action: ghostty_action_s) -> Bool {
|
||||||
// Make sure it a target we understand so all our action handlers can assert
|
// Make sure it a target we understand so all our action handlers can assert
|
||||||
switch (target.tag) {
|
switch (target.tag) {
|
||||||
case GHOSTTY_TARGET_APP, GHOSTTY_TARGET_SURFACE:
|
case GHOSTTY_TARGET_APP, GHOSTTY_TARGET_SURFACE:
|
||||||
@ -431,7 +431,7 @@ extension Ghostty {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
Ghostty.logger.warning("unknown action target=\(target.tag.rawValue)")
|
Ghostty.logger.warning("unknown action target=\(target.tag.rawValue)")
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action dispatch
|
// Action dispatch
|
||||||
@ -541,10 +541,15 @@ extension Ghostty {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case GHOSTTY_ACTION_QUIT_TIMER:
|
case GHOSTTY_ACTION_QUIT_TIMER:
|
||||||
Ghostty.logger.info("known but unimplemented action action=\(action.tag.rawValue)")
|
Ghostty.logger.info("known but unimplemented action action=\(action.tag.rawValue)")
|
||||||
|
return false
|
||||||
default:
|
default:
|
||||||
Ghostty.logger.warning("unknown action action=\(action.tag.rawValue)")
|
Ghostty.logger.warning("unknown action action=\(action.tag.rawValue)")
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we reached here then we assume performed since all unknown actions
|
||||||
|
// are captured in the switch and return false.
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func quit(_ app: ghostty_app_t) {
|
private static func quit(_ app: ghostty_app_t) {
|
||||||
|
@ -46,7 +46,7 @@ pub const App = struct {
|
|||||||
wakeup: *const fn (AppUD) callconv(.C) void,
|
wakeup: *const fn (AppUD) callconv(.C) void,
|
||||||
|
|
||||||
/// Callback called to handle an action.
|
/// Callback called to handle an action.
|
||||||
action: *const fn (*App, apprt.Target.C, apprt.Action.C) callconv(.C) void,
|
action: *const fn (*App, apprt.Target.C, apprt.Action.C) callconv(.C) bool,
|
||||||
|
|
||||||
/// Read the clipboard value. The return value must be preserved
|
/// Read the clipboard value. The return value must be preserved
|
||||||
/// by the host until the next call. If there is no valid clipboard
|
/// by the host until the next call. If there is no valid clipboard
|
||||||
@ -495,13 +495,11 @@ pub const App = struct {
|
|||||||
action,
|
action,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
self.opts.action(
|
return self.opts.action(
|
||||||
self,
|
self,
|
||||||
target.cval(),
|
target.cval(),
|
||||||
@unionInit(apprt.Action, @tagName(action), value).cval(),
|
@unionInit(apprt.Action, @tagName(action), value).cval(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn performPreAction(
|
fn performPreAction(
|
||||||
|
Reference in New Issue
Block a user