Mercurial > sdl-ios-xcode
annotate src/video/bwindow/SDL_sysmouse.cc @ 1351:82c38796c7ca
Changed X11 header order so it works on Solaris.
Fixes Bugzilla #138.
--ryan.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 08 Feb 2006 20:29:12 +0000 |
parents | 604d73db6802 |
children | c71e05b4dc2e |
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 */ |
22 | |
23 #include <AppKit.h> | |
24 #include <GameKit.h> | |
25 | |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
26 #include "SDL_stdlib.h" |
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
27 #include "SDL_string.h" |
0 | 28 #include "SDL_error.h" |
29 #include "SDL_BWin.h" | |
30 | |
31 extern "C" { | |
32 | |
33 #include "SDL_sysmouse_c.h" | |
34 | |
35 /* Convert bits to padded bytes */ | |
36 #define PADDED_BITS(bits) ((bits+7)/8) | |
37 | |
38 /* The implementation dependent data for the window manager cursor */ | |
39 struct WMcursor { | |
40 char *bits; | |
41 }; | |
42 | |
43 /* Can this be done in the BeOS? */ | |
44 WMcursor *BE_CreateWMCursor(_THIS, | |
45 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | |
46 { | |
47 WMcursor *cursor; | |
48 int allowed_x; | |
49 int allowed_y; | |
50 int run, pad, i; | |
51 char *cptr; | |
52 | |
53 allowed_x = 16; /* BeOS limitation */ | |
54 allowed_y = 16; /* BeOS limitation */ | |
55 if ( (w > allowed_x) || (h > allowed_y) ) { | |
56 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", | |
57 allowed_x, allowed_y); | |
58 return(NULL); | |
59 } | |
60 | |
61 /* Allocate the cursor */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
62 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); |
0 | 63 if ( cursor == NULL ) { |
64 SDL_OutOfMemory(); | |
65 return(NULL); | |
66 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
67 cursor->bits = (char *)SDL_malloc(4+2*((allowed_x/8)*allowed_y)); |
0 | 68 if ( cursor->bits == NULL ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
69 SDL_free(cursor); |
0 | 70 SDL_OutOfMemory(); |
71 return(NULL); | |
72 } | |
73 cursor->bits[0] = allowed_y; /* Size of the cursor */ | |
74 cursor->bits[1] = 1; /* Bit depth of cursor */ | |
75 cursor->bits[2] = hot_y; | |
76 cursor->bits[3] = hot_x; | |
77 cptr = &cursor->bits[4]; | |
78 | |
79 /* Pad out to the normal cursor size */ | |
80 run = PADDED_BITS(w); | |
81 pad = PADDED_BITS(allowed_x)-run; | |
82 for ( i=0; i<h; ++i ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
83 SDL_memcpy(cptr, data, run); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
84 SDL_memset(cptr+run, 0, pad); |
0 | 85 data += run; |
86 cptr += (run+pad); | |
87 } | |
88 for ( ; i<allowed_y; ++i ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
89 SDL_memset(cptr, 0, run+pad); |
0 | 90 cptr += (run+pad); |
91 } | |
92 for ( i=0; i<h; ++i ) { | |
93 /* FIXME: The mask should be OR'd with the data to turn | |
94 inverted color pixels black, since inverted color pixels | |
95 aren't supported under BeOS. | |
96 */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
97 SDL_memcpy(cptr, mask, run); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
98 SDL_memset(cptr+run, 0, pad); |
0 | 99 mask += run; |
100 cptr += (run+pad); | |
101 } | |
102 for ( ; i<allowed_y; ++i ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
103 SDL_memset(cptr, 0, run+pad); |
0 | 104 cptr += (run+pad); |
105 } | |
106 return(cursor); | |
107 } | |
108 | |
109 int BE_ShowWMCursor(_THIS, WMcursor *cursor) | |
110 { | |
111 if ( be_app->Lock() ) { | |
112 if ( cursor == NULL ) { | |
113 if ( SDL_BlankCursor != NULL ) { | |
114 be_app->SetCursor(SDL_BlankCursor->bits); | |
115 } | |
116 } else { | |
117 be_app->SetCursor(cursor->bits); | |
118 } | |
119 be_app->Unlock(); | |
120 } | |
121 return(1); | |
122 } | |
123 | |
124 void BE_FreeWMCursor(_THIS, WMcursor *cursor) | |
125 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
126 SDL_free(cursor->bits); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
127 SDL_free(cursor); |
0 | 128 } |
129 | |
130 /* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */ | |
131 void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | |
132 { | |
133 BPoint pt(x, y); | |
134 SDL_Win->Lock(); | |
135 SDL_Win->ConvertToScreen(&pt); | |
136 SDL_Win->Unlock(); | |
137 set_mouse_position((int32)pt.x, (int32)pt.y); | |
138 } | |
139 | |
140 }; /* Extern C */ |