Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_ph_mouse.c @ 2288:e9bcf004c324
Merged fix for bug #482 from SDL 1.2 revision 3492.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 29 Dec 2007 20:13:23 +0000 |
parents | c121d94672cb |
children | 99210400e8b9 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #include "SDL_mouse.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
25 #include "../../events/SDL_events_c.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 #include "../SDL_cursor_c.h" |
0 | 27 #include "SDL_ph_mouse_c.h" |
28 | |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
29 struct WMcursor |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
30 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
31 PhCursorDef_t *ph_cursor; |
0 | 32 }; |
33 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
34 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
35 ph_FreeWMCursor(_THIS, WMcursor * cursor) |
0 | 36 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
37 if (window != NULL) { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
38 SDL_Lock_EventThread(); |
0 | 39 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
40 if (PtSetResource(window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
41 < 0) { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
42 /* TODO: output error msg */ |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
43 } |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
44 |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
45 SDL_Unlock_EventThread(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
46 } |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
47 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
48 SDL_free(cursor); |
0 | 49 } |
50 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
51 WMcursor * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
52 ph_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w, int h, int hot_x, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
53 int hot_y) |
0 | 54 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
55 WMcursor *cursor; |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
56 int clen, i; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
57 unsigned char bit, databit, maskbit; |
0 | 58 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
59 /* Allocate and initialize the cursor memory */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
60 if ((cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor))) == NULL) { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
61 SDL_OutOfMemory(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
62 return (NULL); |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
63 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
64 SDL_memset(cursor, 0, sizeof(WMcursor)); |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
65 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
66 cursor->ph_cursor = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
67 (PhCursorDef_t *) SDL_malloc(sizeof(PhCursorDef_t) + 32 * 4 * 2); |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
68 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
69 if (cursor->ph_cursor == NULL) { |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
70 SDL_SetError("ph_CreateWMCursor(): cursor malloc failed !\n"); |
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
71 return NULL; |
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
72 } |
0 | 73 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
74 SDL_memset(cursor->ph_cursor, 0, (sizeof(PhCursorDef_t) + 32 * 4 * 2)); |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
75 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
76 cursor->ph_cursor->hdr.type = Ph_RDATA_CURSOR; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
77 cursor->ph_cursor->size1.x = (short) w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
78 cursor->ph_cursor->size1.y = (short) h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
79 cursor->ph_cursor->offset1.x = (short) hot_x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
80 cursor->ph_cursor->offset1.y = (short) hot_y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
81 cursor->ph_cursor->bytesperline1 = (char) w / 8; |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
82 cursor->ph_cursor->color1 = Pg_WHITE; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
83 cursor->ph_cursor->size2.x = (short) w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
84 cursor->ph_cursor->size2.y = (short) h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
85 cursor->ph_cursor->offset2.x = (short) hot_x; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
86 cursor->ph_cursor->offset2.y = (short) hot_y; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
87 cursor->ph_cursor->bytesperline2 = (char) w / 8; |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
88 cursor->ph_cursor->color2 = Pg_BLACK; |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
89 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
90 clen = (w / 8) * h; |
0 | 91 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
92 /* Copy the mask and the data to different bitmap planes */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
93 for (i = 0; i < clen; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
94 for (bit = 0; bit < 8; bit++) { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
95 databit = data[i] & (1 << bit); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
96 maskbit = mask[i] & (1 << bit); |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
97 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
98 cursor->ph_cursor->images[i] |= (databit == 0) ? maskbit : 0; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
99 /* If the databit != 0, treat it as a black pixel and |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
100 * ignore the maskbit (can't do an inverted color) */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
101 cursor->ph_cursor->images[i + clen] |= databit; |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
102 } |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
103 } |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
104 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
105 /* #bytes following the hdr struct */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
106 cursor->ph_cursor->hdr.len = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
107 sizeof(PhCursorDef_t) + clen * 2 - sizeof(PhRegionDataHdr_t); |
0 | 108 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
109 return (cursor); |
0 | 110 } |
111 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
112 PhCursorDef_t |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
113 ph_GetWMPhCursor(WMcursor * cursor) |
0 | 114 { |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
115 return (*cursor->ph_cursor); |
0 | 116 } |
117 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
118 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
119 ph_ShowWMCursor(_THIS, WMcursor * cursor) |
0 | 120 { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
121 PtArg_t args[3]; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
122 int nargs = 0; |
0 | 123 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
124 /* Don't do anything if the display is gone */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
125 if (window == NULL) { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
126 return (0); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
127 } |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
128 |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
129 /* looks like photon can't draw mouse cursor in direct mode */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
130 if (this->screen->flags & SDL_FULLSCREEN) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
131 /* disable the fake mouse in the fullscreen OpenGL mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
132 if (this->screen->flags & SDL_INTERNALOPENGL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
133 cursor = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
134 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
135 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
136 } |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
137 } |
0 | 138 |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
139 /* Set the photon cursor, or blank if cursor is NULL */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
140 if (cursor != NULL) { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
141 PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
142 /* Could set next to any PgColor_t value */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
143 PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR, 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
144 PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
145 (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t))); |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
146 nargs = 3; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
147 } else { /* Ph_CURSOR_NONE */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
148 |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
571
diff
changeset
|
149 PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
150 nargs = 1; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
151 } |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
152 |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
153 SDL_Lock_EventThread(); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
154 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
155 if (PtSetResources(window, nargs, args) < 0) { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
156 return (0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
157 } |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
158 |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
159 SDL_Unlock_EventThread(); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
160 |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
380
diff
changeset
|
161 return (1); |
0 | 162 } |
163 | |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
164 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
165 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
166 ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) |
0 | 167 { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
168 short abs_x, abs_y; |
283
3d8b6b9f1e18
Date: Mon, 18 Feb 2002 16:46:59 +1200
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
169 |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
170 SDL_Lock_EventThread(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
171 PtGetAbsPosition(window, &abs_x, &abs_y); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
172 PhMoveCursorAbs(PhInputGroup(NULL), x + abs_x, y + abs_y); |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
173 SDL_Unlock_EventThread(); |
0 | 174 } |
175 | |
176 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
177 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
178 ph_CheckMouseMode(_THIS) |
0 | 179 { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
180 /* If the mouse is hidden and input is grabbed, we use relative mode */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
181 if (!(SDL_cursorstate & CURSOR_VISIBLE) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
182 && (this->input_grab != SDL_GRAB_OFF)) { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
183 mouse_relative = 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
184 } else { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
185 mouse_relative = 0; |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
186 } |
0 | 187 } |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
188 |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
189 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
190 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
191 ph_UpdateMouse(_THIS) |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
192 { |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
193 PhCursorInfo_t phcursor; |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
194 short abs_x; |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
195 short abs_y; |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
196 |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
197 /* Lock the event thread, in multi-threading environments */ |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
198 SDL_Lock_EventThread(); |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
199 |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
200 /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */ |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
201 PtGetAbsPosition(window, &abs_x, &abs_y); |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
202 PhQueryCursor(PhInputGroup(NULL), &phcursor); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
203 if (((phcursor.pos.x >= abs_x) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
204 && (phcursor.pos.x <= abs_x + this->screen->w)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
205 && ((phcursor.pos.y >= abs_y) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
206 && (phcursor.pos.y <= abs_y + this->screen->h))) { |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
207 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
208 SDL_PrivateMouseMotion(0, 0, phcursor.pos.x - abs_x, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
209 phcursor.pos.y - abs_y); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
210 } else { |
701
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
211 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
212 } |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
213 |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
214 /* Unlock the event thread, in multi-threading environments */ |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
215 SDL_Unlock_EventThread(); |
aaf3b8af6616
Date: Sat, 30 Aug 2003 16:28:10 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
663
diff
changeset
|
216 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
217 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
218 /* vi: set ts=4 sw=4 expandtab: */ |