comparison src/video/x11/SDL_x11dga.c @ 4021:cbad710a6509 SDL-1.2

Fixed bug #437 Some X servers advertise the DGA extension don't support DGA1 anymore.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 08 Jul 2007 20:38:36 +0000
parents d910939febfa
children a1b03ba2fcd0
comparison
equal deleted inserted replaced
4020:33d34b7ce689 4021:cbad710a6509
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 /* This is currently only used to enable DGA mouse. 24 /* This is currently only used to enable DGA mouse.
25 The new fullscreen code makes it very difficult to handle DGA dynamically. 25 There is a completely separate DGA driver that is fullscreen-only.
26 There will be a completely separate DGA driver that is fullscreen-only.
27 */ 26 */
28 27
29 #include "SDL_video.h" 28 #include "SDL_video.h"
30 #include "../SDL_cursor_c.h" 29 #include "../SDL_cursor_c.h"
31 #include "SDL_x11dga_c.h" 30 #include "SDL_x11dga_c.h"
34 int dga_event, dga_error = -1; 33 int dga_event, dga_error = -1;
35 34
36 void X11_EnableDGAMouse(_THIS) 35 void X11_EnableDGAMouse(_THIS)
37 { 36 {
38 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE 37 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE
39 int dga_major, dga_minor; 38 static int use_dgamouse = -1;
40 int use_dgamouse;
41 const char *env_use_dgamouse;
42 39
43 /* Check configuration to see if we should use DGA mouse */ 40 /* Check configuration to see if we should use DGA mouse */
44 use_dgamouse = 1; 41 if ( use_dgamouse < 0 ) {
45 env_use_dgamouse = SDL_getenv("SDL_VIDEO_X11_DGAMOUSE"); 42 int dga_major, dga_minor;
46 if ( env_use_dgamouse ) { 43 int dga_flags;
47 use_dgamouse = atoi(env_use_dgamouse); 44 const char *env_use_dgamouse;
45
46 use_dgamouse = 1;
47 env_use_dgamouse = SDL_getenv("SDL_VIDEO_X11_DGAMOUSE");
48 if ( env_use_dgamouse ) {
49 use_dgamouse = SDL_atoi(env_use_dgamouse);
50 }
51 /* Check for buggy X servers */
52 if ( use_dgamouse && BUGGY_XFREE86(==, 4000) ) {
53 use_dgamouse = 0;
54 }
55 if ( !use_dgamouse || !local_X11 ||
56 !SDL_NAME(XF86DGAQueryExtension)(SDL_Display, &dga_event, &dga_error) ||
57 !SDL_NAME(XF86DGAQueryVersion)(SDL_Display, &dga_major, &dga_minor) ||
58 !SDL_NAME(XF86DGAQueryDirectVideo)(SDL_Display, SDL_Screen, &dga_flags) ||
59 !(dga_flags & XF86DGADirectPresent) ) {
60 use_dgamouse = 0;
61 }
48 } 62 }
49 /* Check for buggy X servers */ 63
50 if ( use_dgamouse && BUGGY_XFREE86(==, 4000) ) { 64 if ( use_dgamouse && !(using_dga & DGA_MOUSE) ) {
51 use_dgamouse = 0;
52 }
53 /* Only use DGA mouse if the cursor is not showing (in relative mode) */
54 if ( use_dgamouse && local_X11 && !(using_dga & DGA_MOUSE) &&
55 SDL_NAME(XF86DGAQueryExtension)(SDL_Display, &dga_event, &dga_error) &&
56 SDL_NAME(XF86DGAQueryVersion)(SDL_Display, &dga_major, &dga_minor) ) {
57 if ( SDL_NAME(XF86DGADirectVideo)(SDL_Display, SDL_Screen, XF86DGADirectMouse) ) { 65 if ( SDL_NAME(XF86DGADirectVideo)(SDL_Display, SDL_Screen, XF86DGADirectMouse) ) {
58 using_dga |= DGA_MOUSE; 66 using_dga |= DGA_MOUSE;
59 } 67 }
60 } 68 }
61 #endif /* SDL_VIDEO_DRIVER_X11_DGAMOUSE */ 69 #endif /* SDL_VIDEO_DRIVER_X11_DGAMOUSE */
63 71
64 /* Argh. Glide resets DGA mouse mode when it makes the context current! */ 72 /* Argh. Glide resets DGA mouse mode when it makes the context current! */
65 void X11_CheckDGAMouse(_THIS) 73 void X11_CheckDGAMouse(_THIS)
66 { 74 {
67 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE 75 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE
68 int flags;
69
70 if ( using_dga & DGA_MOUSE ) { 76 if ( using_dga & DGA_MOUSE ) {
71 SDL_NAME(XF86DGAQueryDirectVideo)(SDL_Display, SDL_Screen, &flags); 77 SDL_NAME(XF86DGADirectVideo)(SDL_Display,SDL_Screen,XF86DGADirectMouse);
72 if ( ! (flags & XF86DGADirectMouse) ) {
73 SDL_NAME(XF86DGADirectVideo)(SDL_Display,SDL_Screen,XF86DGADirectMouse);
74 }
75 } 78 }
76 #endif 79 #endif
77 } 80 }
78 81
79 void X11_DisableDGAMouse(_THIS) 82 void X11_DisableDGAMouse(_THIS)