src/video/cocoa/SDL_cocoawindow.h
author Jørgen P. Tjernø
Tue, 25 Feb 2014 17:27:41 -0800
changeset 8260 028ed8da2524
parent 8149 681eb46b8ac4
child 8291 36f8cf82d308
permissions -rw-r--r--
Mac: Improve moving relative mode windows.

This makes it possible to move windows by their title bar, even if they're in
relative mode, if you click the title bar when the window does not have focus.

Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2396
slouken@1933
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@1933
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1933
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1933
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1933
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@1933
    22
slouken@1933
    23
#ifndef _SDL_cocoawindow_h
slouken@1933
    24
#define _SDL_cocoawindow_h
slouken@1933
    25
slouken@3400
    26
#import <Cocoa/Cocoa.h>
slouken@3400
    27
slouken@1933
    28
typedef struct SDL_WindowData SDL_WindowData;
slouken@1933
    29
slouken@7963
    30
typedef enum
slouken@7963
    31
{
slouken@7963
    32
    PENDING_OPERATION_NONE,
slouken@7963
    33
    PENDING_OPERATION_ENTER_FULLSCREEN,
slouken@7963
    34
    PENDING_OPERATION_LEAVE_FULLSCREEN,
slouken@7963
    35
    PENDING_OPERATION_MINIMIZE
slouken@7963
    36
} PendingWindowOperation;
slouken@7963
    37
slouken@5374
    38
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
slouken@1933
    39
    SDL_WindowData *_data;
jorgen@7090
    40
    BOOL observingVisible;
slouken@7740
    41
    BOOL wasCtrlLeft;
jorgen@7090
    42
    BOOL wasVisible;
slouken@7967
    43
    BOOL isFullscreenSpace;
slouken@7952
    44
    BOOL inFullscreenTransition;
slouken@7963
    45
    PendingWindowOperation pendingWindowOperation;
jorgen@8260
    46
    BOOL isMoving;
jorgen@8260
    47
    int pendingWindowWarpX, pendingWindowWarpY;
slouken@1933
    48
}
slouken@1933
    49
slouken@1933
    50
-(void) listen:(SDL_WindowData *) data;
jorgen@7090
    51
-(void) pauseVisibleObservation;
jorgen@7090
    52
-(void) resumeVisibleObservation;
slouken@7967
    53
-(BOOL) setFullscreenSpace:(BOOL) state;
slouken@7968
    54
-(BOOL) isInFullscreenSpace;
slouken@7968
    55
-(BOOL) isInFullscreenSpaceTransition;
slouken@7963
    56
-(void) addPendingWindowOperation:(PendingWindowOperation) operation;
slouken@1933
    57
-(void) close;
slouken@1933
    58
jorgen@8260
    59
-(BOOL) isMoving;
jorgen@8260
    60
-(void) setPendingMoveX:(int)x Y:(int)y;
jorgen@8260
    61
-(void) windowDidFinishMoving;
jorgen@8260
    62
slouken@1933
    63
/* Window delegate functionality */
slouken@1933
    64
-(BOOL) windowShouldClose:(id) sender;
slouken@1933
    65
-(void) windowDidExpose:(NSNotification *) aNotification;
slouken@1933
    66
-(void) windowDidMove:(NSNotification *) aNotification;
slouken@1933
    67
-(void) windowDidResize:(NSNotification *) aNotification;
slouken@1933
    68
-(void) windowDidMiniaturize:(NSNotification *) aNotification;
slouken@1933
    69
-(void) windowDidDeminiaturize:(NSNotification *) aNotification;
slouken@1933
    70
-(void) windowDidBecomeKey:(NSNotification *) aNotification;
slouken@1933
    71
-(void) windowDidResignKey:(NSNotification *) aNotification;
slouken@7952
    72
-(void) windowWillEnterFullScreen:(NSNotification *) aNotification;
slouken@7952
    73
-(void) windowDidEnterFullScreen:(NSNotification *) aNotification;
slouken@7952
    74
-(void) windowWillExitFullScreen:(NSNotification *) aNotification;
slouken@7952
    75
-(void) windowDidExitFullScreen:(NSNotification *) aNotification;
slouken@1933
    76
slouken@1933
    77
/* Window event handling */
slouken@1933
    78
-(void) mouseDown:(NSEvent *) theEvent;
slouken@1933
    79
-(void) rightMouseDown:(NSEvent *) theEvent;
slouken@1933
    80
-(void) otherMouseDown:(NSEvent *) theEvent;
slouken@1933
    81
-(void) mouseUp:(NSEvent *) theEvent;
slouken@1933
    82
-(void) rightMouseUp:(NSEvent *) theEvent;
slouken@1933
    83
-(void) otherMouseUp:(NSEvent *) theEvent;
slouken@1933
    84
-(void) mouseMoved:(NSEvent *) theEvent;
slouken@1957
    85
-(void) mouseDragged:(NSEvent *) theEvent;
slouken@1958
    86
-(void) rightMouseDragged:(NSEvent *) theEvent;
slouken@1958
    87
-(void) otherMouseDragged:(NSEvent *) theEvent;
slouken@1933
    88
-(void) scrollWheel:(NSEvent *) theEvent;
slouken@4673
    89
-(void) touchesBeganWithEvent:(NSEvent *) theEvent;
slouken@4673
    90
-(void) touchesMovedWithEvent:(NSEvent *) theEvent;
slouken@4673
    91
-(void) touchesEndedWithEvent:(NSEvent *) theEvent;
slouken@4673
    92
-(void) touchesCancelledWithEvent:(NSEvent *) theEvent;
slouken@4673
    93
slouken@4673
    94
/* Touch event handling */
slouken@4673
    95
typedef enum {
slouken@4673
    96
    COCOA_TOUCH_DOWN,
slouken@4673
    97
    COCOA_TOUCH_UP,
slouken@4673
    98
    COCOA_TOUCH_MOVE,
slouken@4673
    99
    COCOA_TOUCH_CANCELLED
slouken@4673
   100
} cocoaTouchType;
slouken@4673
   101
-(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
slouken@4673
   102
slouken@1936
   103
@end
slouken@1936
   104
/* *INDENT-ON* */
slouken@1936
   105
jorgen@7594
   106
@class SDLOpenGLContext;
jorgen@7594
   107
slouken@1936
   108
struct SDL_WindowData
slouken@1933
   109
{
slouken@3685
   110
    SDL_Window *window;
slouken@3685
   111
    NSWindow *nswindow;
jorgen@7595
   112
    NSMutableArray *nscontexts;
slouken@1951
   113
    SDL_bool created;
jorgen@8260
   114
    SDL_bool inWindowMove;
slouken@1933
   115
    Cocoa_WindowListener *listener;
slouken@1933
   116
    struct SDL_VideoData *videodata;
slouken@1933
   117
};
slouken@1933
   118
slouken@1933
   119
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
slouken@1933
   120
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
slouken@1933
   121
                                  const void *data);
slouken@1933
   122
extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window);
slouken@5375
   123
extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
slouken@1933
   124
extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window);
slouken@1933
   125
extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window);
stopiccot@6681
   126
extern void Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window);
slouken@6788
   127
extern void Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window);
slouken@1933
   128
extern void Cocoa_ShowWindow(_THIS, SDL_Window * window);
slouken@1933
   129
extern void Cocoa_HideWindow(_THIS, SDL_Window * window);
slouken@1933
   130
extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window);
slouken@1933
   131
extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
slouken@1933
   132
extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
slouken@1933
   133
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
icculus@6422
   134
extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
slouken@5305
   135
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
slouken@5466
   136
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
slouken@5466
   137
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
slouken@6662
   138
extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
slouken@1933
   139
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
slouken@1933
   140
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
slouken@1933
   141
                                      struct SDL_SysWMinfo *info);
slouken@1933
   142
slouken@1933
   143
#endif /* _SDL_cocoawindow_h */
slouken@1933
   144
slouken@1933
   145
/* vi: set ts=4 sw=4 expandtab: */