From: Mike Blumenkrantz Date: Wed, 1 Jul 2015 19:24:05 +0000 (-0400) Subject: redo all x11 client mouse grabbing for focus X-Git-Tag: upstream/0.20.0~657 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33ec963be29721ced020bb96319933b5a9f70e90;p=platform%2Fupstream%2Fenlightenment.git redo all x11 client mouse grabbing for focus I did an audit of this and it seemed that it no longer served the purpose for which it was originally intended. specifically, this is for enforcing click: raise/focus options, and so grabs must be in play on client windows only when they are not focused to ensure that we get mouse events and can then focus them. the grabs must then be removed once the window has focus to avoid spurious mouse eventing --- diff --git a/src/bin/e_comp_x.c b/src/bin/e_comp_x.c index fe126be..fb7a648 100644 --- a/src/bin/e_comp_x.c +++ b/src/bin/e_comp_x.c @@ -179,9 +179,9 @@ static void _e_comp_x_focus_setup(E_Client *ec) { if (_e_comp_x_client_data_get(ec)->button_grabbed) return; - if (!((e_client_focus_policy_click(ec)) || + if ((!e_client_focus_policy_click(ec)) || (e_config->always_click_to_raise) || - (e_config->always_click_to_focus))) return; + (e_config->always_click_to_focus)) return; ecore_x_window_button_grab(_e_comp_x_client_util_win_get(ec), 1, ECORE_X_EVENT_MASK_MOUSE_DOWN | ECORE_X_EVENT_MASK_MOUSE_UP | @@ -2117,14 +2117,20 @@ _e_comp_x_mapping_change(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_X_E Ecore_X_Window win; if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_X) continue; - win = _e_comp_x_client_util_pwin_get(ec); + win = _e_comp_x_client_util_win_get(ec); if ((!_e_comp_x_client_data_get(ec)->first_map) || (!_e_comp_x_client_data_get(ec)->reparented)) continue; - _e_comp_x_focus_setdown(ec); - e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, win); - e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, win); - e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, win); - e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, win); - _e_comp_x_focus_setup(ec); + if (ec->focused) + { + _e_comp_x_focus_setup(ec); + _e_comp_x_focus_setdown(ec); + } + else + { + _e_comp_x_focus_setdown(ec); + _e_comp_x_focus_setup(ec); + e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, win); + } } e_comp_canvas_keys_grab(); return ECORE_CALLBACK_PASS_ON; @@ -2899,9 +2905,14 @@ _e_comp_x_hook_client_pre_frame_assign(void *d EINA_UNUSED, E_Client *ec) ecore_x_window_show(pwin); } - _e_comp_x_focus_setup(ec); - e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, pwin); - e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, pwin); + if (ec->focused) + _e_comp_x_focus_setdown(ec); + else + { + _e_comp_x_focus_setup(ec); + e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, win); + } _e_comp_x_client_evas_init(ec); if (ec->netwm.ping && (!ec->ping_poller)) e_client_ping(ec); @@ -3145,7 +3156,10 @@ _e_comp_x_hook_client_fetch(void *d EINA_UNUSED, E_Client *ec) else if (ec->netwm.type == E_WINDOW_TYPE_DESKTOP) { ec->focus_policy_override = E_FOCUS_CLICK; + _e_comp_x_focus_setdown(ec); _e_comp_x_focus_setup(ec); + e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, win); if (!ec->netwm.state.skip_pager) { ec->netwm.state.skip_pager = 1; @@ -4218,6 +4232,7 @@ static void _e_comp_x_hook_client_focus_unset(void *d EINA_UNUSED, E_Client *ec) { E_COMP_X_PIXMAP_CHECK; + _e_comp_x_focus_setup(ec); _e_comp_x_focus_check(); } @@ -4225,6 +4240,7 @@ static void _e_comp_x_hook_client_focus_set(void *d EINA_UNUSED, E_Client *ec) { focus_time = ecore_x_current_time_get(); + _e_comp_x_focus_setdown(ec); if (!_e_comp_x_client_has_xwindow(ec)) { e_grabinput_focus(e_comp->ee_win, E_FOCUS_METHOD_PASSIVE); @@ -4307,9 +4323,9 @@ _e_comp_x_hook_client_del(void *d EINA_UNUSED, E_Client *ec) ecore_x_window_prop_card32_set(win, E_ATOM_MANAGED, &visible, 1); if ((!ec->already_unparented) && cd && cd->reparented) { + _e_comp_x_focus_setdown(ec); e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, pwin); e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, pwin); - _e_comp_x_focus_setdown(ec); if (!cd->deleted) { if (stopping) @@ -4906,9 +4922,14 @@ _e_comp_x_bindings_grab_cb(void) EINA_LIST_FOREACH(e_comp->clients, l, ec) { if (e_client_util_ignored_get(ec)) continue; - _e_comp_x_focus_setup(ec); - e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_pwin_get(ec)); - e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_pwin_get(ec)); + if (ec->focused) + _e_comp_x_focus_setdown(ec); + else + { + _e_comp_x_focus_setup(ec); + e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_win_get(ec)); + e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_win_get(ec)); + } } } @@ -4920,10 +4941,16 @@ _e_comp_x_bindings_ungrab_cb(void) EINA_LIST_FOREACH(e_comp->clients, l, ec) { + Ecore_X_Window win; + if (e_client_util_ignored_get(ec)) continue; - _e_comp_x_focus_setdown(ec); - e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_pwin_get(ec)); - e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, _e_comp_x_client_util_pwin_get(ec)); + win = _e_comp_x_client_util_win_get(ec); + ecore_x_window_button_ungrab(win, 1, 0, 1); + ecore_x_window_button_ungrab(win, 2, 0, 1); + ecore_x_window_button_ungrab(win, 3, 0, 1); + e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, win); + _e_comp_x_client_data_get(ec)->button_grabbed = 0; } } diff --git a/src/bin/e_focus.c b/src/bin/e_focus.c index fc4cfbc..04f8bed 100644 --- a/src/bin/e_focus.c +++ b/src/bin/e_focus.c @@ -61,50 +61,13 @@ e_focus_event_mouse_up(E_Client *ec EINA_UNUSED) } E_API void -e_focus_event_focus_in(E_Client *ec) +e_focus_event_focus_in(E_Client *ec EINA_UNUSED) { - if ((e_client_focus_policy_click(ec)) && - (!e_config->always_click_to_raise) && - (!e_config->always_click_to_focus)) - { - if (!ec->button_grabbed) return; - e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, e_client_util_pwin_get(ec)); - e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, e_client_util_pwin_get(ec)); -#ifndef HAVE_WAYLAND_ONLY - ecore_x_window_button_ungrab(e_client_util_win_get(ec), 1, 0, 1); - ecore_x_window_button_ungrab(e_client_util_win_get(ec), 2, 0, 1); - ecore_x_window_button_ungrab(e_client_util_win_get(ec), 3, 0, 1); -#endif - e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, e_client_util_pwin_get(ec)); - e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, e_client_util_pwin_get(ec)); - ec->button_grabbed = 0; - } } E_API void -e_focus_event_focus_out(E_Client *ec) +e_focus_event_focus_out(E_Client *ec EINA_UNUSED) { - if ((e_client_focus_policy_click(ec)) && - (!e_config->always_click_to_raise) && - (!e_config->always_click_to_focus)) - { - if (ec->button_grabbed) return; -#ifndef HAVE_WAYLAND_ONLY - ecore_x_window_button_grab(e_client_util_win_get(ec), 1, - ECORE_X_EVENT_MASK_MOUSE_DOWN | - ECORE_X_EVENT_MASK_MOUSE_UP | - ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1); - ecore_x_window_button_grab(e_client_util_win_get(ec), 2, - ECORE_X_EVENT_MASK_MOUSE_DOWN | - ECORE_X_EVENT_MASK_MOUSE_UP | - ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1); - ecore_x_window_button_grab(e_client_util_win_get(ec), 3, - ECORE_X_EVENT_MASK_MOUSE_DOWN | - ECORE_X_EVENT_MASK_MOUSE_UP | - ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1); -#endif - ec->button_grabbed = 1; - } } /* local subsystem functions */