diff options
Diffstat (limited to 'button.c')
-rw-r--r-- | button.c | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -69,12 +69,16 @@ static void set_button_active( struct gwm_window *window, int new ) { static void button_button_press( struct gwm_window *window, xcb_button_press_event_t *ev ) { - if( initial_press( ev ) ) - /* No buttons were pressed; grab initiates. */ - set_button_active( window, TRUE ); + if( !pointer_demux ) { + /* Initiate grab. */ + pointer_demux = window->w; - if( ev->detail == 3 && ( window->u.button.frame->u.frame.child-> - u.managed.protocols & PROTOCOL_DELETE_WINDOW ) ) + set_button_active( window, TRUE ); + } + + if( ( window->u.button.frame->u.frame.child->u.managed.protocols & + PROTOCOL_DELETE_WINDOW ) && ( ev->detail == 3 || + ( ev->state & XCB_BUTTON_MASK_3 ) ) ) /* Button 3 will kill the client, even if it supports WM_DELETE_WINDOW. Change to CURSOR_DESTROY to indicate the distinction. */ xcb_change_active_pointer_grab( c, cursors[ CURSOR_DESTROY ], @@ -87,6 +91,9 @@ static void button_button_press( struct gwm_window *window, static void button_button_release( struct gwm_window *window, xcb_button_release_event_t *ev ) { + if( !pointer_demux ) + return; + if( final_release( ev ) ) { /* Final button released; grab terminates. */ if( button_active ) { @@ -115,6 +122,8 @@ static void button_button_release( struct gwm_window *window, set_button_active( window, FALSE ); } + + pointer_demux = XCB_NONE; } else if( ev->detail == 3 && ( window->u.button.frame->u.frame.child-> u.managed.protocols & PROTOCOL_DELETE_WINDOW ) ) @@ -130,13 +139,21 @@ static void button_button_release( struct gwm_window *window, static void button_enter_notify( struct gwm_window *window, xcb_enter_notify_event_t *ev ) { - set_button_active( window, TRUE ); + if( !pointer_demux ) + return; + + if( ev->event == window->w ) + set_button_active( window, TRUE ); } static void button_leave_notify( struct gwm_window *window, xcb_leave_notify_event_t *ev ) { - set_button_active( window, FALSE ); + if( !pointer_demux ) + return; + + if( ev->event == window->w ) + set_button_active( window, FALSE ); } const event_handler button_handlers[] = { |