annotate src/video/gem/SDL_gemvideo.h @ 563:04dcaf3da918

Massive Quartz input enhancements from Darrell Walisser. His email: Enclosed is a patch that addresses the following: --Various minor cleanups. Removed dead/obsolete code, made some style cleanups --Mouse Events Now keep track of what button(s) were pressed so we know when to send the mouse up event. This fixes the case where the mouse is dragged outside of the game window and released (in which case we want to send the mouse up event even though the mouse is outside the game window). --Input Grabbing Here is my take on the grabbing situation, which is the basis for the new implementation. There are 3 grab states, ungrabbed (UG), visible (VG), and invisible (IG). Both VG and IG keep the mouse constrained to the window and produce relative motion events. In VG the cursor is visible (duh), in IG it is not. In VG, absolute motion events also work. There are 6 actions that can affect grabbing: 1. Set Fullscreen/Window (F/W). In fullscreen, a visible grab should do nothing. However, a fullscreen visible grab can be treated just like a windowed visible grab, which is what I have done to help simplify things. 2. Cursor hide/show (H/S). If the cursor is hidden when grabbing, the grab is an invisible grab. If the cursor is visible, the grab should just constrain the mouse to the window. 3. Input grab/ungrab(G/U). If grabbed, the cursor should be confined to the window as should the keyboard input. On Mac OS X, the keyboard input is implicitly grabbed by confining the cursor, except for command-tab which can switch away from the application. Should the window come to the foreground if the application is deactivated and grab input is called? This isn't necessary in this implementation because the grab state will be asserted upon activation. Using my notation, these are all the cases that need to be handled (state + action = new state). UG+U = UG UG+G = VG or IG, if cursor is visible or not UG+H = UG UG+S = UG VG+U = UG VG+G = VG VG+H = IG VG+S = VG IG+U = UG IG+G = IG IG+H = IG IG+S = VG The cases that result in the same state can be ignored in the code, which cuts it down to just 5 cases. Another issue is what happens when the app loses/gains input focus from deactivate/activate or iconify/deiconify. I think that if input focus is ever lost (outside of SDL's control), the grab state should be suspended and the cursor should become visible and active again. When regained, the cursor should reappear in its original location and/or grab state. This way, when reactivating the cursor is still in the same position as before so apps shouldn't get confused when the next motion event comes in. This is what I've done in this patch.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 27 Dec 2002 20:52:41 +0000
parents 0ce5a68278fd
children 028e03e273c8
rev   line source
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
297
f6ffac90895c Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents: 281
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 static char rcsid =
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 "@(#) $Id$";
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #ifndef _SDL_gemvideo_h
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #define _SDL_gemvideo_h
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "SDL_sysvideo.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "SDL_mutex.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 /* Hidden "this" pointer for the video functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #define _THIS SDL_VideoDevice *this
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 /* Functions prototypes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 void GEM_wind_redraw(_THIS, int winhandle, short *inside);
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 /* Private display data */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #define SDL_NUMMODES 1 /* Fullscreen */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 struct SDL_PrivateVideoData {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 /* VDI infos */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 short vdi_handle; /* VDI handle */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 short full_w, full_h; /* Fullscreen size */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 int bpp; /* Colour depth */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 int pixelsize; /* Bytes per pixel */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 Uint16 old_numcolors; /* Number of colors in saved palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 Uint16 old_palette[256][3]; /* Saved current palette */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 Uint16 pitch; /* Line length */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 int format; /* Screen format */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 void *screen; /* Screen address */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 Uint32 red, green, blue, alpha; /* Screen components */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 Uint32 screensize;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 short blit_coords[8]; /* Coordinates for bitblt */
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
59 /* GEM infos */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 short desk_x, desk_y; /* Desktop properties */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 short desk_w, desk_h;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 short win_handle; /* Our window handle */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 void *buffer; /* Our shadow buffer */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 int window_type; /* Window type */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 const char *title_name; /* Window title */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 const char *icon_name; /* Icon title */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 short version; /* AES version */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 short wfeatures; /* AES window features */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 SDL_bool window_fulled; /* Window maximized ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 SDL_bool mouse_relative; /* Report relative mouse movement */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 SDL_bool locked; /* AES locked for fullscreen ? */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 };
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 /* Hidden structure -> variables names */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 #define VDI_handle (this->hidden->vdi_handle)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 #define VDI_w (this->hidden->full_w)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 #define VDI_h (this->hidden->full_h)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 #define VDI_bpp (this->hidden->bpp)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 #define VDI_pixelsize (this->hidden->pixelsize)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 #define VDI_oldnumcolors (this->hidden->old_numcolors)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 #define VDI_oldpalette (this->hidden->old_palette)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 #define VDI_pitch (this->hidden->pitch)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 #define VDI_format (this->hidden->format)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 #define VDI_screen (this->hidden->screen)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 #define VDI_redmask (this->hidden->red)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 #define VDI_greenmask (this->hidden->green)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 #define VDI_bluemask (this->hidden->blue)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 #define VDI_alphamask (this->hidden->alpha)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 #define VDI_screensize (this->hidden->screensize)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 #define VDI_src_mfdb (this->hidden->src_mfdb)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 #define VDI_dst_mfdb (this->hidden->dst_mfdb)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 #define VDI_blit_coords (this->hidden->blit_coords)
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
94
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 #define GEM_desk_x (this->hidden->desk_x)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 #define GEM_desk_y (this->hidden->desk_y)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 #define GEM_desk_w (this->hidden->desk_w)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 #define GEM_desk_h (this->hidden->desk_h)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 #define GEM_handle (this->hidden->win_handle)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 #define GEM_buffer (this->hidden->buffer)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 #define GEM_win_type (this->hidden->window_type)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 #define GEM_title_name (this->hidden->title_name)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 #define GEM_icon_name (this->hidden->icon_name)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 #define GEM_version (this->hidden->version)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 #define GEM_wfeatures (this->hidden->wfeatures)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 #define GEM_win_fulled (this->hidden->window_fulled)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 #define GEM_mouse_relative (this->hidden->mouse_relative)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 #define GEM_locked (this->hidden->locked)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 #define SDL_modelist (this->hidden->SDL_modelist)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 #endif /* _SDL_gemvideo_h */