mirror of
https://github.com/swaywm/sway.git
synced 2024-11-30 03:41:27 +00:00
Fix xwayland unmanaged surfaces
This commit is contained in:
parent
f5e5b1819b
commit
7ce1038478
|
@ -87,6 +87,9 @@ struct sway_xwayland_unmanaged {
|
||||||
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|
||||||
|
struct wl_listener commit;
|
||||||
|
struct wl_listener map;
|
||||||
|
struct wl_listener unmap;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.get_prop = get_prop,
|
.get_prop = get_prop,
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.close = _close,
|
.close = _close,
|
||||||
|
.destroy = destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -147,6 +147,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
.close = _close,
|
.close = _close,
|
||||||
|
.destroy = destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -14,30 +14,65 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
|
static void unmanaged_handle_commit(struct wl_listener *listener, void *data) {
|
||||||
struct sway_xwayland_unmanaged *sway_surface =
|
struct sway_xwayland_unmanaged *surface =
|
||||||
wl_container_of(listener, sway_surface, destroy);
|
wl_container_of(listener, surface, commit);
|
||||||
wl_list_remove(&sway_surface->destroy.link);
|
// TODO: damage tracking
|
||||||
wl_list_remove(&sway_surface->link);
|
|
||||||
free(sway_surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_unmanaged(struct wlr_xwayland_surface *xsurface) {
|
static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
|
||||||
struct sway_xwayland_unmanaged *sway_surface =
|
struct sway_xwayland_unmanaged *surface =
|
||||||
|
wl_container_of(listener, surface, map);
|
||||||
|
struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
|
||||||
|
wl_list_insert(&root_container.sway_root->xwayland_unmanaged,
|
||||||
|
&surface->link);
|
||||||
|
wl_signal_add(&xsurface->surface->events.commit, &surface->commit);
|
||||||
|
surface->commit.notify = unmanaged_handle_commit;
|
||||||
|
// TODO: damage tracking
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_xwayland_unmanaged *surface =
|
||||||
|
wl_container_of(listener, surface, unmap);
|
||||||
|
wl_list_remove(&surface->link);
|
||||||
|
wl_list_remove(&surface->commit.link);
|
||||||
|
// TODO: damage tracking
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_xwayland_unmanaged *surface =
|
||||||
|
wl_container_of(listener, surface, destroy);
|
||||||
|
struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
|
||||||
|
if (xsurface->mapped) {
|
||||||
|
unmanaged_handle_unmap(&surface->unmap, xsurface);
|
||||||
|
}
|
||||||
|
wl_list_remove(&surface->map.link);
|
||||||
|
wl_list_remove(&surface->unmap.link);
|
||||||
|
wl_list_remove(&surface->destroy.link);
|
||||||
|
free(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct sway_xwayland_unmanaged *create_unmanaged(
|
||||||
|
struct wlr_xwayland_surface *xsurface) {
|
||||||
|
struct sway_xwayland_unmanaged *surface =
|
||||||
calloc(1, sizeof(struct sway_xwayland_unmanaged));
|
calloc(1, sizeof(struct sway_xwayland_unmanaged));
|
||||||
if (!sway_assert(sway_surface, "Failed to allocate surface")) {
|
if (surface == NULL) {
|
||||||
return;
|
wlr_log(L_ERROR, "Allocation failed");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_surface->wlr_xwayland_surface = xsurface;
|
surface->wlr_xwayland_surface = xsurface;
|
||||||
|
|
||||||
wl_signal_add(&xsurface->events.destroy, &sway_surface->destroy);
|
wl_signal_add(&xsurface->events.map, &surface->map);
|
||||||
sway_surface->destroy.notify = unmanaged_handle_destroy;
|
surface->map.notify = unmanaged_handle_map;
|
||||||
|
wl_signal_add(&xsurface->events.unmap, &surface->unmap);
|
||||||
|
surface->unmap.notify = unmanaged_handle_unmap;
|
||||||
|
wl_signal_add(&xsurface->events.destroy, &surface->destroy);
|
||||||
|
surface->destroy.notify = unmanaged_handle_destroy;
|
||||||
|
|
||||||
wl_list_insert(&root_container.sway_root->xwayland_unmanaged,
|
unmanaged_handle_map(&surface->map, xsurface);
|
||||||
&sway_surface->link);
|
|
||||||
|
|
||||||
// TODO: damage tracking
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +162,7 @@ static const struct sway_view_impl view_impl = {
|
||||||
.configure = configure,
|
.configure = configure,
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
.close = _close,
|
.close = _close,
|
||||||
|
.destroy = destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
|
|
Loading…
Reference in a new issue