[PATCH v2 2/9] text: Rename and extend text_model key event
Jan Arne Petersen
jpetersen at openismus.com
Thu Nov 15 02:29:46 PST 2012
From: Jan Arne Petersen <jpetersen at openismus.com>
Rename the key event in text_model to keysym and add serial, time and
modifiers arguments.
Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
clients/editor.c | 13 ++++++++-----
clients/keyboard.c | 40 ++++++++++++++++++++++++++--------------
protocol/input-method.xml | 14 ++++++++++++--
protocol/text.xml | 14 +++++++++-----
src/text-backend.c | 16 ++++++++++------
5 files changed, 65 insertions(+), 32 deletions(-)
diff --git a/clients/editor.c b/clients/editor.c
index 348041c..0a52faf 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -361,10 +361,13 @@ text_model_preedit_styling(void *data,
}
static void
-text_model_key(void *data,
- struct text_model *text_model,
- uint32_t key,
- uint32_t state)
+text_model_keysym(void *data,
+ struct text_model *text_model,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t key,
+ uint32_t state,
+ uint32_t modifiers)
{
struct text_entry *entry = data;
const char *state_label;
@@ -454,7 +457,7 @@ static const struct text_model_listener text_model_listener = {
text_model_preedit_string,
text_model_delete_surrounding_text,
text_model_preedit_styling,
- text_model_key,
+ text_model_keysym,
text_model_selection_replacement,
text_model_direction,
text_model_locale,
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 1b2a9ba..d1e5dbf 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -234,7 +234,7 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
}
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;
@@ -259,8 +259,10 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
break;
case keytype_enter:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_KP_Enter, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_KP_Enter, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
case keytype_space:
keyboard->keyboard->preedit_string = strcat(keyboard->keyboard->preedit_string,
@@ -277,28 +279,38 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key)
break;
case keytype_tab:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
case keytype_arrow_up:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
case keytype_arrow_left:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
case keytype_arrow_right:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
case keytype_arrow_down:
virtual_keyboard_commit_preedit(keyboard->keyboard);
- input_method_context_key(keyboard->keyboard->context,
- XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED);
+ input_method_context_keysym(keyboard->keyboard->context,
+ display_get_serial(keyboard->keyboard->display),
+ time,
+ XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED, 0);
break;
}
}
@@ -330,7 +342,7 @@ button_handler(struct widget *widget,
for (i = 0; i < sizeof(keys) / sizeof(*keys); ++i) {
col -= keys[i].width;
if (col < 0) {
- keyboard_handle_key(keyboard, &keys[i]);
+ keyboard_handle_key(keyboard, time, &keys[i]);
break;
}
}
diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index 09ab10c..61b70c0 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -53,9 +53,19 @@
<arg name="index" type="int"/>
<arg name="length" type="uint"/>
</request>
- <request name="key">
- <arg name="key" type="uint"/>
+ <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="modifiers" type="uint"/>
</request>
<event name="surrounding_text">
<description summary="surrounding text event">
diff --git a/protocol/text.xml b/protocol/text.xml
index 1b3a4b5..c98f702 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -113,16 +113,20 @@
<arg name="length" type="uint"/>
</event>
<event name="preedit_styling"/>
- <event name="key">
- <description summary="key">
+ <event 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. Key is a XKB keycode, state a
- wl_keyboard key_state.
+ the wl_keyboard key event convention. State is a XKB keysym, state a
+ wl_keyboard key_state. Modifiers are a mask for effective modifiers
+ (where the modfier indices are from the seats keymap)
</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="modifiers" type="uint"/>
</event>
<event name="selection_replacement"/>
<event name="direction"/>
diff --git a/src/text-backend.c b/src/text-backend.c
index ae1f16c..f37a9cf 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -350,14 +350,18 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
}
static void
-input_method_context_key(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t key,
- uint32_t state)
+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_key(&context->model->resource, key, state);
+ text_model_send_keysym(&context->model->resource, serial, time,
+ sym, state, modifiers);
}
static const struct input_method_context_interface input_method_context_implementation = {
@@ -365,7 +369,7 @@ static const struct input_method_context_interface input_method_context_implemen
input_method_context_commit_string,
input_method_context_preedit_string,
input_method_context_delete_surrounding_text,
- input_method_context_key
+ input_method_context_keysym
};
static void
--
1.7.11.7
More information about the wayland-devel
mailing list