From 187f556f850f8c2c75a03102ecd9d375fab33a77 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 19 Oct 2022 10:10:03 +0300 Subject: [PATCH] Drop Screens --- autotests/integration/pointer_input.cpp | 3 +- autotests/integration/screens_test.cpp | 11 +--- src/CMakeLists.txt | 1 - src/input.cpp | 1 - src/pointer_input.cpp | 14 +++-- src/screens.cpp | 67 ----------------------- src/screens.h | 72 ------------------------- src/tabbox/switcheritem.cpp | 3 +- src/waylandwindow.cpp | 3 +- src/workspace.cpp | 9 ---- src/workspace.h | 3 -- 11 files changed, 15 insertions(+), 172 deletions(-) delete mode 100644 src/screens.cpp delete mode 100644 src/screens.h diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index 9d3a871bd5..d4b775db2e 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -16,7 +16,6 @@ #include "options.h" #include "pointer_input.h" #include "screenedge.h" -#include "screens.h" #include "utils/xcursortheme.h" #include "virtualdesktops.h" #include "wayland/clientconnection.h" @@ -56,7 +55,7 @@ static PlatformCursorImage loadReferenceThemeCursor(const QByteArray &name) { const Cursor *pointerCursor = Cursors::self()->mouse(); - const KXcursorTheme theme(pointerCursor->themeName(), pointerCursor->themeSize(), workspace()->screens()->maxScale()); + const KXcursorTheme theme(pointerCursor->themeName(), pointerCursor->themeSize(), kwinApp()->devicePixelRatio()); if (theme.isEmpty()) { return PlatformCursorImage(); } diff --git a/autotests/integration/screens_test.cpp b/autotests/integration/screens_test.cpp index d8a9e8d24a..fd6962fb8b 100644 --- a/autotests/integration/screens_test.cpp +++ b/autotests/integration/screens_test.cpp @@ -11,7 +11,6 @@ #include "core/output.h" #include "core/platform.h" #include "cursor.h" -#include "screens.h" #include "wayland_server.h" #include "window.h" #include "workspace.h" @@ -127,8 +126,6 @@ void ScreensTest::testCurrentWithFollowsMouse_data() void ScreensTest::testCurrentWithFollowsMouse() { - QSignalSpy changedSpy(workspace()->screens(), &Screens::changed); - // Enable "active screen follows mouse" auto group = kwinApp()->config()->group("Windows"); group.writeEntry("ActiveMouseScreen", true); @@ -136,9 +133,8 @@ void ScreensTest::testCurrentWithFollowsMouse() workspace()->slotReconfigure(); QFETCH(QVector, geometries); - QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::QueuedConnection, + QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, geometries.count()), Q_ARG(QVector, geometries)); - QVERIFY(changedSpy.wait()); QFETCH(QPoint, cursorPos); KWin::Cursors::self()->mouse()->setPos(cursorPos); @@ -163,12 +159,9 @@ void ScreensTest::testCurrentPoint_data() void ScreensTest::testCurrentPoint() { - QSignalSpy changedSpy(workspace()->screens(), &KWin::Screens::changed); - QFETCH(QVector, geometries); - QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::QueuedConnection, + QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, geometries.count()), Q_ARG(QVector, geometries)); - QVERIFY(changedSpy.wait()); // Disable "active screen follows mouse" auto group = kwinApp()->config()->group("Windows"); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 476f02c5ae..0a3dc1bf21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,7 +120,6 @@ target_sources(kwin PRIVATE rules.cpp scene.cpp screenedge.cpp - screens.cpp scripting/dbuscall.cpp scripting/desktopbackgrounditem.cpp scripting/screenedgeitem.cpp diff --git a/src/input.cpp b/src/input.cpp index 1488d2e8a8..6bffd78e6e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -39,7 +39,6 @@ #include "internalwindow.h" #include "popup_input_filter.h" #include "screenedge.h" -#include "screens.h" #include "unmanaged.h" #include "virtualdesktops.h" #include "wayland/display.h" diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index 652e8212c9..46321e67cd 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -20,7 +20,6 @@ #include "input_event_spy.h" #include "mousebuttons.h" #include "osd.h" -#include "screens.h" #include "wayland/datadevice_interface.h" #include "wayland/display.h" #include "wayland/pointer_interface.h" @@ -108,7 +107,7 @@ void PointerInputRedirection::init() }); Q_EMIT m_cursor->changed(); - connect(workspace()->screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange); + connect(workspace(), &Workspace::outputsChanged, this, &PointerInputRedirection::updateAfterScreenChange); #if KWIN_BUILD_SCREENLOCKER if (waylandServer()->hasScreenLockerIntegration()) { connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, [this]() { @@ -1219,7 +1218,7 @@ WaylandCursorImage::WaylandCursorImage(QObject *parent) Cursor *pointerCursor = Cursors::self()->mouse(); connect(pointerCursor, &Cursor::themeChanged, this, &WaylandCursorImage::invalidateCursorTheme); - connect(workspace()->screens(), &Screens::maxScaleChanged, this, &WaylandCursorImage::invalidateCursorTheme); + connect(workspace(), &Workspace::outputsChanged, this, &WaylandCursorImage::invalidateCursorTheme); } bool WaylandCursorImage::ensureCursorTheme() @@ -1229,7 +1228,14 @@ bool WaylandCursorImage::ensureCursorTheme() } const Cursor *pointerCursor = Cursors::self()->mouse(); - const qreal targetDevicePixelRatio = workspace()->screens()->maxScale(); + qreal targetDevicePixelRatio = 1; + + const auto outputs = workspace()->outputs(); + for (const Output *output : outputs) { + if (output->scale() > targetDevicePixelRatio) { + targetDevicePixelRatio = output->scale(); + } + } m_cursorTheme = KXcursorTheme(pointerCursor->themeName(), pointerCursor->themeSize(), targetDevicePixelRatio); if (!m_cursorTheme.isEmpty()) { diff --git a/src/screens.cpp b/src/screens.cpp deleted file mode 100644 index 881023660d..0000000000 --- a/src/screens.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2013 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "screens.h" - -#include - -#include "core/output.h" -#include "core/platform.h" -#include "cursor.h" -#include "settings.h" -#include "utils/common.h" -#include -#include - -namespace KWin -{ - -Screens::Screens() - : m_maxScale(1.0) -{ - connect(workspace(), &Workspace::outputsChanged, this, &Screens::changed); -} - -void Screens::init() -{ - connect(this, &Screens::changed, this, &Screens::updateSize); - - Q_EMIT changed(); -} - -qreal Screens::scale(int screen) const -{ - if (Output *output = findOutput(screen)) { - return output->scale(); - } - return 1.0; -} - -qreal Screens::maxScale() const -{ - return m_maxScale; -} - -void Screens::updateSize() -{ - qreal maxScale = 1.0; - for (int i = 0; i < workspace()->outputs().count(); ++i) { - maxScale = qMax(maxScale, scale(i)); - } - if (!qFuzzyCompare(m_maxScale, maxScale)) { - m_maxScale = maxScale; - Q_EMIT maxScaleChanged(); - } -} - -Output *Screens::findOutput(int screen) const -{ - return workspace()->outputs().value(screen); -} - -} // namespace diff --git a/src/screens.h b/src/screens.h deleted file mode 100644 index bebe2c86ee..0000000000 --- a/src/screens.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2013 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#ifndef KWIN_SCREENS_H -#define KWIN_SCREENS_H - -// KWin includes -#include -// KDE includes -#include -#include -// Qt includes -#include -#include -#include -#include - -namespace KWin -{ -class Window; -class Output; -class Platform; - -class KWIN_EXPORT Screens : public QObject -{ - Q_OBJECT - -public: - explicit Screens(); - - void init(); - - /** - * The highest scale() of all connected screens - * for use when deciding what scale to load global assets at - * Similar to QGuiApplication::scale - * @see scale - */ - qreal maxScale() const; - - /** - * The output scale for this display, for use by high DPI displays - */ - qreal scale(int screen) const; - -Q_SIGNALS: - /** - * Emitted whenever the screens are changed either count or geometry. - */ - void changed(); - /** - * Emitted when the maximum scale of all attached screens changes - * @see maxScale - */ - void maxScaleChanged(); - -private Q_SLOTS: - void updateSize(); - -private: - Output *findOutput(int screenId) const; - - qreal m_maxScale; -}; -} - -#endif // KWIN_SCREENS_H diff --git a/src/tabbox/switcheritem.cpp b/src/tabbox/switcheritem.cpp index ae52ad4388..4bccd7b069 100644 --- a/src/tabbox/switcheritem.cpp +++ b/src/tabbox/switcheritem.cpp @@ -10,7 +10,6 @@ // KWin #include "composite.h" #include "core/output.h" -#include "screens.h" #include "tabboxhandler.h" #include "workspace.h" // Qt @@ -34,7 +33,7 @@ SwitcherItem::SwitcherItem(QObject *parent) setCurrentIndex(tabBox->currentIndex().row()); } }); - connect(workspace()->screens(), &Screens::changed, this, &SwitcherItem::screenGeometryChanged); + connect(workspace(), &Workspace::outputsChanged, this, &SwitcherItem::screenGeometryChanged); connect(Compositor::self(), &Compositor::compositingToggled, this, &SwitcherItem::compositingChanged); } diff --git a/src/waylandwindow.cpp b/src/waylandwindow.cpp index 894695faaa..eb6434a68b 100644 --- a/src/waylandwindow.cpp +++ b/src/waylandwindow.cpp @@ -7,7 +7,6 @@ */ #include "waylandwindow.h" -#include "screens.h" #include "wayland/clientbuffer.h" #include "wayland/clientconnection.h" #include "wayland/display.h" @@ -46,7 +45,7 @@ WaylandWindow::WaylandWindow(SurfaceInterface *surface) this, &WaylandWindow::updateClientOutputs); connect(this, &WaylandWindow::desktopFileNameChanged, this, &WaylandWindow::updateIcon); - connect(workspace()->screens(), &Screens::changed, this, &WaylandWindow::updateClientOutputs); + connect(workspace(), &Workspace::outputsChanged, this, &WaylandWindow::updateClientOutputs); connect(surface->client(), &ClientConnection::aboutToBeDestroyed, this, &WaylandWindow::destroyWindow); diff --git a/src/workspace.cpp b/src/workspace.cpp index 6712b72c2b..4a6e3fa8ff 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -38,7 +38,6 @@ #include "pluginmanager.h" #include "rules.h" #include "screenedge.h" -#include "screens.h" #include "scripting/scripting.h" #include "syncalarmx11filter.h" #include "x11window.h" @@ -161,7 +160,6 @@ Workspace::Workspace() m_rulebook = std::make_unique(); m_rulebook->load(); - m_screens = std::make_unique(); m_screenEdges = std::make_unique(); // VirtualDesktopManager needs to be created prior to init shortcuts @@ -213,8 +211,6 @@ void Workspace::init() slotPlatformOutputsQueried(); connect(kwinApp()->platform(), &Platform::outputsQueried, this, &Workspace::slotPlatformOutputsQueried); - m_screens->init(); - // create VirtualDesktopManager and perform dependency injection VirtualDesktopManager *vds = VirtualDesktopManager::self(); connect(vds, &VirtualDesktopManager::desktopCreated, this, &Workspace::slotDesktopAdded); @@ -3123,11 +3119,6 @@ ScreenEdges *Workspace::screenEdges() const return m_screenEdges.get(); } -Screens *Workspace::screens() const -{ - return m_screens.get(); -} - #if KWIN_BUILD_TABBOX TabBox::TabBox *Workspace::tabbox() const { diff --git a/src/workspace.h b/src/workspace.h index 0be9b2104c..1258e3f502 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -71,7 +71,6 @@ enum class Predicate; class Outline; class RuleBook; class ScreenEdges; -class Screens; #if KWIN_BUILD_ACTIVITIES class Activities; #endif @@ -456,7 +455,6 @@ public: Placement *placement() const; RuleBook *rulebook() const; ScreenEdges *screenEdges() const; - Screens *screens() const; #if KWIN_BUILD_TABBOX TabBox::TabBox *tabbox() const; #endif @@ -749,7 +747,6 @@ private: std::unique_ptr m_placement; std::unique_ptr m_rulebook; std::unique_ptr m_screenEdges; - std::unique_ptr m_screens; #if KWIN_BUILD_TABBOX std::unique_ptr m_tabbox; #endif