summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Dankov <tryagain@navit-project.org>2016-07-11 16:49:10 +0300
committerMichael Dankov <tryagain@navit-project.org>2016-07-11 16:49:10 +0300
commitb5912cb08754f3512c2d78c4cc12d45c326881f0 (patch)
treef3f625739988ef3eee106672336c6c8bc961b24f
parent1e638f6e57a0e0d6d691b08fcd27a6b610a6b362 (diff)
downloadnavit-b5912cb08754f3512c2d78c4cc12d45c326881f0.tar.gz
refactor:gui_internal:Always show software keyboard if supported
by graphics module.
-rw-r--r--navit/gui/internal/gui_internal_keyboard.c67
-rw-r--r--navit/gui/internal/gui_internal_keyboard.h2
-rw-r--r--navit/gui/internal/gui_internal_menu.c6
-rw-r--r--navit/gui/internal/gui_internal_priv.h5
-rw-r--r--navit/gui/internal/gui_internal_widget.c4
5 files changed, 57 insertions, 27 deletions
diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c
index 3dc6ae556..517b1863a 100644
--- a/navit/gui/internal/gui_internal_keyboard.c
+++ b/navit/gui/internal/gui_internal_keyboard.c
@@ -170,7 +170,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
this->current.x=-1;
this->current.y=-1;
gui_internal_highlight(this);
- if (md->keyboard_mode & VKBD_FLAG_1024)
+ if (md->keyboard_mode & VKBD_FLAG_MINIMIZED)
render=2;
else
render=1;
@@ -193,6 +193,19 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
wkbd->cols=9;
}
+ if (!(mode & VKBD_FLAG_MINIMIZED)) {
+ int res;
+ if(!this->kbd)
+ this->kbd=g_new0(struct graphics_keyboard,1);
+ this->kbd->mode = mode;
+ if(this->kbd->lang)
+ g_free(this->kbd->lang);
+ this->kbd->lang = g_strdup(getenv("LANG"));
+ res = graphics_show_native_keyboard(this->gra, this->kbd);
+ if(res>0)
+ mode|=VKBD_FLAG_MINIMIZED;
+ }
+
if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
for (i = 0 ; i < 26 ; i++) {
char text[]={'A'+i,'\0'};
@@ -203,10 +216,10 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
KEY("-");
KEY("'");
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
} else {
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SWCASE();
MODE(VKBD_NUMERIC);
@@ -224,10 +237,10 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
KEY("-");
KEY("'");
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
} else {
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SWCASE();
MODE(VKBD_NUMERIC);
@@ -250,7 +263,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
KEY("-");
KEY("'");
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SPACER();
SPACER();
} else {
@@ -258,7 +271,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
MODE(VKBD_CYRILLIC_UPPER);
MODE(VKBD_CYRILLIC_LOWER);
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
MODE(VKBD_LATIN_UPPER);
MODE(VKBD_LATIN_LOWER);
}
@@ -294,7 +307,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SWCASE();
@@ -313,7 +326,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SWCASE();
@@ -327,7 +340,7 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
if(md->search_list && md->search_list->type==widget_table) {
struct table_data *td=(struct table_data*)(md->search_list->data);
- td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
+ td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_MINIMIZED);
}
if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
@@ -338,17 +351,17 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
SPACER();
wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
+ wk->datai = mode | VKBD_FLAG_MINIMIZED;
SPACER();
gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
- if (mode & VKBD_FLAG_1024) {
+ }
+
+ if (mode & VKBD_FLAG_MINIMIZED) {
char *text=NULL;
int font=0;
struct widget *wkl;
- mode &= ~VKBD_FLAG_1024;
+ mode &= ~VKBD_FLAG_MINIMIZED;
text=gui_internal_keyb_modes[mode/8].title;
font=gui_internal_keyb_modes[mode/8].font;
wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
@@ -476,18 +489,28 @@ gui_internal_keyboard_init_mode(char *lang)
* @param this The internal GUI instance
* @param w The placeholder widget
*/
-void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w) {
+void
+gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w)
+{
struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
if (kbd) {
graphics_hide_native_keyboard(this_->gra, kbd);
- g_free(kbd->lang);
- g_free(kbd->gui_priv);
} else
dbg(lvl_warning, "no graphics_keyboard found, cleanup failed\n");
g_free(w);
}
+static void
+gui_internal_keyboard_destroy_native(struct gui_priv *this_, struct widget *w)
+{
+ struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
+ if(!kbd)
+ return;
+ gui_internal_keyboard_hide_native(this_, w);
+ g_free(kbd->lang);
+ g_free(kbd->gui_priv);
+}
/**
* @brief Shows the platform's native on-screen keyboard or other input method
@@ -514,15 +537,16 @@ void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w)
*
* @return The placeholder widget for the on-screen keyboard, may be {@code NULL}
*/
-struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang) {
+struct widget *
+gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang)
+{
struct widget *ret = NULL;
struct menu_data *md = gui_internal_menu_data(this);
struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
int res;
kbd->mode = mode;
- if (lang)
- kbd->lang = g_strdup(lang);
+ kbd->lang = g_strdup(lang);
res = graphics_show_native_keyboard(this->gra, kbd);
switch(res) {
@@ -530,6 +554,7 @@ struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct
dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard\n");
/* no break */
case 0:
+ g_free(kbd->lang);
g_free(kbd);
return NULL;
}
diff --git a/navit/gui/internal/gui_internal_keyboard.h b/navit/gui/internal/gui_internal_keyboard.h
index 9b9039224..39f007f77 100644
--- a/navit/gui/internal/gui_internal_keyboard.h
+++ b/navit/gui/internal/gui_internal_keyboard.h
@@ -15,7 +15,7 @@ enum vkbd_mode {
/* modifiers and masks */
VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
- VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
+ VKBD_FLAG_MINIMIZED = 1024, /* Keyboard is minimized and only "unhide" button is shown instead */
VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
};
diff --git a/navit/gui/internal/gui_internal_menu.c b/navit/gui/internal/gui_internal_menu.c
index 33def9983..1394a5c93 100644
--- a/navit/gui/internal/gui_internal_menu.c
+++ b/navit/gui/internal/gui_internal_menu.c
@@ -44,6 +44,8 @@ gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render)
GList *l;
struct widget *wr,*wd;
gui_internal_search_idle_end(this);
+ if(this->kbd)
+ graphics_hide_native_keyboard(this->gra, this->kbd);
while ((l = g_list_last(this->root.children))) {
wd=l->data;
if (wd == w) {
@@ -228,12 +230,14 @@ gui_internal_menu_render(struct gui_priv *this)
{
GList *l;
struct widget *menu;
-
+ this->keyboard_required=0;
l=g_list_last(this->root.children);
menu=l->data;
gui_internal_say(this, menu, 0);
gui_internal_widget_pack(this, menu);
gui_internal_widget_render(this, menu);
+ if(!this->keyboard_required && this->kbd)
+ graphics_hide_native_keyboard(this->gra, this->kbd);
}
struct widget *
diff --git a/navit/gui/internal/gui_internal_priv.h b/navit/gui/internal/gui_internal_priv.h
index 0dee59db2..43f82328e 100644
--- a/navit/gui/internal/gui_internal_priv.h
+++ b/navit/gui/internal/gui_internal_priv.h
@@ -79,9 +79,8 @@ struct gui_priv {
char *country_iso2;
int speech;
int keyboard; /**< Whether the internal GUI keyboard is enabled */
- int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
- * HTML menu, text entry dialogs do not use this member.
- */
+ int keyboard_required; /**< Whether keyboard input is needed. */
+ struct graphics_keyboard *kbd; /**< Pointer to graphics keyboard object filled by graphics_show_native_keyboard */
struct gui_config_settings config; /**< The setting information read from the configuration file.
* values of -1 indicate no value was specified in the config file.
*/
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 1dd28837f..3cd9afce7 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -119,8 +119,10 @@ gui_internal_label_render(struct gui_priv *this, struct widget *w)
{
struct point pnt=w->p;
gui_internal_background_render(this, w);
- if (w->state & STATE_EDIT)
+ if (w->state & STATE_EDIT) {
+ this->keyboard_required=1;
graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
+ }
if (w->text) {
char *text;
char *startext=(char*)g_alloca(strlen(w->text)+1);