From 4b41c33268a1c155c606293d1d39ba2f61a478ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 6 Mar 2015 12:38:07 +0100 Subject: [PATCH] Workspace::movingClient changed to AbstractClient In events.cpp it's casted to Client as it's X11 specific. In InputRedirections it's kind of broken, but window movement is anyway broken. --- abstract_client.h | 3 +++ client.h | 4 ++-- effects.cpp | 2 +- events.cpp | 8 ++++---- geometry.cpp | 2 +- input.cpp | 2 +- screenedge.cpp | 2 +- scripting/workspace_wrapper.cpp | 2 +- scripting/workspace_wrapper.h | 3 ++- workspace.cpp | 2 +- workspace.h | 8 ++++---- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/abstract_client.h b/abstract_client.h index 81753fb7d3..795faea335 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -27,6 +27,7 @@ namespace KWin { class TabGroup; +class WindowRules; namespace TabBox { @@ -68,6 +69,7 @@ public: virtual void setShortcut(const QString &cut) = 0; virtual bool performMouseCommand(Options::MouseCommand, const QPoint &globalPos) = 0; virtual void setOnAllDesktops(bool set) = 0; + virtual void setDesktop(int) = 0; virtual void minimize(bool avoid_animation = false) = 0; virtual void setFullScreen(bool set, bool user = true) = 0; virtual bool keepAbove() const = 0; @@ -95,6 +97,7 @@ public: virtual bool userCanSetFullScreen() const = 0; virtual bool userCanSetNoBorder() const = 0; virtual void setOnAllActivities(bool set) = 0; + virtual const WindowRules* rules() const = 0; // TODO: remove boolean trap static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false); diff --git a/client.h b/client.h index 4fed73e22b..13f57af708 100644 --- a/client.h +++ b/client.h @@ -308,7 +308,7 @@ public: Group* group(); void checkGroup(Group* gr = NULL, bool force = false); void changeClientLeaderGroup(Group* gr); - const WindowRules* rules() const; + const WindowRules* rules() const override; void removeRule(Rules* r); void setupWindowRules(bool ignore_temporary); void applyWindowRules(); @@ -355,7 +355,7 @@ public: void setActive(bool); virtual int desktop() const; - void setDesktop(int); + void setDesktop(int) override; void setOnAllDesktops(bool set) override; void sendToScreen(int screen) override; diff --git a/effects.cpp b/effects.cpp index 86ecc9a512..3565129b22 100644 --- a/effects.cpp +++ b/effects.cpp @@ -221,7 +221,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) connect(ws, &Workspace::showingDesktopChanged, this, &EffectsHandlerImpl::showingDesktopChanged); connect(ws, &Workspace::currentDesktopChanged, this, - [this](int old, Client *c) { + [this](int old, AbstractClient *c) { const int newDesktop = VirtualDesktopManager::self()->current(); if (old != 0 && newDesktop != old) { emit desktopChanged(old, newDesktop, c ? c->effectWindow() : 0); diff --git a/events.cpp b/events.cpp index 8872e48b60..f79d48066f 100644 --- a/events.cpp +++ b/events.cpp @@ -312,8 +312,8 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) xcb_key_press_event_t *event = reinterpret_cast(e); KKeyServer::xcbKeyPressEventToQt(event, &keyQt); // qDebug() << "Workspace::keyPress( " << keyQt << " )"; - if (movingClient) { - movingClient->keyPressEvent(keyQt, event->time); + if (Client *c = dynamic_cast(movingClient)) { + c->keyPressEvent(keyQt, event->time); return true; } #ifdef KWIN_BUILD_TABBOX @@ -366,9 +366,9 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) } } } - if (movingClient) { + if (Client *c = dynamic_cast(movingClient)) { if (eventType == XCB_BUTTON_PRESS || eventType == XCB_BUTTON_RELEASE || eventType == XCB_MOTION_NOTIFY) { - if (movingClient->moveResizeGrabWindow() == reinterpret_cast(e)->event && movingClient->windowEvent(e)) { + if (c->moveResizeGrabWindow() == reinterpret_cast(e)->event && c->windowEvent(e)) { return true; } } diff --git a/geometry.cpp b/geometry.cpp index 6cc6a93b7b..dd2df6244e 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -793,7 +793,7 @@ QRect Workspace::adjustClientSize(Client* c, QRect moveResizeGeom, int mode) /*! Marks the client as being moved around by the user. */ -void Workspace::setClientIsMoving(Client *c) +void Workspace::setClientIsMoving(AbstractClient *c) { Q_ASSERT(!c || !movingClient); // Catch attempts to move a second // window while still moving the first one. diff --git a/input.cpp b/input.cpp index cb9902ca9a..56747715a3 100644 --- a/input.cpp +++ b/input.cpp @@ -534,7 +534,7 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa return; } if (workspace()) { - if (Client *c = workspace()->getMovingClient()) { + if (Client *c = dynamic_cast(workspace()->getMovingClient())) { // TODO: this does not yet fully support moving of the Client // cursor events change the cursor and on Wayland pointer warping is not possible c->keyPressEvent(m_xkb->toQtKey(m_xkb->toKeysym(key))); diff --git a/screenedge.cpp b/screenedge.cpp index 7f45d762f2..79ee09acb2 100644 --- a/screenedge.cpp +++ b/screenedge.cpp @@ -285,7 +285,7 @@ void Edge::switchDesktop(const QPoint &cursorPos) pos.setY(OFFSET); } #ifndef KWIN_UNIT_TEST - if (Client *c = Workspace::self()->getMovingClient()) { + if (AbstractClient *c = Workspace::self()->getMovingClient()) { if (c->rules()->checkDesktop(desktop) != int(desktop)) { // user attempts to move a client to another desktop where it is ruleforced to not be return; diff --git a/scripting/workspace_wrapper.cpp b/scripting/workspace_wrapper.cpp index 7ce5dd8592..0c2e8c13a9 100644 --- a/scripting/workspace_wrapper.cpp +++ b/scripting/workspace_wrapper.cpp @@ -39,7 +39,7 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent) KWin::Workspace *ws = KWin::Workspace::self(); KWin::VirtualDesktopManager *vds = KWin::VirtualDesktopManager::self(); connect(ws, SIGNAL(desktopPresenceChanged(KWin::Client*,int)), SIGNAL(desktopPresenceChanged(KWin::Client*,int))); - connect(ws, SIGNAL(currentDesktopChanged(int,KWin::Client*)), SIGNAL(currentDesktopChanged(int,KWin::Client*))); + connect(ws, &Workspace::currentDesktopChanged, this, &WorkspaceWrapper::currentDesktopChanged); connect(ws, SIGNAL(clientAdded(KWin::Client*)), SIGNAL(clientAdded(KWin::Client*))); connect(ws, SIGNAL(clientAdded(KWin::Client*)), SLOT(setupClientConnections(KWin::Client*))); connect(ws, SIGNAL(clientRemoved(KWin::Client*)), SIGNAL(clientRemoved(KWin::Client*))); diff --git a/scripting/workspace_wrapper.h b/scripting/workspace_wrapper.h index 9a2582bf9b..c7e68024df 100644 --- a/scripting/workspace_wrapper.h +++ b/scripting/workspace_wrapper.h @@ -31,6 +31,7 @@ along with this program. If not, see . namespace KWin { // forward declarations +class AbstractClient; class Client; class WorkspaceWrapper : public QObject @@ -88,7 +89,7 @@ private: Q_SIGNALS: void desktopPresenceChanged(KWin::Client *client, int desktop); - void currentDesktopChanged(int desktop, KWin::Client *client); + void currentDesktopChanged(int desktop, KWin::AbstractClient *client); void clientAdded(KWin::Client *client); void clientRemoved(KWin::Client *client); void clientManaging(KWin::Client *client); diff --git a/workspace.cpp b/workspace.cpp index 4a62a50043..30bb5ea1ac 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -189,7 +189,7 @@ Workspace::Workspace(bool restore) } else { m_compositor = Compositor::create(this); } - connect(this, SIGNAL(currentDesktopChanged(int,KWin::Client*)), m_compositor, SLOT(addRepaintFull())); + connect(this, &Workspace::currentDesktopChanged, m_compositor, &Compositor::addRepaintFull); auto decorationBridge = Decoration::DecorationBridge::create(this); decorationBridge->init(); diff --git a/workspace.h b/workspace.h index c5da590c77..9014f9bb31 100644 --- a/workspace.h +++ b/workspace.h @@ -170,7 +170,7 @@ public: /** * Indicates that the client c is being moved around by the user. */ - void setClientIsMoving(Client* c); + void setClientIsMoving(AbstractClient* c); QPoint adjustClientPosition(Client* c, QPoint pos, bool unrestricted, double snapAdjust = 1.0); QRect adjustClientSize(Client* c, QRect moveResizeGeom, int mode); @@ -327,7 +327,7 @@ public: void updateFocusMousePosition(const QPoint& pos); QPoint focusMousePosition() const; - Client* getMovingClient() { + AbstractClient* getMovingClient() { return movingClient; } @@ -442,7 +442,7 @@ Q_SIGNALS: //Signals required for the scripting interface void desktopPresenceChanged(KWin::Client*, int); - void currentDesktopChanged(int, KWin::Client*); + void currentDesktopChanged(int, KWin::AbstractClient*); void clientAdded(KWin::Client*); void clientRemoved(KWin::Client*); void clientActivated(KWin::Client*); @@ -516,7 +516,7 @@ private: Client* active_client; Client* last_active_client; AbstractClient* most_recently_raised; // Used ONLY by raiseOrLowerClient() - Client* movingClient; + AbstractClient* movingClient; // Delay(ed) window focus timer and client QTimer* delayFocusTimer;