Merge pull request #5880 from terids/core-darwin-bindings

core/sys/darwin/Foundation: Add additional AppKit bindings
This commit is contained in:
Jeroen van Rijn
2025-11-04 10:59:38 +01:00
committed by GitHub
3 changed files with 151 additions and 0 deletions

View File

@@ -132,6 +132,11 @@ Application_finishLaunching :: proc "c" (self: ^Application) {
msgSend(nil, self, "finishLaunching")
}
@(objc_type=Application, objc_name="stop")
Application_stop :: proc "c" (self: ^Application, sender: ^Object) {
msgSend(nil, self, "stop:", sender)
}
@(objc_type=Application, objc_name="terminate")
Application_terminate :: proc "c" (self: ^Application, sender: ^Object) {
msgSend(nil, self, "terminate:", sender)
@@ -156,6 +161,12 @@ Application_nextEventMatchingMask :: proc "c" (self: ^Application, mask: EventMa
Application_sendEvent :: proc "c" (self: ^Application, event: ^Event) {
msgSend(nil, self, "sendEvent:", event)
}
@(objc_type=Application, objc_name="postEvent")
Application_postEvent :: proc "c" (self: ^Application, event: ^Event, atStart: BOOL) {
msgSend(nil, self, "postEvent:atStart:", event, atStart)
}
@(objc_type=Application, objc_name="updateWindows")
Application_updateWindows :: proc "c" (self: ^Application) {
msgSend(nil, self, "updateWindows")
@@ -175,6 +186,11 @@ RunningApplication_localizedName :: proc "c" (self: ^RunningApplication) -> ^Str
return msgSend(^String, self, "localizedName")
}
@(objc_type=RunningApplication, objc_name="finishedLaunching")
RunningApplication_finishedLaunching :: proc "c" (self: ^RunningApplication) -> BOOL {
return msgSend(BOOL, self, "isFinishedLaunching")
}
ApplicationDelegateTemplate :: struct {
// Launching Applications
applicationWillFinishLaunching: proc(notification: ^Notification),

View File

@@ -250,6 +250,35 @@ kVK :: enum {
ISO_Section = 0x0A,
}
/* class methods for creating events */
@(objc_type=Event, objc_name="otherEventWithType", objc_is_class_method=true)
Event_otherEventWithType :: proc "c" (
type: EventType,
location: Point,
flags: EventModifierFlags,
time: TimeInterval,
window_number: Integer,
ctx: id,
subtype: i16,
data1: Integer,
data2: Integer,
) -> ^Event {
return msgSend(
^Event,
Event,
"otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:",
type,
location,
flags,
time,
window_number,
ctx,
subtype,
data1,
data2,
)
}
/* these messages are valid for all events */

View File

@@ -56,6 +56,60 @@ BackingStoreType :: enum UInteger {
Buffered = 2,
}
WindowCollectionBehaviorFlag :: enum UInteger {
CanJoinAllSpaces = 0,
MoveToActiveSpace = 1,
Managed = 2,
Transient = 3,
Stationary = 4,
ParticipatesInCycle = 5,
IgnoresCycle = 6,
FullScreenPrimary = 7,
FullScreenAuxiliary = 8,
FullScreenNone = 9,
FullScreenAllowsTiling = 11,
FullScreenDisallowsTiling = 12,
Primary = 16,
Auxiliary = 17,
CanJoinAllApplications = 18,
}
WindowCollectionBehavior :: distinct bit_set[WindowCollectionBehaviorFlag; UInteger]
WindowCollectionBehaviorDefault :: WindowCollectionBehavior{}
WindowCollectionBehaviorPrimary :: WindowCollectionBehavior{.Primary, .FullScreenAuxiliary}
WindowCollectionBehaviorAuxiliary :: WindowCollectionBehavior{.Auxiliary, .FullScreenNone}
WindowCollectionBehaviorCanJoinAllApplications :: WindowCollectionBehavior{.CanJoinAllApplications}
WindowCollectionBehaviorCanJoinAllSpaces :: WindowCollectionBehavior{.CanJoinAllSpaces}
WindowCollectionBehaviorMoveToActiveSpace :: WindowCollectionBehavior{.MoveToActiveSpace}
WindowCollectionBehaviorStationary :: WindowCollectionBehavior{.Stationary}
WindowCollectionBehaviorManaged :: WindowCollectionBehavior{.Managed}
WindowCollectionBehaviorTransient :: WindowCollectionBehavior{.Transient}
WindowCollectionBehaviorFullScreenPrimary :: WindowCollectionBehavior{.FullScreenPrimary}
WindowCollectionBehaviorFullScreenAuxiliary :: WindowCollectionBehavior{.FullScreenAuxiliary}
WindowCollectionBehaviorFullScreenNone :: WindowCollectionBehavior{.FullScreenNone}
WindowCollectionBehaviorFullScreenAllowsTiling :: WindowCollectionBehavior{.FullScreenAllowsTiling}
WindowCollectionBehaviorFullScreenDisallowsTiling :: WindowCollectionBehavior{.FullScreenDisallowsTiling}
WindowCollectionBehaviorParticipatesInCycle :: WindowCollectionBehavior{.ParticipatesInCycle}
WindowCollectionBehaviorIgnoresCycle :: WindowCollectionBehavior{.IgnoresCycle}
WindowLevel :: enum Integer {
Normal = 0,
Floating = 3,
Submenu = 3,
TornOffMenu = 3,
ModalPanel = 8,
MainMenu = 24,
Status = 25,
PopUpMenu = 101,
ScreenSaver = 1000,
}
WindowTabbingMode :: enum Integer {
Automatic = 0,
Preferred = 1,
Disallowed = 2,
}
WindowDelegateTemplate :: struct {
// Managing Sheets
windowWillPositionSheetUsingRect: proc(window: ^Window, sheet: ^Window, rect: Rect) -> Rect,
@@ -600,6 +654,10 @@ Responder :: struct {using _: Object}
@(objc_class="NSView")
View :: struct {using _: Responder}
@(objc_type=View, objc_name="alloc", objc_is_class_method=true)
View_alloc :: proc "c" () -> ^View {
return msgSend(^View, View, "alloc")
}
@(objc_type=View, objc_name="initWithFrame")
View_initWithFrame :: proc "c" (self: ^View, frame: Rect) -> ^View {
@@ -670,6 +728,10 @@ Window_setFrame :: proc "c" (self: ^Window, frame: Rect, display: BOOL) {
Window_setFrameOrigin :: proc "c" (self: ^Window, origin: Point) {
msgSend(nil, self, "setFrameOrigin:", origin)
}
@(objc_type=Window, objc_name="center")
Window_center :: proc "c" (self: ^Window) {
msgSend(nil, self, "center")
}
@(objc_type=Window, objc_name="opaque")
Window_opaque :: proc "c" (self: ^Window) -> BOOL {
return msgSend(BOOL, self, "opaque")
@@ -686,6 +748,14 @@ Window_backgroundColor :: proc "c" (self: ^Window) -> ^Color {
Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^Color) {
msgSend(nil, self, "setBackgroundColor:", color)
}
@(objc_type = Window, objc_name = "orderFront")
Window_orderFront :: proc "c" (self: ^Window, sender: id) {
msgSend(nil, self, "orderFront:", sender)
}
@(objc_type = Window, objc_name = "orderOut")
Window_orderOut :: proc "c" (self: ^Window, sender: id) {
msgSend(nil, self, "orderOut:", sender)
}
@(objc_type=Window, objc_name="makeKeyAndOrderFront")
Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^Object) {
msgSend(nil, self, "makeKeyAndOrderFront:", key)
@@ -722,6 +792,10 @@ Window_close :: proc "c" (self: ^Window) {
Window_setDelegate :: proc "c" (self: ^Window, delegate: ^WindowDelegate) {
msgSend(nil, self, "setDelegate:", delegate)
}
@(objc_type = Window, objc_name = "delegate")
Window_delegate :: proc "c" (self: ^Window) -> ^WindowDelegate {
return msgSend(^WindowDelegate, self, "delegate")
}
@(objc_type=Window, objc_name="backingScaleFactor")
Window_backingScaleFactor :: proc "c" (self: ^Window) -> Float {
return msgSend(Float, self, "backingScaleFactor")
@@ -798,3 +872,35 @@ Window_performWindowDragWithEvent :: proc "c" (self: ^Window, event: ^Event) {
Window_setToolbar :: proc "c" (self: ^Window, toolbar: ^Toolbar) {
msgSend(nil, self, "setToolbar:", toolbar)
}
@(objc_type = Window, objc_name = "setCollectionBehavior")
Window_setCollectionBehavior :: proc "c" (self: ^Window, behavior: WindowCollectionBehavior) {
msgSend(nil, self, "setCollectionBehavior:", behavior)
}
@(objc_type = Window, objc_name = "collectionBehavior")
Window_collectionBehavior :: proc "c" (self: ^Window) -> WindowCollectionBehavior {
return msgSend(WindowCollectionBehavior, self, "collectionBehavior")
}
@(objc_type = Window, objc_name = "setLevel")
Window_setLevel :: proc "c" (self: ^Window, level: WindowLevel) {
msgSend(nil, self, "setLevel:", level)
}
@(objc_type = Window, objc_name = "setReleasedWhenClosed")
Window_setReleasedWhenClosed :: proc "c" (self: ^Window, flag: BOOL) {
msgSend(nil, self, "setReleasedWhenClosed:", flag)
}
@(objc_type = Window, objc_name = "makeFirstResponder")
Window_makeFirstResponder :: proc "c" (self: ^Window, responder: ^Responder) -> BOOL {
return msgSend(BOOL, self, "makeFirstResponder:", responder)
}
@(objc_type = Window, objc_name = "setRestorable")
Window_setRestorable :: proc "c" (self: ^Window, flag: BOOL) {
msgSend(nil, self, "setRestorable:", flag)
}
@(objc_type = Window, objc_name = "setTabbingMode")
Window_setTabbingMode :: proc "c" (self: ^Window, mode: WindowTabbingMode) {
msgSend(nil, self, "setTabbingMode:", mode)
}
@(objc_type = Window, objc_name = "toggleFullScreen")
Window_toggleFullScreen :: proc "c" (self: ^Window, sender: id) {
msgSend(nil, self, "toggleFullScreen:", sender)
}