Skip to content

Commit

Permalink
MythMainWindow: Respect the 'UseFixedWindowSize' setting
Browse files Browse the repository at this point in the history
- may not be useful on a day to day basis (not least because we do not
resize the UI) but handy for debugging OpenGL framebuffer sizing issues.
  • Loading branch information
mark-kendall committed Sep 23, 2019
1 parent 9320058 commit cc78135
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
24 changes: 13 additions & 11 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -1045,10 +1045,12 @@ void TV::InitFromDB(void)
kv["EndOfRecordingExitPrompt"] = "0";
kv["JumpToProgramOSD"] = "1";
kv["GuiSizeForTV"] = "0";
kv["UseVideoModes"] = "0";
kv["ClearSavedPosition"] = "1";
kv["JobsRunOnRecordHost"] = "0";
kv["ContinueEmbeddedTVPlay"] = "0";
kv["UseFixedWindowSize"] = "1";
kv["RunFrontendInWindow"] = "0";
kv["PersistentBrowseMode"] = "0";
kv["BrowseAllTuners"] = "0";
kv["ChannelOrdering"] = "channum";
Expand Down Expand Up @@ -1095,10 +1097,12 @@ void TV::InitFromDB(void)
m_dbEndOfRecExitPrompt = (kv["EndOfRecordingExitPrompt"].toInt() != 0);
m_dbJumpPreferOsd = (kv["JumpToProgramOSD"].toInt() != 0);
m_dbUseGuiSizeForTv = (kv["GuiSizeForTV"].toInt() != 0);
m_dbUseVideoModes = (kv["UseVideoModes"].toInt() != 0);
m_dbClearSavedPosition = (kv["ClearSavedPosition"].toInt() != 0);
m_dbRunJobsOnRemote = (kv["JobsRunOnRecordHost"].toInt() != 0);
m_dbContinueEmbedded = (kv["ContinueEmbeddedTVPlay"].toInt() != 0);
m_dbUseFixedSize = (kv["UseFixedWindowSize"].toInt() != 0);
m_dbRunFrontendInWindow= (kv["RunFrontendInWindow"].toInt() != 0);
m_dbBrowseAlways = (kv["PersistentBrowseMode"].toInt() != 0);
m_dbBrowseAllTuners = (kv["BrowseAllTuners"].toInt() != 0);
db_channel_ordering = kv["ChannelOrdering"];
Expand Down Expand Up @@ -1163,8 +1167,7 @@ bool TV::Init(bool createWindow)

if (createWindow)
{
bool fullscreen = !gCoreContext->GetBoolSetting("GuiSizeForTV", false);
bool switchMode = gCoreContext->GetBoolSetting("UseVideoModes", false);
bool fullscreen = !m_dbUseGuiSizeForTv;

m_savedGuiBounds = QRect(GetMythMainWindow()->geometry().topLeft(),
GetMythMainWindow()->size());
Expand Down Expand Up @@ -1200,7 +1203,7 @@ bool TV::Init(bool createWindow)
}

// main window sizing
if (switchMode)
if (m_dbUseVideoModes)
{
DisplayRes *display_res = DisplayRes::GetDisplayRes();
if(display_res)
Expand Down Expand Up @@ -1309,7 +1312,8 @@ TV::~TV(void)
// restore window to gui size and position
MythMainWindow* mwnd = GetMythMainWindow();
mwnd->setGeometry(m_savedGuiBounds);
mwnd->setFixedSize(m_savedGuiBounds.size());
if (m_dbUseFixedSize)
mwnd->setFixedSize(m_savedGuiBounds.size());
mwnd->ResizePainterWindow(m_savedGuiBounds.size());
#ifdef Q_OS_ANDROID
mwnd->Show();
Expand Down Expand Up @@ -2496,10 +2500,9 @@ void TV::HandleStateChange(PlayerContext *mctx, PlayerContext *ctx)
{
if (!ctx->IsPIP())
GetMythUI()->DisableScreensaver();
bool switchMode = gCoreContext->GetBoolSetting("UseVideoModes", false);
// m_playerBounds is not applicable when switching modes so
// skip this logic in that case.
if (!switchMode)
if (!m_dbUseVideoModes)
{
MythMainWindow *mainWindow = GetMythMainWindow();
mainWindow->setBaseSize(m_playerBounds.size());
Expand Down Expand Up @@ -8671,9 +8674,10 @@ void TV::DoEditSchedule(int editType)
mctx->UnlockDeletePlayer(__FILE__, __LINE__);
ReturnPlayerLock(actx);
MythMainWindow *mwnd = GetMythMainWindow();
if (!m_dbUseGuiSizeForTv || !m_dbUseFixedSize)
if (!m_dbUseGuiSizeForTv)
{
mwnd->setFixedSize(m_savedGuiBounds.size());
if (m_dbUseFixedSize)
mwnd->setFixedSize(m_savedGuiBounds.size());
mwnd->setGeometry(m_savedGuiBounds.left(), m_savedGuiBounds.top(),
m_savedGuiBounds.width(), m_savedGuiBounds.height());
}
Expand Down Expand Up @@ -9699,9 +9703,7 @@ void TV::customEvent(QEvent *e)

// m_playerBounds is not applicable when switching modes so
// skip this logic in that case.
bool switchMode = gCoreContext->GetBoolSetting("UseVideoModes", false);
if (!switchMode
&& (!m_dbUseGuiSizeForTv || !m_dbUseFixedSize))
if (!m_dbUseVideoModes && (!m_dbUseGuiSizeForTv || !m_dbUseFixedSize))
{
mwnd->setMinimumSize(QSize(16, 16));
mwnd->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/tv_play.h
Expand Up @@ -783,10 +783,12 @@ class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer
bool m_dbEndOfRecExitPrompt {false};
bool m_dbJumpPreferOsd {true};
bool m_dbUseGuiSizeForTv {false};
bool m_dbUseVideoModes {false};
bool m_dbClearSavedPosition {false};
bool m_dbRunJobsOnRemote {false};
bool m_dbContinueEmbedded {false};
bool m_dbUseFixedSize {true};
bool m_dbRunFrontendInWindow {false};
bool m_dbBrowseAlways {false};
bool m_dbBrowseAllTuners {false};
bool m_dbUseChannelGroups {false};
Expand Down
36 changes: 26 additions & 10 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -144,6 +144,7 @@ class MythMainWindowPrivate
int m_xbase {0};
int m_ybase {0};
bool m_does_fill_screen {false};
bool m_fixed_window_size {true};

bool m_ignore_lirc_keys {false};
bool m_ignore_joystick_keys {false};
Expand Down Expand Up @@ -628,7 +629,8 @@ void MythMainWindow::ResizePainterWindow(const QSize &size)
{
if (!d->m_paintwin)
return;
d->m_paintwin->setFixedSize(size);
if (d->m_fixed_window_size)
d->m_paintwin->setFixedSize(size);
d->m_paintwin->resize(size);
}

Expand Down Expand Up @@ -1007,13 +1009,19 @@ void MythMainWindow::Init(const QString& forcedpainter, bool mayReInit)
// Set window border based on fullscreen attribute
Qt::WindowFlags flags = Qt::Window;

d->m_fixed_window_size = GetMythDB()->GetBoolSetting("UseFixedWindowSize", true);
bool inwindow = GetMythDB()->GetBoolSetting("RunFrontendInWindow", false);
bool fullscreen = d->m_does_fill_screen && !GetMythUI()->IsGeometryOverridden();

// On Compiz/Unit, when the window is fullscreen and frameless changing
// screen position ends up stuck. Adding a border temporarily prevents this
setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);

if (d->m_fixed_window_size)
LOG(VB_GENERAL, LOG_INFO, "Using fixed window size");
else
LOG(VB_GENERAL, LOG_INFO, "Window is resizeable");

if (!inwindow)
{
LOG(VB_GENERAL, LOG_INFO, "Using Frameless Window");
Expand All @@ -1025,6 +1033,11 @@ void MythMainWindow::Init(const QString& forcedpainter, bool mayReInit)
flags |= Qt::MSWindowsOwnDC;
#endif

// NOTE if running fullscreen AND windowed (i.e. borders etc) then we do not
// have any idea at this time of the size of the borders/decorations.
// Typically, on linux, this means we create the UI slightly larger than
// required - as X adds the decorations at a later point.

if (fullscreen && !inwindow)
{
LOG(VB_GENERAL, LOG_INFO, "Using Full Screen Window");
Expand All @@ -1037,7 +1050,7 @@ void MythMainWindow::Init(const QString& forcedpainter, bool mayReInit)
}
else
{
// reset type
// reset type
setWindowState(Qt::WindowNoState);
}

Expand All @@ -1063,12 +1076,14 @@ void MythMainWindow::Init(const QString& forcedpainter, bool mayReInit)
d->m_uiScreenRect = QRect(0, 0, d->m_screenwidth, d->m_screenheight);

LOG(VB_GENERAL, LOG_INFO, QString("UI Screen Resolution: %1 x %2")
.arg(QString::number(d->m_screenwidth))
.arg(QString::number(d->m_screenheight)));
.arg(d->m_screenwidth).arg(d->m_screenheight));

setGeometry(d->m_xbase, d->m_ybase, d->m_screenwidth, d->m_screenheight);
// remove size constraints
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
// fix size if required (i.e. don't allow the user to resize)
if (d->m_fixed_window_size)
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
resize(d->m_screenwidth, d->m_screenheight);

Show();
Expand Down Expand Up @@ -1196,7 +1211,9 @@ void MythMainWindow::Init(const QString& forcedpainter, bool mayReInit)

void MythMainWindow::DelayedAction(void)
{
setFixedSize(QSize(d->m_screenwidth, d->m_screenheight));
if (d->m_fixed_window_size)
setFixedSize(d->m_screenwidth, d->m_screenheight);
resize(d->m_screenwidth, d->m_screenheight);
Show();

#ifdef Q_OS_ANDROID
Expand Down Expand Up @@ -1386,7 +1403,8 @@ void MythMainWindow::ReinitDone(void)
d->m_oldrender = nullptr;

d->m_paintwin->move(0, 0);
d->m_paintwin->setFixedSize(size());
if (d->m_fixed_window_size)
d->m_paintwin->setFixedSize(size()); // why?
d->m_paintwin->raise();
ShowPainterWindow();

Expand Down Expand Up @@ -2859,9 +2877,7 @@ void MythMainWindow::ShowMouseCursor(bool show)
{
if (show && GetMythDB()->GetBoolSetting("HideMouseCursor", false))
return;
#ifdef QWS
QWSServer::setCursorVisible(show);
#endif

// Set cursor call must come after Show() to work on some systems.
setCursor(show ? (Qt::ArrowCursor) : (Qt::BlankCursor));

Expand Down

0 comments on commit cc78135

Please sign in to comment.