src/video/cocoa/SDL_cocoawindow.h
author Sam Lantinga <slouken@libsdl.org>
Fri, 11 Feb 2011 00:25:44 -0800
changeset 5249 7a963be087ef
parent 5246 58265e606e4e
child 5262 b530ef003506
permissions -rw-r--r--
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.

There are still some problems with the ConvertNSRect() calculations when switching video modes, which causes wierd window positioning issues, and the fullscreen window is still minimized on exit.
slouken@1933
     1
/*
slouken@1933
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@1933
     4
slouken@1933
     5
    This library is free software; you can redistribute it and/or
slouken@1933
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1933
     7
    License as published by the Free Software Foundation; either
slouken@1933
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1933
     9
slouken@1933
    10
    This library is distributed in the hope that it will be useful,
slouken@1933
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1933
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1933
    13
    Lesser General Public License for more details.
slouken@1933
    14
slouken@1933
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1933
    16
    License along with this library; if not, write to the Free Software
slouken@1933
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1933
    18
slouken@1933
    19
    Sam Lantinga
slouken@1933
    20
    slouken@libsdl.org
slouken@1933
    21
*/
slouken@1933
    22
#include "SDL_config.h"
slouken@1933
    23
slouken@1933
    24
#ifndef _SDL_cocoawindow_h
slouken@1933
    25
#define _SDL_cocoawindow_h
slouken@1933
    26
slouken@3400
    27
#import <Cocoa/Cocoa.h>
slouken@3400
    28
slouken@1933
    29
typedef struct SDL_WindowData SDL_WindowData;
slouken@1933
    30
slouken@1936
    31
/* *INDENT-OFF* */
slouken@4925
    32
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
slouken@3400
    33
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
slouken@3400
    34
#else
slouken@3400
    35
@interface Cocoa_WindowListener : NSResponder {
slouken@3400
    36
#endif		
slouken@1933
    37
    SDL_WindowData *_data;
slouken@1933
    38
}
slouken@1933
    39
slouken@1933
    40
-(void) listen:(SDL_WindowData *) data;
slouken@1933
    41
-(void) close;
slouken@1933
    42
slouken@1933
    43
/* Window delegate functionality */
slouken@1933
    44
-(BOOL) windowShouldClose:(id) sender;
slouken@1933
    45
-(void) windowDidExpose:(NSNotification *) aNotification;
slouken@1933
    46
-(void) windowDidMove:(NSNotification *) aNotification;
slouken@1933
    47
-(void) windowDidResize:(NSNotification *) aNotification;
slouken@1933
    48
-(void) windowDidMiniaturize:(NSNotification *) aNotification;
slouken@1933
    49
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
slouken@1933
    50
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
slouken@1933
    51
-(void) windowDidResignKey:(NSNotification *) aNotification;
slouken@1933
    52
-(void) windowDidHide:(NSNotification *) aNotification;
slouken@1933
    53
-(void) windowDidUnhide:(NSNotification *) aNotification;
slouken@1933
    54
slouken@1933
    55
/* Window event handling */
slouken@1933
    56
-(void) mouseDown:(NSEvent *) theEvent;
slouken@1933
    57
-(void) rightMouseDown:(NSEvent *) theEvent;
slouken@1933
    58
-(void) otherMouseDown:(NSEvent *) theEvent;
slouken@1933
    59
-(void) mouseUp:(NSEvent *) theEvent;
slouken@1933
    60
-(void) rightMouseUp:(NSEvent *) theEvent;
slouken@1933
    61
-(void) otherMouseUp:(NSEvent *) theEvent;
slouken@1933
    62
-(void) mouseMoved:(NSEvent *) theEvent;
slouken@1957
    63
-(void) mouseDragged:(NSEvent *) theEvent;
slouken@1958
    64
-(void) rightMouseDragged:(NSEvent *) theEvent;
slouken@1958
    65
-(void) otherMouseDragged:(NSEvent *) theEvent;
slouken@1933
    66
-(void) scrollWheel:(NSEvent *) theEvent;
slouken@4673
    67
-(void) touchesBeganWithEvent:(NSEvent *) theEvent;
slouken@4673
    68
-(void) touchesMovedWithEvent:(NSEvent *) theEvent;
slouken@4673
    69
-(void) touchesEndedWithEvent:(NSEvent *) theEvent;
slouken@4673
    70
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
slouken@4673
    71
slouken@4673
    72
/* Touch event handling */
slouken@4673
    73
typedef enum {
slouken@4673
    74
    COCOA_TOUCH_DOWN,
slouken@4673
    75
    COCOA_TOUCH_UP,
slouken@4673
    76
    COCOA_TOUCH_MOVE,
slouken@4673
    77
    COCOA_TOUCH_CANCELLED
slouken@4673
    78
} cocoaTouchType;
slouken@4673
    79
-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
slouken@4673
    80
slouken@1936
    81
@end
slouken@1936
    82
/* *INDENT-ON* */
slouken@1936
    83
slouken@1936
    84
struct SDL_WindowData
slouken@1933
    85
{
slouken@3685
    86
    SDL_Window *window;
slouken@3685
    87
    NSWindow *nswindow;
slouken@1951
    88
    SDL_bool created;
slouken@1933
    89
    Cocoa_WindowListener *listener;
slouken@1933
    90
    struct SDL_VideoData *videodata;
slouken@1933
    91
};
slouken@1933
    92
slouken@1933
    93
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
slouken@1933
    94
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
slouken@1933
    95
                                  const void *data);
slouken@1933
    96
extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
slouken@1933
    97
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
slouken@1933
    98
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
slouken@1933
    99
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
slouken@1933
   100
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
slouken@1933
   101
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
slouken@1933
   102
extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
slouken@1933
   103
extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
slouken@1933
   104
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
slouken@5249
   105
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window);
slouken@1933
   106
extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window);
slouken@1933
   107
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
slouken@1933
   108
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
slouken@1933
   109
                                      struct SDL_SysWMinfo *info);
slouken@1933
   110
slouken@1933
   111
#endif /* _SDL_cocoawindow_h */
slouken@1933
   112
slouken@1933
   113
/* vi: set ts=4 sw=4 expandtab: */