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,
|
||||
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_action_s);
|
||||
|
||||
|
@ -423,7 +423,7 @@ extension Ghostty {
|
||||
|
||||
// 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
|
||||
switch (target.tag) {
|
||||
case GHOSTTY_TARGET_APP, GHOSTTY_TARGET_SURFACE:
|
||||
@ -431,7 +431,7 @@ extension Ghostty {
|
||||
|
||||
default:
|
||||
Ghostty.logger.warning("unknown action target=\(target.tag.rawValue)")
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
// Action dispatch
|
||||
@ -541,10 +541,15 @@ extension Ghostty {
|
||||
fallthrough
|
||||
case GHOSTTY_ACTION_QUIT_TIMER:
|
||||
Ghostty.logger.info("known but unimplemented action action=\(action.tag.rawValue)")
|
||||
|
||||
return false
|
||||
default:
|
||||
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) {
|
||||
|
@ -46,7 +46,7 @@ pub const App = struct {
|
||||
wakeup: *const fn (AppUD) callconv(.C) void,
|
||||
|
||||
/// 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
|
||||
/// by the host until the next call. If there is no valid clipboard
|
||||
@ -495,13 +495,11 @@ pub const App = struct {
|
||||
action,
|
||||
value,
|
||||
});
|
||||
self.opts.action(
|
||||
return self.opts.action(
|
||||
self,
|
||||
target.cval(),
|
||||
@unionInit(apprt.Action, @tagName(action), value).cval(),
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
fn performPreAction(
|
||||
|
Reference in New Issue
Block a user