diff options
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h')
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h new file mode 100644 index 0000000..6df69f4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h | |||
| @@ -0,0 +1,199 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 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 | |||
| 36 | typedef 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 | |||
| 126 | // Touch event handling | ||
| 127 | - (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent; | ||
| 128 | |||
| 129 | // Tablet event handling (but these also come through on mouse events sometimes!) | ||
| 130 | - (void)tabletProximity:(NSEvent *)theEvent; | ||
| 131 | - (void)tabletPoint:(NSEvent *)theEvent; | ||
| 132 | |||
| 133 | @end | ||
| 134 | /* *INDENT-ON* */ | ||
| 135 | |||
| 136 | @class SDL3OpenGLContext; | ||
| 137 | @class SDL_CocoaVideoData; | ||
| 138 | |||
| 139 | @interface SDL_CocoaWindowData : NSObject | ||
| 140 | @property(nonatomic) SDL_Window *window; | ||
| 141 | @property(nonatomic) NSWindow *nswindow; | ||
| 142 | @property(nonatomic) NSView *sdlContentView; | ||
| 143 | @property(nonatomic) NSMutableArray *nscontexts; | ||
| 144 | @property(nonatomic) BOOL in_blocking_transition; | ||
| 145 | @property(nonatomic) BOOL fullscreen_space_requested; | ||
| 146 | @property(nonatomic) BOOL was_zoomed; | ||
| 147 | @property(nonatomic) NSInteger window_number; | ||
| 148 | @property(nonatomic) NSInteger flash_request; | ||
| 149 | @property(nonatomic) SDL_Window *keyboard_focus; | ||
| 150 | @property(nonatomic) SDL3Cocoa_WindowListener *listener; | ||
| 151 | @property(nonatomic) NSModalSession modal_session; | ||
| 152 | @property(nonatomic) SDL_CocoaVideoData *videodata; | ||
| 153 | @property(nonatomic) bool pending_size; | ||
| 154 | @property(nonatomic) bool pending_position; | ||
| 155 | @property(nonatomic) bool border_toggled; | ||
| 156 | |||
| 157 | #ifdef SDL_VIDEO_OPENGL_EGL | ||
| 158 | @property(nonatomic) EGLSurface egl_surface; | ||
| 159 | #endif | ||
| 160 | @end | ||
| 161 | |||
| 162 | extern bool b_inModeTransition; | ||
| 163 | |||
| 164 | extern bool Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); | ||
| 165 | extern void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 166 | extern bool Cocoa_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); | ||
| 167 | extern bool Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 168 | extern void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 169 | extern void Cocoa_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 170 | extern void Cocoa_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 171 | extern void Cocoa_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 172 | extern void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); | ||
| 173 | extern bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); | ||
| 174 | extern void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 175 | extern void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 176 | extern void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 177 | extern void Cocoa_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 178 | extern void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 179 | extern void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 180 | extern void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); | ||
| 181 | extern void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); | ||
| 182 | extern void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); | ||
| 183 | extern SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); | ||
| 184 | extern void *Cocoa_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); | ||
| 185 | extern SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 186 | extern bool Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 187 | extern bool Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); | ||
| 188 | extern void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 189 | extern bool Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled); | ||
| 190 | extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept); | ||
| 191 | extern bool Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); | ||
| 192 | extern bool Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); | ||
| 193 | extern bool Cocoa_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); | ||
| 194 | extern bool Cocoa_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); | ||
| 195 | extern bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); | ||
| 196 | |||
| 197 | extern void Cocoa_MenuVisibilityCallback(void *userdata, const char *name, const char *oldValue, const char *newValue); | ||
| 198 | |||
| 199 | #endif // SDL_cocoawindow_h_ | ||
