text: Rename and extend text_model key event

Rename the key event in text_model to keysym and add serial, time and
modifiers arguments. Add a modifiers_map event to transfer an array of
0-terminated modifier names, so that a mapping of modifiers to the
modifier bit mask is possible.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent 674fd1d625
commit d9be93b964
  1. 17
      clients/editor.c
  2. 40
      clients/keyboard.c
  3. 17
      protocol/input-method.xml
  4. 22
      protocol/text.xml
  5. 25
      src/text-backend.c

@ -361,10 +361,20 @@ text_model_preedit_styling(void *data,
} }
static void static void
text_model_key(void *data, text_model_modifiers_map(void *data,
struct text_model *text_model, struct text_model *text_model,
struct wl_array *map)
{
}
static void
text_model_keysym(void *data,
struct text_model *text_model,
uint32_t serial,
uint32_t time,
uint32_t key, uint32_t key,
uint32_t state) uint32_t state,
uint32_t modifiers)
{ {
struct text_entry *entry = data; struct text_entry *entry = data;
const char *state_label; const char *state_label;
@ -454,7 +464,8 @@ static const struct text_model_listener text_model_listener = {
text_model_preedit_string, text_model_preedit_string,
text_model_delete_surrounding_text, text_model_delete_surrounding_text,
text_model_preedit_styling, text_model_preedit_styling,
text_model_key, text_model_modifiers_map,
text_model_keysym,
text_model_selection_replacement, text_model_selection_replacement,
text_model_direction, text_model_direction,
text_model_locale, text_model_locale,

@ -234,7 +234,7 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
} }
static void static void
keyboard_handle_key(struct keyboard *keyboard, const struct key *key) keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *key)
{ {
const char *label = keyboard->state == keyboardstate_default ? key->label : key->alt; const char *label = keyboard->state == keyboardstate_default ? key->label : key->alt;
@ -259,8 +259,10 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
break; break;
case keytype_enter: case keytype_enter:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_KP_Enter, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_KP_Enter, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
case keytype_space: case keytype_space:
keyboard->keyboard->preedit_string = strcat(keyboard->keyboard->preedit_string, keyboard->keyboard->preedit_string = strcat(keyboard->keyboard->preedit_string,
@ -277,28 +279,38 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
break; break;
case keytype_tab: case keytype_tab:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
case keytype_arrow_up: case keytype_arrow_up:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
case keytype_arrow_left: case keytype_arrow_left:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
case keytype_arrow_right: case keytype_arrow_right:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
case keytype_arrow_down: case keytype_arrow_down:
virtual_keyboard_commit_preedit(keyboard->keyboard); virtual_keyboard_commit_preedit(keyboard->keyboard);
input_method_context_key(keyboard->keyboard->context, input_method_context_keysym(keyboard->keyboard->context,
XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED); display_get_serial(keyboard->keyboard->display),
time,
XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break; break;
} }
} }
@ -330,7 +342,7 @@ button_handler(struct widget *widget,
for (i = 0; i < sizeof(keys) / sizeof(*keys); ++i) { for (i = 0; i < sizeof(keys) / sizeof(*keys); ++i) {
col -= keys[i].width; col -= keys[i].width;
if (col < 0) { if (col < 0) {
keyboard_handle_key(keyboard, &keys[i]); keyboard_handle_key(keyboard, time, &keys[i]);
break; break;
} }
} }

@ -53,9 +53,22 @@
<arg name="index" type="int"/> <arg name="index" type="int"/>
<arg name="length" type="uint"/> <arg name="length" type="uint"/>
</request> </request>
<request name="key"> <request name="modifiers_map">
<arg name="key" type="uint"/> <arg name="map" type="array"/>
</request>
<request name="keysym">
<description summary="keysym">
Notify when a key event was sent. Key events should not be used
for normal text input operations, which should be done with
commit_string, delete_surrounfing_text, etc. The key event follows
the wl_keyboard key event convention. State is a XKB keysym, state a
wl_keyboard key_state.
</description>
<arg name="serial" type="uint"/>
<arg name="time" type="uint"/>
<arg name="sym" type="uint"/>
<arg name="state" type="uint"/> <arg name="state" type="uint"/>
<arg name="modifiers" type="uint"/>
</request> </request>
<event name="surrounding_text"> <event name="surrounding_text">
<description summary="surrounding text event"> <description summary="surrounding text event">

@ -113,16 +113,28 @@
<arg name="length" type="uint"/> <arg name="length" type="uint"/>
</event> </event>
<event name="preedit_styling"/> <event name="preedit_styling"/>
<event name="key"> <event name="modifiers_map">
<description summary="key"> <description summary="modifiers map">
Transfer an array of 0-terminated modifiers names. The position in
the array is the index of the modifier as used in the modifiers
bitmask in the keysym event.
</description>
<arg name="map" type="array"/>
</event>
<event name="keysym">
<description summary="keysym">
Notify when a key event was sent. Key events should not be used Notify when a key event was sent. Key events should not be used
for normal text input operations, which should be done with for normal text input operations, which should be done with
commit_string, delete_surrounfing_text, etc. The key event follows commit_string, delete_surrounfing_text, etc. The key event follows
the wl_keyboard key event convention. Key is a XKB keycode, state a the wl_keyboard key event convention. State is a XKB keysym, state a
wl_keyboard key_state. wl_keyboard key_state. Modifiers are a mask for effective modifiers
(where the modfier indices are set by the modifiers_map event)
</description> </description>
<arg name="key" type="uint"/> <arg name="serial" type="uint"/>
<arg name="time" type="uint"/>
<arg name="sym" type="uint"/>
<arg name="state" type="uint"/> <arg name="state" type="uint"/>
<arg name="modifiers" type="uint"/>
</event> </event>
<event name="selection_replacement"/> <event name="selection_replacement"/>
<event name="direction"/> <event name="direction"/>

@ -350,14 +350,28 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
} }
static void static void
input_method_context_key(struct wl_client *client, input_method_context_modifiers_map(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
uint32_t key, struct wl_array *map)
uint32_t state)
{ {
struct input_method_context *context = resource->data; struct input_method_context *context = resource->data;
text_model_send_key(&context->model->resource, key, state); text_model_send_modifiers_map(&context->model->resource, map);
}
static void
input_method_context_keysym(struct wl_client *client,
struct wl_resource *resource,
uint32_t serial,
uint32_t time,
uint32_t sym,
uint32_t state,
uint32_t modifiers)
{
struct input_method_context *context = resource->data;
text_model_send_keysym(&context->model->resource, serial, time,
sym, state, modifiers);
} }
static const struct input_method_context_interface input_method_context_implementation = { static const struct input_method_context_interface input_method_context_implementation = {
@ -365,7 +379,8 @@ static const struct input_method_context_interface input_method_context_implemen
input_method_context_commit_string, input_method_context_commit_string,
input_method_context_preedit_string, input_method_context_preedit_string,
input_method_context_delete_surrounding_text, input_method_context_delete_surrounding_text,
input_method_context_key input_method_context_modifiers_map,
input_method_context_keysym
}; };
static void static void

Loading…
Cancel
Save