static void pointer_handle_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) { struct display *display = data; struct wl_buffer *buffer; struct wl_cursor *cursor = display->default_cursor; struct wl_cursor_image *image; if (display->window->fullscreen) wl_pointer_set_cursor(pointer, serial, NULL, 0, 0); else if (cursor) { image = display->default_cursor->images[0]; buffer = wl_cursor_image_get_buffer(image); wl_pointer_set_cursor(pointer, serial, display->cursor_surface, image->hotspot_x, image->hotspot_y); wl_surface_attach(display->cursor_surface, buffer, 0, 0); wl_surface_damage(display->cursor_surface, 0, 0, image->width, image->height); wl_surface_commit(display->cursor_surface); } }
static void setCursor(const char* name) { struct wl_buffer* buffer; struct wl_cursor* cursor; struct wl_cursor_image* image; struct wl_surface* surface = _glfw.wl.cursorSurface; cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); if (!cursor) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Standard cursor not found"); return; } image = cursor->images[0]; if (!image) return; buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial, surface, image->hotspot_x, image->hotspot_y); wl_surface_attach(surface, buffer, 0, 0); wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); }
static void check_focus(struct wayland_input *input, wl_fixed_t x, wl_fixed_t y) { struct wayland_compositor *c = input->compositor; int width, height, inside; width = input->output->mode.width; height = input->output->mode.height; inside = c->border.left <= wl_fixed_to_int(x) && wl_fixed_to_int(x) < width + c->border.left && c->border.top <= wl_fixed_to_int(y) && wl_fixed_to_int(y) < height + c->border.top; if (!input->focus && inside) { notify_pointer_focus(&input->base, &input->output->base, x - wl_fixed_from_int(c->border.left), y = wl_fixed_from_int(c->border.top)); wl_pointer_set_cursor(input->pointer, input->enter_serial, NULL, 0, 0); } else if (input->focus && !inside) { notify_pointer_focus(&input->base, NULL, 0, 0); /* FIXME: Should set default cursor here. */ } input->focus = inside; }
static void pointer_handle_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) { struct window *window = data; if (window->registry->pointer) { struct wl_cursor_image *image = window->cursor.cursor->images[0]; wl_pointer_set_cursor(pointer, serial, window->cursor.surface, image->hotspot_x, image->hotspot_y); } }
static void hide_cursor(void) { if (!GLWin.pointer.wl_pointer) return; wl_pointer_set_cursor(GLWin.pointer.wl_pointer, GLWin.pointer.serial, nullptr, 0, 0); }
static void gfx_ctx_wl_show_mouse(void *data, bool state) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; if (!wl->wl_pointer) return; if (state) { struct wl_cursor_image *image = wl->cursor.default_cursor->images[0]; wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, wl->cursor.surface, image->hotspot_x, image->hotspot_y); wl_surface_attach(wl->cursor.surface, wl_cursor_image_get_buffer(image), 0, 0); wl_surface_damage(wl->cursor.surface, 0, 0, image->width, image->height); wl_surface_commit(wl->cursor.surface); } else wl_pointer_set_cursor(wl->wl_pointer, wl->cursor.serial, NULL, 0, 0); wl->cursor.visible = state; }
static void clutter_wayland_handle_pointer_enter (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { ClutterInputDeviceWayland *device = data; ClutterStageCogl *stage_cogl; ClutterEvent *event; ClutterBackend *backend; ClutterBackendWayland *backend_wayland; stage_cogl = wl_surface_get_user_data (surface); device->pointer_focus = stage_cogl; _clutter_input_device_set_stage (CLUTTER_INPUT_DEVICE (device), stage_cogl->wrapper); event = clutter_event_new (CLUTTER_ENTER); event->crossing.stage = stage_cogl->wrapper; event->crossing.time = 0; /* ?! */ event->crossing.x = wl_fixed_to_double(x); event->crossing.y = wl_fixed_to_double(y); event->crossing.source = CLUTTER_ACTOR (stage_cogl->wrapper); event->crossing.device = CLUTTER_INPUT_DEVICE (device); device->x = event->crossing.x; device->y = event->crossing.y; _clutter_event_push (event, FALSE); /* Set the cursor to the cursor loaded at backend initialisation */ backend = clutter_get_default_backend (); backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); wl_pointer_set_cursor (pointer, serial, backend_wayland->cursor_surface, backend_wayland->cursor_x, backend_wayland->cursor_y); wl_surface_attach (backend_wayland->cursor_surface, backend_wayland->cursor_buffer, 0, 0); wl_surface_damage (backend_wayland->cursor_surface, 0, 0, 32, /* XXX: FFS */ 32); wl_surface_commit (backend_wayland->cursor_surface); }
EAPI void ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!input) return; _pointer_update_stop(input); if (input->pointer) wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial, surface, hot_x, hot_y); }
static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { struct pointer_data *pointer_data; pointer_data = wl_pointer_get_user_data(wl_pointer); pointer_data->target_surface = surface; wl_surface_attach(pointer_data->surface, pointer_data->buffer, 0, 0); wl_surface_commit(pointer_data->surface); wl_pointer_set_cursor(wl_pointer, serial, pointer_data->surface, pointer_data->hot_spot_x, pointer_data->hot_spot_y); }
static void _eventd_nd_wl_pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { EventdNdWlSeat *self = data; EventdNdBackendContext *context = self->context; self->surface = wl_surface_get_user_data(surface); if ( context->cursor.surface == NULL ) return; if ( context->cursor.cursor->image_count < 2 ) _eventd_nd_cursor_set_image(context, 0); else _eventd_nd_cursor_frame_callback(context, context->cursor.frame_cb, 0); wl_pointer_set_cursor(self->pointer, serial, context->cursor.surface, context->cursor.image->hotspot_x, context->cursor.image->hotspot_y); }
static void setCursor(_GLFWwindow* window, const char* name) { struct wl_buffer* buffer; struct wl_cursor* cursor; struct wl_cursor_image* image; struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; int scale = 1; if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI) { // We only support up to scale=2 for now, since libwayland-cursor // requires us to load a different theme for each size. scale = 2; theme = _glfw.wl.cursorThemeHiDPI; } cursor = wl_cursor_theme_get_cursor(theme, name); if (!cursor) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Standard cursor not found"); return; } // TODO: handle animated cursors too. image = cursor->images[0]; if (!image) return; buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, surface, image->hotspot_x / scale, image->hotspot_y / scale); wl_surface_set_buffer_scale(surface, scale); wl_surface_attach(surface, buffer, 0, 0); wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); }
/* * This function will effectively set the pointer (mouse) cursor * depending on the GLUT_CURSOR_* choice. */ void fghPointerSetCursor( SFG_Window* window, struct wl_pointer* pointer, uint32_t serial ) { struct wl_cursor_image* image; struct wl_buffer* buffer; image = window->Window.pContext.cursor->images[0]; buffer = wl_cursor_image_get_buffer( image ); wl_surface_attach( window->Window.pContext.cursor_surface, buffer, 0, 0 ); wl_surface_damage( window->Window.pContext.cursor_surface, 0, 0, image->width, image->height ); wl_surface_commit( window->Window.pContext.cursor_surface ); wl_pointer_set_cursor( pointer, serial, window->Window.pContext.cursor_surface, image->hotspot_x, image->hotspot_y ); }
static void pointer_handle_enter (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) { GstGLWindowWaylandEGL *window_egl = data; struct wl_buffer *buffer; struct wl_cursor_image *image = NULL; window_egl->display.serial = serial; if (window_egl->display.default_cursor) { image = window_egl->display.default_cursor->images[0]; buffer = wl_cursor_image_get_buffer (image); wl_pointer_set_cursor (pointer, serial, window_egl->display.cursor_surface, image->hotspot_x, image->hotspot_y); wl_surface_attach (window_egl->display.cursor_surface, buffer, 0, 0); wl_surface_damage (window_egl->display.cursor_surface, 0, 0, image->width, image->height); wl_surface_commit (window_egl->display.cursor_surface); } }