Provide a base implementation for performMouseCommand in AbstractClient
Most commands can be operated directly in AbstractClient already which means less code duplication to make the commands work for wayland clients.icc-effect-5.14.5
parent
9a8f94f8fc
commit
8d407157c4
|
@ -20,9 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "abstract_client.h"
|
||||
#include "decorations/decorationpalette.h"
|
||||
#include "focuschain.h"
|
||||
#include "screens.h"
|
||||
#ifdef KWIN_BUILD_TABBOX
|
||||
#include "tabbox.h"
|
||||
#endif
|
||||
#include "tabgroup.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#if HAVE_WAYLAND
|
||||
|
@ -632,4 +634,122 @@ void AbstractClient::destroyWindowManagementInterface()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint &globalPos)
|
||||
{
|
||||
bool replay = false;
|
||||
switch(cmd) {
|
||||
case Options::MouseRaise:
|
||||
workspace()->raiseClient(this);
|
||||
break;
|
||||
case Options::MouseLower: {
|
||||
workspace()->lowerClient(this);
|
||||
break;
|
||||
}
|
||||
case Options::MouseOperationsMenu:
|
||||
if (isActive() && options->isClickRaise())
|
||||
autoRaise();
|
||||
workspace()->showWindowMenu(QRect(globalPos, globalPos), this);
|
||||
break;
|
||||
case Options::MouseToggleRaiseAndLower:
|
||||
workspace()->raiseOrLowerClient(this);
|
||||
break;
|
||||
case Options::MouseActivateAndRaise: {
|
||||
replay = isActive(); // for clickraise mode
|
||||
bool mustReplay = !rules()->checkAcceptFocus(info->input());
|
||||
if (mustReplay) {
|
||||
ToplevelList::const_iterator it = workspace()->stackingOrder().constEnd(),
|
||||
begin = workspace()->stackingOrder().constBegin();
|
||||
while (mustReplay && --it != begin && *it != this) {
|
||||
AbstractClient *c = qobject_cast<AbstractClient*>(*it);
|
||||
if (!c || (c->keepAbove() && !keepAbove()) || (keepBelow() && !c->keepBelow()))
|
||||
continue; // can never raise above "it"
|
||||
mustReplay = !(c->isOnCurrentDesktop() && c->isOnCurrentActivity() && c->geometry().intersects(geometry()));
|
||||
}
|
||||
}
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || mustReplay;
|
||||
break;
|
||||
}
|
||||
case Options::MouseActivateAndLower:
|
||||
workspace()->requestFocus(this);
|
||||
workspace()->lowerClient(this);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || !rules()->checkAcceptFocus(info->input());
|
||||
break;
|
||||
case Options::MouseActivate:
|
||||
replay = isActive(); // for clickraise mode
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || !rules()->checkAcceptFocus(info->input());
|
||||
break;
|
||||
case Options::MouseActivateRaiseAndPassClick:
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = true;
|
||||
break;
|
||||
case Options::MouseActivateAndPassClick:
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = true;
|
||||
break;
|
||||
case Options::MouseMaximize:
|
||||
maximize(MaximizeFull);
|
||||
break;
|
||||
case Options::MouseRestore:
|
||||
maximize(MaximizeRestore);
|
||||
break;
|
||||
case Options::MouseMinimize:
|
||||
minimize();
|
||||
break;
|
||||
case Options::MouseAbove: {
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
if (keepBelow())
|
||||
setKeepBelow(false);
|
||||
else
|
||||
setKeepAbove(true);
|
||||
break;
|
||||
}
|
||||
case Options::MouseBelow: {
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
if (keepAbove())
|
||||
setKeepAbove(false);
|
||||
else
|
||||
setKeepBelow(true);
|
||||
break;
|
||||
}
|
||||
case Options::MousePreviousDesktop:
|
||||
workspace()->windowToPreviousDesktop(this);
|
||||
break;
|
||||
case Options::MouseNextDesktop:
|
||||
workspace()->windowToNextDesktop(this);
|
||||
break;
|
||||
case Options::MouseOpacityMore:
|
||||
if (!isDesktop()) // No point in changing the opacity of the desktop
|
||||
setOpacity(qMin(opacity() + 0.1, 1.0));
|
||||
break;
|
||||
case Options::MouseOpacityLess:
|
||||
if (!isDesktop()) // No point in changing the opacity of the desktop
|
||||
setOpacity(qMax(opacity() - 0.1, 0.1));
|
||||
break;
|
||||
case Options::MousePreviousTab:
|
||||
if (tabGroup())
|
||||
tabGroup()->activatePrev();
|
||||
break;
|
||||
case Options::MouseNextTab:
|
||||
if (tabGroup())
|
||||
tabGroup()->activateNext();
|
||||
break;
|
||||
case Options::MouseClose:
|
||||
closeWindow();
|
||||
break;
|
||||
case Options::MouseDragTab:
|
||||
case Options::MouseNothing:
|
||||
default:
|
||||
replay = true;
|
||||
break;
|
||||
}
|
||||
return replay;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
virtual void sendToScreen(int screen) = 0;
|
||||
virtual const QKeySequence &shortcut() const = 0;
|
||||
virtual void setShortcut(const QString &cut) = 0;
|
||||
virtual bool performMouseCommand(Options::MouseCommand, const QPoint &globalPos) = 0;
|
||||
virtual bool performMouseCommand(Options::MouseCommand, const QPoint &globalPos);
|
||||
void setOnAllDesktops(bool set);
|
||||
void setDesktop(int);
|
||||
int desktop() const override {
|
||||
|
|
|
@ -376,13 +376,6 @@ bool ShellClient::noBorder() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ShellClient::performMouseCommand(Options::MouseCommand cmd, const QPoint &globalPos)
|
||||
{
|
||||
Q_UNUSED(cmd)
|
||||
Q_UNUSED(globalPos)
|
||||
return false;
|
||||
}
|
||||
|
||||
const WindowRules *ShellClient::rules() const
|
||||
{
|
||||
static WindowRules s_rules;
|
||||
|
|
|
@ -77,7 +77,6 @@ public:
|
|||
MaximizeMode maximizeMode() const override;
|
||||
bool noBorder() const override;
|
||||
const WindowRules *rules() const override;
|
||||
bool performMouseCommand(Options::MouseCommand cmd, const QPoint &globalPos) override;
|
||||
void sendToScreen(int screen) override;
|
||||
void setFullScreen(bool set, bool user = true) override;
|
||||
void setNoBorder(bool set) override;
|
||||
|
|
107
useractions.cpp
107
useractions.cpp
|
@ -1182,9 +1182,6 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
{
|
||||
bool replay = false;
|
||||
switch(command) {
|
||||
case Options::MouseRaise:
|
||||
workspace()->raiseClient(this);
|
||||
break;
|
||||
case Options::MouseLower: {
|
||||
workspace()->lowerClient(this);
|
||||
// used to be activateNextClient(this), then topClientOnDesktop
|
||||
|
@ -1208,54 +1205,6 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
setShade(ShadeNone);
|
||||
cancelShadeHoverTimer();
|
||||
break;
|
||||
case Options::MouseOperationsMenu:
|
||||
if (isActive() && options->isClickRaise())
|
||||
autoRaise();
|
||||
workspace()->showWindowMenu(QRect(globalPos, globalPos), this);
|
||||
break;
|
||||
case Options::MouseToggleRaiseAndLower:
|
||||
workspace()->raiseOrLowerClient(this);
|
||||
break;
|
||||
case Options::MouseActivateAndRaise: {
|
||||
replay = isActive(); // for clickraise mode
|
||||
bool mustReplay = !rules()->checkAcceptFocus(info->input());
|
||||
if (mustReplay) {
|
||||
ToplevelList::const_iterator it = workspace()->stackingOrder().constEnd(),
|
||||
begin = workspace()->stackingOrder().constBegin();
|
||||
while (mustReplay && --it != begin && *it != this) {
|
||||
Client *c = qobject_cast<Client*>(*it);
|
||||
if (!c || (c->keepAbove() && !keepAbove()) || (keepBelow() && !c->keepBelow()))
|
||||
continue; // can never raise above "it"
|
||||
mustReplay = !(c->isOnCurrentDesktop() && c->isOnCurrentActivity() && c->geometry().intersects(geometry()));
|
||||
}
|
||||
}
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || mustReplay;
|
||||
break;
|
||||
}
|
||||
case Options::MouseActivateAndLower:
|
||||
workspace()->requestFocus(this);
|
||||
workspace()->lowerClient(this);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || !rules()->checkAcceptFocus(info->input());
|
||||
break;
|
||||
case Options::MouseActivate:
|
||||
replay = isActive(); // for clickraise mode
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = replay || !rules()->checkAcceptFocus(info->input());
|
||||
break;
|
||||
case Options::MouseActivateRaiseAndPassClick:
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = true;
|
||||
break;
|
||||
case Options::MouseActivateAndPassClick:
|
||||
workspace()->takeActivity(this, Workspace::ActivityFocus);
|
||||
screens()->setCurrent(globalPos);
|
||||
replay = true;
|
||||
break;
|
||||
case Options::MouseActivateRaiseAndMove:
|
||||
case Options::MouseActivateRaiseAndUnrestrictedMove:
|
||||
workspace()->raiseClient(this);
|
||||
|
@ -1305,60 +1254,8 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl
|
|||
updateCursor();
|
||||
break;
|
||||
}
|
||||
case Options::MouseMaximize:
|
||||
maximize(MaximizeFull);
|
||||
break;
|
||||
case Options::MouseRestore:
|
||||
maximize(MaximizeRestore);
|
||||
break;
|
||||
case Options::MouseMinimize:
|
||||
minimize();
|
||||
break;
|
||||
case Options::MouseAbove: {
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
if (keepBelow())
|
||||
setKeepBelow(false);
|
||||
else
|
||||
setKeepAbove(true);
|
||||
break;
|
||||
}
|
||||
case Options::MouseBelow: {
|
||||
StackingUpdatesBlocker blocker(workspace());
|
||||
if (keepAbove())
|
||||
setKeepAbove(false);
|
||||
else
|
||||
setKeepBelow(true);
|
||||
break;
|
||||
}
|
||||
case Options::MousePreviousDesktop:
|
||||
workspace()->windowToPreviousDesktop(this);
|
||||
break;
|
||||
case Options::MouseNextDesktop:
|
||||
workspace()->windowToNextDesktop(this);
|
||||
break;
|
||||
case Options::MouseOpacityMore:
|
||||
if (!isDesktop()) // No point in changing the opacity of the desktop
|
||||
setOpacity(qMin(opacity() + 0.1, 1.0));
|
||||
break;
|
||||
case Options::MouseOpacityLess:
|
||||
if (!isDesktop()) // No point in changing the opacity of the desktop
|
||||
setOpacity(qMax(opacity() - 0.1, 0.1));
|
||||
break;
|
||||
case Options::MousePreviousTab:
|
||||
if (tabGroup())
|
||||
tabGroup()->activatePrev();
|
||||
break;
|
||||
case Options::MouseNextTab:
|
||||
if (tabGroup())
|
||||
tabGroup()->activateNext();
|
||||
break;
|
||||
case Options::MouseClose:
|
||||
closeWindow();
|
||||
break;
|
||||
case Options::MouseDragTab:
|
||||
case Options::MouseNothing:
|
||||
replay = true;
|
||||
break;
|
||||
default:
|
||||
return AbstractClient::performMouseCommand(command, globalPos);
|
||||
}
|
||||
return replay;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue