Forward x11 raw pointer buttons to PointerInputRedirection

Summary:
The raw pointer button events intercepted in the XInput2 input filter
get sent through the Platform to the PointerInputRedirection. This
makes the PointerInputRedirection track the pointer button state and
emit the signals for button changed and axis changed.

These signals are used by the modifier-only shortcut detection to
determine whether the shortcut should trigger.

On X11 the "normal" input handling doesn't use the InputRedirection
and the emitted signals are not consumed by anything else. As
PointerInputRedirection is not inited the events are not forwarded
to the input filter, thus won't be processed by other parts and
won't interfere with the normal event processing on X11.

Given that it also doesn't matter that the input filter does not
apply the left-handed setting. The internal tracking will have a
wrong mouse button, but nothing is going to do decisions based on
the value of the pressed mouse button. For the moment all we are
interested in is that a button is pressed.

Test Plan:
Pressed meta, clicked, scrolled, released meta: launcher
did not open. Pressed meta, released meta: launcher opened

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2506

BUG: 367730
master
Martin Gräßlin 8 years ago
parent b78848ef36
commit 9c5f972c6a

@ -18,7 +18,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "xinputintegration.h"
#include "main.h"
#include "logging.h"
#include "platform.h"
#include "x11cursor.h"
#include "keyboard_input.h"
@ -28,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/extensions/XInput2.h>
#include <X11/extensions/XI2proto.h>
#include <linux/input.h>
namespace KWin
{
@ -52,6 +56,60 @@ public:
m_xkb->updateKey(reinterpret_cast<xXIRawEvent*>(event)->detail - 8, InputRedirection::KeyboardKeyReleased);
}
break;
case XI_RawButtonPress:
if (m_xkb) {
auto e = reinterpret_cast<xXIRawEvent*>(event);
switch (e->detail) {
// TODO: this currently ignores left handed settings, for current usage not needed
// if we want to use also for global mouse shortcuts, this needs to reflect state correctly
case XCB_BUTTON_INDEX_1:
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, e->time);
break;
case XCB_BUTTON_INDEX_2:
kwinApp()->platform()->pointerButtonPressed(BTN_MIDDLE, e->time);
break;
case XCB_BUTTON_INDEX_3:
kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, e->time);
break;
case XCB_BUTTON_INDEX_4:
case XCB_BUTTON_INDEX_5:
// vertical axis, ignore on press
break;
// TODO: further buttons, horizontal scrolling?
}
}
if (m_x11Cursor) {
m_x11Cursor->schedulePoll();
}
break;
case XI_RawButtonRelease:
if (m_xkb) {
auto e = reinterpret_cast<xXIRawEvent*>(event);
switch (e->detail) {
// TODO: this currently ignores left handed settings, for current usage not needed
// if we want to use also for global mouse shortcuts, this needs to reflect state correctly
case XCB_BUTTON_INDEX_1:
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, e->time);
break;
case XCB_BUTTON_INDEX_2:
kwinApp()->platform()->pointerButtonReleased(BTN_MIDDLE, e->time);
break;
case XCB_BUTTON_INDEX_3:
kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, e->time);
break;
case XCB_BUTTON_INDEX_4:
kwinApp()->platform()->pointerAxisVertical(120, e->time);
break;
case XCB_BUTTON_INDEX_5:
kwinApp()->platform()->pointerAxisVertical(-120, e->time);
break;
// TODO: further buttons, horizontal scrolling?
}
}
if (m_x11Cursor) {
m_x11Cursor->schedulePoll();
}
break;
default:
if (m_x11Cursor) {
m_x11Cursor->schedulePoll();

@ -179,10 +179,11 @@ void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time, L
void PointerInputRedirection::processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device)
{
updateButton(button, state);
if (!m_inited) {
return;
}
updateButton(button, state);
QEvent::Type type;
switch (state) {
@ -210,15 +211,16 @@ void PointerInputRedirection::processButton(uint32_t button, InputRedirection::P
void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time, LibInput::Device *device)
{
if (!m_inited) {
return;
}
if (delta == 0) {
return;
}
emit m_input->pointerAxisChanged(axis, delta);
if (!m_inited) {
return;
}
WheelEvent wheelEvent(m_pos, delta,
(axis == InputRedirection::PointerAxisHorizontal) ? Qt::Horizontal : Qt::Vertical,
m_qtButtons, m_input->keyboardModifiers(), time, device);

Loading…
Cancel
Save