summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorJan Arne Petersen <jpetersen@openismus.com>2013-04-18 16:47:33 +0200
committerKristian Høgsberg <krh@bitplanet.net>2013-05-02 16:41:48 -0400
commit00191c7c4a3bb049db95ca1fe612f0ba993cbaf7 (patch)
tree402342701de907433590dd6c426e84c77f6ec674 /clients
parentb41531a88ea79376560f11e3ec488cfa8b9e3ef3 (diff)
text: Fix serial handling
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
Diffstat (limited to 'clients')
-rw-r--r--clients/editor.c24
-rw-r--r--clients/keyboard.c23
-rw-r--r--clients/weston-simple-im.c28
3 files changed, 34 insertions, 41 deletions
diff --git a/clients/editor.c b/clients/editor.c
index e61eda04..c40815ac 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -63,6 +63,7 @@ struct text_entry {
xkb_mod_mask_t shift_mask;
} keysym;
uint32_t serial;
+ uint32_t reset_serial;
uint32_t content_purpose;
uint32_t click_to_show;
char *preferred_language;
@@ -138,6 +139,12 @@ text_input_commit_string(void *data,
{
struct text_entry *entry = data;
+ if ((entry->serial - serial) > (entry->serial - entry->reset_serial)) {
+ fprintf(stderr, "Ignore commit. Serial: %u, Current: %u, Reset: %u\n",
+ serial, entry->serial, entry->reset_serial);
+ return;
+ }
+
text_entry_reset_preedit(entry);
text_entry_delete_selected_text(entry);
@@ -175,7 +182,6 @@ text_input_preedit_string(void *data,
static void
text_input_delete_surrounding_text(void *data,
struct text_input *text_input,
- uint32_t serial,
int32_t index,
uint32_t length)
{
@@ -207,7 +213,6 @@ text_input_delete_surrounding_text(void *data,
static void
text_input_cursor_position(void *data,
struct text_input *text_input,
- uint32_t serial,
int32_t index,
int32_t anchor)
{
@@ -220,7 +225,6 @@ text_input_cursor_position(void *data,
static void
text_input_preedit_styling(void *data,
struct text_input *text_input,
- uint32_t serial,
uint32_t index,
uint32_t length,
uint32_t style)
@@ -272,7 +276,6 @@ text_input_preedit_styling(void *data,
static void
text_input_preedit_cursor(void *data,
struct text_input *text_input,
- uint32_t serial,
int32_t index)
{
struct text_entry *entry = data;
@@ -374,6 +377,9 @@ text_input_enter(void *data,
entry->active = 1;
+ text_entry_update(entry);
+ entry->reset_serial = entry->serial;
+
widget_schedule_redraw(entry->widget);
}
@@ -552,10 +558,7 @@ text_entry_activate(struct text_entry *entry,
if (!entry->click_to_show)
text_input_show_input_panel(entry->text_input);
- entry->serial++;
-
text_input_activate(entry->text_input,
- entry->serial,
seat,
surface);
}
@@ -653,7 +656,7 @@ text_entry_update(struct text_entry *entry)
text_input_set_cursor_rectangle(entry->text_input, cursor_rectangle.x, cursor_rectangle.y,
cursor_rectangle.width, cursor_rectangle.height);
- text_input_commit_state(entry->text_input);
+ text_input_commit_state(entry->text_input, ++entry->serial);
}
static void
@@ -714,8 +717,9 @@ text_entry_commit_and_reset(struct text_entry *entry)
free(commit);
}
- entry->serial++;
- text_input_reset(entry->text_input, entry->serial);
+ text_input_reset(entry->text_input);
+ text_entry_update(entry);
+ entry->reset_serial = entry->serial;
}
static void
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 17fb6837..9dd210af 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -395,7 +395,6 @@ virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
"",
"");
input_method_context_cursor_position(keyboard->context,
- keyboard->serial,
0, 0);
input_method_context_commit_string(keyboard->context,
keyboard->serial,
@@ -412,14 +411,12 @@ virtual_keyboard_send_preedit(struct virtual_keyboard *keyboard,
if (keyboard->preedit_style)
input_method_context_preedit_styling(keyboard->context,
- keyboard->serial,
0,
strlen(keyboard->preedit_string),
keyboard->preedit_style);
if (cursor > 0)
index = cursor;
input_method_context_preedit_cursor(keyboard->context,
- keyboard->serial,
index);
input_method_context_preedit_string(keyboard->context,
keyboard->serial,
@@ -449,7 +446,6 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time, const struct key *
if (strlen(keyboard->keyboard->preedit_string) == 0) {
input_method_context_delete_surrounding_text(keyboard->keyboard->context,
- keyboard->keyboard->serial,
-1, 1);
} else {
keyboard->keyboard->preedit_string[strlen(keyboard->keyboard->preedit_string) - 1] = '\0';
@@ -579,8 +575,7 @@ handle_surrounding_text(void *data,
static void
handle_reset(void *data,
- struct input_method_context *context,
- uint32_t serial)
+ struct input_method_context *context)
{
struct virtual_keyboard *keyboard = data;
@@ -597,8 +592,6 @@ handle_reset(void *data,
free(keyboard->preedit_string);
keyboard->preedit_string = strdup("");
}
-
- keyboard->serial = serial;
}
static void
@@ -628,12 +621,15 @@ handle_invoke_action(void *data,
}
static void
-handle_commit(void *data,
- struct input_method_context *context)
+handle_commit_state(void *data,
+ struct input_method_context *context,
+ uint32_t serial)
{
struct virtual_keyboard *keyboard = data;
const struct layout *layout;
+ keyboard->serial = serial;
+
layout = get_current_layout(keyboard);
if (keyboard->surrounding_text)
@@ -670,15 +666,14 @@ static const struct input_method_context_listener input_method_context_listener
handle_reset,
handle_content_type,
handle_invoke_action,
- handle_commit,
+ handle_commit_state,
handle_preferred_language
};
static void
input_method_activate(void *data,
struct input_method *input_method,
- struct input_method_context *context,
- uint32_t serial)
+ struct input_method_context *context)
{
struct virtual_keyboard *keyboard = data;
struct wl_array modifiers_map;
@@ -700,7 +695,7 @@ input_method_activate(void *data,
free(keyboard->surrounding_text);
keyboard->surrounding_text = NULL;
- keyboard->serial = serial;
+ keyboard->serial = 0;
keyboard->context = context;
input_method_context_add_listener(context,
diff --git a/clients/weston-simple-im.c b/clients/weston-simple-im.c
index 9d31e3b0..a5320039 100644
--- a/clients/weston-simple-im.c
+++ b/clients/weston-simple-im.c
@@ -112,16 +112,13 @@ handle_surrounding_text(void *data,
static void
handle_reset(void *data,
- struct input_method_context *context,
- uint32_t serial)
+ struct input_method_context *context)
{
struct simple_im *keyboard = data;
fprintf(stderr, "Reset pre-edit buffer\n");
keyboard->compose_state = state_normal;
-
- keyboard->serial = serial;
}
static void
@@ -141,9 +138,13 @@ handle_invoke_action(void *data,
}
static void
-handle_commit(void *data,
- struct input_method_context *context)
+handle_commit_state(void *data,
+ struct input_method_context *context,
+ uint32_t serial)
{
+ struct simple_im *keyboard = data;
+
+ keyboard->serial = serial;
}
static void
@@ -158,7 +159,7 @@ static const struct input_method_context_listener input_method_context_listener
handle_reset,
handle_content_type,
handle_invoke_action,
- handle_commit,
+ handle_commit_state,
handle_preferred_language
};
@@ -285,8 +286,7 @@ static const struct wl_keyboard_listener input_method_keyboard_listener = {
static void
input_method_activate(void *data,
struct input_method *input_method,
- struct input_method_context *context,
- uint32_t serial)
+ struct input_method_context *context)
{
struct simple_im *keyboard = data;
@@ -295,7 +295,7 @@ input_method_activate(void *data,
keyboard->compose_state = state_normal;
- keyboard->serial = serial;
+ keyboard->serial = 0;
keyboard->context = context;
input_method_context_add_listener(context,
@@ -396,7 +396,7 @@ simple_im_key_handler(struct simple_im *keyboard,
for (i = 0; i < sizeof(ignore_keys_on_compose) / sizeof(ignore_keys_on_compose[0]); i++) {
if (sym == ignore_keys_on_compose[i]) {
- input_method_context_key(context, serial, time, key, state);
+ input_method_context_key(context, keyboard->serial, time, key, state);
return;
}
}
@@ -412,13 +412,11 @@ simple_im_key_handler(struct simple_im *keyboard,
if (cs) {
if (cs->keys[i + 1] == 0) {
input_method_context_preedit_cursor(keyboard->context,
- keyboard->serial,
0);
input_method_context_preedit_string(keyboard->context,
keyboard->serial,
"", "");
input_method_context_cursor_position(keyboard->context,
- keyboard->serial,
0, 0);
input_method_context_commit_string(keyboard->context,
keyboard->serial,
@@ -432,7 +430,6 @@ simple_im_key_handler(struct simple_im *keyboard,
}
input_method_context_preedit_cursor(keyboard->context,
- keyboard->serial,
strlen(text));
input_method_context_preedit_string(keyboard->context,
keyboard->serial,
@@ -446,13 +443,11 @@ simple_im_key_handler(struct simple_im *keyboard,
idx += xkb_keysym_to_utf8(keyboard->compose_seq.keys[j], text + idx, sizeof(text) - idx);
}
input_method_context_preedit_cursor(keyboard->context,
- keyboard->serial,
0);
input_method_context_preedit_string(keyboard->context,
keyboard->serial,
"", "");
input_method_context_cursor_position(keyboard->context,
- keyboard->serial,
0, 0);
input_method_context_commit_string(keyboard->context,
keyboard->serial,
@@ -471,7 +466,6 @@ simple_im_key_handler(struct simple_im *keyboard,
return;
input_method_context_cursor_position(keyboard->context,
- keyboard->serial,
0, 0);
input_method_context_commit_string(keyboard->context,
keyboard->serial,