diff --git a/src/core/output.cpp b/src/core/output.cpp index f95f979882..fd354f76cd 100644 --- a/src/core/output.cpp +++ b/src/core/output.cpp @@ -260,6 +260,16 @@ QRectF Output::mapToGlobal(const QRectF &rect) const return rect.translated(geometry().topLeft()); } +QPointF Output::mapToGlobal(const QPointF &pos) const +{ + return pos + geometry().topLeft(); +} + +QPointF Output::mapFromGlobal(const QPointF &pos) const +{ + return pos - geometry().topLeft(); +} + Output::Capabilities Output::capabilities() const { return m_information.capabilities; diff --git a/src/core/output.h b/src/core/output.h index c232d46943..277b9a325d 100644 --- a/src/core/output.h +++ b/src/core/output.h @@ -25,7 +25,6 @@ namespace KWin { -class EffectScreenImpl; class RenderLoop; class OutputConfiguration; class ColorTransformation; @@ -117,6 +116,12 @@ private: class KWIN_EXPORT Output : public QObject { Q_OBJECT + Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) + Q_PROPERTY(qreal devicePixelRatio READ scale NOTIFY scaleChanged) + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT) + Q_PROPERTY(QString model READ model CONSTANT) + Q_PROPERTY(QString serialNumber READ serialNumber CONSTANT) public: enum class DpmsMode { @@ -184,6 +189,9 @@ public: */ QRectF mapToGlobal(const QRectF &rect) const; + Q_INVOKABLE QPointF mapToGlobal(const QPointF &pos) const; + Q_INVOKABLE QPointF mapFromGlobal(const QPointF &pos) const; + /** * Returns a short identifiable name of this output. */ @@ -430,14 +438,12 @@ protected: void setInformation(const Information &information); void setState(const State &state); - EffectScreenImpl *m_effectScreen = nullptr; State m_state; Information m_information; QUuid m_uuid; int m_directScanoutCount = 0; int m_refCount = 1; ContentType m_contentType = ContentType::None; - friend class EffectScreenImpl; // to access m_effectScreen }; inline QRect Output::rect() const diff --git a/src/effects.cpp b/src/effects.cpp index 4c6386d31f..3de674775e 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -228,13 +228,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *s setupWindowConnections(window); } - connect(ws, &Workspace::outputAdded, this, &EffectsHandlerImpl::slotOutputAdded); - connect(ws, &Workspace::outputRemoved, this, &EffectsHandlerImpl::slotOutputRemoved); - - const QList outputs = ws->outputs(); - for (Output *output : outputs) { - slotOutputAdded(output); - } + connect(ws, &Workspace::outputAdded, this, &EffectsHandlerImpl::screenAdded); + connect(ws, &Workspace::outputRemoved, this, &EffectsHandlerImpl::screenRemoved); if (auto inputMethod = kwinApp()->inputMethod()) { connect(inputMethod, &InputMethod::panelChanged, this, &EffectsHandlerImpl::inputPanelChanged); @@ -284,7 +279,7 @@ void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData &data, std::chrono::m // no special final code } -void EffectsHandlerImpl::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void EffectsHandlerImpl::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) { (*m_currentPaintScreenIterator++)->paintScreen(renderTarget, viewport, mask, region, screen); @@ -751,12 +746,11 @@ void EffectsHandlerImpl::windowToDesktops(EffectWindow *w, const QList &de window->setDesktops(desktops); } -void EffectsHandlerImpl::windowToScreen(EffectWindow *w, EffectScreen *screen) +void EffectsHandlerImpl::windowToScreen(EffectWindow *w, Output *screen) { auto window = static_cast(w)->window(); if (window->isClient() && !window->isDesktop() && !window->isDock()) { - EffectScreenImpl *screenImpl = static_cast(screen); - Workspace::self()->sendWindowToOutput(window, screenImpl->platformOutput()); + Workspace::self()->sendWindowToOutput(window, screen); } } @@ -1024,9 +1018,9 @@ void EffectsHandlerImpl::addRepaint(int x, int y, int w, int h) m_compositor->scene()->addRepaint(x, y, w, h); } -EffectScreen *EffectsHandlerImpl::activeScreen() const +Output *EffectsHandlerImpl::activeScreen() const { - return EffectScreenImpl::get(workspace()->activeOutput()); + return workspace()->activeOutput(); } static VirtualDesktop *resolveVirtualDesktop(int desktopId) @@ -1038,10 +1032,9 @@ static VirtualDesktop *resolveVirtualDesktop(int desktopId) } } -QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const +QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const Output *screen, int desktop) const { - const EffectScreenImpl *screenImpl = static_cast(screen); - return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), resolveVirtualDesktop(desktop)); + return Workspace::self()->clientArea(opt, screen, resolveVirtualDesktop(desktop)); } QRectF EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *effectWindow) const @@ -1152,9 +1145,7 @@ void EffectsHandlerImpl::registerTouchBorder(ElectricBorder border, QAction *act void EffectsHandlerImpl::registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback) { - workspace()->screenEdges()->reserveTouch(border, action, [progressCallback](ElectricBorder border, const QPointF &deltaProgress, Output *output) { - progressCallback(border, deltaProgress, EffectScreenImpl::get(output)); - }); + workspace()->screenEdges()->reserveTouch(border, action, progressCallback); } void EffectsHandlerImpl::unregisterTouchBorder(ElectricBorder border, QAction *action) @@ -1579,19 +1570,20 @@ SessionState EffectsHandlerImpl::sessionState() const return Workspace::self()->sessionManager()->state(); } -QList EffectsHandlerImpl::screens() const +QList EffectsHandlerImpl::screens() const { - return m_effectScreens; + return Workspace::self()->outputs(); } -EffectScreen *EffectsHandlerImpl::screenAt(const QPoint &point) const +Output *EffectsHandlerImpl::screenAt(const QPoint &point) const { - return EffectScreenImpl::get(Workspace::self()->outputAt(point)); + return Workspace::self()->outputAt(point); } -EffectScreen *EffectsHandlerImpl::findScreen(const QString &name) const +Output *EffectsHandlerImpl::findScreen(const QString &name) const { - for (EffectScreen *screen : std::as_const(m_effectScreens)) { + const auto outputs = Workspace::self()->outputs(); + for (Output *screen : outputs) { if (screen->name() == name) { return screen; } @@ -1599,32 +1591,15 @@ EffectScreen *EffectsHandlerImpl::findScreen(const QString &name) const return nullptr; } -EffectScreen *EffectsHandlerImpl::findScreen(int screenId) const +Output *EffectsHandlerImpl::findScreen(int screenId) const { - return m_effectScreens.value(screenId); + return Workspace::self()->outputs().value(screenId); } -void EffectsHandlerImpl::slotOutputAdded(Output *output) -{ - EffectScreen *screen = new EffectScreenImpl(output, this); - m_effectScreens.append(screen); - Q_EMIT screenAdded(screen); -} - -void EffectsHandlerImpl::slotOutputRemoved(Output *output) -{ - EffectScreen *screen = EffectScreenImpl::get(output); - m_effectScreens.removeOne(screen); - Q_EMIT screenRemoved(screen); - delete screen; -} - -void EffectsHandlerImpl::renderScreen(EffectScreen *screen) +void EffectsHandlerImpl::renderScreen(Output *output) { RenderTarget renderTarget(GLFramebuffer::currentFramebuffer()); - auto output = static_cast(screen)->platformOutput(); - RenderLayer layer(output->renderLoop()); SceneDelegate delegate(m_scene, output); delegate.setLayer(&layer); @@ -1670,81 +1645,6 @@ QQmlEngine *EffectsHandlerImpl::qmlEngine() const return Scripting::self()->qmlEngine(); } -//**************************************** -// EffectScreenImpl -//**************************************** - -EffectScreenImpl::EffectScreenImpl(Output *output, QObject *parent) - : EffectScreen(parent) - , m_platformOutput(output) -{ - m_platformOutput->m_effectScreen = this; - - connect(output, &Output::aboutToChange, this, &EffectScreen::aboutToChange); - connect(output, &Output::changed, this, &EffectScreen::changed); - connect(output, &Output::wakeUp, this, &EffectScreen::wakeUp); - connect(output, &Output::aboutToTurnOff, this, &EffectScreen::aboutToTurnOff); - connect(output, &Output::scaleChanged, this, &EffectScreen::devicePixelRatioChanged); - connect(output, &Output::geometryChanged, this, &EffectScreen::geometryChanged); -} - -EffectScreenImpl::~EffectScreenImpl() -{ - if (m_platformOutput) { - m_platformOutput->m_effectScreen = nullptr; - } -} - -EffectScreenImpl *EffectScreenImpl::get(Output *output) -{ - return output->m_effectScreen; -} - -Output *EffectScreenImpl::platformOutput() const -{ - return m_platformOutput; -} - -QString EffectScreenImpl::name() const -{ - return m_platformOutput->name(); -} - -QString EffectScreenImpl::manufacturer() const -{ - return m_platformOutput->manufacturer(); -} - -QString EffectScreenImpl::model() const -{ - return m_platformOutput->model(); -} - -QString EffectScreenImpl::serialNumber() const -{ - return m_platformOutput->serialNumber(); -} - -qreal EffectScreenImpl::devicePixelRatio() const -{ - return m_platformOutput->scale(); -} - -QRect EffectScreenImpl::geometry() const -{ - return m_platformOutput->geometry(); -} - -int EffectScreenImpl::refreshRate() const -{ - return m_platformOutput->refreshRate(); -} - -EffectScreen::Transform EffectScreenImpl::transform() const -{ - return EffectScreen::Transform(m_platformOutput->transform().kind()); -} - //**************************************** // EffectWindowImpl //**************************************** @@ -1885,9 +1785,9 @@ void EffectWindowImpl::unrefWindow() Q_UNREACHABLE(); // TODO } -EffectScreen *EffectWindowImpl::screen() const +Output *EffectWindowImpl::screen() const { - return EffectScreenImpl::get(m_window->output()); + return m_window->output(); } #define WINDOW_HELPER(rettype, prototype, toplevelPrototype) \ diff --git a/src/effects.h b/src/effects.h index a112464331..e2ddf160ec 100644 --- a/src/effects.h +++ b/src/effects.h @@ -50,7 +50,7 @@ public: EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *scene); ~EffectsHandlerImpl() override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; @@ -65,7 +65,7 @@ public: EffectWindow *activeWindow() const override; void moveWindow(EffectWindow *w, const QPoint &pos, bool snap = false, double snapAdjust = 1.0) override; void windowToDesktop(EffectWindow *w, int desktop) override; - void windowToScreen(EffectWindow *w, EffectScreen *screen) override; + void windowToScreen(EffectWindow *w, Output *screen) override; void setShowingDesktop(bool showing) override; QString currentActivity() const override; @@ -126,8 +126,8 @@ public: void addRepaint(const QRegion &r) override; void addRepaint(int x, int y, int w, int h) override; - EffectScreen *activeScreen() const override; - QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override; + Output *activeScreen() const override; + QRectF clientArea(clientAreaOption, const Output *screen, int desktop) const override; QRectF clientArea(clientAreaOption, const EffectWindow *c) const override; QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const override; QSize virtualScreenSize() const override; @@ -238,11 +238,11 @@ public: void renderOffscreenQuickView(const RenderTarget &renderTarget, const RenderViewport &viewport, OffscreenQuickView *effectQuickView) const override; SessionState sessionState() const override; - QList screens() const override; - EffectScreen *screenAt(const QPoint &point) const override; - EffectScreen *findScreen(const QString &name) const override; - EffectScreen *findScreen(int screenId) const override; - void renderScreen(EffectScreen *screen) override; + QList screens() const override; + Output *screenAt(const QPoint &point) const override; + Output *findScreen(const QString &name) const override; + Output *findScreen(int screenId) const override; + void renderScreen(Output *screen) override; bool isCursorHidden() const override; KWin::EffectWindow *inputPanel() const override; @@ -262,10 +262,6 @@ public Q_SLOTS: Q_SCRIPTABLE QString supportInformation(const QString &name) const; Q_SCRIPTABLE QString debug(const QString &name, const QString ¶meter = QString()) const; -protected Q_SLOTS: - void slotOutputAdded(Output *output); - void slotOutputRemoved(Output *output); - protected: void connectNotify(const QMetaMethod &signal) override; void disconnectNotify(const QMetaMethod &signal) override; @@ -321,32 +317,6 @@ private: EffectLoader *m_effectLoader; int m_trackingCursorChanges; std::unique_ptr m_x11WindowPropertyNotify; - QList m_effectScreens; -}; - -class EffectScreenImpl : public EffectScreen -{ - Q_OBJECT - -public: - explicit EffectScreenImpl(Output *output, QObject *parent = nullptr); - ~EffectScreenImpl() override; - - Output *platformOutput() const; - - QString name() const override; - QString manufacturer() const override; - QString model() const override; - QString serialNumber() const override; - qreal devicePixelRatio() const override; - QRect geometry() const override; - int refreshRate() const override; - Transform transform() const override; - - static EffectScreenImpl *get(Output *output); - -private: - QPointer m_platformOutput; }; class EffectWindowImpl : public EffectWindow @@ -386,7 +356,7 @@ public: QString caption() const override; QRectF expandedGeometry() const override; - EffectScreen *screen() const override; + Output *screen() const override; QPointF pos() const override; QSizeF size() const override; QRectF rect() const override; diff --git a/src/libkwineffects/effecttogglablestate.cpp b/src/libkwineffects/effecttogglablestate.cpp index 721a80bf35..20f90b3592 100644 --- a/src/libkwineffects/effecttogglablestate.cpp +++ b/src/libkwineffects/effecttogglablestate.cpp @@ -241,7 +241,7 @@ void EffectTogglableTouchBorder::setBorders(const QList &touchActivateBorde for (const int &border : touchActivateBorders) { m_touchBorderActivate.append(ElectricBorder(border)); - effects->registerRealtimeTouchBorder(ElectricBorder(border), m_state->toggleAction(), [this](ElectricBorder border, const QPointF &deltaProgress, const EffectScreen *screen) { + effects->registerRealtimeTouchBorder(ElectricBorder(border), m_state->toggleAction(), [this](ElectricBorder border, const QPointF &deltaProgress, const Output *screen) { if (m_state->status() == EffectTogglableState::Status::Active) { return; } diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index dcf4b75dc5..81b2105265 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -10,6 +10,7 @@ */ #include "libkwineffects/kwineffects.h" +#include "core/output.h" #include "config-kwin.h" @@ -431,7 +432,7 @@ void Effect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds effects->prePaintScreen(data, presentTime); } -void Effect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void Effect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); } @@ -627,21 +628,6 @@ bool EffectsHandler::isOpenGLCompositing() const EffectsHandler *effects = nullptr; -EffectScreen::EffectScreen(QObject *parent) - : QObject(parent) -{ -} - -QPointF EffectScreen::mapToGlobal(const QPointF &pos) const -{ - return pos + geometry().topLeft(); -} - -QPointF EffectScreen::mapFromGlobal(const QPointF &pos) const -{ - return pos - geometry().topLeft(); -} - //**************************************** // EffectWindow //**************************************** diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index e39ad04eda..0eafdbc099 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -73,7 +73,7 @@ class EffectWindowGroup; class EffectFrame; class EffectFramePrivate; class OffscreenQuickView; -class EffectScreen; +class Output; class Effect; class WindowQuad; class WindowQuadList; @@ -380,7 +380,7 @@ public: * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. */ - virtual void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen); + virtual void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen); /** * Called after all the painting has been finished. * In this method you can: @@ -801,7 +801,7 @@ class KWIN_EXPORT EffectsHandler : public QObject */ Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged) Q_PROPERTY(bool optionRollOverDesktops READ optionRollOverDesktops) - Q_PROPERTY(KWin::EffectScreen *activeScreen READ activeScreen) + Q_PROPERTY(KWin::Output *activeScreen READ activeScreen) /** * Factor by which animation speed in the effect should be modified (multiplied). * If configurable in the effect itself, the option should have also 'default' @@ -832,13 +832,13 @@ class KWIN_EXPORT EffectsHandler : public QObject friend class Effect; public: - using TouchBorderCallback = std::function; + using TouchBorderCallback = std::function; explicit EffectsHandler(CompositingType type); ~EffectsHandler() override; // for use by effects virtual void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) = 0; - virtual void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) = 0; + virtual void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) = 0; virtual void postPaintScreen() = 0; virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) = 0; virtual void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) = 0; @@ -982,7 +982,7 @@ public: */ Q_SCRIPTABLE virtual void windowToDesktops(KWin::EffectWindow *w, const QList &desktopIds) = 0; - Q_SCRIPTABLE virtual void windowToScreen(KWin::EffectWindow *w, EffectScreen *screen) = 0; + Q_SCRIPTABLE virtual void windowToScreen(KWin::EffectWindow *w, Output *screen) = 0; virtual void setShowingDesktop(bool showing) = 0; // Activities @@ -1063,8 +1063,8 @@ public: Q_SCRIPTABLE virtual QString desktopName(int desktop) const = 0; virtual bool optionRollOverDesktops() const = 0; - virtual EffectScreen *activeScreen() const = 0; // Xinerama - virtual QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const = 0; + virtual Output *activeScreen() const = 0; // Xinerama + virtual QRectF clientArea(clientAreaOption, const Output *screen, int desktop) const = 0; virtual QRectF clientArea(clientAreaOption, const EffectWindow *c) const = 0; virtual QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const = 0; @@ -1392,15 +1392,15 @@ public: /** * Returns the list of all the screens connected to the system. */ - virtual QList screens() const = 0; - virtual EffectScreen *screenAt(const QPoint &point) const = 0; - virtual EffectScreen *findScreen(const QString &name) const = 0; - virtual EffectScreen *findScreen(int screenId) const = 0; + virtual QList screens() const = 0; + virtual Output *screenAt(const QPoint &point) const = 0; + virtual Output *findScreen(const QString &name) const = 0; + virtual Output *findScreen(int screenId) const = 0; /** * Renders @p screen in the current render target */ - virtual void renderScreen(EffectScreen *screen) = 0; + virtual void renderScreen(Output *screen) = 0; virtual KWin::EffectWindow *inputPanel() const = 0; virtual bool isInputPanelOverlay() const = 0; @@ -1411,11 +1411,11 @@ Q_SIGNALS: /** * This signal is emitted whenever a new @a screen is added to the system. */ - void screenAdded(KWin::EffectScreen *screen); + void screenAdded(KWin::Output *screen); /** * This signal is emitted whenever a @a screen is removed from the system. */ - void screenRemoved(KWin::EffectScreen *screen); + void screenRemoved(KWin::Output *screen); /** * Signal emitted when the current desktop changed. * @param oldDesktop The previously current desktop @@ -1702,100 +1702,6 @@ protected: CompositingType compositing_type; }; -/** - * The EffectScreen class represents a screen used by/for Effect classes. - */ -class KWIN_EXPORT EffectScreen : public QObject -{ - Q_OBJECT - Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) - Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) - Q_PROPERTY(QString name READ name CONSTANT) - Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT) - Q_PROPERTY(QString model READ model CONSTANT) - Q_PROPERTY(QString serialNumber READ serialNumber CONSTANT) - Q_PROPERTY(qreal refreshRate READ refreshRate CONSTANT) - -public: - explicit EffectScreen(QObject *parent = nullptr); - - /** - * Returns the name of the screen, e.g. "DP-1". - */ - virtual QString name() const = 0; - - /** - * Returns the screen's ratio between physical pixels and device-independent pixels. - */ - virtual qreal devicePixelRatio() const = 0; - - /** - * Returns the screen's geometry in the device-independent pixels. - */ - virtual QRect geometry() const = 0; - - Q_INVOKABLE QPointF mapToGlobal(const QPointF &pos) const; - Q_INVOKABLE QPointF mapFromGlobal(const QPointF &pos) const; - - /** - * Returns the screen's refresh rate in milli-hertz. - */ - virtual int refreshRate() const = 0; - - enum class Transform { - Normal, - Rotated90, - Rotated180, - Rotated270, - Flipped, - Flipped90, - Flipped180, - Flipped270 - }; - Q_ENUM(Transform) - virtual Transform transform() const = 0; - - virtual QString manufacturer() const = 0; - virtual QString model() const = 0; - virtual QString serialNumber() const = 0; - -Q_SIGNALS: - /** - * Notifies that the display will be dimmed in @p time ms. - */ - void aboutToTurnOff(std::chrono::milliseconds time); - - /** - * Notifies that the output has been turned on and the wake can be decorated. - */ - void wakeUp(); - - /** - * This signal is emitted when the geometry of this screen changes. - */ - void geometryChanged(); - - /** - * This signal is emitted when the device pixel ratio of this screen changes. - */ - void devicePixelRatioChanged(); - - /** - * Notifies that the output is about to change configuration based on a - * user interaction. - * - * Be it because it gets a transformation or moved around. - */ - void aboutToChange(); - - /** - * Notifies that the output changed based on a user interaction. - * - * Be it because it gets a transformation or moved around. - */ - void changed(); -}; - class EffectWindowVisibleRef; /** * @short Representation of a window used by/for Effect classes. @@ -1811,7 +1717,7 @@ class KWIN_EXPORT EffectWindow : public QObject Q_PROPERTY(qreal height READ height) Q_PROPERTY(qreal opacity READ opacity) Q_PROPERTY(QPointF pos READ pos) - Q_PROPERTY(KWin::EffectScreen *screen READ screen) + Q_PROPERTY(KWin::Output *screen READ screen) Q_PROPERTY(QSizeF size READ size) Q_PROPERTY(qreal width READ width) Q_PROPERTY(qreal x READ x) @@ -2170,7 +2076,7 @@ public: * @since 4.9 */ virtual QRectF expandedGeometry() const = 0; - virtual EffectScreen *screen() const = 0; + virtual Output *screen() const = 0; virtual QPointF pos() const = 0; virtual QSizeF size() const = 0; virtual QRectF rect() const = 0; @@ -3296,7 +3202,7 @@ class KWIN_EXPORT ScreenPrePaintData public: int mask; QRegion paint; - EffectScreen *screen = nullptr; + Output *screen = nullptr; }; /** diff --git a/src/libkwineffects/kwinoffscreeneffect.cpp b/src/libkwineffects/kwinoffscreeneffect.cpp index adedeb6453..f37be13945 100644 --- a/src/libkwineffects/kwinoffscreeneffect.cpp +++ b/src/libkwineffects/kwinoffscreeneffect.cpp @@ -5,6 +5,7 @@ */ #include "libkwineffects/kwinoffscreeneffect.h" +#include "core/output.h" #include "libkwineffects/gltexture.h" #include "libkwineffects/glutils.h" #include "libkwineffects/rendertarget.h" @@ -94,7 +95,7 @@ void OffscreenEffect::apply(EffectWindow *window, int mask, WindowPaintData &dat void OffscreenData::maybeRender(EffectWindow *window) { const QRectF logicalGeometry = window->expandedGeometry(); - const qreal scale = window->screen()->devicePixelRatio(); + const qreal scale = window->screen()->scale(); const QSize textureSize = (logicalGeometry.size() * scale).toSize(); if (!m_texture || m_texture->size() != textureSize) { diff --git a/src/libkwineffects/kwinquickeffect.cpp b/src/libkwineffects/kwinquickeffect.cpp index fc3b7b2e95..adc63930db 100644 --- a/src/libkwineffects/kwinquickeffect.cpp +++ b/src/libkwineffects/kwinquickeffect.cpp @@ -5,6 +5,7 @@ */ #include "libkwineffects/kwinquickeffect.h" +#include "core/output.h" #include "logging_p.h" @@ -22,7 +23,7 @@ static QHash s_views; class QuickSceneViewIncubator : public QQmlIncubator { public: - QuickSceneViewIncubator(QuickSceneEffect *effect, EffectScreen *screen, const std::function &statusChangedCallback) + QuickSceneViewIncubator(QuickSceneEffect *effect, Output *screen, const std::function &statusChangedCallback) : QQmlIncubator(QQmlIncubator::Asynchronous) , m_effect(effect) , m_screen(screen) @@ -49,7 +50,7 @@ public: private: QuickSceneEffect *m_effect; - EffectScreen *m_screen; + Output *m_screen; std::function m_statusChangedCallback; std::unique_ptr m_view; }; @@ -61,18 +62,18 @@ public: { return effect->d.get(); } - bool isItemOnScreen(QQuickItem *item, EffectScreen *screen) const; + bool isItemOnScreen(QQuickItem *item, Output *screen) const; std::unique_ptr delegate; QUrl source; - std::map> contexts; - std::map> incubators; - std::map> views; + std::map> contexts; + std::map> incubators; + std::map> views; QPointer mouseImplicitGrab; bool running = false; }; -bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem *item, EffectScreen *screen) const +bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem *item, Output *screen) const { if (!item || !screen || !views.contains(screen)) { return false; @@ -82,12 +83,12 @@ bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem *item, EffectScreen *scr return item->window() == view->window(); } -QuickSceneView::QuickSceneView(QuickSceneEffect *effect, EffectScreen *screen) +QuickSceneView::QuickSceneView(QuickSceneEffect *effect, Output *screen) : m_effect(effect) , m_screen(screen) { setGeometry(screen->geometry()); - connect(screen, &EffectScreen::geometryChanged, this, [this, screen]() { + connect(screen, &Output::geometryChanged, this, [this, screen]() { setGeometry(screen->geometry()); }); @@ -123,7 +124,7 @@ QuickSceneEffect *QuickSceneView::effect() const return m_effect; } -EffectScreen *QuickSceneView::screen() const +Output *QuickSceneView::screen() const { return m_screen; } @@ -184,7 +185,7 @@ bool QuickSceneEffect::supported() void QuickSceneEffect::checkItemDraggedOutOfScreen(QQuickItem *item) { const QRectF globalGeom = QRectF(item->mapToGlobal(QPointF(0, 0)), QSizeF(item->width(), item->height())); - QList screens; + QList screens; for (const auto &[screen, view] : d->views) { if (!d->isItemOnScreen(item, screen) && screen->geometry().intersects(globalGeom.toRect())) { @@ -198,7 +199,7 @@ void QuickSceneEffect::checkItemDraggedOutOfScreen(QQuickItem *item) void QuickSceneEffect::checkItemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item) { const auto it = std::find_if(d->views.begin(), d->views.end(), [this, globalPos, item](const auto &view) { - EffectScreen *screen = view.first; + Output *screen = view.first; return !d->isItemOnScreen(item, screen) && screen->geometry().contains(globalPos.toPoint()); }); if (it != d->views.end()) { @@ -267,7 +268,7 @@ void QuickSceneEffect::setDelegate(QQmlComponent *delegate) } } -QuickSceneView *QuickSceneEffect::viewForScreen(EffectScreen *screen) const +QuickSceneView *QuickSceneEffect::viewForScreen(Output *screen) const { const auto it = d->views.find(screen); return it == d->views.end() ? nullptr : it->second.get(); @@ -379,7 +380,7 @@ void QuickSceneEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil } } -void QuickSceneEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void QuickSceneEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { if (effects->waylandDisplay()) { const auto it = d->views.find(screen); @@ -398,24 +399,24 @@ bool QuickSceneEffect::isActive() const return !d->views.empty() && !effects->isScreenLocked(); } -QVariantMap QuickSceneEffect::initialProperties(EffectScreen *screen) +QVariantMap QuickSceneEffect::initialProperties(Output *screen) { return QVariantMap(); } -void QuickSceneEffect::handleScreenAdded(EffectScreen *screen) +void QuickSceneEffect::handleScreenAdded(Output *screen) { addScreen(screen); } -void QuickSceneEffect::handleScreenRemoved(EffectScreen *screen) +void QuickSceneEffect::handleScreenRemoved(Output *screen) { d->views.erase(screen); d->incubators.erase(screen); d->contexts.erase(screen); } -void QuickSceneEffect::addScreen(EffectScreen *screen) +void QuickSceneEffect::addScreen(Output *screen) { auto properties = initialProperties(screen); properties["width"] = screen->geometry().width(); @@ -481,8 +482,8 @@ void QuickSceneEffect::startInternal() // Install an event filter to monitor cursor shape changes. qApp->installEventFilter(this); - const QList screens = effects->screens(); - for (EffectScreen *screen : screens) { + const QList screens = effects->screens(); + for (Output *screen : screens) { addScreen(screen); } diff --git a/src/libkwineffects/kwinquickeffect.h b/src/libkwineffects/kwinquickeffect.h index 212dc75ce1..08907e9336 100644 --- a/src/libkwineffects/kwinquickeffect.h +++ b/src/libkwineffects/kwinquickeffect.h @@ -6,6 +6,7 @@ #pragma once +#include "core/output.h" #include "libkwineffects/kwineffects.h" #include "libkwineffects/kwinoffscreenquickview.h" @@ -29,15 +30,15 @@ class KWIN_EXPORT QuickSceneView : public OffscreenQuickView { Q_OBJECT Q_PROPERTY(QuickSceneEffect *effect READ effect CONSTANT) - Q_PROPERTY(EffectScreen *screen READ screen CONSTANT) + Q_PROPERTY(Output *screen READ screen CONSTANT) Q_PROPERTY(QQuickItem *rootItem READ rootItem CONSTANT) public: - explicit QuickSceneView(QuickSceneEffect *effect, EffectScreen *screen); + explicit QuickSceneView(QuickSceneEffect *effect, Output *screen); ~QuickSceneView() override; QuickSceneEffect *effect() const; - EffectScreen *screen() const; + Output *screen() const; QQuickItem *rootItem() const; void setRootItem(QQuickItem *item); @@ -54,7 +55,7 @@ public Q_SLOTS: private: QuickSceneEffect *m_effect; - EffectScreen *m_screen; + Output *m_screen; std::unique_ptr m_rootItem; bool m_dirty = false; }; @@ -96,7 +97,7 @@ public: /** * Returns the scene view on the specified screen */ - Q_INVOKABLE QuickSceneView *viewForScreen(EffectScreen *screen) const; + Q_INVOKABLE QuickSceneView *viewForScreen(Output *screen) const; /** * Returns the view at the specified @a pos in the global screen coordinates. @@ -139,7 +140,7 @@ public: bool eventFilter(QObject *watched, QEvent *event) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; bool isActive() const override; void windowInputMouseEvent(QEvent *event) override; @@ -155,8 +156,8 @@ public: Q_INVOKABLE void checkItemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item); Q_SIGNALS: - void itemDraggedOutOfScreen(QQuickItem *item, QList screens); - void itemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item, EffectScreen *screen); + void itemDraggedOutOfScreen(QQuickItem *item, QList screens); + void itemDroppedOutOfScreen(const QPointF &globalPos, QQuickItem *item, Output *screen); void activeViewChanged(KWin::QuickSceneView *view); void delegateChanged(); @@ -167,13 +168,13 @@ protected: * * @see QQmlComponent::createWithInitialProperties() */ - virtual QVariantMap initialProperties(EffectScreen *screen); + virtual QVariantMap initialProperties(Output *screen); private: - void handleScreenAdded(EffectScreen *screen); - void handleScreenRemoved(EffectScreen *screen); + void handleScreenAdded(Output *screen); + void handleScreenRemoved(Output *screen); - void addScreen(EffectScreen *screen); + void addScreen(Output *screen); void startInternal(); void stopInternal(); diff --git a/src/plugins/blur/blur.cpp b/src/plugins/blur/blur.cpp index c3ca486e0c..d06507dc2c 100644 --- a/src/plugins/blur/blur.cpp +++ b/src/plugins/blur/blur.cpp @@ -286,7 +286,7 @@ void BlurEffect::slotWindowDeleted(EffectWindow *w) } } -void BlurEffect::slotScreenRemoved(KWin::EffectScreen *screen) +void BlurEffect::slotScreenRemoved(KWin::Output *screen) { for (auto &[window, data] : m_windows) { if (auto it = data.render.find(screen); it != data.render.end()) { diff --git a/src/plugins/blur/blur.h b/src/plugins/blur/blur.h index 006ca9310a..d1230a42b9 100644 --- a/src/plugins/blur/blur.h +++ b/src/plugins/blur/blur.h @@ -33,7 +33,7 @@ struct BlurEffectData QRegion region; /// The render data per screen. Screens can have different color spaces. - std::unordered_map render; + std::unordered_map render; }; class BlurEffect : public KWin::Effect @@ -67,7 +67,7 @@ public: public Q_SLOTS: void slotWindowAdded(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); - void slotScreenRemoved(KWin::EffectScreen *screen); + void slotScreenRemoved(KWin::Output *screen); void slotPropertyNotify(KWin::EffectWindow *w, long atom); void setupDecorationConnections(EffectWindow *w); @@ -114,7 +114,7 @@ private: long net_wm_blur_region = 0; QRegion m_paintedArea; // keeps track of all painted areas (from bottom to top) QRegion m_currentBlur; // keeps track of the currently blured area of the windows(from bottom to top) - EffectScreen *m_currentScreen = nullptr; + Output *m_currentScreen = nullptr; size_t m_iterationCount; // number of times the texture will be downsized to half size int m_offset; diff --git a/src/plugins/colorpicker/colorpicker.cpp b/src/plugins/colorpicker/colorpicker.cpp index a00ab0011b..a620242712 100644 --- a/src/plugins/colorpicker/colorpicker.cpp +++ b/src/plugins/colorpicker/colorpicker.cpp @@ -52,7 +52,7 @@ ColorPickerEffect::ColorPickerEffect() ColorPickerEffect::~ColorPickerEffect() = default; -void ColorPickerEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ColorPickerEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); diff --git a/src/plugins/colorpicker/colorpicker.h b/src/plugins/colorpicker/colorpicker.h index a318a39807..9763454227 100644 --- a/src/plugins/colorpicker/colorpicker.h +++ b/src/plugins/colorpicker/colorpicker.h @@ -25,7 +25,7 @@ class ColorPickerEffect : public Effect, protected QDBusContext public: ColorPickerEffect(); ~ColorPickerEffect() override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; bool isActive() const override; int requestedEffectChainPosition() const override diff --git a/src/plugins/kscreen/kscreen.cpp b/src/plugins/kscreen/kscreen.cpp index 11fd14d7ed..5b288fdd05 100644 --- a/src/plugins/kscreen/kscreen.cpp +++ b/src/plugins/kscreen/kscreen.cpp @@ -8,6 +8,7 @@ */ // own #include "kscreen.h" +#include "core/output.h" // KConfigSkeleton #include "kscreenconfig.h" #include @@ -55,12 +56,12 @@ KscreenEffect::KscreenEffect() } reconfigure(ReconfigureAll); - const QList screens = effects->screens(); + const QList screens = effects->screens(); for (auto screen : screens) { addScreen(screen); } connect(effects, &EffectsHandler::screenAdded, this, &KscreenEffect::addScreen); - connect(effects, &EffectsHandler::screenRemoved, this, [this](KWin::EffectScreen *screen) { + connect(effects, &EffectsHandler::screenRemoved, this, [this](KWin::Output *screen) { m_waylandStates.remove(screen); }); } @@ -69,14 +70,14 @@ KscreenEffect::~KscreenEffect() { } -void KscreenEffect::addScreen(EffectScreen *screen) +void KscreenEffect::addScreen(Output *screen) { - connect(screen, &EffectScreen::wakeUp, this, [this, screen] { + connect(screen, &Output::wakeUp, this, [this, screen] { auto &state = m_waylandStates[screen]; state.m_timeLine.setDuration(std::chrono::milliseconds(animationTime(250))); setState(state, StateFadingIn); }); - connect(screen, &EffectScreen::aboutToTurnOff, this, [this, screen](std::chrono::milliseconds dimmingIn) { + connect(screen, &Output::aboutToTurnOff, this, [this, screen](std::chrono::milliseconds dimmingIn) { auto &state = m_waylandStates[screen]; state.m_timeLine.setDuration(dimmingIn); setState(state, StateFadingOut); @@ -210,7 +211,7 @@ bool KscreenEffect::isActive() const return !m_waylandStates.isEmpty() || (!effects->waylandDisplay() && m_atom && m_xcbState.m_state != StateNormal); } -bool KscreenEffect::isScreenActive(EffectScreen *screen) const +bool KscreenEffect::isScreenActive(Output *screen) const { return m_waylandStates.contains(screen) || (!effects->waylandDisplay() && m_atom && m_xcbState.m_state != StateNormal); } diff --git a/src/plugins/kscreen/kscreen.h b/src/plugins/kscreen/kscreen.h index 1a96426a04..dcc9b7ab45 100644 --- a/src/plugins/kscreen/kscreen.h +++ b/src/plugins/kscreen/kscreen.h @@ -53,12 +53,12 @@ private: void switchState(ScreenState &state); void setState(ScreenState &state, FadeOutState newState); - void addScreen(EffectScreen *screen); - bool isScreenActive(EffectScreen *screen) const; + void addScreen(Output *screen); + bool isScreenActive(Output *screen) const; - QHash m_waylandStates; + QHash m_waylandStates; ScreenState m_xcbState; - EffectScreen *m_currentScreen = nullptr; + Output *m_currentScreen = nullptr; xcb_atom_t m_atom; }; diff --git a/src/plugins/magnifier/magnifier.cpp b/src/plugins/magnifier/magnifier.cpp index bae73e845e..8ef9fa69e8 100644 --- a/src/plugins/magnifier/magnifier.cpp +++ b/src/plugins/magnifier/magnifier.cpp @@ -114,7 +114,7 @@ void MagnifierEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mill } } -void MagnifierEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void MagnifierEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); // paint normal screen if (m_zoom != 1.0) { diff --git a/src/plugins/magnifier/magnifier.h b/src/plugins/magnifier/magnifier.h index 58dca0ddc3..b067b69698 100644 --- a/src/plugins/magnifier/magnifier.h +++ b/src/plugins/magnifier/magnifier.h @@ -28,7 +28,7 @@ public: ~MagnifierEffect() override; void reconfigure(ReconfigureFlags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; static bool supported(); diff --git a/src/plugins/mouseclick/mouseclick.cpp b/src/plugins/mouseclick/mouseclick.cpp index d586f29d7f..440dbf30b8 100644 --- a/src/plugins/mouseclick/mouseclick.cpp +++ b/src/plugins/mouseclick/mouseclick.cpp @@ -97,7 +97,7 @@ void MouseClickEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil effects->prePaintScreen(data, presentTime); } -void MouseClickEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void MouseClickEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); diff --git a/src/plugins/mouseclick/mouseclick.h b/src/plugins/mouseclick/mouseclick.h index 2bede5038d..9421a7a7b4 100644 --- a/src/plugins/mouseclick/mouseclick.h +++ b/src/plugins/mouseclick/mouseclick.h @@ -97,7 +97,7 @@ public: ~MouseClickEffect() override; void reconfigure(ReconfigureFlags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; diff --git a/src/plugins/mousemark/mousemark.cpp b/src/plugins/mousemark/mousemark.cpp index a9b80315f2..3981509a97 100644 --- a/src/plugins/mousemark/mousemark.cpp +++ b/src/plugins/mousemark/mousemark.cpp @@ -99,7 +99,7 @@ void MouseMarkEffect::reconfigure(ReconfigureFlags) } } -void MouseMarkEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void MouseMarkEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); // paint normal screen if (marks.isEmpty() && drawing.isEmpty()) { diff --git a/src/plugins/mousemark/mousemark.h b/src/plugins/mousemark/mousemark.h index a1f1607000..a3df6c2ee0 100644 --- a/src/plugins/mousemark/mousemark.h +++ b/src/plugins/mousemark/mousemark.h @@ -28,7 +28,7 @@ public: MouseMarkEffect(); ~MouseMarkEffect() override; void reconfigure(ReconfigureFlags) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; bool isActive() const override; int requestedEffectChainPosition() const override; diff --git a/src/plugins/outputlocator/outputlocator.cpp b/src/plugins/outputlocator/outputlocator.cpp index 3e98c0b727..9cd93ab6c4 100644 --- a/src/plugins/outputlocator/outputlocator.cpp +++ b/src/plugins/outputlocator/outputlocator.cpp @@ -5,8 +5,9 @@ */ #include "outputlocator.h" - +#include "core/output.h" #include "libkwineffects/kwinoffscreenquickview.h" + #include #include @@ -17,13 +18,13 @@ namespace KWin { -static QString outputName(const EffectScreen *screen) +static QString outputName(const Output *screen) { const auto screens = effects->screens(); - const bool shouldShowSerialNumber = std::any_of(screens.cbegin(), screens.cend(), [screen](const EffectScreen *other) { + const bool shouldShowSerialNumber = std::any_of(screens.cbegin(), screens.cend(), [screen](const Output *other) { return other != screen && other->manufacturer() == screen->manufacturer() && other->model() == screen->model(); }); - const bool shouldShowConnector = shouldShowSerialNumber && std::any_of(screens.cbegin(), screens.cend(), [screen](const EffectScreen *other) { + const bool shouldShowConnector = shouldShowSerialNumber && std::any_of(screens.cbegin(), screens.cend(), [screen](const Output *other) { return other != screen && other->serialNumber() == screen->serialNumber(); }); @@ -77,7 +78,7 @@ void OutputLocatorEffect::show() const auto screens = effects->screens(); for (const auto screen : screens) { auto scene = new OffscreenQuickScene(); - scene->setSource(m_qmlUrl, {{QStringLiteral("outputName"), outputName(screen)}, {QStringLiteral("resolution"), screen->geometry().size()}, {QStringLiteral("scale"), screen->devicePixelRatio()}}); + scene->setSource(m_qmlUrl, {{QStringLiteral("outputName"), outputName(screen)}, {QStringLiteral("resolution"), screen->geometry().size()}, {QStringLiteral("scale"), screen->scale()}}); QRectF geometry(0, 0, scene->rootItem()->implicitWidth(), scene->rootItem()->implicitHeight()); geometry.moveCenter(screen->geometry().center()); scene->setGeometry(geometry.toRect()); @@ -103,7 +104,7 @@ void OutputLocatorEffect::hide() effects->addRepaint(repaintRegion); } -void OutputLocatorEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::EffectScreen *screen) +void OutputLocatorEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); // On X11 all screens are painted at once diff --git a/src/plugins/outputlocator/outputlocator.h b/src/plugins/outputlocator/outputlocator.h index 4b58b04d90..b4beff06d8 100644 --- a/src/plugins/outputlocator/outputlocator.h +++ b/src/plugins/outputlocator/outputlocator.h @@ -22,7 +22,7 @@ class OutputLocatorEffect : public KWin::Effect public: explicit OutputLocatorEffect(QObject *parent = nullptr); - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::Output *screen) override; bool isActive() const override; public Q_SLOTS: @@ -32,6 +32,6 @@ public Q_SLOTS: private: QUrl m_qmlUrl; QTimer m_showTimer; - std::unordered_map> m_scenesByScreens; + std::unordered_map> m_scenesByScreens; }; } diff --git a/src/plugins/private/expoarea.cpp b/src/plugins/private/expoarea.cpp index 689eab2be2..eb7e4735f7 100644 --- a/src/plugins/private/expoarea.cpp +++ b/src/plugins/private/expoarea.cpp @@ -5,6 +5,7 @@ */ #include "expoarea.h" +#include "core/output.h" namespace KWin { @@ -34,20 +35,20 @@ qreal ExpoArea::height() const return m_rect.height(); } -EffectScreen *ExpoArea::screen() const +Output *ExpoArea::screen() const { return m_screen; } -void ExpoArea::setScreen(EffectScreen *screen) +void ExpoArea::setScreen(Output *screen) { if (m_screen != screen) { if (m_screen) { - disconnect(m_screen, &EffectScreen::geometryChanged, this, &ExpoArea::update); + disconnect(m_screen, &Output::geometryChanged, this, &ExpoArea::update); } m_screen = screen; if (m_screen) { - connect(m_screen, &EffectScreen::geometryChanged, this, &ExpoArea::update); + connect(m_screen, &Output::geometryChanged, this, &ExpoArea::update); } update(); Q_EMIT screenChanged(); diff --git a/src/plugins/private/expoarea.h b/src/plugins/private/expoarea.h index 5fb774c5c8..426365bbd8 100644 --- a/src/plugins/private/expoarea.h +++ b/src/plugins/private/expoarea.h @@ -14,7 +14,7 @@ namespace KWin class ExpoArea : public QObject { Q_OBJECT - Q_PROPERTY(KWin::EffectScreen *screen READ screen WRITE setScreen NOTIFY screenChanged) + Q_PROPERTY(KWin::Output *screen READ screen WRITE setScreen NOTIFY screenChanged) Q_PROPERTY(qreal x READ x NOTIFY xChanged) Q_PROPERTY(qreal y READ y NOTIFY yChanged) Q_PROPERTY(qreal width READ width NOTIFY widthChanged) @@ -23,8 +23,8 @@ class ExpoArea : public QObject public: explicit ExpoArea(QObject *parent = nullptr); - EffectScreen *screen() const; - void setScreen(EffectScreen *screen); + Output *screen() const; + void setScreen(Output *screen); qreal x() const; qreal y() const; @@ -42,7 +42,7 @@ private: void update(); QRectF m_rect; - EffectScreen *m_screen = nullptr; + Output *m_screen = nullptr; }; } // namespace KWin diff --git a/src/plugins/screenedge/screenedgeeffect.cpp b/src/plugins/screenedge/screenedgeeffect.cpp index 99e1493c9a..f5aa47b872 100644 --- a/src/plugins/screenedge/screenedgeeffect.cpp +++ b/src/plugins/screenedge/screenedgeeffect.cpp @@ -88,7 +88,7 @@ void ScreenEdgeEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil } } -void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); for (auto &[border, glow] : m_borders) { diff --git a/src/plugins/screenedge/screenedgeeffect.h b/src/plugins/screenedge/screenedgeeffect.h index 843752c90a..d35e11595b 100644 --- a/src/plugins/screenedge/screenedgeeffect.h +++ b/src/plugins/screenedge/screenedgeeffect.h @@ -29,7 +29,7 @@ public: ScreenEdgeEffect(); ~ScreenEdgeEffect() override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; bool isActive() const override; int requestedEffectChainPosition() const override diff --git a/src/plugins/screenshot/screenshot.cpp b/src/plugins/screenshot/screenshot.cpp index 66ad071cad..54beef2493 100644 --- a/src/plugins/screenshot/screenshot.cpp +++ b/src/plugins/screenshot/screenshot.cpp @@ -11,6 +11,7 @@ #include "screenshot.h" #include "screenshotdbusinterface2.h" +#include "core/output.h" #include "libkwineffects/glplatform.h" #include "libkwineffects/glutils.h" #include "libkwineffects/rendertarget.h" @@ -34,14 +35,14 @@ struct ScreenShotAreaData ScreenShotFlags flags; QRect area; QImage result; - QList screens; + QList screens; }; struct ScreenShotScreenData { QPromise promise; ScreenShotFlags flags; - EffectScreen *screen = nullptr; + Output *screen = nullptr; }; static void convertFromGLImage(QImage &img, int w, int h, const QMatrix4x4 &renderTargetTransformation) @@ -100,7 +101,7 @@ ScreenShotEffect::~ScreenShotEffect() cancelScreenScreenShots(); } -QFuture ScreenShotEffect::scheduleScreenShot(EffectScreen *screen, ScreenShotFlags flags) +QFuture ScreenShotEffect::scheduleScreenShot(Output *screen, ScreenShotFlags flags) { for (const ScreenShotScreenData &data : m_screenScreenShots) { if (data.screen == screen && data.flags == flags) { @@ -133,8 +134,8 @@ QFuture ScreenShotEffect::scheduleScreenShot(const QRect &area, ScreenSh data.area = area; data.flags = flags; - const QList screens = effects->screens(); - for (EffectScreen *screen : screens) { + const QList screens = effects->screens(); + for (Output *screen : screens) { if (screen->geometry().intersects(area)) { data.screens.append(screen); } @@ -142,9 +143,9 @@ QFuture ScreenShotEffect::scheduleScreenShot(const QRect &area, ScreenSh qreal devicePixelRatio = 1.0; if (flags & ScreenShotNativeResolution) { - for (const EffectScreen *screen : std::as_const(data.screens)) { - if (screen->devicePixelRatio() > devicePixelRatio) { - devicePixelRatio = screen->devicePixelRatio(); + for (const Output *screen : std::as_const(data.screens)) { + if (screen->scale() > devicePixelRatio) { + devicePixelRatio = screen->scale(); } } } @@ -198,7 +199,7 @@ void ScreenShotEffect::cancelScreenScreenShots() m_screenScreenShots.clear(); } -void ScreenShotEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ScreenShotEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { m_paintedScreen = screen; effects->paintScreen(renderTarget, viewport, mask, region, screen); @@ -236,8 +237,8 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot) } if (screenshot->flags & ScreenShotNativeResolution) { - if (const EffectScreen *screen = window->screen()) { - devicePixelRatio = screen->devicePixelRatio(); + if (const Output *screen = window->screen()) { + devicePixelRatio = screen->scale(); } } @@ -313,7 +314,7 @@ bool ScreenShotEffect::takeScreenShot(const RenderTarget &renderTarget, const Re const QRect sourceRect = screenshot->area & m_paintedScreen->geometry(); qreal sourceDevicePixelRatio = 1.0; if (screenshot->flags & ScreenShotNativeResolution) { - sourceDevicePixelRatio = m_paintedScreen->devicePixelRatio(); + sourceDevicePixelRatio = m_paintedScreen->scale(); } const QImage snapshot = blitScreenshot(renderTarget, viewport, sourceRect, sourceDevicePixelRatio); @@ -346,7 +347,7 @@ bool ScreenShotEffect::takeScreenShot(const RenderTarget &renderTarget, const Re qreal devicePixelRatio = 1.0; if (screenshot->flags & ScreenShotNativeResolution) { - devicePixelRatio = screenshot->screen->devicePixelRatio(); + devicePixelRatio = screenshot->screen->scale(); } QImage snapshot = blitScreenshot(renderTarget, viewport, screenshot->screen->geometry(), devicePixelRatio); @@ -430,7 +431,7 @@ void ScreenShotEffect::handleScreenAdded() cancelAreaScreenShots(); } -void ScreenShotEffect::handleScreenRemoved(EffectScreen *screen) +void ScreenShotEffect::handleScreenRemoved(Output *screen) { cancelAreaScreenShots(); diff --git a/src/plugins/screenshot/screenshot.h b/src/plugins/screenshot/screenshot.h index 8e9c5eabbc..6dcbcd335e 100644 --- a/src/plugins/screenshot/screenshot.h +++ b/src/plugins/screenshot/screenshot.h @@ -56,7 +56,7 @@ public: * the image data. If the screen is removed before the screenshot is taken, the future will * be cancelled. */ - QFuture scheduleScreenShot(EffectScreen *screen, ScreenShotFlags flags = {}); + QFuture scheduleScreenShot(Output *screen, ScreenShotFlags flags = {}); /** * Schedules a screenshot of the given @a area. The returned QFuture can be used to query the @@ -71,7 +71,7 @@ public: */ QFuture scheduleScreenShot(EffectWindow *window, ScreenShotFlags flags = {}); - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; bool isActive() const override; int requestedEffectChainPosition() const override; @@ -80,7 +80,7 @@ public: private Q_SLOTS: void handleWindowClosed(EffectWindow *window); void handleScreenAdded(); - void handleScreenRemoved(EffectScreen *screen); + void handleScreenRemoved(Output *screen); private: void takeScreenShot(ScreenShotWindowData *screenshot); @@ -99,7 +99,7 @@ private: std::vector m_screenScreenShots; std::unique_ptr m_dbusInterface2; - EffectScreen *m_paintedScreen = nullptr; + Output *m_paintedScreen = nullptr; }; } // namespace KWin diff --git a/src/plugins/screenshot/screenshotdbusinterface2.cpp b/src/plugins/screenshot/screenshotdbusinterface2.cpp index 16f102cdcc..493c38a660 100644 --- a/src/plugins/screenshot/screenshotdbusinterface2.cpp +++ b/src/plugins/screenshot/screenshotdbusinterface2.cpp @@ -7,6 +7,7 @@ */ #include "screenshotdbusinterface2.h" +#include "core/output.h" #include "screenshot2adaptor.h" #include "screenshotlogging.h" #include "utils/filedescriptor.h" @@ -169,12 +170,12 @@ class ScreenShotSourceScreen2 : public ScreenShotSource2 Q_OBJECT public: - ScreenShotSourceScreen2(ScreenShotEffect *effect, EffectScreen *screen, ScreenShotFlags flags); + ScreenShotSourceScreen2(ScreenShotEffect *effect, Output *screen, ScreenShotFlags flags); QVariantMap attributes() const override; private: - EffectScreen *m_screen; + Output *m_screen; }; class ScreenShotSourceArea2 : public ScreenShotSource2 @@ -243,7 +244,7 @@ void ScreenShotSource2::marshal(ScreenShotSinkPipe2 *sink) } ScreenShotSourceScreen2::ScreenShotSourceScreen2(ScreenShotEffect *effect, - EffectScreen *screen, + Output *screen, ScreenShotFlags flags) : ScreenShotSource2(effect->scheduleScreenShot(screen, flags)) , m_screen(screen) @@ -456,7 +457,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureScreen(const QString &name, return QVariantMap(); } - EffectScreen *screen = effects->findScreen(name); + Output *screen = effects->findScreen(name); if (!screen) { sendErrorReply(s_errorInvalidScreen, s_errorInvalidScreenMessage); return QVariantMap(); @@ -482,7 +483,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureActiveScreen(const QVariantMap &opt return QVariantMap(); } - EffectScreen *screen = effects->activeScreen(); + Output *screen = effects->activeScreen(); if (!screen) { sendErrorReply(s_errorInvalidScreen, s_errorInvalidScreenMessage); return QVariantMap(); @@ -540,7 +541,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureInteractive(uint kind, QDBusConnection bus = QDBusConnection::sessionBus(); bus.send(replyMessage.createErrorReply(s_errorCancelled, s_errorCancelledMessage)); } else { - EffectScreen *screen = effects->screenAt(point.toPoint()); + Output *screen = effects->screenAt(point.toPoint()); takeScreenShot(screen, screenShotFlagsFromOptions(options), new ScreenShotSinkPipe2(fileDescriptor, replyMessage)); } @@ -590,7 +591,7 @@ void ScreenShotDBusInterface2::bind(ScreenShotSinkPipe2 *sink, ScreenShotSource2 }); } -void ScreenShotDBusInterface2::takeScreenShot(EffectScreen *screen, ScreenShotFlags flags, +void ScreenShotDBusInterface2::takeScreenShot(Output *screen, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink) { bind(sink, new ScreenShotSourceScreen2(m_effect, screen, flags)); diff --git a/src/plugins/screenshot/screenshotdbusinterface2.h b/src/plugins/screenshot/screenshotdbusinterface2.h index faba216965..d047f09369 100644 --- a/src/plugins/screenshot/screenshotdbusinterface2.h +++ b/src/plugins/screenshot/screenshotdbusinterface2.h @@ -57,7 +57,7 @@ public Q_SLOTS: QDBusUnixFileDescriptor pipe); private: - void takeScreenShot(EffectScreen *screen, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); + void takeScreenShot(Output *screen, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); void takeScreenShot(const QRect &area, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); void takeScreenShot(EffectWindow *window, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); diff --git a/src/plugins/screentransform/screentransform.cpp b/src/plugins/screentransform/screentransform.cpp index aadd960f27..71cac9b369 100644 --- a/src/plugins/screentransform/screentransform.cpp +++ b/src/plugins/screentransform/screentransform.cpp @@ -39,7 +39,7 @@ ScreenTransformEffect::ScreenTransformEffect() m_previousTextureLocation = m_shader->uniformLocation("previousTexture"); m_currentTextureLocation = m_shader->uniformLocation("currentTexture"); - const QList screens = effects->screens(); + const QList screens = effects->screens(); for (auto screen : screens) { addScreen(screen); } @@ -54,19 +54,19 @@ bool ScreenTransformEffect::supported() return effects->compositingType() == OpenGLCompositing && effects->waylandDisplay() && effects->animationsSupported(); } -qreal transformAngle(EffectScreen::Transform current, EffectScreen::Transform old) +qreal transformAngle(OutputTransform current, OutputTransform old) { auto ensureShort = [](int angle) { return angle > 180 ? angle - 360 : angle < -180 ? angle + 360 : angle; }; // % 4 to ignore flipped cases (for now) - return ensureShort((int(current) % 4 - int(old) % 4) * 90); + return ensureShort((int(current.kind()) % 4 - int(old.kind()) % 4) * 90); } -void ScreenTransformEffect::addScreen(EffectScreen *screen) +void ScreenTransformEffect::addScreen(Output *screen) { - connect(screen, &EffectScreen::changed, this, [this, screen] { + connect(screen, &Output::changed, this, [this, screen] { auto &state = m_states[screen]; if (transformAngle(screen->transform(), state.m_oldTransform) == 0) { effects->makeOpenGLContextCurrent(); @@ -79,12 +79,12 @@ void ScreenTransformEffect::addScreen(EffectScreen *screen) Q_ASSERT(state.m_angle != 0); effects->addRepaintFull(); }); - connect(screen, &EffectScreen::aboutToChange, this, [this, screen] { + connect(screen, &Output::aboutToChange, this, [this, screen] { effects->makeOpenGLContextCurrent(); auto &state = m_states[screen]; state.m_oldTransform = screen->transform(); state.m_oldGeometry = screen->geometry(); - state.m_prev.texture = GLTexture::allocate(GL_RGBA8, screen->geometry().size() * screen->devicePixelRatio()); + state.m_prev.texture = GLTexture::allocate(GL_RGBA8, screen->geometry().size() * screen->scale()); if (!state.m_prev.texture) { m_states.remove(screen); return; @@ -101,7 +101,7 @@ void ScreenTransformEffect::addScreen(EffectScreen *screen) }); } -void ScreenTransformEffect::removeScreen(EffectScreen *screen) +void ScreenTransformEffect::removeScreen(Output *screen) { effects->makeOpenGLContextCurrent(); m_states.remove(screen); @@ -181,7 +181,7 @@ static QRectF lerp(const QRectF &a, const QRectF &b, qreal t) return ret; } -void ScreenTransformEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::EffectScreen *screen) +void ScreenTransformEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::Output *screen) { auto it = m_states.find(screen); if (it == m_states.end() || !it->m_captured) { @@ -190,7 +190,7 @@ void ScreenTransformEffect::paintScreen(const RenderTarget &renderTarget, const } // Render the screen in an offscreen texture. - const QSize nativeSize = screen->geometry().size() * screen->devicePixelRatio(); + const QSize nativeSize = screen->geometry().size() * screen->scale(); if (!it->m_current.texture || it->m_current.texture->size() != nativeSize) { it->m_current.texture = GLTexture::allocate(GL_RGBA8, nativeSize); if (!it->m_current.texture) { diff --git a/src/plugins/screentransform/screentransform.h b/src/plugins/screentransform/screentransform.h index 86966903b6..0c1b772bec 100644 --- a/src/plugins/screentransform/screentransform.h +++ b/src/plugins/screentransform/screentransform.h @@ -8,6 +8,7 @@ */ #pragma once +#include "core/output.h" #include "libkwineffects/kwineffects.h" namespace KWin @@ -25,7 +26,7 @@ public: ~ScreenTransformEffect() override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, KWin::Output *screen) override; bool isActive() const override; @@ -48,15 +49,15 @@ private: Snapshot m_prev; Snapshot m_current; QRect m_oldGeometry; - EffectScreen::Transform m_oldTransform; + OutputTransform m_oldTransform; qreal m_angle = 0; bool m_captured = false; }; - void addScreen(EffectScreen *screen); - void removeScreen(EffectScreen *screen); + void addScreen(Output *screen); + void removeScreen(Output *screen); - QHash m_states; + QHash m_states; std::unique_ptr m_shader; int m_previousTextureLocation = -1; diff --git a/src/plugins/showfps/showfpseffect.cpp b/src/plugins/showfps/showfpseffect.cpp index 6d1b38a228..030b4af9e9 100644 --- a/src/plugins/showfps/showfpseffect.cpp +++ b/src/plugins/showfps/showfpseffect.cpp @@ -7,6 +7,7 @@ */ #include "showfpseffect.h" +#include "core/output.h" #include "libkwineffects/renderviewport.h" #include @@ -75,7 +76,7 @@ void ShowFpsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::millis } } -void ShowFpsEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ShowFpsEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); diff --git a/src/plugins/showfps/showfpseffect.h b/src/plugins/showfps/showfpseffect.h index f26e6bc38d..747045fe11 100644 --- a/src/plugins/showfps/showfpseffect.h +++ b/src/plugins/showfps/showfpseffect.h @@ -36,7 +36,7 @@ public: QColor paintColor() const; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, KWin::WindowPaintData &data) override; void postPaintScreen() override; diff --git a/src/plugins/showpaint/showpaint.cpp b/src/plugins/showpaint/showpaint.cpp index 8d7f42d292..5b3a519f06 100644 --- a/src/plugins/showpaint/showpaint.cpp +++ b/src/plugins/showpaint/showpaint.cpp @@ -43,7 +43,7 @@ ShowPaintEffect::ShowPaintEffect() connect(toggleAction, &QAction::triggered, this, &ShowPaintEffect::toggle); } -void ShowPaintEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ShowPaintEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { m_painted = QRegion(); effects->paintScreen(renderTarget, viewport, mask, region, screen); diff --git a/src/plugins/showpaint/showpaint.h b/src/plugins/showpaint/showpaint.h index 5b4b012686..3a0e67c119 100644 --- a/src/plugins/showpaint/showpaint.h +++ b/src/plugins/showpaint/showpaint.h @@ -21,7 +21,7 @@ class ShowPaintEffect : public Effect public: ShowPaintEffect(); - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; bool isActive() const override; diff --git a/src/plugins/slide/slide.cpp b/src/plugins/slide/slide.cpp index a1c62751d7..e58405e909 100644 --- a/src/plugins/slide/slide.cpp +++ b/src/plugins/slide/slide.cpp @@ -11,6 +11,7 @@ // own #include "slide.h" +#include "core/output.h" // KConfigSkeleton #include "slideconfig.h" @@ -134,13 +135,13 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::millisec effects->prePaintScreen(data, presentTime); } -void SlideEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void SlideEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { m_paintCtx.wrap = effects->optionRollOverDesktops(); effects->paintScreen(renderTarget, viewport, mask, region, screen); } -QPoint SlideEffect::getDrawCoords(QPointF pos, EffectScreen *screen) +QPoint SlideEffect::getDrawCoords(QPointF pos, Output *screen) { QPoint c = QPoint(); c.setX(pos.x() * (screen->geometry().width() + m_hGap)); @@ -226,7 +227,7 @@ void SlideEffect::paintWindow(const RenderTarget &renderTarget, const RenderView desktopTranslation = QPointF(desktopTranslation.x(), desktopTranslation.y() + gridHeight); } - for (EffectScreen *screen : screens) { + for (Output *screen : screens) { QPoint drawTranslation = getDrawCoords(desktopTranslation, screen); data += drawTranslation; diff --git a/src/plugins/slide/slide.h b/src/plugins/slide/slide.h index 88c652740a..795b83b7e1 100644 --- a/src/plugins/slide/slide.h +++ b/src/plugins/slide/slide.h @@ -57,7 +57,7 @@ public: void reconfigure(ReconfigureFlags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; @@ -80,7 +80,7 @@ private Q_SLOTS: void windowDeleted(EffectWindow *w); private: - QPoint getDrawCoords(QPointF pos, EffectScreen *screen); + QPoint getDrawCoords(QPointF pos, Output *screen); bool isTranslated(const EffectWindow *w) const; bool willBePainted(const EffectWindow *w) const; bool shouldElevate(const EffectWindow *w) const; diff --git a/src/plugins/snaphelper/snaphelper.cpp b/src/plugins/snaphelper/snaphelper.cpp index bc483d9071..3232510880 100644 --- a/src/plugins/snaphelper/snaphelper.cpp +++ b/src/plugins/snaphelper/snaphelper.cpp @@ -32,8 +32,8 @@ static QRegion computeDirtyRegion(const QRectF &windowRect) QRegion dirtyRegion; - const QList screens = effects->screens(); - for (EffectScreen *screen : screens) { + const QList screens = effects->screens(); + for (Output *screen : screens) { const QRectF screenRect = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); QRectF screenWindowRect = windowRect; @@ -93,14 +93,14 @@ void SnapHelperEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil effects->prePaintScreen(data, presentTime); } -void SnapHelperEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void SnapHelperEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); const qreal opacityFactor = m_animation.active ? m_animation.timeLine.value() : 1.0; - const QList screens = effects->screens(); + const QList screens = effects->screens(); const auto scale = viewport.scale(); @@ -121,7 +121,7 @@ void SnapHelperEffect::paintScreen(const RenderTarget &renderTarget, const Rende glLineWidth(s_lineWidth); QList verts; verts.reserve(screens.count() * 24); - for (EffectScreen *screen : screens) { + for (Output *screen : screens) { const QRectF rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); const int midX = rect.x() + rect.width() / 2; const int midY = rect.y() + rect.height() / 2; @@ -167,7 +167,7 @@ void SnapHelperEffect::paintScreen(const RenderTarget &renderTarget, const Rende painter->setPen(pen); painter->setBrush(Qt::NoBrush); - for (EffectScreen *screen : screens) { + for (Output *screen : screens) { const QRectF rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); // Center lines. painter->drawLine(rect.center().x(), rect.y(), rect.center().x(), rect.y() + rect.height()); diff --git a/src/plugins/snaphelper/snaphelper.h b/src/plugins/snaphelper/snaphelper.h index 3a4236f6fc..0e77aed44b 100644 --- a/src/plugins/snaphelper/snaphelper.h +++ b/src/plugins/snaphelper/snaphelper.h @@ -26,7 +26,7 @@ public: void reconfigure(ReconfigureFlags flags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; diff --git a/src/plugins/startupfeedback/startupfeedback.cpp b/src/plugins/startupfeedback/startupfeedback.cpp index 06a541c9c0..0854c182f7 100644 --- a/src/plugins/startupfeedback/startupfeedback.cpp +++ b/src/plugins/startupfeedback/startupfeedback.cpp @@ -196,7 +196,7 @@ void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono effects->prePaintScreen(data, presentTime); } -void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); if (m_active) { diff --git a/src/plugins/startupfeedback/startupfeedback.h b/src/plugins/startupfeedback/startupfeedback.h index 6cf9242d99..fd94a90b6c 100644 --- a/src/plugins/startupfeedback/startupfeedback.h +++ b/src/plugins/startupfeedback/startupfeedback.h @@ -33,7 +33,7 @@ public: void reconfigure(ReconfigureFlags flags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; diff --git a/src/plugins/thumbnailaside/thumbnailaside.cpp b/src/plugins/thumbnailaside/thumbnailaside.cpp index bb0c896471..e46547e178 100644 --- a/src/plugins/thumbnailaside/thumbnailaside.cpp +++ b/src/plugins/thumbnailaside/thumbnailaside.cpp @@ -55,7 +55,7 @@ void ThumbnailAsideEffect::reconfigure(ReconfigureFlags) arrange(); } -void ThumbnailAsideEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ThumbnailAsideEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { painted = QRegion(); effects->paintScreen(renderTarget, viewport, mask, region, screen); @@ -166,7 +166,7 @@ void ThumbnailAsideEffect::arrange() mwidth = std::max(mwidth, d.window->width()); pos[d.index] = d.window->height(); } - EffectScreen *effectiveScreen = effects->findScreen(screen); + Output *effectiveScreen = effects->findScreen(screen); if (!effectiveScreen) { effectiveScreen = effects->activeScreen(); } diff --git a/src/plugins/thumbnailaside/thumbnailaside.h b/src/plugins/thumbnailaside/thumbnailaside.h index 1f3edc5985..91857c1677 100644 --- a/src/plugins/thumbnailaside/thumbnailaside.h +++ b/src/plugins/thumbnailaside/thumbnailaside.h @@ -34,7 +34,7 @@ class ThumbnailAsideEffect public: ThumbnailAsideEffect(); void reconfigure(ReconfigureFlags) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; // for properties diff --git a/src/plugins/tileseditor/tileseditoreffect.cpp b/src/plugins/tileseditor/tileseditoreffect.cpp index 5a4d0e2c04..476d4a70e0 100644 --- a/src/plugins/tileseditor/tileseditoreffect.cpp +++ b/src/plugins/tileseditor/tileseditoreffect.cpp @@ -38,7 +38,7 @@ TilesEditorEffect::~TilesEditorEffect() { } -QVariantMap TilesEditorEffect::initialProperties(EffectScreen *screen) +QVariantMap TilesEditorEffect::initialProperties(Output *screen) { return QVariantMap{ {QStringLiteral("effect"), QVariant::fromValue(this)}, diff --git a/src/plugins/tileseditor/tileseditoreffect.h b/src/plugins/tileseditor/tileseditoreffect.h index 6c2fb6722a..633a6acdf2 100644 --- a/src/plugins/tileseditor/tileseditoreffect.h +++ b/src/plugins/tileseditor/tileseditoreffect.h @@ -37,7 +37,7 @@ Q_SIGNALS: void animationDurationChanged(); protected: - QVariantMap initialProperties(EffectScreen *screen) override; + QVariantMap initialProperties(Output *screen) override; private: void realDeactivate(); diff --git a/src/plugins/touchpoints/touchpoints.cpp b/src/plugins/touchpoints/touchpoints.cpp index 1124d0864b..07641c0ab4 100644 --- a/src/plugins/touchpoints/touchpoints.cpp +++ b/src/plugins/touchpoints/touchpoints.cpp @@ -119,7 +119,7 @@ void TouchPointsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mi effects->prePaintScreen(data, presentTime); } -void TouchPointsEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void TouchPointsEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); diff --git a/src/plugins/touchpoints/touchpoints.h b/src/plugins/touchpoints/touchpoints.h index 3286826a51..b6404e6f87 100644 --- a/src/plugins/touchpoints/touchpoints.h +++ b/src/plugins/touchpoints/touchpoints.h @@ -27,7 +27,7 @@ public: TouchPointsEffect(); ~TouchPointsEffect() override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override; diff --git a/src/plugins/trackmouse/trackmouse.cpp b/src/plugins/trackmouse/trackmouse.cpp index 15c1bbf8e2..8b3fbeb2ad 100644 --- a/src/plugins/trackmouse/trackmouse.cpp +++ b/src/plugins/trackmouse/trackmouse.cpp @@ -98,7 +98,7 @@ void TrackMouseEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil effects->prePaintScreen(data, presentTime); } -void TrackMouseEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void TrackMouseEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { effects->paintScreen(renderTarget, viewport, mask, region, screen); // paint normal screen diff --git a/src/plugins/trackmouse/trackmouse.h b/src/plugins/trackmouse/trackmouse.h index de298d3f96..fd052f30f6 100644 --- a/src/plugins/trackmouse/trackmouse.h +++ b/src/plugins/trackmouse/trackmouse.h @@ -29,7 +29,7 @@ public: TrackMouseEffect(); ~TrackMouseEffect() override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; void reconfigure(ReconfigureFlags) override; bool isActive() const override; diff --git a/src/plugins/windowview/windowvieweffect.cpp b/src/plugins/windowview/windowvieweffect.cpp index c3d0c5807d..f0cf98b5b4 100644 --- a/src/plugins/windowview/windowvieweffect.cpp +++ b/src/plugins/windowview/windowvieweffect.cpp @@ -193,7 +193,7 @@ void WindowViewEffect::reconfigure(ReconfigureFlags) effects->reserveElectricBorder(ElectricBorder(i), this); } - auto touchCallback = [this](ElectricBorder border, const QPointF &deltaProgress, const EffectScreen *screen) { + auto touchCallback = [this](ElectricBorder border, const QPointF &deltaProgress, const Output *screen) { if (m_status == Status::Active) { return; } diff --git a/src/plugins/zoom/zoom.cpp b/src/plugins/zoom/zoom.cpp index 6f0261d601..77a99725e8 100644 --- a/src/plugins/zoom/zoom.cpp +++ b/src/plugins/zoom/zoom.cpp @@ -263,7 +263,7 @@ void ZoomEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseco effects->prePaintScreen(data, presentTime); } -ZoomEffect::OffscreenData *ZoomEffect::ensureOffscreenData(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectScreen *screen) +ZoomEffect::OffscreenData *ZoomEffect::ensureOffscreenData(const RenderTarget &renderTarget, const RenderViewport &viewport, Output *screen) { const QRect rect = viewport.renderRect().toRect(); const qreal devicePixelRatio = viewport.scale(); @@ -286,7 +286,7 @@ ZoomEffect::OffscreenData *ZoomEffect::ensureOffscreenData(const RenderTarget &r return &data; } -void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { OffscreenData *offscreenData = ensureOffscreenData(renderTarget, viewport, screen); if (!offscreenData) { @@ -561,7 +561,7 @@ void ZoomEffect::slotWindowDamaged() } } -void ZoomEffect::slotScreenRemoved(EffectScreen *screen) +void ZoomEffect::slotScreenRemoved(Output *screen) { if (auto it = m_offscreenData.find(screen); it != m_offscreenData.end()) { effects->makeOpenGLContextCurrent(); diff --git a/src/plugins/zoom/zoom.h b/src/plugins/zoom/zoom.h index 7815529463..c4472e81ac 100644 --- a/src/plugins/zoom/zoom.h +++ b/src/plugins/zoom/zoom.h @@ -44,7 +44,7 @@ public: ~ZoomEffect() override; void reconfigure(ReconfigureFlags flags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) override; + void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; void postPaintScreen() override; bool isActive() const override; int requestedEffectChainPosition() const override; @@ -78,7 +78,7 @@ private Q_SLOTS: Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void slotWindowAdded(EffectWindow *w); void slotWindowDamaged(); - void slotScreenRemoved(EffectScreen *screen); + void slotScreenRemoved(Output *screen); private: void showCursor(); @@ -94,7 +94,7 @@ private: }; GLTexture *ensureCursorTexture(); - OffscreenData *ensureOffscreenData(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectScreen *screen); + OffscreenData *ensureOffscreenData(const RenderTarget &renderTarget, const RenderViewport &viewport, Output *screen); void markCursorTextureDirty(); #if HAVE_ACCESSIBILITY @@ -131,7 +131,7 @@ private: int xMove, yMove; double moveFactor; std::chrono::milliseconds lastPresentTime; - std::map m_offscreenData; + std::map m_offscreenData; }; } // namespace diff --git a/src/scene/workspacescene.cpp b/src/scene/workspacescene.cpp index e8929b2ffe..8a9009c27a 100644 --- a/src/scene/workspacescene.cpp +++ b/src/scene/workspacescene.cpp @@ -240,7 +240,7 @@ QRegion WorkspaceScene::prePaint(SceneDelegate *delegate) ScreenPrePaintData prePaintData; prePaintData.mask = 0; - prePaintData.screen = EffectScreenImpl::get(painted_screen); + prePaintData.screen = painted_screen; effects->makeOpenGLContextCurrent(); Q_EMIT preFrameRender(); @@ -364,7 +364,7 @@ void WorkspaceScene::paint(const RenderTarget &renderTarget, const QRegion ®i m_renderer->beginFrame(renderTarget, viewport); - effects->paintScreen(renderTarget, viewport, m_paintContext.mask, region, EffectScreenImpl::get(painted_screen)); + effects->paintScreen(renderTarget, viewport, m_paintContext.mask, region, painted_screen); m_paintScreenCount = 0; Q_EMIT frameRendered(); @@ -372,7 +372,7 @@ void WorkspaceScene::paint(const RenderTarget &renderTarget, const QRegion ®i } // the function that'll be eventually called by paintScreen() above -void WorkspaceScene::finalPaintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen) +void WorkspaceScene::finalPaintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) { m_paintScreenCount++; if (mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) { @@ -384,7 +384,7 @@ void WorkspaceScene::finalPaintScreen(const RenderTarget &renderTarget, const Re // The generic painting code that can handle even transformations. // It simply paints bottom-to-top. -void WorkspaceScene::paintGenericScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int, EffectScreen *screen) +void WorkspaceScene::paintGenericScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int, Output *screen) { if (m_paintContext.mask & PAINT_SCREEN_BACKGROUND_FIRST) { if (m_paintScreenCount == 1) { diff --git a/src/scene/workspacescene.h b/src/scene/workspacescene.h index efe1efb925..8158dbd571 100644 --- a/src/scene/workspacescene.h +++ b/src/scene/workspacescene.h @@ -90,11 +90,11 @@ protected: void clearStackingOrder(); friend class EffectsHandlerImpl; // called after all effects had their paintScreen() called - void finalPaintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, EffectScreen *screen); + void finalPaintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen); // shared implementation of painting the screen in the generic // (unoptimized) way void preparePaintGenericScreen(); - void paintGenericScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, EffectScreen *screen); + void paintGenericScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, Output *screen); // shared implementation of painting the screen in an optimized way void preparePaintSimpleScreen(); void paintSimpleScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion); diff --git a/src/scripting/scriptedeffect.cpp b/src/scripting/scriptedeffect.cpp index 12fd8badf4..f33de90425 100644 --- a/src/scripting/scriptedeffect.cpp +++ b/src/scripting/scriptedeffect.cpp @@ -13,6 +13,7 @@ #include "scriptingutils.h" #include "workspace_wrapper.h" +#include "core/output.h" #include "input.h" #include "screenedge.h" #include "workspace.h" @@ -720,7 +721,7 @@ bool ScriptedEffect::registerRealtimeScreenEdge(int edge, const QJSValue &callba } } }); - effects->registerRealtimeTouchBorder(static_cast(edge), triggerAction, [this](ElectricBorder border, const QPointF &deltaProgress, EffectScreen *screen) { + effects->registerRealtimeTouchBorder(static_cast(edge), triggerAction, [this](ElectricBorder border, const QPointF &deltaProgress, Output *screen) { auto it = realtimeScreenEdgeCallbacks().constFind(border); if (it != realtimeScreenEdgeCallbacks().constEnd()) { for (const QJSValue &callback : it.value()) {