52 |
|
#include <X11/extensions/xf86dga.h> |
53 |
|
#endif |
54 |
|
|
55 |
+ |
#if ENABLE_XF86_VIDMODE |
56 |
+ |
#include <X11/extensions/xf86vmode.h> |
57 |
+ |
#endif |
58 |
+ |
|
59 |
|
#if ENABLE_FBDEV_DGA |
60 |
|
#include <sys/mman.h> |
61 |
|
#endif |
86 |
|
static pthread_t redraw_thread; // Redraw thread |
87 |
|
|
88 |
|
static bool has_dga = false; // Flag: Video DGA capable |
89 |
+ |
static bool has_vidmode = false; // Flag: VidMode extension available |
90 |
|
|
91 |
|
static bool ctrl_down = false; // Flag: Ctrl key pressed |
92 |
|
static bool caps_on = false; // Flag: Caps Lock on |
139 |
|
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
140 |
|
static int fbdev_fd; |
141 |
|
|
142 |
+ |
#if ENABLE_XF86_VIDMODE |
143 |
+ |
// Variables for XF86 VidMode support |
144 |
+ |
static XF86VidModeModeInfo **x_video_modes; // Array of all available modes |
145 |
+ |
static int num_x_video_modes; |
146 |
+ |
#endif |
147 |
+ |
|
148 |
|
|
149 |
|
// Prototypes |
150 |
|
static void *redraw_func(void *arg); |
493 |
|
// Set relative mouse mode |
494 |
|
ADBSetRelMouseMode(true); |
495 |
|
|
496 |
+ |
#if ENABLE_XF86_VIDMODE |
497 |
+ |
// Switch to best mode |
498 |
+ |
if (has_vidmode) { |
499 |
+ |
int best = 0; |
500 |
+ |
for (int i=1; i<num_x_video_modes; i++) { |
501 |
+ |
if (x_video_modes[i]->hdisplay >= width && x_video_modes[i]->vdisplay >= height && |
502 |
+ |
x_video_modes[i]->hdisplay <= x_video_modes[best]->hdisplay && x_video_modes[i]->vdisplay <= x_video_modes[best]->vdisplay) { |
503 |
+ |
best = i; |
504 |
+ |
} |
505 |
+ |
} |
506 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[best]); |
507 |
+ |
XF86VidModeSetViewPort(x_display, screen, 0, 0); |
508 |
+ |
} |
509 |
+ |
#endif |
510 |
+ |
|
511 |
|
// Create window |
512 |
|
XSetWindowAttributes wattr; |
513 |
|
wattr.event_mask = eventmask = dga_eventmask; |
661 |
|
else |
662 |
|
has_dga = false; |
663 |
|
#endif |
664 |
< |
|
664 |
> |
|
665 |
|
#if ENABLE_XF86_DGA |
666 |
|
// DGA available? |
667 |
< |
int event_base, error_base; |
668 |
< |
if (XF86DGAQueryExtension(x_display, &event_base, &error_base)) { |
667 |
> |
int dga_event_base, dga_error_base; |
668 |
> |
if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) { |
669 |
|
int dga_flags = 0; |
670 |
|
XF86DGAQueryDirectVideo(x_display, screen, &dga_flags); |
671 |
|
has_dga = dga_flags & XF86DGADirectPresent; |
673 |
|
has_dga = false; |
674 |
|
#endif |
675 |
|
|
676 |
+ |
#if ENABLE_XF86_VIDMODE |
677 |
+ |
// VidMode available? |
678 |
+ |
int vm_event_base, vm_error_base; |
679 |
+ |
has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base); |
680 |
+ |
if (has_vidmode) |
681 |
+ |
XF86VidModeGetAllModeLines(x_display, screen, &num_x_video_modes, &x_video_modes); |
682 |
+ |
#endif |
683 |
+ |
|
684 |
|
// Find black and white colors |
685 |
|
XParseColor(x_display, DefaultColormap(x_display, screen), "rgb:00/00/00", &black); |
686 |
|
XAllocColor(x_display, DefaultColormap(x_display, screen), &black); |
832 |
|
} |
833 |
|
#endif |
834 |
|
|
835 |
+ |
#if ENABLE_XF86_VIDMODE |
836 |
+ |
if (has_vidmode && display_type == DISPLAY_DGA) |
837 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); |
838 |
+ |
#endif |
839 |
+ |
|
840 |
|
#if ENABLE_FBDEV_DGA |
841 |
|
if (display_type == DISPLAY_DGA) { |
842 |
|
XUngrabPointer(x_display, CurrentTime); |