xwayland and somemother stuff
This commit is contained in:
+38
-12
@@ -1,3 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
@@ -23,6 +25,15 @@ bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_surface *absinthe_toplevel_surface(struct absinthe_toplevel *toplevel)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (absinthe_toplevel_is_x11(toplevel))
|
||||
return toplevel->toplevel.x11->surface;
|
||||
#endif
|
||||
return toplevel->toplevel.xdg->base->surface;
|
||||
}
|
||||
|
||||
void absinthe_toplevel_map(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
|
||||
@@ -34,9 +45,14 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data)
|
||||
? 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);
|
||||
#ifdef XWAYLAND
|
||||
if (absinthe_toplevel_is_x11(toplevel)) {
|
||||
toplevel->scene_surface = wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.x11->surface);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
toplevel->scene_surface = wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.xdg->base->surface);
|
||||
}
|
||||
toplevel->scene_surface->node.data = toplevel;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
@@ -60,11 +76,14 @@ 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);
|
||||
if (toplevel == toplevel->server->focused_toplevel)
|
||||
toplevel->server->focused_toplevel = NULL;
|
||||
|
||||
wl_list_remove(&toplevel->link);
|
||||
wl_list_remove(&toplevel->flink);
|
||||
|
||||
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
||||
|
||||
layout_arrange(toplevel->output);
|
||||
}
|
||||
|
||||
@@ -162,8 +181,15 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt
|
||||
{
|
||||
if (width < 0 || height < 0)
|
||||
return;
|
||||
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
|
||||
if (toplevel->type == ABSINTHE_TOPLEVEL_XDG)
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
|
||||
#ifdef XWAYLAND
|
||||
else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) {
|
||||
wlr_xwayland_surface_configure(toplevel->toplevel.x11,
|
||||
toplevel->geometry.x, toplevel->geometry.y, width, height);
|
||||
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen)
|
||||
@@ -201,16 +227,16 @@ void absinthe_toplevel_update_borders_geometry(struct absinthe_toplevel *topleve
|
||||
if (toplevel->geometry.width - 2 * border_width < 0 || toplevel->geometry.height - 2 * border_width < 0)
|
||||
return;
|
||||
|
||||
wlr_scene_node_set_position(&toplevel->scene_tree->node, toplevel->geometry.x, toplevel->geometry.y);
|
||||
wlr_scene_node_set_position(&toplevel->scene_surface->node, border_width, border_width);
|
||||
wlr_scene_node_set_position(&toplevel->scene_tree->node, toplevel->geometry.x, toplevel->geometry.y);
|
||||
wlr_scene_node_set_position(&toplevel->scene_surface->node, border_width, border_width);
|
||||
|
||||
wlr_scene_rect_set_size(toplevel->border[0], toplevel->geometry.width - 2 * border_width, border_width);
|
||||
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * border_width, border_width);
|
||||
wlr_scene_rect_set_size(toplevel->border[2], border_width, toplevel->geometry.height);
|
||||
wlr_scene_rect_set_size(toplevel->border[3], border_width, toplevel->geometry.height);
|
||||
|
||||
wlr_scene_node_set_position(&toplevel->border[0]->node, border_width, 0);
|
||||
wlr_scene_node_set_position(&toplevel->border[1]->node, border_width, toplevel->geometry.height - border_width);
|
||||
wlr_scene_node_set_position(&toplevel->border[2]->node, 0, 0);
|
||||
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - border_width, 0);
|
||||
wlr_scene_node_set_position(&toplevel->border[0]->node, border_width, 0);
|
||||
wlr_scene_node_set_position(&toplevel->border[1]->node, border_width, toplevel->geometry.height - border_width);
|
||||
wlr_scene_node_set_position(&toplevel->border[2]->node, 0, 0);
|
||||
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - border_width, 0);
|
||||
}
|
||||
|
||||
+7
-6
@@ -1,3 +1,4 @@
|
||||
#include "absinthe-toplevel.h"
|
||||
#include "types.h"
|
||||
|
||||
void layout_arrange(struct absinthe_output *output)
|
||||
@@ -24,11 +25,11 @@ void layout_arrange(struct absinthe_output *output)
|
||||
break;
|
||||
}
|
||||
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg,
|
||||
output->geometry.width - borders_width - 2 * output_gap,
|
||||
output->geometry.height - borders_width - 2 * output_gap);
|
||||
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||
toplevel->geometry.y = output->geometry.y + output_gap;
|
||||
absinthe_toplevel_set_size(toplevel,
|
||||
output->geometry.width - borders_width - 2 * output_gap,
|
||||
output->geometry.height - borders_width - 2 * output_gap);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,9 +48,9 @@ void layout_arrange(struct absinthe_output *output)
|
||||
continue;
|
||||
|
||||
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
|
||||
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||
toplevel->geometry.y = output->geometry.y + dy;
|
||||
absinthe_toplevel_set_size(toplevel, main_stack_width, height);
|
||||
dy += height + borders_width + layout_gap;
|
||||
|
||||
i++;
|
||||
@@ -64,17 +65,17 @@ void layout_arrange(struct absinthe_output *output)
|
||||
|
||||
if (i < ABSINTHE_MAIN_STACK_SIZE) {
|
||||
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
|
||||
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||
toplevel->geometry.y = output->geometry.y + dy;
|
||||
absinthe_toplevel_set_size(toplevel, main_stack_width, height);
|
||||
dy += height + borders_width + layout_gap;
|
||||
} else {
|
||||
if (i == ABSINTHE_MAIN_STACK_SIZE)
|
||||
dy = output_gap;
|
||||
height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width;
|
||||
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
|
||||
toplevel->geometry.x = output->geometry.x + main_stack_width + layout_gap + output_gap;
|
||||
toplevel->geometry.y = output->geometry.y + dy;
|
||||
absinthe_toplevel_set_size(toplevel, width, height);
|
||||
dy += height + borders_width + layout_gap;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -32,7 +32,7 @@ void xwayland_dissociate(struct wl_listener *listener, void *data)
|
||||
|
||||
void xwayland_configure(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_activate);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_configure);
|
||||
struct wlr_xwayland_surface_configure_event *event = data;
|
||||
|
||||
if (!toplevel->toplevel.x11->surface || !toplevel->toplevel.x11->surface->mapped) {
|
||||
@@ -41,10 +41,10 @@ void xwayland_configure(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
if (absinthe_toplevel_is_unmanaged(toplevel)) {
|
||||
wlr_scene_node_set_position(&toplevel->scene_tree->node, event->x, event->y);
|
||||
wlr_xwayland_surface_configure(toplevel->toplevel.x11,
|
||||
event->x, event->y, event->width, event->height);
|
||||
return;
|
||||
wlr_scene_node_set_position(&toplevel->scene_tree->node, event->x, event->y);
|
||||
wlr_xwayland_surface_configure(toplevel->toplevel.x11,
|
||||
event->x, event->y, event->width, event->height);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user