1.1 --- a/src/video/quartz/SDL_QuartzVideo.h Wed Dec 31 04:48:38 2003 +0000
1.2 +++ b/src/video/quartz/SDL_QuartzVideo.h Sun Jan 04 14:55:35 2004 +0000
1.3 @@ -1,6 +1,6 @@
1.4 /*
1.5 SDL - Simple DirectMedia Layer
1.6 - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
1.7 + Copyright (C) 1997-2003 Sam Lantinga
1.8
1.9 This library is free software; you can redistribute it and/or
1.10 modify it under the terms of the GNU Library General Public
1.11 @@ -54,7 +54,7 @@
1.12 #include <OpenGL/glext.h>
1.13 #include <Carbon/Carbon.h>
1.14 #include <QuickTime/QuickTime.h>
1.15 -#include <IOKit/IOKitLib.h> /* For powersave handling */
1.16 +#include <IOKit/IOKitLib.h> /* For powersave handling */
1.17 #include <pthread.h>
1.18
1.19 #include "SDL_thread.h"
1.20 @@ -66,53 +66,6 @@
1.21 #include "SDL_pixels_c.h"
1.22 #include "SDL_events_c.h"
1.23
1.24 -/*
1.25 - Add methods to get at private members of NSScreen.
1.26 - Since there is a bug in Apple's screen switching code
1.27 - that does not update this variable when switching
1.28 - to fullscreen, we'll set it manually (but only for the
1.29 - main screen).
1.30 -*/
1.31 -@interface NSScreen (NSScreenAccess)
1.32 -- (void) setFrame:(NSRect)frame;
1.33 -@end
1.34 -
1.35 -@implementation NSScreen (NSScreenAccess)
1.36 -- (void) setFrame:(NSRect)frame;
1.37 -{
1.38 - _frame = frame;
1.39 -}
1.40 -@end
1.41 -
1.42 -/*
1.43 - This is a workaround to directly access NSOpenGLContext's CGL context
1.44 - We need this to check for errors NSOpenGLContext doesn't support
1.45 -*/
1.46 -@interface NSOpenGLContext (CGLContextAccess)
1.47 -- (CGLContextObj) cglContext;
1.48 -@end
1.49 -
1.50 -@implementation NSOpenGLContext (CGLContextAccess)
1.51 -- (CGLContextObj) cglContext;
1.52 -{
1.53 - return _contextAuxiliary;
1.54 -}
1.55 -@end
1.56 -
1.57 -/*
1.58 - Structure for rez switch gamma fades
1.59 - We can hide the monitor flicker by setting the gamma tables to 0
1.60 -*/
1.61 -#define QZ_GAMMA_TABLE_SIZE 256
1.62 -
1.63 -typedef struct {
1.64 -
1.65 - CGGammaValue red[QZ_GAMMA_TABLE_SIZE];
1.66 - CGGammaValue green[QZ_GAMMA_TABLE_SIZE];
1.67 - CGGammaValue blue[QZ_GAMMA_TABLE_SIZE];
1.68 -
1.69 -} SDL_QuartzGammaTable;
1.70 -
1.71 /* Main driver structure to store required state information */
1.72 typedef struct SDL_PrivateVideoData {
1.73
1.74 @@ -131,7 +84,6 @@
1.75 NSQuickDrawView *view; /* the window's view; draw 2D and OpenGL into this view */
1.76 SDL_Surface *resize_icon; /* icon for the resize badge, we have to draw it by hand */
1.77 SDL_GrabMode current_grab_mode; /* default value is SDL_GRAB_OFF */
1.78 - BOOL in_foreground; /* boolean; indicate if app is in foreground or not */
1.79 SDL_Rect **client_mode_list; /* resolution list to pass back to client */
1.80 SDLKey keymap[256]; /* Mac OS X to SDL key mapping */
1.81 Uint32 current_mods; /* current keyboard modifiers, to track modifier state */
1.82 @@ -140,8 +92,8 @@
1.83 Uint8 expect_mouse_up; /* used to determine when to send mouse up events */
1.84 Uint8 grab_state; /* used to manage grab behavior */
1.85 NSPoint cursor_loc; /* saved cursor coords, for activate/deactivate when grabbed */
1.86 - BOOL cursor_visible; /* tells if cursor was instructed to be hidden or not (SDL_ShowCursor) */
1.87 - BOOL cursor_hidden; /* tells if cursor is *actually* hidden or not */
1.88 + BOOL cursor_should_be_visible; /* tells if cursor is supposed to be visible (SDL_ShowCursor) */
1.89 + BOOL cursor_visible; /* tells if cursor is *actually* visible or not */
1.90 Uint8* sw_buffers[2]; /* pointers to the two software buffers for double-buffer emulation */
1.91 SDL_Thread *thread; /* thread for async updates to the screen */
1.92 SDL_sem *sem1, *sem2; /* synchronization for async screen updates */
1.93 @@ -156,7 +108,7 @@
1.94 Sint16 yuv_width, yuv_height;
1.95 CGrafPtr yuv_port;
1.96
1.97 -} SDL_PrivateVideoData ;
1.98 +} SDL_PrivateVideoData;
1.99
1.100 #define _THIS SDL_VideoDevice *this
1.101 #define display_id (this->hidden->display)
1.102 @@ -176,7 +128,6 @@
1.103 #define warp_flag (this->hidden->warp_flag)
1.104 #define resize_icon (this->hidden->resize_icon)
1.105 #define current_grab_mode (this->hidden->current_grab_mode)
1.106 -#define in_foreground (this->hidden->in_foreground)
1.107 #define client_mode_list (this->hidden->client_mode_list)
1.108 #define keymap (this->hidden->keymap)
1.109 #define current_mods (this->hidden->current_mods)
1.110 @@ -185,8 +136,8 @@
1.111 #define expect_mouse_up (this->hidden->expect_mouse_up)
1.112 #define grab_state (this->hidden->grab_state)
1.113 #define cursor_loc (this->hidden->cursor_loc)
1.114 +#define cursor_should_be_visible (this->hidden->cursor_should_be_visible)
1.115 #define cursor_visible (this->hidden->cursor_visible)
1.116 -#define cursor_hidden (this->hidden->cursor_hidden)
1.117 #define sw_buffers (this->hidden->sw_buffers)
1.118 #define thread (this->hidden->thread)
1.119 #define sem1 (this->hidden->sem1)
1.120 @@ -194,17 +145,6 @@
1.121 #define current_buffer (this->hidden->current_buffer)
1.122 #define quit_thread (this->hidden->quit_thread)
1.123
1.124 -#define yuv_idh (this->hidden->yuv_idh)
1.125 -#define yuv_matrix (this->hidden->yuv_matrix)
1.126 -#define yuv_codec (this->hidden->yuv_codec)
1.127 -#define yuv_seq (this->hidden->yuv_seq)
1.128 -#define yuv_pixmap (this->hidden->yuv_pixmap)
1.129 -#define yuv_data (this->hidden->yuv_data)
1.130 -#define yuv_width (this->hidden->yuv_width)
1.131 -#define yuv_height (this->hidden->yuv_height)
1.132 -#define yuv_port (this->hidden->yuv_port)
1.133 -
1.134 -
1.135 /* grab states - the input is in one of these states */
1.136 enum {
1.137 QZ_UNGRABBED = 0,
1.138 @@ -220,145 +160,52 @@
1.139 QZ_SHOWCURSOR
1.140 };
1.141
1.142 -/*
1.143 - Obscuring code: maximum number of windows above ours (inclusive)
1.144 -
1.145 - Note: this doesn't work too well in practice and should be
1.146 - phased out when we add OpenGL 2D acceleration. It was never
1.147 - enabled in the first place, so this shouldn't be a problem ;-)
1.148 -*/
1.149 -#define kMaxWindows 256
1.150 -
1.151 -/* Some of the Core Graphics Server API for obscuring code */
1.152 -#define kCGSWindowLevelTop 2147483632
1.153 -#define kCGSWindowLevelDockIconDrag 500
1.154 -#define kCGSWindowLevelDockMenu 101
1.155 -#define kCGSWindowLevelMenuIgnore 21
1.156 -#define kCGSWindowLevelMenu 20
1.157 -#define kCGSWindowLevelDockLabel 12
1.158 -#define kCGSWindowLevelDockIcon 11
1.159 -#define kCGSWindowLevelDock 10
1.160 -#define kCGSWindowLevelUtility 3
1.161 -#define kCGSWindowLevelNormal 0
1.162 -
1.163 -/*
1.164 - For completeness; We never use these window levels, they are always below us
1.165 - #define kCGSWindowLevelMBarShadow -20
1.166 - #define kCGSWindowLevelDesktopPicture -2147483647
1.167 - #define kCGSWindowLevelDesktop -2147483648
1.168 -*/
1.169 -
1.170 -typedef CGError CGSError;
1.171 -typedef long CGSWindowCount;
1.172 -typedef void * CGSConnectionID;
1.173 -typedef int CGSWindowID;
1.174 -typedef CGSWindowID* CGSWindowIDList;
1.175 -typedef CGWindowLevel CGSWindowLevel;
1.176 -typedef NSRect CGSRect;
1.177 -
1.178 -extern CGSConnectionID _CGSDefaultConnection ();
1.179 -
1.180 -extern CGSError CGSGetOnScreenWindowList (CGSConnectionID cid,
1.181 - CGSConnectionID owner,
1.182 - CGSWindowCount listCapacity,
1.183 - CGSWindowIDList list,
1.184 - CGSWindowCount *listCount);
1.185 -
1.186 -extern CGSError CGSGetScreenRectForWindow (CGSConnectionID cid,
1.187 - CGSWindowID wid,
1.188 - CGSRect *rect);
1.189 -
1.190 -extern CGWindowLevel CGSGetWindowLevel (CGSConnectionID cid,
1.191 - CGSWindowID wid,
1.192 - CGSWindowLevel *level);
1.193 -
1.194 -extern CGSError CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, unsigned int y,
1.195 - unsigned int w, unsigned int h, unsigned int color);
1.196 -
1.197 -extern CGSError CGSDisplayCanHWFill (CGDirectDisplayID id);
1.198 -
1.199 -extern CGSError CGSGetMouseEnabledFlags (CGSConnectionID cid, CGSWindowID wid, int *flags);
1.200 -
1.201 -int CGSDisplayHWSync (CGDirectDisplayID id);
1.202 -
1.203 -/* Bootstrap functions */
1.204 -static int QZ_Available ();
1.205 -static SDL_VideoDevice* QZ_CreateDevice (int device_index);
1.206 -static void QZ_DeleteDevice (SDL_VideoDevice *device);
1.207 -
1.208 -/* Initialization, Query, Setup, and Redrawing functions */
1.209 -static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format);
1.210 -
1.211 -static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format,
1.212 - Uint32 flags);
1.213 -static void QZ_UnsetVideoMode (_THIS);
1.214 -
1.215 -static SDL_Surface* QZ_SetVideoMode (_THIS, SDL_Surface *current,
1.216 - int width, int height, int bpp,
1.217 - Uint32 flags);
1.218 -static int QZ_ToggleFullScreen (_THIS, int on);
1.219 -static int QZ_SetColors (_THIS, int first_color,
1.220 - int num_colors, SDL_Color *colors);
1.221 -
1.222 -static int QZ_LockDoubleBuffer (_THIS, SDL_Surface *surface);
1.223 -static void QZ_UnlockDoubleBuffer (_THIS, SDL_Surface *surface);
1.224 -static int QZ_ThreadFlip (_THIS);
1.225 -static int QZ_FlipDoubleBuffer (_THIS, SDL_Surface *surface);
1.226 -static void QZ_DoubleBufferUpdate (_THIS, int num_rects, SDL_Rect *rects);
1.227 -
1.228 -static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects);
1.229 -static int QZ_LockWindow (_THIS, SDL_Surface *surface);
1.230 -static void QZ_UnlockWindow (_THIS, SDL_Surface *surface);
1.231 -static void QZ_UpdateRects (_THIS, int num_rects, SDL_Rect *rects);
1.232 -static void QZ_VideoQuit (_THIS);
1.233 -
1.234 -/* Hardware surface functions (for fullscreen mode only) */
1.235 -#if 0 /* Not used (apparently, it's really slow) */
1.236 -static int QZ_FillHWRect (_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
1.237 -#endif
1.238 -static int QZ_LockHWSurface(_THIS, SDL_Surface *surface);
1.239 -static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface);
1.240 -static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface);
1.241 -/* static int QZ_FlipHWSurface (_THIS, SDL_Surface *surface); */
1.242 -
1.243 /* Gamma Functions */
1.244 -static int QZ_SetGamma (_THIS, float red, float green, float blue);
1.245 -static int QZ_GetGamma (_THIS, float *red, float *green, float *blue);
1.246 -static int QZ_SetGammaRamp (_THIS, Uint16 *ramp);
1.247 -static int QZ_GetGammaRamp (_THIS, Uint16 *ramp);
1.248 +int QZ_SetGamma (_THIS, float red, float green, float blue);
1.249 +int QZ_GetGamma (_THIS, float *red, float *green, float *blue);
1.250 +int QZ_SetGammaRamp (_THIS, Uint16 *ramp);
1.251 +int QZ_GetGammaRamp (_THIS, Uint16 *ramp);
1.252
1.253 /* OpenGL functions */
1.254 -static int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags);
1.255 -static void QZ_TearDownOpenGL (_THIS);
1.256 -static void* QZ_GL_GetProcAddress (_THIS, const char *proc);
1.257 -static int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value);
1.258 -static int QZ_GL_MakeCurrent (_THIS);
1.259 -static void QZ_GL_SwapBuffers (_THIS);
1.260 -static int QZ_GL_LoadLibrary (_THIS, const char *location);
1.261 -
1.262 -/* Private function to warp the cursor (used internally) */
1.263 -static void QZ_PrivateWarpCursor (_THIS, int x, int y);
1.264 +int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags);
1.265 +void QZ_TearDownOpenGL (_THIS);
1.266 +void* QZ_GL_GetProcAddress (_THIS, const char *proc);
1.267 +int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value);
1.268 +int QZ_GL_MakeCurrent (_THIS);
1.269 +void QZ_GL_SwapBuffers (_THIS);
1.270 +int QZ_GL_LoadLibrary (_THIS, const char *location);
1.271
1.272 /* Cursor and Mouse functions */
1.273 -static void QZ_FreeWMCursor (_THIS, WMcursor *cursor);
1.274 -static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
1.275 - int w, int h, int hot_x, int hot_y);
1.276 -static int QZ_ShowWMCursor (_THIS, WMcursor *cursor);
1.277 -static void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y);
1.278 -static void QZ_MoveWMCursor (_THIS, int x, int y);
1.279 -static void QZ_CheckMouseMode (_THIS);
1.280 +void QZ_FreeWMCursor (_THIS, WMcursor *cursor);
1.281 +WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
1.282 + int w, int h, int hot_x, int hot_y);
1.283 +int QZ_ShowWMCursor (_THIS, WMcursor *cursor);
1.284 +void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y);
1.285 +void QZ_MoveWMCursor (_THIS, int x, int y);
1.286 +void QZ_CheckMouseMode (_THIS);
1.287
1.288 /* Event functions */
1.289 -static void QZ_InitOSKeymap (_THIS);
1.290 -static void QZ_PumpEvents (_THIS);
1.291 +void QZ_InitOSKeymap (_THIS);
1.292 +void QZ_PumpEvents (_THIS);
1.293
1.294 /* Window Manager functions */
1.295 -static void QZ_SetCaption (_THIS, const char *title, const char *icon);
1.296 -static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask);
1.297 -static int QZ_IconifyWindow (_THIS);
1.298 -static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode);
1.299 -/*static int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/
1.300 +void QZ_SetCaption (_THIS, const char *title, const char *icon);
1.301 +void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask);
1.302 +int QZ_IconifyWindow (_THIS);
1.303 +SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode);
1.304 +/*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/
1.305
1.306 /* YUV functions */
1.307 -static SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
1.308 +SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
1.309 Uint32 format, SDL_Surface *display);
1.310 +
1.311 +
1.312 +/* Private functions (used internally) */
1.313 +void QZ_PrivateWarpCursor (_THIS, int x, int y);
1.314 +void QZ_ChangeGrabState (_THIS, int action);
1.315 +void QZ_RegisterForSleepNotifications (_THIS);
1.316 +void QZ_ShowMouse (_THIS);
1.317 +void QZ_HideMouse (_THIS);
1.318 +void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p);
1.319 +void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p);
1.320 +