annotate src/video/quartz/SDL_QuartzWM.m @ 1905:36d52b1f0504

Prefer the D3D renderer over GDI, at least for testing. Added support for the SDL_VIDEO_RENDERER environment variable to pick the desired render driver. Implemented WritePixels support for the D3D renderer.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 14 Jul 2006 08:22:45 +0000
parents c121d94672cb
children
rev   line source
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
3 Copyright (C) 1997-2003 Sam Lantinga
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
20 slouken@libsdl.org
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1207
diff changeset
22 #include "SDL_config.h"
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
24 #include "SDL_QuartzVideo.h"
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
25
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
26
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
27 struct WMcursor
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
28 {
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
29 NSCursor *nscursor;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 };
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
32 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
33 QZ_FreeWMCursor(_THIS, WMcursor * cursor)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
34 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
36 if (cursor != NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
37 [cursor->nscursor release];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
38 free(cursor);
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
39 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
42 WMcursor *
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
43 QZ_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
44 int w, int h, int hot_x, int hot_y)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
45 {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
46 WMcursor *cursor;
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
47 NSBitmapImageRep *imgrep;
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
48 NSImage *img;
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
49 unsigned char *planes[5];
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
50 int i;
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
51 NSAutoreleasePool *pool;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
52
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
53 pool =[[NSAutoreleasePool alloc] init];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
54
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
55 /* Allocate the cursor memory */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
56 cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
57 if (cursor == NULL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
58 goto outOfMemory;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
59
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
60 /* create the image representation and get the pointers to its storage */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
61 imgrep =[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: w pixelsHigh: h bitsPerSample: 1 samplesPerPixel: 2 hasAlpha: YES isPlanar: YES colorSpaceName: NSDeviceBlackColorSpace bytesPerRow: (w + 7) / 8 bitsPerPixel:0] autorelease];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
62 if (imgrep == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
63 goto outOfMemory;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
64 [imgrep getBitmapDataPlanes:planes];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
65
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
66 /* copy data and mask, extending the mask to all black pixels because the inversion effect doesn't work with Cocoa's alpha-blended cursors */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
67 for (i = 0; i < (w + 7) / 8 * h; i++) {
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
68 planes[0][i] = data[i];
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
69 planes[1][i] = mask[i] | data[i];
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
70 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
71
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
72 /* create image and cursor */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
73 img =[[[NSImage alloc] initWithSize:NSMakeSize(w, h)] autorelease];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
74 if (img == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
75 goto outOfMemory;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
76 [img addRepresentation:imgrep];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
77 if (system_version < 0x1030) { /* on 10.2, cursors must be 16*16 */
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
78 if (w > 16 || h > 16) { /* too big: scale it down */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
79 [img setScalesWhenResized:YES];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
80 hot_x = hot_x * 16 / w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
81 hot_y = hot_y * 16 / h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
82 } else { /* too small (or just right): extend it (from the bottom left corner, so hot_y must be adjusted) */
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
83 hot_y += 16 - h;
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
84 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
85 [img setSize:NSMakeSize(16, 16)];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
86 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
87 cursor->nscursor =[[NSCursor alloc] initWithImage: img hotSpot:NSMakePoint(hot_x,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
88 hot_y)];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
89 if (cursor->nscursor == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
90 goto outOfMemory;
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
91
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
92 [pool release];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
93 return (cursor);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
94
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
95 outOfMemory:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
96 [pool release];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
97 if (cursor != NULL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
98 SDL_free(cursor);
1883
2780f547f5e7 Fix for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1812
diff changeset
99 SDL_OutOfMemory();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
100 return (NULL);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
103 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
104 QZ_ShowMouse(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
105 {
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
106 if (!cursor_visible) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
107 [NSCursor unhide];
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
108 cursor_visible = YES;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
109 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
110 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
111
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
112 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
113 QZ_HideMouse(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
114 {
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
115 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
116 [NSCursor hide];
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
117 cursor_visible = NO;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
118 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
119 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
120
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
121 BOOL
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
122 QZ_IsMouseInWindow(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
123 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
124 if (qz_window == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
125 return YES; /*fullscreen */
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
126 else {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
127 NSPoint p =[qz_window mouseLocationOutsideOfEventStream];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
128 p.y -= 1.0f; /* Apparently y goes from 1 to h, not from 0 to h-1 (i.e. the "location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
129 return NSPointInRect(p,[window_view frame]);
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
130 }
779
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
131 }
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
132
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
133 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
134 QZ_ShowWMCursor(_THIS, WMcursor * cursor)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
135 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
137 if (cursor == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
138 if (cursor_should_be_visible) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
139 QZ_HideMouse(this);
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
140 cursor_should_be_visible = NO;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
141 QZ_ChangeGrabState(this, QZ_HIDECURSOR);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
143 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
144 [cursor->nscursor set];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
145 if (!cursor_should_be_visible) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
146 QZ_ShowMouse(this);
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
147 cursor_should_be_visible = YES;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
148 QZ_ChangeGrabState(this, QZ_SHOWCURSOR);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
155 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
156 Coordinate conversion functions, for convenience
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
157 Cocoa sets the origin at the lower left corner of the window/screen
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
158 SDL, CoreGraphics/WindowServer, and QuickDraw use the origin at the upper left corner
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
159 The routines were written so they could be called before SetVideoMode() has finished;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
160 this might have limited usefulness at the moment, but the extra cost is trivial.
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
161 */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
162
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
163 /* Convert Cocoa screen coordinate to Cocoa window coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
164 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
165 QZ_PrivateGlobalToLocal(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
166 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
168 *p =[qz_window convertScreenToBase:*p];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
169 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
170
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
171
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
172 /* Convert Cocoa window coordinate to Cocoa screen coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
173 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
174 QZ_PrivateLocalToGlobal(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
175 {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
176
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
177 *p =[qz_window convertBaseToScreen:*p];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
178 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
179
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
180 /* Convert SDL coordinate to Cocoa coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
181 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
182 QZ_PrivateSDLToCocoa(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
183 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
184
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
185 if (CGDisplayIsCaptured(display_id)) { /* capture signals fullscreen */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
186
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
187 p->y = CGDisplayPixelsHigh(display_id) - p->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
188 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
189
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
190 *p =[window_view convertPoint: *p toView:nil];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
191
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
192 /* We need a workaround in OpenGL mode */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
193 if (SDL_VideoSurface->flags & SDL_OPENGL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
194 p->y =[window_view frame].size.height - p->y;
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
195 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
196 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
197 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
198
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
199 /* Convert Cocoa coordinate to SDL coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
200 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
201 QZ_PrivateCocoaToSDL(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
202 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
203
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
204 if (CGDisplayIsCaptured(display_id)) { /* capture signals fullscreen */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
205
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
206 p->y = CGDisplayPixelsHigh(display_id) - p->y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
207 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
208
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
209 *p =[window_view convertPoint: *p fromView:nil];
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 876
diff changeset
210
983
7f08bd66f1ca Date: Fri, 19 Nov 2004 06:23:53 -0800 (PST)
Sam Lantinga <slouken@libsdl.org>
parents: 952
diff changeset
211 /* We need a workaround in OpenGL mode */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
212 if (SDL_VideoSurface != NULL
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
213 && (SDL_VideoSurface->flags & SDL_OPENGL)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
214 p->y =[window_view frame].size.height - p->y;
952
Sam Lantinga <slouken@libsdl.org>
parents: 951
diff changeset
215 }
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
216 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
217 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
218
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
219 /* Convert SDL coordinate to window server (CoreGraphics) coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
220 CGPoint
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
221 QZ_PrivateSDLToCG(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
222 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
223
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
224 CGPoint cgp;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
225
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
226 if (!CGDisplayIsCaptured(display_id)) { /* not captured => not fullscreen => local coord */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
227
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
228 int height;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
229
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
230 QZ_PrivateSDLToCocoa(this, p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
231 QZ_PrivateLocalToGlobal(this, p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
232
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
233 height = CGDisplayPixelsHigh(display_id);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
234 p->y = height - p->y;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
235 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
236
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
237 cgp.x = p->x;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
238 cgp.y = p->y;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
239
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
240 return cgp;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
241 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
242
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
243 #if 0 /* Dead code */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
244 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
245 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
246 QZ_PrivateCGToSDL(_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
247 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
248
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
249 if (!CGDisplayIsCaptured(display_id)) { /* not captured => not fullscreen => local coord */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
250
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
251 int height;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
252
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
253 /* Convert CG Global to Cocoa Global */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
254 height = CGDisplayPixelsHigh(display_id);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
255 p->y = height - p->y;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
256
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
257 QZ_PrivateGlobalToLocal(this, p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
258 QZ_PrivateCocoaToSDL(this, p);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 }
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
261 #endif /* Dead code */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
263 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
264 QZ_PrivateWarpCursor(_THIS, int x, int y)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
265 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
266
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
267 NSPoint p;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
268 CGPoint cgp;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
269
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
270 p = NSMakePoint(x, y);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
271 cgp = QZ_PrivateSDLToCG(this, &p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
272
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
273 /* this is the magic call that fixes cursor "freezing" after warp */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
274 CGSetLocalEventsSuppressionInterval(0.0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
275 CGWarpMouseCursorPosition(cgp);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
276 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
277
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
278 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
279 QZ_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
280 {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
281
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 /* Only allow warping when in foreground */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
283 if (![NSApp isActive])
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 return;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
285
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 /* Do the actual warp */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
287 if (grab_state != QZ_INVISIBLE_GRAB)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
288 QZ_PrivateWarpCursor(this, x, y);
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
289
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
290 /* Generate the mouse moved event */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
291 SDL_PrivateMouseMotion(0, 0, x, y);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
294 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
295 QZ_MoveWMCursor(_THIS, int x, int y)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
296 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
297 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
298 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
299 QZ_CheckMouseMode(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
300 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
301 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
303 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
304 QZ_SetCaption(_THIS, const char *title, const char *icon)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
305 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
307 if (qz_window != nil) {
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
308 NSString *string;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
309 if (title != NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
310 string =[[NSString alloc] initWithUTF8String:title];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
311 [qz_window setTitle:string];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
312 [string release];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
313 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
314 if (icon != NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
315 string =[[NSString alloc] initWithUTF8String:icon];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
316 [qz_window setMiniwindowTitle:string];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
317 [string release];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
318 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
319 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
322 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
323 QZ_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask)
269
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
324 {
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
325 NSBitmapImageRep *imgrep;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
326 NSImage *img;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
327 SDL_Surface *mergedSurface;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
328 NSAutoreleasePool *pool;
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
329 Uint8 *pixels;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
330 SDL_bool iconSrcAlpha;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
331 Uint8 iconAlphaValue;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
332 int i, j, maskPitch, index;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
333
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
334 pool =[[NSAutoreleasePool alloc] init];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
335
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
336 imgrep =[[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL pixelsWide: icon->w pixelsHigh: icon->h bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES isPlanar: NO colorSpaceName: NSDeviceRGBColorSpace bytesPerRow: 4 * icon->w bitsPerPixel:32] autorelease];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
337 if (imgrep == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
338 goto freePool;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
339 pixels =[imgrep bitmapData];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
340 SDL_memset(pixels, 0, 4 * icon->w * icon->h); /* make the background, which will survive in colorkeyed areas, completely transparent */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
341
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
342 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
343 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
344 #else
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
345 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
346 #endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
347 mergedSurface =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
348 SDL_CreateRGBSurfaceFrom(pixels, icon->w, icon->h, 32, 4 * icon->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
349 BYTEORDER_DEPENDENT_RGBA_MASKS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
350 if (mergedSurface == NULL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
351 goto freePool;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
352
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
353 /* blit, with temporarily cleared SRCALPHA flag because we want to copy, not alpha-blend */
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
354 iconSrcAlpha = ((icon->flags & SDL_SRCALPHA) != 0);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
355 iconAlphaValue = icon->format->alpha;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
356 SDL_SetAlpha(icon, 0, 255);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
357 SDL_BlitSurface(icon, NULL, mergedSurface, NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
358 if (iconSrcAlpha)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
359 SDL_SetAlpha(icon, SDL_SRCALPHA, iconAlphaValue);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
360
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
361 SDL_FreeSurface(mergedSurface);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
362
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
363 /* apply mask, source alpha, and premultiply color values by alpha */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
364 maskPitch = (icon->w + 7) / 8;
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
365 for (i = 0; i < icon->h; i++) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
366 for (j = 0; j < icon->w; j++) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
367 index = i * 4 * icon->w + j * 4;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
368 if (!(mask[i * maskPitch + j / 8] & (128 >> j % 8))) {
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
369 pixels[index + 3] = 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
370 } else {
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
371 if (iconSrcAlpha) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
372 if (icon->format->Amask == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
373 pixels[index + 3] = icon->format->alpha;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
374 } else {
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
375 pixels[index + 3] = 255;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
376 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
377 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
378 if (pixels[index + 3] < 255) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
379 pixels[index + 0] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
380 (Uint16) pixels[index + 0] * pixels[index + 3] / 255;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
381 pixels[index + 1] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
382 (Uint16) pixels[index + 1] * pixels[index + 3] / 255;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
383 pixels[index + 2] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
384 (Uint16) pixels[index + 2] * pixels[index + 3] / 255;
592
1970e458070d Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
385 }
1970e458070d Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
386 }
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
387 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
388
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
389 img =[[[NSImage alloc] initWithSize:NSMakeSize(icon->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
390 icon->h)] autorelease];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
391 if (img == nil)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
392 goto freePool;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
393 [img addRepresentation:imgrep];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
394 [NSApp setApplicationIconImage:img];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
395
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
396 freePool:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
397 [pool release];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
398 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
399
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
400 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
401 QZ_IconifyWindow(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
402 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
404 if (![qz_window isMiniaturized]) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
405 [qz_window miniaturize:nil];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
406 return 1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
407 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
408 SDL_SetError("window already iconified");
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
409 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
410 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
411 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
412
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
413 /*
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
414 int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info) {
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
415 info->nsWindowPtr = qz_window;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
416 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
417 }*/
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
419 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
420 QZ_ChangeGrabState(_THIS, int action)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
421 {
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
422
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
423 /*
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
424 Figure out what the next state should be based on the action.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
425 Ignore actions that can't change the current state.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
426 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
427 if (grab_state == QZ_UNGRABBED) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
428 if (action == QZ_ENABLE_GRAB) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
429 if (cursor_should_be_visible)
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
430 grab_state = QZ_VISIBLE_GRAB;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
431 else
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
432 grab_state = QZ_INVISIBLE_GRAB;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
433 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
434 } else if (grab_state == QZ_VISIBLE_GRAB) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
435 if (action == QZ_DISABLE_GRAB)
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
436 grab_state = QZ_UNGRABBED;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
437 else if (action == QZ_HIDECURSOR)
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
438 grab_state = QZ_INVISIBLE_GRAB;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
439 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
440 assert(grab_state == QZ_INVISIBLE_GRAB);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
441
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
442 if (action == QZ_DISABLE_GRAB)
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
443 grab_state = QZ_UNGRABBED;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
444 else if (action == QZ_SHOWCURSOR)
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
445 grab_state = QZ_VISIBLE_GRAB;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
446 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
447
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
448 /* now apply the new state */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
449 if (grab_state == QZ_UNGRABBED) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
450
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
451 CGAssociateMouseAndMouseCursorPosition(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
452 } else if (grab_state == QZ_VISIBLE_GRAB) {
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
453
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
454 CGAssociateMouseAndMouseCursorPosition(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
455 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
456 assert(grab_state == QZ_INVISIBLE_GRAB);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
457
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
458 QZ_PrivateWarpCursor(this, SDL_VideoSurface->w / 2,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
459 SDL_VideoSurface->h / 2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
460 CGAssociateMouseAndMouseCursorPosition(0);
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
461 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
462 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
463
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
464 SDL_GrabMode
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
465 QZ_GrabInput(_THIS, SDL_GrabMode grab_mode)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
466 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
468 int doGrab = grab_mode & SDL_GRAB_ON;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
469 /*int fullscreen = grab_mode & SDL_GRAB_FULLSCREEN; */
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
470
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
471 if (this->screen == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
472 SDL_SetError("QZ_GrabInput: screen is NULL");
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
473 return SDL_GRAB_OFF;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
474 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
475
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
476 if (!video_set) {
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
477 /*SDL_SetError ("QZ_GrabInput: video is not set, grab will take effect on mode switch"); */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
478 current_grab_mode = grab_mode;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
479 return grab_mode; /* Will be set later on mode switch */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
480 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
481
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
482 if (grab_mode != SDL_GRAB_QUERY) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
483 if (doGrab)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
484 QZ_ChangeGrabState(this, QZ_ENABLE_GRAB);
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
485 else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
486 QZ_ChangeGrabState(this, QZ_DISABLE_GRAB);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1883
diff changeset
487
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
488 current_grab_mode = doGrab ? SDL_GRAB_ON : SDL_GRAB_OFF;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
489 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
490
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
491 return current_grab_mode;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
492 }