layout functionality
This commit is contained in:
@@ -2,3 +2,4 @@ absinthe
|
||||
xdg-shell-protocol.h
|
||||
TAGS
|
||||
tags
|
||||
compile_commands.json
|
||||
|
||||
@@ -7,4 +7,5 @@ compile: proto
|
||||
gcc -o absinthe src/* \
|
||||
-DXWAYLAND \
|
||||
-I./ -I./include -DWLR_USE_UNSTABLE $(shell pkg-config wlroots-0.20 --libs --cflags) -lwayland-server -lxkbcommon \
|
||||
-O3 \
|
||||
-g
|
||||
|
||||
+6
-5
@@ -4,13 +4,14 @@
|
||||
#define ABSINTHE_CURSOR_MOVE_BUTTON BTN_LEFT
|
||||
#define ABSINTHE_CURSOR_RESIZE_BUTTON BTN_RIGHT
|
||||
|
||||
#define ABSINTHE_TOPLEVEL_BORDER_WIDTH 2
|
||||
#define ABSINTHE_TOPLEVEL_BORDER_WIDTH 1
|
||||
|
||||
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};
|
||||
static const float focused_border_color[4] = {0.64, 0.75, 0.55, 1.0};
|
||||
static const float urgent_border_color[4] = {0.84, 0.47, 0.5, 1.0};
|
||||
static const float unfocused_border_color[4] = {0.39, 0.42, 0.46, 1.0};
|
||||
|
||||
#define ABSINTHE_MAIN_STACK_WIDTH 0.5
|
||||
#define ABSINTHE_MAIN_STACK_SIZE 2
|
||||
#define ABSINTHE_MAIN_STACK_SIZE 1;
|
||||
#define ABSINTHE_MAIN_STACK_WIDTH 0.5;
|
||||
|
||||
#define ABSINTHE_OUTPUT_GAP 10
|
||||
#define ABSINTHE_LAYOUT_GAP 10
|
||||
|
||||
@@ -120,6 +120,9 @@ struct absinthe_output {
|
||||
struct wl_listener frame;
|
||||
struct wl_listener request_state;
|
||||
struct wl_listener destroy;
|
||||
|
||||
float main_stack_width;
|
||||
float main_stack_size;
|
||||
};
|
||||
|
||||
struct absinthe_toplevel {
|
||||
|
||||
+3
-2
@@ -26,7 +26,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
|
||||
if (prev_surface) {
|
||||
struct wlr_xdg_toplevel *prev_toplevel = wlr_xdg_toplevel_try_from_wlr_surface(prev_surface);
|
||||
if (prev_toplevel) {
|
||||
// wlr_xdg_toplevel_set_activated(prev_toplevel, false);
|
||||
wlr_xdg_toplevel_set_activated(prev_toplevel, false);
|
||||
absinthe_toplevel_set_border_color(prev_toplevel->base->data, unfocused_border_color);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,8 @@ 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->toplevel.xdg, true);
|
||||
if (!absinthe_toplevel_is_x11(toplevel))
|
||||
wlr_xdg_toplevel_set_activated(toplevel->toplevel.xdg, true);
|
||||
absinthe_toplevel_set_border_color(toplevel, focused_border_color);
|
||||
|
||||
if (keyboard)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "types.h"
|
||||
#include "absinthe-toplevel.h"
|
||||
#include "focus.h"
|
||||
#include "layout.h"
|
||||
|
||||
void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -42,6 +43,30 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
|
||||
case XKB_KEY_k:
|
||||
focus_prev(server);
|
||||
break;
|
||||
case XKB_KEY_h:
|
||||
if (server->focused_output && server->focused_output->main_stack_width > 0.15) {
|
||||
server->focused_output->main_stack_width -= 0.1;
|
||||
layout_arrange(server->focused_output);
|
||||
}
|
||||
break;
|
||||
case XKB_KEY_l:
|
||||
if (server->focused_output && server->focused_output->main_stack_width < 0.9) {
|
||||
server->focused_output->main_stack_width += 0.1;
|
||||
layout_arrange(server->focused_output);
|
||||
}
|
||||
break;
|
||||
case XKB_KEY_H:
|
||||
if (server->focused_output) {
|
||||
server->focused_output->main_stack_size += 1;
|
||||
layout_arrange(server->focused_output);
|
||||
}
|
||||
break;
|
||||
case XKB_KEY_L:
|
||||
if (server->focused_output && server->focused_output->main_stack_size > 1) {
|
||||
server->focused_output->main_stack_size -= 1;
|
||||
layout_arrange(server->focused_output);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
+11
-10
@@ -9,9 +9,10 @@ void layout_arrange(struct absinthe_output *output)
|
||||
struct absinthe_toplevel *toplevel;
|
||||
size_t toplevels_count = 0;
|
||||
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
||||
if (toplevel->output == output)
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true);
|
||||
if (toplevel->output == output) {
|
||||
toplevels_count++;
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (toplevels_count < 1)
|
||||
@@ -35,20 +36,20 @@ void layout_arrange(struct absinthe_output *output)
|
||||
}
|
||||
|
||||
int32_t layout_gap = ABSINTHE_LAYOUT_GAP;
|
||||
int32_t main_stack_width = (toplevels_count <= ABSINTHE_MAIN_STACK_SIZE)
|
||||
int32_t main_stack_width = (toplevels_count <= output->main_stack_size)
|
||||
? output->geometry.width - borders_width - 2 * output_gap
|
||||
: ABSINTHE_MAIN_STACK_WIDTH * (output->geometry.width - 2 * output_gap);
|
||||
int32_t width = output->geometry.width - main_stack_width - borders_width - layout_gap - 2 * output_gap;
|
||||
: output->main_stack_width * (output->geometry.width - 2 * output_gap);
|
||||
int32_t width = output->geometry.width - main_stack_width - borders_width - 2 * output_gap - layout_gap;
|
||||
int32_t height;
|
||||
int32_t dy = output_gap;
|
||||
size_t i = 0;
|
||||
|
||||
if (toplevels_count <= ABSINTHE_MAIN_STACK_SIZE) {
|
||||
if (toplevels_count <= output->main_stack_size) {
|
||||
wl_list_for_each(toplevel, &output->server->toplevels, link) {
|
||||
if (toplevel->output != output)
|
||||
continue;
|
||||
|
||||
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
|
||||
height = (output->geometry.height - dy - output_gap) / (output->main_stack_size - i) - borders_width;
|
||||
toplevel->geometry.x = output->geometry.x + output_gap;
|
||||
toplevel->geometry.y = output->geometry.y + dy;
|
||||
absinthe_toplevel_set_size(toplevel, main_stack_width, height);
|
||||
@@ -64,14 +65,14 @@ void layout_arrange(struct absinthe_output *output)
|
||||
continue;
|
||||
|
||||
|
||||
if (i < ABSINTHE_MAIN_STACK_SIZE) {
|
||||
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
|
||||
if (i < output->main_stack_size) {
|
||||
height = (output->geometry.height - dy - output_gap) / (output->main_stack_size - i) - borders_width;
|
||||
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)
|
||||
if (i == output->main_stack_size)
|
||||
dy = output_gap;
|
||||
height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width;
|
||||
toplevel->geometry.x = output->geometry.x + main_stack_width + layout_gap + output_gap;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "focus.h"
|
||||
#include "keyboard.h"
|
||||
#include "cursor.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
@@ -56,6 +57,9 @@ void server_new_output(struct wl_listener *listener, void *data)
|
||||
struct wlr_scene_output *scene_output = wlr_scene_output_create(server->scene, wlr_output);
|
||||
wlr_scene_output_layout_add_output(server->scene_layout, l_layout, scene_output);
|
||||
wlr_output_layout_get_box(server->output_layout, output->wlr_output, &output->geometry);
|
||||
|
||||
output->main_stack_size = ABSINTHE_MAIN_STACK_SIZE;
|
||||
output->main_stack_width = ABSINTHE_MAIN_STACK_WIDTH;
|
||||
}
|
||||
|
||||
void server_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
||||
|
||||
Reference in New Issue
Block a user