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

Signals

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

Public Member Functions

virtual bool VideoModesAvailable ()
 
virtual bool UsingVideoModes ()
 
virtual bool IsPlanar ()
 
virtual const MythDisplayModesGetVideoModes ()
 
QStringList GetDescription ()
 
QRect GetScreenBounds ()
 
QScreen * GetCurrentScreen ()
 Return a pointer to the screen to use. More...
 
double GetPixelAspectRatio ()
 
QSize GetGUIResolution ()
 
bool NextModeIsLarger (QSize Size)
 Check whether the next mode is larger in size than the current mode. More...
 
void SwitchToDesktop ()
 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 ()
 
QSize GetPhysicalSize ()
 
double GetRefreshRate () const
 
std::chrono::microseconds GetRefreshInterval (std::chrono::microseconds Fallback) const
 
double GetAspectRatio (QString &Source, bool IgnoreModeOverride=false)
 Returns current screen aspect ratio. More...
 
double EstimateVirtualAspectRatio ()
 Estimate the overall display aspect ratio for multi screen setups. More...
 
MythEDIDGetEDID ()
 
MythDisplayRates GetRefreshRates (QSize Size)
 
MythHDRPtr GetHDRState ()
 

Static Public Member Functions

static void ConfigureQtGUI (int SwapInterval, const MythCommandLineParser &CmdLine)
 Shared static initialisation code for all MythTV GUI applications. More...
 
static bool SpanAllScreens ()
 Return true if the MythTV windows should span all screens. More...
 
static QString GetExtraScreenInfo (QScreen *qScreen)
 
static int GetScreenCount ()
 

Protected Member Functions

 MythDisplay ()
 
 ~MythDisplay () override
 
virtual void UpdateCurrentMode ()
 Retrieve screen details. More...
 
virtual bool SwitchToVideoMode (QSize Size, double Framerate)
 
void DebugModes () const
 
void SetWidget (QWidget *MainWindow)
 Set the QWidget and QWindow in use. More...
 
void Initialise ()
 
void InitScreenBounds ()
 Get screen size from Qt while respecting the user's multiscreen settings. More...
 
void WaitForScreenChange ()
 
void WaitForNewScreen ()
 
void InitHDR ()
 

Static Protected Member Functions

static MythDisplayCreate (MythMainWindow *MainWindow)
 Create a MythDisplay object appropriate for the current platform. More...
 
static QScreen * GetDesiredScreen ()
 
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 }
 
MythDisplayModes m_videoModes { }
 
MythHDRPtr m_hdrState { nullptr }
 
MythVRRPtr m_vrrState { nullptr }
 

Static Private Member Functions

static void PauseForModeSwitch ()
 

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 wrapper around platform dependant display functionality. It can only be created by MythMainWindow and the single instance is owned by the MythMainWindow object.

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.
See also
MythMainWindow

Definition at line 22 of file mythdisplay.h.

Constructor & Destructor Documentation

◆ MythDisplay()

MythDisplay::MythDisplay ( )
protected

Definition at line 209 of file mythdisplay.cpp.

Referenced by Create().

◆ ~MythDisplay()

MythDisplay::~MythDisplay ( )
overrideprotected

Definition at line 228 of file mythdisplay.cpp.

Member Function Documentation

◆ VideoModesAvailable()

virtual bool MythDisplay::VideoModesAvailable ( )
inlinevirtual

◆ UsingVideoModes()

virtual bool MythDisplay::UsingVideoModes ( )
inlinevirtual

◆ IsPlanar()

virtual bool MythDisplay::IsPlanar ( )
inlinevirtual

Reimplemented in MythDisplayDRM.

Definition at line 31 of file mythdisplay.h.

Referenced by MythVideoOutputGPU::MythVideoOutputGPU().

◆ GetVideoModes()

const MythDisplayModes & MythDisplay::GetVideoModes ( )
virtual

◆ ConfigureQtGUI()

void MythDisplay::ConfigureQtGUI ( int  SwapInterval,
const MythCommandLineParser CmdLine 
)
static

Shared static initialisation 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 1158 of file mythdisplay.cpp.

Referenced by main().

◆ SpanAllScreens()

bool MythDisplay::SpanAllScreens ( )
static

Return true if the MythTV windows should span all screens.

Definition at line 495 of file mythdisplay.cpp.

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

◆ GetExtraScreenInfo()

QString MythDisplay::GetExtraScreenInfo ( QScreen *  qScreen)
static

◆ GetDescription()

QStringList MythDisplay::GetDescription ( )

Definition at line 136 of file mythdisplay.cpp.

Referenced by StatusBox::doDisplayStatus().

◆ GetScreenBounds()

QRect MythDisplay::GetScreenBounds ( )

◆ GetCurrentScreen()

QScreen * MythDisplay::GetCurrentScreen ( )

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 328 of file mythdisplay.cpp.

Referenced by MythVRR::Create(), GetDescription(), MythVideoBounds::PopulateGeometry(), and UpdateCurrentMode().

◆ GetScreenCount()

int MythDisplay::GetScreenCount ( )
static

◆ GetPixelAspectRatio()

double MythDisplay::GetPixelAspectRatio ( )

Definition at line 293 of file mythdisplay.cpp.

Referenced by MythUIScreenBounds::UpdateScreenSettings().

◆ GetGUIResolution()

QSize MythDisplay::GetGUIResolution ( )

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

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

◆ SwitchToDesktop()

void MythDisplay::SwitchToDesktop ( )

Return the screen to the original desktop video mode.

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

Definition at line 681 of file mythdisplay.cpp.

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

◆ SwitchToGUI()

bool MythDisplay::SwitchToGUI ( bool  Wait = false)

Switches to the GUI resolution.

Definition at line 774 of file mythdisplay.cpp.

Referenced by TV::DoEditSchedule(), MythMainWindow::MythMainWindow(), 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 692 of file mythdisplay.cpp.

Referenced by MythVideoOutputGPU::ResizeForVideo().

◆ GetResolution()

QSize MythDisplay::GetResolution ( )

◆ GetPhysicalSize()

QSize MythDisplay::GetPhysicalSize ( )

Definition at line 1072 of file mythdisplay.cpp.

◆ GetRefreshRate()

double MythDisplay::GetRefreshRate ( ) const

Definition at line 805 of file mythdisplay.cpp.

Referenced by GetDescription().

◆ GetRefreshInterval()

std::chrono::microseconds MythDisplay::GetRefreshInterval ( std::chrono::microseconds  Fallback) const

Definition at line 810 of file mythdisplay.cpp.

Referenced by MythPlayerUI::MythPlayerUI().

◆ 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 871 of file mythdisplay.cpp.

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

◆ EstimateVirtualAspectRatio()

double MythDisplay::EstimateVirtualAspectRatio ( )

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 969 of file mythdisplay.cpp.

Referenced by GetAspectRatio().

◆ GetEDID()

MythEDID & MythDisplay::GetEDID ( )

◆ GetRefreshRates()

MythDisplayRates MythDisplay::GetRefreshRates ( QSize  Size)

Definition at line 832 of file mythdisplay.cpp.

Referenced by HostRefreshRateComboBoxSetting::GetRefreshRates().

◆ GetHDRState()

MythHDRPtr MythDisplay::GetHDRState ( )

Definition at line 939 of file mythdisplay.cpp.

Referenced by MythHDRTracker::Create().

◆ ScreenChanged

void MythDisplay::ScreenChanged ( QScreen *  qScreen)
virtualslot

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

Definition at line 423 of file mythdisplay.cpp.

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

◆ PrimaryScreenChanged

void MythDisplay::PrimaryScreenChanged ( QScreen *  qScreen)
staticslot

Definition at line 444 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenAdded

void MythDisplay::ScreenAdded ( QScreen *  qScreen)
slot

Definition at line 449 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ ScreenRemoved

void MythDisplay::ScreenRemoved ( QScreen *  qScreen)
slot

Definition at line 455 of file mythdisplay.cpp.

Referenced by MythDisplay().

◆ PhysicalDPIChanged

void MythDisplay::PhysicalDPIChanged ( qreal  DPI)
slot

Definition at line 437 of file mythdisplay.cpp.

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

◆ GeometryChanged

void MythDisplay::GeometryChanged ( QRect  Geometry)
staticslot

Definition at line 461 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

◆ Create()

MythDisplay * MythDisplay::Create ( MythMainWindow MainWindow)
staticprotected

Create a MythDisplay object appropriate for the current platform.

Note
This function always returns a valid MythDisplay object.

Definition at line 83 of file mythdisplay.cpp.

Referenced by MythMainWindow::MythMainWindow().

◆ UpdateCurrentMode()

void MythDisplay::UpdateCurrentMode ( )
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, MythDisplayOSX, MythDisplayWindows, MythDisplayAndroid, MythDisplayMutter, MythDisplayDRM, and MythDisplayX11.

Definition at line 473 of file mythdisplay.cpp.

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

◆ SwitchToVideoMode()

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

◆ DebugModes()

void MythDisplay::DebugModes ( ) 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 246 of file mythdisplay.cpp.

Referenced by MythMainWindow::Init().

◆ GetDesiredScreen()

QScreen * MythDisplay::GetDesiredScreen ( )
staticprotected

Definition at line 333 of file mythdisplay.cpp.

Referenced by MythDisplay(), and SetWidget().

◆ DebugScreen()

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

◆ Initialise()

void MythDisplay::Initialise ( )
protected

◆ InitScreenBounds()

void MythDisplay::InitScreenBounds ( )
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 611 of file mythdisplay.cpp.

Referenced by Initialise(), and SetWidget().

◆ WaitForScreenChange()

void MythDisplay::WaitForScreenChange ( )
protected

Definition at line 1077 of file mythdisplay.cpp.

Referenced by SwitchToGUI(), and SwitchToVideo().

◆ WaitForNewScreen()

void MythDisplay::WaitForNewScreen ( )
protected

Definition at line 1096 of file mythdisplay.cpp.

Referenced by SetWidget().

◆ InitHDR()

void MythDisplay::InitHDR ( )
protected

Definition at line 944 of file mythdisplay.cpp.

Referenced by Initialise().

◆ PauseForModeSwitch()

void MythDisplay::PauseForModeSwitch ( )
staticprivate

Definition at line 1116 of file mythdisplay.cpp.

Referenced by SwitchToVideo().

Friends And Related Function Documentation

◆ MythMainWindow

friend class MythMainWindow
friend

Definition at line 26 of file mythdisplay.h.

Member Data Documentation

◆ m_waitForModeChanges

bool MythDisplay::m_waitForModeChanges { true }
protected

Definition at line 88 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 91 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

◆ m_window

QWindow* MythDisplay::m_window { nullptr }
protected

Definition at line 96 of file mythdisplay.h.

Referenced by SetWidget().

◆ m_screen

QScreen* MythDisplay::m_screen { nullptr }
protected

◆ m_videoModes

MythDisplayModes MythDisplay::m_videoModes { }
protected

◆ m_hdrState

MythHDRPtr MythDisplay::m_hdrState { nullptr }
protected

Definition at line 99 of file mythdisplay.h.

Referenced by GetDescription(), GetHDRState(), and InitHDR().

◆ m_vrrState

MythVRRPtr MythDisplay::m_vrrState { nullptr }
protected

Definition at line 100 of file mythdisplay.h.

Referenced by GetDescription(), GetRefreshInterval(), Initialise(), and SwitchToVideo().

◆ m_initialised

bool MythDisplay::m_initialised { false }
private

Definition at line 106 of file mythdisplay.h.

Referenced by Initialise(), and SetWidget().

◆ m_firstScreenChange

bool MythDisplay::m_firstScreenChange { true }
private

Definition at line 107 of file mythdisplay.h.

Referenced by SetWidget().

◆ m_screenBounds

QRect MythDisplay::m_screenBounds { }
private

Definition at line 108 of file mythdisplay.h.

Referenced by GetScreenBounds(), and InitScreenBounds().

◆ m_desktopMode

MythDisplayMode MythDisplay::m_desktopMode { }
private

Definition at line 109 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToDesktop().

◆ m_guiMode

MythDisplayMode MythDisplay::m_guiMode { }
private

Definition at line 110 of file mythdisplay.h.

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

◆ m_videoMode

MythDisplayMode MythDisplay::m_videoMode { }
private

Definition at line 111 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().

◆ m_overrideVideoModes

DisplayModeMap MythDisplay::m_overrideVideoModes { }
private

Definition at line 112 of file mythdisplay.h.

Referenced by Initialise(), and SwitchToVideo().


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