Commit a3709b93 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Alexandre Julliard

winewayland.drv: Add initial stub for wl_pointer handling.

Track the availability of a pointer device for a seat. For now we assume only a single seat and pointer.
parent 0992d097
......@@ -9,6 +9,7 @@ SOURCES = \
version.rc \
wayland.c \
wayland_output.c \
wayland_pointer.c \
wayland_surface.c \
waylanddrv_main.c \
window.c \
......
......@@ -54,6 +54,29 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener =
};
/**********************************************************************
* wl_seat handling
*/
static void wl_seat_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
{
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !process_wayland.wl_pointer)
wayland_pointer_init(wl_seat_get_pointer(seat));
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && process_wayland.wl_pointer)
wayland_pointer_deinit();
}
static void wl_seat_handle_name(void *data, struct wl_seat *seat, const char *name)
{
}
static const struct wl_seat_listener seat_listener =
{
wl_seat_handle_capabilities,
wl_seat_handle_name
};
/**********************************************************************
* Registry handling
*/
......@@ -98,6 +121,17 @@ static void registry_handle_global(void *data, struct wl_registry *registry,
{
process_wayland.wl_shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
}
else if (strcmp(interface, "wl_seat") == 0)
{
if (process_wayland.wl_seat)
{
WARN("Only a single seat is currently supported, ignoring additional seats.\n");
return;
}
process_wayland.wl_seat = wl_registry_bind(registry, id, &wl_seat_interface,
version < 5 ? version : 5);
wl_seat_add_listener(process_wayland.wl_seat, &seat_listener, NULL);
}
}
static void registry_handle_global_remove(void *data, struct wl_registry *registry,
......@@ -116,6 +150,15 @@ static void registry_handle_global_remove(void *data, struct wl_registry *regist
return;
}
}
if (process_wayland.wl_seat &&
wl_proxy_get_id((struct wl_proxy *)process_wayland.wl_seat) == id)
{
TRACE("removing seat\n");
if (process_wayland.wl_pointer) wayland_pointer_deinit();
wl_seat_release(process_wayland.wl_seat);
process_wayland.wl_seat = NULL;
}
}
static const struct wl_registry_listener registry_listener = {
......
/*
* Wayland pointer handling
*
* Copyright (c) 2020 Alexandros Frantzis for Collabora Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include "waylanddrv.h"
static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
{
}
static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *wl_surface,
wl_fixed_t sx, wl_fixed_t sy)
{
}
static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *wl_surface)
{
}
static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button,
uint32_t state)
{
}
static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
}
static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer)
{
}
static void pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer,
uint32_t axis_source)
{
}
static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
uint32_t time, uint32_t axis)
{
}
static void pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
uint32_t axis, int32_t discrete)
{
}
static const struct wl_pointer_listener pointer_listener =
{
pointer_handle_enter,
pointer_handle_leave,
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
pointer_handle_frame,
pointer_handle_axis_source,
pointer_handle_axis_stop,
pointer_handle_axis_discrete
};
void wayland_pointer_init(struct wl_pointer *wl_pointer)
{
process_wayland.wl_pointer = wl_pointer;
wl_pointer_add_listener(process_wayland.wl_pointer, &pointer_listener, NULL);
}
void wayland_pointer_deinit(void)
{
wl_pointer_release(process_wayland.wl_pointer);
process_wayland.wl_pointer = NULL;
}
......@@ -66,6 +66,8 @@ struct wayland
struct wl_compositor *wl_compositor;
struct xdg_wm_base *xdg_wm_base;
struct wl_shm *wl_shm;
struct wl_seat *wl_seat;
struct wl_pointer *wl_pointer;
struct wl_list output_list;
/* Protects the output_list and the wayland_output.current states. */
pthread_mutex_t output_mutex;
......@@ -168,6 +170,13 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *surfac
void wayland_window_flush(HWND hwnd) DECLSPEC_HIDDEN;
/**********************************************************************
* Wayland pointer
*/
void wayland_pointer_init(struct wl_pointer *wl_pointer) DECLSPEC_HIDDEN;
void wayland_pointer_deinit(void) DECLSPEC_HIDDEN;
/**********************************************************************
* Helpers
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment