2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
24 #if defined(__APPLE__) && defined(__MACH__)
25 #include <Carbon/Carbon.h>
26 #elif TARGET_API_MAC_CARBON && (UNIVERSAL_INTERFACES_VERSION > 0x0335)
29 #include <Quickdraw.h>
32 /* Routines that are not supported by the Carbon API... */
33 #if !TARGET_API_MAC_CARBON
34 #include <CursorDevices.h>
37 #include "SDL_mouse.h"
38 #include "SDL_macmouse_c.h"
41 /* The implementation dependent data for the window manager cursor */
47 void Mac_FreeWMCursor(_THIS, WMcursor *cursor)
52 WMcursor *Mac_CreateWMCursor(_THIS,
53 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
58 /* Allocate the cursor memory */
59 cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor));
60 if ( cursor == NULL ) {
64 SDL_memset(cursor, 0, sizeof(*cursor));
74 for ( row=0; row<h; ++row ) {
75 SDL_memcpy(&cursor->curs.data[row], data, bytes);
78 for ( row=0; row<h; ++row ) {
79 SDL_memcpy(&cursor->curs.mask[row], mask, bytes);
82 cursor->curs.hotSpot.h = hot_x;
83 cursor->curs.hotSpot.v = hot_y;
85 /* That was easy. :) */
89 int Mac_cursor_showing = 1;
91 int Mac_ShowWMCursor(_THIS, WMcursor *cursor)
93 if ( cursor == NULL ) {
94 if ( Mac_cursor_showing ) {
96 Mac_cursor_showing = 0;
99 SetCursor(&cursor->curs);
100 if ( ! Mac_cursor_showing ) {
102 Mac_cursor_showing = 1;
108 void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
110 #if !TARGET_API_MAC_CARBON
111 CursorDevice *cursordevice;
114 CursorDeviceNextDevice(&cursordevice);
115 if ( cursordevice != nil ) {
123 LocalToGlobal(&where);
125 CursorDeviceMoveTo(cursordevice, where.h, where.v);
127 #endif /* !TARGET_API_MAC_CARBON */