X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f29cfd7775c13ca8f59361624b1d2a35397e125b..9175b26272dc4f9062bf268fa916f5b7a21d1dc6:/src/msw/display.cpp diff --git a/src/msw/display.cpp b/src/msw/display.cpp index 2758483bba..56845df6e8 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -3,9 +3,10 @@ // Purpose: MSW Implementation of wxDisplay class // Author: Royce Mitchell III // Modified by: VZ (resolutions enumeration/change support, DirectDraw, ...) +// Ryan Norton (IsPrimary override) // Created: 06/21/02 // RCS-ID: $Id$ -// Copyright: (c) wxWindows team +// Copyright: (c) wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -55,6 +56,10 @@ #pragma warning(disable:4706) #endif +// with mingw32, we must include windows.h first and it doesn't hurt with other +// compilers +#include + #include #ifdef _MSC_VER @@ -216,7 +221,7 @@ wxDDEnumExCallback(GUID *pGuid, return true; } -HRESULT WINAPI wxDDEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc, +HRESULT WINAPI wxDDEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext) { // we need at least the mode size @@ -242,12 +247,16 @@ HRESULT WINAPI wxDDEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc, // initialize gs_displays using DirectX functions static bool DoInitDirectX() { +#if wxUSE_LOG // suppress the errors if ddraw.dll is not found wxLog::EnableLogging(false); +#endif wxDynamicLibrary dllDX(_T("ddraw.dll")); - wxLog::EnableLogging(true); +#if wxUSE_LOG + wxLog::EnableLogging(); +#endif if ( !dllDX.IsLoaded() ) return false; @@ -373,10 +382,12 @@ size_t wxDisplayBase::GetCount() { InitDisplays(); - // I'm not sure if they really always return the same thing and if this is - // not true I'd like to know in which situation does it happen - wxASSERT_MSG( gs_displays->GetCount() == (size_t)::GetSystemMetrics(SM_CMONITORS), - _T("So how many displays does this system have?") ); + //RN: FIXME: This is wrong - the display info array should reload after every call + //to GetCount() - otherwise it will not be accurate. + //The user can change the number of displays in display properties/settings + //after GetCount or similar is called and really mess this up... + //wxASSERT_MSG( gs_displays->GetCount() == (size_t)::GetSystemMetrics(SM_CMONITORS), + // _T("So how many displays does this system have?") ); return gs_displays->GetCount(); } @@ -540,6 +551,30 @@ wxString wxDisplay::GetNameForEnumSettings() const return name; } +// ---------------------------------------------------------------------------- +// determine if this is the primary display +// ---------------------------------------------------------------------------- + +bool wxDisplay::IsPrimary() const +{ + wxDisplayInfo& dpyInfo = (*gs_displays)[m_index]; + + MONITORINFOEX monInfo; + wxZeroMemory(monInfo); + monInfo.cbSize = sizeof(monInfo); + + // NB: Cast from MONITORINFOEX* to MONITORINFO* is done because + // Mingw headers - unlike the ones from Microsoft's Platform SDK - + // don't derive the former from the latter in C++ mode and so + // the pointer's type is not converted implicitly. + if ( !::GetMonitorInfo(dpyInfo.m_hmon, (LPMONITORINFO)&monInfo) ) + { + wxLogLastError(_T("GetMonitorInfo")); + } + + return (monInfo.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY; +} + // ---------------------------------------------------------------------------- // video modes enumeration // ---------------------------------------------------------------------------- @@ -654,7 +689,7 @@ bool wxDisplay::DoChangeModeDirectX(const wxVideoMode& mode) return false; } - + return true; }