annotate src/video/quartz/SDL_QuartzWM.m @ 273:72acb06d3721

*** empty log message ***
author Sam Lantinga <slouken@libsdl.org>
date Tue, 22 Jan 2002 21:14:36 +0000
parents d1447a846d80
children f6ffac90895c
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
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
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 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 struct WMcursor {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 Cursor curs;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 };
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 static void QZ_FreeWMCursor (_THIS, WMcursor *cursor) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 if ( cursor != NULL )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 free (cursor);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 }
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 /* Use the Carbon cursor routines for now */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 int w, int h, int hot_x, int hot_y) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 WMcursor *cursor;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 int row, bytes;
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
38
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
39 /* Allocate the cursor memory */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 cursor = (WMcursor *)malloc(sizeof(WMcursor));
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 if ( cursor == NULL ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 SDL_OutOfMemory();
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 return(NULL);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 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
46
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
47 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
48 w = 16;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
49
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
50 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
51 h = 16;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
52
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
53 bytes = (w+7)/8;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
54
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
55 for ( row=0; row<h; ++row ) {
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
56 memcpy(&cursor->curs.data[row], data, bytes);
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
57 data += bytes;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 }
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
59 for ( row=0; row<h; ++row ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 memcpy(&cursor->curs.mask[row], mask, bytes);
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
61 mask += bytes;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 cursor->curs.hotSpot.h = hot_x;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 cursor->curs.hotSpot.v = hot_y;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
66 return(cursor);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
69 static int QZ_cursor_visible = 1;
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
70
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 if ( cursor == NULL) {
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
74 if ( QZ_cursor_visible ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 HideCursor ();
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
76 QZ_cursor_visible = 0;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 SetCursor(&cursor->curs);
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
81 if ( ! QZ_cursor_visible ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 ShowCursor ();
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
83 QZ_cursor_visible = 1;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
90 /**
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
91 * Coordinate conversion functions, for convenience
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
92 * Cocoa sets the origin at the lower left corner of the window/screen
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
93 * SDL, CoreGraphics/WindowServer, and QuickDraw use the origin at the upper left corner
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
94 * The routines were written so they could be called before SetVideoMode() has finished;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
95 * this might have limited usefulness at the moment, but the extra cost is trivial.
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
96 **/
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
97
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
98 /* Convert Cocoa screen coordinate to Cocoa window coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
99 static void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
101 *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
102 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
103
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
104
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
105 /* Convert Cocoa window coordinate to Cocoa screen coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
106 static void QZ_PrivateLocalToGlobal (_THIS, NSPoint *p) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
107
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
108 *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
109 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
110
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
111 /* Convert SDL coordinate to Cocoa coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
112 static void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
113
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
114 int height;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
116 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
117
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
118 height = CGDisplayPixelsHigh (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
119 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
120 else {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
121
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
122 height = NSHeight ( [ qz_window frame ] );
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
123 if ( [ qz_window styleMask ] & NSTitledWindowMask ) {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
125 height -= 22;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
126 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
127 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
128
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
129 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
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 coordinate to SDL coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
133 static void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) {
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 QZ_PrivateSDLToCocoa (this, 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 window server (CoreGraphics) coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
139 static CGPoint QZ_PrivateSDLToCG (_THIS, NSPoint *p) {
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 CGPoint cgp;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
142
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
143 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
144
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
145 int height;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
146
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
147 QZ_PrivateSDLToCocoa (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
148 QZ_PrivateLocalToGlobal (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
149
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
150 height = CGDisplayPixelsHigh (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
151 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
152 }
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 cgp.x = p->x;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
155 cgp.y = p->y;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
156
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
157 return cgp;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
158 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
159
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
160 /* Convert window server (CoreGraphics) coordinate to SDL coordinate */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
161 static void QZ_PrivateCGToSDL (_THIS, NSPoint *p) {
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 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
164
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
165 int height;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
166
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
167 /* 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
168 height = CGDisplayPixelsHigh (display_id);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
169 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
170
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
171 QZ_PrivateGlobalToLocal (this, p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
172 QZ_PrivateCocoaToSDL (this, p);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
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 static void QZ_PrivateWarpCursor (_THIS, int x, int y) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
177
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
178 NSPoint p;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
179 CGPoint cgp;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
181 p = NSMakePoint (x, y);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
182 cgp = QZ_PrivateSDLToCG (this, &p);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
183 CGDisplayMoveCursorToPoint (display_id, cgp);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
184 warp_ticks = SDL_GetTicks();
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
185 warp_flag = 1;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
186 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
187
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
188 static void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
189
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 /* Only allow warping when in foreground */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 if ( ! inForeground )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 return;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 /* Do the actual warp */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
195 QZ_PrivateWarpCursor (this, x, y);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 static void QZ_MoveWMCursor (_THIS, int x, int y) { }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 static void QZ_CheckMouseMode (_THIS) { }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 static void QZ_SetCaption (_THIS, const char *title, const char *icon) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
203 if ( qz_window != nil ) {
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
204 NSString *string;
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
205 if ( title != NULL ) {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
206 string = [ [ NSString alloc ] initWithCString:title ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
207 [ qz_window setTitle:string ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
208 [ string release ];
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
209 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
210 if ( icon != NULL ) {
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
211 string = [ [ NSString alloc ] initWithCString:icon ];
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
212 [ qz_window setMiniwindowTitle:string ];
58
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
213 [ string release ];
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
214 }
bd6b0a910a65 * Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents: 47
diff changeset
215 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217
269
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
218 static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask)
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
219 {
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
220 NSBitmapImageRep *imgrep;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
221 NSImage *img;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
222 SDL_Surface *mergedSurface;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
223 Uint8 *surfPtr;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
224 int i,j,masksize;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
225 NSAutoreleasePool *pool;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
226 SDL_Rect rrect;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
227 NSSize imgSize = {icon->w, icon->h};
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
228 pool = [ [ NSAutoreleasePool alloc ] init ];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
229 SDL_GetClipRect(icon, &rrect);
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
230 /* create a big endian RGBA surface */
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
231 mergedSurface = SDL_CreateRGBSurface(SDL_SWSURFACE|SDL_SRCALPHA,
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
232 icon->w, icon->h, 32, 0xff<<24, 0xff<<16, 0xff<<8, 0xff<<0);
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
233 if (mergedSurface==NULL) { NSLog(@"Error creating surface for
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
234 merge"); goto freePool; }
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
235 if (SDL_BlitSurface(icon,&rrect,mergedSurface,&rrect)) {
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
236 NSLog(@"Error blitting to mergedSurface");
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
237 goto freePool;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
238 }
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
239 if (mask) {
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
240 masksize=icon->w*icon->h;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
241 surfPtr = (Uint8 *)mergedSurface->pixels;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
242 #define ALPHASHIFT 3
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
243 for (i=0;i<masksize;i+=8)
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
244 for (j=0;j<8;j++)
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
245 surfPtr[ALPHASHIFT+((i+j)<<2)]=(mask[i>>3]&(1<<(7-j)))?0xFF:0x00;
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
246 }
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
247 imgrep = [[NSBitmapImageRep alloc]
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
248 initWithBitmapDataPlanes:(unsigned char **)&mergedSurface->pixels
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
249 pixelsWide:icon->w pixelsHigh:icon->h bitsPerSample:8 samplesPerPixel:4
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
250 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
251 bytesPerRow:icon->w<<2 bitsPerPixel:32];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
252 img = [[NSImage alloc] initWithSize:imgSize];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
253 [img addRepresentation: imgrep];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
254 [NSApp setApplicationIconImage:img];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
255 [img release];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
256 [imgrep release];
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
257 SDL_FreeSurface(mergedSurface);
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
258 freePool:
4125b9859c71 Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
259 [pool release];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 static int QZ_IconifyWindow (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 /* Bug! minimize erases the framebuffer */
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
265 if ( ! [ qz_window isMiniaturized ] ) {
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
266 [ qz_window miniaturize:nil ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 return 1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 else {
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 58
diff changeset
270 SDL_SetError ("qz_window already iconified");
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 static 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
277 info->nsWindowPtr = qz_window;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 return 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 }*/
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 switch (grab_mode) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 case SDL_GRAB_QUERY:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 case SDL_GRAB_OFF:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 CGAssociateMouseAndMouseCursorPosition (1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 currentGrabMode = SDL_GRAB_OFF;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 case SDL_GRAB_ON:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 CGAssociateMouseAndMouseCursorPosition (0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 currentGrabMode = SDL_GRAB_ON;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 case SDL_GRAB_FULLSCREEN:
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 269
diff changeset
296
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 return currentGrabMode;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 }