- Display *disp = (Display*)wxGetDisplay();
-
- if ( XineramaIsActive(disp) )
- {
- XineramaScreenInfo *screenarr;
- int numscreens;
- screenarr = XineramaQueryScreens(disp, &numscreens);
- m_priv->m_rect = wxRect(screenarr[index].x_org, screenarr[index].y_org,
- screenarr[index].width, screenarr[index].height);
- m_priv->m_depth = DefaultDepth(disp, DefaultScreen(disp));
- XFree(screenarr);
- }
- else
- {
- wxSize size = wxGetDisplaySize();
- m_priv->m_rect = wxRect(0, 0, size.GetWidth(), size.GetHeight());
- m_priv->m_depth = wxDisplayDepth();
- }
+ XF86VidModeModeLine VM;
+ int nDotClock;
+ XF86VidModeGetModeLine((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()),
+ &nDotClock, &VM);
+ wxClearXVM(VM);
+ return wxCVM2(VM, nDotClock);
+}
+
+bool wxDisplayImplX11::ChangeMode(const wxVideoMode& mode)
+{
+ 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;