Commit d2cdd3de authored by Martin Flöser's avatar Martin Flöser

UserActionsMenu operates on AbstractClient

There are still a few areas where it's dynamic casting to Client,
e.g.:
* sendToDesktop
* window tabbing related
* activities related
parent 4eb9a98f
......@@ -80,6 +80,21 @@ public:
virtual void maximize(MaximizeMode) = 0;
virtual bool noBorder() const = 0;
virtual void setNoBorder(bool set) = 0;
virtual void blockActivityUpdates(bool b = true) = 0;
virtual QPalette palette() const = 0;
virtual bool isResizable() const = 0;
virtual bool isMovable() const = 0;
virtual bool isMovableAcrossScreens() const = 0;
virtual bool isShade() const = 0; // True only for ShadeNormal
virtual ShadeMode shadeMode() const = 0; // Prefer isShade()
virtual void setShade(bool set) = 0;
virtual void setShade(ShadeMode mode) = 0;
virtual bool isShadeable() const = 0;
virtual bool isMaximizable() const = 0;
virtual bool isMinimizable() const = 0;
virtual bool userCanSetFullScreen() const = 0;
virtual bool userCanSetNoBorder() const = 0;
virtual void setOnAllActivities(bool set) = 0;
// TODO: remove boolean trap
static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false);
......
......@@ -362,23 +362,23 @@ public:
virtual QStringList activities() const;
void setOnActivity(const QString &activity, bool enable);
void setOnAllActivities(bool set);
void setOnAllActivities(bool set) override;
void setOnActivities(QStringList newActivitiesList);
void updateActivities(bool includeTransients);
void blockActivityUpdates(bool b = true);
void blockActivityUpdates(bool b = true) override;
/// Is not minimized and not hidden. I.e. normally visible on some virtual desktop.
bool isShown(bool shaded_is_shown) const override;
bool isHiddenInternal() const; // For compositing
bool isShade() const; // True only for ShadeNormal
ShadeMode shadeMode() const; // Prefer isShade()
void setShade(bool set);
void setShade(ShadeMode mode);
bool isShadeable() const;
bool isShade() const override; // True only for ShadeNormal
ShadeMode shadeMode() const override; // Prefer isShade()
void setShade(bool set) override;
void setShade(ShadeMode mode) override;
bool isShadeable() const override;
bool isMinimized() const override;
bool isMaximizable() const;
bool isMaximizable() const override;
QRect geometryRestore() const;
MaximizeMode maximizeMode() const override;
......@@ -395,7 +395,7 @@ public:
Q_DECLARE_FLAGS(QuickTileMode, QuickTileFlag)
QuickTileMode quickTileMode() const;
bool isMinimizable() const;
bool isMinimizable() const override;
void setMaximize(bool vertically, bool horizontally);
QRect iconGeometry() const;
......@@ -403,7 +403,7 @@ public:
bool isFullScreen() const override;
bool isFullScreenable(bool fullscreen_hack = false) const;
bool isActiveFullScreen() const;
bool userCanSetFullScreen() const;
bool userCanSetFullScreen() const override;
QRect geometryFSRestore() const {
return geom_fs_restore; // Only for session saving
}
......@@ -413,7 +413,7 @@ public:
bool noBorder() const override;
void setNoBorder(bool set) override;
bool userCanSetNoBorder() const;
bool userCanSetNoBorder() const override;
void checkNoBorder();
bool skipTaskbar(bool from_outside = false) const;
......@@ -442,9 +442,9 @@ public:
bool wantsTabFocus() const override;
bool wantsInput() const;
bool isResizable() const;
bool isMovable() const;
bool isMovableAcrossScreens() const;
bool isResizable() const override;
bool isMovable() const override;
bool isMovableAcrossScreens() const override;
bool isCloseable() const override; ///< May be closed by the user (May have a close button)
void takeFocus();
......@@ -666,7 +666,7 @@ public:
void cancelFocusOutTimer();
QPalette palette() const;
QPalette palette() const override;
const Decoration::DecorationPalette *decorationPalette() const;
/**
......
......@@ -92,7 +92,7 @@ UserActionsMenu::UserActionsMenu(QObject *parent)
, m_closeOperation(NULL)
, m_removeFromTabGroup(NULL)
, m_closeTabGroup(NULL)
, m_client(QWeakPointer<Client>())
, m_client(QWeakPointer<AbstractClient>())
{
}
......@@ -120,7 +120,7 @@ void UserActionsMenu::close()
m_client.clear();
}
bool UserActionsMenu::isMenuClient(const Client *c) const
bool UserActionsMenu::isMenuClient(const AbstractClient *c) const
{
if (!c || m_client.isNull()) {
return false;
......@@ -128,7 +128,7 @@ bool UserActionsMenu::isMenuClient(const Client *c) const
return c == m_client.data();
}
void UserActionsMenu::show(const QRect &pos, const QWeakPointer<Client> &cl)
void UserActionsMenu::show(const QRect &pos, const QWeakPointer<AbstractClient> &cl)
{
if (!KAuthorized::authorizeKAction(QStringLiteral("kwin_rmb")))
return;
......@@ -165,7 +165,7 @@ void UserActionsMenu::show(const QRect &pos, const QWeakPointer<Client> &cl)
}
}
void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<Client> &c)
void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<AbstractClient> &c)
{
QStringList args;
QString type;
......@@ -497,12 +497,16 @@ void UserActionsMenu::entabPopupClient(QAction* action)
{
if (m_client.isNull() || !action->data().isValid())
return;
Client *other = action->data().value<Client*>();
Client *other = dynamic_cast<Client*>(action->data().value<AbstractClient*>());
if (!Workspace::self()->clientList().contains(other)) // might have been lost betwenn pop-up and selection
return;
m_client.data()->tabBehind(other, true);
Client *c = dynamic_cast<Client*>(m_client.data());
if (!c) {
return;
}
c->tabBehind(other, true);
if (options->focusPolicyIsReasonable())
Workspace::self()->requestFocus(m_client.data());
Workspace::self()->requestFocus(c);
}
void UserActionsMenu::rebuildTabGroupPopup()
......@@ -712,7 +716,7 @@ void UserActionsMenu::slotWindowOperation(QAction *action)
return;
Options::WindowOperation op = static_cast< Options::WindowOperation >(action->data().toInt());
QWeakPointer<Client> c = (!m_client.isNull()) ? m_client : QWeakPointer<Client>(Workspace::self()->activeClient());
QWeakPointer<AbstractClient> c = (!m_client.isNull()) ? m_client : QWeakPointer<AbstractClient>(Workspace::self()->activeClient());
if (c.isNull())
return;
QString type;
......@@ -746,7 +750,8 @@ void UserActionsMenu::slotSendToDesktop(QAction *action)
if (!ok) {
return;
}
if (m_client.isNull())
Client *c = dynamic_cast<Client*>(m_client.data());
if (c)
return;
Workspace *ws = Workspace::self();
VirtualDesktopManager *vds = VirtualDesktopManager::self();
......@@ -758,7 +763,7 @@ void UserActionsMenu::slotSendToDesktop(QAction *action)
vds->setCount(desk);
}
ws->sendClientToDesktop(m_client.data(), desk, false);
ws->sendClientToDesktop(c, desk, false);
}
void UserActionsMenu::slotSendToScreen(QAction *action)
......@@ -786,7 +791,12 @@ void UserActionsMenu::slotToggleOnActivity(QAction *action)
return;
}
Activities::self()->toggleClientOnActivity(m_client.data(), activity, false);
Client *c = dynamic_cast<Client*>(m_client.data());
if (!c) {
return;
}
Activities::self()->toggleClientOnActivity(c, activity, false);
if (m_activityMenu && m_activityMenu->isVisible() && m_activityMenu->actions().count()) {
const bool isOnAll = m_client.data()->isOnAllActivities();
m_activityMenu->actions().at(0)->setChecked(isOnAll);
......
......@@ -30,6 +30,7 @@ class QRect;
namespace KWin
{
class AbstractClient;
class Client;
/**
......@@ -78,7 +79,7 @@ public:
* @param c The Client to compare
* @returns Whether the Client is the one related to this Menu
**/
bool isMenuClient(const Client *c) const;
bool isMenuClient(const AbstractClient *c) const;
/**
* Closes the Menu and prepares it for next usage.
**/
......@@ -89,7 +90,7 @@ public:
* @param pos The position where the menu should be shown.
* @param client The Client for which the Menu has to be shown.
**/
void show(const QRect &pos, const QWeakPointer<Client> &client);
void show(const QRect &pos, const QWeakPointer<AbstractClient> &client);
public Q_SLOTS:
/**
......@@ -199,7 +200,7 @@ private:
* @param message The message type to be shown
* @param c The Client for which the dialog should be shown.
**/
void helperDialog(const QString &message, const QWeakPointer<Client> &c);
void helperDialog(const QString &message, const QWeakPointer<AbstractClient> &c);
/**
* The actual main context menu which is show when the UserActionsMenu is invoked.
**/
......@@ -249,7 +250,7 @@ private:
/**
* The Client for which the menu is shown.
**/
QWeakPointer<Client> m_client;
QWeakPointer<AbstractClient> m_client;
};
class ShortcutDialog
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment