text: Add support for control keys to the protocol
Add key event to the text_model interface and a key request to the input_method_context interface. Implement it in the example editor client and the example keyboard. Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
e202bae9d3
commit
ce8a4433f5
+24
-1
@@ -284,8 +284,31 @@ text_model_preedit_styling(void *data,
|
||||
|
||||
static void
|
||||
text_model_key(void *data,
|
||||
struct text_model *text_model)
|
||||
struct text_model *text_model,
|
||||
uint32_t key,
|
||||
uint32_t state)
|
||||
{
|
||||
const char *state_label;
|
||||
const char *key_label;
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
state_label = "pressed";
|
||||
} else {
|
||||
state_label = "released";
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case XKB_KEY_Tab:
|
||||
key_label = "Tab";
|
||||
break;
|
||||
case XKB_KEY_KP_Enter:
|
||||
key_label = "Enter";
|
||||
break;
|
||||
default:
|
||||
key_label = "Unknown";
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s key was %s.\n", key_label, state_label);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -228,6 +228,8 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
|
||||
}
|
||||
break;
|
||||
case keytype_enter:
|
||||
input_method_context_key(keyboard->keyboard->context,
|
||||
XKB_KEY_KP_Enter, WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
break;
|
||||
case keytype_space:
|
||||
keyboard->keyboard->preedit_string = strcat(keyboard->keyboard->preedit_string,
|
||||
@@ -250,6 +252,8 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
|
||||
case keytype_symbols:
|
||||
break;
|
||||
case keytype_tab:
|
||||
input_method_context_key(keyboard->keyboard->context,
|
||||
XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user