adding xwayland support
This commit is contained in:
@@ -3,6 +3,14 @@
|
|||||||
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel);
|
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel);
|
||||||
bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel);
|
bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel);
|
||||||
|
|
||||||
|
void absinthe_toplevel_map(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_unmap(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_destroy(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_request_move(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_request_resize(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_request_maximize(struct wl_listener *listener, void *data);
|
||||||
|
void absinthe_toplevel_request_fullscreen(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy);
|
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy);
|
||||||
|
|
||||||
void absinthe_toplevel_set_position(struct absinthe_toplevel *toplevel, int32_t x, int32_t y);
|
void absinthe_toplevel_set_position(struct absinthe_toplevel *toplevel, int32_t x, int32_t y);
|
||||||
|
|||||||
@@ -2,11 +2,4 @@
|
|||||||
|
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
|
|
||||||
void xdg_toplevel_map(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_unmap(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_commit(struct wl_listener *listener, void *data);
|
void xdg_toplevel_commit(struct wl_listener *listener, void *data);
|
||||||
void xdg_toplevel_destroy(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_request_move(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_request_resize(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_request_maximize(struct wl_listener *listener, void *data);
|
|
||||||
void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data);
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "absinthe-toplevel.h"
|
||||||
|
#include "output.h"
|
||||||
|
#include "layout.h"
|
||||||
|
|
||||||
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel)
|
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel)
|
||||||
{
|
{
|
||||||
@@ -20,6 +23,106 @@ bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_map(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
|
||||||
|
|
||||||
|
toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree);
|
||||||
|
toplevel->scene_tree->node.data = toplevel;
|
||||||
|
|
||||||
|
toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
|
||||||
|
? 0
|
||||||
|
: ABSINTHE_TOPLEVEL_BORDER_WIDTH;
|
||||||
|
|
||||||
|
toplevel->scene_surface = toplevel->type == ABSINTHE_TOPLEVEL_XDG
|
||||||
|
? wlr_scene_xdg_surface_create(toplevel->scene_tree, toplevel->toplevel.xdg->base)
|
||||||
|
: wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.x11->surface);
|
||||||
|
toplevel->scene_surface->node.data = toplevel;
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
toplevel->border[i] = wlr_scene_rect_create(toplevel->scene_tree, 0, 0, unfocused_border_color);
|
||||||
|
toplevel->border[i]->node.data = toplevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH;
|
||||||
|
|
||||||
|
update_focused_output(toplevel->server);
|
||||||
|
toplevel->output = toplevel->server->focused_output;
|
||||||
|
toplevel->fullscreen = false;
|
||||||
|
|
||||||
|
wl_list_insert(&toplevel->server->toplevels, &toplevel->link);
|
||||||
|
wl_list_insert(&toplevel->server->focus_stack, &toplevel->flink);
|
||||||
|
|
||||||
|
layout_arrange(toplevel->output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, unmap);
|
||||||
|
|
||||||
|
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
||||||
|
|
||||||
|
wl_list_remove(&toplevel->link);
|
||||||
|
wl_list_remove(&toplevel->flink);
|
||||||
|
|
||||||
|
layout_arrange(toplevel->output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, destroy);
|
||||||
|
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (absinthe_toplevel_is_x11(toplevel)) {
|
||||||
|
wl_list_remove(&toplevel->xwayland_activate.link);
|
||||||
|
wl_list_remove(&toplevel->xwayland_associate.link);
|
||||||
|
wl_list_remove(&toplevel->xwayland_dissociate.link);
|
||||||
|
wl_list_remove(&toplevel->xwayland_configure.link);
|
||||||
|
wl_list_remove(&toplevel->xwayland_set_hints.link);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
wl_list_remove(&toplevel->map.link);
|
||||||
|
wl_list_remove(&toplevel->unmap.link);
|
||||||
|
wl_list_remove(&toplevel->commit.link);
|
||||||
|
wl_list_remove(&toplevel->request_move.link);
|
||||||
|
wl_list_remove(&toplevel->request_resize.link);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_list_remove(&toplevel->destroy.link);
|
||||||
|
wl_list_remove(&toplevel->request_maximize.link);
|
||||||
|
wl_list_remove(&toplevel->request_fullscreen.link);
|
||||||
|
|
||||||
|
free(toplevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_request_move(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_request_resize(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_request_maximize(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
|
}
|
||||||
|
|
||||||
|
void absinthe_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_fullscreen);
|
||||||
|
absinthe_toplevel_set_fullscreen(toplevel, toplevel->toplevel.xdg->requested.fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
|
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
|
||||||
{
|
{
|
||||||
struct wlr_scene_node *node = wlr_scene_node_at(&server->scene->tree.node, lx, ly, sx, sy);
|
struct wlr_scene_node *node = wlr_scene_node_at(&server->scene->tree.node, lx, ly, sx, sy);
|
||||||
|
|||||||
+13
-12
@@ -69,23 +69,24 @@ void server_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
|||||||
toplevel->toplevel.xdg = xdg_toplevel;
|
toplevel->toplevel.xdg = xdg_toplevel;
|
||||||
toplevel->toplevel.xdg->base->data = toplevel;
|
toplevel->toplevel.xdg->base->data = toplevel;
|
||||||
|
|
||||||
toplevel->map.notify = xdg_toplevel_map;
|
|
||||||
wl_signal_add(&xdg_toplevel->base->surface->events.map, &toplevel->map);
|
|
||||||
toplevel->unmap.notify = xdg_toplevel_unmap;
|
|
||||||
wl_signal_add(&xdg_toplevel->base->surface->events.unmap, &toplevel->unmap);
|
|
||||||
toplevel->commit.notify = xdg_toplevel_commit;
|
toplevel->commit.notify = xdg_toplevel_commit;
|
||||||
wl_signal_add(&xdg_toplevel->base->surface->events.commit, &toplevel->commit);
|
wl_signal_add(&xdg_toplevel->base->surface->events.commit, &toplevel->commit);
|
||||||
|
|
||||||
toplevel->destroy.notify = xdg_toplevel_destroy;
|
toplevel->map.notify = absinthe_toplevel_map;
|
||||||
|
wl_signal_add(&xdg_toplevel->base->surface->events.map, &toplevel->map);
|
||||||
|
toplevel->unmap.notify = absinthe_toplevel_unmap;
|
||||||
|
wl_signal_add(&xdg_toplevel->base->surface->events.unmap, &toplevel->unmap);
|
||||||
|
|
||||||
|
toplevel->destroy.notify = absinthe_toplevel_destroy;
|
||||||
wl_signal_add(&xdg_toplevel->events.destroy, &toplevel->destroy);
|
wl_signal_add(&xdg_toplevel->events.destroy, &toplevel->destroy);
|
||||||
|
|
||||||
toplevel->request_move.notify = xdg_toplevel_request_move;
|
toplevel->request_move.notify = absinthe_toplevel_request_move;
|
||||||
wl_signal_add(&xdg_toplevel->events.request_move, &toplevel->request_move);
|
wl_signal_add(&xdg_toplevel->events.request_move, &toplevel->request_move);
|
||||||
toplevel->request_resize.notify = xdg_toplevel_request_resize;
|
toplevel->request_resize.notify = absinthe_toplevel_request_resize;
|
||||||
wl_signal_add(&xdg_toplevel->events.request_resize, &toplevel->request_resize);
|
wl_signal_add(&xdg_toplevel->events.request_resize, &toplevel->request_resize);
|
||||||
toplevel->request_maximize.notify = xdg_toplevel_request_maximize;
|
toplevel->request_maximize.notify = absinthe_toplevel_request_maximize;
|
||||||
wl_signal_add(&xdg_toplevel->events.request_maximize, &toplevel->request_maximize);
|
wl_signal_add(&xdg_toplevel->events.request_maximize, &toplevel->request_maximize);
|
||||||
toplevel->request_fullscreen.notify = xdg_toplevel_request_fullscreen;
|
toplevel->request_fullscreen.notify = absinthe_toplevel_request_fullscreen;
|
||||||
wl_signal_add(&xdg_toplevel->events.request_fullscreen, &toplevel->request_fullscreen);
|
wl_signal_add(&xdg_toplevel->events.request_fullscreen, &toplevel->request_fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +149,11 @@ void server_xwayland_new_surface(struct wl_listener *listener, void *data)
|
|||||||
toplevel->server = server;
|
toplevel->server = server;
|
||||||
toplevel->toplevel.x11 = surface;
|
toplevel->toplevel.x11 = surface;
|
||||||
|
|
||||||
toplevel->destroy.notify = xdg_toplevel_destroy;
|
toplevel->destroy.notify = absinthe_toplevel_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &toplevel->destroy);
|
wl_signal_add(&surface->events.destroy, &toplevel->destroy);
|
||||||
toplevel->request_maximize.notify = xdg_toplevel_request_maximize;
|
toplevel->request_maximize.notify = absinthe_toplevel_request_maximize;
|
||||||
wl_signal_add(&surface->events.request_maximize, &toplevel->request_maximize);
|
wl_signal_add(&surface->events.request_maximize, &toplevel->request_maximize);
|
||||||
toplevel->request_fullscreen.notify = xdg_toplevel_request_fullscreen;
|
toplevel->request_fullscreen.notify = absinthe_toplevel_request_fullscreen;
|
||||||
wl_signal_add(&surface->events.request_fullscreen, &toplevel->request_fullscreen);
|
wl_signal_add(&surface->events.request_fullscreen, &toplevel->request_fullscreen);
|
||||||
|
|
||||||
toplevel->xwayland_activate.notify = xwayland_activate;
|
toplevel->xwayland_activate.notify = xwayland_activate;
|
||||||
|
|||||||
@@ -32,103 +32,3 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data)
|
|||||||
toplevel->performing_resize = false;
|
toplevel->performing_resize = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xdg_toplevel_map(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
|
|
||||||
|
|
||||||
toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree);
|
|
||||||
toplevel->scene_tree->node.data = toplevel;
|
|
||||||
|
|
||||||
toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
|
|
||||||
? 0
|
|
||||||
: ABSINTHE_TOPLEVEL_BORDER_WIDTH;
|
|
||||||
|
|
||||||
toplevel->scene_surface = toplevel->type == ABSINTHE_TOPLEVEL_XDG
|
|
||||||
? wlr_scene_xdg_surface_create(toplevel->scene_tree, toplevel->toplevel.xdg->base)
|
|
||||||
: wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.x11->surface);
|
|
||||||
toplevel->scene_surface->node.data = toplevel;
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
toplevel->border[i] = wlr_scene_rect_create(toplevel->scene_tree, 0, 0, unfocused_border_color);
|
|
||||||
toplevel->border[i]->node.data = toplevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH;
|
|
||||||
|
|
||||||
update_focused_output(toplevel->server);
|
|
||||||
toplevel->output = toplevel->server->focused_output;
|
|
||||||
toplevel->fullscreen = false;
|
|
||||||
|
|
||||||
wl_list_insert(&toplevel->server->toplevels, &toplevel->link);
|
|
||||||
wl_list_insert(&toplevel->server->focus_stack, &toplevel->flink);
|
|
||||||
|
|
||||||
layout_arrange(toplevel->output);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, unmap);
|
|
||||||
|
|
||||||
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
|
||||||
|
|
||||||
wl_list_remove(&toplevel->link);
|
|
||||||
wl_list_remove(&toplevel->flink);
|
|
||||||
|
|
||||||
layout_arrange(toplevel->output);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, destroy);
|
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
|
||||||
if (absinthe_toplevel_is_x11(toplevel)) {
|
|
||||||
wl_list_remove(&toplevel->xwayland_activate.link);
|
|
||||||
wl_list_remove(&toplevel->xwayland_associate.link);
|
|
||||||
wl_list_remove(&toplevel->xwayland_dissociate.link);
|
|
||||||
wl_list_remove(&toplevel->xwayland_configure.link);
|
|
||||||
wl_list_remove(&toplevel->xwayland_set_hints.link);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
wl_list_remove(&toplevel->map.link);
|
|
||||||
wl_list_remove(&toplevel->unmap.link);
|
|
||||||
wl_list_remove(&toplevel->commit.link);
|
|
||||||
wl_list_remove(&toplevel->request_move.link);
|
|
||||||
wl_list_remove(&toplevel->request_resize.link);
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_list_remove(&toplevel->destroy.link);
|
|
||||||
wl_list_remove(&toplevel->request_maximize.link);
|
|
||||||
wl_list_remove(&toplevel->request_fullscreen.link);
|
|
||||||
|
|
||||||
free(toplevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_request_move(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
|
||||||
if (toplevel->toplevel.xdg->base->initialized)
|
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_request_resize(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
|
||||||
if (toplevel->toplevel.xdg->base->initialized)
|
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_request_maximize(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
|
||||||
if (toplevel->toplevel.xdg->base->initialized)
|
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_fullscreen);
|
|
||||||
absinthe_toplevel_set_fullscreen(toplevel, toplevel->toplevel.xdg->requested.fullscreen);
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-2
@@ -16,9 +16,9 @@ void xwayland_associate(struct wl_listener *listener, void *data)
|
|||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_associate);
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_associate);
|
||||||
|
|
||||||
toplevel->map.notify = xdg_toplevel_map;
|
toplevel->map.notify = absinthe_toplevel_map;
|
||||||
wl_signal_add(&toplevel->toplevel.x11->surface->events.map, &toplevel->map);
|
wl_signal_add(&toplevel->toplevel.x11->surface->events.map, &toplevel->map);
|
||||||
toplevel->unmap.notify = xdg_toplevel_unmap;
|
toplevel->unmap.notify = absinthe_toplevel_unmap;
|
||||||
wl_signal_add(&toplevel->toplevel.x11->surface->events.unmap, &toplevel->unmap);
|
wl_signal_add(&toplevel->toplevel.x11->surface->events.unmap, &toplevel->unmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user