Eina_List *l, *l_prev;
WindowInfo *wi = NULL;
int removed_index = 0;
+ int keyboard_index = -1;
EINA_LIST_REVERSE_FOREACH_SAFE(wtd->window_infos, l, l_prev, wi) {
if (!wi) continue;
if (atspi_accessible_is_equal(wi->window, window)) {
wtd->window_infos = eina_list_remove_list(wtd->window_infos, l);
window_removed = EINA_TRUE;
break;
- }
+ } else if (wi->keyboard_window_is)
+ keyboard_index = removed_index;
+
removed_index++;
}
DEBUG("top window: %s", id);
g_free(id);
}
- } else {
+ } else if (removed_index > 0 && keyboard_index == removed_index - 1) {
/* The removed window could be under the keyboard window,
in this case the keyboard window should be removed from the list */
- if (removed_index != 0) {
- int count = eina_list_count(wtd->window_infos);
- wi = eina_list_nth(wtd->window_infos, count - removed_index - 1);
- if (wi) {
- gchar *id = atspi_accessible_get_unique_id(wi->window, NULL);
- DEBUG("Check upper window: %s, keyboard window: %d", id, wi->keyboard_window_is);
- g_free(id);
- if (wi->keyboard_window_is) {
- wtd->window_infos = eina_list_remove(wtd->window_infos, wi);
- g_object_unref(wi->window);
- g_free(wi);
- }
- } else
- DEBUG("Current window info list is emtpy");
- }
+ window_tracker_keyboard_window_remove(wtd);
}
gchar *id = atspi_accessible_get_unique_id(window, NULL);