struct {
xkb_mod_mask_t shift_mask;
} keysym;
+ uint32_t serial;
};
struct editor {
static void
text_model_commit_string(void *data,
struct text_model *text_model,
+ uint32_t serial,
const char *text,
uint32_t index)
{
static void
text_model_preedit_string(void *data,
struct text_model *text_model,
+ uint32_t serial,
const char *text,
const char *commit)
{
static void
text_model_delete_surrounding_text(void *data,
struct text_model *text_model,
+ uint32_t serial,
int32_t index,
uint32_t length)
{
static void
text_model_preedit_styling(void *data,
struct text_model *text_model,
+ uint32_t serial,
uint32_t index,
uint32_t length,
uint32_t style)
static void
text_model_preedit_cursor(void *data,
struct text_model *text_model,
+ uint32_t serial,
int32_t index)
{
struct text_entry *entry = data;
{
struct wl_surface *surface = window_get_wl_surface(entry->window);
+ entry->serial++;
+
text_model_activate(entry->model,
+ entry->serial,
seat,
surface);
}
{
entry->cursor = text_layout_xy_to_index(entry->layout, x, y);
- text_model_reset(entry->model);
+ entry->serial++;
+
+ text_model_reset(entry->model, entry->serial);
if (entry->preedit.cursor > 0 &&
entry->cursor >= (uint32_t)entry->preedit.cursor) {
struct {
xkb_mod_mask_t shift_mask;
} keysym;
+ uint32_t serial;
};
enum key_type {
return;
input_method_context_preedit_cursor(keyboard->context,
+ keyboard->serial,
0);
input_method_context_preedit_string(keyboard->context,
+ keyboard->serial,
"",
"");
input_method_context_commit_string(keyboard->context,
+ keyboard->serial,
keyboard->preedit_string,
strlen(keyboard->preedit_string));
free(keyboard->preedit_string);
keyboard->keyboard->preedit_string = strcat(keyboard->keyboard->preedit_string,
label);
input_method_context_preedit_cursor(keyboard->keyboard->context,
+ keyboard->keyboard->serial,
strlen(keyboard->keyboard->preedit_string));
input_method_context_preedit_string(keyboard->keyboard->context,
+ keyboard->keyboard->serial,
keyboard->keyboard->preedit_string,
keyboard->keyboard->preedit_string);
break;
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';
input_method_context_preedit_cursor(keyboard->keyboard->context,
+ keyboard->keyboard->serial,
strlen(keyboard->keyboard->preedit_string));
input_method_context_preedit_string(keyboard->keyboard->context,
+ keyboard->keyboard->serial,
keyboard->keyboard->preedit_string,
keyboard->keyboard->preedit_string);
}
static void
input_method_context_reset(void *data,
- struct input_method_context *context)
+ struct input_method_context *context,
+ uint32_t serial)
{
struct virtual_keyboard *keyboard = data;
if (strlen(keyboard->preedit_string)) {
input_method_context_preedit_cursor(context,
+ serial,
0);
input_method_context_preedit_string(context,
+ serial,
"",
"");
free(keyboard->preedit_string);
keyboard->preedit_string = strdup("");
}
+
+ keyboard->serial = serial;
}
static const struct input_method_context_listener input_method_context_listener = {
static void
input_method_activate(void *data,
struct input_method *input_method,
- struct input_method_context *context)
+ struct input_method_context *context,
+ uint32_t serial)
{
struct virtual_keyboard *keyboard = data;
struct wl_array modifiers_map;
free(keyboard->preedit_string);
keyboard->preedit_string = strdup("");
+ keyboard->serial = serial;
keyboard->context = context;
input_method_context_add_listener(context,
xkb_mod_mask_t shift_mask;
keyboard_input_key_handler_t key_handler;
+
+ uint32_t serial;
};
static const struct compose_seq compose_seqs[] = {
static void
input_method_context_reset(void *data,
- struct input_method_context *context)
+ struct input_method_context *context,
+ uint32_t serial)
{
struct simple_im *keyboard = data;
fprintf(stderr, "Reset pre-edit buffer\n");
keyboard->compose_state = state_normal;
+
+ keyboard->serial = serial;
}
static const struct input_method_context_listener input_method_context_listener = {
static void
input_method_activate(void *data,
struct input_method *input_method,
- struct input_method_context *context)
+ struct input_method_context *context,
+ uint32_t serial)
{
struct simple_im *keyboard = data;
keyboard->compose_state = state_normal;
+ keyboard->serial = serial;
+
keyboard->context = context;
input_method_context_add_listener(context,
&input_method_context_listener,
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_commit_string(keyboard->context,
+ keyboard->serial,
cs->text,
strlen(cs->text));
keyboard->compose_state = state_normal;
}
input_method_context_preedit_cursor(keyboard->context,
+ keyboard->serial,
strlen(text));
input_method_context_preedit_string(keyboard->context,
+ keyboard->serial,
text,
text);
}
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_commit_string(keyboard->context,
+ keyboard->serial,
text,
strlen(text));
keyboard->compose_state = state_normal;
return;
input_method_context_commit_string(keyboard->context,
+ keyboard->serial,
text,
strlen(text));
}
<description summary="commit string">
Send the commit string text to the applications text model.
</description>
+ <arg name="serial" type="uint"/>
<arg name="text" type="string"/>
<arg name="index" type="uint"/>
</request>
<description summary="pre-edit string">
Send the pre-edit string text to the applications text model.
</description>
+ <arg name="serial" type="uint"/>
<arg name="text" type="string"/>
<arg name="commit" type="string"/>
</request>
<request name="preedit_styling">
+ <arg name="serial" type="uint"/>
<arg name="index" type="uint"/>
<arg name="length" type="uint"/>
<arg name="style" type="uint"/>
Sets the cursor position inside the composing text (as byte index)
relative to the start of the composing text.
</description>
+ <arg name="serial" type="uint"/>
<arg name="index" type="int"/>
</request>
<request name="delete_surrounding_text">
+ <arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="length" type="uint"/>
</request>
<arg name="anchor" type="uint"/>
</event>
<event name="reset">
+ <arg name="serial" type="uint"/>
</event>
</interface>
which allows communication with the text model.
</description>
<arg name="id" type="new_id" interface="input_method_context"/>
+ <arg name="serial" type="uint"/>
</event>
<event name="deactivate">
<description summary="activate event">
model and tracked for focus lost. The activated event is emitted on
successful activation.
</description>
+ <arg name="serial" type="uint"/>
<arg name="seat" type="object" interface="wl_seat"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
be reseted, for example after the text was changed outside of the
normal input method flow.
</description>
+ <arg name="serial" type="uint"/>
</request>
<request name="set_micro_focus">
<arg name="x" type="int"/>
or the result of some composing (pre-edit). It also sets the new
cursor position (as byte index) relative to the inserted text.
</description>
+ <arg name="serial" type="uint"/>
<arg name="text" type="string"/>
<arg name="index" type="uint"/>
</event>
be removed. It also sets the cursor position (as byte index) relative
to the start of the composing text.
</description>
+ <arg name="serial" type="uint"/>
<arg name="text" type="string"/>
<arg name="commit" type="string"/>
</event>
deleted. Index is relative to the current cursor (as byte index).
Length is the length of deleted text (as bytes).
</description>
+ <arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="length" type="uint"/>
</event>
<entry name="incorrect" value="7"/>
</enum>
<event name="preedit_styling">
+ <arg name="serial" type="uint"/>
<arg name="index" type="uint"/>
<arg name="length" type="uint"/>
<arg name="style" type="uint"/>
Sets the cursor position inside the composing text (as byte index)
relative to the start of the composing text.
</description>
+ <arg name="serial" type="uint"/>
<arg name="index" type="int"/>
</event>
<event name="modifiers_map">
};
static void input_method_context_create(struct text_model *model,
- struct input_method *input_method);
+ struct input_method *input_method,
+ uint32_t serial);
static void input_method_context_end_keyboard_grab(struct input_method_context *context);
static void input_method_init_seat(struct weston_seat *seat);
static void
text_model_activate(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
struct wl_resource *seat,
struct wl_resource *surface)
{
text_model->surface = surface->data;
- input_method_context_create(text_model, input_method);
+ input_method_context_create(text_model, input_method, serial);
wl_signal_emit(&ec->show_input_panel_signal, ec);
static void
text_model_reset(struct wl_client *client,
- struct wl_resource *resource)
+ struct wl_resource *resource,
+ uint32_t serial)
{
struct text_model *text_model = resource->data;
struct input_method *input_method, *next;
wl_list_for_each_safe(input_method, next, &text_model->input_methods, link) {
if (!input_method->context)
continue;
- input_method_context_send_reset(&input_method->context->resource);
+ input_method_context_send_reset(&input_method->context->resource, serial);
}
}
static void
input_method_context_commit_string(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
const char *text,
uint32_t index)
{
struct input_method_context *context = resource->data;
- text_model_send_commit_string(&context->model->resource, text, index);
+ text_model_send_commit_string(&context->model->resource, serial, text, index);
}
static void
input_method_context_preedit_string(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
const char *text,
const char *commit)
{
struct input_method_context *context = resource->data;
- text_model_send_preedit_string(&context->model->resource, text, commit);
+ text_model_send_preedit_string(&context->model->resource, serial, text, commit);
}
static void
input_method_context_preedit_styling(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
uint32_t index,
uint32_t length,
uint32_t style)
{
struct input_method_context *context = resource->data;
- text_model_send_preedit_styling(&context->model->resource, index, length, style);
+ text_model_send_preedit_styling(&context->model->resource, serial, index, length, style);
}
static void
input_method_context_preedit_cursor(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
int32_t cursor)
{
struct input_method_context *context = resource->data;
- text_model_send_preedit_cursor(&context->model->resource, cursor);
+ text_model_send_preedit_cursor(&context->model->resource, serial, cursor);
}
static void
input_method_context_delete_surrounding_text(struct wl_client *client,
struct wl_resource *resource,
+ uint32_t serial,
int32_t index,
uint32_t length)
{
struct input_method_context *context = resource->data;
- text_model_send_delete_surrounding_text(&context->model->resource, index, length);
+ text_model_send_delete_surrounding_text(&context->model->resource, serial, index, length);
}
static void
static void
input_method_context_create(struct text_model *model,
- struct input_method *input_method)
+ struct input_method *input_method,
+ uint32_t serial)
{
struct input_method_context *context;
wl_client_add_resource(input_method->input_method_binding->client, &context->resource);
- input_method_send_activate(input_method->input_method_binding, &context->resource);
+ input_method_send_activate(input_method->input_method_binding, &context->resource, serial);
}
static void