MythTV  master
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | Friends | List of all members
MythDisplay Class Reference

#include <mythdisplay.h>

Inheritance diagram for MythDisplay:
Inheritance graph
[legend]
Collaboration diagram for MythDisplay:
Collaboration graph
[legend]

Public Slots

virtual void ScreenChanged (QScreen *qScreen)
 The actual screen in use has changed. We must use it. More...
 
static void PrimaryScreenChanged (QScreen *qScreen)
 
void ScreenAdded (QScreen *qScreen)
 
void ScreenRemoved (QScreen *qScreen)
 
void PhysicalDPIChanged (qreal DPI)
 
static void GeometryChanged (const QRect &Geometry)
 

Signals

void CurrentScreenChanged (QScreen *qScreen)
 
void ScreenCountChanged (int Screens)
 
void CurrentDPIChanged (qreal DPI)
 

Public Member Functions

virtual bool VideoModesAvailable (void)
 
virtual bool UsingVideoModes (void)
 
virtual const vector< MythDisplayMode > & GetVideoModes (void)
 
QRect GetScreenBounds (void)
 
QScreen * GetCurrentScreen (void)
 Return a pointer to the screen to use. More...
 
double GetPixelAspectRatio (void)
 
QSize GetGUIResolution (void)
 
bool NextModeIsLarger (QSize Size)
 Check whether the next mode is larger in size than the current mode. More...
 
void SwitchToDesktop (void)
 Return the screen to the original desktop video mode. More...
 
bool SwitchToGUI (bool Wait=false)
 Switches to the GUI resolution. More...
 
bool SwitchToVideo (QSize Size, double Rate=0.0)
 Switches to the resolution and refresh rate defined in the database for the specified video resolution and frame rate. More...
 
QSize GetResolution (void)
 
QSize GetPhysicalSize (void)
 
double GetRefreshRate (void) const
 
int GetRefreshInterval (int Fallback) const
 
double GetAspectRatio (QString &Source, bool IgnoreModeOverride=false)
 Returns current screen aspect ratio. More...
 
double EstimateVirtualAspectRatio (void)
 Estimate the overall display aspect ratio for multi screen setups. More...
 
MythEDIDGetEDID (void)
 
std::vector< double > GetRefreshRates (QSize Size)
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter (const QString &debugName, bool logDebug=true)
 Creates reference counter with an initial value of 1. More...
 
virtual int IncrRef (void)
 Increments reference count. More...
 
virtual int DecrRef (void)
 Decrements reference count and deletes on 0. More...
 

Static Public Member Functions

static MythDisplayAcquireRelease (bool Acquire=true)
 
static QStringList GetDescription (void)
 
static void ConfigureQtGUI (int SwapInterval=1, const QString &Display=QString())
 Shared static initialistaion code for all MythTV GUI applications. More...
 
static bool SpanAllScreens (void)
 Return true if the MythTV windows should span all screens. More...
 
static QString GetExtraScreenInfo (QScreen *qScreen)
 
static int GetScreenCount (void)
 
- Static Public Member Functions inherited from ReferenceCounter
static void PrintDebug (void)
 Print out any leaks if that level of debugging is enabled. More...
 

Protected Member Functions

 MythDisplay ()
 
 ~MythDisplay () override
 
virtual void UpdateCurrentMode (void)
 Retrieve screen details. More...
 
virtual bool SwitchToVideoMode (QSize Size, double Framerate)
 
void DebugModes (void) const
 
void SetWidget (QWidget *MainWindow)
 Set the QWidget and QWindow in use. More...
 
void Initialise (void)
 
void InitScreenBounds (void)
 Get screen size from Qt while respecting the user's multiscreen settings. More...
 
void WaitForScreenChange (void)
 
void WaitForNewScreen (void)
 
- Protected Member Functions inherited from ReferenceCounter
virtual ~ReferenceCounter (void)
 Called on destruction, will warn if object deleted with references in place. More...
 

Static Protected Member Functions

static QScreen * GetDesiredScreen (void)
 
static void DebugScreen (QScreen *qScreen, const QString &Message)
 

Protected Attributes

bool m_waitForModeChanges { true }
 
bool m_modeComplete { false }
 
double m_refreshRate { 0.0 }
 
double m_aspectRatioOverride { 0.0 }
 
QSize m_resolution { 0, 0 }
 
QSize m_physicalSize { 0, 0 }
 
MythEDID m_edid { }
 
QWidget * m_widget { nullptr }
 
QWindow * m_window { nullptr }
 
QScreen * m_screen { nullptr }
 
vector< MythDisplayModem_videoModes { }
 
- Protected Attributes inherited from ReferenceCounter
bool m_logDebug
 This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More...
 
QAtomicInt m_referenceCount {1}
 

Static Private Member Functions

static void PauseForModeSwitch (void)
 

Private Attributes

bool m_initialised { false }
 
bool m_firstScreenChange { true }
 
QRect m_screenBounds { }
 
MythDisplayMode m_desktopMode { }
 
MythDisplayMode m_guiMode { }
 
MythDisplayMode m_videoMode { }
 
DisplayModeMap m_overrideVideoModes { }
 

Friends

class MythMainWindow
 

Detailed Description

MythDisplay is a reference counted, singleton class.

Retrieve a reference to the MythDisplay object by calling AcquireRelease().

A valid pointer is always returned.

Release the reference by calling AcquireRelease(false).

Note
There is no locking in MythDisplay. It should never be used from anywhere other than the main/UI thread.
Bug:
When using Xinerama/virtual screens, we get the correct screen at startup and we successfully move to another screen at the first attempt. Subsequently trying to move back to the original screen does not work. This appears to be an issue with MythMainWindow relying on MythUIHelper for screen coordinates that are not updated and/or subsequent window movements moving the window into the wrong screen. Much of the MythUIHelper code needs to move into MythDisplay.
Todo:
Complete handling of screen changes. We need to handle several cases. Firstly, when the main window is moved (dragged) to a new screen. This generally works but need to check if all display details are updated (VideoOutWindow is currently hooked up to the CurrentScreenChanged signal - so video window sizing should work without issue). Various other parameters need updating though e.g. refresh rates, supported rates etc Secondly, when a new screen is added and the user has configured a multiscreen setup - in which case we might want to move the main window to the new screen. There are various complications here. Currently switching windows is triggered from the settings screens - which initiate a teardown of painter/render/UI etc. We cannot do that from random parts of the UI or during video playback.

Definition at line 18 of file mythdisplay.h.

Constructor & Destructor Documentation

◆ MythDisplay()

MythDisplay::MythDisplay ( )
protected

Definition at line 182 of file mythdisplay.cpp.

Referenced by AcquireRelease().

◆ ~MythDisplay()

MythDisplay::~MythDisplay ( )
overrideprotected

Definition at line 202 of file mythdisplay.cpp.

Member Function Documentation

◆ AcquireRelease()

MythDisplay * MythDisplay::AcquireRelease ( bool  Acquire = true)
static

◆ GetDescription()

QStringList MythDisplay::GetDescription ( void  )
static

Definition at line 132 of file mythdisplay.cpp.

Referenced by StatusBox::doDisplayStatus().

◆ VideoModesAvailable()

virtual bool MythDisplay::VideoModesAvailable ( void  )
inlinevirtual

Reimplemented in MythDisplayX11, MythDisplayRPI, MythDisplayOSX, and MythDisplayMutter.

Definition at line 28 of file mythdisplay.h.

Referenced by AppearanceSettings::AppearanceSettings().

◆ UsingVideoModes()

virtual bool MythDisplay::UsingVideoModes ( void  )
inlinevirtual

◆ GetVideoModes()

const vector< MythDisplayMode > & MythDisplay::GetVideoModes ( void  )
virtual

◆ ConfigureQtGUI()

void MythDisplay::ConfigureQtGUI ( int  SwapInterval = 1,
const QString &  _Display = QString() 
)
static

Shared static initialistaion code for all MythTV GUI applications.

Note
This function must be called before Qt/QPA is initialised i.e. before any call to QApplication.

Definition at line 1061 of file mythdisplay.cpp.

Referenced by main().

◆ SpanAllScreens()

bool MythDisplay::SpanAllScreens ( void  )
static

Return true if the MythTV windows should span all screens.

Definition at line 464 of file mythdisplay.cpp.

Referenced by GetAspectRatio(), GetDescription(), GetDesiredScreen(), InitScreenBounds(), and MythVideoBounds::PopulateGeometry().

◆ GetExtraScreenInfo()

QString MythDisplay::GetExtraScreenInfo ( QScreen *  qScreen)
static

◆ GetScreenBounds()

QRect MythDisplay::GetScreenBounds ( void  )

◆ GetCurrentScreen()

QScreen * MythDisplay::GetCurrentScreen ( void  )

Return a pointer to the screen to use.

This function looks at the users screen preference, and will return that screen if possible. If not, i.e. the screen isn't plugged in, then this function returns the system's primary screen.

Note: There is no special case here for the case of MythTV spanning all screens, as all screen have access to the virtual desktop attributes. The check for spanning screens must be made when the screen size/geometry accessed, and the proper physical/virtual size/geometry retrieved.

Definition at line 297 of file mythdisplay.cpp.

Referenced by GetDescription(), MythMainWindow::GrabWindow(), MythVideoBounds::PopulateGeometry(), and UpdateCurrentMode().

◆ GetScreenCount()

int MythDisplay::GetScreenCount ( void  )
static

◆ GetPixelAspectRatio()

double MythDisplay::GetPixelAspectRatio ( void  )

Definition at line 266 of file mythdisplay.cpp.

Referenced by MythUIHelperPrivate::StoreGUIsettings().

◆ GetGUIResolution()

QSize MythDisplay::GetGUIResolution ( void  )

Definition at line 275 of file mythdisplay.cpp.

Referenced by TV::DoEditSchedule(), and TV::~TV().

◆ NextModeIsLarger()

bool MythDisplay::NextModeIsLarger ( QSize  Size)

Check whether the next mode is larger in size than the current mode.

This is used to allow the caller to force an update of the main window to ensure the window is fully resized and is in no way clipped. Not an issue if the next mode is smaller.

Definition at line 626 of file mythdisplay.cpp.

Referenced by TV::DoEditSchedule(), MythVideoOutputGPU::ResizeForVideo(), and TV::~TV().

◆ SwitchToDesktop()

void MythDisplay::SwitchToDesktop ( void  )

Return the screen to the original desktop video mode.

Note
It is assume the app is exiting once this is called.

Definition at line 635 of file mythdisplay.cpp.

Referenced by SetWidget(), and MythUIHelperPrivate::~MythUIHelperPrivate().

◆ SwitchToGUI()

bool MythDisplay::SwitchToGUI ( bool  Wait = false)

Switches to the GUI resolution.

Definition at line 711 of file mythdisplay.cpp.

Referenced by TV::DoEditSchedule(), MythUIHelper::LoadQtConfig(), and TV::~TV().

◆ SwitchToVideo()

bool MythDisplay::SwitchToVideo ( QSize  Size,
double  Rate = 0.0 
)

Switches to the resolution and refresh rate defined in the database for the specified video resolution and frame rate.

Definition at line 646 of file mythdisplay.cpp.

Referenced by MythVideoOutputGPU::ResizeForVideo().

◆ GetResolution()

QSize MythDisplay::GetResolution ( void  )

◆ GetPhysicalSize()

QSize MythDisplay::GetPhysicalSize ( void  )

Definition at line 975 of file mythdisplay.cpp.

◆ GetRefreshRate()

double MythDisplay::GetRefreshRate ( void  ) const

Definition at line 742 of file mythdisplay.cpp.

Referenced by GetDescription().

◆ GetRefreshInterval()

int MythDisplay::GetRefreshInterval ( int  Fallback) const

Definition at line 747 of file mythdisplay.cpp.

Referenced by MythPlayer::CanSupportDoubleRate(), and MythPlayer::InitAVSync().

◆ GetAspectRatio()

double MythDisplay::GetAspectRatio ( QString &  Source,
bool  IgnoreModeOverride = false 
)

Returns current screen aspect ratio.

For the vast majority of cases we should be using the physical display size to compute the actual aspect ratio.

This is currently overridden by:-

  • a custom, user specified aspect ratio for a given display mode. This feature is considered legacy as I don't believe it should be needed anymore, complicates both the code and the user 'experience' and offers very limited values for the override (4:3 and 16:9).
  • a general override for setups where the aspect ratio is not correctly detected. This generally means exotic multiscreen setups and displays with invalid and/or misleading EDIDs.

If no override is specified and a valid physical aspect ratio cannot be calculated, then we fallback to the screen resolution (i.e. assume square pixels) and finally a guess at 16:9.

Definition at line 795 of file mythdisplay.cpp.

Referenced by GetDescription(), MythVideoBounds::InitBounds(), MythVideoOutputGPU::InitDisplayMeasurements(), and MythVideoOutputGPU::ResizeForVideo().

◆ EstimateVirtualAspectRatio()

double MythDisplay::EstimateVirtualAspectRatio ( void  )

Estimate the overall display aspect ratio for multi screen setups.

Note
This will only work where screens are configured either as a grid (e.g. 2x2) or as a single 'row' or 'column' of screens. Likewise it will fail if the aspect ratios of the displays are not similar and may not work if the display resolutions are significantly different (in a grid type setup).
Untested with a grid layout - anyone have a card with 4 outputs?

Definition at line 872 of file mythdisplay.cpp.

Referenced by GetAspectRatio().

◆ GetEDID()

MythEDID & MythDisplay::GetEDID ( void  )

Definition at line 858 of file mythdisplay.cpp.

Referenced by MythCECAdapter::Open(), and MythDisplayX11::UpdateCurrentMode().

◆ GetRefreshRates()

std::vector< double > MythDisplay::GetRefreshRates ( QSize  Size)

Definition at line 756 of file mythdisplay.cpp.

Referenced by HostRefreshRateComboBoxSetting::GetRefreshRates().

◆ ScreenChanged

void MythDisplay::ScreenChanged ( QScreen *  qScreen)
virtualslot

The actual screen in use has changed. We must use it.

Definition at line 392 of file mythdisplay.cpp.

Referenced by MythDisplayDRM::ScreenChanged(), and SetWidget().

◆ PrimaryScreenChanged

void MythDisplay::PrimaryScreenChanged ( QScreen *  qScreen)
staticslot

Definition at line 413 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenAdded

void MythDisplay::ScreenAdded ( QScreen *  qScreen)
slot

Definition at line 418 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenRemoved

void MythDisplay::ScreenRemoved ( QScreen *  qScreen)
slot

Definition at line 424 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ PhysicalDPIChanged

void MythDisplay::PhysicalDPIChanged ( qreal  DPI)
slot

Definition at line 406 of file mythdisplay.cpp.

Referenced by MythDisplay(), MythVideoBounds::MythVideoBounds(), and ScreenChanged().

◆ GeometryChanged

void MythDisplay::GeometryChanged ( const QRect &  Geometry)
staticslot

Definition at line 430 of file mythdisplay.cpp.

Referenced by MythDisplay(), and ScreenChanged().

◆ CurrentScreenChanged

void MythDisplay::CurrentScreenChanged ( QScreen *  qScreen)
signal

◆ ScreenCountChanged

void MythDisplay::ScreenCountChanged ( int  Screens)
signal

◆ CurrentDPIChanged

void MythDisplay::CurrentDPIChanged ( qreal  DPI)
signal

◆ UpdateCurrentMode()

void MythDisplay::UpdateCurrentMode ( void  )
protectedvirtual

Retrieve screen details.

This is the final fallback when no other platform specifics are available It is usually accurate apart from the refresh rate - which is often rounded down.

Reimplemented in MythDisplayX11, MythDisplayWindows, MythDisplayRPI, MythDisplayOSX, MythDisplayDRM, MythDisplayAndroid, and MythDisplayMutter.

Definition at line 442 of file mythdisplay.cpp.

Referenced by Initialise(), SetWidget(), SwitchToGUI(), SwitchToVideo(), MythDisplayMutter::UpdateCurrentMode(), MythDisplayDRM::UpdateCurrentMode(), MythDisplayOSX::UpdateCurrentMode(), MythDisplayRPI::UpdateCurrentMode(), MythDisplayWindows::UpdateCurrentMode(), and MythDisplayX11::UpdateCurrentMode().

◆ SwitchToVideoMode()

bool MythDisplay::SwitchToVideoMode ( QSize  Size,
double  Framerate 
)
protectedvirtual

Reimplemented in MythDisplayRPI, MythDisplayX11, MythDisplayOSX, and MythDisplayMutter.

Definition at line 767 of file mythdisplay.cpp.

Referenced by SwitchToDesktop(), SwitchToGUI(), and SwitchToVideo().

◆ DebugModes()

void MythDisplay::DebugModes ( void  ) const
protected

◆ SetWidget()

void MythDisplay::SetWidget ( QWidget *  MainWindow)
protected

Set the QWidget and QWindow in use.

Certain platform implementations need to know the QWidget and/or QWindow to access display information. We also connect to the QWindow::screenChanged signal so that we are informed when the window has been moved into a new screen.

Note
We typically call this twice; once before MythMainWindow is shown and once after. This is because we need to try and ensure we are using the correct screen before showing the window, and hence have the correct geometry etc, and once after because the QWindow is sometimes not created until after the widget is shown - and we cannot connect the screenChanged signal until we know the window handle.

Definition at line 220 of file mythdisplay.cpp.

Referenced by MythMainWindow::Init().

◆ GetDesiredScreen()

QScreen * MythDisplay::GetDesiredScreen ( void  )
staticprotected

Definition at line 302 of file mythdisplay.cpp.

Referenced by MythDisplay(), and SetWidget().

◆ DebugScreen()

void MythDisplay::DebugScreen ( QScreen *  qScreen,
const QString &  Message 
)
staticprotected

◆ Initialise()

void MythDisplay::Initialise ( void  )
protected

◆ InitScreenBounds()

void MythDisplay::InitScreenBounds ( void  )
protected

Get screen size from Qt while respecting the user's multiscreen settings.

If the windowing system environment has multiple screens, then use QScreen::virtualSize() to get the size of the virtual desktop. Otherwise QScreen::size() or QScreen::availableSize() will provide the size of an individual screen.

Definition at line 577 of file mythdisplay.cpp.

Referenced by Initialise(), and SetWidget().

◆ WaitForScreenChange()

void MythDisplay::WaitForScreenChange ( void  )
protected

Definition at line 980 of file mythdisplay.cpp.

Referenced by SwitchToGUI(), and SwitchToVideo().

◆ WaitForNewScreen()

void MythDisplay::WaitForNewScreen ( void  )
protected

Definition at line 999 of file mythdisplay.cpp.

Referenced by SetWidget().

◆ PauseForModeSwitch()

void MythDisplay::PauseForModeSwitch ( void  )
staticprivate

Definition at line 1019 of file mythdisplay.cpp.

Referenced by SwitchToVideo().

Friends And Related Function Documentation

◆ MythMainWindow

friend class MythMainWindow
friend

Definition at line 22 of file mythdisplay.h.

Member Data Documentation

◆ m_waitForModeChanges

bool MythDisplay::m_waitForModeChanges { true }
protected

Definition at line 84 of file mythdisplay.h.

Referenced by MythDisplayRPI::MythDisplayRPI(), and WaitForScreenChange().

◆ m_modeComplete

bool MythDisplay::m_modeComplete { false }
protected

◆ m_refreshRate

double MythDisplay::m_refreshRate { 0.0 }
protected

◆ m_aspectRatioOverride

double MythDisplay::m_aspectRatioOverride { 0.0 }
protected

Definition at line 87 of file mythdisplay.h.

Referenced by GetAspectRatio(), SwitchToGUI(), and SwitchToVideo().

◆ m_resolution

QSize MythDisplay::m_resolution { 0, 0 }
protected

◆ m_physicalSize

QSize MythDisplay::m_physicalSize { 0, 0 }
protected

◆ m_edid

MythEDID MythDisplay::m_edid { }
protected

◆ m_widget

QWidget* MythDisplay::m_widget { nullptr }
protected

Definition at line 91 of file mythdisplay.h.

Referenced by SetWidget(), MythDisplayOSX::UpdateCurrentMode(), and WaitForNewScreen().

◆ m_window

QWindow* MythDisplay::m_window { nullptr }
protected

Definition at line 92 of file mythdisplay.h.

Referenced by SetWidget().

◆ m_screen

QScreen* MythDisplay::m_screen { nullptr }
protected

◆ m_videoModes

vector<MythDisplayMode> MythDisplay::m_videoModes { }
protected

◆ m_initialised

bool MythDisplay::m_initialised { false }
private

Definition at line 100 of file mythdisplay.h.

Referenced by Initialise(), and SetWidget().

◆ m_firstScreenChange

bool MythDisplay::m_firstScreenChange { true }
private

Definition at line 101 of file mythdisplay.h.

Referenced by SetWidget().

◆ m_screenBounds

QRect MythDisplay::m_screenBounds { }
private

Definition at line 102 of file mythdisplay.h.

Referenced by GetScreenBounds(), and InitScreenBounds().

◆ m_desktopMode

MythDisplayMode MythDisplay::m_desktopMode { }
private

Definition at line 103 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToDesktop().

◆ m_guiMode

MythDisplayMode MythDisplay::m_guiMode { }
private

Definition at line 104 of file mythdisplay.h.

Referenced by GetGUIResolution(), Initialise(), and SwitchToGUI().

◆ m_videoMode

MythDisplayMode MythDisplay::m_videoMode { }
private

Definition at line 105 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().

◆ m_overrideVideoModes

DisplayModeMap MythDisplay::m_overrideVideoModes { }
private

Definition at line 106 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().


The documentation for this class was generated from the following files: