Commit 49b04fb6 authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz
Browse files

Merge branch 'fix_keyboard_away' into 'master'

Fix crashes when pressing tab

Closes #18

See merge request !28
parents 81c5b9e8 e3984305
Pipeline #2724 passed with stage
in 56 seconds
......@@ -89,6 +89,7 @@ struct virtual_keyboard {
char *preferred_layout;
uint32_t buttons_held;
bool scheduled_hidden; // the keyboard should hide as soon as buttons_held == 0
};
/// Modifiers passed to the virtual_keyboard protocol.
......@@ -694,6 +695,9 @@ static void keyboard_update_mods(struct keyboard *keyboard) {
mods, 0, locked, 0);
}
static void
try_hide(struct virtual_keyboard *keyboard);
static void
keyboard_handle_key(struct keyboard *keyboard, const struct layout *layout,
uint32_t time, const struct key *key,
......@@ -863,6 +867,11 @@ keyboard_handle_key(struct keyboard *keyboard, const struct layout *layout,
default:
dbg("Keytype invalid\n");
}
if (keyboard->keyboard->scheduled_hidden
&& keyboard->keyboard->buttons_held == 0) {
try_hide(keyboard->keyboard);
}
}
static int
......@@ -971,6 +980,13 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
break;
}
}
if (!keyboard->window) {
return;
}
if (!keyboard->window) {
return;
}
struct size size = keyboard_get_size(keyboard);
window_schedule_resize(keyboard->window, size.width, size.height);
......@@ -1012,6 +1028,10 @@ touch_handler(struct input *input, uint32_t time,
}
}
if (!keyboard->window) {
return;
}
struct size size = keyboard_get_size(keyboard);
window_schedule_resize(keyboard->window, size.width, size.height);
widget_schedule_redraw(keyboard->widget);
......@@ -1143,6 +1163,19 @@ make_hidden(struct virtual_keyboard *keyboard) {
notify_visible(false);
}
/** Checks for clicked buttons and hides when they are all unclicked.
*/
static void
try_hide(struct virtual_keyboard *keyboard) {
if (keyboard->buttons_held) {
keyboard->scheduled_hidden = true;
} else {
keyboard->scheduled_hidden = false;
make_hidden(keyboard);
return;
}
}
static void
handle_input_method_activate(void *data, struct zwp_input_method_v2 *input_method)
{
......@@ -1208,7 +1241,7 @@ handle_commit_state(void *data, struct zwp_input_method_v2 *input_method)
if (keyboard->current.active) {
make_visible(keyboard);
} else {
make_hidden(keyboard);
try_hide(keyboard);
}
}
......@@ -1221,7 +1254,7 @@ handle_unavailable(void *data, struct zwp_input_method_v2 *zwp_input_method_v2)
keyboard->current.active = false;
zwp_input_method_v2_destroy(keyboard->input_method);
keyboard->input_method = NULL;
make_hidden(keyboard);
try_hide(keyboard);
}
static const struct zwp_input_method_v2_listener input_method_listener = {
......@@ -1354,7 +1387,7 @@ handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation,
if (arg_visible) {
make_visible(keyboard);
} else {
make_hidden(keyboard);
try_hide(keyboard);
}
sm_puri_osk0_complete_set_visible(object, invocation);
return TRUE;
......
......@@ -244,7 +244,7 @@ struct window {
int redraw_inhibited;
int redraw_needed;
int redraw_task_scheduled;
struct task redraw_task;
guint redraw_task;
int resize_needed;
int custom;
int focused;
......@@ -1590,7 +1590,10 @@ window_destroy(struct window *window)
struct window_output *window_output;
struct window_output *window_output_tmp;
wl_list_remove(&window->redraw_task.link);
if (window->redraw_task) {
g_source_remove(window->redraw_task);
window->redraw_task = 0;
}
wl_list_for_each(input, &display->input_list, link) {
if (input->touch_focus == window)
......@@ -1726,6 +1729,9 @@ widget_destroy(struct widget *widget)
wl_list_for_each(input, &display->input_list, link) {
if (input->focus_widget == widget)
input->focus_widget = NULL;
if (input->grab == widget) {
input->grab = NULL;
}
}
wl_list_remove(&widget->link);
......@@ -3904,8 +3910,8 @@ void
window_inhibit_redraw(struct window *window)
{
window->redraw_inhibited = 1;
wl_list_remove(&window->redraw_task.link);
wl_list_init(&window->redraw_task.link);
g_source_remove(window->redraw_task);
window->redraw_task = 0;
window->redraw_task_scheduled = 0;
}
......@@ -4178,6 +4184,11 @@ surface_redraw(struct surface *surface)
return 0;
}
struct window_handle {
struct display* display;
struct window* window;
};
static gboolean
idle_redraw(void *data)
{
......@@ -4188,7 +4199,7 @@ idle_redraw(void *data)
DBG(" --------- \n");
wl_list_init(&window->redraw_task.link);
window->redraw_task = 0;
window->redraw_task_scheduled = 0;
if (window->resize_needed) {
......@@ -4238,7 +4249,7 @@ window_schedule_redraw_task(struct window *window)
return;
if (!window->redraw_task_scheduled) {
g_idle_add(idle_redraw, window);
window->redraw_task = g_idle_add(idle_redraw, window);
window->redraw_task_scheduled = 1;
}
}
......@@ -4839,7 +4850,6 @@ static struct window *
wl_surface_set_user_data(surface->surface, window);
wl_list_insert(display->window_list.prev, &window->link);
wl_list_init(&window->redraw_task.link);
wl_list_init (&window->window_output_list);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment