summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wong <gtw@gnu.org>2009-12-06 10:17:29 -0700
committerGary Wong <gtw@gnu.org>2009-12-06 10:17:29 -0700
commitb31ed8da98a0780e8199d7fc00180d14b26bac06 (patch)
tree8cf8c6728e61a1ee4e372fc052bdd7caf2d4b030
parent1f6bda35de26928aa92b531c19fc3b3db0e6746e (diff)
Handle weird reparenting cases.
-rw-r--r--ChangeLog10
-rw-r--r--root.c17
-rw-r--r--window-table.c21
3 files changed, 42 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 22ebaba..e42ad7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-06 Gary Wong <gtw@gnu.org>
+
+ * root.c (root_reparent_notify): Handle cases where a window is
+ "reparented" to its current parent.
+
+ * window-table.c (stack_move_above): Treat moving a window above
+ itself as a no-op.
+ (stack_insert_singleton, stack_insert_above, stack_remove)
+ (stack_move_above): Add extra assertions.
+
2009-09-11 Gary Wong <gtw@gnu.org>
* decorate-core.c (decorate_core_init): Moved to the initialisation
diff --git a/root.c b/root.c
index 6f468c3..14ece34 100644
--- a/root.c
+++ b/root.c
@@ -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 );
}
diff --git a/window-table.c b/window-table.c
index fb71d86..981d6b1 100644
--- a/window-table.c
+++ b/window-table.c
@@ -495,7 +495,12 @@ static void stack_insert_new( struct window_stack *stack, xcb_window_t window,
extern void stack_insert_singleton( struct window_stack *stack,
xcb_window_t key ) {
+ if( !key )
+ return;
+
stack_insert_new( stack, key, key, key );
+
+ assert( stack_lookup( stack, key ) );
}
extern void stack_insert_above( struct window_stack *stack,
@@ -504,6 +509,9 @@ extern void stack_insert_above( struct window_stack *stack,
struct stacking_order *l, *h;
xcb_window_t higher_window;
+ if( !key )
+ return;
+
l = stack_lookup( stack, lower_window );
assert( l );
higher_window = l->higher_window;
@@ -515,6 +523,10 @@ extern void stack_insert_above( struct window_stack *stack,
h = stack_lookup( stack, higher_window );
h->lower_window = key;
l->higher_window = key;
+
+ assert( stack_lookup( stack, key ) );
+ assert( l );
+ assert( h );
}
extern void stack_remove( struct window_stack *stack, xcb_window_t window ) {
@@ -546,9 +558,14 @@ extern void stack_remove( struct window_stack *stack, xcb_window_t window ) {
/* Load becoming low: resize. */
stack_rehash( stack, stack->hash, stack->n >> 1,
stack->max - 4 );
+
+ assert( !stack_lookup( stack, window ) );
+
return;
}
}
+
+ assert( FALSE );
}
extern void stack_move_above( struct window_stack *stack,
@@ -557,7 +574,7 @@ extern void stack_move_above( struct window_stack *stack,
struct stacking_order *l, *h, *entry;
- if( !window )
+ if( !window || window == lower_window )
return;
entry = stack_lookup( stack, window );
@@ -585,6 +602,8 @@ extern void stack_move_above( struct window_stack *stack,
l->higher_window = window;
entry->lower_window = lower_window;
entry->higher_window = h->window;
+
+ assert( stack_lookup( stack, window ) );
}
extern xcb_window_t stack_real_below( struct window_stack *stack,