comparison src/video/x11/SDL_x11mouse.c @ 1575:3ba88cb7eb1b

Updated dynamic X11 code. See details in Bugzilla #170.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 22 Mar 2006 05:00:59 +0000
parents d910939febfa
children 5b0805ceb50f
comparison
equal deleted inserted replaced
1574:0fd72308659e 1575:3ba88cb7eb1b
39 39
40 void X11_FreeWMCursor(_THIS, WMcursor *cursor) 40 void X11_FreeWMCursor(_THIS, WMcursor *cursor)
41 { 41 {
42 if ( SDL_Display != NULL ) { 42 if ( SDL_Display != NULL ) {
43 SDL_Lock_EventThread(); 43 SDL_Lock_EventThread();
44 pXFreeCursor(SDL_Display, cursor->x_cursor); 44 XFreeCursor(SDL_Display, cursor->x_cursor);
45 pXSync(SDL_Display, False); 45 XSync(SDL_Display, False);
46 SDL_Unlock_EventThread(); 46 SDL_Unlock_EventThread();
47 } 47 }
48 SDL_free(cursor); 48 SDL_free(cursor);
49 } 49 }
50 50
94 94
95 /* Prevent the event thread from running while we use the X server */ 95 /* Prevent the event thread from running while we use the X server */
96 SDL_Lock_EventThread(); 96 SDL_Lock_EventThread();
97 97
98 /* Create the data image */ 98 /* Create the data image */
99 data_image = pXCreateImage(SDL_Display, 99 data_image = XCreateImage(SDL_Display,
100 DefaultVisual(SDL_Display, SDL_Screen), 100 DefaultVisual(SDL_Display, SDL_Screen),
101 1, XYBitmap, 0, x_data, w, h, 8, w/8); 101 1, XYBitmap, 0, x_data, w, h, 8, w/8);
102 data_image->byte_order = MSBFirst; 102 data_image->byte_order = MSBFirst;
103 data_image->bitmap_bit_order = MSBFirst; 103 data_image->bitmap_bit_order = MSBFirst;
104 data_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1); 104 data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
105 105
106 /* Create the data mask */ 106 /* Create the data mask */
107 mask_image = pXCreateImage(SDL_Display, 107 mask_image = XCreateImage(SDL_Display,
108 DefaultVisual(SDL_Display, SDL_Screen), 108 DefaultVisual(SDL_Display, SDL_Screen),
109 1, XYBitmap, 0, x_mask, w, h, 8, w/8); 109 1, XYBitmap, 0, x_mask, w, h, 8, w/8);
110 mask_image->byte_order = MSBFirst; 110 mask_image->byte_order = MSBFirst;
111 mask_image->bitmap_bit_order = MSBFirst; 111 mask_image->bitmap_bit_order = MSBFirst;
112 mask_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1); 112 mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
113 113
114 /* Create the graphics context */ 114 /* Create the graphics context */
115 GCvalues.function = GXcopy; 115 GCvalues.function = GXcopy;
116 GCvalues.foreground = ~0; 116 GCvalues.foreground = ~0;
117 GCvalues.background = 0; 117 GCvalues.background = 0;
118 GCvalues.plane_mask = AllPlanes; 118 GCvalues.plane_mask = AllPlanes;
119 GCcursor = pXCreateGC(SDL_Display, data_pixmap, 119 GCcursor = XCreateGC(SDL_Display, data_pixmap,
120 (GCFunction|GCForeground|GCBackground|GCPlaneMask), 120 (GCFunction|GCForeground|GCBackground|GCPlaneMask),
121 &GCvalues); 121 &GCvalues);
122 122
123 /* Blit the images to the pixmaps */ 123 /* Blit the images to the pixmaps */
124 pXPutImage(SDL_Display, data_pixmap, GCcursor, data_image, 124 XPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
125 0, 0, 0, 0, w, h); 125 0, 0, 0, 0, w, h);
126 pXPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image, 126 XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
127 0, 0, 0, 0, w, h); 127 0, 0, 0, 0, w, h);
128 pXFreeGC(SDL_Display, GCcursor); 128 XFreeGC(SDL_Display, GCcursor);
129 /* These free the x_data and x_mask memory pointers */ 129 /* These free the x_data and x_mask memory pointers */
130 pXDestroyImage(data_image); 130 XDestroyImage(data_image);
131 pXDestroyImage(mask_image); 131 XDestroyImage(mask_image);
132 132
133 /* Create the cursor */ 133 /* Create the cursor */
134 cursor->x_cursor = pXCreatePixmapCursor(SDL_Display, data_pixmap, 134 cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap,
135 mask_pixmap, &black, &white, hot_x, hot_y); 135 mask_pixmap, &black, &white, hot_x, hot_y);
136 pXFreePixmap(SDL_Display, data_pixmap); 136 XFreePixmap(SDL_Display, data_pixmap);
137 pXFreePixmap(SDL_Display, mask_pixmap); 137 XFreePixmap(SDL_Display, mask_pixmap);
138 138
139 /* Release the event thread */ 139 /* Release the event thread */
140 pXSync(SDL_Display, False); 140 XSync(SDL_Display, False);
141 SDL_Unlock_EventThread(); 141 SDL_Unlock_EventThread();
142 142
143 return(cursor); 143 return(cursor);
144 } 144 }
145 145
153 /* Set the X11 cursor cursor, or blank if cursor is NULL */ 153 /* Set the X11 cursor cursor, or blank if cursor is NULL */
154 if ( SDL_Window ) { 154 if ( SDL_Window ) {
155 SDL_Lock_EventThread(); 155 SDL_Lock_EventThread();
156 if ( cursor == NULL ) { 156 if ( cursor == NULL ) {
157 if ( SDL_BlankCursor != NULL ) { 157 if ( SDL_BlankCursor != NULL ) {
158 pXDefineCursor(SDL_Display, SDL_Window, 158 XDefineCursor(SDL_Display, SDL_Window,
159 SDL_BlankCursor->x_cursor); 159 SDL_BlankCursor->x_cursor);
160 } 160 }
161 } else { 161 } else {
162 pXDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor); 162 XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
163 } 163 }
164 pXSync(SDL_Display, False); 164 XSync(SDL_Display, False);
165 SDL_Unlock_EventThread(); 165 SDL_Unlock_EventThread();
166 } 166 }
167 return(1); 167 return(1);
168 } 168 }
169 169
176 leave physical cursor at center of screen if 176 leave physical cursor at center of screen if
177 mouse hidden and grabbed */ 177 mouse hidden and grabbed */
178 SDL_PrivateMouseMotion(0, 0, x, y); 178 SDL_PrivateMouseMotion(0, 0, x, y);
179 } else { 179 } else {
180 SDL_Lock_EventThread(); 180 SDL_Lock_EventThread();
181 pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y); 181 XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
182 pXSync(SDL_Display, False); 182 XSync(SDL_Display, False);
183 SDL_Unlock_EventThread(); 183 SDL_Unlock_EventThread();
184 } 184 }
185 } 185 }
186 186
187 /* Sets the mouse acceleration from a string of the form: 187 /* Sets the mouse acceleration from a string of the form:
215 } else { 215 } else {
216 mouse_param = NULL; 216 mouse_param = NULL;
217 } 217 }
218 } 218 }
219 if ( mouse_param_buf ) { 219 if ( mouse_param_buf ) {
220 pXChangePointerControl(SDL_Display, True, True, 220 XChangePointerControl(SDL_Display, True, True,
221 accel_value[0], accel_value[1], accel_value[2]); 221 accel_value[0], accel_value[1], accel_value[2]);
222 SDL_free(mouse_param_buf); 222 SDL_free(mouse_param_buf);
223 } 223 }
224 } 224 }
225 225
248 if ( ! (using_dga & DGA_MOUSE) ) { 248 if ( ! (using_dga & DGA_MOUSE) ) {
249 char *xmouse_accel; 249 char *xmouse_accel;
250 250
251 SDL_GetMouseState(&mouse_last.x, &mouse_last.y); 251 SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
252 /* Use as raw mouse mickeys as possible */ 252 /* Use as raw mouse mickeys as possible */
253 pXGetPointerControl(SDL_Display, 253 XGetPointerControl(SDL_Display,
254 &mouse_accel.numerator, 254 &mouse_accel.numerator,
255 &mouse_accel.denominator, 255 &mouse_accel.denominator,
256 &mouse_accel.threshold); 256 &mouse_accel.threshold);
257 xmouse_accel=SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL"); 257 xmouse_accel=SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL");
258 if ( xmouse_accel ) { 258 if ( xmouse_accel ) {
264 } else { 264 } else {
265 if ( mouse_relative ) { 265 if ( mouse_relative ) {
266 if ( using_dga & DGA_MOUSE ) { 266 if ( using_dga & DGA_MOUSE ) {
267 X11_DisableDGAMouse(this); 267 X11_DisableDGAMouse(this);
268 } else { 268 } else {
269 pXChangePointerControl(SDL_Display, True, True, 269 XChangePointerControl(SDL_Display, True, True,
270 mouse_accel.numerator, 270 mouse_accel.numerator,
271 mouse_accel.denominator, 271 mouse_accel.denominator,
272 mouse_accel.threshold); 272 mouse_accel.threshold);
273 } 273 }
274 mouse_relative = 0; 274 mouse_relative = 0;