Move logic to handle mouse buttons on windows to AbstractClient
Part of the logic is split out in a generic way so that the code can be shared with activating of Wayland clients.
This commit is contained in:
parent
8d407157c4
commit
c3b7ed907b
3 changed files with 56 additions and 23 deletions
|
@ -634,6 +634,47 @@ void AbstractClient::destroyWindowManagementInterface()
|
|||
#endif
|
||||
}
|
||||
|
||||
Options::MouseCommand AbstractClient::getMouseCommand(Qt::MouseButton button, bool *handled) const
|
||||
{
|
||||
*handled = false;
|
||||
if (button == Qt::NoButton) {
|
||||
return Options::MouseNothing;
|
||||
}
|
||||
if (isActive()) {
|
||||
if (options->isClickRaise()) {
|
||||
*handled = true;
|
||||
return Options::MouseActivateRaiseAndPassClick;
|
||||
}
|
||||
} else {
|
||||
*handled = true;
|
||||
switch (button) {
|
||||
case Qt::LeftButton:
|
||||
return options->commandWindow1();
|
||||
case Qt::MiddleButton:
|
||||
return options->commandWindow2();
|
||||
case Qt::RightButton:
|
||||
return options->commandWindow3();
|
||||
default:
|
||||
// all other buttons pass Activate & Pass Client
|
||||
return Options::MouseActivateAndPassClick;
|
||||
}
|
||||
}
|
||||
return Options::MouseNothing;
|
||||
}
|
||||
|
||||
Options::MouseCommand AbstractClient::getWheelCommand(Qt::Orientation orientation, bool *handled) const
|
||||
{
|
||||
*handled = false;
|
||||
if (orientation != Qt::Vertical) {
|
||||
return Options::MouseNothing;
|
||||
}
|
||||
if (!isActive()) {
|
||||
*handled = true;
|
||||
return options->commandWindowWheel();
|
||||
}
|
||||
return Options::MouseNothing;
|
||||
}
|
||||
|
||||
bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint &globalPos)
|
||||
{
|
||||
bool replay = false;
|
||||
|
|
|
@ -357,6 +357,16 @@ public:
|
|||
|
||||
virtual bool hasStrut() const;
|
||||
|
||||
/**
|
||||
* Determines the mouse command for the given @p button in the current state.
|
||||
*
|
||||
* The @p handled argument specifies whether the button was handled or not.
|
||||
* This value should be used to determine whether the mouse button should be
|
||||
* passed to the AbstractClient or being filtered out.
|
||||
**/
|
||||
Options::MouseCommand getMouseCommand(Qt::MouseButton button, bool *handled) const;
|
||||
Options::MouseCommand getWheelCommand(Qt::Orientation orientation, bool *handled) const;
|
||||
|
||||
// TODO: remove boolean trap
|
||||
static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, bool active_hack = false);
|
||||
|
||||
|
|
28
events.cpp
28
events.cpp
|
@ -1135,31 +1135,13 @@ bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
// inactive inner window
|
||||
if (!isActive() && w == wrapperId() && button < 6) {
|
||||
was_action = true;
|
||||
switch(button) {
|
||||
case XCB_BUTTON_INDEX_1:
|
||||
com = options->commandWindow1();
|
||||
break;
|
||||
case XCB_BUTTON_INDEX_2:
|
||||
com = options->commandWindow2();
|
||||
break;
|
||||
case XCB_BUTTON_INDEX_3:
|
||||
com = options->commandWindow3();
|
||||
break;
|
||||
case XCB_BUTTON_INDEX_4:
|
||||
case XCB_BUTTON_INDEX_5:
|
||||
com = options->commandWindowWheel();
|
||||
break;
|
||||
if (w == wrapperId()) {
|
||||
if (button < 4) {
|
||||
com = getMouseCommand(x11ToQtMouseButton(button), &was_action);
|
||||
} else if (button < 6) {
|
||||
com = getWheelCommand(Qt::Vertical, &was_action);
|
||||
}
|
||||
}
|
||||
// active inner window
|
||||
if (isActive() && w == wrapperId()
|
||||
&& options->isClickRaise() && button < 4) { // exclude wheel
|
||||
com = Options::MouseActivateRaiseAndPassClick;
|
||||
was_action = true;
|
||||
}
|
||||
}
|
||||
if (was_action) {
|
||||
bool replay = performMouseCommand(com, QPoint(x_root, y_root));
|
||||
|
|
Loading…
Reference in a new issue