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 GeometryChanged (const QRect &Geometry)
 

Signals

void CurrentScreenChanged (QScreen *qScreen)
 
void ScreenCountChanged (int Screens)
 

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)
 
int GetRefreshInterval (int Fallback)
 
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)
 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 180 of file mythdisplay.cpp.

Referenced by AcquireRelease().

◆ ~MythDisplay()

MythDisplay::~MythDisplay ( )
overrideprotected

Definition at line 195 of file mythdisplay.cpp.

Member Function Documentation

◆ AcquireRelease()

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

◆ GetDescription()

QStringList MythDisplay::GetDescription ( void  )
static

Definition at line 126 of file mythdisplay.cpp.

Referenced by StatusBox::doDisplayStatus().

◆ VideoModesAvailable()

virtual bool MythDisplay::VideoModesAvailable ( void  )
inlinevirtual

Reimplemented in MythDisplayRPI, MythDisplayX11, and MythDisplayOSX.

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)
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 1046 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 447 of file mythdisplay.cpp.

Referenced by GetAspectRatio(), GetDescription(), GetDesiredScreen(), InitScreenBounds(), and VideoOutWindow::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 290 of file mythdisplay.cpp.

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

◆ GetScreenCount()

int MythDisplay::GetScreenCount ( void  )
static

◆ GetPixelAspectRatio()

double MythDisplay::GetPixelAspectRatio ( void  )

Definition at line 259 of file mythdisplay.cpp.

Referenced by MythUIHelperPrivate::StoreGUIsettings().

◆ GetGUIResolution()

QSize MythDisplay::GetGUIResolution ( void  )

Definition at line 268 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 613 of file mythdisplay.cpp.

Referenced by TV::DoEditSchedule(), MythVideoOutput::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 622 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 698 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 633 of file mythdisplay.cpp.

Referenced by MythVideoOutput::ResizeForVideo().

◆ GetResolution()

QSize MythDisplay::GetResolution ( void  )

◆ GetPhysicalSize()

QSize MythDisplay::GetPhysicalSize ( void  )

Definition at line 960 of file mythdisplay.cpp.

◆ GetRefreshRate()

double MythDisplay::GetRefreshRate ( void  )

Definition at line 729 of file mythdisplay.cpp.

Referenced by GetDescription().

◆ GetRefreshInterval()

int MythDisplay::GetRefreshInterval ( int  Fallback)

Definition at line 734 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 782 of file mythdisplay.cpp.

Referenced by GetDescription(), VideoOutWindow::Init(), MythVideoOutput::InitDisplayMeasurements(), and MythVideoOutput::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 857 of file mythdisplay.cpp.

Referenced by GetAspectRatio().

◆ GetEDID()

MythEDID & MythDisplay::GetEDID ( void  )

Definition at line 843 of file mythdisplay.cpp.

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

◆ GetRefreshRates()

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

Definition at line 743 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 383 of file mythdisplay.cpp.

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

◆ PrimaryScreenChanged

void MythDisplay::PrimaryScreenChanged ( QScreen *  qScreen)
staticslot

Definition at line 396 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenAdded

void MythDisplay::ScreenAdded ( QScreen *  qScreen)
slot

Definition at line 401 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenRemoved

void MythDisplay::ScreenRemoved ( QScreen *  qScreen)
slot

Definition at line 407 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ GeometryChanged

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

Definition at line 413 of file mythdisplay.cpp.

Referenced by MythDisplay(), and ScreenChanged().

◆ CurrentScreenChanged

void MythDisplay::CurrentScreenChanged ( QScreen *  qScreen)
signal

◆ ScreenCountChanged

void MythDisplay::ScreenCountChanged ( int  Screens)
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 MythDisplayRPI, MythDisplayX11, MythDisplayDRM, MythDisplayOSX, MythDisplayWindows, and MythDisplayAndroid.

Definition at line 425 of file mythdisplay.cpp.

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

◆ SwitchToVideoMode()

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

Reimplemented in MythDisplayRPI, MythDisplayX11, and MythDisplayOSX.

Definition at line 754 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 213 of file mythdisplay.cpp.

Referenced by MythMainWindow::Init().

◆ GetDesiredScreen()

QScreen * MythDisplay::GetDesiredScreen ( void  )
staticprotected

Definition at line 295 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 564 of file mythdisplay.cpp.

Referenced by Initialise(), and SetWidget().

◆ WaitForScreenChange()

void MythDisplay::WaitForScreenChange ( void  )
protected

Definition at line 965 of file mythdisplay.cpp.

Referenced by SwitchToGUI(), and SwitchToVideo().

◆ WaitForNewScreen()

void MythDisplay::WaitForNewScreen ( void  )
protected

Definition at line 984 of file mythdisplay.cpp.

Referenced by SetWidget().

◆ PauseForModeSwitch()

void MythDisplay::PauseForModeSwitch ( void  )
staticprivate

Definition at line 1004 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 82 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 85 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 89 of file mythdisplay.h.

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

◆ m_window

QWindow* MythDisplay::m_window { nullptr }
protected

Definition at line 90 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 98 of file mythdisplay.h.

Referenced by Initialise(), and SetWidget().

◆ m_firstScreenChange

bool MythDisplay::m_firstScreenChange { true }
private

Definition at line 99 of file mythdisplay.h.

Referenced by SetWidget().

◆ m_screenBounds

QRect MythDisplay::m_screenBounds { }
private

Definition at line 100 of file mythdisplay.h.

Referenced by GetScreenBounds(), and InitScreenBounds().

◆ m_desktopMode

MythDisplayMode MythDisplay::m_desktopMode { }
private

Definition at line 101 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToDesktop().

◆ m_guiMode

MythDisplayMode MythDisplay::m_guiMode { }
private

Definition at line 102 of file mythdisplay.h.

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

◆ m_videoMode

MythDisplayMode MythDisplay::m_videoMode { }
private

Definition at line 103 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().

◆ m_overrideVideoModes

DisplayModeMap MythDisplay::m_overrideVideoModes { }
private

Definition at line 104 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().


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