From a205515d91ad1c711dabcc94db43c5211fdbb8e2 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sat, 9 Jan 2021 01:04:02 -0500 Subject: [PATCH] [client] clipboard/wayland: implement a no-op Wayland clipboard Build scaffolding only; implementation in later commits. Co-authored-by: Quantum --- client/CMakeLists.txt | 3 + client/clipboards/CMakeLists.txt | 4 ++ client/clipboards/Wayland/CMakeLists.txt | 25 +++++++ client/clipboards/Wayland/src/wayland.c | 92 ++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 client/clipboards/Wayland/CMakeLists.txt create mode 100644 client/clipboards/Wayland/src/wayland.c diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 7d490c46..f779eac5 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -24,6 +24,9 @@ add_feature_info(ENABLE_EGL ENABLE_EGL "EGL renderer.") option(ENABLE_CB_X11 "Enable X11 clipboard integration" ON) add_feature_info(ENABLE_CB_X11 ENABLE_CB_X11 "X11 Clipboard Integration.") +option(ENABLE_CB_WAYLAND "Enable Wayland clipboard integration" ON) +add_feature_info(ENABLE_CB_WAYLAND ENABLE_CB_WAYLAND "Wayland Clipboard Integration.") + option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON) add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.") diff --git a/client/clipboards/CMakeLists.txt b/client/clipboards/CMakeLists.txt index e3e077a3..31b24583 100644 --- a/client/clipboards/CMakeLists.txt +++ b/client/clipboards/CMakeLists.txt @@ -23,6 +23,10 @@ if (ENABLE_CB_X11) add_clipboard(X11) endif() +if (ENABLE_CB_WAYLAND) + add_clipboard(Wayland) +endif() + list(REMOVE_AT CLIPBOARDS 0) list(REMOVE_AT CLIPBOARDS_LINK 0) diff --git a/client/clipboards/Wayland/CMakeLists.txt b/client/clipboards/Wayland/CMakeLists.txt new file mode 100644 index 00000000..fa676a65 --- /dev/null +++ b/client/clipboards/Wayland/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.0) +project(clipboard_Wayland LANGUAGES C) + +find_package(PkgConfig) +pkg_check_modules(CLIPBOARD_PKGCONFIG REQUIRED + wayland-client +) + +add_library(clipboard_Wayland STATIC + src/wayland.c +) + +target_link_libraries(clipboard_Wayland + ${CLIPBOARD_PKGCONFIG_LIBRARIES} + lg_common +) + +target_include_directories(clipboard_Wayland + PUBLIC + $ + $ + PRIVATE + src + ${CLIPBOARD_PKGCONFIG_INCLUDE_DIRS} +) diff --git a/client/clipboards/Wayland/src/wayland.c b/client/clipboards/Wayland/src/wayland.c new file mode 100644 index 00000000..f9da4d23 --- /dev/null +++ b/client/clipboards/Wayland/src/wayland.c @@ -0,0 +1,92 @@ +/* +Looking Glass - KVM FrameRelay (KVMFR) Client +Copyright (C) 2017-2019 Geoffrey McRae +https://looking-glass.hostfission.com + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 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 General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "interface/clipboard.h" +#include "common/debug.h" + +struct state +{ + LG_ClipboardReleaseFn releaseFn; + LG_ClipboardRequestFn requestFn; + LG_ClipboardNotifyFn notifyFn; + LG_ClipboardDataFn dataFn; + LG_ClipboardData type; +}; + +static struct state * this = NULL; + +static const char * wayland_cb_getName() +{ + return "Wayland"; +} + +static bool wayland_cb_init( + SDL_SysWMinfo * wminfo, + LG_ClipboardReleaseFn releaseFn, + LG_ClipboardNotifyFn notifyFn, + LG_ClipboardDataFn dataFn) +{ + if (wminfo->subsystem != SDL_SYSWM_WAYLAND) + { + DEBUG_ERROR("wrong subsystem"); + return false; + } + + this = (struct state *)malloc(sizeof(struct state)); + memset(this, 0, sizeof(struct state)); + + this->releaseFn = releaseFn; + this->notifyFn = notifyFn; + this->dataFn = dataFn; + return true; +} + +static void wayland_cb_free() +{ + free(this); + this = NULL; +} + +static void wayland_cb_wmevent(SDL_SysWMmsg * msg) +{ +} + +static void wayland_cb_notice(LG_ClipboardRequestFn requestFn, LG_ClipboardData type) +{ +} + +static void wayland_cb_release() +{ + this->requestFn = NULL; +} + +static void wayland_cb_request(LG_ClipboardData type) +{ +} + +const LG_Clipboard LGC_Wayland = +{ + .getName = wayland_cb_getName, + .init = wayland_cb_init, + .free = wayland_cb_free, + .wmevent = wayland_cb_wmevent, + .notice = wayland_cb_notice, + .release = wayland_cb_release, + .request = wayland_cb_request +};