]> git.tdb.fi Git - libs/gui.git/blobdiff - source/display.cpp
Implement the rest of fullscreen mode (video mode switching, pointer grab)
[libs/gui.git] / source / display.cpp
index 724318a06af3d797efaee820c56e1e62c06cc066..b8e4fbe6119e1ea93645d4fbad9476b080c88040 100644 (file)
@@ -59,19 +59,25 @@ Display::Display(const string &disp_name)
 
        XSetErrorHandler(x_error_handler);
 
+       int screen=DefaultScreen(display);
+
        int nmodes;
        XF86VidModeModeInfo **infos;
-       XF86VidModeGetAllModeLines(display, DefaultScreen(display), &nmodes, &infos);
+       XF86VidModeGetAllModeLines(display, screen, &nmodes, &infos);
        for(int i=0; i<nmodes; ++i)
        {
                XF86VidModeModeInfo &info=*infos[i];
        
-               VideoMode mode;
-               mode.width=info.hdisplay;
-               mode.height=info.vdisplay;
+               VideoMode mode(info.hdisplay, info.vdisplay);
                mode.rate=info.dotclock/(info.htotal*info.vtotal);
                modes.push_back(mode);
        }
+
+       XF86VidModeModeLine modeline;
+       int dotclock;
+       XF86VidModeGetModeLine(display, screen, &dotclock, &modeline);
+       orig_mode=VideoMode(modeline.hdisplay, modeline.vdisplay);
+       orig_mode.rate=dotclock/(modeline.htotal*modeline.vtotal);
 }
 
 Display::~Display()
@@ -102,9 +108,10 @@ void Display::set_mode(const VideoMode &mode)
                XF86VidModeModeInfo &info=*infos[i];
 
                unsigned rate=info.dotclock/(info.htotal*info.vtotal);
-               if(info.hdisplay==mode.width && info.vdisplay==mode.height && rate==mode.rate)
+               if(info.hdisplay==mode.width && info.vdisplay==mode.height && (mode.rate==0 || rate==mode.rate))
                {
                        XF86VidModeSwitchToMode(display, screen, &info);
+                       XF86VidModeSetViewPort(display, screen, 0, 0);
                        return;
                }
        }