diff options
author | Gary Wong <gtw@gnu.org> | 2009-12-06 10:17:29 -0700 |
---|---|---|
committer | Gary Wong <gtw@gnu.org> | 2009-12-06 10:17:29 -0700 |
commit | b31ed8da98a0780e8199d7fc00180d14b26bac06 (patch) | |
tree | 8cf8c6728e61a1ee4e372fc052bdd7caf2d4b030 /root.c | |
parent | 1f6bda35de26928aa92b531c19fc3b3db0e6746e (diff) |
Handle weird reparenting cases.
Diffstat (limited to 'root.c')
-rw-r--r-- | root.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -129,11 +129,18 @@ static void root_destroy_notify( struct gwm_window *window, static void root_reparent_notify( struct gwm_window *window, xcb_reparent_notify_event_t *ev ) { - if( ev->parent == window->w ) - stack_insert_above( &window_stack, ev->window, - stack_lookup( &window_stack, window->w | - STACK_END )->lower_window ); - else + if( ev->parent == window->w ) { + /* It's possible to reparent a window to its current parent, + so we can't assume the window is not already in the stack. */ + if( stack_lookup( &window_stack, ev->window ) ) + stack_move_above( &window_stack, ev->window, + stack_lookup( &window_stack, window->w | + STACK_END )->lower_window ); + else + stack_insert_above( &window_stack, ev->window, + stack_lookup( &window_stack, window->w | + STACK_END )->lower_window ); + } else stack_remove( &window_stack, ev->window ); } |