mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
feat(macos): allow setting an intial start position
This commit is contained in:

committed by
Mitchell Hashimoto

parent
5ced72498e
commit
9a58de6d5a
@ -514,6 +514,12 @@ typedef struct {
|
|||||||
uint32_t height;
|
uint32_t height;
|
||||||
} ghostty_action_initial_size_s;
|
} ghostty_action_initial_size_s;
|
||||||
|
|
||||||
|
// apprt.action.InitialPosition
|
||||||
|
typedef struct {
|
||||||
|
int32_t x;
|
||||||
|
int32_t y;
|
||||||
|
} ghostty_action_initial_position_s;
|
||||||
|
|
||||||
// apprt.action.CellSize
|
// apprt.action.CellSize
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
@ -606,6 +612,7 @@ typedef union {
|
|||||||
ghostty_action_resize_split_s resize_split;
|
ghostty_action_resize_split_s resize_split;
|
||||||
ghostty_action_size_limit_s size_limit;
|
ghostty_action_size_limit_s size_limit;
|
||||||
ghostty_action_initial_size_s initial_size;
|
ghostty_action_initial_size_s initial_size;
|
||||||
|
ghostty_action_initial_position_s initial_position;
|
||||||
ghostty_action_cell_size_s cell_size;
|
ghostty_action_cell_size_s cell_size;
|
||||||
ghostty_action_inspector_e inspector;
|
ghostty_action_inspector_e inspector;
|
||||||
ghostty_action_desktop_notification_s desktop_notification;
|
ghostty_action_desktop_notification_s desktop_notification;
|
||||||
|
@ -517,6 +517,9 @@ extension Ghostty {
|
|||||||
case GHOSTTY_ACTION_INITIAL_SIZE:
|
case GHOSTTY_ACTION_INITIAL_SIZE:
|
||||||
setInitialSize(app, target: target, v: action.action.initial_size)
|
setInitialSize(app, target: target, v: action.action.initial_size)
|
||||||
|
|
||||||
|
case GHOSTTY_ACTION_INITIAL_POSITION:
|
||||||
|
setInitialPosition(app, target: target, v: action.action.initial_position)
|
||||||
|
|
||||||
case GHOSTTY_ACTION_CELL_SIZE:
|
case GHOSTTY_ACTION_CELL_SIZE:
|
||||||
setCellSize(app, target: target, v: action.action.cell_size)
|
setCellSize(app, target: target, v: action.action.cell_size)
|
||||||
|
|
||||||
@ -1069,6 +1072,26 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func setInitialPosition(
|
||||||
|
_ app: ghostty_app_t,
|
||||||
|
target: ghostty_target_s,
|
||||||
|
v: ghostty_action_initial_position_s) {
|
||||||
|
switch (target.tag) {
|
||||||
|
case GHOSTTY_TARGET_APP:
|
||||||
|
Ghostty.logger.warning("mouse over link does nothing with an app target")
|
||||||
|
return
|
||||||
|
|
||||||
|
case GHOSTTY_TARGET_SURFACE:
|
||||||
|
guard let surface = target.target.surface else { return }
|
||||||
|
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||||
|
surfaceView.initialPosition = NSMakePoint(Double(v.x), Double(v.y))
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
assertionFailure()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static func setCellSize(
|
private static func setCellSize(
|
||||||
_ app: ghostty_app_t,
|
_ app: ghostty_app_t,
|
||||||
target: ghostty_target_s,
|
target: ghostty_target_s,
|
||||||
|
Reference in New Issue
Block a user