text: Add activate/deactivate events

Let the client know when a text model gets activated or deactiavted.
dev
Jan Arne Petersen 13 years ago committed by Kristian Høgsberg
parent 5196374218
commit de3b6a15c0
  1. 45
      clients/editor.c
  2. 4
      protocol/text.xml
  3. 10
      src/text-backend.c

@ -107,6 +107,28 @@ text_model_locale(void *data,
{
}
static void
text_model_activated(void *data,
struct text_model *text_model)
{
struct text_entry *entry = data;
entry->active = 1;
widget_schedule_redraw(entry->widget);
}
static void
text_model_deactivated(void *data,
struct text_model *text_model)
{
struct text_entry *entry = data;
entry->active = 0;
widget_schedule_redraw(entry->widget);
}
static const struct text_model_listener text_model_listener = {
text_model_commit_string,
text_model_preedit_string,
@ -114,7 +136,9 @@ static const struct text_model_listener text_model_listener = {
text_model_key,
text_model_selection_replacement,
text_model_direction,
text_model_locale
text_model_locale,
text_model_activated,
text_model_deactivated
};
static struct text_entry*
@ -283,24 +307,13 @@ button_handler(struct widget *widget,
assert(!(activate_entry && activate_editor));
if (activate_entry) {
if (editor->editor->active)
text_entry_deactivate(editor->editor);
if (!editor->entry->active)
text_entry_activate(editor->entry);
text_entry_activate(editor->entry);
} else if (activate_editor) {
if (editor->entry->active)
text_entry_deactivate(editor->entry);
if (!editor->editor->active)
text_entry_activate(editor->editor);
text_entry_activate(editor->editor);
} else {
if (editor->entry->active)
text_entry_deactivate(editor->entry);
if (editor->editor->active)
text_entry_deactivate(editor->editor);
text_entry_deactivate(editor->entry);
text_entry_deactivate(editor->editor);
}
editor->entry->active = activate_entry;
editor->editor->active = activate_editor;
assert(!(editor->entry->active && editor->editor->active));
widget_schedule_redraw(widget);
}

@ -33,7 +33,9 @@
<event name="key"/>
<event name="selection_replacement"/>
<event name="direction"/>
<event name="locale"/>
<event name="locale"/>
<event name="activated"/>
<event name="deactivated"/>
</interface>
<interface name="text_model_factory" version="1">

@ -54,6 +54,7 @@ deactivate_text_model(struct text_model *text_model)
if (text_model->input_method->active_model == text_model) {
text_model->input_method->active_model = NULL;
wl_signal_emit(&ec->hide_input_panel_signal, ec);
text_model_send_deactivated(&text_model->resource);
}
}
@ -90,9 +91,18 @@ text_model_activate(struct wl_client *client,
struct text_model *text_model = resource->data;
struct weston_compositor *ec = text_model->input_method->ec;
if (text_model->input_method->active_model) {
if (text_model->input_method->active_model == text_model)
return;
deactivate_text_model(text_model->input_method->active_model);
}
text_model->input_method->active_model = text_model;
wl_signal_emit(&ec->show_input_panel_signal, ec);
text_model_send_activated(&text_model->resource);
}
static void

Loading…
Cancel
Save