aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_wl2/ecore_wl2_input.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-10-25 14:18:58 -0400
committerChris Michael <cp.michael@samsung.com>2016-10-25 14:22:07 -0400
commita80d4ef5a54b9252c3017c858de87ac6a2a39c16 (patch)
tree88a8d8309bbe5d7cd2a0d5c1d74c36c709f0f02d /src/lib/ecore_wl2/ecore_wl2_input.c
parentecore-wl2: Don't call cursor_update_stop function twice. (diff)
downloadefl-a80d4ef5a54b9252c3017c858de87ac6a2a39c16.tar.gz
ecore-wl2: Remove usage of libwayland-cursor
This commit removes usage of libwayland-cursor inside Ecore_Wl2 library. This is done so that EFL Wayland applications can use EFL mouse pointers and not look ugly :) @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_input.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_input.c115
1 files changed, 8 insertions, 107 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c
index 919d424d61..93fdb21802 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -671,14 +671,7 @@ _pointer_cb_frame(void *data, struct wl_callback *callback, unsigned int timesta
input->cursor.frame_cb = NULL;
}
- if (!input->cursor.name)
- {
- _ecore_wl2_input_cursor_set(input, NULL);
- return;
- }
-
- if ((input->cursor.wl_cursor->image_count > 1) &&
- (!input->cursor.frame_cb))
+ if (!input->cursor.frame_cb)
{
input->cursor.frame_cb = wl_surface_frame(input->cursor.surface);
wl_callback_add_listener(input->cursor.frame_cb,
@@ -1146,18 +1139,9 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability
input->wl.pointer = wl_seat_get_pointer(seat);
wl_pointer_set_user_data(input->wl.pointer, input);
wl_pointer_add_listener(input->wl.pointer, &_pointer_listener, input);
-
- if (!input->cursor.surface)
- {
- input->cursor.surface =
- wl_compositor_create_surface(input->display->wl.compositor);
- }
}
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (input->wl.pointer))
{
- if (input->cursor.surface) wl_surface_destroy(input->cursor.surface);
- input->cursor.surface = NULL;
-
#ifdef WL_POINTER_RELEASE_SINCE_VERSION
if (input->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION)
wl_pointer_release(input->wl.pointer);
@@ -1225,73 +1209,25 @@ _ecore_wl2_input_cursor_setup(Ecore_Wl2_Input *input)
tmp = getenv("ECORE_WL_CURSOR_SIZE");
if (tmp) input->cursor.size = atoi(tmp);
- tmp = getenv("ECORE_WL_CURSOR_THEME_NAME");
- eina_stringshare_replace(&input->cursor.theme_name, tmp);
-
if (!input->cursor.name)
input->cursor.name = eina_stringshare_add("left_ptr");
-
- if (input->display->wl.shm)
- {
- input->cursor.theme =
- wl_cursor_theme_load(input->cursor.theme_name, input->cursor.size,
- input->display->wl.shm);
- }
}
-static Eina_Bool
+Eina_Bool
_ecore_wl2_input_cursor_update(void *data)
{
Ecore_Wl2_Input *input;
- struct wl_cursor_image *image;
- struct wl_buffer *buffer;
- unsigned int delay = 0;
input = data;
if (!input) return EINA_FALSE;
- image = input->cursor.wl_cursor->images[input->cursor.index];
- if (!image) return EINA_FALSE;
-
- buffer = wl_cursor_image_get_buffer(image);
- if (buffer)
- {
- if (input->wl.pointer)
- wl_pointer_set_cursor(input->wl.pointer, input->pointer.enter_serial,
- input->cursor.surface,
- image->hotspot_x, image->hotspot_y);
-
- wl_surface_attach(input->cursor.surface, buffer, 0, 0);
-#ifdef WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION
- if (input->display->wl.compositor_version >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
- wl_surface_damage_buffer(input->cursor.surface,
- 0, 0, image->width, image->height);
- else
-#endif
- wl_surface_damage(input->cursor.surface,
- 0, 0, image->width, image->height);
- wl_surface_commit(input->cursor.surface);
-
- if ((input->cursor.wl_cursor->image_count > 1) &&
- (!input->cursor.frame_cb))
- _pointer_cb_frame(input, NULL, 0);
- }
-
- if (input->cursor.wl_cursor->image_count <= 1)
- return ECORE_CALLBACK_CANCEL;
-
- delay = image->delay;
- input->cursor.index =
- (input->cursor.index + 1) % input->cursor.wl_cursor->image_count;
+ if (input->wl.pointer)
+ wl_pointer_set_cursor(input->wl.pointer, input->pointer.enter_serial,
+ input->cursor.surface,
+ input->cursor.hot_x, input->cursor.hot_y);
- if (!input->cursor.timer)
- {
- input->cursor.timer =
- ecore_timer_loop_add(delay / 1000.0,
- _ecore_wl2_input_cursor_update, input);
- }
- else
- ecore_timer_interval_set(input->cursor.timer, delay / 1000.0);
+ if (!input->cursor.frame_cb)
+ _pointer_cb_frame(input, NULL, 0);
return ECORE_CALLBACK_RENEW;
}
@@ -1356,11 +1292,7 @@ _ecore_wl2_input_del(Ecore_Wl2_Input *input)
_ecore_wl2_input_cursor_update_stop(input);
- if (input->cursor.theme) wl_cursor_theme_destroy(input->cursor.theme);
- if (input->cursor.surface) wl_surface_destroy(input->cursor.surface);
if (input->cursor.name) eina_stringshare_del(input->cursor.name);
- if (input->cursor.theme_name)
- eina_stringshare_del(input->cursor.theme_name);
if (input->data.types.data)
{
@@ -1392,41 +1324,10 @@ _ecore_wl2_input_del(Ecore_Wl2_Input *input)
void
_ecore_wl2_input_cursor_set(Ecore_Wl2_Input *input, const char *cursor)
{
- struct wl_cursor *wl_cursor;
-
_ecore_wl2_input_cursor_update_stop(input);
eina_stringshare_replace(&input->cursor.name, cursor);
if (!cursor) eina_stringshare_replace(&input->cursor.name, "left_ptr");
-
- wl_cursor =
- wl_cursor_theme_get_cursor(input->cursor.theme, input->cursor.name);
- if (!wl_cursor)
- {
- wl_cursor =
- wl_cursor_theme_get_cursor(input->cursor.theme, "left_ptr");
- }
-
- if (!wl_cursor)
- {
- ERR("Could not get Wayland Cursor from Cursor Theme: %s",
- input->cursor.theme_name);
- return;
- }
-
- input->cursor.wl_cursor = wl_cursor;
-
- if ((!wl_cursor->images) || (!wl_cursor->images[0]))
- {
- if (input->wl.pointer)
- wl_pointer_set_cursor(input->wl.pointer, input->pointer.enter_serial,
- NULL, 0, 0);
- return;
- }
-
- input->cursor.index = 0;
-
- _ecore_wl2_input_cursor_update(input);
}
void