diff --git a/include/absinthe-toplevel.h b/include/absinthe-toplevel.h index 8ef28c2..44283c2 100644 --- a/include/absinthe-toplevel.h +++ b/include/absinthe-toplevel.h @@ -1,5 +1,7 @@ #include "types.h" +bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel); + 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); diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..28c133e --- /dev/null +++ b/include/config.h @@ -0,0 +1,15 @@ +#pragma once + +#define ABSINTHE_CURSOR_MOD WLR_MODIFIER_ALT +#define ABSINTHE_CURSOR_MOVE_BUTTON BTN_LEFT +#define ABSINTHE_CURSOR_RESIZE_BUTTON BTN_RIGHT + +#define ABSINTHE_TOPLEVEL_BORDER_WIDTH 2 + +static const float focused_border_color[4] = {0.88, 0.18, 0.18, 1.0}; +static const float unfocused_border_color[4] = {0.18, 0.18, 0.18, 1.0}; + +#define ABSINTHE_MAIN_TOPLEVEL_WIDTH 0.5 + +#define ABSINTHE_OUTPUT_GAP 10 +#define ABSINTHE_LAYOUT_GAP 10 diff --git a/include/types.h b/include/types.h index 1cdea36..6271f98 100644 --- a/include/types.h +++ b/include/types.h @@ -16,23 +16,13 @@ #include #include -// Configuration, will be moved later +#ifdef XWAYLAND +#include +#include +#include +#endif -#define ABSINTHE_CURSOR_MOD WLR_MODIFIER_ALT -#define ABSINTHE_CURSOR_MOVE_BUTTON BTN_LEFT -#define ABSINTHE_CURSOR_RESIZE_BUTTON BTN_RIGHT - -#define ABSINTHE_WINDOW_BORDER_WIDTH 2 - -static const float focused_border_color[4] = {0.88, 0.18, 0.18, 1.0}; -static const float unfocused_border_color[4] = {0.18, 0.18, 0.18, 1.0}; - -#define ABSINTHE_MAIN_TOPLEVEL_WIDTH 0.5 - -#define ABSINTHE_OUTPUT_GAP 10 -#define ABSINTHE_LAYOUT_GAP 10 - -// Configuration end +#include "config.h" enum absinthe_cursor_mode { ABSINTHE_CURSOR_PASSTHROUGH, @@ -48,17 +38,18 @@ enum absinthe_cursor_resize_corner { }; enum absinthe_toplevel_type { - ABSINTHE_TOPLEVEL_XDG_SHELL, + ABSINTHE_TOPLEVEL_XDG, ABSINTHE_TOPLEVEL_LAYER_SHELL, ABSINTHE_TOPLEVEL_X11, }; enum absinthe_layers { ABSINTHE_LAYER_BACKGROUND, + ABSINTHE_LAYER_BOTTOM, ABSINTHE_LAYER_TILE, ABSINTHE_LAYER_FLOAT, + ABSINTHE_LAYER_TOP, ABSINTHE_LAYER_FULLSCREEN, - ABSINTHE_LAYER_POPUP, ABSINTHE_LAYER_OVERLAY, ABSINTHE_LAYER_LOCK, ABSINTHE_LAYERS_COUNT, @@ -126,6 +117,8 @@ struct absinthe_output { }; struct absinthe_toplevel { + enum absinthe_toplevel_type type; + struct wl_list link; struct wl_list flink; // for focus stack struct absinthe_server *server; @@ -135,13 +128,18 @@ struct absinthe_toplevel { int32_t border_width; struct wlr_scene_rect *border[4]; + struct wlr_xdg_toplevel_decoration_v1 *decoration; + bool fullscreen; bool performing_resize; struct wlr_box geometry; struct wlr_box prev_geometry; - struct wlr_xdg_toplevel *xdg_toplevel; + union { + struct wlr_xdg_toplevel *xdg; + struct wlr_xwayland_surface *x11; + } toplevel; struct wl_listener map; struct wl_listener unmap; struct wl_listener commit; @@ -150,9 +148,16 @@ struct absinthe_toplevel { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; - struct wlr_xdg_toplevel_decoration_v1 *decoration; struct wl_listener decoration_request_mode; struct wl_listener decoration_destroy; + +#ifdef XWAYLAND + struct wl_listener activate; + struct wl_listener associate; + struct wl_listener dissociate; + struct wl_listener configure; + struct wl_listener set_hints; +#endif }; struct absinthe_popup { diff --git a/src/absinthe-toplevel.c b/src/absinthe-toplevel.c index 5841fd3..d24cdaf 100644 --- a/src/absinthe-toplevel.c +++ b/src/absinthe-toplevel.c @@ -3,6 +3,14 @@ #include "types.h" +bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel) +{ +#ifdef XWAYLAND + return toplevel->type == ABSINTHE_TOPLEVEL_TYPE_X11; +#endif + return false; +} + 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); @@ -40,12 +48,10 @@ void absinthe_toplevel_set_position(struct absinthe_toplevel *toplevel, int32_t void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t width, int32_t height) { - int32_t bw = toplevel->border_width; - if (width < 0 || height < 0) return; - wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, width, height); + wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height); } void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen) @@ -55,7 +61,7 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f struct absinthe_output *output = toplevel->server->focused_output; toplevel->fullscreen = fullscreen; - wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, fullscreen); + wlr_xdg_toplevel_set_fullscreen(toplevel->toplevel.xdg, fullscreen); if (fullscreen) { toplevel->prev_geometry = toplevel->geometry; @@ -64,7 +70,7 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height); } else { toplevel->geometry = toplevel->prev_geometry; - toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH; + toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH; absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height); } } @@ -78,21 +84,21 @@ void absinthe_toplevel_set_border_color(struct absinthe_toplevel *toplevel, cons void absinthe_toplevel_update_borders_geometry(struct absinthe_toplevel *toplevel) { - int32_t bw = toplevel->border_width; + int32_t border_width = toplevel->border_width; - if (toplevel->geometry.width - 2 * bw < 0 || toplevel->geometry.height - 2 * bw < 0) + 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, bw, bw); + 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 * bw, bw); - wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * bw, bw); - wlr_scene_rect_set_size(toplevel->border[2], bw, toplevel->geometry.height); - wlr_scene_rect_set_size(toplevel->border[3], bw, toplevel->geometry.height); + 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, bw, 0); - wlr_scene_node_set_position(&toplevel->border[1]->node, bw, toplevel->geometry.height - bw); + 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 - bw, 0); + wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - border_width, 0); } diff --git a/src/cursor.c b/src/cursor.c index accc1ea..e1aadd0 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -9,7 +9,7 @@ void reset_cursor_mode(struct absinthe_server *server) server->cursor_mode = ABSINTHE_CURSOR_PASSTHROUGH; wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default"); if (server->focused_toplevel) { - wlr_xdg_toplevel_set_resizing(server->focused_toplevel->xdg_toplevel, false); + wlr_xdg_toplevel_set_resizing(server->focused_toplevel->toplevel.xdg, false); } } @@ -34,13 +34,13 @@ static void process_cursor_move(struct absinthe_server *server) { static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new_geometry) { - int32_t bw = toplevel->border_width; + int32_t borders_width = 2 * toplevel->border_width; - int32_t min_width = toplevel->xdg_toplevel->current.min_width; - int32_t min_height = toplevel->xdg_toplevel->current.min_height; + int32_t min_width = toplevel->toplevel.xdg->current.min_width; + int32_t min_height = toplevel->toplevel.xdg->current.min_height; - int32_t max_width = toplevel->xdg_toplevel->current.max_width; - int32_t max_height = toplevel->xdg_toplevel->current.max_height; + int32_t max_width = toplevel->toplevel.xdg->current.max_width; + int32_t max_height = toplevel->toplevel.xdg->current.max_height; if (max_width == 0) max_width = 10000; @@ -48,20 +48,20 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new if (max_height == 0) max_height = 10000; - if (new_geometry->width - 2 * bw >= min_width && new_geometry->width - 2 * bw <= max_width) { + if (new_geometry->width - borders_width >= min_width && new_geometry->width - borders_width <= max_width) { toplevel->geometry.x = new_geometry->x; toplevel->geometry.width = new_geometry->width; toplevel->performing_resize = true; } - if (new_geometry->height - 2 * bw >= min_height && new_geometry->height - 2 * bw <= max_height) { + if (new_geometry->height - borders_width >= min_height && new_geometry->height - borders_width <= max_height) { toplevel->geometry.y = new_geometry->y; toplevel->geometry.height = new_geometry->height; toplevel->performing_resize = true; } if (toplevel->performing_resize) - absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - 2 * bw, toplevel->geometry.height - 2 * bw); + absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - borders_width, toplevel->geometry.height - borders_width); } static void process_cursor_resize(struct absinthe_server *server) { diff --git a/src/focus.c b/src/focus.c index 08adb56..3ad17d0 100644 --- a/src/focus.c +++ b/src/focus.c @@ -12,7 +12,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel) struct absinthe_server *server = toplevel->server; struct wlr_seat *seat = server->seat; struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface; - struct wlr_surface *surface = toplevel->xdg_toplevel->base->surface; + struct wlr_surface *surface = toplevel->toplevel.xdg->base->surface; if (surface == prev_surface) return; @@ -31,7 +31,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel) wlr_scene_node_raise_to_top(&toplevel->scene_tree->node); wl_list_remove(&toplevel->flink); wl_list_insert(&server->focus_stack, &toplevel->flink); - wlr_xdg_toplevel_set_activated(toplevel->xdg_toplevel, true); + wlr_xdg_toplevel_set_activated(toplevel->toplevel.xdg, true); absinthe_toplevel_set_border_color(toplevel, focused_border_color); if (keyboard) diff --git a/src/layout.c b/src/layout.c index 3497940..fba31c6 100644 --- a/src/layout.c +++ b/src/layout.c @@ -16,8 +16,8 @@ void layout_arrange(struct absinthe_output *output) if (toplevels_count < 1) return; - int32_t bw = ABSINTHE_WINDOW_BORDER_WIDTH; - int32_t og = ABSINTHE_OUTPUT_GAP; + int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2; + int32_t output_gap = ABSINTHE_OUTPUT_GAP; if (toplevels_count == 1) { wl_list_for_each(toplevel, &output->server->toplevels, link) { @@ -25,35 +25,35 @@ void layout_arrange(struct absinthe_output *output) break; } - wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, - output->geometry.width - 2 * bw - 2 * og, - output->geometry.height - 2 * bw - 2 * og); - toplevel->geometry.x = output->geometry.x + og; - toplevel->geometry.y = output->geometry.y + og; + 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; return; } - int32_t w, h; - int32_t lg = ABSINTHE_LAYOUT_GAP; - int32_t mw = ABSINTHE_MAIN_TOPLEVEL_WIDTH * (output->geometry.width - 2 * og); - int32_t ty = og; + int32_t layout_gap = ABSINTHE_LAYOUT_GAP; + int32_t main_toplevel_width = ABSINTHE_MAIN_TOPLEVEL_WIDTH * (output->geometry.width - 2 * output_gap); + int32_t width, height; + width = output->geometry.width - main_toplevel_width - borders_width - layout_gap - 2 * output_gap; + int32_t dy = output_gap; size_t i = 0; wl_list_for_each(toplevel, &output->server->toplevels, link) { if (toplevel->output != output) continue; if (i == 0) { - h = output->geometry.height - 2 * bw - 2 * og; - wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, mw, h); - toplevel->geometry.x = output->geometry.x + og; - toplevel->geometry.y = output->geometry.y + og; + height = output->geometry.height - borders_width - 2 * output_gap; + wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_toplevel_width, height); + toplevel->geometry.x = output->geometry.x + output_gap; + toplevel->geometry.y = output->geometry.y + output_gap; } else { - w = output->geometry.width - mw - 2 * bw - 2 * lg - 2 * og; - h = (output->geometry.height - ty - og) / (toplevels_count - i) - 2 * bw; - wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, w, h); - toplevel->geometry.x = output->geometry.x + mw + lg + og; - toplevel->geometry.y = output->geometry.y + ty; - ty += h + 2 * bw + lg; + 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_toplevel_width + layout_gap + output_gap; + toplevel->geometry.y = output->geometry.y + dy; + dy += height + borders_width + layout_gap; } i++; diff --git a/src/server.c b/src/server.c index b76e245..15a324b 100644 --- a/src/server.c +++ b/src/server.c @@ -59,7 +59,8 @@ void server_new_xdg_toplevel(struct wl_listener *listener, void *data) struct absinthe_toplevel *toplevel = malloc(sizeof(*toplevel)); toplevel->server = server; - toplevel->xdg_toplevel = xdg_toplevel; + toplevel->type = ABSINTHE_TOPLEVEL_XDG; + toplevel->toplevel.xdg = xdg_toplevel; toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree); toplevel->scene_tree->node.data = toplevel; toplevel->scene_surface = wlr_scene_xdg_surface_create(toplevel->scene_tree, xdg_toplevel->base); @@ -150,54 +151,54 @@ void server_cursor_button(struct wl_listener *listener, void *data) struct wlr_surface *surface = NULL; struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); + if (!toplevel) + goto handle; - if (toplevel) { - struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(server->seat); - uint32_t mods = wlr_keyboard_get_modifiers(keyboard); - if (mods & ABSINTHE_CURSOR_MOD) { - if (event->button == ABSINTHE_CURSOR_MOVE_BUTTON) { - server->cursor_mode = ABSINTHE_CURSOR_MOVE; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "all-scroll"); - handled = true; - } else if (event->button == ABSINTHE_CURSOR_RESIZE_BUTTON) { - server->cursor_mode = ABSINTHE_CURSOR_RESIZE; - handled = true; - } + struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(server->seat); + uint32_t mods = wlr_keyboard_get_modifiers(keyboard); + if (mods & ABSINTHE_CURSOR_MOD) { + if (event->button == ABSINTHE_CURSOR_MOVE_BUTTON) { + server->cursor_mode = ABSINTHE_CURSOR_MOVE; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "all-scroll"); + handled = true; + } else if (event->button == ABSINTHE_CURSOR_RESIZE_BUTTON) { + server->cursor_mode = ABSINTHE_CURSOR_RESIZE; + handled = true; } - - focus_toplevel(toplevel); - server->grab_x = server->cursor->x; - server->grab_y = server->cursor->y; - - int32_t lx, ly; - wlr_scene_node_coords(&toplevel->scene_tree->node, &lx, &ly); - server->grabbed_geometry.x = lx; - server->grabbed_geometry.y = ly; - server->grabbed_geometry.width = toplevel->geometry.width; - server->grabbed_geometry.height = toplevel->geometry.height; - - if (server->cursor_mode != ABSINTHE_CURSOR_RESIZE) - goto handle; - - int32_t width = toplevel->xdg_toplevel->base->geometry.width; - int32_t height = toplevel->xdg_toplevel->base->geometry.height; - - if (server->grab_x > (lx + width / 2) && server->grab_y > (ly + height / 2)) { - server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_RIGHT; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "se-resize"); - } else if (server->grab_x < (lx + width / 2) && server->grab_y > (ly + height / 2)) { - server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_LEFT; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "sw-resize"); - } else if (server->grab_x > (lx + width / 2) && server->grab_y < (ly + height / 2)) { - server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_TOP_RIGHT; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "ne-resize"); - } else { - server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_TOP_LEFT; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "nw-resize"); - } - - wlr_xdg_toplevel_set_resizing(toplevel->xdg_toplevel, true); } + + focus_toplevel(toplevel); + server->grab_x = server->cursor->x; + server->grab_y = server->cursor->y; + + int32_t lx, ly; + wlr_scene_node_coords(&toplevel->scene_tree->node, &lx, &ly); + server->grabbed_geometry.x = lx; + server->grabbed_geometry.y = ly; + server->grabbed_geometry.width = toplevel->geometry.width; + server->grabbed_geometry.height = toplevel->geometry.height; + + if (server->cursor_mode != ABSINTHE_CURSOR_RESIZE) + goto handle; + + int32_t width = toplevel->toplevel.xdg->base->geometry.width; + int32_t height = toplevel->toplevel.xdg->base->geometry.height; + + if (server->grab_x > (lx + width / 2) && server->grab_y > (ly + height / 2)) { + server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_RIGHT; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "se-resize"); + } else if (server->grab_x < (lx + width / 2) && server->grab_y > (ly + height / 2)) { + server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_LEFT; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "sw-resize"); + } else if (server->grab_x > (lx + width / 2) && server->grab_y < (ly + height / 2)) { + server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_TOP_RIGHT; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "ne-resize"); + } else { + server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_TOP_LEFT; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "nw-resize"); + } + + wlr_xdg_toplevel_set_resizing(toplevel->toplevel.xdg, true); } handle: diff --git a/src/xdg-decoration.c b/src/xdg-decoration.c index 556e15d..9b8f1a8 100644 --- a/src/xdg-decoration.c +++ b/src/xdg-decoration.c @@ -5,7 +5,7 @@ void xdg_decoration_request_mode(struct wl_listener *listener, void *data) { struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, decoration_request_mode); - if (toplevel->xdg_toplevel->base->initialized) + if (toplevel->toplevel.xdg->base->initialized) wlr_xdg_toplevel_decoration_v1_set_mode(toplevel->decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } diff --git a/src/xdg-toplevel.c b/src/xdg-toplevel.c index af54c42..d8ea7c5 100644 --- a/src/xdg-toplevel.c +++ b/src/xdg-toplevel.c @@ -14,7 +14,7 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data) { struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, commit); - if (toplevel->xdg_toplevel->base->initial_commit) { + if (toplevel->toplevel.xdg->base->initial_commit) { // Forse server side decoration mode if (toplevel->decoration) xdg_decoration_request_mode(&toplevel->decoration_request_mode, toplevel->decoration); @@ -23,9 +23,9 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data) // wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0); } else { // Check for size because we did't set it on initial commit - int32_t bw = toplevel->border_width; - toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw; - toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw; + int32_t borders_width = 2 * toplevel->border_width; + toplevel->geometry.width = toplevel->toplevel.xdg->base->geometry.width + borders_width; + toplevel->geometry.height = toplevel->toplevel.xdg->base->geometry.height + borders_width; absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); absinthe_toplevel_update_borders_geometry(toplevel); @@ -42,7 +42,7 @@ void xdg_toplevel_map(struct wl_listener *listener, void *data) toplevel->border[i]->node.data = toplevel; } - toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH; + toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH; update_focused_output(toplevel->server); toplevel->output = toplevel->server->focused_output; @@ -85,26 +85,26 @@ void xdg_toplevel_destroy(struct wl_listener *listener, void *data) void xdg_toplevel_request_move(struct wl_listener *listener, void *data) { struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize); - if (toplevel->xdg_toplevel->base->initialized) - wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base); + 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->xdg_toplevel->base->initialized) - wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base); + 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->xdg_toplevel->base->initialized) - wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base); + 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->xdg_toplevel->requested.fullscreen); + absinthe_toplevel_set_fullscreen(toplevel, toplevel->toplevel.xdg->requested.fullscreen); }