2016-08-12 11:41:34 +03:00
|
|
|
/*
|
|
|
|
* Copyright © 2010-2012 Intel Corporation
|
|
|
|
* Copyright © 2011-2012 Collabora, Ltd.
|
|
|
|
* Copyright © 2013 Raspberry Pi Foundation
|
|
|
|
* Copyright © 2016 Quentin "Sardem FF7" Glidic
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <wayland-server.h>
|
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2019-04-04 14:46:00 +03:00
|
|
|
#include <libweston/zalloc.h>
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2019-04-04 16:02:14 +03:00
|
|
|
#include <libweston-desktop/libweston-desktop.h>
|
2016-08-12 11:41:34 +03:00
|
|
|
#include "internal.h"
|
2016-08-12 11:41:35 +03:00
|
|
|
#include "xwayland/xwayland-internal-interface.h"
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
enum weston_desktop_xwayland_surface_state {
|
|
|
|
NONE,
|
|
|
|
TOPLEVEL,
|
|
|
|
MAXIMIZED,
|
|
|
|
FULLSCREEN,
|
|
|
|
TRANSIENT,
|
|
|
|
XWAYLAND,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct weston_desktop_xwayland {
|
|
|
|
struct weston_desktop *desktop;
|
|
|
|
struct weston_desktop_client *client;
|
|
|
|
struct weston_layer layer;
|
|
|
|
};
|
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface {
|
2016-08-12 11:41:34 +03:00
|
|
|
struct weston_desktop_xwayland *xwayland;
|
|
|
|
struct weston_desktop *desktop;
|
|
|
|
struct weston_desktop_surface *surface;
|
|
|
|
struct wl_listener resource_destroy_listener;
|
|
|
|
struct weston_view *view;
|
2016-08-12 11:41:35 +03:00
|
|
|
const struct weston_xwayland_client_interface *client_interface;
|
2016-08-12 11:41:34 +03:00
|
|
|
struct weston_geometry next_geometry;
|
|
|
|
bool has_next_geometry;
|
2017-12-08 13:10:53 +03:00
|
|
|
bool committed;
|
2016-08-12 11:41:34 +03:00
|
|
|
bool added;
|
|
|
|
enum weston_desktop_xwayland_surface_state state;
|
2022-06-06 21:30:59 +03:00
|
|
|
enum weston_desktop_xwayland_surface_state prev_state;
|
2016-08-12 11:41:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surface *surface,
|
2016-08-12 11:41:34 +03:00
|
|
|
enum weston_desktop_xwayland_surface_state state,
|
|
|
|
struct weston_desktop_surface *parent,
|
|
|
|
int32_t x, int32_t y)
|
|
|
|
{
|
2016-11-15 15:24:21 +03:00
|
|
|
struct weston_surface *wsurface;
|
2016-08-12 11:41:34 +03:00
|
|
|
bool to_add = (parent == NULL && state != XWAYLAND);
|
|
|
|
|
|
|
|
assert(state != NONE);
|
2016-11-15 12:43:36 +03:00
|
|
|
assert(!parent || state == TRANSIENT);
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-08-16 12:42:47 +03:00
|
|
|
if (to_add && surface->added) {
|
|
|
|
surface->state = state;
|
2016-08-12 11:41:34 +03:00
|
|
|
return;
|
2016-08-16 12:42:47 +03:00
|
|
|
}
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-11-15 15:24:21 +03:00
|
|
|
wsurface = weston_desktop_surface_get_surface(surface->surface);
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
if (surface->state != state) {
|
|
|
|
if (surface->state == XWAYLAND) {
|
2016-11-15 13:22:09 +03:00
|
|
|
assert(!surface->added);
|
|
|
|
|
2016-08-16 11:52:46 +03:00
|
|
|
weston_desktop_surface_unlink_view(surface->view);
|
2016-08-16 11:55:02 +03:00
|
|
|
weston_view_destroy(surface->view);
|
2016-08-12 11:41:34 +03:00
|
|
|
surface->view = NULL;
|
2016-11-15 15:24:21 +03:00
|
|
|
weston_surface_unmap(wsurface);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (to_add) {
|
|
|
|
weston_desktop_surface_unset_relative_to(surface->surface);
|
|
|
|
weston_desktop_api_surface_added(surface->desktop,
|
|
|
|
surface->surface);
|
2016-11-15 12:48:42 +03:00
|
|
|
surface->added = true;
|
2017-12-08 13:10:53 +03:00
|
|
|
if (surface->state == NONE && surface->committed)
|
|
|
|
/* We had a race, and wl_surface.commit() was
|
|
|
|
* faster, just fake a commit to map the
|
|
|
|
* surface */
|
|
|
|
weston_desktop_api_committed(surface->desktop,
|
|
|
|
surface->surface,
|
|
|
|
0, 0);
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
} else if (surface->added) {
|
|
|
|
weston_desktop_api_surface_removed(surface->desktop,
|
|
|
|
surface->surface);
|
2016-11-15 12:48:42 +03:00
|
|
|
surface->added = false;
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state == XWAYLAND) {
|
2016-11-15 13:22:09 +03:00
|
|
|
assert(!surface->added);
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
surface->view =
|
|
|
|
weston_desktop_surface_create_view(surface->surface);
|
|
|
|
weston_layer_entry_insert(&surface->xwayland->layer.view_list,
|
|
|
|
&surface->view->layer_link);
|
2016-11-15 15:24:21 +03:00
|
|
|
surface->view->is_mapped = true;
|
2022-06-12 22:51:45 +03:00
|
|
|
weston_surface_map(wsurface);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
surface->state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent != NULL)
|
|
|
|
weston_desktop_surface_set_relative_to(surface->surface, parent,
|
|
|
|
x, y, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurface,
|
2016-08-15 13:21:39 +03:00
|
|
|
void *user_data,
|
2016-08-12 11:41:34 +03:00
|
|
|
int32_t sx, int32_t sy)
|
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
2017-01-18 16:37:59 +03:00
|
|
|
struct weston_geometry oldgeom;
|
|
|
|
|
|
|
|
assert(dsurface == surface->surface);
|
2017-12-08 13:10:53 +03:00
|
|
|
surface->committed = true;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-11-28 17:37:07 +03:00
|
|
|
#ifdef WM_DEBUG
|
|
|
|
weston_log("%s: xwayland surface %p\n", __func__, surface);
|
|
|
|
#endif
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
if (surface->has_next_geometry) {
|
2017-01-18 16:37:59 +03:00
|
|
|
oldgeom = weston_desktop_surface_get_geometry(surface->surface);
|
2022-06-06 21:30:59 +03:00
|
|
|
/* If we're transitioning away from fullscreen or maximized
|
|
|
|
* we've moved to old saved co-ordinates that were saved
|
|
|
|
* with window geometry in place, so avoid adajusting by
|
|
|
|
* the geometry in those cases.
|
|
|
|
*/
|
|
|
|
if (surface->state == surface->prev_state) {
|
|
|
|
sx -= surface->next_geometry.x - oldgeom.x;
|
|
|
|
sy -= surface->next_geometry.y - oldgeom.y;
|
|
|
|
}
|
|
|
|
surface->prev_state = surface->state;
|
2017-01-18 16:37:59 +03:00
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
surface->has_next_geometry = false;
|
|
|
|
weston_desktop_surface_set_geometry(surface->surface,
|
|
|
|
surface->next_geometry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->added)
|
|
|
|
weston_desktop_api_committed(surface->desktop, surface->surface,
|
|
|
|
sx, sy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_desktop_xwayland_surface_set_size(struct weston_desktop_surface *dsurface,
|
2016-08-12 11:41:35 +03:00
|
|
|
void *user_data,
|
|
|
|
int32_t width, int32_t height)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
|
|
|
struct weston_surface *wsurface =
|
|
|
|
weston_desktop_surface_get_surface(surface->surface);
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
surface->client_interface->send_configure(wsurface, width, height);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_desktop_xwayland_surface_destroy(struct weston_desktop_surface *dsurface,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
wl_list_remove(&surface->resource_destroy_listener.link);
|
|
|
|
|
|
|
|
weston_desktop_surface_unset_relative_to(surface->surface);
|
2016-08-18 17:45:30 +03:00
|
|
|
if (surface->added)
|
2016-08-12 11:41:34 +03:00
|
|
|
weston_desktop_api_surface_removed(surface->desktop,
|
|
|
|
surface->surface);
|
2016-08-18 17:45:30 +03:00
|
|
|
else if (surface->state == XWAYLAND)
|
2016-08-16 11:52:46 +03:00
|
|
|
weston_desktop_surface_unlink_view(surface->view);
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
free(surface);
|
|
|
|
}
|
|
|
|
|
2020-03-22 20:19:38 +03:00
|
|
|
static void
|
|
|
|
weston_desktop_xwayland_surface_close(struct weston_desktop_surface *dsurface,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
|
|
|
struct weston_surface *wsurface =
|
|
|
|
weston_desktop_surface_get_surface(surface->surface);
|
|
|
|
|
|
|
|
surface->client_interface->send_close(wsurface);
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
static bool
|
|
|
|
weston_desktop_xwayland_surface_get_maximized(struct weston_desktop_surface *dsurface,
|
2016-08-12 11:41:35 +03:00
|
|
|
void *user_data)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
return surface->state == MAXIMIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
weston_desktop_xwayland_surface_get_fullscreen(struct weston_desktop_surface *dsurface,
|
2016-08-12 11:41:35 +03:00
|
|
|
void *user_data)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface = user_data;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
return surface->state == FULLSCREEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct weston_desktop_surface_implementation weston_desktop_xwayland_surface_internal_implementation = {
|
|
|
|
.committed = weston_desktop_xwayland_surface_committed,
|
|
|
|
.set_size = weston_desktop_xwayland_surface_set_size,
|
|
|
|
|
|
|
|
.get_maximized = weston_desktop_xwayland_surface_get_maximized,
|
|
|
|
.get_fullscreen = weston_desktop_xwayland_surface_get_fullscreen,
|
|
|
|
|
|
|
|
.destroy = weston_desktop_xwayland_surface_destroy,
|
2020-03-22 20:19:38 +03:00
|
|
|
.close = weston_desktop_xwayland_surface_close,
|
2016-08-12 11:41:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
weston_destop_xwayland_resource_destroyed(struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface =
|
2016-08-12 11:41:34 +03:00
|
|
|
wl_container_of(listener, surface, resource_destroy_listener);
|
|
|
|
|
|
|
|
weston_desktop_surface_destroy(surface->surface);
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
static struct weston_desktop_xwayland_surface *
|
|
|
|
create_surface(struct weston_desktop_xwayland *xwayland,
|
|
|
|
struct weston_surface *wsurface,
|
|
|
|
const struct weston_xwayland_client_interface *client_interface)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
struct weston_desktop_xwayland_surface *surface;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
surface = zalloc(sizeof(struct weston_desktop_xwayland_surface));
|
2016-08-12 11:41:34 +03:00
|
|
|
if (surface == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
surface->xwayland = xwayland;
|
|
|
|
surface->desktop = xwayland->desktop;
|
2016-08-12 11:41:35 +03:00
|
|
|
surface->client_interface = client_interface;
|
2016-08-12 11:41:34 +03:00
|
|
|
|
|
|
|
surface->surface =
|
|
|
|
weston_desktop_surface_create(surface->desktop,
|
|
|
|
xwayland->client, wsurface,
|
|
|
|
&weston_desktop_xwayland_surface_internal_implementation,
|
|
|
|
surface);
|
|
|
|
if (surface->surface == NULL) {
|
|
|
|
free(surface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->resource_destroy_listener.notify =
|
|
|
|
weston_destop_xwayland_resource_destroyed;
|
|
|
|
wl_resource_add_destroy_listener(wsurface->resource,
|
|
|
|
&surface->resource_destroy_listener);
|
|
|
|
|
2016-12-08 11:21:08 +03:00
|
|
|
weston_desktop_surface_set_pid(surface->surface, 0);
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_toplevel(struct weston_desktop_xwayland_surface *surface)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, TOPLEVEL, NULL,
|
|
|
|
0, 0);
|
|
|
|
}
|
|
|
|
|
2016-11-16 15:03:31 +03:00
|
|
|
static void
|
|
|
|
set_toplevel_with_position(struct weston_desktop_xwayland_surface *surface,
|
|
|
|
int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, TOPLEVEL, NULL,
|
|
|
|
0, 0);
|
|
|
|
weston_desktop_api_set_xwayland_position(surface->desktop,
|
|
|
|
surface->surface, x, y);
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_parent(struct weston_desktop_xwayland_surface *surface,
|
|
|
|
struct weston_surface *wparent)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
struct weston_desktop_surface *parent;
|
|
|
|
|
|
|
|
if (!weston_surface_is_desktop_surface(wparent))
|
|
|
|
return;
|
|
|
|
|
|
|
|
parent = weston_surface_get_desktop_surface(wparent);
|
2016-08-12 11:41:35 +03:00
|
|
|
weston_desktop_api_set_parent(surface->desktop, surface->surface, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_transient(struct weston_desktop_xwayland_surface *surface,
|
|
|
|
struct weston_surface *wparent, int x, int y)
|
|
|
|
{
|
|
|
|
struct weston_desktop_surface *parent;
|
|
|
|
|
|
|
|
if (!weston_surface_is_desktop_surface(wparent))
|
|
|
|
return;
|
|
|
|
|
|
|
|
parent = weston_surface_get_desktop_surface(wparent);
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, TRANSIENT, parent,
|
|
|
|
x, y);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_fullscreen(struct weston_desktop_xwayland_surface *surface,
|
|
|
|
struct weston_output *output)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, FULLSCREEN, NULL,
|
|
|
|
0, 0);
|
|
|
|
weston_desktop_api_fullscreen_requested(surface->desktop,
|
|
|
|
surface->surface, true, output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_xwayland(struct weston_desktop_xwayland_surface *surface, int x, int y)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL,
|
|
|
|
x, y);
|
2017-06-28 00:08:40 +03:00
|
|
|
weston_view_set_position(surface->view, x, y);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-08-12 11:41:35 +03:00
|
|
|
move(struct weston_desktop_xwayland_surface *surface,
|
2016-08-12 11:41:34 +03:00
|
|
|
struct weston_pointer *pointer)
|
|
|
|
{
|
|
|
|
if (surface->state == TOPLEVEL ||
|
|
|
|
surface->state == MAXIMIZED ||
|
|
|
|
surface->state == FULLSCREEN)
|
|
|
|
weston_desktop_api_move(surface->desktop, surface->surface,
|
|
|
|
pointer->seat, pointer->grab_serial);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-08-12 11:41:35 +03:00
|
|
|
resize(struct weston_desktop_xwayland_surface *surface,
|
2016-08-12 11:41:34 +03:00
|
|
|
struct weston_pointer *pointer, uint32_t edges)
|
|
|
|
{
|
|
|
|
if (surface->state == TOPLEVEL ||
|
|
|
|
surface->state == MAXIMIZED ||
|
|
|
|
surface->state == FULLSCREEN)
|
|
|
|
weston_desktop_api_resize(surface->desktop, surface->surface,
|
|
|
|
pointer->seat, pointer->grab_serial,
|
|
|
|
edges);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_title(struct weston_desktop_xwayland_surface *surface, const char *title)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
weston_desktop_surface_set_title(surface->surface, title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_window_geometry(struct weston_desktop_xwayland_surface *surface,
|
2016-08-12 11:41:34 +03:00
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
|
|
|
{
|
|
|
|
surface->has_next_geometry = true;
|
|
|
|
surface->next_geometry.x = x;
|
|
|
|
surface->next_geometry.y = y;
|
|
|
|
surface->next_geometry.width = width;
|
|
|
|
surface->next_geometry.height = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_maximized(struct weston_desktop_xwayland_surface *surface)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
|
|
|
weston_desktop_xwayland_surface_change_state(surface, MAXIMIZED, NULL,
|
|
|
|
0, 0);
|
|
|
|
weston_desktop_api_maximized_requested(surface->desktop,
|
|
|
|
surface->surface, true);
|
|
|
|
}
|
|
|
|
|
2022-03-10 21:34:17 +03:00
|
|
|
static void
|
|
|
|
set_minimized(struct weston_desktop_xwayland_surface *surface)
|
|
|
|
{
|
|
|
|
weston_desktop_api_minimized_requested(surface->desktop,
|
|
|
|
surface->surface);
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
static void
|
2016-08-12 11:41:35 +03:00
|
|
|
set_pid(struct weston_desktop_xwayland_surface *surface, pid_t pid)
|
2016-08-12 11:41:34 +03:00
|
|
|
{
|
2016-08-12 11:41:35 +03:00
|
|
|
weston_desktop_surface_set_pid(surface->surface, pid);
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
|
|
|
|
2022-06-22 22:08:23 +03:00
|
|
|
static void
|
|
|
|
get_position(struct weston_desktop_xwayland_surface *surface,
|
|
|
|
int32_t *x, int32_t *y)
|
|
|
|
{
|
|
|
|
if (!surface->surface) {
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
weston_desktop_api_get_position(surface->desktop, surface->surface, x, y);
|
|
|
|
}
|
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
static const struct weston_desktop_xwayland_interface weston_desktop_xwayland_interface = {
|
|
|
|
.create_surface = create_surface,
|
|
|
|
.set_toplevel = set_toplevel,
|
2016-11-16 15:03:31 +03:00
|
|
|
.set_toplevel_with_position = set_toplevel_with_position,
|
2016-08-12 11:41:35 +03:00
|
|
|
.set_parent = set_parent,
|
|
|
|
.set_transient = set_transient,
|
|
|
|
.set_fullscreen = set_fullscreen,
|
|
|
|
.set_xwayland = set_xwayland,
|
|
|
|
.move = move,
|
|
|
|
.resize = resize,
|
|
|
|
.set_title = set_title,
|
|
|
|
.set_window_geometry = set_window_geometry,
|
|
|
|
.set_maximized = set_maximized,
|
2022-03-10 21:34:17 +03:00
|
|
|
.set_minimized = set_minimized,
|
2016-08-12 11:41:35 +03:00
|
|
|
.set_pid = set_pid,
|
2022-06-22 22:08:23 +03:00
|
|
|
.get_position = get_position,
|
2016-08-12 11:41:35 +03:00
|
|
|
};
|
|
|
|
|
2016-08-12 11:41:34 +03:00
|
|
|
void
|
|
|
|
weston_desktop_xwayland_init(struct weston_desktop *desktop)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = weston_desktop_get_compositor(desktop);
|
|
|
|
struct weston_desktop_xwayland *xwayland;
|
|
|
|
|
|
|
|
xwayland = zalloc(sizeof(struct weston_desktop_xwayland));
|
|
|
|
if (xwayland == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xwayland->desktop = desktop;
|
|
|
|
xwayland->client = weston_desktop_client_create(desktop, NULL, NULL, NULL, NULL, 0, 0);
|
|
|
|
|
2016-12-17 15:40:51 +03:00
|
|
|
weston_layer_init(&xwayland->layer, compositor);
|
2022-03-10 19:58:22 +03:00
|
|
|
/* This is the layer we use for override redirect "windows", which
|
|
|
|
* ends up used for tooltips and drop down menus, among other things.
|
|
|
|
* Previously this was WESTON_LAYER_POSITION_NORMAL + 1, but this is
|
|
|
|
* below the fullscreen layer, so fullscreen apps would be above their
|
|
|
|
* menus and tooltips.
|
|
|
|
*
|
|
|
|
* Moving this to just below the TOP_UI layer ensures visibility at all
|
|
|
|
* times, with the minor drawback that they could be rendered above
|
|
|
|
* DESKTOP_UI.
|
|
|
|
*
|
|
|
|
* For tooltips with no transient window hints, this is probably the best
|
|
|
|
* we can do.
|
|
|
|
*/
|
2016-12-17 15:40:51 +03:00
|
|
|
weston_layer_set_position(&xwayland->layer,
|
2022-03-10 19:58:22 +03:00
|
|
|
WESTON_LAYER_POSITION_TOP_UI - 1);
|
2016-08-12 11:41:34 +03:00
|
|
|
|
2016-08-12 11:41:35 +03:00
|
|
|
compositor->xwayland = xwayland;
|
|
|
|
compositor->xwayland_interface = &weston_desktop_xwayland_interface;
|
2016-08-12 11:41:34 +03:00
|
|
|
}
|
2021-05-14 16:12:35 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
weston_desktop_xwayland_fini(struct weston_desktop *desktop)
|
|
|
|
{
|
|
|
|
struct weston_compositor *compositor = weston_desktop_get_compositor(desktop);
|
|
|
|
struct weston_desktop_xwayland *xwayland;
|
|
|
|
|
|
|
|
xwayland = compositor->xwayland;
|
|
|
|
|
|
|
|
weston_desktop_client_destroy(xwayland->client);
|
|
|
|
weston_layer_fini(&xwayland->layer);
|
|
|
|
free(xwayland);
|
|
|
|
|
|
|
|
compositor->xwayland = NULL;
|
|
|
|
compositor->xwayland_interface = NULL;
|
|
|
|
}
|