+ XF86VidModeModeInfo** ppXModes; //Enumerated Modes (Don't forget XFree() :))
+ int nNumModes; //Number of modes enumerated....
+
+ if( !XF86VidModeGetAllModeLines((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()), &nNumModes, &ppXModes) )
+ {
+ wxLogSysError(_("Failed to change video mode"));
+ return false;
+ }
+
+ bool bRet = false;
+ if (mode == wxDefaultVideoMode)
+ {
+ bRet = XF86VidModeSwitchToMode((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()),
+ ppXModes[0]) == TRUE;
+
+ for (int i = 0; i < nNumModes; ++i)
+ {
+ wxClearXVM((*ppXModes[i]));
+ // XFree(ppXModes[i]); //supposed to free?
+ }
+ }
+ else
+ {
+ for (int i = 0; i < nNumModes; ++i)
+ {
+ if (!bRet &&
+ ppXModes[i]->hdisplay == mode.w &&
+ ppXModes[i]->vdisplay == mode.h &&
+ wxCRR((*ppXModes[i])) == mode.refresh)
+ {
+ //switch!
+ bRet = XF86VidModeSwitchToMode((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()),
+ ppXModes[i]) == TRUE;
+ }
+ wxClearXVM((*ppXModes[i]));
+ // XFree(ppXModes[i]); //supposed to free?
+ }
+ }
+
+ XFree(ppXModes);
+
+ return bRet;