annotate src/video/quartz/SDL_QuartzWM.m @ 1830:19555149bb66

Add a reminder to fix current->w,current->h
author Patrice Mandin <patmandin@gmail.com>
date Sun, 14 May 2006 09:55:22 +0000
parents 9c882e94b545
children 2780f547f5e7
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
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 struct WMcursor {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 Cursor curs;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 };
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
31 void QZ_FreeWMCursor (_THIS, WMcursor *cursor) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 if ( cursor != NULL )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 free (cursor);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 /* Use the Carbon cursor routines for now */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
38 WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
39 int w, int h, int hot_x, int hot_y) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
40 WMcursor *cursor;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
41 int row, bytes;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
42
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
43 /* Allocate the cursor memory */
1756
eed7a3f396ce Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
44 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor));
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
45 if ( cursor == NULL ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
46 SDL_OutOfMemory();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
47 return(NULL);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
48 }
1756
eed7a3f396ce Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
49 SDL_memset(cursor, 0, sizeof(*cursor));
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
50
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
51 if (w > 16)
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
52 w = 16;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
53
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
54 if (h > 16)
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
55 h = 16;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
56
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
57 bytes = (w+7)/8;
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
58
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
59 for ( row=0; row<h; ++row ) {
1756
eed7a3f396ce Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
60 SDL_memcpy(&cursor->curs.data[row], data, bytes);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
61 data += bytes;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
62 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
63 for ( row=0; row<h; ++row ) {
1756
eed7a3f396ce Using the SDL C runtime functions
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
64 SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
65 mask += bytes;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
66 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
67 cursor->curs.hotSpot.h = hot_x;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
68 cursor->curs.hotSpot.v = hot_y;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 324
diff changeset
69
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
70 return(cursor);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
73 void QZ_ShowMouse (_THIS) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
74 if (!cursor_visible) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
75 [ NSCursor unhide ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
76 cursor_visible = YES;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
77 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
78 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
79
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
80 void QZ_HideMouse (_THIS) {
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
81 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) && cursor_visible) {
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
82 [ NSCursor hide ];
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
83 cursor_visible = NO;
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
84 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
85 }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
86
779
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
87 BOOL QZ_IsMouseInWindow (_THIS) {
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
88 if (qz_window == nil) return YES; /*fullscreen*/
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
89 else {
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
90 NSPoint p = [ qz_window mouseLocationOutsideOfEventStream ];
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
91 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" */
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
92 return NSPointInRect(p, [ window_view frame ]);
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
93 }
779
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
94 }
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
95
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
96 int QZ_ShowWMCursor (_THIS, WMcursor *cursor) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 if ( cursor == NULL) {
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
99 if ( cursor_should_be_visible ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
100 QZ_HideMouse (this);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
101 cursor_should_be_visible = NO;
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
102 QZ_ChangeGrabState (this, QZ_HIDECURSOR);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 SetCursor(&cursor->curs);
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
107 if ( ! cursor_should_be_visible ) {
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
108 QZ_ShowMouse (this);
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
109 cursor_should_be_visible = YES;
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
110 QZ_ChangeGrabState (this, QZ_SHOWCURSOR);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
117 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
118 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
119 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
120 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
121 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
122 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
123 */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
124
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
125 /* Convert Cocoa screen coordinate to Cocoa window coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
126 void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
128 *p = [ qz_window convertScreenToBase:*p ];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
129 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
130
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
131
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
132 /* Convert Cocoa window coordinate to Cocoa screen coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
133 void QZ_PrivateLocalToGlobal (_THIS, NSPoint *p) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
134
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
135 *p = [ qz_window convertBaseToScreen:*p ];
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
136 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
137
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
138 /* Convert SDL coordinate to Cocoa coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
139 void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
140
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
141 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
142
876
9e84d106ec19 (Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents: 779
diff changeset
143 p->y = CGDisplayPixelsHigh (display_id) - p->y;
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
144 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
145 else {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 876
diff changeset
146
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 876
diff changeset
147 *p = [ window_view convertPoint:*p toView: nil ];
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
148
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
149 /* We need a workaround in OpenGL mode */
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
150 if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
151 p->y = [window_view frame].size.height - p->y;
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
152 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
153 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
154 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
155
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
156 /* Convert Cocoa coordinate to SDL coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
157 void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
158
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
159 if ( CGDisplayIsCaptured (display_id) ) { /* capture signals fullscreen */
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
160
876
9e84d106ec19 (Said Max Horn on the SDL mailing list...)
Ryan C. Gordon <icculus@icculus.org>
parents: 779
diff changeset
161 p->y = CGDisplayPixelsHigh (display_id) - p->y;
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
162 }
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
163 else {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 876
diff changeset
164
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 876
diff changeset
165 *p = [ window_view convertPoint:*p fromView: nil ];
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
166
983
7f08bd66f1ca Date: Fri, 19 Nov 2004 06:23:53 -0800 (PST)
Sam Lantinga <slouken@libsdl.org>
parents: 952
diff changeset
167 /* We need a workaround in OpenGL mode */
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
168 if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) {
1192
54aa9aa32327 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 983
diff changeset
169 p->y = [window_view frame].size.height - p->y;
952
Sam Lantinga <slouken@libsdl.org>
parents: 951
diff changeset
170 }
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
171 }
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
172 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
173
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
174 /* Convert SDL coordinate to window server (CoreGraphics) coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
175 CGPoint QZ_PrivateSDLToCG (_THIS, NSPoint *p) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
176
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
177 CGPoint cgp;
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 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
180
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
181 int height;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
182
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
183 QZ_PrivateSDLToCocoa (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
184 QZ_PrivateLocalToGlobal (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
185
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
186 height = CGDisplayPixelsHigh (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
187 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
188 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
189
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
190 cgp.x = p->x;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
191 cgp.y = p->y;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
192
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
193 return cgp;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
194 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
195
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
196 #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
197 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
198 void QZ_PrivateCGToSDL (_THIS, NSPoint *p) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
199
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
200 if ( ! CGDisplayIsCaptured (display_id) ) { /* not captured => not fullscreen => local coord */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
201
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
202 int height;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
203
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
204 /* Convert CG Global to Cocoa Global */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
205 height = CGDisplayPixelsHigh (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
206 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
207
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
208 QZ_PrivateGlobalToLocal (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
209 QZ_PrivateCocoaToSDL (this, p);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 }
683
5d2f027b3349 Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 615
diff changeset
212 #endif /* Dead code */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
214 void QZ_PrivateWarpCursor (_THIS, int x, int y) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
215
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
216 NSPoint p;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
217 CGPoint cgp;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
219 p = NSMakePoint (x, y);
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
220 cgp = QZ_PrivateSDLToCG (this, &p);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
221
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
222 /* this is the magic call that fixes cursor "freezing" after warp */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
223 CGSetLocalEventsSuppressionInterval (0.0);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
224 CGWarpMouseCursorPosition (cgp);
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
225 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
226
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
227 void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
228
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 /* Only allow warping when in foreground */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
230 if ( ! [ NSApp isActive ] )
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 return;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233 /* Do the actual warp */
1207
c9ec00d3e8bc To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1192
diff changeset
234 if (grab_state != QZ_INVISIBLE_GRAB) 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
235
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
236 /* Generate the mouse moved event */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
237 SDL_PrivateMouseMotion (0, 0, x, y);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
240 void QZ_MoveWMCursor (_THIS, int x, int y) { }
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
241 void QZ_CheckMouseMode (_THIS) { }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
243 void QZ_SetCaption (_THIS, const char *title, const char *icon) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
245 if ( qz_window != nil ) {
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
246 NSString *string;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
247 if ( title != NULL ) {
951
121f56c1277d Date: Sun, 29 Aug 2004 20:55:54 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 934
diff changeset
248 string = [ [ NSString alloc ] initWithUTF8String:title ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
249 [ qz_window setTitle:string ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
250 [ string release ];
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
251 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
252 if ( icon != NULL ) {
951
121f56c1277d Date: Sun, 29 Aug 2004 20:55:54 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 934
diff changeset
253 string = [ [ NSString alloc ] initWithUTF8String:icon ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
254 [ qz_window setMiniwindowTitle:string ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
255 [ string release ];
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
256 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
257 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
260 void 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
261 {
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
262 NSBitmapImageRep *imgrep;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
263 NSImage *img;
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
264 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
265 NSAutoreleasePool *pool;
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
266 Uint8 *pixels;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
267 SDL_bool iconSrcAlpha;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
268 Uint8 iconAlphaValue;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
269 int i, j, maskPitch, index;
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
270
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
271 pool = [ [ NSAutoreleasePool alloc ] init ];
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
272
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
273 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 ];
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
274 if (imgrep == nil) goto freePool;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
275 pixels = [ imgrep bitmapData ];
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
276 SDL_memset(pixels, 0, 4*icon->w*icon->h); /* make the background, which will survive in colorkeyed areas, completely transparent */
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
277
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
278 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
279 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
280 #else
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
281 #define BYTEORDER_DEPENDENT_RGBA_MASKS 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
282 #endif
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
283 mergedSurface = SDL_CreateRGBSurfaceFrom(pixels, icon->w, icon->h, 32, 4*icon->w, BYTEORDER_DEPENDENT_RGBA_MASKS);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
284 if (mergedSurface == NULL) goto freePool;
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
285
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
286 /* 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
287 iconSrcAlpha = ((icon->flags & SDL_SRCALPHA) != 0);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
288 iconAlphaValue = icon->format->alpha;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
289 SDL_SetAlpha(icon, 0, 255);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
290 SDL_BlitSurface(icon, NULL, mergedSurface, NULL);
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
291 if (iconSrcAlpha) SDL_SetAlpha(icon, SDL_SRCALPHA, iconAlphaValue);
592
1970e458070d Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
292
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
293 SDL_FreeSurface(mergedSurface);
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
294
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
295 /* apply mask, source alpha, and premultiply color values by alpha */
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
296 maskPitch = (icon->w+7)/8;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
297 for (i = 0; i < icon->h; i++) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
298 for (j = 0; j < icon->w; j++) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
299 index = i*4*icon->w + j*4;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
300 if (!(mask[i*maskPitch + j/8] & (128 >> j%8))) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
301 pixels[index + 3] = 0;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
302 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
303 else {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
304 if (iconSrcAlpha) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
305 if (icon->format->Amask == 0) pixels[index + 3] = icon->format->alpha;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
306 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
307 else {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
308 pixels[index + 3] = 255;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
309 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
310 }
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
311 if (pixels[index + 3] < 255) {
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
312 pixels[index + 0] = (Uint16)pixels[index + 0]*pixels[index + 3]/255;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
313 pixels[index + 1] = (Uint16)pixels[index + 1]*pixels[index + 3]/255;
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
314 pixels[index + 2] = (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
315 }
1970e458070d Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
316 }
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
317 }
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
318
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
319 img = [ [ [ NSImage alloc ] initWithSize: NSMakeSize(icon->w, icon->h) ] autorelease ];
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
320 if (img == nil) goto freePool;
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
321 [ img addRepresentation: imgrep ];
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
322 [ NSApp setApplicationIconImage:img ];
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
323
269
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
324 freePool:
1812
9c882e94b545 Fixed bug #208
Sam Lantinga <slouken@libsdl.org>
parents: 1756
diff changeset
325 [ pool release ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
328 int QZ_IconifyWindow (_THIS) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
330 if ( ! [ qz_window isMiniaturized ] ) {
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
331 [ qz_window miniaturize:nil ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 else {
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
335 SDL_SetError ("window already iconified");
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 /*
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
341 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
342 info->nsWindowPtr = qz_window;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 }*/
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
346 void QZ_ChangeGrabState (_THIS, int action) {
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
347
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
348 /*
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
349 Figure out what the next state should be based on the action.
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
350 Ignore actions that can't change the current state.
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
351 */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
352 if ( grab_state == QZ_UNGRABBED ) {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
353 if ( action == QZ_ENABLE_GRAB ) {
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
354 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
355 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
356 else
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
357 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
358 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
359 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
360 else if ( 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
361 if ( action == QZ_DISABLE_GRAB )
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
362 grab_state = QZ_UNGRABBED;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
363 else if ( action == QZ_HIDECURSOR )
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
364 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
365 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
366 else {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
367 assert( 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
368
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
369 if ( action == QZ_DISABLE_GRAB )
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
370 grab_state = QZ_UNGRABBED;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
371 else if ( action == QZ_SHOWCURSOR )
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
372 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
373 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
374
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
375 /* 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
376 if (grab_state == QZ_UNGRABBED) {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
377
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
378 CGAssociateMouseAndMouseCursorPosition (1);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
379 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
380 else if (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
381
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
382 CGAssociateMouseAndMouseCursorPosition (1);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
383 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
384 else {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
385 assert( 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
386
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
387 QZ_PrivateWarpCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
388 CGAssociateMouseAndMouseCursorPosition (0);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
389 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
390 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
391
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
392 SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
394 int doGrab = grab_mode & SDL_GRAB_ON;
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
395 /*int fullscreen = grab_mode & SDL_GRAB_FULLSCREEN;*/
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
396
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
397 if ( this->screen == NULL ) {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
398 SDL_SetError ("QZ_GrabInput: screen is NULL");
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
399 return SDL_GRAB_OFF;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
400 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
402 if ( ! video_set ) {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
403 /*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
404 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
405 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
406 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
407
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
408 if ( grab_mode != SDL_GRAB_QUERY ) {
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
409 if ( doGrab )
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
410 QZ_ChangeGrabState (this, QZ_ENABLE_GRAB);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
411 else
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
412 QZ_ChangeGrabState (this, QZ_DISABLE_GRAB);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
413
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
414 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
415 }
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 501
diff changeset
416
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
417 return current_grab_mode;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418 }