diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 3de00b254b..e2aee99c52 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -928,59 +928,6 @@ EAPI Eina_Bool ecore_wl2_window_iconified_get(Ecore_Wl2_Window *window); */ EAPI void ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool iconified); -/** - * Retrieves the mouse position of the current window. - * - * @param window The window on which to retrieve the mouse position - * @param x where to return the horizontal position. May be NULL. Returns 0 on error. - * @param y where to return the vertical position. May be NULL. Returns 0 on error. - * - * @ingroup Ecore_Wl2_Window_Group - * @see ecore_wl2_window_pointer_device_xy_get - * @since 1.17 - */ -EAPI void ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, int *x, int *y); - -/** - * Retrieves the mouse position of the current window. - * - * @param window The window on which to retrieve the mouse position. - * @param pointer The Efl.Input.Pointer device to fetch the position. - * @param x where to return the horizontal position. May be NULL. Returns 0 on error. - * @param y where to return the vertical position. May be NULL. Returns 0 on error. - * @ingroup Ecore_Wl2_Window_Group - * @since 1.19 - */ -EAPI void ecore_wl2_window_pointer_device_xy_get(Ecore_Wl2_Window *window, const Eo *pointer, int *x, int *y); - -/** - * Set a given wl_surface to use as the pointer on a window - * - * @param window The window to set this surface as the pointer on - * @param surface The surface to use as the pointer - * @param hot_x The x coordinate to use as the cursor hot spot - * @param hot_y The y coordinate to use as the cursor hot spot - * - * @ingroup Ecore_Wl2_Window_Group - * @since 1.17 - */ -EAPI void ecore_wl2_window_pointer_set(Ecore_Wl2_Window *window, struct wl_surface *surface, int hot_x, int hot_y); - -/** - * Set a specific cursor on a given window - * - * @brief This function will try to find a matching cursor inside the existing - * cursor theme and set the pointer which is over the given window to be - * the specified cursor - * - * @param window The window to set the cursor on - * @param cursor The name of the cursor to try and set - * - * @ingroup Ecore_Wl2_Window_Group - * @since 1.17 - */ -EAPI void ecore_wl2_window_cursor_from_name_set(Ecore_Wl2_Window *window, const char *cursor); - /** * Set the type of a given window * @@ -1074,6 +1021,45 @@ EAPI Eina_Bool ecore_wl2_input_keyboard_repeat_get(const Ecore_Wl2_Input *input, * @since 1.20 */ EAPI Eo *ecore_wl2_input_seat_device_get(const Ecore_Wl2_Input *input, const Ecore_Wl2_Window *window); + +/** + * Retrieves the mouse position of the seat + * + * @param input The seat + * @param x where to return the horizontal position. May be NULL. Returns 0 on error. + * @param y where to return the vertical position. May be NULL. Returns 0 on error. + * @return @c EINA_TRUE if coords were successfully retrieved + * + * @since 1.20 + */ +EAPI Eina_Bool ecore_wl2_input_pointer_xy_get(const Ecore_Wl2_Input *input, int *x, int *y); + +/** + * Set a given wl_surface to use as the pointer on a seat + * + * @param input The seat to set this surface as the pointer on + * @param surface The surface to use as the pointer + * @param hot_x The x coordinate to use as the cursor hot spot + * @param hot_y The y coordinate to use as the cursor hot spot + * + * @since 1.20 + */ +EAPI void ecore_wl2_input_pointer_set(Ecore_Wl2_Input *input, struct wl_surface *surface, int hot_x, int hot_y); + +/** + * Set a specific cursor on a given seat + * + * @brief This function will try to find a matching cursor inside the existing + * cursor theme and set the pointer for the specified seat to be + * the specified cursor + * + * @param input The seat to set the cursor on + * @param cursor The name of the cursor to try and set + * + * @since 1.20 + */ +EAPI void ecore_wl2_input_cursor_from_name_set(Ecore_Wl2_Input *input, const char *cursor); + /** * @defgroup Ecore_Wl2_Dnd_Group Wayland Library Drag-n-Drop Functions * @ingroup Ecore_Wl2_Group diff --git a/src/lib/ecore_wl2/ecore_wl2_dnd.c b/src/lib/ecore_wl2/ecore_wl2_dnd.c index fc0dfd2306..9196c10cf7 100644 --- a/src/lib/ecore_wl2/ecore_wl2_dnd.c +++ b/src/lib/ecore_wl2/ecore_wl2_dnd.c @@ -486,7 +486,7 @@ ecore_wl2_dnd_drag_start(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, Ecore osurface, dsurface, input->display->serial); input->data.drag.serial = input->display->serial; - ecore_wl2_window_cursor_from_name_set(window, "move"); + ecore_wl2_input_cursor_from_name_set(input, "move"); } return input->data.drag.serial; } diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 324edb2faf..935f09cbe7 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -1698,3 +1698,35 @@ ecore_wl2_input_seat_device_get(const Ecore_Wl2_Input *input, const Ecore_Wl2_Wi devices = _ecore_wl2_devices_get(input, window->id); return devices ? devices->seat_dev : NULL; } + +EAPI void +ecore_wl2_input_pointer_set(Ecore_Wl2_Input *input, struct wl_surface *surface, int hot_x, int hot_y) +{ + EINA_SAFETY_ON_NULL_RETURN(input); + + input->cursor.surface = surface; + input->cursor.hot_x = hot_x; + input->cursor.hot_y = hot_y; + + _ecore_wl2_input_cursor_update(input); +} + +EAPI void +ecore_wl2_input_cursor_from_name_set(Ecore_Wl2_Input *input, const char *cursor) +{ + EINA_SAFETY_ON_NULL_RETURN(input); + _ecore_wl2_input_cursor_set(input, cursor); +} + +EAPI Eina_Bool +ecore_wl2_input_pointer_xy_get(const Ecore_Wl2_Input *input, int *x, int *y) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE); + + if (x) *x = 0; + if (y) *y = 0; + if (!input->wl.pointer) return EINA_FALSE; + if (x) *x = input->pointer.sx; + if (y) *y = input->pointer.sy; + return EINA_TRUE; +} diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 3d56fb7326..a3e84f5ab1 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -1143,80 +1143,10 @@ ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool iconified) } EAPI void -ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, int *x, int *y) +ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type) { - Ecore_Wl2_Input *input; - EINA_SAFETY_ON_NULL_RETURN(window); - - if (x) *x = 0; - if (y) *y = 0; - - input = ecore_wl2_window_input_get(window); - if (!input) return; - - if (x) *x = input->pointer.sx; - if (y) *y = input->pointer.sy; -} - -EAPI void -ecore_wl2_window_pointer_device_xy_get(Ecore_Wl2_Window *window, const Eo *pointer, int *x, int *y) -{ - Ecore_Wl2_Input_Devices *devs; - Eina_List *l; - Ecore_Wl2_Input *input; - - EINA_SAFETY_ON_NULL_RETURN(window); - EINA_SAFETY_ON_NULL_RETURN(pointer); - - if (x) *x = 0; - if (y) *y = 0; - - EINA_INLIST_FOREACH(window->display->inputs, input) - { - if (!input->wl.pointer) - continue; - - EINA_LIST_FOREACH(input->devices_list, l, devs) - { - if ((devs->window_id == window->id) && - (devs->pointer_dev == pointer)) - { - if (x) *x = input->pointer.sx; - if (y) *y = input->pointer.sy; - } - } - } -} - -EAPI void -ecore_wl2_window_pointer_set(Ecore_Wl2_Window *window, struct wl_surface *surface, int hot_x, int hot_y) -{ - Ecore_Wl2_Input *input; - - EINA_SAFETY_ON_NULL_RETURN(window); - - input = ecore_wl2_window_input_get(window); - if (!input) return; - - input->cursor.surface = surface; - input->cursor.hot_x = hot_x; - input->cursor.hot_y = hot_y; - - _ecore_wl2_input_cursor_update(input); -} - -EAPI void -ecore_wl2_window_cursor_from_name_set(Ecore_Wl2_Window *window, const char *cursor) -{ - Ecore_Wl2_Input *input; - - EINA_SAFETY_ON_NULL_RETURN(window); - - input = ecore_wl2_window_input_get(window); - if (!input) return; - - _ecore_wl2_input_cursor_set(input, cursor); + window->type = type; } EAPI void diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 921767aab7..0d73c15647 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -3128,8 +3128,14 @@ _elm_win_wl_cursor_set(Evas_Object *obj, const char *cursor) } if ((sd->wl.win) && (sd->pointer.surf) && (sd->pointer.visible)) - ecore_wl2_window_pointer_set(sd->wl.win, sd->pointer.surf, - sd->pointer.hot_x, sd->pointer.hot_y); + { + /* FIXME: multiseat */ + Ecore_Wl2_Input *input; + + input = ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(sd->wl.win), "default"); + EINA_SAFETY_ON_NULL_RETURN(input); + ecore_wl2_input_pointer_set(input, sd->pointer.surf, sd->pointer.hot_x, sd->pointer.hot_y); + } } #endif @@ -4080,7 +4086,7 @@ _elm_win_frame_cb_menu(void *data, if (x < 0) x += wx; if (y < 0) y += wy; - input = ecore_wl2_window_input_get(sd->wl.win); + input = ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(sd->wl.win), "default"); if (sd->wl.win->zxdg_toplevel) zxdg_toplevel_v6_show_window_menu(sd->wl.win->zxdg_toplevel, diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c index 3ac197052b..42ec69772b 100644 --- a/src/lib/elementary/elm_cnp.c +++ b/src/lib/elementary/elm_cnp.c @@ -2880,6 +2880,18 @@ _wl_sel_obj_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_i if (dragwidget == obj) dragwidget = NULL; } +static Ecore_Wl2_Input * +_wl_default_seat_get(Ecore_Wl2_Window *win, Evas_Object *obj) +{ + Eo *seat; + + if (!obj) return ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(win), "default"); + seat = evas_device_get(evas_object_evas_get(obj), "default"); + EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL); + return ecore_wl2_display_input_find(ecore_wl2_window_display_get(win), + evas_device_seat_id_get(seat)); +} + static void _wl_sel_obj_del2(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { @@ -2973,7 +2985,7 @@ _wl_elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Form } types[count - 1] = 0; - sel->selection_serial = ecore_wl2_dnd_selection_set(ecore_wl2_window_input_get(win), types); + sel->selection_serial = ecore_wl2_dnd_selection_set(_wl_default_seat_get(win, obj), types); free(types); return EINA_TRUE; @@ -3098,7 +3110,7 @@ _wl_elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type selection, Elm_Se if (selection == ELM_SEL_TYPE_XDND) return EINA_FALSE; - input = ecore_wl2_window_input_get(win); + input = _wl_default_seat_get(win, (void*)obj); offer = ecore_wl2_dnd_selection_get(input); //there can be no selection available @@ -3173,7 +3185,7 @@ _wl_elm_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type selection EINA_UNUSED ELM_SAFE_FREE(sel->selbuf, free); sel->buflen = 0; /* sel->clear(); */ - sel->selection_serial = ecore_wl2_dnd_selection_clear(ecore_wl2_window_input_get(_wl_elm_widget_window_get(obj))); + sel->selection_serial = ecore_wl2_dnd_selection_clear(_wl_default_seat_get(_wl_elm_widget_window_get(obj), obj)); return EINA_TRUE; } @@ -3426,7 +3438,7 @@ _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data, types[nb_types] = NULL; win = _wl_elm_widget_window_get(obj); - ecore_wl2_dnd_drag_types_set(ecore_wl2_window_input_get(win), types); + ecore_wl2_dnd_drag_types_set(_wl_default_seat_get(win, obj), types); /* set the drag data used when a drop occurs */ free(wl_cnp_selection.selbuf); @@ -3517,7 +3529,7 @@ _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data, parent = ecore_evas_wayland2_window_get(ee); } - wl_cnp_selection.drag_serial = ecore_wl2_dnd_drag_start(ecore_wl2_window_input_get(win), parent, win); + wl_cnp_selection.drag_serial = ecore_wl2_dnd_drag_start(_wl_default_seat_get(win, obj), parent, win); return EINA_TRUE; } @@ -3772,7 +3784,7 @@ _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) } win = ecore_wl2_display_window_find(_elm_wl_display, ev->win); - ecore_wl2_dnd_drag_end(ecore_wl2_window_input_get(win)); + ecore_wl2_dnd_drag_end(_wl_default_seat_get(win, NULL)); return ECORE_CALLBACK_PASS_ON; } @@ -3812,7 +3824,7 @@ _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) doaccept = EINA_FALSE; win = ecore_wl2_display_window_find(_elm_wl_display, ev->win); - ecore_wl2_input_ungrab(ecore_wl2_window_input_get(win)); + ecore_wl2_input_ungrab(_wl_default_seat_get(win, NULL)); return ECORE_CALLBACK_PASS_ON; } @@ -3863,7 +3875,7 @@ _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Offer_Data_Ready } } win = _wl_elm_widget_window_get(sel->requestwidget); - ecore_wl2_dnd_drag_end(ecore_wl2_window_input_get(win)); + ecore_wl2_dnd_drag_end(_wl_default_seat_get(win, NULL)); if (tmp_info) _tmpinfo_free(tmp_info); free(ddata.data); return; @@ -3871,7 +3883,7 @@ _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Offer_Data_Ready } win = _wl_elm_widget_window_get(sel->requestwidget); - ecore_wl2_dnd_drag_end(ecore_wl2_window_input_get(win)); + ecore_wl2_dnd_drag_end(_wl_default_seat_get(win, NULL)); savedtypes.textreq = 0; } @@ -5255,7 +5267,7 @@ elm_selection_selection_has_owner(Evas_Object *obj) win = _wl_elm_widget_window_get(obj); if (win) - return !!ecore_wl2_dnd_selection_get(ecore_wl2_window_input_get(win)); + return !!ecore_wl2_dnd_selection_get(_wl_default_seat_get(win, obj)); #endif return _local_elm_selection_selection_has_owner(obj); } @@ -5784,7 +5796,7 @@ elm_drag_cancel(Evas_Object *obj) win = _wl_elm_widget_window_get(obj); if (win) - ecore_wl2_dnd_drag_end(ecore_wl2_window_input_get(win)); + ecore_wl2_dnd_drag_end(_wl_default_seat_get(win, obj)); #endif end: diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c index 6f5279424f..68f64b3a54 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c @@ -1095,22 +1095,30 @@ static void _ecore_evas_wl_common_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y) { Ecore_Evas_Engine_Wl_Data *wdata; + Ecore_Wl2_Input *input; LOGFN(__FILE__, __LINE__, __FUNCTION__); wdata = ee->engine.data; - ecore_wl2_window_pointer_xy_get(wdata->win, x, y); + input = ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(wdata->win), "default"); + if (input) ecore_wl2_input_pointer_xy_get(input, x, y); } static void _ecore_evas_wl_common_pointer_device_xy_get(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y) { Ecore_Evas_Engine_Wl_Data *wdata; + Ecore_Wl2_Input *input; + const Eo *seat; LOGFN(__FILE__, __LINE__, __FUNCTION__); wdata = ee->engine.data; - ecore_wl2_window_pointer_device_xy_get(wdata->win, pointer, x, y); + seat = evas_device_parent_get(pointer); + EINA_SAFETY_ON_NULL_RETURN(seat); + input = ecore_wl2_display_input_find(ecore_wl2_window_display_get(wdata->win), evas_device_seat_id_get(seat)); + EINA_SAFETY_ON_NULL_RETURN(input); + ecore_wl2_input_pointer_xy_get(input, x, y); } static void @@ -1233,13 +1241,15 @@ _ecore_evas_wl_common_aspect_set(Ecore_Evas *ee, double aspect) } static void -_ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer EINA_UNUSED, int hot_x EINA_UNUSED, int hot_y EINA_UNUSED) +_ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer EINA_UNUSED, int hot_x, int hot_y) { Ecore_Evas_Engine_Wl_Data *wdata; + Ecore_Wl2_Input *input; wdata = ee->engine.data; - if (obj != _ecore_evas_default_cursor_image_get(ee)) - ecore_wl2_window_pointer_set(wdata->win, NULL, 0, 0); + if (obj == _ecore_evas_default_cursor_image_get(ee)) return; + input = ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(wdata->win), "default"); + if (input) ecore_wl2_input_pointer_set(input, NULL, hot_x, hot_y); } static void diff --git a/src/modules/ecore_imf/wayland/wayland_imcontext.c b/src/modules/ecore_imf/wayland/wayland_imcontext.c index 6c740123f3..76bd728db8 100644 --- a/src/modules/ecore_imf/wayland/wayland_imcontext.c +++ b/src/modules/ecore_imf/wayland/wayland_imcontext.c @@ -374,7 +374,9 @@ static void set_focus(Ecore_IMF_Context *ctx) { WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx); - Ecore_Wl2_Input *input = ecore_wl2_window_input_get(imcontext->window); + Ecore_Wl2_Input *input; + + input = ecore_wl2_display_input_find_by_name(ecore_wl2_window_display_get(imcontext->window), "default"); if (!input) return;