} keysym;
uint32_t serial;
uint32_t content_purpose;
+ uint32_t click_to_show;
};
struct editor {
entry->active = 0;
+ text_model_hide_input_panel(text_model);
+
widget_schedule_redraw(entry->widget);
}
+static void
+text_model_input_panel_state(void *data,
+ struct text_model *text_model,
+ uint32_t state)
+{
+}
+
static const struct text_model_listener text_model_listener = {
text_model_commit_string,
text_model_preedit_string,
text_model_modifiers_map,
text_model_keysym,
text_model_enter,
- text_model_leave
+ text_model_leave,
+ text_model_input_panel_state
};
static struct text_entry*
{
struct wl_surface *surface = window_get_wl_surface(entry->window);
+ if (entry->click_to_show && entry->active) {
+ text_model_show_input_panel(entry->model);
+
+ return;
+ }
+
+ if (!entry->click_to_show)
+ text_model_show_input_panel(entry->model);
+
entry->serial++;
text_model_activate(entry->model,
main(int argc, char *argv[])
{
struct editor editor;
+ int i;
+ uint32_t click_to_show = 0;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp("--click-to-show", argv[i]) == 0)
+ click_to_show = 1;
memset(&editor, 0, sizeof editor);
editor.widget = frame_create(editor.window, &editor);
editor.entry = text_entry_create(&editor, "Entry");
+ editor.entry->click_to_show = click_to_show;
editor.editor = text_entry_create(&editor, "Numeric");
editor.editor->content_purpose = TEXT_MODEL_CONTENT_PURPOSE_NUMBER;
+ editor.editor->click_to_show = click_to_show;
window_set_title(editor.window, "Text Editor");
window_set_key_handler(editor.window, key_handler);
</request>
<request name="commit">
</request>
+ <request name="show_input_panel">
+ <description summary="show input panels">
+ Requests input panels (virtual keyboard) to show.
+ </description>
+ </request>
+ <request name="hide_input_panel">
+ <description summary="hide input panels">
+ Requests input panels (virtual keyboard) to hide.
+ </description>
+ </request>
<event name="commit_string">
<description summary="commit">
Notify when text should be inserted into the editor widget. The text
destroyed.
</description>
</event>
+ <event name="input_panel_state">
+ <description summary="state of the input panel">
+ Notify when the visibility state of the input panel changed.
+ </description>
+ <arg name="state" type="uint"/>
+ </event>
</interface>
<interface name="text_model_factory" version="1">
hide_input_panel_listener);
struct weston_surface *surface, *next;
+ if (!shell->showing_input_panels)
+ return;
+
shell->showing_input_panels = false;
if (!shell->locked)
struct wl_list input_methods;
struct wl_surface *surface;
+
+ uint32_t input_panel_visible;
};
struct text_model_factory {
input_method_context_create(text_model, input_method, serial);
- wl_signal_emit(&ec->show_input_panel_signal, ec);
+ if (text_model->input_panel_visible)
+ wl_signal_emit(&ec->show_input_panel_signal, ec);
text_model_send_enter(&text_model->resource, &text_model->surface->resource);
}
}
}
+static void
+text_model_show_input_panel(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct text_model *text_model = resource->data;
+ struct weston_compositor *ec = text_model->ec;
+
+ text_model->input_panel_visible = 1;
+
+ if (!wl_list_empty(&text_model->input_methods))
+ wl_signal_emit(&ec->show_input_panel_signal, ec);
+}
+
+static void
+text_model_hide_input_panel(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct text_model *text_model = resource->data;
+ struct weston_compositor *ec = text_model->ec;
+
+ text_model->input_panel_visible = 0;
+
+ if (!wl_list_empty(&text_model->input_methods))
+ wl_signal_emit(&ec->hide_input_panel_signal, ec);
+}
+
static const struct text_model_interface text_model_implementation = {
text_model_set_surrounding_text,
text_model_activate,
text_model_set_micro_focus,
text_model_set_content_type,
text_model_invoke_action,
- text_model_commit
+ text_model_commit,
+ text_model_show_input_panel,
+ text_model_hide_input_panel
};
static void text_model_factory_create_text_model(struct wl_client *client,