-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change(linux): Implement ordered output without patched ibus #11535
base: master
Are you sure you want to change the base?
Conversation
User Test ResultsTest specification and instructions ERROR: user tests have not yet been defined Test Artifacts |
1d2a12e
to
eb3b6db
Compare
#define KEYMAN_LALT 56 // 0x38 | ||
#define KEYMAN_RCTRL 97 // 0x61 | ||
#define KEYMAN_RALT 100 // 0x64 | ||
#define KEYMAN_F24_KEYCODE_OUTPUT_SENTINEL 194 // 0xC2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In debugging I realized that the key code we used previously was not F24...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be changing the value or changing the define name? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
202 is the X11 keycode for F24 (= kernel keycode + 8)
linux/ibus-keyman/src/engine.c
Outdated
@@ -639,6 +617,7 @@ process_backspace_action(IBusEngine *engine, unsigned int code_points_to_delete) | |||
} else { | |||
g_message("%s: non-compliant app: forwarding %d backspaces", __FUNCTION__, code_points_to_delete); | |||
while (code_points_to_delete > 0) { | |||
// REVIEW: Do we have to go through keyman-system-service for sending the backspace? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it might be better to go through keyman-system-service for the backspace so that they get processed by ibus in the correct order with the F24 keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. If we go through keyman-system-service we simulate a keypress which means it round-trips and comes back to us.
If we directly send it to ibus we use ibus_engine_forward_key_event
which gets processed by the client and doesn't come back to us, resulting in the correct output.
eb3b6db
to
53c3d2b
Compare
53c3d2b
to
25959aa
Compare
order_output(gboolean isKeyUp) { | ||
g_message("%s: Calling order output sentinel on keyman-system-service: isKeyDown=%d", | ||
__FUNCTION__, !isKeyUp); | ||
KeymanSystemServiceClient client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to be expensive to instantiate (and destroy) (twice) on every keystroke? Should we be storing a global instance?
#define KEYMAN_LALT 56 // 0x38 | ||
#define KEYMAN_RCTRL 97 // 0x61 | ||
#define KEYMAN_RALT 100 // 0x64 | ||
#define KEYMAN_F24_KEYCODE_OUTPUT_SENTINEL 194 // 0xC2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be changing the value or changing the define name? 😁
@@ -70,6 +93,7 @@ KeymanSystemService::KeymanSystemService() | |||
int ret; | |||
|
|||
GetKbdDevices(); | |||
CreateOrderOutputDevice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateOrderOutputDevice(); | |
CreateOrderedOutputDevice(); |
and elsewhere
@@ -115,6 +139,12 @@ KeymanSystemService::~KeymanSystemService() | |||
delete device; | |||
} | |||
delete kbd_devices; | |||
kbd_ordered_output = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kbd_ordered_output = nullptr; | |
kbd_devices = nullptr; |
@@ -166,6 +196,16 @@ void KeymanSystemService::GetKbdDevices() { | |||
} | |||
} | |||
|
|||
void KeymanSystemService::CreateOrderOutputDevice() { | |||
if (!kbd_ordered_output) { | |||
kbd_ordered_output = new OrderOutputDevice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kbd_ordered_output = new OrderOutputDevice(); | |
kbd_ordered_output = new OrderedOutputDevice(); |
ditto 😁
@@ -3,18 +3,21 @@ | |||
|
|||
#include <list> | |||
#include <systemd/sd-bus.h> | |||
#include "OrderOutputDevice.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "OrderOutputDevice.h" | |
#include "OrderedOutputDevice.h" |
|
||
using namespace std; | ||
|
||
#define KEYMAN_F24_KEYCODE_OUTPUT_SENTINEL 194 // 0xC2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should be sharing value with ibus-keyman rather than defining in two places
__FUNCTION__, isKeyDown, strerror(-error)); | ||
return false; | ||
} | ||
error = libevdev_uinput_write_event(uinput_dev, EV_SYN, SYN_REPORT, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment on this?
CallOrderedOutputSentinel: | ||
@isKeyDown: Whether or not we're dealing with a keydown or keyup | ||
|
||
Press the orderd output sentinel key to serialize the output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Press the orderd output sentinel key to serialize the output. | |
Press the ordered output sentinel key to serialize the output. |
…ervice This change allows to press F24 as ordered output sentinel from keyman-system-service. This is part of implementing serialized output with keyman-system-service instead of requiring a patched ibus. The problem both approaches try to solve is that with non-compliant apps it is not possible to directly delete characters from the context. Instead we have to emit a backspace key before we can commit the new characters. However, the backspace key press goes through a different code path in ibus and so it can happen that the commit gets processed before the backspace which then deletes from the characters we just added instead of from the old content. The previous implementation solved this by forwarding a F24 ordered output sentinel key to ibus and relying on the patched ibus to send that back to us. When we received the F24 key we committed the characters that we queued when we forwarded the F24 key (implemented in #7079). The new approach implemented in this change instead sends the F24 ordered output sentinel key through keyman-system-service and so follows the regular key processing without requiring a patched ibus to send the key back to us. The rest of the algorithm stays mostly the same: when we receive the F24 key we commit the characters previously queued. The difference to the previous implementation is that we now also queue the backspace keys that we generate. Part-of: #10799
This change implements things on the ibus-keyman side. Fixes: #10799
25959aa
to
436d00a
Compare
This change allows to press F24 as ordered output sentinel from keyman-system-service.
This is part of implementing serialized output with keyman-system-service instead of requiring a patched ibus.
The problem both approaches try to solve is that with non-compliant apps it is not possible to directly delete characters from the context. Instead we have to emit a backspace key before we can commit the new characters. However, the backspace key press goes through a different code path in ibus and so it can happen that the commit gets processed before the backspace which then deletes from the characters we just added instead of from the old content.
The previous implementation solved this by forwarding a F24 ordered output sentinel key to ibus and relying on the patched ibus to send that back to us. When we received the F24 key we committed the characters that we queued when we forwarded the F24 key (implemented in #7079).
The new approach implemented in this change instead sends the F24 ordered output sentinel key through keyman-system-service and so follows the regular key processing without requiring a patched ibus to send the key back to us. The rest of the algorithm stays the same: when we receive the F24 key we commit the characters previously queued.
Closes: #10799