comparison src/video/gem/SDL_gemmouse.c @ 1857:417f2af2bd52

Fix mouse cursor change
author Patrice Mandin <patmandin@gmail.com>
date Wed, 14 Jun 2006 18:57:58 +0000
parents d910939febfa
children c121d94672cb b2d9881c8c88
comparison
equal deleted inserted replaced
1856:21f13c787b46 1857:417f2af2bd52
31 31
32 #include "SDL_mouse.h" 32 #include "SDL_mouse.h"
33 #include "../../events/SDL_events_c.h" 33 #include "../../events/SDL_events_c.h"
34 #include "../SDL_cursor_c.h" 34 #include "../SDL_cursor_c.h"
35 #include "SDL_gemmouse_c.h" 35 #include "SDL_gemmouse_c.h"
36 #include "SDL_gemvideo.h"
36 37
37 /* Defines */ 38 /* Defines */
38 39
39 /*#define DEBUG_VIDEO_GEM 1*/ 40 /*#define DEBUG_VIDEO_GEM 1*/
40 41
41 #define MAXCURWIDTH 16 42 #define MAXCURWIDTH 16
42 #define MAXCURHEIGHT 16 43 #define MAXCURHEIGHT 16
43 44
44 /* The implementation dependent data for the window manager cursor */
45 struct WMcursor {
46 MFORM *mform_p;
47 };
48
49
50 void GEM_FreeWMCursor(_THIS, WMcursor *cursor) 45 void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
51 { 46 {
47 #ifdef DEBUG_VIDEO_GEM
48 printf("sdl:video:gem: free cursor\n");
49 #endif
50
52 if (cursor == NULL) 51 if (cursor == NULL)
53 return; 52 return;
54 53
55 graf_mouse(ARROW, NULL); 54 graf_mouse(ARROW, NULL);
56 55
64 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) 63 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
65 { 64 {
66 WMcursor *cursor; 65 WMcursor *cursor;
67 MFORM *new_mform; 66 MFORM *new_mform;
68 int i; 67 int i;
68
69 #ifdef DEBUG_VIDEO_GEM
70 Uint16 *data1, *mask1;
71
72 printf("sdl:video:gem: create cursor\n");
73 #endif
69 74
70 /* Check the size */ 75 /* Check the size */
71 if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) { 76 if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
72 SDL_SetError("Only cursors of dimension (%dx%d) are allowed", 77 SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
73 MAXCURWIDTH, MAXCURHEIGHT); 78 MAXCURWIDTH, MAXCURHEIGHT);
98 new_mform->mf_bg = 1; 103 new_mform->mf_bg = 1;
99 104
100 for (i=0;i<MAXCURHEIGHT;i++) { 105 for (i=0;i<MAXCURHEIGHT;i++) {
101 new_mform->mf_mask[i]=0; 106 new_mform->mf_mask[i]=0;
102 new_mform->mf_data[i]=0; 107 new_mform->mf_data[i]=0;
108 #ifdef DEBUG_VIDEO_GEM
109 data1 = (Uint16 *) &data[i<<1];
110 mask1 = (Uint16 *) &mask[i<<1];
111 printf("sdl:video:gem: source: line %d: data=0x%04x, mask=0x%04x\n",
112 i, data1[i], mask1[i]);
113 #endif
103 } 114 }
104 115
105 if (w<=8) { 116 if (w<=8) {
106 for (i=0;i<h;i++) { 117 for (i=0;i<h;i++) {
107 new_mform->mf_mask[i]= mask[i]<<8; 118 new_mform->mf_mask[i]= mask[i]<<8;
108 new_mform->mf_data[i]= data[i]<<8; 119 new_mform->mf_data[i]= data[i]<<8;
109 } 120 }
110 } else { 121 } else {
111 for (i=0;i<h;i++) { 122 for (i=0;i<h;i++) {
112 new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1]; 123 new_mform->mf_mask[i]= (mask[i<<1]<<8) | mask[(i<<1)+1];
113 new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1]; 124 new_mform->mf_data[i]= (data[i<<1]<<8) | data[(i<<1)+1];
114 } 125 }
115 } 126 }
116 127
117 #ifdef DEBUG_VIDEO_GEM 128 #ifdef DEBUG_VIDEO_GEM
118 for (i=0; i<h ;i++) { 129 for (i=0; i<h ;i++) {
119 printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, new_mform->mf_mask[i]); 130 printf("sdl:video:gem: cursor: line %d: data=0x%04x, mask=0x%04x\n",
131 i, new_mform->mf_data[i], new_mform->mf_mask[i]);
120 } 132 }
121 133
122 printf("sdl:video:gem: CreateWMCursor(): done\n"); 134 printf("sdl:video:gem: CreateWMCursor(): done\n");
123 #endif 135 #endif
124 136
125 return cursor; 137 return cursor;
126 } 138 }
127 139
128 int GEM_ShowWMCursor(_THIS, WMcursor *cursor) 140 int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
129 { 141 {
130 /* 142 GEM_cursor = cursor;
131 if (cursor == NULL) { 143 if (cursor == NULL) {
132 graf_mouse(M_OFF, NULL); 144 graf_mouse(M_OFF, NULL);
145 GEM_cursor = (void *) -1;
133 } else if (cursor->mform_p) { 146 } else if (cursor->mform_p) {
134 graf_mouse(USER_DEF, cursor->mform_p); 147 graf_mouse(USER_DEF, cursor->mform_p);
135 } 148 }
136 */ 149
137 #ifdef DEBUG_VIDEO_GEM 150 #ifdef DEBUG_VIDEO_GEM
138 printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); 151 printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
139 #endif 152 #endif
140 153
141 return 1; 154 return 1;
155 } 168 }
156 #endif 169 #endif
157 170
158 void GEM_CheckMouseMode(_THIS) 171 void GEM_CheckMouseMode(_THIS)
159 { 172 {
173 #ifdef DEBUG_VIDEO_GEM
174 printf("sdl:video:gem: check mouse mode\n");
175 #endif
176
160 /* If the mouse is hidden and input is grabbed, we use relative mode */ 177 /* If the mouse is hidden and input is grabbed, we use relative mode */
161 if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) && 178 if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) &&
162 /*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */ 179 /*(this->input_grab != SDL_GRAB_OFF) && */ /* Damn GEM can not grab */
163 (SDL_GetAppState() & SDL_APPACTIVE) ) { 180 (SDL_GetAppState() & SDL_APPACTIVE) ) {
164 GEM_mouse_relative = SDL_TRUE; 181 GEM_mouse_relative = SDL_TRUE;