Drop Screens

This commit is contained in:
Vlad Zahorodnii 2022-10-19 10:10:03 +03:00
parent 9cf60224e6
commit 187f556f85
11 changed files with 15 additions and 172 deletions

View file

@ -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();
}

View file

@ -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<QRect>, geometries);
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::QueuedConnection,
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection,
Q_ARG(int, geometries.count()), Q_ARG(QVector<QRect>, 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<QRect>, geometries);
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::QueuedConnection,
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection,
Q_ARG(int, geometries.count()), Q_ARG(QVector<QRect>, geometries));
QVERIFY(changedSpy.wait());
// Disable "active screen follows mouse"
auto group = kwinApp()->config()->group("Windows");

View file

@ -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

View file

@ -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"

View file

@ -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()) {

View file

@ -1,67 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "screens.h"
#include <config-kwin.h>
#include "core/output.h"
#include "core/platform.h"
#include "cursor.h"
#include "settings.h"
#include "utils/common.h"
#include <window.h>
#include <workspace.h>
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

View file

@ -1,72 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_SCREENS_H
#define KWIN_SCREENS_H
// KWin includes
#include <kwinglobals.h>
// KDE includes
#include <KConfig>
#include <KSharedConfig>
// Qt includes
#include <QObject>
#include <QRect>
#include <QTimer>
#include <QVector>
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

View file

@ -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);
}

View file

@ -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);

View file

@ -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<RuleBook>();
m_rulebook->load();
m_screens = std::make_unique<Screens>();
m_screenEdges = std::make_unique<ScreenEdges>();
// 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
{

View file

@ -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<Placement> m_placement;
std::unique_ptr<RuleBook> m_rulebook;
std::unique_ptr<ScreenEdges> m_screenEdges;
std::unique_ptr<Screens> m_screens;
#if KWIN_BUILD_TABBOX
std::unique_ptr<TabBox::TabBox> m_tabbox;
#endif