[AD] DGA driver improvement |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hi,
I've tried to improve the linux DGA driver, more precisely the
interaction between the windowed modes and the window manager:
Allegro will ask the user to choose the window location before entering
the DGA windowed mode.
My little patch works perfectly on my system but as my DGA frame buffer
is linear I don't know if it will be ok with a banked one.
--
Eric Botcazou (ebotcazou@xxxxxxxxxx)
Web Site: http://www.multimania.com/ebotcazou
--- allegro-3.9.31/src/x/xwin.c Sun Jan 30 22:46:58 2000
+++ allegro-3.9.31a/src/x/xwin.c Sat Feb 5 15:49:42 2000
@@ -125,6 +125,8 @@
int _xwin_in_gfx_call = 0;
#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA
+int _xdga_x_ofs=0;
+int _xdga_y_ofs=0;
int _xdga_last_line = -1;
#endif
@@ -2677,6 +2679,33 @@
return 0;
}
+ /* Query window location before the grabbing (windowed modes only) */
+ if (fullscr) {
+ _xdga_x_ofs=0;
+ _xdga_y_ofs=0;
+ }
+ else {
+ char tmp[256];
+ XEvent ev;
+ Window child_win;
+
+ _xwin_safe_copy(tmp, _xwin.window_title, sizeof(tmp));
+ _xwin_safe_copy(_xwin.window_title, "Choose the window location", sizeof(_xwin.window_title));
+ XStoreName(_xwin.display, _xwin.window, _xwin.window_title);
+ XSetWindowBackground(_xwin.display, _xwin.window, BlackPixel(_xwin.display, _xwin.screen));
+ XClearWindow(_xwin.display, _xwin.window);
+ _xwin_private_resize_window(vw, vh);
+
+ do
+ XWindowEvent(_xwin.display, _xwin.window, KeyPressMask, &ev);
+ while (XKeycodeToKeysym(_xwin.display, ev.xkey.keycode, 0) != XK_Return);
+
+ _xwin_safe_copy(_xwin.window_title, tmp, sizeof(_xwin.window_title));
+ XStoreName(_xwin.display, _xwin.window, _xwin.window_title);
+
+ XTranslateCoordinates(_xwin.display, _xwin.window, XDefaultRootWindow(_xwin.display), 0, 0, &_xdga_x_ofs, &_xdga_y_ofs, &child_win);
+ }
+
/* If you want to use debugger, comment grabbing (but there will be no input in Allegro). */
#if 1
/* Grab keyboard and mouse. */
@@ -2731,6 +2760,7 @@
/* I'm not sure that it is correct, but what else? */
memsize *= 1024;
fb_width = v_w * (_xwin.fast_visual_depth / 8);
+ fb_addr += _xdga_x_ofs*(_xwin.fast_visual_depth / 8) + _xdga_y_ofs*fb_width;
/* Free private data. */
if ((modeline.privsize > 0) && (modeline.private != 0))
@@ -2742,20 +2772,21 @@
return 0;
}
- v_h = memsize / fb_width;
- s_w = modeline.hdisplay;
- s_h = modeline.vdisplay;
+ v_w = v_w - _xdga_x_ofs;
+ v_h = memsize / fb_width - _xdga_y_ofs;
+ s_w = modeline.hdisplay - _xdga_x_ofs;
+ s_h = modeline.vdisplay - _xdga_y_ofs;
if ((s_w < w) || (s_h < h) || ((vw - w) > (v_w - s_w)) || ((vh - h) > (v_h - s_h))) {
- ustrcpy(allegro_error, get_config_text("Unsupported screen size"));
+ ustrcpy(allegro_error, get_config_text("Unsupported screen size or location"));
return 0;
}
_xwin.screen_width = w;
_xwin.screen_height = h;
_xwin.screen_depth = depth;
- _xwin.virtual_width = v_w - s_w + w;
- _xwin.virtual_height = v_h - s_h + h;
+ _xwin.virtual_width = vw;
+ _xwin.virtual_height = vh;
if (banksize < memsize) {
/* Banked frame buffer. */
@@ -2877,6 +2908,8 @@
*/
static void _xdga_switch_screen_bank(int line)
{
+ line+=_xdga_y_ofs;
+
if (line != _xdga_last_line) {
XF86DGASetVidPage(_xwin.display, _xwin.screen, _gfx_bank[line]);
_xdga_last_line = line;