SDL_cocoawindow.h
Go to the documentation of this file.
/*
Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef SDL_cocoawindow_h_
#define SDL_cocoawindow_h_
#import <Cocoa/Cocoa.h>
#if SDL_VIDEO_OPENGL_EGL
#include "../SDL_egl_c.h"
#endif
typedef struct SDL_WindowData SDL_WindowData;
typedef enum
{
PENDING_OPERATION_NONE,
PENDING_OPERATION_ENTER_FULLSCREEN,
PENDING_OPERATION_LEAVE_FULLSCREEN,
PENDING_OPERATION_MINIMIZE
} PendingWindowOperation;
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
SDL_WindowData *_data;
BOOL observingVisible;
BOOL wasCtrlLeft;
BOOL wasVisible;
BOOL isFullscreenSpace;
BOOL inFullscreenTransition;
PendingWindowOperation pendingWindowOperation;
BOOL isMoving;
int pendingWindowWarpX, pendingWindowWarpY;
BOOL isDragAreaRunning;
}
-(void) listen:(SDL_WindowData *) data;
-(void) pauseVisibleObservation;
-(void) resumeVisibleObservation;
-(BOOL) setFullscreenSpace:(BOOL) state;
-(BOOL) isInFullscreenSpace;
-(BOOL) isInFullscreenSpaceTransition;
-(void) addPendingWindowOperation:(PendingWindowOperation) operation;
-(void) close;
-(BOOL) isMoving;
-(void) setPendingMoveX:(int)x Y:(int)y;
-(void) windowDidFinishMoving;
/* Window delegate functionality */
-(BOOL) windowShouldClose:(id) sender;
-(void) windowDidExpose:(NSNotification *) aNotification;
-(void) windowDidMove:(NSNotification *) aNotification;
-(void) windowDidResize:(NSNotification *) aNotification;
-(void) windowDidMiniaturize:(NSNotification *) aNotification;
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
-(void) windowDidResignKey:(NSNotification *) aNotification;
-(void) windowDidChangeBackingProperties:(NSNotification *) aNotification;
-(void) windowWillEnterFullScreen:(NSNotification *) aNotification;
-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
/* See if event is in a drag area, toggle on window dragging. */
-(BOOL) processHitTest:(NSEvent *)theEvent;
/* Window event handling */
-(void) mouseDown:(NSEvent *) theEvent;
-(void) rightMouseDown:(NSEvent *) theEvent;
-(void) otherMouseDown:(NSEvent *) theEvent;
-(void) mouseUp:(NSEvent *) theEvent;
-(void) rightMouseUp:(NSEvent *) theEvent;
-(void) otherMouseUp:(NSEvent *) theEvent;
-(void) mouseMoved:(NSEvent *) theEvent;
-(void) mouseDragged:(NSEvent *) theEvent;
-(void) rightMouseDragged:(NSEvent *) theEvent;
-(void) otherMouseDragged:(NSEvent *) theEvent;
-(void) scrollWheel:(NSEvent *) theEvent;
-(void) touchesBeganWithEvent:(NSEvent *) theEvent;
-(void) touchesMovedWithEvent:(NSEvent *) theEvent;
-(void) touchesEndedWithEvent:(NSEvent *) theEvent;
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
/* Touch event handling */
-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
@end
/* *INDENT-ON* */
@class SDLOpenGLContext;
struct SDL_WindowData
{
SDL_Window *window;
NSWindow *nswindow;
NSMutableArray *nscontexts;
SDL_bool created;
SDL_bool inWindowMove;
Cocoa_WindowListener *listener;
struct SDL_VideoData *videodata;
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
#endif
};
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
const void *data);
extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window);
extern int Cocoa_SetWindowOpacity(_THIS, SDL_Window * window, float opacity);
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info);
extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
#endif /* SDL_cocoawindow_h_ */
/* vi: set ts=4 sw=4 expandtab: */
Cocoa_CreateWindowFrom
int Cocoa_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
-[Cocoa_WindowListener isInFullscreenSpace]
BOOL isInFullscreenSpace()
PENDING_OPERATION_ENTER_FULLSCREEN
Definition: SDL_cocoawindow.h:37
SDL_WindowData::nscontexts
NSMutableArray * nscontexts
Definition: SDL_cocoawindow.h:116
EGLSurface
void * EGLSurface
Definition: egl.h:59
Cocoa_MinimizeWindow
void Cocoa_MinimizeWindow(_THIS, SDL_Window *window)
Cocoa_SetWindowIcon
void Cocoa_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
Cocoa_SetWindowMaximumSize
void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window *window)
Cocoa_SetWindowResizable
void Cocoa_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
SDL_VideoData::display
struct wl_display * display
Definition: SDL_waylandvideo.h:40
Cocoa_WindowListener::isDragAreaRunning
BOOL isDragAreaRunning
Definition: SDL_cocoawindow.h:52
Cocoa_SetWindowBordered
void Cocoa_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
Cocoa_WindowListener::observingVisible
BOOL observingVisible
Definition: SDL_cocoawindow.h:44
Cocoa_WindowListener
Definition: SDL_cocoawindow.h:42
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:69
-[Cocoa_WindowListener isMoving]
BOOL isMoving()
Cocoa_WindowListener::wasCtrlLeft
BOOL wasCtrlLeft
Definition: SDL_cocoawindow.h:45
Cocoa_SetWindowTitle
void Cocoa_SetWindowTitle(_THIS, SDL_Window *window)
PENDING_OPERATION_NONE
Definition: SDL_cocoawindow.h:36
SDL_WindowData::window
SDL_Window * window
Definition: SDL_cocoawindow.h:114
Cocoa_SetWindowPosition
void Cocoa_SetWindowPosition(_THIS, SDL_Window *window)
-[Cocoa_WindowListener windowDidFinishMoving]
void windowDidFinishMoving()
PENDING_OPERATION_LEAVE_FULLSCREEN
Definition: SDL_cocoawindow.h:38
SDL_WindowData
Definition: SDL_androidwindow.h:35
Cocoa_RestoreWindow
void Cocoa_RestoreWindow(_THIS, SDL_Window *window)
-[Cocoa_WindowListener isInFullscreenSpaceTransition]
BOOL isInFullscreenSpaceTransition()
Cocoa_ShowWindow
void Cocoa_ShowWindow(_THIS, SDL_Window *window)
PENDING_OPERATION_MINIMIZE
Definition: SDL_cocoawindow.h:39
SDL_SysWMinfo
Definition: SDL_syswm.h:194
Cocoa_WindowListener::pendingWindowWarpY
int pendingWindowWarpY
Definition: SDL_cocoawindow.h:51
SDL_WindowData::listener
Cocoa_WindowListener * listener
Definition: SDL_cocoawindow.h:119
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_WindowData::videodata
struct SDL_VideoData * videodata
Definition: SDL_cocoawindow.h:120
-[Cocoa_WindowListener resumeVisibleObservation]
void resumeVisibleObservation()
Cocoa_SetWindowGammaRamp
int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
Cocoa_DestroyWindow
void Cocoa_DestroyWindow(_THIS, SDL_Window *window)
Cocoa_RaiseWindow
void Cocoa_RaiseWindow(_THIS, SDL_Window *window)
Cocoa_GetWindowWMInfo
SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
Cocoa_WindowListener::_data
SDL_WindowData * _data
Definition: SDL_cocoawindow.h:43
PendingWindowOperation
PendingWindowOperation
Definition: SDL_cocoawindow.h:34
Cocoa_SetWindowOpacity
int Cocoa_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
Cocoa_SetWindowFullscreen
void Cocoa_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
Cocoa_WindowListener::pendingWindowWarpX
int pendingWindowWarpX
Definition: SDL_cocoawindow.h:51
SDL_WindowData::nswindow
NSWindow * nswindow
Definition: SDL_cocoawindow.h:115
enabled
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: SDL_opengl_glext.h:2479
SDL_VideoDisplay
Definition: SDL_sysvideo.h:125
Cocoa_WindowListener::pendingWindowOperation
PendingWindowOperation pendingWindowOperation
Definition: SDL_cocoawindow.h:49
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:139
Cocoa_CreateWindow
int Cocoa_CreateWindow(_THIS, SDL_Window *window)
Cocoa_GetWindowGammaRamp
int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
Cocoa_WindowListener::wasVisible
BOOL wasVisible
Definition: SDL_cocoawindow.h:46
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
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_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:73
Cocoa_SetWindowSize
void Cocoa_SetWindowSize(_THIS, SDL_Window *window)
SDL_VideoData
Definition: SDL_androidvideo.h:35
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:169
SDL_WindowData::created
SDL_bool created
Definition: SDL_cocoawindow.h:117
Cocoa_WindowListener::inFullscreenTransition
BOOL inFullscreenTransition
Definition: SDL_cocoawindow.h:48
SDL_WindowData::inWindowMove
SDL_bool inWindowMove
Definition: SDL_cocoawindow.h:118
Cocoa_WindowListener::isMoving
BOOL isMoving
Definition: SDL_cocoawindow.h:50
-[Cocoa_WindowListener pauseVisibleObservation]
void pauseVisibleObservation()
Cocoa_HideWindow
void Cocoa_HideWindow(_THIS, SDL_Window *window)
Cocoa_SetWindowGrab
void Cocoa_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
-[Cocoa_WindowListener close]
void close()
Cocoa_WindowListener::isFullscreenSpace
BOOL isFullscreenSpace
Definition: SDL_cocoawindow.h:47
Cocoa_MaximizeWindow
void Cocoa_MaximizeWindow(_THIS, SDL_Window *window)
Cocoa_SetWindowHitTest
int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
Cocoa_SetWindowMinimumSize
void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window *window)