mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Merge pull request #2027 from RyanDwyer/implement-floating
Implement floating
This commit is contained in:
commit
96446fdbf7
26 changed files with 662 additions and 220 deletions
|
|
@ -37,7 +37,13 @@ struct cmd_results *cmd_border(int argc, char **argv) {
|
|||
"or 'border pixel <px>'");
|
||||
}
|
||||
|
||||
view_autoconfigure(view);
|
||||
if (container_is_floating(view->swayc)) {
|
||||
container_damage_whole(view->swayc);
|
||||
container_set_geometry_from_floating_view(view->swayc);
|
||||
container_damage_whole(view->swayc);
|
||||
} else {
|
||||
view_autoconfigure(view);
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||
if (seat->cursor) {
|
||||
|
|
|
|||
40
sway/commands/floating.c
Normal file
40
sway/commands/floating.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/ipc-server.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/tree/arrange.h"
|
||||
#include "sway/tree/container.h"
|
||||
#include "sway/tree/layout.h"
|
||||
#include "sway/tree/view.h"
|
||||
#include "list.h"
|
||||
|
||||
struct cmd_results *cmd_floating(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct sway_container *container =
|
||||
config->handler_context.current_container;
|
||||
if (container->type != C_VIEW) {
|
||||
// TODO: This doesn't strictly speaking have to be true
|
||||
return cmd_results_new(CMD_INVALID, "float", "Only views can float");
|
||||
}
|
||||
|
||||
bool wants_floating;
|
||||
if (strcasecmp(argv[0], "enable") == 0) {
|
||||
wants_floating = true;
|
||||
} else if (strcasecmp(argv[0], "disable") == 0) {
|
||||
wants_floating = false;
|
||||
} else if (strcasecmp(argv[0], "toggle") == 0) {
|
||||
wants_floating = !container_is_floating(container);
|
||||
} else {
|
||||
return cmd_results_new(CMD_FAILURE, "floating",
|
||||
"Expected 'floating <enable|disable|toggle>'");
|
||||
}
|
||||
|
||||
container_set_floating(container, wants_floating);
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
@ -12,19 +12,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
|
|||
}
|
||||
struct sway_container *parent = config->handler_context.current_container;
|
||||
|
||||
// TODO: floating
|
||||
/*
|
||||
if (parent->is_floating) {
|
||||
return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows");
|
||||
if (container_is_floating(parent)) {
|
||||
return cmd_results_new(CMD_FAILURE, "layout",
|
||||
"Unable to change layout of floating windows");
|
||||
}
|
||||
*/
|
||||
|
||||
while (parent->type == C_VIEW) {
|
||||
parent = parent->parent;
|
||||
}
|
||||
|
||||
// TODO: stacks and tabs
|
||||
|
||||
if (strcasecmp(argv[0], "default") == 0) {
|
||||
parent->layout = parent->prev_layout;
|
||||
if (parent->layout == L_NONE) {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,14 @@
|
|||
#include "stringop.h"
|
||||
#include "list.h"
|
||||
|
||||
static const char* expected_syntax =
|
||||
static const char* expected_syntax =
|
||||
"Expected 'move <left|right|up|down> <[px] px>' or "
|
||||
"'move <container|window> to workspace <name>' or "
|
||||
"'move <container|window|workspace> to output <name|direction>' or "
|
||||
"'move position mouse'";
|
||||
|
||||
static struct sway_container *output_in_direction(const char *direction,
|
||||
struct wlr_output *reference, int ref_ox, int ref_oy) {
|
||||
int ref_lx = ref_ox + reference->lx,
|
||||
ref_ly = ref_oy + reference->ly;
|
||||
struct wlr_output *reference, int ref_lx, int ref_ly) {
|
||||
struct {
|
||||
char *name;
|
||||
enum wlr_direction direction;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
|
||||
static struct cmd_results *do_split(int layout) {
|
||||
struct sway_container *con = config->handler_context.current_container;
|
||||
if (container_is_floating(con)) {
|
||||
return cmd_results_new(CMD_FAILURE, "split",
|
||||
"Can't split a floating view");
|
||||
}
|
||||
struct sway_container *parent = container_split(con, layout);
|
||||
container_create_notify(parent);
|
||||
arrange_children_of(parent);
|
||||
|
|
@ -23,24 +27,23 @@ struct cmd_results *cmd_split(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
|
||||
do_split(L_VERT);
|
||||
return do_split(L_VERT);
|
||||
} else if (strcasecmp(argv[0], "h") == 0 ||
|
||||
strcasecmp(argv[0], "horizontal") == 0) {
|
||||
do_split(L_HORIZ);
|
||||
return do_split(L_HORIZ);
|
||||
} else if (strcasecmp(argv[0], "t") == 0 ||
|
||||
strcasecmp(argv[0], "toggle") == 0) {
|
||||
struct sway_container *focused =
|
||||
config->handler_context.current_container;
|
||||
|
||||
if (focused->parent->layout == L_VERT) {
|
||||
do_split(L_HORIZ);
|
||||
return do_split(L_HORIZ);
|
||||
} else {
|
||||
do_split(L_VERT);
|
||||
return do_split(L_VERT);
|
||||
}
|
||||
} else {
|
||||
error = cmd_results_new(CMD_FAILURE, "split",
|
||||
return cmd_results_new(CMD_FAILURE, "split",
|
||||
"Invalid split command (expected either horizontal or vertical).");
|
||||
return error;
|
||||
}
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
40
sway/commands/sticky.c
Normal file
40
sway/commands/sticky.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/ipc-server.h"
|
||||
#include "sway/output.h"
|
||||
#include "sway/tree/arrange.h"
|
||||
#include "sway/tree/container.h"
|
||||
#include "sway/tree/layout.h"
|
||||
#include "sway/tree/view.h"
|
||||
#include "list.h"
|
||||
|
||||
struct cmd_results *cmd_sticky(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
struct sway_container *container =
|
||||
config->handler_context.current_container;
|
||||
if (!container_is_floating(container)) {
|
||||
return cmd_results_new(CMD_FAILURE, "sticky",
|
||||
"Can't set sticky on a tiled container");
|
||||
}
|
||||
|
||||
bool wants_sticky;
|
||||
if (strcasecmp(argv[0], "enable") == 0) {
|
||||
wants_sticky = true;
|
||||
} else if (strcasecmp(argv[0], "disable") == 0) {
|
||||
wants_sticky = false;
|
||||
} else if (strcasecmp(argv[0], "toggle") == 0) {
|
||||
wants_sticky = !container->is_sticky;
|
||||
} else {
|
||||
return cmd_results_new(CMD_FAILURE, "sticky",
|
||||
"Expected 'sticky <enable|disable|toggle>'");
|
||||
}
|
||||
|
||||
container->is_sticky = wants_sticky;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue