Atlas - SDL_cocoawindow.h

Home / ext / SDL / src / video / cocoa Lines: 1 | Size: 9231 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#include "SDL_internal.h" 22 23#ifndef SDL_cocoawindow_h_ 24#define SDL_cocoawindow_h_ 25 26#import <Cocoa/Cocoa.h> 27 28#ifdef SDL_VIDEO_OPENGL_EGL 29#include "../SDL_egl_c.h" 30#endif 31 32#define SDL_METALVIEW_TAG 255 33 34@class SDL_CocoaWindowData; 35 36typedef enum 37{ 38 PENDING_OPERATION_NONE = 0x00, 39 PENDING_OPERATION_ENTER_FULLSCREEN = 0x01, 40 PENDING_OPERATION_LEAVE_FULLSCREEN = 0x02, 41 PENDING_OPERATION_MINIMIZE = 0x04, 42 PENDING_OPERATION_ZOOM = 0x08 43} PendingWindowOperation; 44 45@interface SDL3Cocoa_WindowListener : NSResponder <NSWindowDelegate> 46{ 47 /* SDL_CocoaWindowData owns this Listener and has a strong reference to it. 48 * To avoid reference cycles, we could have either a weak or an 49 * unretained ref to the WindowData. */ 50 __weak SDL_CocoaWindowData *_data; 51 BOOL observingVisible; 52 BOOL wasCtrlLeft; 53 BOOL wasVisible; 54 BOOL isFullscreenSpace; 55 BOOL inFullscreenTransition; 56 PendingWindowOperation pendingWindowOperation; 57 BOOL isMoving; 58 BOOL isMiniaturizing; 59 NSInteger focusClickPending; 60 float pendingWindowWarpX, pendingWindowWarpY; 61 BOOL isDragAreaRunning; 62 NSTimer *liveResizeTimer; 63} 64 65- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent; 66- (void)listen:(SDL_CocoaWindowData *)data; 67- (void)pauseVisibleObservation; 68- (void)resumeVisibleObservation; 69- (BOOL)setFullscreenSpace:(BOOL)state; 70- (BOOL)isInFullscreenSpace; 71- (BOOL)isInFullscreenSpaceTransition; 72- (void)addPendingWindowOperation:(PendingWindowOperation)operation; 73- (void)close; 74 75- (BOOL)isMoving; 76- (BOOL)isMovingOrFocusClickPending; 77- (void)setFocusClickPending:(NSInteger)button; 78- (void)clearFocusClickPending:(NSInteger)button; 79- (void)updateIgnoreMouseState:(NSEvent *)theEvent; 80- (void)setPendingMoveX:(float)x Y:(float)y; 81- (void)windowDidFinishMoving; 82- (void)onMovingOrFocusClickPendingStateCleared; 83 84// Window delegate functionality 85- (BOOL)windowShouldClose:(id)sender; 86- (void)windowDidExpose:(NSNotification *)aNotification; 87- (void)windowDidChangeOcclusionState:(NSNotification *)aNotification; 88- (void)windowWillStartLiveResize:(NSNotification *)aNotification; 89- (void)windowDidEndLiveResize:(NSNotification *)aNotification; 90- (void)windowDidMove:(NSNotification *)aNotification; 91- (void)windowDidResize:(NSNotification *)aNotification; 92- (void)windowDidMiniaturize:(NSNotification *)aNotification; 93- (void)windowDidDeminiaturize:(NSNotification *)aNotification; 94- (void)windowDidBecomeKey:(NSNotification *)aNotification; 95- (void)windowDidResignKey:(NSNotification *)aNotification; 96- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification; 97- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification; 98- (void)windowDidChangeScreen:(NSNotification *)aNotification; 99- (void)windowWillEnterFullScreen:(NSNotification *)aNotification; 100- (void)windowDidEnterFullScreen:(NSNotification *)aNotification; 101- (void)windowWillExitFullScreen:(NSNotification *)aNotification; 102- (void)windowDidExitFullScreen:(NSNotification *)aNotification; 103- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; 104 105// See if event is in a drag area, toggle on window dragging. 106- (void)updateHitTest; 107- (BOOL)processHitTest:(NSEvent *)theEvent; 108 109// Window event handling 110- (void)mouseDown:(NSEvent *)theEvent; 111- (void)rightMouseDown:(NSEvent *)theEvent; 112- (void)otherMouseDown:(NSEvent *)theEvent; 113- (void)mouseUp:(NSEvent *)theEvent; 114- (void)rightMouseUp:(NSEvent *)theEvent; 115- (void)otherMouseUp:(NSEvent *)theEvent; 116- (void)mouseMoved:(NSEvent *)theEvent; 117- (void)mouseDragged:(NSEvent *)theEvent; 118- (void)rightMouseDragged:(NSEvent *)theEvent; 119- (void)otherMouseDragged:(NSEvent *)theEvent; 120- (void)scrollWheel:(NSEvent *)theEvent; 121- (void)touchesBeganWithEvent:(NSEvent *)theEvent; 122- (void)touchesMovedWithEvent:(NSEvent *)theEvent; 123- (void)touchesEndedWithEvent:(NSEvent *)theEvent; 124- (void)touchesCancelledWithEvent:(NSEvent *)theEvent; 125- (void)magnifyWithEvent:(NSEvent *) theEvent; 126 127// Touch event handling 128- (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent; 129 130// Tablet event handling (but these also come through on mouse events sometimes!) 131- (void)tabletProximity:(NSEvent *)theEvent; 132- (void)tabletPoint:(NSEvent *)theEvent; 133 134@end 135/* *INDENT-ON* */ 136 137@class SDL3OpenGLContext; 138@class SDL_CocoaVideoData; 139 140@interface SDL_CocoaWindowData : NSObject 141@property(nonatomic) SDL_Window *window; 142@property(nonatomic) NSWindow *nswindow; 143@property(nonatomic) NSView *sdlContentView; 144@property(nonatomic) NSRect viewport; 145@property(nonatomic) NSMutableArray *nscontexts; 146@property(nonatomic) BOOL in_blocking_transition; 147@property(nonatomic) BOOL fullscreen_space_requested; 148@property(nonatomic) BOOL was_zoomed; 149@property(nonatomic) NSInteger window_number; 150@property(nonatomic) NSInteger flash_request; 151@property(nonatomic) SDL3Cocoa_WindowListener *listener; 152@property(nonatomic) NSModalSession modal_session; 153@property(nonatomic) SDL_CocoaVideoData *videodata; 154@property(nonatomic) bool pending_size; 155@property(nonatomic) bool pending_position; 156@property(nonatomic) bool border_toggled; 157@property(nonatomic) bool has_modal_dialog; 158 159#ifdef SDL_VIDEO_OPENGL_EGL 160@property(nonatomic) EGLSurface egl_surface; 161#endif 162@end 163 164extern bool b_inModeTransition; 165 166extern bool Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); 167extern void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); 168extern bool Cocoa_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); 169extern bool Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); 170extern void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); 171extern void Cocoa_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); 172extern void Cocoa_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); 173extern void Cocoa_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window); 174extern void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); 175extern bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); 176extern void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); 177extern void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); 178extern void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); 179extern void Cocoa_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); 180extern void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); 181extern void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); 182extern void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); 183extern void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); 184extern void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); 185extern SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); 186extern void *Cocoa_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); 187extern SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window); 188extern bool Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); 189extern bool Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); 190extern void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); 191extern bool Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled); 192extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept); 193extern bool Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); 194extern bool Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); 195extern bool Cocoa_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); 196extern bool Cocoa_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); 197extern bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); 198 199extern void Cocoa_MenuVisibilityCallback(void *userdata, const char *name, const char *oldValue, const char *newValue); 200 201#endif // SDL_cocoawindow_h_ 202
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.