Fix some issues in multi-screen
This commit is contained in:
parent
b5e3fa865e
commit
0a633adc72
4 changed files with 46 additions and 8 deletions
|
@ -44,8 +44,8 @@ FakeWindow::FakeWindow(QQuickView *parent)
|
||||||
Qt::WindowStaysOnTopHint |
|
Qt::WindowStaysOnTopHint |
|
||||||
Qt::NoDropShadowWindowHint |
|
Qt::NoDropShadowWindowHint |
|
||||||
Qt::WindowDoesNotAcceptFocus);
|
Qt::WindowDoesNotAcceptFocus);
|
||||||
setScreen(qApp->primaryScreen());
|
// setScreen(qApp->primaryScreen());
|
||||||
updateGeometry();
|
// updateGeometry();
|
||||||
show();
|
show();
|
||||||
|
|
||||||
m_delayedMouseTimer.setSingleShot(true);
|
m_delayedMouseTimer.setSingleShot(true);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
explicit FakeWindow(QQuickView *parent = nullptr);
|
explicit FakeWindow(QQuickView *parent = nullptr);
|
||||||
|
|
||||||
bool containsMouse() const;
|
bool containsMouse() const;
|
||||||
|
void updateGeometry();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void containsMouseChanged(bool contains);
|
void containsMouseChanged(bool contains);
|
||||||
|
@ -41,7 +42,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setContainsMouse(bool contains);
|
void setContainsMouse(bool contains);
|
||||||
void updateGeometry();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer m_delayedMouseTimer;
|
QTimer m_delayedMouseTimer;
|
||||||
|
|
|
@ -59,7 +59,7 @@ MainWindow::MainWindow(QQuickView *parent)
|
||||||
|
|
||||||
setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
setScreen(qApp->primaryScreen());
|
initScreens();
|
||||||
|
|
||||||
initSlideWindow();
|
initSlideWindow();
|
||||||
resizeWindow();
|
resizeWindow();
|
||||||
|
@ -77,8 +77,9 @@ MainWindow::MainWindow(QQuickView *parent)
|
||||||
connect(m_activity, &Activity::launchPadChanged, this, &MainWindow::onVisibilityChanged);
|
connect(m_activity, &Activity::launchPadChanged, this, &MainWindow::onVisibilityChanged);
|
||||||
|
|
||||||
// Screen change.
|
// Screen change.
|
||||||
connect(qApp->primaryScreen(), &QScreen::virtualGeometryChanged, this, &MainWindow::resizeWindow);
|
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &MainWindow::onPrimaryScreenChanged);
|
||||||
connect(qApp->primaryScreen(), &QScreen::geometryChanged, this, &MainWindow::resizeWindow);
|
connect(screen(), &QScreen::virtualGeometryChanged, this, &MainWindow::resizeWindow);
|
||||||
|
connect(screen(), &QScreen::geometryChanged, this, &MainWindow::resizeWindow);
|
||||||
|
|
||||||
connect(m_appModel, &ApplicationModel::countChanged, this, &MainWindow::resizeWindow);
|
connect(m_appModel, &ApplicationModel::countChanged, this, &MainWindow::resizeWindow);
|
||||||
connect(m_settings, &DockSettings::directionChanged, this, &MainWindow::onPositionChanged);
|
connect(m_settings, &DockSettings::directionChanged, this, &MainWindow::onPositionChanged);
|
||||||
|
@ -92,8 +93,8 @@ MainWindow::~MainWindow()
|
||||||
|
|
||||||
QRect MainWindow::windowRect() const
|
QRect MainWindow::windowRect() const
|
||||||
{
|
{
|
||||||
const QRect screenGeometry = qApp->primaryScreen()->geometry();
|
const QRect screenGeometry = screen()->geometry();
|
||||||
const QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
|
const QRect availableGeometry = screen()->availableGeometry();
|
||||||
|
|
||||||
bool isHorizontal = m_settings->direction() == DockSettings::Bottom;
|
bool isHorizontal = m_settings->direction() == DockSettings::Bottom;
|
||||||
|
|
||||||
|
@ -145,6 +146,30 @@ void MainWindow::resizeWindow()
|
||||||
emit resizingFished();
|
emit resizingFished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::initScreens()
|
||||||
|
{
|
||||||
|
switch (m_settings->direction()) {
|
||||||
|
// TODO
|
||||||
|
// case DockSettings::Left:
|
||||||
|
// setScreen(qGuiApp->screens().first());
|
||||||
|
// break;
|
||||||
|
// case DockSettings::Right:
|
||||||
|
// setScreen(qGuiApp->screens().last());
|
||||||
|
// break;
|
||||||
|
// case DockSettings::Bottom:
|
||||||
|
// setScreen(qGuiApp->primaryScreen());
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
setScreen(qGuiApp->primaryScreen());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_fakeWindow) {
|
||||||
|
m_fakeWindow->setScreen(screen());
|
||||||
|
m_fakeWindow->updateGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::initSlideWindow()
|
void MainWindow::initSlideWindow()
|
||||||
{
|
{
|
||||||
KWindowEffects::SlideFromLocation location = KWindowEffects::NoEdge;
|
KWindowEffects::SlideFromLocation location = KWindowEffects::NoEdge;
|
||||||
|
@ -179,6 +204,8 @@ void MainWindow::createFakeWindow()
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
m_fakeWindow = new FakeWindow;
|
m_fakeWindow = new FakeWindow;
|
||||||
|
m_fakeWindow->setScreen(screen());
|
||||||
|
m_fakeWindow->updateGeometry();
|
||||||
|
|
||||||
connect(m_fakeWindow, &FakeWindow::containsMouseChanged, this, [=](bool contains) {
|
connect(m_fakeWindow, &FakeWindow::containsMouseChanged, this, [=](bool contains) {
|
||||||
switch (m_settings->visibility()) {
|
switch (m_settings->visibility()) {
|
||||||
|
@ -219,8 +246,17 @@ void MainWindow::deleteFakeWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onPrimaryScreenChanged(QScreen *screen)
|
||||||
|
{
|
||||||
|
initScreens();
|
||||||
|
setScreen(screen);
|
||||||
|
resizeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onPositionChanged()
|
void MainWindow::onPositionChanged()
|
||||||
{
|
{
|
||||||
|
initScreens();
|
||||||
|
|
||||||
if (m_settings->visibility() == DockSettings::AlwaysHide) {
|
if (m_settings->visibility() == DockSettings::AlwaysHide) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
initSlideWindow();
|
initSlideWindow();
|
||||||
|
|
|
@ -45,6 +45,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
QRect windowRect() const;
|
QRect windowRect() const;
|
||||||
void resizeWindow();
|
void resizeWindow();
|
||||||
|
void initScreens();
|
||||||
void initSlideWindow();
|
void initSlideWindow();
|
||||||
void updateViewStruts();
|
void updateViewStruts();
|
||||||
void clearViewStruts();
|
void clearViewStruts();
|
||||||
|
@ -53,6 +54,7 @@ private:
|
||||||
void deleteFakeWindow();
|
void deleteFakeWindow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onPrimaryScreenChanged(QScreen *screen);
|
||||||
void onPositionChanged();
|
void onPositionChanged();
|
||||||
void onIconSizeChanged();
|
void onIconSizeChanged();
|
||||||
void onVisibilityChanged();
|
void onVisibilityChanged();
|
||||||
|
|
Loading…
Reference in a new issue