adding xwayland support
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "types.h"
|
#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);
|
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);
|
||||||
|
|||||||
@@ -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
|
||||||
+25
-20
@@ -16,23 +16,13 @@
|
|||||||
#include <wlr/types/wlr_output_management_v1.h>
|
#include <wlr/types/wlr_output_management_v1.h>
|
||||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||||
|
|
||||||
// Configuration, will be moved later
|
#ifdef XWAYLAND
|
||||||
|
#include <wlr/xwayland.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_icccm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ABSINTHE_CURSOR_MOD WLR_MODIFIER_ALT
|
#include "config.h"
|
||||||
#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
|
|
||||||
|
|
||||||
enum absinthe_cursor_mode {
|
enum absinthe_cursor_mode {
|
||||||
ABSINTHE_CURSOR_PASSTHROUGH,
|
ABSINTHE_CURSOR_PASSTHROUGH,
|
||||||
@@ -48,17 +38,18 @@ enum absinthe_cursor_resize_corner {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum absinthe_toplevel_type {
|
enum absinthe_toplevel_type {
|
||||||
ABSINTHE_TOPLEVEL_XDG_SHELL,
|
ABSINTHE_TOPLEVEL_XDG,
|
||||||
ABSINTHE_TOPLEVEL_LAYER_SHELL,
|
ABSINTHE_TOPLEVEL_LAYER_SHELL,
|
||||||
ABSINTHE_TOPLEVEL_X11,
|
ABSINTHE_TOPLEVEL_X11,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum absinthe_layers {
|
enum absinthe_layers {
|
||||||
ABSINTHE_LAYER_BACKGROUND,
|
ABSINTHE_LAYER_BACKGROUND,
|
||||||
|
ABSINTHE_LAYER_BOTTOM,
|
||||||
ABSINTHE_LAYER_TILE,
|
ABSINTHE_LAYER_TILE,
|
||||||
ABSINTHE_LAYER_FLOAT,
|
ABSINTHE_LAYER_FLOAT,
|
||||||
|
ABSINTHE_LAYER_TOP,
|
||||||
ABSINTHE_LAYER_FULLSCREEN,
|
ABSINTHE_LAYER_FULLSCREEN,
|
||||||
ABSINTHE_LAYER_POPUP,
|
|
||||||
ABSINTHE_LAYER_OVERLAY,
|
ABSINTHE_LAYER_OVERLAY,
|
||||||
ABSINTHE_LAYER_LOCK,
|
ABSINTHE_LAYER_LOCK,
|
||||||
ABSINTHE_LAYERS_COUNT,
|
ABSINTHE_LAYERS_COUNT,
|
||||||
@@ -126,6 +117,8 @@ struct absinthe_output {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct absinthe_toplevel {
|
struct absinthe_toplevel {
|
||||||
|
enum absinthe_toplevel_type type;
|
||||||
|
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list flink; // for focus stack
|
struct wl_list flink; // for focus stack
|
||||||
struct absinthe_server *server;
|
struct absinthe_server *server;
|
||||||
@@ -135,13 +128,18 @@ struct absinthe_toplevel {
|
|||||||
|
|
||||||
int32_t border_width;
|
int32_t border_width;
|
||||||
struct wlr_scene_rect *border[4];
|
struct wlr_scene_rect *border[4];
|
||||||
|
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||||
|
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool performing_resize;
|
bool performing_resize;
|
||||||
|
|
||||||
struct wlr_box geometry;
|
struct wlr_box geometry;
|
||||||
struct wlr_box prev_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 map;
|
||||||
struct wl_listener unmap;
|
struct wl_listener unmap;
|
||||||
struct wl_listener commit;
|
struct wl_listener commit;
|
||||||
@@ -150,9 +148,16 @@ struct absinthe_toplevel {
|
|||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
struct wl_listener request_maximize;
|
struct wl_listener request_maximize;
|
||||||
struct wl_listener request_fullscreen;
|
struct wl_listener request_fullscreen;
|
||||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
|
||||||
struct wl_listener decoration_request_mode;
|
struct wl_listener decoration_request_mode;
|
||||||
struct wl_listener decoration_destroy;
|
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 {
|
struct absinthe_popup {
|
||||||
|
|||||||
+21
-15
@@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#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 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);
|
||||||
@@ -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)
|
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)
|
if (width < 0 || height < 0)
|
||||||
return;
|
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)
|
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;
|
struct absinthe_output *output = toplevel->server->focused_output;
|
||||||
toplevel->fullscreen = fullscreen;
|
toplevel->fullscreen = fullscreen;
|
||||||
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, fullscreen);
|
wlr_xdg_toplevel_set_fullscreen(toplevel->toplevel.xdg, fullscreen);
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
toplevel->prev_geometry = toplevel->geometry;
|
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);
|
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height);
|
||||||
} else {
|
} else {
|
||||||
toplevel->geometry = toplevel->prev_geometry;
|
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);
|
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)
|
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;
|
return;
|
||||||
|
|
||||||
wlr_scene_node_set_position(&toplevel->scene_tree->node, toplevel->geometry.x, toplevel->geometry.y);
|
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[0], toplevel->geometry.width - 2 * border_width, border_width);
|
||||||
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * bw, bw);
|
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * border_width, border_width);
|
||||||
wlr_scene_rect_set_size(toplevel->border[2], bw, toplevel->geometry.height);
|
wlr_scene_rect_set_size(toplevel->border[2], border_width, toplevel->geometry.height);
|
||||||
wlr_scene_rect_set_size(toplevel->border[3], bw, 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[0]->node, border_width, 0);
|
||||||
wlr_scene_node_set_position(&toplevel->border[1]->node, bw, toplevel->geometry.height - bw);
|
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[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);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -9,7 +9,7 @@ void reset_cursor_mode(struct absinthe_server *server)
|
|||||||
server->cursor_mode = ABSINTHE_CURSOR_PASSTHROUGH;
|
server->cursor_mode = ABSINTHE_CURSOR_PASSTHROUGH;
|
||||||
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default");
|
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default");
|
||||||
if (server->focused_toplevel) {
|
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)
|
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_width = toplevel->toplevel.xdg->current.min_width;
|
||||||
int32_t min_height = toplevel->xdg_toplevel->current.min_height;
|
int32_t min_height = toplevel->toplevel.xdg->current.min_height;
|
||||||
|
|
||||||
int32_t max_width = toplevel->xdg_toplevel->current.max_width;
|
int32_t max_width = toplevel->toplevel.xdg->current.max_width;
|
||||||
int32_t max_height = toplevel->xdg_toplevel->current.max_height;
|
int32_t max_height = toplevel->toplevel.xdg->current.max_height;
|
||||||
|
|
||||||
if (max_width == 0)
|
if (max_width == 0)
|
||||||
max_width = 10000;
|
max_width = 10000;
|
||||||
@@ -48,20 +48,20 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new
|
|||||||
if (max_height == 0)
|
if (max_height == 0)
|
||||||
max_height = 10000;
|
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.x = new_geometry->x;
|
||||||
toplevel->geometry.width = new_geometry->width;
|
toplevel->geometry.width = new_geometry->width;
|
||||||
toplevel->performing_resize = true;
|
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.y = new_geometry->y;
|
||||||
toplevel->geometry.height = new_geometry->height;
|
toplevel->geometry.height = new_geometry->height;
|
||||||
toplevel->performing_resize = true;
|
toplevel->performing_resize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toplevel->performing_resize)
|
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) {
|
static void process_cursor_resize(struct absinthe_server *server) {
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
|
|||||||
struct absinthe_server *server = toplevel->server;
|
struct absinthe_server *server = toplevel->server;
|
||||||
struct wlr_seat *seat = server->seat;
|
struct wlr_seat *seat = server->seat;
|
||||||
struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;
|
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)
|
if (surface == prev_surface)
|
||||||
return;
|
return;
|
||||||
@@ -31,7 +31,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
|
|||||||
wlr_scene_node_raise_to_top(&toplevel->scene_tree->node);
|
wlr_scene_node_raise_to_top(&toplevel->scene_tree->node);
|
||||||
wl_list_remove(&toplevel->flink);
|
wl_list_remove(&toplevel->flink);
|
||||||
wl_list_insert(&server->focus_stack, &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);
|
absinthe_toplevel_set_border_color(toplevel, focused_border_color);
|
||||||
|
|
||||||
if (keyboard)
|
if (keyboard)
|
||||||
|
|||||||
+21
-21
@@ -16,8 +16,8 @@ void layout_arrange(struct absinthe_output *output)
|
|||||||
if (toplevels_count < 1)
|
if (toplevels_count < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int32_t bw = ABSINTHE_WINDOW_BORDER_WIDTH;
|
int32_t borders_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH * 2;
|
||||||
int32_t og = ABSINTHE_OUTPUT_GAP;
|
int32_t output_gap = ABSINTHE_OUTPUT_GAP;
|
||||||
|
|
||||||
if (toplevels_count == 1) {
|
if (toplevels_count == 1) {
|
||||||
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
||||||
@@ -25,35 +25,35 @@ void layout_arrange(struct absinthe_output *output)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel,
|
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg,
|
||||||
output->geometry.width - 2 * bw - 2 * og,
|
output->geometry.width - borders_width - 2 * output_gap,
|
||||||
output->geometry.height - 2 * bw - 2 * og);
|
output->geometry.height - borders_width - 2 * output_gap);
|
||||||
toplevel->geometry.x = output->geometry.x + og;
|
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||||
toplevel->geometry.y = output->geometry.y + og;
|
toplevel->geometry.y = output->geometry.y + output_gap;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t w, h;
|
int32_t layout_gap = ABSINTHE_LAYOUT_GAP;
|
||||||
int32_t lg = ABSINTHE_LAYOUT_GAP;
|
int32_t main_toplevel_width = ABSINTHE_MAIN_TOPLEVEL_WIDTH * (output->geometry.width - 2 * output_gap);
|
||||||
int32_t mw = ABSINTHE_MAIN_TOPLEVEL_WIDTH * (output->geometry.width - 2 * og);
|
int32_t width, height;
|
||||||
int32_t ty = og;
|
width = output->geometry.width - main_toplevel_width - borders_width - layout_gap - 2 * output_gap;
|
||||||
|
int32_t dy = output_gap;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
||||||
if (toplevel->output != output)
|
if (toplevel->output != output)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
h = output->geometry.height - 2 * bw - 2 * og;
|
height = output->geometry.height - borders_width - 2 * output_gap;
|
||||||
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, mw, h);
|
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_toplevel_width, height);
|
||||||
toplevel->geometry.x = output->geometry.x + og;
|
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||||
toplevel->geometry.y = output->geometry.y + og;
|
toplevel->geometry.y = output->geometry.y + output_gap;
|
||||||
} else {
|
} else {
|
||||||
w = output->geometry.width - mw - 2 * bw - 2 * lg - 2 * og;
|
height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width;
|
||||||
h = (output->geometry.height - ty - og) / (toplevels_count - i) - 2 * bw;
|
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
|
||||||
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, w, h);
|
toplevel->geometry.x = output->geometry.x + main_toplevel_width + layout_gap + output_gap;
|
||||||
toplevel->geometry.x = output->geometry.x + mw + lg + og;
|
toplevel->geometry.y = output->geometry.y + dy;
|
||||||
toplevel->geometry.y = output->geometry.y + ty;
|
dy += height + borders_width + layout_gap;
|
||||||
ty += h + 2 * bw + lg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
+7
-6
@@ -59,7 +59,8 @@ void server_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
|||||||
|
|
||||||
struct absinthe_toplevel *toplevel = malloc(sizeof(*toplevel));
|
struct absinthe_toplevel *toplevel = malloc(sizeof(*toplevel));
|
||||||
toplevel->server = server;
|
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 = wlr_scene_tree_create(&toplevel->server->scene->tree);
|
||||||
toplevel->scene_tree->node.data = toplevel;
|
toplevel->scene_tree->node.data = toplevel;
|
||||||
toplevel->scene_surface = wlr_scene_xdg_surface_create(toplevel->scene_tree, xdg_toplevel->base);
|
toplevel->scene_surface = wlr_scene_xdg_surface_create(toplevel->scene_tree, xdg_toplevel->base);
|
||||||
@@ -150,8 +151,9 @@ void server_cursor_button(struct wl_listener *listener, void *data)
|
|||||||
struct wlr_surface *surface = NULL;
|
struct wlr_surface *surface = NULL;
|
||||||
struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy);
|
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);
|
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(server->seat);
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(keyboard);
|
uint32_t mods = wlr_keyboard_get_modifiers(keyboard);
|
||||||
if (mods & ABSINTHE_CURSOR_MOD) {
|
if (mods & ABSINTHE_CURSOR_MOD) {
|
||||||
@@ -179,8 +181,8 @@ void server_cursor_button(struct wl_listener *listener, void *data)
|
|||||||
if (server->cursor_mode != ABSINTHE_CURSOR_RESIZE)
|
if (server->cursor_mode != ABSINTHE_CURSOR_RESIZE)
|
||||||
goto handle;
|
goto handle;
|
||||||
|
|
||||||
int32_t width = toplevel->xdg_toplevel->base->geometry.width;
|
int32_t width = toplevel->toplevel.xdg->base->geometry.width;
|
||||||
int32_t height = toplevel->xdg_toplevel->base->geometry.height;
|
int32_t height = toplevel->toplevel.xdg->base->geometry.height;
|
||||||
|
|
||||||
if (server->grab_x > (lx + width / 2) && server->grab_y > (ly + height / 2)) {
|
if (server->grab_x > (lx + width / 2) && server->grab_y > (ly + height / 2)) {
|
||||||
server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_RIGHT;
|
server->cursor_resize_corner = ABSINTHE_CURSOR_RESIZE_CORNER_BOTTOM_RIGHT;
|
||||||
@@ -196,8 +198,7 @@ void server_cursor_button(struct wl_listener *listener, void *data)
|
|||||||
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "nw-resize");
|
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "nw-resize");
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_resizing(toplevel->xdg_toplevel, true);
|
wlr_xdg_toplevel_set_resizing(toplevel->toplevel.xdg, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle:
|
handle:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
void xdg_decoration_request_mode(struct wl_listener *listener, void *data)
|
void xdg_decoration_request_mode(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, decoration_request_mode);
|
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);
|
wlr_xdg_toplevel_decoration_v1_set_mode(toplevel->decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -14,7 +14,7 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data)
|
|||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, commit);
|
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
|
// Forse server side decoration mode
|
||||||
if (toplevel->decoration)
|
if (toplevel->decoration)
|
||||||
xdg_decoration_request_mode(&toplevel->decoration_request_mode, 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);
|
// wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
// Check for size because we did't set it on initial commit
|
// Check for size because we did't set it on initial commit
|
||||||
int32_t bw = toplevel->border_width;
|
int32_t borders_width = 2 * toplevel->border_width;
|
||||||
toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw;
|
toplevel->geometry.width = toplevel->toplevel.xdg->base->geometry.width + borders_width;
|
||||||
toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw;
|
toplevel->geometry.height = toplevel->toplevel.xdg->base->geometry.height + borders_width;
|
||||||
|
|
||||||
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
|
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
|
||||||
absinthe_toplevel_update_borders_geometry(toplevel);
|
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[i]->node.data = toplevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH;
|
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH;
|
||||||
|
|
||||||
update_focused_output(toplevel->server);
|
update_focused_output(toplevel->server);
|
||||||
toplevel->output = toplevel->server->focused_output;
|
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)
|
void xdg_toplevel_request_move(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
if (toplevel->xdg_toplevel->base->initialized)
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xdg_toplevel_request_resize(struct wl_listener *listener, void *data)
|
void xdg_toplevel_request_resize(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
if (toplevel->xdg_toplevel->base->initialized)
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xdg_toplevel_request_maximize(struct wl_listener *listener, void *data)
|
void xdg_toplevel_request_maximize(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||||
if (toplevel->xdg_toplevel->base->initialized)
|
if (toplevel->toplevel.xdg->base->initialized)
|
||||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_fullscreen);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user