src/video/cocoa/SDL_cocoawindow.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 11 Nov 2013 20:42:59 -0800
changeset 7961 c629882e0a81
parent 7952 5ac1a895b313
child 7963 f06bbd9cd708
permissions -rw-r--r--
Properly handle toggling fullscreen state when another fullscreen state change is in progress.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 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_config.h"
    22 
    23 #ifndef _SDL_cocoawindow_h
    24 #define _SDL_cocoawindow_h
    25 
    26 #import <Cocoa/Cocoa.h>
    27 
    28 typedef struct SDL_WindowData SDL_WindowData;
    29 
    30 @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
    31     SDL_WindowData *_data;
    32     BOOL observingVisible;
    33     BOOL wasCtrlLeft;
    34     BOOL wasVisible;
    35     BOOL isFullscreen;
    36     BOOL inFullscreenTransition;
    37 
    38     enum
    39     {
    40         PENDING_TRANSITION_NONE,
    41         PENDING_TRANSITION_ENTER_FULLSCREEN,
    42         PENDING_TRANSITION_LEAVE_FULLSCREEN
    43     } pendingFullscreenTransition;
    44 }
    45 
    46 -(void) listen:(SDL_WindowData *) data;
    47 -(void) pauseVisibleObservation;
    48 -(void) resumeVisibleObservation;
    49 -(BOOL) setFullscreenState:(BOOL) state;
    50 -(void) close;
    51 
    52 /* Window delegate functionality */
    53 -(BOOL) windowShouldClose:(id) sender;
    54 -(void) windowDidExpose:(NSNotification *) aNotification;
    55 -(void) windowDidMove:(NSNotification *) aNotification;
    56 -(void) windowDidResize:(NSNotification *) aNotification;
    57 -(void) windowDidMiniaturize:(NSNotification *) aNotification;
    58 -(void) windowDidDeminiaturize:(NSNotification *) aNotification;
    59 -(void) windowDidBecomeKey:(NSNotification *) aNotification;
    60 -(void) windowDidResignKey:(NSNotification *) aNotification;
    61 -(void) windowWillEnterFullScreen:(NSNotification *) aNotification;
    62 -(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
    63 -(void) windowWillExitFullScreen:(NSNotification *) aNotification;
    64 -(void) windowDidExitFullScreen:(NSNotification *) aNotification;
    65 
    66 /* Window event handling */
    67 -(void) mouseDown:(NSEvent *) theEvent;
    68 -(void) rightMouseDown:(NSEvent *) theEvent;
    69 -(void) otherMouseDown:(NSEvent *) theEvent;
    70 -(void) mouseUp:(NSEvent *) theEvent;
    71 -(void) rightMouseUp:(NSEvent *) theEvent;
    72 -(void) otherMouseUp:(NSEvent *) theEvent;
    73 -(void) mouseMoved:(NSEvent *) theEvent;
    74 -(void) mouseDragged:(NSEvent *) theEvent;
    75 -(void) rightMouseDragged:(NSEvent *) theEvent;
    76 -(void) otherMouseDragged:(NSEvent *) theEvent;
    77 -(void) scrollWheel:(NSEvent *) theEvent;
    78 -(void) touchesBeganWithEvent:(NSEvent *) theEvent;
    79 -(void) touchesMovedWithEvent:(NSEvent *) theEvent;
    80 -(void) touchesEndedWithEvent:(NSEvent *) theEvent;
    81 -(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
    82 
    83 /* Touch event handling */
    84 typedef enum {
    85     COCOA_TOUCH_DOWN,
    86     COCOA_TOUCH_UP,
    87     COCOA_TOUCH_MOVE,
    88     COCOA_TOUCH_CANCELLED
    89 } cocoaTouchType;
    90 -(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
    91 
    92 @end
    93 /* *INDENT-ON* */
    94 
    95 @class SDLOpenGLContext;
    96 
    97 struct SDL_WindowData
    98 {
    99     SDL_Window *window;
   100     NSWindow *nswindow;
   101     NSMutableArray *nscontexts;
   102     SDL_bool created;
   103     Cocoa_WindowListener *listener;
   104     struct SDL_VideoData *videodata;
   105 };
   106 
   107 extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
   108 extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
   109                                   const void *data);
   110 extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
   111 extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
   112 extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
   113 extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
   114 extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window);
   115 extern void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window);
   116 extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
   117 extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
   118 extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
   119 extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
   120 extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
   121 extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
   122 extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
   123 extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
   124 extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
   125 extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
   126 extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
   127 extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
   128 extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
   129                                       struct SDL_SysWMinfo *info);
   130 
   131 #endif /* _SDL_cocoawindow_h */
   132 
   133 /* vi: set ts=4 sw=4 expandtab: */