Add wxDisplay::GetDepth() and use it for wxDisplayDepth()

Allow getting the depth of any display, not just the primary one, even
though this is not implemented for Unix ports currently.

Mostly do this for consistency with the other display-related functions.
This commit is contained in:
Vadim Zeitlin
2018-10-06 15:28:11 +02:00
parent e834585cf7
commit 24b5e256df
20 changed files with 157 additions and 90 deletions

View File

@@ -34,6 +34,16 @@
static wxRect wxGetMainScreenWorkArea();
namespace
{
inline int wxGetMainScreenDepth()
{
Display* const dpy = wxGetX11Display();
return DefaultDepth(dpy, DefaultScreen (dpy));
}
class wxDisplayImplSingleX11 : public wxDisplayImplSingle
{
public:
@@ -50,6 +60,11 @@ public:
{
return wxGetMainScreenWorkArea();
}
virtual int GetDepth() const wxOVERRIDE
{
return wxGetMainScreenDepth();
}
};
class wxDisplayFactorySingleX11 : public wxDisplayFactorySingle
@@ -61,6 +76,8 @@ protected:
}
};
} // anonymous namespace
#if wxUSE_DISPLAY
#include <X11/extensions/Xinerama.h>
@@ -118,6 +135,14 @@ public:
// we don't currently react to its changes
return IsPrimary() ? wxGetMainScreenWorkArea() : m_rect;
}
virtual int GetDepth() const wxOVERRIDE
{
const wxVideoMode& mode = GetCurrentMode();
if ( mode.bpp )
return mode.bpp;
return wxGetMainScreenDepth();
}
virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const wxOVERRIDE;
virtual wxVideoMode GetCurrentMode() const wxOVERRIDE;
@@ -125,7 +150,6 @@ public:
private:
wxRect m_rect;
int m_depth;
wxDECLARE_NO_COPY_CLASS(wxDisplayImplX11);
};