diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index b5d82634..8c891606 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -849,7 +849,7 @@ static LRESULT KeyMessageHandler (UINT message, int scancode, DWORD status) dskForceCloseMenu (); #endif next_node = - get_next_visible_mainwin (__mg_zorder_info, + get_next_activable_mainwin (__mg_zorder_info, __mg_zorder_info->active_win); if (next_node) { diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index 21b56bed..9bf8c587 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -1679,7 +1679,7 @@ int __mg_remove_all_znodes_of_client (int cli) /* if active_win belongs to the client, change it */ if (nodes [old_active].cli == cli) { - int next_active = get_next_visible_mainwin (zi, 0); + int next_active = get_next_activable_mainwin (zi, 0); srvSetActiveWindow (nodes [next_active].cli, next_active); } @@ -2900,7 +2900,7 @@ static int srvKeyMessageHandler (int message, int scancode, DWORD status) #ifdef _MGHAVE_MENU srvForceCloseMenu (0); #endif - next_node = get_next_visible_mainwin (__mg_zorder_info, + next_node = get_next_activable_mainwin (__mg_zorder_info, __mg_zorder_info->active_win); if (next_node) { srvMove2Top (0, next_node); diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index 6ec5fd18..bbe0c164 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -1240,7 +1240,7 @@ int __kernel_get_prev_znode (const ZORDERINFO* zi, int from) return prev; } -static int get_next_visible_mainwin (const ZORDERINFO* zi, int from) +static int get_next_activable_mainwin (const ZORDERINFO* zi, int from) { int next; ZORDERNODE* nodes = GET_ZORDERNODE(zi); @@ -2422,26 +2422,28 @@ static int FreeZOrderNodeEx (ZORDERINFO* zi, int idx_znode, HDC* memdc) } #endif /* defined _MGSCHEMA_COMPOSITING */ + /* XXX: get next activable window znode before freeing the current znode */ + next_active = get_next_activable_mainwin (zi, idx_znode); + old_active = zi->active_win; + if (idx_znode == zi->active_win) + zi->active_win = 0; + if (first == &fixed_idx) { /* Since 4.2.0: handle fixed znodes */ - nodes [idx_znode].hwnd = 0; + nodes [idx_znode].hwnd = HWND_NULL; nodes [idx_znode].cli = -1; nodes [idx_znode].flags &= ~ZOF_VISIBLE; } else if (*first == idx_znode) { /* unchain it */ unchain_znode ((unsigned char*)(zi+1), nodes, idx_znode); - nodes [idx_znode].hwnd = 0; + nodes [idx_znode].hwnd = HWND_NULL; nodes [idx_znode].cli = -1; *first = nodes [idx_znode].next; *nr_nodes -= 1; } - old_active = zi->active_win; - if (idx_znode == zi->active_win) - zi->active_win = 0; - /* unlock zi for change */ unlock_zi_for_change (zi); @@ -2463,7 +2465,6 @@ static int FreeZOrderNodeEx (ZORDERINFO* zi, int idx_znode, HDC* memdc) /* if active_win is this window, change it */ if (idx_znode == old_active) { - next_active = get_next_visible_mainwin (zi, idx_znode); dskSetActiveZOrderNode (nodes [next_active].cli, next_active); }