Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzWM.m @ 761:c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
From: Max Horn
Subject: SDL: video/quartz cleanup
while doing some experimental changes in the quartz code, I was annoyed
by having to recompile that one big .o file over and over again. So I
decided to finally realize one TODO: properly splitting the code over
multiple files :-).
With two exceptions, I didn't make code changes, only rearranged files
and added new headers. Since there are several new files, making a
patch didn't work out so well, so I decided to just send you all the
new & modified files.
The one source change I made is related to showing/hiding the mouse. I
renamed cursor_visible to cursor_should_be_visible and cursor_hidden to
cursor_visible; I think that makes reading the code easier.
Then I added two new functions: QZ_ShowMouse and QZ_HideMouse. They
help manage cursor_visible (the former 'cursor_hidden'). Finally I
replaced the Carbon ShowCursor/HiderCuror calls by [NSCursor hide] and
[NSCursor unhide]. The API docs are not conclusive, but it might be
that with those the "cursor_visible" (former 'cursor_hidden') hack may
not be necessary anymore; however so far I didn't test this hypothesis,
so I left that in.
The other change was to remove in_foreground and use [NSApp isActive]
instead: Manually keeping track of whether we are in the foreground is
error prone. This should work better in some corner cases.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2004 14:55:35 +0000 |
parents | 5d2f027b3349 |
children | 68c8da837fc0 |
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 */ |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
22 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
23 #include "SDL_QuartzVideo.h" |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
24 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
25 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 struct WMcursor { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 Cursor curs; |
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 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
30 void QZ_FreeWMCursor (_THIS, WMcursor *cursor) { |
47
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 if ( cursor != NULL ) |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
33 free (cursor); |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 } |
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 /* 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
|
37 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
|
38 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
|
39 WMcursor *cursor; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
40 int row, bytes; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
41 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
42 /* Allocate the cursor memory */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
43 cursor = (WMcursor *)malloc(sizeof(WMcursor)); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
44 if ( cursor == NULL ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
45 SDL_OutOfMemory(); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
46 return(NULL); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
47 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
48 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
|
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 (w > 16) |
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
51 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 |
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
53 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
|
54 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 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
56 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
|
57 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
58 for ( row=0; row<h; ++row ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
59 memcpy(&cursor->curs.data[row], data, bytes); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
60 data += bytes; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
61 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
62 for ( row=0; row<h; ++row ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
63 memcpy(&cursor->curs.mask[row], mask, bytes); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
64 mask += bytes; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
65 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
324
diff
changeset
|
66 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
|
67 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
|
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 return(cursor); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
70 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
71 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
72 void QZ_ShowMouse (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
73 if (!cursor_visible) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
74 [ NSCursor unhide ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
75 cursor_visible = YES; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
76 } |
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 void QZ_HideMouse (_THIS) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
80 if (cursor_visible) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
81 [ NSCursor hide ]; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
82 cursor_visible = NO; |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
83 } |
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 int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
87 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
88 if ( cursor == NULL) { |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
89 if ( cursor_should_be_visible ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
90 QZ_HideMouse (this); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
91 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
|
92 QZ_ChangeGrabState (this, QZ_HIDECURSOR); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
93 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
94 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
95 else { |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
96 SetCursor(&cursor->curs); |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
97 if ( ! cursor_should_be_visible ) { |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
98 QZ_ShowMouse (this); |
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
99 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
|
100 QZ_ChangeGrabState (this, QZ_SHOWCURSOR); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
101 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
102 } |
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 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
105 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
106 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
107 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 */ |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
114 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
115 /* 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
|
116 void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
117 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
118 *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
|
119 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
120 |
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 /* 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
|
123 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
|
124 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
125 *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
|
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 /* 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
|
129 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
|
130 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
131 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
|
132 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
133 p->y = CGDisplayPixelsHigh (display_id) - p->y - 1; |
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 else { |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
136 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
137 NSPoint newPoint; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
139 newPoint = [ window_view convertPoint:*p toView:[ qz_window contentView ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
140 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
141 *p = newPoint; |
272
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 } |
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 /* 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
|
146 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
|
147 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
148 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
|
149 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
150 p->y = CGDisplayPixelsHigh (display_id) - p->y - 1; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
151 } |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
152 else { |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
153 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
154 NSPoint newPoint; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
155 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
156 newPoint = [ window_view convertPoint:*p fromView:[ qz_window contentView ] ]; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
157 |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
158 *p = newPoint; |
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
159 } |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
160 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
161 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
162 /* 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
|
163 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
|
164 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
165 CGPoint cgp; |
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 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
|
168 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
169 int height; |
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_PrivateSDLToCocoa (this, p); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
172 QZ_PrivateLocalToGlobal (this, p); |
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 height = CGDisplayPixelsHigh (display_id); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
175 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
|
176 } |
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 cgp.x = p->x; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
179 cgp.y = p->y; |
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 return cgp; |
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 |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
184 #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
|
185 /* 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
|
186 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
|
187 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
188 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
|
189 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
190 int height; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
191 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
192 /* 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
|
193 height = CGDisplayPixelsHigh (display_id); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
194 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
|
195 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
196 QZ_PrivateGlobalToLocal (this, p); |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
197 QZ_PrivateCocoaToSDL (this, p); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
198 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
199 } |
683
5d2f027b3349
Date: Sat, 9 Aug 2003 20:14:06 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
615
diff
changeset
|
200 #endif /* Dead code */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
201 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
202 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
|
203 |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
204 NSPoint p; |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
205 CGPoint cgp; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
206 |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
207 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
|
208 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
|
209 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
210 /* 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
|
211 CGSetLocalEventsSuppressionInterval (0.0); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
212 CGWarpMouseCursorPosition (cgp); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
213 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
269
diff
changeset
|
214 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
215 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
|
216 |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
217 /* 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
|
218 if ( ! [ NSApp isActive ] ) |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
219 return; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
220 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
221 /* 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
|
222 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
|
223 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
224 /* 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
|
225 SDL_PrivateMouseMotion (0, 0, x, y); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
226 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
227 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
228 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
|
229 void QZ_CheckMouseMode (_THIS) { } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
230 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
231 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
|
232 |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
233 if ( qz_window != nil ) { |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
234 NSString *string; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
235 if ( title != NULL ) { |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
236 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
|
237 [ qz_window setTitle:string ]; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
238 [ string release ]; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
239 } |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
240 if ( icon != NULL ) { |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
241 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
|
242 [ qz_window setMiniwindowTitle:string ]; |
58
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
243 [ string release ]; |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
244 } |
bd6b0a910a65
* Removed fullscreen menu option from the "Window" menu
Sam Lantinga <slouken@lokigames.com>
parents:
47
diff
changeset
|
245 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
246 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
247 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
248 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
|
249 { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
250 NSBitmapImageRep *imgrep; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
251 NSImage *img; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
252 SDL_Surface *mergedSurface; |
592
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
253 int i,j; |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
254 NSAutoreleasePool *pool; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
255 SDL_Rect rrect; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
256 NSSize imgSize = {icon->w, icon->h}; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
257 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
258 pool = [ [ NSAutoreleasePool alloc ] init ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
259 SDL_GetClipRect(icon, &rrect); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
260 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
261 /* create a big endian RGBA surface */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
262 mergedSurface = SDL_CreateRGBSurface(SDL_SWSURFACE|SDL_SRCALPHA, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
263 icon->w, icon->h, 32, 0xff<<24, 0xff<<16, 0xff<<8, 0xff<<0); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
264 if (mergedSurface==NULL) { |
324
f25f666d609a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
303
diff
changeset
|
265 NSLog(@"Error creating surface for merge"); |
f25f666d609a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
303
diff
changeset
|
266 goto freePool; |
f25f666d609a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
303
diff
changeset
|
267 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
268 |
592
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
269 if (mergedSurface->pitch != |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
270 mergedSurface->format->BytesPerPixel * mergedSurface->w) { |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
271 SDL_SetError ("merged surface has wrong format"); |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
272 SDL_FreeSurface (mergedSurface); |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
273 goto freePool; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
274 } |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
275 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
276 if (SDL_BlitSurface(icon,&rrect,mergedSurface,&rrect)) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
277 NSLog(@"Error blitting to mergedSurface"); |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
278 goto freePool; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
279 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
280 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
281 if (mask) { |
592
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
282 |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
283 Uint32 *pixels = mergedSurface->pixels; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
284 for (i = 0; i < mergedSurface->h; i++) { |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
285 for (j = 0; j < mergedSurface->w; j++) { |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
286 |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
287 int index = i * mergedSurface->w + j; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
288 int mindex = index >> 3; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
289 int bindex = 7 - (index & 0x7); |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
290 |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
291 if (mask[mindex] & (1 << bindex)) |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
292 pixels[index] |= 0x000000FF; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
293 else |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
294 pixels[index] &= 0xFFFFFF00; |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
295 } |
1970e458070d
Fixed crash in SDL_SetIcon() under Quartz (thanks Darrell!)
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
296 } |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
297 } |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
298 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
299 imgrep = [ [ NSBitmapImageRep alloc] |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
300 initWithBitmapDataPlanes:(unsigned char **)&mergedSurface->pixels |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
301 pixelsWide:icon->w pixelsHigh:icon->h bitsPerSample:8 samplesPerPixel:4 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
302 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
303 bytesPerRow:icon->w<<2 bitsPerPixel:32 ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
304 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
305 img = [ [ NSImage alloc ] initWithSize:imgSize ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
306 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
307 [ 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
|
308 [ 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
|
309 |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
310 [ img release ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
311 [ imgrep release ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
312 SDL_FreeSurface(mergedSurface); |
269
4125b9859c71
Added Quartz version of SDL_SetIcon() for MacOS X (thanks Bob)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
313 freePool: |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
314 [pool release]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
315 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
316 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
317 int QZ_IconifyWindow (_THIS) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
318 |
158
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
319 if ( ! [ qz_window isMiniaturized ] ) { |
4382c38dfbee
Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
58
diff
changeset
|
320 [ qz_window miniaturize:nil ]; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
321 return 1; |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
322 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
323 else { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
324 SDL_SetError ("window already iconified"); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
325 return 0; |
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 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
328 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
329 /* |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
330 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
|
331 info->nsWindowPtr = qz_window; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
332 return 0; |
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 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
335 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
|
336 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
337 /* |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
338 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
|
339 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
|
340 */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 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
|
345 else |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
346 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
|
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 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
|
350 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
|
351 grab_state = QZ_UNGRABBED; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
352 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
|
353 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
|
354 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
355 else { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
356 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
|
357 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
358 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
|
359 grab_state = QZ_UNGRABBED; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
360 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
|
361 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
|
362 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
363 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
364 /* 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
|
365 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
|
366 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
367 CGAssociateMouseAndMouseCursorPosition (1); |
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 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
|
370 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
371 CGAssociateMouseAndMouseCursorPosition (1); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
372 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
373 else { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
374 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
|
375 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
376 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
|
377 CGAssociateMouseAndMouseCursorPosition (0); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
378 } |
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 |
761
c5b2b6d2d1fe
Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
683
diff
changeset
|
381 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
|
382 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
383 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
|
384 /*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
|
385 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
386 if ( this->screen == NULL ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
387 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
|
388 return SDL_GRAB_OFF; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
389 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
390 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
391 if ( ! video_set ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
392 /*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
|
393 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
|
394 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
|
395 } |
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 ( 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
|
398 if ( doGrab ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
399 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
|
400 else |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
401 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
|
402 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
403 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
|
404 } |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
501
diff
changeset
|
405 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
406 return current_grab_mode; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
407 } |