mirror of
https://github.com/swaywm/sway.git
synced 2024-12-26 15:06:34 +01:00
scene_graph: port wlr_forgein_toplevel_management output enter/leave events
This commit is contained in:
parent
7c635b61fe
commit
5fc85c5066
3 changed files with 55 additions and 0 deletions
|
@ -91,6 +91,10 @@ struct sway_container {
|
||||||
} border;
|
} border;
|
||||||
|
|
||||||
struct wlr_scene_tree *content_tree;
|
struct wlr_scene_tree *content_tree;
|
||||||
|
struct wlr_scene_buffer *output_handler;
|
||||||
|
|
||||||
|
struct wl_listener output_enter;
|
||||||
|
struct wl_listener output_leave;
|
||||||
|
|
||||||
struct sway_container_state current;
|
struct sway_container_state current;
|
||||||
struct sway_container_state pending;
|
struct sway_container_state pending;
|
||||||
|
|
|
@ -385,6 +385,10 @@ static void arrange_container(struct sway_container *con,
|
||||||
// make sure it's enabled for viewing
|
// make sure it's enabled for viewing
|
||||||
wlr_scene_node_set_enabled(&con->scene_tree->node, true);
|
wlr_scene_node_set_enabled(&con->scene_tree->node, true);
|
||||||
|
|
||||||
|
if (con->output_handler) {
|
||||||
|
wlr_scene_buffer_set_dest_size(con->output_handler, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
if (con->view) {
|
if (con->view) {
|
||||||
int border_top = container_titlebar_height();
|
int border_top = container_titlebar_height();
|
||||||
int border_width = con->current.border_thickness;
|
int border_width = con->current.border_thickness;
|
||||||
|
|
|
@ -25,6 +25,35 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
|
static void handle_output_enter(
|
||||||
|
struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_container *con = wl_container_of(
|
||||||
|
listener, con, output_enter);
|
||||||
|
struct wlr_scene_output *output = data;
|
||||||
|
|
||||||
|
if (con->view->foreign_toplevel) {
|
||||||
|
wlr_foreign_toplevel_handle_v1_output_enter(
|
||||||
|
con->view->foreign_toplevel, output->output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_output_leave(
|
||||||
|
struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_container *con = wl_container_of(
|
||||||
|
listener, con, output_leave);
|
||||||
|
struct wlr_scene_output *output = data;
|
||||||
|
|
||||||
|
if (con->view->foreign_toplevel) {
|
||||||
|
wlr_foreign_toplevel_handle_v1_output_leave(
|
||||||
|
con->view->foreign_toplevel, output->output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool handle_point_accepts_input(
|
||||||
|
struct wlr_scene_buffer *buffer, double *x, double *y) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent,
|
static struct wlr_scene_rect *alloc_rect_node(struct wlr_scene_tree *parent,
|
||||||
bool *failed) {
|
bool *failed) {
|
||||||
if (*failed) {
|
if (*failed) {
|
||||||
|
@ -63,6 +92,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
// - content_tree (we put the content node here so when we disable the
|
// - content_tree (we put the content node here so when we disable the
|
||||||
// border everything gets disabled. We only render the content iff there
|
// border everything gets disabled. We only render the content iff there
|
||||||
// is a border as well)
|
// is a border as well)
|
||||||
|
// - buffer used for output enter/leave events for foreign_toplevel
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
c->scene_tree = alloc_scene_tree(root->staging, &failed);
|
c->scene_tree = alloc_scene_tree(root->staging, &failed);
|
||||||
|
|
||||||
|
@ -90,6 +120,22 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
c->border.bottom = alloc_rect_node(c->border.tree, &failed);
|
c->border.bottom = alloc_rect_node(c->border.tree, &failed);
|
||||||
c->border.left = alloc_rect_node(c->border.tree, &failed);
|
c->border.left = alloc_rect_node(c->border.tree, &failed);
|
||||||
c->border.right = alloc_rect_node(c->border.tree, &failed);
|
c->border.right = alloc_rect_node(c->border.tree, &failed);
|
||||||
|
|
||||||
|
c->output_handler = wlr_scene_buffer_create(c->border.tree, NULL);
|
||||||
|
if (!c->output_handler) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to allocate a scene node");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!failed) {
|
||||||
|
c->output_enter.notify = handle_output_enter;
|
||||||
|
wl_signal_add(&c->output_handler->events.output_enter,
|
||||||
|
&c->output_enter);
|
||||||
|
c->output_leave.notify = handle_output_leave;
|
||||||
|
wl_signal_add(&c->output_handler->events.output_leave,
|
||||||
|
&c->output_leave);
|
||||||
|
c->output_handler->point_accepts_input = handle_point_accepts_input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!failed && !scene_descriptor_assign(&c->scene_tree->node,
|
if (!failed && !scene_descriptor_assign(&c->scene_tree->node,
|
||||||
|
@ -456,6 +502,7 @@ void container_destroy(struct sway_container *con) {
|
||||||
|
|
||||||
if (con->view && con->view->container == con) {
|
if (con->view && con->view->container == con) {
|
||||||
con->view->container = NULL;
|
con->view->container = NULL;
|
||||||
|
wlr_scene_node_destroy(&con->output_handler->node);
|
||||||
if (con->view->destroying) {
|
if (con->view->destroying) {
|
||||||
view_destroy(con->view);
|
view_destroy(con->view);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue