Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib/deskflow/IKeyState.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ class IKeyState : public IInterface
*/
virtual void fakeAllKeysUp() = 0;

//! Clear stale modifiers
/*!
Clears stuck modifier state in platform-specific keyboard tracking (e.g. XKB).
Default implementation does nothing.
*/
virtual void clearStaleModifiers()
{
// Default implementation does nothing
}

//! Fake ctrl+alt+del
/*!
Synthesize a press of ctrl+alt+del. Return true if processing is
Expand Down
3 changes: 2 additions & 1 deletion src/lib/deskflow/IPlatformScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,13 @@ class IPlatformScreen : public IScreen, public IPrimaryScreen, public ISecondary
virtual KeyModifierMask pollActiveModifiers() const = 0;
virtual SInt32 pollActiveGroup() const = 0;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
virtual void clearStaleModifiers() = 0;

// Drag-and-drop overrides
virtual String &getDraggingFilename() = 0;
virtual void clearDraggingFilename() = 0;
virtual bool isDraggingStarted() = 0;
virtual bool isFakeDraggingStarted() = 0;

virtual void fakeDraggingFiles(DragFileList fileList) = 0;
virtual const String &getDropTarget() const = 0;

Expand Down
1 change: 1 addition & 0 deletions src/lib/deskflow/KeyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ void KeyState::updateKeyState()
}

// get the current modifier state
clearStaleModifiers();
m_mask = pollActiveModifiers();

// set active modifiers
Expand Down
5 changes: 5 additions & 0 deletions src/lib/deskflow/PlatformScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ void PlatformScreen::pollPressedKeys(KeyButtonSet &pressedKeys) const
getKeyState()->pollPressedKeys(pressedKeys);
}

void PlatformScreen::clearStaleModifiers()
{
getKeyState()->clearStaleModifiers();
}

bool PlatformScreen::isDraggingStarted()
{
if (App::instance().argsBase().m_enableDragDrop) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/deskflow/PlatformScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class PlatformScreen : public IPlatformScreen
virtual KeyModifierMask pollActiveModifiers() const;
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const;
virtual void clearStaleModifiers();

virtual void setDraggingStarted(bool started)
{
Expand Down
9 changes: 9 additions & 0 deletions src/lib/platform/EiKeyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,13 @@ void EiKeyState::update_xkb_state(uint32_t keyval, bool is_pressed)
xkb_state_update_key(xkb_state_, keyval, is_pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
}

void EiKeyState::clearStaleModifiers()
{
// Recreate the XKB state to clear stuck modifiers that happen when
// modifier keys are press on client and released on server
if (xkb_state_) {
xkb_state_unref(xkb_state_);
}
xkb_state_ = xkb_state_new(xkb_keymap_);
}
} // namespace deskflow
1 change: 1 addition & 0 deletions src/lib/platform/EiKeyState.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class EiKeyState : public KeyState
void pollPressedKeys(KeyButtonSet &pressedKeys) const override;
KeyID map_key_from_keyval(std::uint32_t keyval) const;
void update_xkb_state(std::uint32_t keyval, bool is_pressed);
void clearStaleModifiers() override;

protected:
// KeyState overrides
Expand Down
Loading