summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-12-04 11:41:33 +0100
committerSimon Rettberg2018-12-04 11:41:33 +0100
commit51fb6c02cd9bd3a1767a1e37bd82f03d449b1e5c (patch)
treedbc0e571135b32685c15a87f5100c814bfc5d15b
parentSupport UltraWide screens (diff)
downloadbeamergui-51fb6c02cd9bd3a1767a1e37bd82f03d449b1e5c.tar.gz
beamergui-51fb6c02cd9bd3a1767a1e37bd82f03d449b1e5c.tar.xz
beamergui-51fb6c02cd9bd3a1767a1e37bd82f03d449b1e5c.zip
Fix bug
-rw-r--r--src/widget.cpp98
-rw-r--r--src/xprivate.cpp3
2 files changed, 54 insertions, 47 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 069e8db..cff1ccd 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -81,15 +81,15 @@ Widget::Widget(QWidget *parent) :
_popupCount(0),
_iProjector(QIcon(":projector")),
_iScreen(QIcon(":screen")),
- _addEventDbus(false),
- _addEventOther(false)
+ _addEventDbus(false),
+ _addEventOther(false)
{
_ui->setupUi(this);
// Add refresh button
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
_ui->tabWidget->setCornerWidget(_ui->btnReload);
connect(_ui->btnReload, &QPushButton::clicked, [=](bool) {
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
ScreenSetup::inst()->initModes();
initControls();
});
@@ -128,45 +128,45 @@ Widget::Widget(QWidget *parent) :
t->setSingleShot(true);
// Timeout after screen setup changed -- handle
connect(t, &QTimer::timeout, [=]() {
- // Query how many screens there are now
+ // Query how many screens there are now
int currentCount = ScreenSetup::inst()->queryCurrentOutputCount();
- qDebug() << "Timeout. Dbus:" << _addEventDbus << "X:" << _addEventOther << "old count:" << _lastScreenCount << "new count:" << currentCount;
- if (_addEventDbus && !_addEventOther) {
- // Only dbus reported a change -- wait some more in case we have link flap (don't make it worse than it already is)
- t->start(2000); // If no other DBus event fires within 2 secs, we'll continue below next time
- } else if (this->isHidden()) {
- // GUI is currently hidden
- if (currentCount == _lastScreenCount) {
- // Nothing seems to have changed. This might happen when another tool changes the screen config. Let's not interfere.
- } else if (currentCount > _lastScreenCount) { // Screen count increased - auto setup
- _lastScreenCount = currentCount;
- ScreenSetup::inst()->initModes();
- ScreenMode mode;
- auto ret = ScreenSetup::inst()->setDefaultMode(CommandLine::testMode(), mode);
- if (!ret.ok() || !keepResolution()) {
- ret.revert();
- }
- } else { // Screen count decreased - pop up GUI and don't just deconfig the screen
- this->show();
- }
+ qDebug() << "Timeout. Dbus:" << _addEventDbus << "X:" << _addEventOther << "old count:" << _lastScreenCount << "new count:" << currentCount;
+ if (_addEventDbus && !_addEventOther) {
+ // Only dbus reported a change -- wait some more in case we have link flap (don't make it worse than it already is)
+ t->start(2000); // If no other DBus event fires within 2 secs, we'll continue below next time
+ } else if (this->isHidden()) {
+ // GUI is currently hidden
+ if (currentCount == _lastScreenCount) {
+ // Nothing seems to have changed. This might happen when another tool changes the screen config. Let's not interfere.
+ } else if (currentCount > _lastScreenCount) { // Screen count increased - auto setup
+ _lastScreenCount = currentCount;
+ ScreenSetup::inst()->initModes();
+ ScreenMode mode;
+ auto ret = ScreenSetup::inst()->setDefaultMode(CommandLine::testMode(), mode);
+ if (!ret.ok() || !keepResolution()) {
+ ret.revert();
+ }
+ } else { // Screen count decreased - pop up GUI and don't just deconfig the screen
+ this->show();
+ }
} else {
- // GUI currently visible -- highlight refresh button
+ // GUI currently visible -- highlight refresh button
if (currentCount > _lastScreenCount) {
ScreenSetup::inst()->initModes();
initControls();
} else {
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
}
}
- // Reset flags (don't use return above!)
- _addEventDbus = false;
- _addEventOther = false;
+ // Reset flags (don't use return above!)
+ _addEventDbus = false;
+ _addEventOther = false;
});
auto popupGui = [=]() {
if (this->isHidden()) {
t->start(1500);
} else {
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
}
};
for (auto scrn : QGuiApplication::screens()) {
@@ -176,7 +176,7 @@ Widget::Widget(QWidget *parent) :
qDebug() << "QT SEES SCREEN" << scrn->geometry();
_qtScreens.append(scrn);
if (CommandLine::backgroundMode()) {
- _addEventOther = true;
+ _addEventOther = true;
popupGui();
}
});
@@ -206,10 +206,10 @@ Widget::Widget(QWidget *parent) :
connect(ScreenSetup::inst(), &ScreenSetup::outputConfigChanged, [=](ConnectionEvent type) {
if (type == ConnectionEvent::Disconnected) {
if (!this->isHidden()) {
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_HOT);
}
} else {
- _addEventOther = true;
+ _addEventOther = true;
popupGui();
}
});
@@ -232,8 +232,8 @@ void Widget::showEvent(QShowEvent *event)
void Widget::hideEvent(QHideEvent *event)
{
- QWidget::hideEvent(event);
- _lastScreenCount = ScreenSetup::inst()->getOutputCount();
+ QWidget::hideEvent(event);
+ _lastScreenCount = ScreenSetup::inst()->getOutputCount();
}
static void fillCombo(QComboBox *combo, const ResolutionVector &resolutions, const QSize &preselected, const QSize &preferred = QSize())
@@ -280,7 +280,7 @@ void Widget::comboBold(int index)
void Widget::initControls(bool jumpToTab)
{
_lastScreenCount = ScreenSetup::inst()->getOutputCount();
- _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
+ _ui->btnReload->setStyleSheet(STYLE_RELOAD_BUTTON_NORMAL);
//
ScreenMode currentOpMode = ScreenSetup::inst()->getCurrentMode();
_ui->tabWidget->setTabEnabled(1, CommandLine::testMode() || ScreenSetup::inst()->getOutputCount() == 2 || currentOpMode == ScreenMode::Dual);
@@ -534,7 +534,7 @@ bool Widget::keepResolution()
if (skip)
continue;
// Show a dialog asking if the res should be kept
- TimeOutDialog *keepDialog = new TimeOutDialog(15);
+ TimeOutDialog *keepDialog = new TimeOutDialog(15);
QSize s = (geo.size() - keepDialog->size()) / 2;
QPoint tl = geo.topLeft();
tl.rx() += s.width();
@@ -571,7 +571,7 @@ bool Widget::keepResolution()
//______________________________________________________________________________
void Widget::connectButtons() {
- // Swap dualscreen
+ // Swap dualscreen
connect(_ui->btnDualSwap, &QPushButton::clicked, [=](bool) {
_ui->dualContainer->addItem(_ui->dualContainer->takeAt(1));
_ui->dualContainer->addItem(_ui->dualContainer->takeAt(0));
@@ -579,10 +579,10 @@ void Widget::connectButtons() {
// Apply CLONE
connect(_ui->btnCloneApply, &QPushButton::clicked, [=](bool) {
- auto ret = ScreenSetup::inst()->setClone(_ui->cboCloneResolution->currentData().toSize());
- if (!ret.ok() || !keepResolution()) {
+ auto ret = ScreenSetup::inst()->setClone(_ui->cboCloneResolution->currentData().toSize());
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting clone";
- ret.revert();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();
@@ -595,10 +595,10 @@ void Widget::connectButtons() {
if (_ui->btnDualSwap->isChecked()) {
qSwap(left, right);
}
- auto ret = ScreenSetup::inst()->setCustom({left, right});
- if (!ret.ok() || !keepResolution()) {
+ auto ret = ScreenSetup::inst()->setCustom({left, right});
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting dualhead";
- ret.revert();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();
@@ -610,16 +610,20 @@ void Widget::connectButtons() {
for (auto e : _advancedScreens) {
list.append({ e->cboResolution->currentData().toSize(), QList<QString>() });
}
+ int numConf = 0;
for (auto e : _advancedOutput) {
int index = e->cboPosition->currentIndex() - 1;
if (index < 0 || index >= list.size())
continue;
list[index].second.append(e->info.output);
+ numConf++;
}
- auto ret = ScreenSetup::inst()->setCustom(list);
- if (!ret.ok() || !keepResolution()) {
+ if (numConf == 0)
+ return;
+ auto ret = ScreenSetup::inst()->setCustom(list);
+ if (!ret.ok() || !keepResolution()) {
qDebug() << "reverting custom";
- ret.revert();
+ ret.revert();
}
ScreenSetup::inst()->updateScreenResources();
initControls();
diff --git a/src/xprivate.cpp b/src/xprivate.cpp
index 950c6ce..7667b9e 100644
--- a/src/xprivate.cpp
+++ b/src/xprivate.cpp
@@ -419,6 +419,9 @@ XRRModeInfo* XPrivate::getPreferredMode(OutputInfo *oi, XRRModeInfo *fallback) c
mode = getOutputModeForResolution(oi->output, 1280, 800);
}
if (mode == None) {
+ mode = getOutputModeForResolution(oi->output, 1152, 864);
+ }
+ if (mode == None) {
mode = oi->output->modes[0];
}
}