Skip to content
Snippets Groups Projects
Commit 2daa2c80 authored by Alexandros Frantzis's avatar Alexandros Frantzis
Browse files

winewayland.drv: Add skeleton data device format infrastructure.


Introduce infrastructure to convert clipboard/drag-and-drop data
between what Wayland understands and what Wine understands.

Signed-off-by: default avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent 10b83e51
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ C_SRCS = \
wayland_cursor.c \
wayland_data_device.c \
wayland_data_device_dll.c \
wayland_data_device_format.c \
wayland_dmabuf.c \
wayland_keyboard.c \
wayland_keyboard_layout.c \
......
/*
* Wayland data device format 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"
#include "winternl.h"
/* Order is important. When selecting a mime-type for a clipboard format we
* will choose the first entry that matches the specified clipboard format. */
static struct wayland_data_device_format supported_formats[] =
{
{NULL, 0, NULL, NULL, NULL, 0},
};
static ATOM register_clipboard_format(const WCHAR *name)
{
ATOM atom;
if (NtAddAtom(name, lstrlenW(name) * sizeof(WCHAR), &atom)) return 0;
return atom;
}
void wayland_data_device_init_formats(void)
{
struct wayland_data_device_format *format = supported_formats;
while (format->mime_type)
{
if (format->clipboard_format == 0)
format->clipboard_format = register_clipboard_format(format->register_name);
format++;
}
}
struct wayland_data_device_format *wayland_data_device_format_for_mime_type(const char *mime)
{
struct wayland_data_device_format *format = supported_formats;
while (format->mime_type)
{
if (!strcmp(mime, format->mime_type))
return format;
format++;
}
return NULL;
}
static BOOL string_array_contains(struct wl_array *array, const char *str)
{
char **p;
wl_array_for_each(p, array)
if (!strcmp(*p, str)) return TRUE;
return FALSE;
}
struct wayland_data_device_format *wayland_data_device_format_for_clipboard_format(UINT clipboard_format,
struct wl_array *mimes)
{
struct wayland_data_device_format *format = supported_formats;
while (format->mime_type)
{
if (format->clipboard_format == clipboard_format &&
(!mimes || string_array_contains(mimes, format->mime_type)))
{
return format;
}
format++;
}
return NULL;
}
......@@ -246,6 +246,19 @@ struct wayland_data_device
struct wl_data_offer *dnd_wl_data_offer;
};
struct wayland_data_device_format
{
const char *mime_type;
UINT clipboard_format;
const WCHAR *register_name;
/* In case of failure, 'ret_size' is left unchanged. */
void *(*import)(struct wayland_data_device_format *format,
const void *data, size_t data_size, size_t *ret_size);
void (*export)(struct wayland_data_device_format *format, int fd,
void *data, size_t size);
UINT_PTR extra;
};
struct wayland
{
struct wl_list thread_link;
......@@ -692,6 +705,10 @@ void wayland_data_device_init(struct wayland_data_device *data_device,
struct wayland *wayland) DECLSPEC_HIDDEN;
void wayland_data_device_deinit(struct wayland_data_device *data_device) DECLSPEC_HIDDEN;
void wayland_data_device_ensure_clipboard_window(struct wayland *wayland) DECLSPEC_HIDDEN;
void wayland_data_device_init_formats(void) DECLSPEC_HIDDEN;
struct wayland_data_device_format *wayland_data_device_format_for_mime_type(const char *mime) DECLSPEC_HIDDEN;
struct wayland_data_device_format *wayland_data_device_format_for_clipboard_format(UINT clipboard_format,
struct wl_array *mimes) DECLSPEC_HIDDEN;
/**********************************************************************
* Registry helpers
......
......@@ -200,6 +200,8 @@ static NTSTATUS waylanddrv_unix_init(void *arg)
wayland_read_options_from_registry();
wayland_data_device_init_formats();
if (!wayland_init_set_cursor()) goto err;
if (!wayland_process_init()) goto err;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment