Commit aba21024 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

xdg-shell: keep track of wl_seat globals

parent 4885b50b
......@@ -202,7 +202,7 @@ video_output/wayland/viewporter-protocol.c: \
$(WAYLAND_PROTOCOLS)/stable/viewporter/viewporter.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) private-code $< $@
libwl_shell_plugin_la_SOURCES = video_output/wayland/xdg-shell.c
libwl_shell_plugin_la_SOURCES = $(libxdg_shell_plugin_la_SOURCES)
nodist_libwl_shell_plugin_la_SOURCES = \
video_output/wayland/server-decoration-client-protocol.h \
video_output/wayland/server-decoration-protocol.c
......@@ -211,7 +211,9 @@ libwl_shell_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
libwl_shell_plugin_la_CFLAGS = $(WAYLAND_CLIENT_CFLAGS)
libwl_shell_plugin_la_LIBADD = $(WAYLAND_CLIENT_LIBS) $(LIBPTHREAD)
libxdg_shell_plugin_la_SOURCES = video_output/wayland/xdg-shell.c
libxdg_shell_plugin_la_SOURCES = \
video_output/wayland/input.h video_output/wayland/input.c \
video_output/wayland/xdg-shell.c
nodist_libxdg_shell_plugin_la_SOURCES = \
video_output/wayland/xdg-shell-client-protocol.h \
video_output/wayland/xdg-shell-protocol.c \
......@@ -238,7 +240,7 @@ video_output/wayland/server-decoration-protocol.c: \
video_output/wayland/server-decoration.xml
EXTRA_DIST += video_output/wayland/server-decoration.xml
libxdg_shell_v6_plugin_la_SOURCES = video_output/wayland/xdg-shell.c
libxdg_shell_v6_plugin_la_SOURCES = $(libxdg_shell_plugin_la_SOURCES)
nodist_libxdg_shell_v6_plugin_la_SOURCES = \
video_output/wayland/xdg-shell-unstable-v6-client-protocol.h \
video_output/wayland/xdg-shell-unstable-v6-protocol.c \
......
/**
* @file input.c
* @brief Wayland input events for VLC media player
*/
/*****************************************************************************
* Copyright © 2018 Rémi Denis-Courmont
*
* This program 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 program 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 program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <wayland-client.h>
#include <vlc_common.h>
#include <vlc_vout_window.h>
#include "input.h"
struct seat_data
{
vout_window_t *owner;
struct wl_seat *seat;
uint32_t version;
struct wl_list node;
};
static void seat_capabilities_cb(void *data, struct wl_seat *seat,
uint32_t capabilities)
{
struct seat_data *sd = data;
struct vout_window_t *wnd = sd->owner;
msg_Dbg(wnd, "seat capabilities: 0x%"PRIx32, capabilities);
(void) seat;
}
static void seat_name_cb(void *data, struct wl_seat *seat, const char *name)
{
struct seat_data *sd = data;
msg_Dbg(sd->owner, "seat name: %s", name);
(void) seat;
}
static const struct wl_seat_listener seat_cbs =
{
seat_capabilities_cb,
seat_name_cb,
};
int seat_create(vout_window_t *wnd, struct wl_registry *registry,
uint32_t name, uint32_t version, struct wl_list *list)
{
struct seat_data *sd = malloc(sizeof (*sd));
if (unlikely(sd == NULL))
return -1;
if (version > 5)
version = 5;
sd->owner = wnd;
sd->version = version;
sd->seat = wl_registry_bind(registry, name, &wl_seat_interface, version);
if (unlikely(sd->seat == NULL))
{
free(sd);
return -1;
}
wl_seat_add_listener(sd->seat, &seat_cbs, sd);
wl_list_insert(list, &sd->node);
return 0;
}
static void seat_destroy(struct seat_data *sd)
{
wl_list_remove(&sd->node);
if (sd->version >= WL_SEAT_RELEASE_SINCE_VERSION)
wl_seat_release(sd->seat);
else
wl_seat_destroy(sd->seat);
free(sd);
}
void seat_destroy_all(struct wl_list *list)
{
while (!wl_list_empty(list))
seat_destroy(container_of(list->next, struct seat_data, node));
}
/*****************************************************************************
* Copyright © 2018 Rémi Denis-Courmont
*
* This program 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 program 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 program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <stdint.h>
struct vout_window_t;
struct wl_registry;
struct wl_list;
int seat_create(struct vout_window_t *wnd, struct wl_registry *,
uint32_t name, uint32_t version, struct wl_list *list);
void seat_destroy_all(struct wl_list *list);
......@@ -90,6 +90,8 @@
#include <vlc_plugin.h>
#include <vlc_vout_window.h>
#include "input.h"
struct vout_window_sys_t
{
struct wl_registry *registry;
......@@ -106,6 +108,8 @@ struct vout_window_sys_t
unsigned height;
bool fullscreen;
struct wl_list seats;
vlc_thread_t thread;
};
......@@ -439,6 +443,9 @@ static void registry_global_cb(void *data, struct wl_registry *registry,
sys->wm_base = wl_registry_bind(registry, name, &xdg_wm_base_interface,
1);
else
if (!strcmp(iface, "wl_seat"))
seat_create(wnd, registry, name, vers, &sys->seats);
else
if (!strcmp(iface, "org_kde_kwin_server_decoration_manager"))
sys->deco_manager = wl_registry_bind(registry, name,
&org_kde_kwin_server_decoration_manager_interface, 1);
......@@ -484,6 +491,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
sys->width = cfg->width;
sys->height = cfg->height;
sys->fullscreen = false;
wl_list_init(&sys->seats);
wnd->sys = sys;
/* Connect to the display server */
......@@ -589,6 +597,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
return VLC_SUCCESS;
error:
seat_destroy_all(&sys->seats);
if (sys->deco != NULL)
org_kde_kwin_server_decoration_destroy(sys->deco);
if (sys->deco_manager != NULL)
......@@ -618,6 +627,7 @@ static void Close(vout_window_t *wnd)
vlc_cancel(sys->thread);
vlc_join(sys->thread, NULL);
seat_destroy_all(&sys->seats);
if (sys->deco != NULL)
org_kde_kwin_server_decoration_destroy(sys->deco);
if (sys->deco_manager != NULL)
......
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