summaryrefslogtreecommitdiff
path: root/clients/editor.c
diff options
context:
space:
mode:
authorJan Arne Petersen <jpetersen@openismus.com>2013-01-31 15:52:21 +0100
committerKristian Høgsberg <krh@bitplanet.net>2013-02-15 17:07:35 -0500
commit6138197337c0e082172e35c634470fbd8cb43b84 (patch)
treed1ce9e45fc538fff56287b752a674d9d7174ee1d /clients/editor.c
parent0eabcaafaeeb8648fbe6a2196f34afbbfd18d65a (diff)
downloadweston-6138197337c0e082172e35c634470fbd8cb43b84.tar.gz
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>
Diffstat (limited to 'clients/editor.c')
-rw-r--r--clients/editor.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/clients/editor.c b/clients/editor.c
index 5c072f21..a830ead5 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -60,6 +60,7 @@ struct text_entry {
} keysym;
uint32_t serial;
uint32_t content_purpose;
+ uint32_t click_to_show;
};
struct editor {
@@ -360,9 +361,18 @@ text_model_leave(void *data,
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 @@ static const struct text_model_listener text_model_listener = {
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 @@ text_entry_activate(struct text_entry *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,
@@ -997,6 +1017,12 @@ int
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 @@ main(int argc, char *argv[])
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);