mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-23 19:12:14 +03:00
checkpoint. fixing up handling of half-duplex num-lock.
This commit is contained in:
parent
8de2696369
commit
cd3e49a9a9
@ -159,7 +159,9 @@ void CXWindowsSecondaryScreen::open(CClient* client)
|
|||||||
|
|
||||||
// check for peculiarities
|
// check for peculiarities
|
||||||
// FIXME -- may have to get these from some database
|
// FIXME -- may have to get these from some database
|
||||||
|
m_numLockHalfDuplex = false;
|
||||||
m_capsLockHalfDuplex = false;
|
m_capsLockHalfDuplex = false;
|
||||||
|
// m_numLockHalfDuplex = true;
|
||||||
// m_capsLockHalfDuplex = true;
|
// m_capsLockHalfDuplex = true;
|
||||||
|
|
||||||
// assume primary has all clipboards
|
// assume primary has all clipboards
|
||||||
@ -421,7 +423,8 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey(
|
|||||||
// that cannot be accomodated.
|
// that cannot be accomodated.
|
||||||
|
|
||||||
// note if the key is the caps lock and it's "half-duplex"
|
// note if the key is the caps lock and it's "half-duplex"
|
||||||
const bool isHalfDuplex = (id == XK_Caps_Lock && m_capsLockHalfDuplex);
|
const bool isHalfDuplex = ((id == XK_Caps_Lock && m_capsLockHalfDuplex) ||
|
||||||
|
(id == XK_Num_Lock && m_numLockHalfDuplex));
|
||||||
|
|
||||||
// ignore releases and repeats for half-duplex keys
|
// ignore releases and repeats for half-duplex keys
|
||||||
if (isHalfDuplex && action != kPress) {
|
if (isHalfDuplex && action != kPress) {
|
||||||
@ -479,15 +482,16 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey(
|
|||||||
keys.push_back(keystroke);
|
keys.push_back(keystroke);
|
||||||
if ((bit & m_toggleModifierMask) != 0) {
|
if ((bit & m_toggleModifierMask) != 0) {
|
||||||
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
||||||
if (bit != m_capsLockMask || !m_capsLockHalfDuplex) {
|
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
||||||
|
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
||||||
keystroke.m_press = False;
|
keystroke.m_press = False;
|
||||||
keys.push_back(keystroke);
|
|
||||||
undo.push_back(keystroke);
|
|
||||||
keystroke.m_press = True;
|
|
||||||
undo.push_back(keystroke);
|
undo.push_back(keystroke);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
keystroke.m_press = False;
|
keystroke.m_press = False;
|
||||||
|
keys.push_back(keystroke);
|
||||||
|
undo.push_back(keystroke);
|
||||||
|
keystroke.m_press = True;
|
||||||
undo.push_back(keystroke);
|
undo.push_back(keystroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,18 +512,19 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey(
|
|||||||
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
log((CLOG_DEBUG2 "modifier 0x%04x is a toggle", bit));
|
||||||
keystroke.m_keycode = modifierKeys[0];
|
keystroke.m_keycode = modifierKeys[0];
|
||||||
keystroke.m_repeat = False;
|
keystroke.m_repeat = False;
|
||||||
if (bit != m_capsLockMask || !m_capsLockHalfDuplex) {
|
if ((bit == m_capsLockMask && m_capsLockHalfDuplex) ||
|
||||||
keystroke.m_press = True;
|
(bit == m_numLockMask && m_numLockHalfDuplex)) {
|
||||||
keys.push_back(keystroke);
|
|
||||||
keystroke.m_press = False;
|
keystroke.m_press = False;
|
||||||
keys.push_back(keystroke);
|
keys.push_back(keystroke);
|
||||||
undo.push_back(keystroke);
|
|
||||||
keystroke.m_press = True;
|
keystroke.m_press = True;
|
||||||
undo.push_back(keystroke);
|
undo.push_back(keystroke);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
keystroke.m_press = True;
|
||||||
|
keys.push_back(keystroke);
|
||||||
keystroke.m_press = False;
|
keystroke.m_press = False;
|
||||||
keys.push_back(keystroke);
|
keys.push_back(keystroke);
|
||||||
|
undo.push_back(keystroke);
|
||||||
keystroke.m_press = True;
|
keystroke.m_press = True;
|
||||||
undo.push_back(keystroke);
|
undo.push_back(keystroke);
|
||||||
}
|
}
|
||||||
@ -595,7 +600,7 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey(
|
|||||||
// bit on press and clear the bit on release. if half-duplex
|
// bit on press and clear the bit on release. if half-duplex
|
||||||
// then toggle each time we get here.
|
// then toggle each time we get here.
|
||||||
if ((modifierBit & m_toggleModifierMask) != 0) {
|
if ((modifierBit & m_toggleModifierMask) != 0) {
|
||||||
if (action == kRelease) {
|
if (isHalfDuplex || action == kRelease) {
|
||||||
mask ^= modifierBit;
|
mask ^= modifierBit;
|
||||||
}
|
}
|
||||||
/* FIXME -- supposed to toggle on on press and off on release but does it?
|
/* FIXME -- supposed to toggle on on press and off on release but does it?
|
||||||
@ -964,7 +969,8 @@ void CXWindowsSecondaryScreen::toggleKey(
|
|||||||
KeyCode keycode = index->second.m_keycode;
|
KeyCode keycode = index->second.m_keycode;
|
||||||
|
|
||||||
// toggle the key
|
// toggle the key
|
||||||
if (keysym == XK_Caps_Lock && m_capsLockHalfDuplex) {
|
if ((keysym == XK_Caps_Lock && m_capsLockHalfDuplex) ||
|
||||||
|
(keysym == XK_Num_Lock && m_numLockHalfDuplex)) {
|
||||||
// "half-duplex" toggle
|
// "half-duplex" toggle
|
||||||
XTestFakeKeyEvent(display, keycode, (m_mask & mask) == 0, CurrentTime);
|
XTestFakeKeyEvent(display, keycode, (m_mask & mask) == 0, CurrentTime);
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,9 @@ private:
|
|||||||
CClient* m_client;
|
CClient* m_client;
|
||||||
Window m_window;
|
Window m_window;
|
||||||
|
|
||||||
// note if caps lock key toggles on up/down (false) or on
|
// note toggle keys that toggles on up/down (false) or on
|
||||||
// transition (true)
|
// transition (true)
|
||||||
|
bool m_numLockHalfDuplex;
|
||||||
bool m_capsLockHalfDuplex;
|
bool m_capsLockHalfDuplex;
|
||||||
|
|
||||||
// set entries indicate keys that are pressed. indexed by keycode.
|
// set entries indicate keys that are pressed. indexed by keycode.
|
||||||
|
Loading…
Reference in New Issue
Block a user