core: Move workspace bits from Platform to Application
Platform will become OutputBackend so some workspace bits, e.g. the effects handler, have to move a layer above.
This commit is contained in:
parent
f1369a40f9
commit
72883df2aa
16 changed files with 209 additions and 181 deletions
|
@ -1620,8 +1620,8 @@ void PointerInputTest::testResizeCursor()
|
|||
// load the fallback cursor (arrow cursor)
|
||||
const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor);
|
||||
QVERIFY(!arrowCursor.isNull());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
|
||||
// we need a pointer to get the enter event
|
||||
auto pointer = m_seat->createPointer(m_seat);
|
||||
|
@ -1679,16 +1679,16 @@ void PointerInputTest::testResizeCursor()
|
|||
QFETCH(KWin::CursorShape, cursorShape);
|
||||
const PlatformCursorImage resizeCursor = loadReferenceThemeCursor(cursorShape);
|
||||
QVERIFY(!resizeCursor.isNull());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), resizeCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), resizeCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), resizeCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), resizeCursor.hotSpot());
|
||||
|
||||
// finish resizing the window
|
||||
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
|
||||
Test::pointerButtonReleased(BTN_RIGHT, timestamp++);
|
||||
QVERIFY(!window->isInteractiveResize());
|
||||
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
}
|
||||
|
||||
void PointerInputTest::testMoveCursor()
|
||||
|
@ -1707,8 +1707,8 @@ void PointerInputTest::testMoveCursor()
|
|||
// load the fallback cursor (arrow cursor)
|
||||
const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor);
|
||||
QVERIFY(!arrowCursor.isNull());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
|
||||
// we need a pointer to get the enter event
|
||||
auto pointer = m_seat->createPointer(m_seat);
|
||||
|
@ -1746,16 +1746,16 @@ void PointerInputTest::testMoveCursor()
|
|||
|
||||
const PlatformCursorImage sizeAllCursor = loadReferenceThemeCursor(Qt::SizeAllCursor);
|
||||
QVERIFY(!sizeAllCursor.isNull());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), sizeAllCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), sizeAllCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), sizeAllCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), sizeAllCursor.hotSpot());
|
||||
|
||||
// finish moving the window
|
||||
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
|
||||
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
||||
QVERIFY(!window->isInteractiveMove());
|
||||
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
QCOMPARE(kwinApp()->cursorImage().image(), arrowCursor.image());
|
||||
QCOMPARE(kwinApp()->cursorImage().hotSpot(), arrowCursor.hotSpot());
|
||||
}
|
||||
|
||||
void PointerInputTest::testHideShowCursor()
|
||||
|
|
|
@ -107,7 +107,7 @@ void TestWindowSelection::testSelectOnWindowPointer()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(!selectedWindow);
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -187,7 +187,7 @@ void TestWindowSelection::testSelectOnWindowKeyboard()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(!selectedWindow);
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -249,7 +249,7 @@ void TestWindowSelection::testSelectOnWindowTouch()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(!selectedWindow);
|
||||
|
||||
|
@ -263,7 +263,7 @@ void TestWindowSelection::testSelectOnWindowTouch()
|
|||
|
||||
// with movement
|
||||
selectedWindow = nullptr;
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
Test::touchDown(0, window->frameGeometry().bottomRight() + QPoint(20, 20), timestamp++);
|
||||
QVERIFY(!selectedWindow);
|
||||
Test::touchMotion(0, window->frameGeometry().bottomRight() - QPoint(1, 1), timestamp++);
|
||||
|
@ -276,7 +276,7 @@ void TestWindowSelection::testSelectOnWindowTouch()
|
|||
Test::touchDown(0, window->frameGeometry().center(), timestamp++);
|
||||
QVERIFY(touchStartedSpy.wait());
|
||||
selectedWindow = nullptr;
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(touchCanceledSpy.wait());
|
||||
QVERIFY(!selectedWindow);
|
||||
|
@ -318,7 +318,7 @@ void TestWindowSelection::testCancelOnWindowPointer()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(!selectedWindow);
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -373,7 +373,7 @@ void TestWindowSelection::testCancelOnWindowKeyboard()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(callback);
|
||||
kwinApp()->startInteractiveWindowSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QVERIFY(!selectedWindow);
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -428,7 +428,7 @@ void TestWindowSelection::testSelectPointPointer()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractivePositionSelection(callback);
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QCOMPARE(point, QPoint());
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -441,7 +441,7 @@ void TestWindowSelection::testSelectPointPointer()
|
|||
|
||||
// trying again should not be allowed
|
||||
QPoint point2;
|
||||
kwinApp()->platform()->startInteractivePositionSelection([&point2](const QPoint &p) {
|
||||
kwinApp()->startInteractivePositionSelection([&point2](const QPoint &p) {
|
||||
point2 = p;
|
||||
});
|
||||
QCOMPARE(point2, QPoint(-1, -1));
|
||||
|
@ -492,7 +492,7 @@ void TestWindowSelection::testSelectPointTouch()
|
|||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->platform()->startInteractivePositionSelection(callback);
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QCOMPARE(point, QPoint());
|
||||
|
||||
|
|
|
@ -241,12 +241,7 @@ void X11StandalonePlatform::startInteractivePositionSelection(std::function<void
|
|||
|
||||
std::unique_ptr<OutlineVisual> X11StandalonePlatform::createOutline(Outline *outline)
|
||||
{
|
||||
// first try composited Outline
|
||||
auto ret = Platform::createOutline(outline);
|
||||
if (!ret) {
|
||||
ret = std::make_unique<NonCompositedOutlineVisual>(outline);
|
||||
}
|
||||
return ret;
|
||||
return std::make_unique<NonCompositedOutlineVisual>(outline);
|
||||
}
|
||||
|
||||
void X11StandalonePlatform::createEffectsHandler(Compositor *compositor, Scene *scene)
|
||||
|
|
|
@ -27,6 +27,13 @@ class WindowSelector;
|
|||
class X11EventFilter;
|
||||
class X11Output;
|
||||
class X11Keyboard;
|
||||
class Edge;
|
||||
class ScreenEdges;
|
||||
class Outline;
|
||||
class OutlineVisual;
|
||||
class Compositor;
|
||||
class Scene;
|
||||
class Window;
|
||||
|
||||
class KWIN_EXPORT X11StandalonePlatform : public Platform
|
||||
{
|
||||
|
@ -38,19 +45,20 @@ public:
|
|||
bool initialize() override;
|
||||
|
||||
std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
|
||||
std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent) override;
|
||||
void createPlatformCursor(QObject *parent = nullptr) override;
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray()) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
|
||||
PlatformCursorImage cursorImage() const override;
|
||||
std::unique_ptr<OutlineVisual> createOutline(Outline *outline) override;
|
||||
void createEffectsHandler(Compositor *compositor, Scene *scene) override;
|
||||
QVector<CompositingType> supportedCompositors() const override;
|
||||
|
||||
void initOutputs();
|
||||
void scheduleUpdateOutputs();
|
||||
void updateOutputs();
|
||||
|
||||
std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent);
|
||||
void createPlatformCursor(QObject *parent = nullptr);
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray());
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
||||
PlatformCursorImage cursorImage() const;
|
||||
std::unique_ptr<OutlineVisual> createOutline(Outline *outline);
|
||||
void createEffectsHandler(Compositor *compositor, Scene *scene);
|
||||
|
||||
X11Keyboard *keyboard() const;
|
||||
RenderLoop *renderLoop() const;
|
||||
Outputs outputs() const override;
|
||||
|
|
|
@ -398,7 +398,7 @@ void Compositor::startupWithWorkspace()
|
|||
}
|
||||
|
||||
// Sets also the 'effects' pointer.
|
||||
kwinApp()->platform()->createEffectsHandler(this, m_scene.get());
|
||||
kwinApp()->createEffectsHandler(this, m_scene.get());
|
||||
|
||||
Q_EMIT compositingToggled(true);
|
||||
|
||||
|
|
|
@ -9,18 +9,12 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#include "composite.h"
|
||||
#include "cursor.h"
|
||||
#include "dmabuftexture.h"
|
||||
#include "effects.h"
|
||||
#include "inputbackend.h"
|
||||
#include "openglbackend.h"
|
||||
#include "outline.h"
|
||||
#include "output.h"
|
||||
#include "outputconfiguration.h"
|
||||
#include "pointer_input.h"
|
||||
#include "qpainterbackend.h"
|
||||
#include "screenedge.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -35,12 +29,6 @@ Platform::~Platform()
|
|||
{
|
||||
}
|
||||
|
||||
PlatformCursorImage Platform::cursorImage() const
|
||||
{
|
||||
Cursor *cursor = Cursors::self()->currentCursor();
|
||||
return PlatformCursorImage(cursor->image(), cursor->hotspot());
|
||||
}
|
||||
|
||||
std::unique_ptr<InputBackend> Platform::createInputBackend()
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -71,16 +59,6 @@ std::shared_ptr<DmaBufTexture> Platform::createDmaBufTexture(const DmaBufParams
|
|||
return createDmaBufTexture({attribs.width, attribs.height}, attribs.format, attribs.modifier);
|
||||
}
|
||||
|
||||
std::unique_ptr<Edge> Platform::createScreenEdge(ScreenEdges *edges)
|
||||
{
|
||||
return std::make_unique<Edge>(edges);
|
||||
}
|
||||
|
||||
void Platform::createPlatformCursor(QObject *parent)
|
||||
{
|
||||
new InputRedirectionCursor(parent);
|
||||
}
|
||||
|
||||
bool Platform::applyOutputChanges(const OutputConfiguration &config)
|
||||
{
|
||||
const auto availableOutputs = outputs();
|
||||
|
@ -142,37 +120,6 @@ void Platform::setSceneEglDisplay(EGLDisplay display)
|
|||
m_eglDisplay = display;
|
||||
}
|
||||
|
||||
void Platform::startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName)
|
||||
{
|
||||
if (!input()) {
|
||||
callback(nullptr);
|
||||
return;
|
||||
}
|
||||
input()->startInteractiveWindowSelection(callback, cursorName);
|
||||
}
|
||||
|
||||
void Platform::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
{
|
||||
if (!input()) {
|
||||
callback(QPoint(-1, -1));
|
||||
return;
|
||||
}
|
||||
input()->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
||||
std::unique_ptr<OutlineVisual> Platform::createOutline(Outline *outline)
|
||||
{
|
||||
if (Compositor::compositing()) {
|
||||
return std::make_unique<CompositedOutlineVisual>(outline);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Platform::createEffectsHandler(Compositor *compositor, Scene *scene)
|
||||
{
|
||||
new EffectsHandlerImpl(compositor, scene);
|
||||
}
|
||||
|
||||
QString Platform::supportInformation() const
|
||||
{
|
||||
return QStringLiteral("Name: %1\n").arg(metaObject()->className());
|
||||
|
|
|
@ -12,28 +12,19 @@
|
|||
#include <kwin_export.h>
|
||||
#include <kwinglobals.h>
|
||||
|
||||
#include <QImage>
|
||||
#include <QObject>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class Window;
|
||||
class Output;
|
||||
class Edge;
|
||||
class Compositor;
|
||||
class DmaBufTexture;
|
||||
class InputBackend;
|
||||
class OpenGLBackend;
|
||||
class Outline;
|
||||
class OutlineVisual;
|
||||
class QPainterBackend;
|
||||
class Scene;
|
||||
class ScreenEdges;
|
||||
class OutputConfiguration;
|
||||
struct DmaBufParams;
|
||||
|
||||
|
@ -63,16 +54,6 @@ public:
|
|||
virtual std::shared_ptr<DmaBufTexture> createDmaBufTexture(const QSize &size, quint32 format, const uint64_t modifier);
|
||||
std::shared_ptr<DmaBufTexture> createDmaBufTexture(const DmaBufParams &attributes);
|
||||
|
||||
/**
|
||||
* Allows the platform to create a platform specific screen edge.
|
||||
* The default implementation creates a Edge.
|
||||
*/
|
||||
virtual std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent);
|
||||
/**
|
||||
* Allows the platform to create a platform specific Cursor.
|
||||
* The default implementation creates an InputRedirectionCursor.
|
||||
*/
|
||||
virtual void createPlatformCursor(QObject *parent = nullptr);
|
||||
/**
|
||||
* The EGLDisplay used by the compositing scene.
|
||||
*/
|
||||
|
@ -92,51 +73,6 @@ public:
|
|||
*/
|
||||
void setSceneEglGlobalShareContext(EGLContext context);
|
||||
|
||||
/**
|
||||
* Starts an interactive window selection process.
|
||||
*
|
||||
* Once the user selected a window the @p callback is invoked with the selected Window as
|
||||
* argument. In case the user cancels the interactive window selection or selecting a window is currently
|
||||
* not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument.
|
||||
*
|
||||
* During the interactive window selection the cursor is turned into a crosshair cursor unless
|
||||
* @p cursorName is provided. The argument @p cursorName is a QByteArray instead of Qt::CursorShape
|
||||
* to support the "pirate" cursor for kill window which is not wrapped by Qt::CursorShape.
|
||||
*
|
||||
* The default implementation forwards to InputRedirection.
|
||||
*
|
||||
* @param callback The function to invoke once the interactive window selection ends
|
||||
* @param cursorName The optional name of the cursor shape to use, default is crosshair
|
||||
*/
|
||||
virtual void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray());
|
||||
|
||||
/**
|
||||
* Starts an interactive position selection process.
|
||||
*
|
||||
* Once the user selected a position on the screen the @p callback is invoked with
|
||||
* the selected point as argument. In case the user cancels the interactive position selection
|
||||
* or selecting a position is currently not possible (e.g. screen locked) the @p callback
|
||||
* is invoked with a point at @c -1 as x and y argument.
|
||||
*
|
||||
* During the interactive window selection the cursor is turned into a crosshair cursor.
|
||||
*
|
||||
* The default implementation forwards to InputRedirection.
|
||||
*
|
||||
* @param callback The function to invoke once the interactive position selection ends
|
||||
*/
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
||||
|
||||
/**
|
||||
* Returns a PlatformCursorImage. By default this is created by softwareCursor and
|
||||
* softwareCursorHotspot. An implementing subclass can use this to provide a better
|
||||
* suited PlatformCursorImage.
|
||||
*
|
||||
* @see softwareCursor
|
||||
* @see softwareCursorHotspot
|
||||
* @since 5.9
|
||||
*/
|
||||
virtual PlatformCursorImage cursorImage() const;
|
||||
|
||||
bool isReady() const
|
||||
{
|
||||
return m_ready;
|
||||
|
@ -166,17 +102,6 @@ public:
|
|||
m_initialOutputScale = scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the OutlineVisual for the given @p outline.
|
||||
* Default implementation creates an OutlineVisual suited for composited usage.
|
||||
*/
|
||||
virtual std::unique_ptr<OutlineVisual> createOutline(Outline *outline);
|
||||
|
||||
/**
|
||||
* Default implementation creates an EffectsHandlerImp;
|
||||
*/
|
||||
virtual void createEffectsHandler(Compositor *compositor, Scene *scene);
|
||||
|
||||
/**
|
||||
* The CompositingTypes supported by the Platform.
|
||||
* The first item should be the most preferred one.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "atoms.h"
|
||||
#include "composite.h"
|
||||
#include "core/output.h"
|
||||
#include "core/platform.h"
|
||||
#include "core/renderbackend.h"
|
||||
#include "debug_console.h"
|
||||
#include "kwinadaptor.h"
|
||||
|
@ -202,7 +201,7 @@ QVariantMap DBusInterface::queryWindowInfo()
|
|||
{
|
||||
m_replyQueryWindowInfo = message();
|
||||
setDelayedReply(true);
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(
|
||||
kwinApp()->startInteractiveWindowSelection(
|
||||
[this](Window *t) {
|
||||
if (!t) {
|
||||
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "screenlockerwatcher.h"
|
||||
#endif
|
||||
#include "composite.h"
|
||||
#include "core/platform.h"
|
||||
#include "decorations/decorationbridge.h"
|
||||
#include "inputmethod.h"
|
||||
#include "inputpanelv1window.h"
|
||||
|
@ -1694,7 +1693,7 @@ void EffectsHandlerImpl::highlightWindows(const QVector<EffectWindow *> &windows
|
|||
|
||||
PlatformCursorImage EffectsHandlerImpl::cursorImage() const
|
||||
{
|
||||
return kwinApp()->platform()->cursorImage();
|
||||
return kwinApp()->cursorImage();
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::hideCursor()
|
||||
|
@ -1709,7 +1708,7 @@ void EffectsHandlerImpl::showCursor()
|
|||
|
||||
void EffectsHandlerImpl::startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback)
|
||||
{
|
||||
kwinApp()->platform()->startInteractiveWindowSelection([callback](KWin::Window *window) {
|
||||
kwinApp()->startInteractiveWindowSelection([callback](KWin::Window *window) {
|
||||
if (window && window->effectWindow()) {
|
||||
callback(window->effectWindow());
|
||||
} else {
|
||||
|
@ -1720,7 +1719,7 @@ void EffectsHandlerImpl::startInteractiveWindowSelection(std::function<void(KWin
|
|||
|
||||
void EffectsHandlerImpl::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
{
|
||||
kwinApp()->platform()->startInteractivePositionSelection(callback);
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::showOnScreenMessage(const QString &message, const QString &iconName)
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "killwindow.h"
|
||||
#include "core/platform.h"
|
||||
#include "main.h"
|
||||
#include "osd.h"
|
||||
#include "unmanaged.h"
|
||||
|
@ -32,7 +31,7 @@ void KillWindow::start()
|
|||
{
|
||||
OSD::show(i18n("Select window to force close with left click or enter.\nEscape or right click to cancel."),
|
||||
QStringLiteral("window-close"));
|
||||
kwinApp()->platform()->startInteractiveWindowSelection(
|
||||
kwinApp()->startInteractiveWindowSelection(
|
||||
[](KWin::Window *t) {
|
||||
OSD::hide();
|
||||
if (!t) {
|
||||
|
|
62
src/main.cpp
62
src/main.cpp
|
@ -15,15 +15,16 @@
|
|||
#include "colormanager.h"
|
||||
#include "composite.h"
|
||||
#include "core/platform.h"
|
||||
#include "core/session.h"
|
||||
#include "cursor.h"
|
||||
#include "effects.h"
|
||||
#include "input.h"
|
||||
#include "inputmethod.h"
|
||||
#include "options.h"
|
||||
#include "outline.h"
|
||||
#include "pluginmanager.h"
|
||||
#if KWIN_BUILD_SCREENLOCKER
|
||||
#include "screenlockerwatcher.h"
|
||||
#endif
|
||||
#include "core/session.h"
|
||||
#include "pointer_input.h"
|
||||
#include "screenedge.h"
|
||||
#include "sm.h"
|
||||
#include "tabletmodemanager.h"
|
||||
#include "utils/xcbutils.h"
|
||||
|
@ -31,6 +32,10 @@
|
|||
#include "workspace.h"
|
||||
#include "x11eventfilter.h"
|
||||
|
||||
#if KWIN_BUILD_SCREENLOCKER
|
||||
#include "screenlockerwatcher.h"
|
||||
#endif
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
// KDE
|
||||
|
@ -258,7 +263,7 @@ void Application::createInput()
|
|||
#endif
|
||||
auto input = InputRedirection::create(this);
|
||||
input->init();
|
||||
m_platform->createPlatformCursor(this);
|
||||
createPlatformCursor(this);
|
||||
}
|
||||
|
||||
void Application::createAtoms()
|
||||
|
@ -331,6 +336,29 @@ void Application::destroyInputMethod()
|
|||
m_inputMethod.reset();
|
||||
}
|
||||
|
||||
std::unique_ptr<Edge> Application::createScreenEdge(ScreenEdges *edges)
|
||||
{
|
||||
return std::make_unique<Edge>(edges);
|
||||
}
|
||||
|
||||
void Application::createPlatformCursor(QObject *parent)
|
||||
{
|
||||
new InputRedirectionCursor(parent);
|
||||
}
|
||||
|
||||
std::unique_ptr<OutlineVisual> Application::createOutline(Outline *outline)
|
||||
{
|
||||
if (Compositor::compositing()) {
|
||||
return std::make_unique<CompositedOutlineVisual>(outline);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Application::createEffectsHandler(Compositor *compositor, Scene *scene)
|
||||
{
|
||||
new EffectsHandlerImpl(compositor, scene);
|
||||
}
|
||||
|
||||
void Application::registerEventFilter(X11EventFilter *filter)
|
||||
{
|
||||
if (filter->isGenericEvent()) {
|
||||
|
@ -629,4 +657,28 @@ ScreenLockerWatcher *Application::screenLockerWatcher() const
|
|||
}
|
||||
#endif
|
||||
|
||||
PlatformCursorImage Application::cursorImage() const
|
||||
{
|
||||
Cursor *cursor = Cursors::self()->currentCursor();
|
||||
return PlatformCursorImage(cursor->image(), cursor->hotspot());
|
||||
}
|
||||
|
||||
void Application::startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName)
|
||||
{
|
||||
if (!input()) {
|
||||
callback(nullptr);
|
||||
return;
|
||||
}
|
||||
input()->startInteractiveWindowSelection(callback, cursorName);
|
||||
}
|
||||
|
||||
void Application::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
{
|
||||
if (!input()) {
|
||||
callback(QPoint(-1, -1));
|
||||
return;
|
||||
}
|
||||
input()->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
57
src/main.h
57
src/main.h
|
@ -36,6 +36,13 @@ class ColorManager;
|
|||
class ScreenLockerWatcher;
|
||||
class TabletModeManager;
|
||||
class XwaylandInterface;
|
||||
class Edge;
|
||||
class ScreenEdges;
|
||||
class Outline;
|
||||
class OutlineVisual;
|
||||
class Compositor;
|
||||
class Scene;
|
||||
class Window;
|
||||
|
||||
class XcbEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
|
@ -245,6 +252,11 @@ public:
|
|||
void createAtoms();
|
||||
void destroyAtoms();
|
||||
|
||||
virtual std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent);
|
||||
virtual void createPlatformCursor(QObject *parent = nullptr);
|
||||
virtual std::unique_ptr<OutlineVisual> createOutline(Outline *outline);
|
||||
virtual void createEffectsHandler(Compositor *compositor, Scene *scene);
|
||||
|
||||
static void setupMalloc();
|
||||
static void setupLocalizedString();
|
||||
|
||||
|
@ -256,6 +268,51 @@ public:
|
|||
ScreenLockerWatcher *screenLockerWatcher() const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Starts an interactive window selection process.
|
||||
*
|
||||
* Once the user selected a window the @p callback is invoked with the selected Window as
|
||||
* argument. In case the user cancels the interactive window selection or selecting a window is currently
|
||||
* not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument.
|
||||
*
|
||||
* During the interactive window selection the cursor is turned into a crosshair cursor unless
|
||||
* @p cursorName is provided. The argument @p cursorName is a QByteArray instead of Qt::CursorShape
|
||||
* to support the "pirate" cursor for kill window which is not wrapped by Qt::CursorShape.
|
||||
*
|
||||
* The default implementation forwards to InputRedirection.
|
||||
*
|
||||
* @param callback The function to invoke once the interactive window selection ends
|
||||
* @param cursorName The optional name of the cursor shape to use, default is crosshair
|
||||
*/
|
||||
virtual void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray());
|
||||
|
||||
/**
|
||||
* Starts an interactive position selection process.
|
||||
*
|
||||
* Once the user selected a position on the screen the @p callback is invoked with
|
||||
* the selected point as argument. In case the user cancels the interactive position selection
|
||||
* or selecting a position is currently not possible (e.g. screen locked) the @p callback
|
||||
* is invoked with a point at @c -1 as x and y argument.
|
||||
*
|
||||
* During the interactive window selection the cursor is turned into a crosshair cursor.
|
||||
*
|
||||
* The default implementation forwards to InputRedirection.
|
||||
*
|
||||
* @param callback The function to invoke once the interactive position selection ends
|
||||
*/
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
||||
|
||||
/**
|
||||
* Returns a PlatformCursorImage. By default this is created by softwareCursor and
|
||||
* softwareCursorHotspot. An implementing subclass can use this to provide a better
|
||||
* suited PlatformCursorImage.
|
||||
*
|
||||
* @see softwareCursor
|
||||
* @see softwareCursorHotspot
|
||||
* @since 5.9
|
||||
*/
|
||||
virtual PlatformCursorImage cursorImage() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void x11ConnectionChanged();
|
||||
void x11ConnectionAboutToBeDestroyed();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "backends/x11/standalone/x11_standalone_platform.h"
|
||||
#include "core/platform.h"
|
||||
#include "core/session.h"
|
||||
#include "outline.h"
|
||||
#include "screenedge.h"
|
||||
#include "sm.h"
|
||||
#include "tabletmodemanager.h"
|
||||
#include "utils/xcbutils.h"
|
||||
|
@ -196,6 +198,45 @@ void ApplicationX11::setReplace(bool replace)
|
|||
m_replace = replace;
|
||||
}
|
||||
|
||||
std::unique_ptr<Edge> ApplicationX11::createScreenEdge(ScreenEdges *parent)
|
||||
{
|
||||
return static_cast<X11StandalonePlatform *>(platform())->createScreenEdge(parent);
|
||||
}
|
||||
|
||||
void ApplicationX11::createPlatformCursor(QObject *parent)
|
||||
{
|
||||
static_cast<X11StandalonePlatform *>(platform())->createPlatformCursor(parent);
|
||||
}
|
||||
|
||||
std::unique_ptr<OutlineVisual> ApplicationX11::createOutline(Outline *outline)
|
||||
{
|
||||
// first try composited Outline
|
||||
if (auto outlineVisual = Application::createOutline(outline)) {
|
||||
return outlineVisual;
|
||||
}
|
||||
return static_cast<X11StandalonePlatform *>(platform())->createOutline(outline);
|
||||
}
|
||||
|
||||
void ApplicationX11::createEffectsHandler(Compositor *compositor, Scene *scene)
|
||||
{
|
||||
static_cast<X11StandalonePlatform *>(platform())->createEffectsHandler(compositor, scene);
|
||||
}
|
||||
|
||||
void ApplicationX11::startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName)
|
||||
{
|
||||
static_cast<X11StandalonePlatform *>(platform())->startInteractiveWindowSelection(callback, cursorName);
|
||||
}
|
||||
|
||||
void ApplicationX11::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
{
|
||||
static_cast<X11StandalonePlatform *>(platform())->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
||||
PlatformCursorImage ApplicationX11::cursorImage() const
|
||||
{
|
||||
return static_cast<X11StandalonePlatform *>(platform())->cursorImage();
|
||||
}
|
||||
|
||||
void ApplicationX11::lostSelection()
|
||||
{
|
||||
sendPostedEvents();
|
||||
|
|
|
@ -24,6 +24,14 @@ public:
|
|||
|
||||
void setReplace(bool replace);
|
||||
|
||||
std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent) override;
|
||||
void createPlatformCursor(QObject *parent = nullptr) override;
|
||||
std::unique_ptr<OutlineVisual> createOutline(Outline *outline) override;
|
||||
void createEffectsHandler(Compositor *compositor, Scene *scene) override;
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray()) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
|
||||
PlatformCursorImage cursorImage() const override;
|
||||
|
||||
protected:
|
||||
void performStartup() override;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "outline.h"
|
||||
// KWin
|
||||
#include "composite.h"
|
||||
#include "core/platform.h"
|
||||
#include "main.h"
|
||||
#include "scripting/scripting.h"
|
||||
#include "utils/common.h"
|
||||
|
@ -105,7 +104,7 @@ void Outline::createHelper()
|
|||
if (m_visual) {
|
||||
return;
|
||||
}
|
||||
m_visual = kwinApp()->platform()->createOutline(this);
|
||||
m_visual = kwinApp()->createOutline(this);
|
||||
}
|
||||
|
||||
void Outline::compositingChanged()
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <config-kwin.h>
|
||||
|
||||
#include "core/output.h"
|
||||
#include "core/platform.h"
|
||||
#include "cursor.h"
|
||||
#include "effects.h"
|
||||
#include "gestures.h"
|
||||
|
@ -1166,7 +1165,7 @@ void ScreenEdges::createHorizontalEdge(ElectricBorder border, const QRect &scree
|
|||
|
||||
std::unique_ptr<Edge> ScreenEdges::createEdge(ElectricBorder border, int x, int y, int width, int height, Output *output, bool createAction)
|
||||
{
|
||||
std::unique_ptr<Edge> edge = kwinApp()->platform()->createScreenEdge(this);
|
||||
std::unique_ptr<Edge> edge = kwinApp()->createScreenEdge(this);
|
||||
// Edges can not have negative size.
|
||||
Q_ASSERT(width >= 0);
|
||||
Q_ASSERT(height >= 0);
|
||||
|
|
Loading…
Reference in a new issue