ecore-wl2: Don't send focus in/out events based on keyboard enter/leave

We should not be sending focus events based on keyboard behaviour, but
rather send them according to xdg shell activate status. This makes
our focus behaviour more "standards" compliant.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2017-02-08 11:51:21 -05:00
parent 62a22fd401
commit 4b2188103d
3 changed files with 33 additions and 18 deletions

View File

@ -408,10 +408,14 @@ _ecore_wl2_input_mouse_up_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window,
_input_event_cb_free, ev->dev);
}
static void
_ecore_wl2_input_focus_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
void
_ecore_wl2_input_focus_in_send(Ecore_Wl2_Window *window)
{
Ecore_Wl2_Event_Focus_In *ev;
Ecore_Wl2_Input *input;
input = ecore_wl2_window_input_get(window);
if (!input) return;
ev = calloc(1, sizeof(Ecore_Wl2_Event_Focus_In));
if (!ev) return;
@ -423,10 +427,14 @@ _ecore_wl2_input_focus_in_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
ev->dev);
}
static void
_ecore_wl2_input_focus_out_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
void
_ecore_wl2_input_focus_out_send(Ecore_Wl2_Window *window)
{
Ecore_Wl2_Event_Focus_Out *ev;
Ecore_Wl2_Input *input;
input = ecore_wl2_window_input_get(window);
if (!input) return;
ev = calloc(1, sizeof(Ecore_Wl2_Event_Focus_Out));
if (!ev) return;
@ -846,15 +854,12 @@ _keyboard_cb_enter(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigne
input->focus.keyboard = window;
window->input = input;
_ecore_wl2_input_focus_in_send(input, window);
}
static void
_keyboard_cb_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface)
_keyboard_cb_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface EINA_UNUSED)
{
Ecore_Wl2_Input *input;
Ecore_Wl2_Window *window;
input = data;
if (!input) return;
@ -866,13 +871,6 @@ _keyboard_cb_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigne
input->repeat.time = 0;
if (input->repeat.timer) ecore_timer_del(input->repeat.timer);
input->repeat.timer = NULL;
/* find the window which this surface belongs to */
window = _ecore_wl2_display_window_surface_find(input->display, surface);
if (!window) return;
_ecore_wl2_input_focus_out_send(input, window);
input->focus.keyboard = NULL;
}
@ -1582,7 +1580,6 @@ ecore_wl2_input_seat_get(Ecore_Wl2_Input *input)
EAPI Ecore_Wl2_Seat_Capabilities
ecore_wl2_input_seat_capabilities_get(Ecore_Wl2_Input *input)
{
Ecore_Wl2_Seat_Capabilities cap = ECORE_WL2_SEAT_CAPABILITIES_NONE;
EINA_SAFETY_ON_NULL_RETURN_VAL(input, cap);

View File

@ -472,6 +472,9 @@ void _ecore_wl_window_semi_free(Ecore_Wl2_Window *window);
void _ecore_wl2_offer_unref(Ecore_Wl2_Offer *offer);
void _ecore_wl2_input_focus_in_send(Ecore_Wl2_Window *window);
void _ecore_wl2_input_focus_out_send(Ecore_Wl2_Window *window);
EAPI extern int _ecore_wl2_event_window_www;
EAPI extern int _ecore_wl2_event_window_www_drag;

View File

@ -146,6 +146,11 @@ _xdg_surface_cb_configure(void *data, struct xdg_surface *xdg_surface EINA_UNUSE
}
}
if (win->focused)
_ecore_wl2_input_focus_in_send(win);
else
_ecore_wl2_input_focus_out_send(win);
win->configure_serial = serial;
if ((win->geometry.w == w) && (win->geometry.h == h))
w = h = 0;
@ -238,6 +243,11 @@ _zxdg_toplevel_cb_configure(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel E
}
}
if (win->focused)
_ecore_wl2_input_focus_in_send(win);
else
_ecore_wl2_input_focus_out_send(win);
win->configure_serial = wl_display_get_serial(win->display->wl.display);
if ((win->geometry.w == width) && (win->geometry.h == height))
width = height = 0;
@ -1298,11 +1308,16 @@ ecore_wl2_window_input_get(Ecore_Wl2_Window *window)
EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(window->display, NULL);
if (window->input) return window->input;
if (window->input)
return window->input;
else if ((window->parent) && (window->parent->input))
return window->parent->input;
EINA_INLIST_FOREACH(window->display->inputs, input)
{
if (input->focus.pointer) return input;
if ((input->wl.pointer) || (input->wl.keyboard) ||
(input->wl.touch))
return input;
}
return NULL;