X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/505c8ccdb3c1c59eb14b019c4386d1a0b10224b0..d0468e8c29ab10c604a0747fa1799bc30f491588:/src/unix/displayx11.cpp diff --git a/src/unix/displayx11.cpp b/src/unix/displayx11.cpp index 081a954c02..4736e99523 100644 --- a/src/unix/displayx11.cpp +++ b/src/unix/displayx11.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 12/05/02 // RCS-ID: $Id$ -// Copyright: (c) wxWindows team +// Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -119,6 +119,7 @@ wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ), m_priv( new wxDisp 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)); @@ -163,7 +164,7 @@ wxString wxDisplay::GetName() const //free private data common to x (usually s3) servers #define wxClearXVM(vm) if(vm.privsize) XFree(vm.c_private) -//Correct res rate from GLFW, which probably has the perfect license :) +// Correct res rate from GLFW #define wxCRR2(v,dc) (int) (((1000.0f * (float) dc) /*PIXELS PER SECOND */) / ((float) v.htotal * v.vtotal /*PIXELS PER FRAME*/) + 0.5f) #define wxCRR(v) wxCRR2(v,v.dotclock) #define wxCVM2(v, dc) wxVideoMode(v.hdisplay, v.vdisplay, DefaultDepth((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay())), wxCRR2(v,dc)) @@ -215,55 +216,55 @@ wxVideoMode wxDisplay::GetCurrentMode() const bool wxDisplay::ChangeMode(const wxVideoMode& mode) { - //This gets kind of tricky AND complicated :) :\ :( :) + XF86VidModeModeInfo** ppXModes; //Enumerated Modes (Don't forget XFree() :)) + int nNumModes; //Number of modes enumerated.... + + if( !XF86VidModeGetAllModeLines((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()), &nNumModes, &ppXModes) ) { - bool bRet = false; - //Some variables.. - XF86VidModeModeInfo** ppXModes; //Enumerated Modes (Don't forget XFree() :)) - int nNumModes; //Number of modes enumerated.... + wxLogSysError(_("Failed to change video mode")); + return false; + } - if(XF86VidModeGetAllModeLines((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()), &nNumModes, &ppXModes) == TRUE) + bool bRet = false; + if (mode == wxDefaultVideoMode) + { + bRet = XF86VidModeSwitchToMode((Display*)wxGetDisplay(), DefaultScreen((Display*)wxGetDisplay()), + ppXModes[0]) == TRUE; + + for (int i = 0; i < nNumModes; ++i) { - if (mode == wxDefaultVideoMode) + 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[0]) == TRUE; - - for (int i = 0; i < nNumModes; ++i) - { - wxClearXVM((*ppXModes[i])); - // XFree(ppXModes[i]); //supposed to free? - } - XFree(ppXModes); - - return bRet; - } - 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? + ppXModes[i]) == TRUE; } - XFree(ppXModes); - - return bRet; - } - else //OOPS! - { - wxLogSysError(_("Failed to change video mode")); - return false; + wxClearXVM((*ppXModes[i])); + // XFree(ppXModes[i]); //supposed to free? } } - /* - //Brian Victor's patch (X11 can't change bit depth yet), here for reference + + XFree(ppXModes); + + return bRet; +} + + +#else // !HAVE_X11_EXTENSIONS_XF86VMODE_H + +wxArrayVideoModes wxDisplay::GetModes(const wxVideoMode& mode) const +{ Display *disp = (Display*)wxGetDisplay(); int count_return; int* depths = XListDepths(disp, 0, &count_return); @@ -277,16 +278,6 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) } } return modes; - */ -} - - -#else // !HAVE_X11_EXTENSIONS_XF86VMODE_H - -wxArrayVideoModes wxDisplay::GetModes(const wxVideoMode& mode) const -{ - // Not implemented - return wxArrayVideoModes(); } wxVideoMode wxDisplay::GetCurrentMode() const