Mercurial > sdl-ios-xcode
annotate src/video/cybergfx/SDL_cgxvideo.h @ 1629:ef4a796e7f24
Fixed bug #55
From Christian Walther:
When writing my patch for #12, I ended up doing all sorts of changes to the way
application/window activating/deactivating is handled in the Quartz backend,
resulting in the attached patch. It does make the code a bit cleaner IMHO, but
as it might be regarded as a case of "if it ain't broken, don't fix it" I'd
like to hear other people's opinion about it. Please shout if some change
strikes you as unnecessary or wrong, and I'll explain the reasons behind it. As
far as I tested it, it does not introduce any new bugs, but I may well have
missed some.
- The most fundamental change (that triggered most of the others) is irrelevant
for the usual single-window SDL applications, it only affects the people who
are crazy enough to display other Cocoa windows alongside the SDL window (I'm
actually doing this currently, although the additional window only displays
debugging info and won't be present in the final product): Before, some things
were done on the application becoming active, some on the window becoming key,
and some on the window becoming main. Conceptually, all these actions belong to
the window becoming key, so that's what I implemented. However, since in a
single-window application these three events always happen together, the
previous implementation "ain't broken".
- This slightly changed the meaning of the SDL_APPMOUSEFOCUS flag from
SDL_GetAppState(): Before, it meant "window is main and mouse is inside window
(or mode is fullscreen)". Now, it means "window is key and mouse is inside
window (or mode is fullscreen)". It makes more sense to me that way. (See
http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Concepts/ChangingMainKeyWindow.html
for a discussion of what key and main windows are.) The other two flags are
unchanged: SDL_APPACTIVE = application is not hidden and window is not
minimized, SDL_APPINPUTFOCUS = window is key (or mode is fullscreen).
- As a side effect, the reorganization fixes the following two issues (and
maybe others) (but they could also be fixed in less invasive ways):
* A regression that was introduced in revision 1.42 of SDL_QuartzVideo.m
(http://libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzVideo.m.diff?r1=1.41&r2=1.42)
(from half-desirable to undesirable behavior):
Situation: While in windowed mode, hide the cursor using
SDL_ShowCursor(SDL_DISABLE), move the mouse outside of the window so that the
cursor becomes visible again, and SDL_SetVideoMode() to a fullscreen mode.
What happened before revision 1.42: The cursor is visible, but becomes
invisible as soon as the mouse is moved (half-desirable).
What happens in revision 1.42 and after (including current CVS): The cursor is
visible and stays visible (undesirable).
What happens after my patch: The cursor is invisible from the beginning
(desirable).
* When the cursor is hidden and grabbed, switch away from the application using
cmd-tab (which ungrabs and makes the cursor visible), move the cursor outside
of the SDL window, then cmd-tab back to the application. In 1.2.8 and in the
current CVS, the cursor is re-grabbed, but it stays visible (immovable in the
middle of the window). With my patch, the cursor is correctly re-grabbed and
hidden. (For some reason, it still doesn't work correctly if you switch back to
the application using the dock instead of cmd-tab. I haven't been able to
figure out why. I can step over [NSCursor hide] being called in the debugger,
but it seems to have no effect.)
- The patch includes my patch for #12 (it was easier to obtain using cvs diff
that way). If you apply both of them, you will end up with 6 duplicate lines in
SDL_QuartzEvents.m.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 13 Apr 2006 14:17:48 +0000 |
parents | 8d9bb0cf2c2a |
children | 782fd950bd46 c121d94672cb |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #ifndef _SDL_cgxvideo_h | |
25 #define _SDL_cgxvideo_h | |
26 | |
27 | |
28 #include <exec/exec.h> | |
29 #include <cybergraphx/cybergraphics.h> | |
30 #include <graphics/scale.h> | |
31 #include <graphics/gfx.h> | |
32 #include <intuition/intuition.h> | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
33 #if defined(__SASC) || defined(STORMC4_WOS) |
0 | 34 #include <proto/exec.h> |
35 #include <proto/cybergraphics.h> | |
36 #include <proto/graphics.h> | |
37 #include <proto/intuition.h> | |
38 #include <proto/console.h> | |
39 #else | |
40 #include <inline/exec.h> | |
41 #include <inline/cybergraphics.h> | |
42 #include <inline/graphics.h> | |
43 #include <inline/intuition.h> | |
44 #include <inline/console.h> | |
45 #endif | |
46 | |
47 #include "SDL_mouse.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
48 #include "../SDL_sysvideo.h" |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
49 #include "mydebug.h" |
0 | 50 |
51 #define USE_CGX_WRITELUTPIXEL | |
52 | |
53 /* Hidden "this" pointer for the video functions */ | |
54 #define _THIS SDL_VideoDevice *this | |
55 | |
56 /* Private display data */ | |
57 struct SDL_PrivateVideoData { | |
58 struct Screen *Public_Display; /* Used for events and window management */ | |
59 struct Screen *GFX_Display; /* Used for graphics and colormap stuff */ | |
60 Uint32 SDL_VisualUnused; /* The visual used by our window */ | |
61 struct Window *SDL_Window; /* Shared by both displays (no X security?) */ | |
62 unsigned char *BlankCursor; /* The invisible cursor */ | |
63 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
64 char *SDL_windowid; /* Flag: true if we have been passed a window */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
65 |
0 | 66 /* The variables used for displaying graphics */ |
67 Uint8 *Ximage; /* The X image for our window */ | |
68 int swap_pixels; /* Flag: true if display is swapped endian */ | |
69 | |
70 /* Support for internal mouse warping */ | |
71 struct { | |
72 int x; | |
73 int y; | |
74 } mouse_last; | |
75 struct { | |
76 int numerator; | |
77 int denominator; | |
78 int threshold; | |
79 } mouse_accel; | |
80 int mouse_relative; | |
81 | |
82 /* The current list of available video modes */ | |
83 SDL_Rect **modelist; | |
84 | |
85 /* available visuals of interest to us, sorted deepest first */ | |
86 struct { | |
87 Uint32 visual; | |
88 int depth; /* number of significant bits/pixel */ | |
89 int bpp; /* pixel quantum in bits */ | |
90 } visuals[5]; /* at most entries for 8, 15, 16, 24 */ | |
91 int nvisuals; | |
92 | |
93 Uint32 vis; /* current visual in use */ | |
94 int depth; /* current visual depth (not bpp) */ | |
95 int BytesPerPixel; | |
96 int currently_fullscreen,same_format,dbuffer; | |
97 | |
98 /* Automatic mode switching support (entering/leaving fullscreen) */ | |
99 Uint32 switch_waiting; | |
100 Uint32 switch_time; | |
101 | |
102 /* Prevent too many XSync() calls */ | |
103 int blit_queued; | |
104 | |
105 /* Colormap handling */ | |
106 LONG Pens; | |
107 Sint32 *XPixels; /* A list of pixels that have been allocated, the size depends on the screen format */ | |
108 struct ScreenBuffer *SB[2]; | |
109 struct RastPort *RP; | |
110 short *iconcolors; /* List of colors used by the icon */ | |
111 }; | |
112 | |
113 /* Old variable names */ | |
114 #define local_X11 (this->hidden->local_X11) | |
115 #define SDL_Display (this->hidden->Public_Display) | |
116 #define GFX_Display (this->hidden->GFX_Display) | |
117 #define SDL_Screen DefaultScreen(this->hidden->Public_Display) | |
118 | |
119 #define SDL_Visual (this->hidden->vis) | |
120 | |
121 #define SDL_Root RootWindow(SDL_Display, SDL_Screen) | |
122 #define WMwindow (this->hidden->WMwindow) | |
123 #define FSwindow (this->hidden->FSwindow) | |
124 #define SDL_Window (this->hidden->SDL_Window) | |
125 #define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW) | |
126 #define SDL_BlankCursor (this->hidden->BlankCursor) | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
127 #define SDL_windowid (this->hidden->SDL_windowid) |
0 | 128 #define SDL_Ximage (this->hidden->Ximage) |
129 #define SDL_GC (this->hidden->gc) | |
130 #define swap_pixels (this->hidden->swap_pixels) | |
131 #define mouse_last (this->hidden->mouse_last) | |
132 #define mouse_accel (this->hidden->mouse_accel) | |
133 #define mouse_relative (this->hidden->mouse_relative) | |
134 #define SDL_modelist (this->hidden->modelist) | |
135 #define SDL_RastPort (this->hidden->RP) | |
136 #define saved_mode (this->hidden->saved_mode) | |
137 #define saved_view (this->hidden->saved_view) | |
138 #define currently_fullscreen (this->hidden->currently_fullscreen) | |
139 #define blit_queued (this->hidden->blit_queued) | |
140 #define SDL_DisplayColormap (this->hidden->GFX_Display->ViewPort.ColorMap) | |
141 #define SDL_XPixels (this->hidden->XPixels) | |
142 #define SDL_iconcolors (this->hidden->iconcolors) | |
143 | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
144 /* Used to get the X cursor from a window-manager specific cursor */ |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
145 // extern Cursor SDL_GetWMXCursor(WMcursor *cursor); |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
146 |
0 | 147 extern int CGX_CreateWindow(_THIS, SDL_Surface *screen, |
148 int w, int h, int bpp, Uint32 flags); | |
149 extern int CGX_ResizeWindow(_THIS, | |
150 SDL_Surface *screen, int w, int h, Uint32 flags); | |
151 | |
152 extern void CGX_DestroyWindow(_THIS, SDL_Surface *screen); | |
153 | |
154 extern struct Library *CyberGfxBase; | |
155 extern struct IntuitionBase *IntuitionBase; | |
156 extern struct GfxBase *GfxBase; | |
157 extern struct ExecBase *SysBase; | |
158 extern struct DosLibrary *DOSBase; | |
159 | |
160 struct private_hwdata | |
161 { | |
162 struct BitMap *bmap; | |
163 APTR lock; | |
164 struct SDL_VideoDevice *videodata; | |
165 APTR mask; | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
166 int allocated; |
0 | 167 }; |
168 | |
169 int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst); | |
170 int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color); | |
171 int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key); | |
172 #endif /* _SDL_x11video_h */ |