text: Add show/hide_input_panel requests
Allows to show/hide the input panel (virtual keyboard) more independent
of focus (some applications might to require additionaly click on a
focused entry to show the input panel).
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
diff --git a/clients/editor.c b/clients/editor.c
index 5c072f2..a830ead 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -60,6 +60,7 @@
} keysym;
uint32_t serial;
uint32_t content_purpose;
+ uint32_t click_to_show;
};
struct editor {
@@ -360,9 +361,18 @@
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,
@@ -372,7 +382,8 @@
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*
@@ -468,6 +479,15 @@
{
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,
@@ -997,6 +1017,12 @@
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);
@@ -1017,8 +1043,10 @@
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);