Make process_text() optional
Not all key processors support text injection (HID keyboard does not support it). Instead of providing a dummy op function, set it to NULL and check on the caller side before calling it.
This commit is contained in:
parent
63e29b1782
commit
bc674721dc
3 changed files with 17 additions and 11 deletions
|
@ -387,15 +387,6 @@ sc_key_processor_process_key(struct sc_key_processor *kp,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sc_key_processor_process_text(struct sc_key_processor *kp,
|
||||
const struct sc_text_event *event) {
|
||||
(void) kp;
|
||||
(void) event;
|
||||
|
||||
// Never forward text input via HID (all the keys are injected separately)
|
||||
}
|
||||
|
||||
bool
|
||||
sc_hid_keyboard_init(struct sc_hid_keyboard *kb, struct sc_aoa *aoa) {
|
||||
kb->aoa = aoa;
|
||||
|
@ -415,7 +406,9 @@ sc_hid_keyboard_init(struct sc_hid_keyboard *kb, struct sc_aoa *aoa) {
|
|||
|
||||
static const struct sc_key_processor_ops ops = {
|
||||
.process_key = sc_key_processor_process_key,
|
||||
.process_text = sc_key_processor_process_text,
|
||||
// Never forward text input via HID (all the keys are injected
|
||||
// separately)
|
||||
.process_text = NULL,
|
||||
};
|
||||
|
||||
// Clipboard synchronization is requested over the control socket, while HID
|
||||
|
|
|
@ -384,6 +384,11 @@ rotate_client_right(struct screen *screen) {
|
|||
static void
|
||||
input_manager_process_text_input(struct input_manager *im,
|
||||
const SDL_TextInputEvent *event) {
|
||||
if (!im->kp->ops->process_text) {
|
||||
// The key processor does not support text input
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_shortcut_mod(im, SDL_GetModState())) {
|
||||
// A shortcut must never generate text events
|
||||
return;
|
||||
|
@ -620,6 +625,7 @@ input_manager_process_key(struct input_manager *im,
|
|||
.mods_state = sc_mods_state_from_sdl(event->keysym.mod),
|
||||
};
|
||||
|
||||
assert(im->kp->ops->process_key);
|
||||
im->kp->ops->process_key(im->kp, &evt, ack_to_wait);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,17 +29,24 @@ struct sc_key_processor {
|
|||
struct sc_key_processor_ops {
|
||||
|
||||
/**
|
||||
* Process the keyboard event
|
||||
* Process a keyboard event
|
||||
*
|
||||
* The `sequence` number (if different from `SC_SEQUENCE_INVALID`) indicates
|
||||
* the acknowledgement number to wait for before injecting this event.
|
||||
* This allows to ensure that the device clipboard is set before injecting
|
||||
* Ctrl+v on the device.
|
||||
*
|
||||
* This function is mandatory.
|
||||
*/
|
||||
void
|
||||
(*process_key)(struct sc_key_processor *kp,
|
||||
const struct sc_key_event *event, uint64_t ack_to_wait);
|
||||
|
||||
/**
|
||||
* Process an input text
|
||||
*
|
||||
* This function is optional.
|
||||
*/
|
||||
void
|
||||
(*process_text)(struct sc_key_processor *kp,
|
||||
const struct sc_text_event *event);
|
||||
|
|
Loading…
Reference in a new issue