InputRedirection emits a signal when the modifiers change
Used by Cursor to properly emit the mouseChanged signal which for historic reasons includes the keyboard modifiers. Again some fiddling around with the autotests and kcmrules needed to make it compile. This needs improvement!
This commit is contained in:
parent
b57885a1bf
commit
b274fb9297
7 changed files with 35 additions and 13 deletions
|
@ -44,7 +44,6 @@ set( testClientMachine_SRCS
|
|||
../client_machine.cpp
|
||||
../utils.cpp
|
||||
../atoms.cpp # needed by utils.cpp
|
||||
../cursor.cpp # needed by utils.cpp
|
||||
)
|
||||
add_executable( testClientMachine ${testClientMachine_SRCS} )
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "testutils.h"
|
||||
// KWin
|
||||
#include "../atoms.h" // needed for utils to compile
|
||||
#include "../input.h" // needed for cursor to compile
|
||||
#include "../main.h" // needed for cursor to compile
|
||||
#include "../cursor.h" // needed for utils to compile
|
||||
#include "../client_machine.h"
|
||||
#include "../utils.h"
|
||||
#include "../xcbutils.h"
|
||||
|
@ -40,15 +39,10 @@ namespace KWin {
|
|||
// just to make the linker of utils happy
|
||||
Atoms* atoms;
|
||||
|
||||
Application::OperationMode Application::operationMode() const
|
||||
Cursor *Cursor::s_self = nullptr;
|
||||
QPoint Cursor::pos()
|
||||
{
|
||||
return Application::OperationModeX11;
|
||||
}
|
||||
|
||||
InputRedirection *InputRedirection::s_self = NULL;
|
||||
Qt::MouseButtons InputRedirection::qtButtonStates() const
|
||||
{
|
||||
return Qt::NoButton;
|
||||
return QPoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
13
cursor.cpp
13
cursor.cpp
|
@ -361,6 +361,10 @@ InputRedirectionCursor::InputRedirectionCursor(QObject *parent)
|
|||
connect(input(), SIGNAL(globalPointerChanged(QPointF)), SLOT(slotPosChanged(QPointF)));
|
||||
connect(input(), SIGNAL(pointerButtonStateChanged(uint32_t,InputRedirection::PointerButtonState)),
|
||||
SLOT(slotPointerButtonChanged()));
|
||||
#ifndef KCMRULES
|
||||
connect(input(), &InputRedirection::keyboardModifiersChanged,
|
||||
this, &InputRedirectionCursor::slotModifiersChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
InputRedirectionCursor::~InputRedirectionCursor()
|
||||
|
@ -377,8 +381,13 @@ void InputRedirectionCursor::slotPosChanged(const QPointF &pos)
|
|||
{
|
||||
const QPoint oldPos = currentPos();
|
||||
updatePos(pos.toPoint());
|
||||
// TODO: add keyboard modifiers
|
||||
emit mouseChanged(pos.toPoint(), oldPos, m_currentButtons, m_oldButtons, Qt::NoModifier, Qt::NoModifier);
|
||||
emit mouseChanged(pos.toPoint(), oldPos, m_currentButtons, m_oldButtons,
|
||||
input()->keyboardModifiers(), input()->keyboardModifiers());
|
||||
}
|
||||
|
||||
void InputRedirectionCursor::slotModifiersChanged(Qt::KeyboardModifiers mods, Qt::KeyboardModifiers oldMods)
|
||||
{
|
||||
emit mouseChanged(currentPos(), currentPos(), m_currentButtons, m_currentButtons, mods, oldMods);
|
||||
}
|
||||
|
||||
void InputRedirectionCursor::slotPointerButtonChanged()
|
||||
|
|
1
cursor.h
1
cursor.h
|
@ -252,6 +252,7 @@ protected:
|
|||
private Q_SLOTS:
|
||||
void slotPosChanged(const QPointF &pos);
|
||||
void slotPointerButtonChanged();
|
||||
void slotModifiersChanged(Qt::KeyboardModifiers mods, Qt::KeyboardModifiers oldMods);
|
||||
private:
|
||||
explicit InputRedirectionCursor(QObject *parent);
|
||||
Qt::MouseButtons m_oldButtons;
|
||||
|
|
|
@ -295,7 +295,11 @@ void InputRedirection::processKeyboardModifiers(uint32_t modsDepressed, uint32_t
|
|||
{
|
||||
// TODO: send to proper Client and also send when active Client changes
|
||||
#if HAVE_XKB
|
||||
Qt::KeyboardModifiers oldMods = keyboardModifiers();
|
||||
m_xkb->updateModifiers(modsDepressed, modsLatched, modsLocked, group);
|
||||
if (oldMods != keyboardModifiers()) {
|
||||
emit keyboardModifiersChanged(keyboardModifiers(), oldMods);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
10
input.h
10
input.h
|
@ -135,6 +135,16 @@ Q_SIGNALS:
|
|||
* @param delta The delta of the event.
|
||||
*/
|
||||
void pointerAxisChanged(InputRedirection::PointerAxis axis, qreal delta);
|
||||
/**
|
||||
* @brief Emitted when the modifiers changes.
|
||||
*
|
||||
* Only emitted for the mask which is provided by Qt::KeyboardModifiers, if other modifiers
|
||||
* change signal is not emitted
|
||||
*
|
||||
* @param newMods The new modifiers state
|
||||
* @param oldMods The previous modifiers state
|
||||
*/
|
||||
void keyboardModifiersChanged(Qt::KeyboardModifiers newMods, Qt::KeyboardModifiers oldMods);
|
||||
|
||||
private:
|
||||
static QEvent::Type buttonStateToEvent(PointerButtonState state);
|
||||
|
|
|
@ -33,3 +33,8 @@ Qt::MouseButtons KWin::InputRedirection::qtButtonStates() const
|
|||
{
|
||||
return Qt::NoButton;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers KWin::InputRedirection::keyboardModifiers() const
|
||||
{
|
||||
return Qt::NoModifier;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue