Merge "Fix keyboard removal logic in _window_remove" into tizen accepted/tizen_unified_x_asan accepted/tizen/unified/20250115.124146 accepted/tizen/unified/x/20250115.142725 accepted/tizen/unified/x/asan/20250211.003441
authorsunghyun kim <scholb.kim@samsung.com>
Tue, 14 Jan 2025 01:35:09 +0000 (01:35 +0000)
committerGerrit Code Review <gerrit@localhost>
Tue, 14 Jan 2025 01:35:09 +0000 (01:35 +0000)
1  2 
src/window_tracker.c

index f61cc4464439a45f5c7f858b889d748a20baa519,37bdd5d5e91fa254240789b43fc69b1f21852637..e52bab76d770910e7a25f73b79d77a170ccde16f
@@@ -343,26 -307,34 +346,12 @@@ static void _window_remove(WindowTracke
                /* keyboard_window_is would be always FASLE because the
                window_tracker_keyboard_window_remove does not use this function */
                if (wtd->user_cb && !keyboard_window_is) {
 -                      top_window = _top_window_get(wtd);
 -                      if (top_window) {
 -                              /* The current top could be keypad window,
 -                              if so, use the second top window */
 -                              wi = eina_list_last_data_get(wtd->window_infos);
 -                              if (wi->keyboard_window_is) {
 -                                      int count = eina_list_count(wtd->window_infos);
 -                                      wi = eina_list_nth(wtd->window_infos, count - 2);
 -                                      if (wi)
 -                                              top_window = wi->window;
 -                                      else
 -                                              top_window = NULL;
 -                              }
 -                              if (top_window)
 -                                      wtd->user_cb(wtd->user_data, top_window);
 -                      }
 -
 -                      if (!top_window)
 -                              app_tracker_null_context_switch(wtd->user_data);
 -
 -                      gchar *id = atspi_accessible_get_unique_id(top_window, NULL);
 -                      DEBUG("top window: %s", id);
 -                      g_free(id);
 +                      _switch_context_to_non_keyboard_top(wtd);
                }
-       } 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);