monocle and set_layout func
This commit is contained in:
@@ -156,6 +156,7 @@ setup(absn_server *server)
|
||||
server->workspaces_count = workspaces_count;
|
||||
server->workspaces = calloc(workspaces_count, sizeof(absn_workspace));
|
||||
for (int i = 0; i < workspaces_count; ++i) {
|
||||
server->workspaces[i].layout = LAYOUT_TILE;
|
||||
server->workspaces[i].name = workspaces[i];
|
||||
server->workspaces[i].count = STACK_COUNT;
|
||||
server->workspaces[i].size = STACK_SIZE;
|
||||
|
||||
+2
-1
@@ -66,7 +66,8 @@ focus_get_topmost(absn_server *server)
|
||||
absn_toplevel *toplevel;
|
||||
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 NULL;
|
||||
|
||||
+20
-3
@@ -132,8 +132,15 @@ switch_workspace(absn_server *server, const absn_arg *arg)
|
||||
absn_toplevel *toplevel;
|
||||
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 */
|
||||
}
|
||||
|
||||
if (toplevel && toplevel->workspace == &server->workspaces[i] &&
|
||||
toplevel->fullscreen)
|
||||
{
|
||||
/* overwrite if there is a fullscreen window */
|
||||
focus = toplevel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +155,7 @@ switch_workspace(absn_server *server, const absn_arg *arg)
|
||||
else
|
||||
#endif
|
||||
surface = focus->xdg->base->surface;
|
||||
|
||||
|
||||
if (surface == server->seat->keyboard_state.focused_surface)
|
||||
server->seat->keyboard_state.focused_surface = NULL;
|
||||
|
||||
@@ -159,11 +166,14 @@ switch_workspace(absn_server *server, const absn_arg *arg)
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
if (server->focused_toplevel->fullscreen)
|
||||
toplevel_set_fullscreen(server->focused_toplevel, false);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < server->workspaces_count; ++i) {
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
set_layout(absn_server *server, const absn_arg *arg)
|
||||
{
|
||||
server->focused_output->workspace->layout = arg->i;
|
||||
layout_arrange(server->focused_output);
|
||||
}
|
||||
|
||||
noreturn void
|
||||
quit(absn_server *server, const absn_arg *arg)
|
||||
{
|
||||
|
||||
+64
-10
@@ -4,21 +4,19 @@
|
||||
#include "toplevel.h"
|
||||
#include "types.h"
|
||||
|
||||
void
|
||||
layout_arrange(struct absn_output *output)
|
||||
/* returns number of toplevels on workspace */
|
||||
static int
|
||||
prepare_output(struct absn_output *output)
|
||||
{
|
||||
if (!output)
|
||||
return;
|
||||
|
||||
struct absn_toplevel *toplevel;
|
||||
int toplevels_count = 0;
|
||||
int res = 0;
|
||||
absn_toplevel *toplevel;
|
||||
wl_list_for_each(toplevel, &output->server->toplevels, link)
|
||||
{
|
||||
if (toplevel->workspace == output->workspace &&
|
||||
!toplevel->floating && !toplevel->fullscreen) {
|
||||
toplevels_count++;
|
||||
if (toplevel->workspace == output->workspace) {
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node,
|
||||
true);
|
||||
if (!toplevel->floating && !toplevel->fullscreen)
|
||||
res++;
|
||||
} else if (toplevel->output == output &&
|
||||
toplevel->workspace != output->workspace) {
|
||||
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)
|
||||
return;
|
||||
|
||||
int32_t og = OUTPUT_GAP;
|
||||
struct wlr_box new_geom;
|
||||
|
||||
absn_toplevel *toplevel;
|
||||
if (toplevels_count == 1) {
|
||||
wl_list_for_each(toplevel, &output->server->toplevels, link)
|
||||
{
|
||||
@@ -143,3 +150,50 @@ layout_arrange(struct absn_output *output)
|
||||
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);
|
||||
|
||||
layout_arrange(toplevel->output);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user