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