monocle and set_layout func
This commit is contained in:
+37
-6
@@ -33,29 +33,60 @@ static const char *workspaces[] = {
|
|||||||
"3",
|
"3",
|
||||||
"4",
|
"4",
|
||||||
"5",
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const absn_keybind keybinds[] = {
|
static const absn_keybind keybinds[] = {
|
||||||
|
{ ALT, XKB_KEY_Escape, quit, { 0 } },
|
||||||
|
|
||||||
{ ALT, XKB_KEY_Return, &run, { .v = "alacritty" } },
|
{ ALT, XKB_KEY_Return, &run, { .v = "alacritty" } },
|
||||||
{ ALT, XKB_KEY_q, kill_focus, { 0 } },
|
{ ALT, XKB_KEY_q, kill_focus, { 0 } },
|
||||||
|
|
||||||
{ ALT, XKB_KEY_j, cycle_focus, { .i = +1 } },
|
{ ALT, XKB_KEY_j, cycle_focus, { .i = +1 } },
|
||||||
{ ALT, XKB_KEY_k, cycle_focus, { .i = -1 } },
|
{ ALT, XKB_KEY_k, cycle_focus, { .i = -1 } },
|
||||||
|
|
||||||
{ ALT, XKB_KEY_f, toggle_fullscreen, { 0 } },
|
{ ALT, XKB_KEY_f, toggle_fullscreen, { 0 } },
|
||||||
|
|
||||||
{ ALT, XKB_KEY_h, increase_master_count, { .i = +1 } },
|
{ ALT, XKB_KEY_h, increase_master_count, { .i = +1 } },
|
||||||
{ ALT, XKB_KEY_l, increase_master_count, { .i = -1 } },
|
{ ALT, XKB_KEY_l, increase_master_count, { .i = -1 } },
|
||||||
|
|
||||||
{ ALT | SHIFT, XKB_KEY_h, increase_master_width, { .f = -0.05 } },
|
{ ALT | SHIFT, XKB_KEY_h, increase_master_width, { .f = -0.05 } },
|
||||||
{ ALT | SHIFT, XKB_KEY_l, increase_master_width, { .f = +0.05 } },
|
{ ALT | SHIFT, XKB_KEY_l, increase_master_width, { .f = +0.05 } },
|
||||||
|
|
||||||
|
{ ALT, XKB_KEY_t, set_layout, { .i = LAYOUT_TILE } },
|
||||||
|
{ ALT, XKB_KEY_m, set_layout, { .i = LAYOUT_MONOCLE } },
|
||||||
|
|
||||||
{ ALT, XKB_KEY_1, switch_workspace, { .v = "1" } },
|
{ ALT, XKB_KEY_1, switch_workspace, { .v = "1" } },
|
||||||
{ ALT, XKB_KEY_2, switch_workspace, { .v = "2" } },
|
{ ALT, XKB_KEY_2, switch_workspace, { .v = "2" } },
|
||||||
{ ALT, XKB_KEY_3, switch_workspace, { .v = "3" } },
|
{ ALT, XKB_KEY_3, switch_workspace, { .v = "3" } },
|
||||||
{ ALT, XKB_KEY_4, switch_workspace, { .v = "4" } },
|
{ ALT, XKB_KEY_4, switch_workspace, { .v = "4" } },
|
||||||
{ ALT, XKB_KEY_5, switch_workspace, { .v = "5" } },
|
{ ALT, XKB_KEY_5, switch_workspace, { .v = "5" } },
|
||||||
{ ALT | SHIFT, XKB_KEY_exclam, focus_move_to_workspace, { .v = "1" } },
|
{ ALT, XKB_KEY_6, switch_workspace, { .v = "6" } },
|
||||||
{ ALT | SHIFT, XKB_KEY_2, focus_move_to_workspace, { .v = "2" } },
|
{ ALT, XKB_KEY_7, switch_workspace, { .v = "7" } },
|
||||||
{ ALT | SHIFT, XKB_KEY_3, focus_move_to_workspace, { .v = "3" } },
|
{ ALT, XKB_KEY_8, switch_workspace, { .v = "8" } },
|
||||||
{ ALT | SHIFT, XKB_KEY_4, focus_move_to_workspace, { .v = "4" } },
|
{ ALT, XKB_KEY_9, switch_workspace, { .v = "9" } },
|
||||||
{ ALT | SHIFT, XKB_KEY_5, focus_move_to_workspace, { .v = "5" } },
|
{ ALT, XKB_KEY_0, switch_workspace, { .v = "10" } },
|
||||||
{ ALT, XKB_KEY_Escape, quit, { 0 } },
|
|
||||||
|
{ ALT | SHIFT, XKB_KEY_exclam, move_focus_to_workspace, { .v = "1" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_at, move_focus_to_workspace, { .v = "2" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_numbersign, move_focus_to_workspace,
|
||||||
|
{ .v = "3" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_dollar, move_focus_to_workspace, { .v = "4" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_percent, move_focus_to_workspace, { .v = "5" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_asciicircum, move_focus_to_workspace,
|
||||||
|
{ .v = "6" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_ampersand, move_focus_to_workspace,
|
||||||
|
{ .v = "7" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_asterisk, move_focus_to_workspace,
|
||||||
|
{ .v = "8" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_parenleft, move_focus_to_workspace,
|
||||||
|
{ .v = "9" } },
|
||||||
|
{ ALT | SHIFT, XKB_KEY_parenright, move_focus_to_workspace,
|
||||||
|
{ .v = "10" } },
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-1
@@ -13,7 +13,9 @@ void increase_master_width(absn_server *server, const absn_arg *arg);
|
|||||||
void increase_master_count(absn_server *server, const absn_arg *arg);
|
void increase_master_count(absn_server *server, const absn_arg *arg);
|
||||||
|
|
||||||
void switch_workspace(absn_server *server, const absn_arg *arg);
|
void switch_workspace(absn_server *server, const absn_arg *arg);
|
||||||
void focus_move_to_workspace(absn_server *server, const absn_arg *arg);
|
void move_focus_to_workspace(absn_server *server, const absn_arg *arg);
|
||||||
|
|
||||||
|
void set_layout(absn_server *server, const absn_arg *arg);
|
||||||
|
|
||||||
void quit(absn_server *server, const absn_arg *arg);
|
void quit(absn_server *server, const absn_arg *arg);
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -79,13 +79,12 @@ static const int layermap[] = {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
LAYOUT_TILE,
|
LAYOUT_TILE,
|
||||||
LAYOUT_FLOAT,
|
LAYOUT_MONOCLE,
|
||||||
LAYOUT_TILELEFT,
|
LAYOUT_TILELEFT,
|
||||||
LAYOUT_TILETOP,
|
LAYOUT_TILETOP,
|
||||||
LAYOUT_TILEBOTTOM,
|
LAYOUT_TILEBOTTOM,
|
||||||
LAYOUT_SPIRAL,
|
LAYOUT_SPIRAL,
|
||||||
LAYOUT_DWINDLE,
|
LAYOUT_DWINDLE,
|
||||||
LAYOUT_MAX,
|
|
||||||
LAYOUT_VGRID,
|
LAYOUT_VGRID,
|
||||||
LAYOUT_HGRID,
|
LAYOUT_HGRID,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ setup(absn_server *server)
|
|||||||
server->workspaces_count = workspaces_count;
|
server->workspaces_count = workspaces_count;
|
||||||
server->workspaces = calloc(workspaces_count, sizeof(absn_workspace));
|
server->workspaces = calloc(workspaces_count, sizeof(absn_workspace));
|
||||||
for (int i = 0; i < workspaces_count; ++i) {
|
for (int i = 0; i < workspaces_count; ++i) {
|
||||||
|
server->workspaces[i].layout = LAYOUT_TILE;
|
||||||
server->workspaces[i].name = workspaces[i];
|
server->workspaces[i].name = workspaces[i];
|
||||||
server->workspaces[i].count = STACK_COUNT;
|
server->workspaces[i].count = STACK_COUNT;
|
||||||
server->workspaces[i].size = STACK_SIZE;
|
server->workspaces[i].size = STACK_SIZE;
|
||||||
|
|||||||
+2
-1
@@ -66,7 +66,8 @@ focus_get_topmost(absn_server *server)
|
|||||||
absn_toplevel *toplevel;
|
absn_toplevel *toplevel;
|
||||||
wl_list_for_each(toplevel, &server->focus_stack, flink)
|
wl_list_for_each(toplevel, &server->focus_stack, flink)
|
||||||
{
|
{
|
||||||
if (toplevel && toplevel->workspace == server->focused_output->workspace)
|
if (toplevel &&
|
||||||
|
toplevel->workspace == server->focused_output->workspace)
|
||||||
return toplevel;
|
return toplevel;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
+19
-2
@@ -132,8 +132,15 @@ switch_workspace(absn_server *server, const absn_arg *arg)
|
|||||||
absn_toplevel *toplevel;
|
absn_toplevel *toplevel;
|
||||||
wl_list_for_each(toplevel, &server->toplevels, link)
|
wl_list_for_each(toplevel, &server->toplevels, link)
|
||||||
{
|
{
|
||||||
if (toplevel && toplevel->workspace == &server->workspaces[i]) {
|
if (!focus && toplevel && toplevel->workspace == &server->workspaces[i]) {
|
||||||
focus = toplevel; /* found it */
|
focus = toplevel; /* found it */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toplevel && toplevel->workspace == &server->workspaces[i] &&
|
||||||
|
toplevel->fullscreen)
|
||||||
|
{
|
||||||
|
/* overwrite if there is a fullscreen window */
|
||||||
|
focus = toplevel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,11 +166,14 @@ switch_workspace(absn_server *server, const absn_arg *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focus_move_to_workspace(absn_server *server, const absn_arg *arg)
|
move_focus_to_workspace(absn_server *server, const absn_arg *arg)
|
||||||
{
|
{
|
||||||
if (!server->focused_toplevel)
|
if (!server->focused_toplevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (server->focused_toplevel->fullscreen)
|
||||||
|
toplevel_set_fullscreen(server->focused_toplevel, false);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < server->workspaces_count; ++i) {
|
for (i = 0; i < server->workspaces_count; ++i) {
|
||||||
if (arg->v == server->workspaces[i].name)
|
if (arg->v == server->workspaces[i].name)
|
||||||
@@ -185,6 +195,13 @@ focus_move_to_workspace(absn_server *server, const absn_arg *arg)
|
|||||||
layout_arrange(server->focused_toplevel->output);
|
layout_arrange(server->focused_toplevel->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_layout(absn_server *server, const absn_arg *arg)
|
||||||
|
{
|
||||||
|
server->focused_output->workspace->layout = arg->i;
|
||||||
|
layout_arrange(server->focused_output);
|
||||||
|
}
|
||||||
|
|
||||||
noreturn void
|
noreturn void
|
||||||
quit(absn_server *server, const absn_arg *arg)
|
quit(absn_server *server, const absn_arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
+64
-10
@@ -4,21 +4,19 @@
|
|||||||
#include "toplevel.h"
|
#include "toplevel.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void
|
/* returns number of toplevels on workspace */
|
||||||
layout_arrange(struct absn_output *output)
|
static int
|
||||||
|
prepare_output(struct absn_output *output)
|
||||||
{
|
{
|
||||||
if (!output)
|
int res = 0;
|
||||||
return;
|
absn_toplevel *toplevel;
|
||||||
|
|
||||||
struct absn_toplevel *toplevel;
|
|
||||||
int toplevels_count = 0;
|
|
||||||
wl_list_for_each(toplevel, &output->server->toplevels, link)
|
wl_list_for_each(toplevel, &output->server->toplevels, link)
|
||||||
{
|
{
|
||||||
if (toplevel->workspace == output->workspace &&
|
if (toplevel->workspace == output->workspace) {
|
||||||
!toplevel->floating && !toplevel->fullscreen) {
|
|
||||||
toplevels_count++;
|
|
||||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node,
|
wlr_scene_node_set_enabled(&toplevel->scene_tree->node,
|
||||||
true);
|
true);
|
||||||
|
if (!toplevel->floating && !toplevel->fullscreen)
|
||||||
|
res++;
|
||||||
} else if (toplevel->output == output &&
|
} else if (toplevel->output == output &&
|
||||||
toplevel->workspace != output->workspace) {
|
toplevel->workspace != output->workspace) {
|
||||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node,
|
wlr_scene_node_set_enabled(&toplevel->scene_tree->node,
|
||||||
@@ -26,12 +24,21 @@ layout_arrange(struct absn_output *output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tile(struct absn_output *output)
|
||||||
|
{
|
||||||
|
int toplevels_count = prepare_output(output);
|
||||||
|
|
||||||
if (toplevels_count < 1)
|
if (toplevels_count < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int32_t og = OUTPUT_GAP;
|
int32_t og = OUTPUT_GAP;
|
||||||
struct wlr_box new_geom;
|
struct wlr_box new_geom;
|
||||||
|
|
||||||
|
absn_toplevel *toplevel;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -143,3 +150,50 @@ layout_arrange(struct absn_output *output)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
monocle(struct absn_output *output)
|
||||||
|
{
|
||||||
|
int toplevels_count = prepare_output(output);
|
||||||
|
|
||||||
|
if (toplevels_count < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32_t og = OUTPUT_GAP;
|
||||||
|
|
||||||
|
struct wlr_box new_geom = {
|
||||||
|
.x = output->geom.x + og,
|
||||||
|
.y = output->geom.y + og,
|
||||||
|
.width = output->geom.width - 2 * og,
|
||||||
|
.height = output->geom.height - 2 * og,
|
||||||
|
};
|
||||||
|
|
||||||
|
absn_toplevel *toplevel;
|
||||||
|
wl_list_for_each(toplevel, &output->server->toplevels, link)
|
||||||
|
{
|
||||||
|
if (toplevel->workspace != output->workspace ||
|
||||||
|
toplevel->floating || toplevel->fullscreen)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
toplevel_set_geom(toplevel, &new_geom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
layout_arrange(struct absn_output *output)
|
||||||
|
{
|
||||||
|
if (!output)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (output->workspace->layout) {
|
||||||
|
case LAYOUT_TILE:
|
||||||
|
tile(output);
|
||||||
|
break;
|
||||||
|
case LAYOUT_MONOCLE:
|
||||||
|
monocle(output);
|
||||||
|
break;
|
||||||
|
default: /* currently not implemented layouts */
|
||||||
|
tile(output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -211,6 +211,8 @@ toplevel_set_fullscreen(absn_toplevel *toplevel, bool fullscreen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
toplevel_update_borders_geom(toplevel);
|
toplevel_update_borders_geom(toplevel);
|
||||||
|
|
||||||
|
layout_arrange(toplevel->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user