Mercurial > fife-parpg
comparison engine/core/video/cursor.cpp @ 285:37d2b163ef5a
* Replaced preprocessor variable __linux__ with __unix__
* Wrapped entire content of setNativeCursor() within preprocessor directives (should fix #354)
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 19 Jun 2009 17:36:16 +0000 |
parents | 4fa875d06e28 |
children | 64738befdf3b |
comparison
equal
deleted
inserted
replaced
284:ea2c6960bbc8 | 285:37d2b163ef5a |
---|---|
23 #if defined( WIN32 ) | 23 #if defined( WIN32 ) |
24 #include <windows.h> | 24 #include <windows.h> |
25 #include <sdl.h> | 25 #include <sdl.h> |
26 #endif | 26 #endif |
27 | 27 |
28 #if defined( __linux__ ) | 28 #if defined( __unix__ ) |
29 #include <X11/Xcursor/Xcursor.h> | 29 #include <X11/Xcursor/Xcursor.h> |
30 #endif | 30 #endif |
31 | 31 |
32 // 3rd party library includes | 32 // 3rd party library includes |
33 | 33 |
57 #endif | 57 #endif |
58 }; | 58 }; |
59 | 59 |
60 #endif | 60 #endif |
61 | 61 |
62 #if defined( __linux__ ) | 62 #if defined( __unix__ ) |
63 | 63 |
64 // Stops the compiler from confusing it with FIFE:Cursor | 64 // Stops the compiler from confusing it with FIFE:Cursor |
65 typedef Cursor XCursor; | 65 typedef Cursor XCursor; |
66 | 66 |
67 // From SDL_x11mouse.c | 67 // From SDL_x11mouse.c |
209 return 32651; // IDC_HELP; | 209 return 32651; // IDC_HELP; |
210 default: | 210 default: |
211 break; | 211 break; |
212 } | 212 } |
213 | 213 |
214 #elif defined( __linux__ ) | 214 #elif defined( __unix__ ) |
215 switch (cursor_id) { | 215 switch (cursor_id) { |
216 case NC_ARROW: | 216 case NC_ARROW: |
217 return 68; | 217 return 68; |
218 case NC_IBEAM: | 218 case NC_IBEAM: |
219 return 152; | 219 return 152; |
255 #endif | 255 #endif |
256 return cursor_id; | 256 return cursor_id; |
257 } | 257 } |
258 | 258 |
259 void Cursor::setNativeCursor(unsigned int cursor_id) { | 259 void Cursor::setNativeCursor(unsigned int cursor_id) { |
260 #if !defined( WIN32 ) && !defined(__linux__) | 260 #if defined( WIN32 ) || defined(__unix__) |
261 return; | |
262 #endif | |
263 | |
264 // Check if a value in NativeCursors is requested | 261 // Check if a value in NativeCursors is requested |
265 cursor_id = getNativeId(cursor_id); | 262 cursor_id = getNativeId(cursor_id); |
266 | 263 |
267 // Load cursor | 264 // Load cursor |
268 #if defined( __linux__ ) | 265 #if defined( __unix__ ) |
269 static Display* dsp = XOpenDisplay(NULL); | 266 static Display* dsp = XOpenDisplay(NULL); |
270 XCursor xCursor = XcursorShapeLoadCursor(dsp, cursor_id); | 267 XCursor xCursor = XcursorShapeLoadCursor(dsp, cursor_id); |
271 if (xCursor == 0) { | 268 if (xCursor == 0) { |
272 if (m_native_cursor != NULL) { | 269 if (m_native_cursor != NULL) { |
273 SDL_FreeCursor(m_native_cursor); | 270 SDL_FreeCursor(m_native_cursor); |
321 if (GetIconInfo(hIcon, &iconinfo)) { | 318 if (GetIconInfo(hIcon, &iconinfo)) { |
322 curs2->hot_x = static_cast<Sint16>(iconinfo.xHotspot); | 319 curs2->hot_x = static_cast<Sint16>(iconinfo.xHotspot); |
323 curs2->hot_y = static_cast<Sint16>(iconinfo.yHotspot); | 320 curs2->hot_y = static_cast<Sint16>(iconinfo.yHotspot); |
324 } | 321 } |
325 | 322 |
326 #elif defined(__linux__) | 323 #elif defined(__unix__) |
327 cursor->x_cursor = xCursor; | 324 cursor->x_cursor = xCursor; |
328 XSync(dsp, false); | 325 XSync(dsp, false); |
329 #endif | 326 #endif |
330 | 327 |
331 m_native_cursor = curs2; | 328 m_native_cursor = curs2; |
332 SDL_SetCursor(curs2); | 329 SDL_SetCursor(curs2); |
333 | 330 |
331 #endif // WIN32 || __unix__ | |
334 } | 332 } |
335 } | 333 } |