[client] wayland: bind xdg_activation_v1 when available

This commit is contained in:
Tudor Brindus 2022-02-06 16:07:29 -05:00 committed by Geoffrey McRae
parent b13582a911
commit 4ee6bdf198
5 changed files with 56 additions and 0 deletions

View File

@ -23,6 +23,7 @@ else()
endif() endif()
add_library(displayserver_Wayland STATIC add_library(displayserver_Wayland STATIC
activation.c
clipboard.c clipboard.c
cursor.c cursor.c
gl.c gl.c

View File

@ -0,0 +1,42 @@
/**
* Looking Glass
* Copyright © 2017-2022 The Looking Glass Authors
* https://looking-glass.io
*
* 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 "wayland.h"
#include <stdbool.h>
#include <wayland-client.h>
#include "common/debug.h"
bool waylandActivationInit(void)
{
if (!wlWm.xdgActivation)
DEBUG_WARN("xdg_activation_v1 not exported by compositor, will not be able "
"to request host focus on behalf of guest applications");
return true;
}
void waylandActivationFree(void)
{
if (wlWm.xdgActivation)
{
xdg_activation_v1_destroy(wlWm.xdgActivation);
}
}

View File

@ -72,6 +72,9 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
wlWm.xdgOutputManager = wl_registry_bind(wlWm.registry, name, wlWm.xdgOutputManager = wl_registry_bind(wlWm.registry, name,
// we only need v2 to run, but v3 saves a callback // we only need v2 to run, but v3 saves a callback
&zxdg_output_manager_v1_interface, version > 3 ? 3 : version); &zxdg_output_manager_v1_interface, version > 3 ? 3 : version);
else if (!strcmp(interface, xdg_activation_v1_interface.name))
wlWm.xdgActivation = wl_registry_bind(wlWm.registry, name,
&xdg_activation_v1_interface, 1);
} }
static void registryGlobalRemoveHandler(void * data, static void registryGlobalRemoveHandler(void * data,

View File

@ -89,6 +89,9 @@ static bool waylandInit(const LG_DSInitParams params)
if (!waylandRegistryInit()) if (!waylandRegistryInit())
return false; return false;
if (!waylandActivationInit())
return false;
if (!waylandIdleInit()) if (!waylandIdleInit())
return false; return false;

View File

@ -47,6 +47,7 @@
#include "wayland-relative-pointer-unstable-v1-client-protocol.h" #include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
#include "wayland-xdg-output-unstable-v1-client-protocol.h" #include "wayland-xdg-output-unstable-v1-client-protocol.h"
#include "wayland-xdg-activation-v1-client-protocol.h"
typedef void (*WaylandPollCallback)(uint32_t events, void * opaque); typedef void (*WaylandPollCallback)(uint32_t events, void * opaque);
@ -180,6 +181,8 @@ struct WaylandDSState
struct zwp_idle_inhibit_manager_v1 * idleInhibitManager; struct zwp_idle_inhibit_manager_v1 * idleInhibitManager;
struct zwp_idle_inhibitor_v1 * idleInhibitor; struct zwp_idle_inhibitor_v1 * idleInhibitor;
struct xdg_activation_v1 * xdgActivation;
struct wp_viewporter * viewporter; struct wp_viewporter * viewporter;
struct wp_viewport * viewport; struct wp_viewport * viewport;
struct zxdg_output_manager_v1 * xdgOutputManager; struct zxdg_output_manager_v1 * xdgOutputManager;
@ -231,6 +234,10 @@ struct WCBState
extern struct WaylandDSState wlWm; extern struct WaylandDSState wlWm;
extern struct WCBState wlCb; extern struct WCBState wlCb;
// activation module
bool waylandActivationInit(void);
void waylandActivationFree(void);
// clipboard module // clipboard module
bool waylandCBInit(void); bool waylandCBInit(void);
void waylandCBRequest(LG_ClipboardData type); void waylandCBRequest(LG_ClipboardData type);