mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-13 12:06:09 -05:00
Validate window position before setting it
This commit is contained in:
@@ -3,6 +3,10 @@
|
|||||||
#include "headers/version.h"
|
#include "headers/version.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#if __linux__
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#endif
|
||||||
|
|
||||||
QMetaObject::Connection inactivePluse;
|
QMetaObject::Connection inactivePluse;
|
||||||
|
|
||||||
@@ -377,9 +381,23 @@ void AdvSceneSwitcher::setTabOrder()
|
|||||||
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
|
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool windowPosValid(QPoint pos)
|
||||||
|
{
|
||||||
|
#if __linux__
|
||||||
|
// QDesktopWidget::availableGeometry() is deprecated.
|
||||||
|
// Switch to QGuiApplication::screenAt() when it is available on most Linux platforms.
|
||||||
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
|
auto screen = desktop->availableGeometry(pos);
|
||||||
|
return (pos.x() > screen.x()) && (pos.y() > screen.y()) &&
|
||||||
|
(pos.x() < screen.width() && (pos.y() < screen.height()));
|
||||||
|
#else
|
||||||
|
return !!QGuiApplication::screenAt(pos);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::restoreWindowGeo()
|
void AdvSceneSwitcher::restoreWindowGeo()
|
||||||
{
|
{
|
||||||
if (switcher->saveWindowGeo) {
|
if (switcher->saveWindowGeo && windowPosValid(switcher->windowPos)) {
|
||||||
this->resize(switcher->windowSize);
|
this->resize(switcher->windowSize);
|
||||||
this->move(switcher->windowPos);
|
this->move(switcher->windowPos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user