diff options
author | Gary Wong <gtw@gnu.org> | 2009-09-09 22:35:47 -0600 |
---|---|---|
committer | Gary Wong <gtw@gnu.org> | 2009-09-09 22:35:47 -0600 |
commit | 354413b0f7026c11f9e70b14f7e828d06a1f4772 (patch) | |
tree | b06f097cea153d9d80121644df7b1e62b2bfa582 | |
parent | 1ab4a061d8e39529895204df88f43ad1662e082e (diff) |
Sort the window menu by stacking order.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | actions.c | 88 | ||||
-rw-r--r-- | frame.c | 6 | ||||
-rw-r--r-- | root.c | 2 |
4 files changed, 73 insertions, 31 deletions
@@ -1,3 +1,11 @@ +2009-09-09 Gary Wong <gtw@gnu.org> + + * actions.c (action_window_list_menu): Insert windows into the + menu by screen, in bottom-to-top stacking order. + + * frame.c (synthetic_configure_notify): Ignore Window errors on + the SendEvent. + 2009-09-08 Gary Wong <gtw@gnu.org> * actions.c (window_list_enter, window_list_leave): New functions. @@ -268,42 +268,74 @@ extern void action_window_list_menu( struct gwm_window *window, union callback_param cp ) { int i, num_items; - struct menuitem *items; - for( i = 0, num_items = 0; i < windows.used; i++ ) - if( windows.values[ i ]->type == WINDOW_MANAGED ) + struct menuitem *items; + + for( i = 0, num_items = 0; i < num_screens; i++ ) { + xcb_window_t w = screens[ i ]->root | STACK_END; + + if( i ) num_items++; - items = alloca( num_items * sizeof *items ); + do { + struct gwm_window *window = lookup_window( w ); + xcb_window_t next = + stack_lookup( &window_stack, w )->lower_window; + + if( window && window->type == WINDOW_FRAME ) + num_items++; + + w = next; + } while( w != ( screens[ i ]->root | STACK_END ) ); + } - for( i = 0, num_items = 0; i < windows.used; i++ ) - if( windows.values[ i ]->type == WINDOW_MANAGED ) { - struct gwm_window *managed = windows.values[ i ]; - char *name = managed->u.managed.name ? managed->u.managed.name : - "(Untitled)"; - - if( managed->u.managed.state == STATE_ICONIC ) { - int len = strlen( name ); - char *new = alloca( len + 3 ); - - new[ 0 ] = '['; - strcpy( new + 1, name ); - new[ len + 1 ] = ']'; - new[ len + 2 ] = 0; - - name = new; - } + items = alloca( num_items * sizeof *items ); + + for( i = 0, num_items = 0; i < num_screens; i++ ) { + xcb_window_t w = screens[ i ]->root | STACK_END; + + if( i ) { + items[ num_items ].label = NULL; - items[ num_items ].label = name; - items[ num_items ].action = window_list_activate; - items[ num_items ].enter_action = window_list_enter; - items[ num_items ].leave_action = window_list_leave; - items[ num_items ].cp.l = managed->w; - items[ num_items ].icon = managed->w; - num_items++; } + do { + struct gwm_window *window = lookup_window( w ); + xcb_window_t next = + stack_lookup( &window_stack, w )->lower_window; + + if( window && window->type == WINDOW_FRAME ) { + struct gwm_window *managed = window->u.frame.child; + char *name = managed->u.managed.name ? + managed->u.managed.name : "(Untitled)"; + + if( managed->u.managed.state == STATE_ICONIC ) { + int len = strlen( name ); + char *new = alloca( len + 3 ); + + new[ 0 ] = '['; + strcpy( new + 1, name ); + new[ len + 1 ] = ']'; + new[ len + 2 ] = 0; + + name = new; + } + + items[ num_items ].label = name; + items[ num_items ].action = window_list_activate; + items[ num_items ].enter_action = window_list_enter; + items[ num_items ].leave_action = window_list_leave; + items[ num_items ].cp.l = managed->w; + items[ num_items ].icon = managed->w; + + num_items++; + } + + w = next; + } while( w != ( screens[ i ]->root | STACK_END ) ); + } + popup_menu( window, ev, num_items, items ); } @@ -1003,8 +1003,10 @@ extern void synthetic_configure_notify( struct gwm_window *window ) { frame_b( window, FALSE ); msg.border_width = window->u.frame.child->u.managed.border_width; msg.override_redirect = FALSE; - xcb_send_event( c, FALSE, window->u.frame.child->w, - XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char *) &msg ); + handle_error_reply( xcb_send_event_checked( + c, FALSE, window->u.frame.child->w, + XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char *) &msg ), + ERR_MASK_WINDOW ); } static void frame_configure_notify( struct gwm_window *window, @@ -190,7 +190,7 @@ static void root_synthetic( struct gwm_window *root, values[ 0 ] = sibling ? sibling->w : config->sibling; values[ 1 ] = config->stack_mode; - handle_error_reply( xcb_configure_window( + handle_error_reply( xcb_configure_window_checked( c, window->u.managed.frame->w, XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE, |