SDL  2.0
SDL_cocoawindow.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 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 #if SDL_VIDEO_OPENGL_EGL
29 #include "../SDL_egl_c.h"
30 #endif
31 
32 typedef struct SDL_WindowData SDL_WindowData;
33 
34 typedef enum
35 {
41 
42 @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
46  BOOL wasVisible;
50  BOOL isMoving;
53 }
54 
55 -(void) listen:(SDL_WindowData *) data;
56 -(void) pauseVisibleObservation;
57 -(void) resumeVisibleObservation;
58 -(BOOL) setFullscreenSpace:(BOOL) state;
59 -(BOOL) isInFullscreenSpace;
60 -(BOOL) isInFullscreenSpaceTransition;
61 -(void) addPendingWindowOperation:(PendingWindowOperation) operation;
62 -(void) close;
63 
64 -(BOOL) isMoving;
65 -(void) setPendingMoveX:(int)x Y:(int)y;
66 -(void) windowDidFinishMoving;
67 
68 /* Window delegate functionality */
69 -(BOOL) windowShouldClose:(id) sender;
70 -(void) windowDidExpose:(NSNotification *) aNotification;
71 -(void) windowDidMove:(NSNotification *) aNotification;
72 -(void) windowDidResize:(NSNotification *) aNotification;
73 -(void) windowDidMiniaturize:(NSNotification *) aNotification;
74 -(void) windowDidDeminiaturize:(NSNotification *) aNotification;
75 -(void) windowDidBecomeKey:(NSNotification *) aNotification;
76 -(void) windowDidResignKey:(NSNotification *) aNotification;
77 -(void) windowDidChangeBackingProperties:(NSNotification *) aNotification;
78 -(void) windowWillEnterFullScreen:(NSNotification *) aNotification;
79 -(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
80 -(void) windowWillExitFullScreen:(NSNotification *) aNotification;
81 -(void) windowDidExitFullScreen:(NSNotification *) aNotification;
82 -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
83 
84 /* See if event is in a drag area, toggle on window dragging. */
85 -(BOOL) processHitTest:(NSEvent *)theEvent;
86 
87 /* Window event handling */
88 -(void) mouseDown:(NSEvent *) theEvent;
89 -(void) rightMouseDown:(NSEvent *) theEvent;
90 -(void) otherMouseDown:(NSEvent *) theEvent;
91 -(void) mouseUp:(NSEvent *) theEvent;
92 -(void) rightMouseUp:(NSEvent *) theEvent;
93 -(void) otherMouseUp:(NSEvent *) theEvent;
94 -(void) mouseMoved:(NSEvent *) theEvent;
95 -(void) mouseDragged:(NSEvent *) theEvent;
96 -(void) rightMouseDragged:(NSEvent *) theEvent;
97 -(void) otherMouseDragged:(NSEvent *) theEvent;
98 -(void) scrollWheel:(NSEvent *) theEvent;
99 -(void) touchesBeganWithEvent:(NSEvent *) theEvent;
100 -(void) touchesMovedWithEvent:(NSEvent *) theEvent;
101 -(void) touchesEndedWithEvent:(NSEvent *) theEvent;
102 -(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
103 
104 /* Touch event handling */
105 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
106 
107 @end
108 /* *INDENT-ON* */
109 
110 @class SDLOpenGLContext;
111 
112 struct SDL_WindowData
113 {
115  NSWindow *nswindow;
116  NSMutableArray *nscontexts;
121 #if SDL_VIDEO_OPENGL_EGL
122  EGLSurface egl_surface;
123 #endif
124 };
125 
128  const void *data);
135 extern int Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity);
152 
153 #endif /* SDL_cocoawindow_h_ */
154 
155 /* vi: set ts=4 sw=4 expandtab: */
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
Cocoa_WindowListener::_data
SDL_WindowData * _data
Definition: SDL_cocoawindow.h:43
Cocoa_WindowListener::pendingWindowWarpX
int pendingWindowWarpX
Definition: SDL_cocoawindow.h:51
SDL_WindowData::nscontexts
NSMutableArray * nscontexts
Definition: SDL_cocoawindow.h:116
PENDING_OPERATION_ENTER_FULLSCREEN
@ PENDING_OPERATION_ENTER_FULLSCREEN
Definition: SDL_cocoawindow.h:37
Cocoa_SetWindowTitle
void Cocoa_SetWindowTitle(_THIS, SDL_Window *window)
SDL_SysWMinfo
Definition: SDL_syswm.h:195
SDL_WindowData
Definition: SDL_androidwindow.h:36
Cocoa_SetWindowIcon
void Cocoa_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
Cocoa_WindowListener::wasVisible
BOOL wasVisible
Definition: SDL_cocoawindow.h:46
Cocoa_WindowListener::inFullscreenTransition
BOOL inFullscreenTransition
Definition: SDL_cocoawindow.h:48
Cocoa_MaximizeWindow
void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
Cocoa_WindowListener
Definition: SDL_cocoawindow.h:42
SDL_WindowData::created
SDL_bool created
Definition: SDL_cocoawindow.h:117
Cocoa_SetWindowPosition
void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
Cocoa_WindowListener::pendingWindowOperation
PendingWindowOperation pendingWindowOperation
Definition: SDL_cocoawindow.h:49
Cocoa_CreateWindow
int Cocoa_CreateWindow(_THIS, SDL_Window *window)
Cocoa_RestoreWindow
void Cocoa_RestoreWindow(_THIS, SDL_Window *window)
Cocoa_SetWindowGammaRamp
int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
Cocoa_MinimizeWindow
void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:74
Cocoa_AcceptDragAndDrop
void Cocoa_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
Cocoa_SetWindowMaximumSize
void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window)
Cocoa_WindowListener::isMoving
BOOL isMoving
Definition: SDL_cocoawindow.h:50
SDL_WindowData::listener
Cocoa_WindowListener * listener
Definition: SDL_cocoawindow.h:119
PENDING_OPERATION_NONE
@ PENDING_OPERATION_NONE
Definition: SDL_cocoawindow.h:36
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
Cocoa_SetWindowSize
void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
Cocoa_RaiseWindow
void Cocoa_RaiseWindow(_THIS, SDL_Window *window)
Cocoa_CreateWindowFrom
int Cocoa_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
Cocoa_WindowListener::isDragAreaRunning
BOOL isDragAreaRunning
Definition: SDL_cocoawindow.h:52
Cocoa_WindowListener::isFullscreenSpace
BOOL isFullscreenSpace
Definition: SDL_cocoawindow.h:47
Cocoa_SetWindowFullscreen
void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
Cocoa_HideWindow
void Cocoa_HideWindow(_THIS, SDL_Window *window)
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
Cocoa_DestroyWindow
void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
PendingWindowOperation
PendingWindowOperation
Definition: SDL_cocoawindow.h:35
SDL_WindowData::window
SDL_Window * window
Definition: SDL_cocoawindow.h:114
Cocoa_SetWindowBordered
void Cocoa_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
Cocoa_SetWindowGrab
void Cocoa_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
SDL_VideoData::display
struct wl_display * display
Definition: SDL_waylandvideo.h:50
Cocoa_SetWindowMinimumSize
void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)
Cocoa_WindowListener::wasCtrlLeft
BOOL wasCtrlLeft
Definition: SDL_cocoawindow.h:45
PENDING_OPERATION_MINIMIZE
@ PENDING_OPERATION_MINIMIZE
Definition: SDL_cocoawindow.h:39
SDL_VideoDisplay
Definition: SDL_sysvideo.h:126
Cocoa_SetWindowOpacity
int Cocoa_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
Cocoa_GetWindowGammaRamp
int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
Cocoa_WindowListener::observingVisible
BOOL observingVisible
Definition: SDL_cocoawindow.h:44
enabled
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: SDL_opengl_glext.h:2479
PENDING_OPERATION_LEAVE_FULLSCREEN
@ PENDING_OPERATION_LEAVE_FULLSCREEN
Definition: SDL_cocoawindow.h:38
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
Cocoa_SetWindowHitTest
int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
SDL_WindowData::videodata
struct SDL_VideoData * videodata
Definition: SDL_cocoawindow.h:120
EGLSurface
void * EGLSurface
Definition: egl.h:59
Cocoa_WindowListener::pendingWindowWarpY
int pendingWindowWarpY
Definition: SDL_cocoawindow.h:51
void
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_WindowData::inWindowMove
SDL_bool inWindowMove
Definition: SDL_cocoawindow.h:118
Cocoa_GetWindowWMInfo
SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Cocoa_ShowWindow
void Cocoa_ShowWindow(_THIS, SDL_Window *window)
SDL_VideoData
Definition: SDL_androidvideo.h:36
Cocoa_SetWindowResizable
void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
SDL_WindowData::nswindow
NSWindow * nswindow
Definition: SDL_cocoawindow.h:115