2018-04-30 21:24:13 +10:00
|
|
|
#include "log.h"
|
|
|
|
#include "sway/commands.h"
|
|
|
|
#include "sway/config.h"
|
2018-05-01 22:42:08 +10:00
|
|
|
#include "sway/input/cursor.h"
|
|
|
|
#include "sway/input/input-manager.h"
|
2018-06-06 22:57:34 +10:00
|
|
|
#include "sway/tree/arrange.h"
|
2018-04-30 21:24:13 +10:00
|
|
|
#include "sway/tree/container.h"
|
|
|
|
#include "sway/tree/view.h"
|
|
|
|
|
|
|
|
struct cmd_results *cmd_border(int argc, char **argv) {
|
|
|
|
struct cmd_results *error = NULL;
|
|
|
|
if ((error = checkarg(argc, "border", EXPECTED_AT_LEAST, 1))) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sway_container *container =
|
|
|
|
config->handler_context.current_container;
|
|
|
|
if (container->type != C_VIEW) {
|
|
|
|
return cmd_results_new(CMD_INVALID, "border",
|
|
|
|
"Only views can have borders");
|
|
|
|
}
|
|
|
|
struct sway_view *view = container->sway_view;
|
|
|
|
|
|
|
|
if (strcmp(argv[0], "none") == 0) {
|
|
|
|
view->border = B_NONE;
|
|
|
|
} else if (strcmp(argv[0], "normal") == 0) {
|
|
|
|
view->border = B_NORMAL;
|
|
|
|
} else if (strcmp(argv[0], "pixel") == 0) {
|
|
|
|
view->border = B_PIXEL;
|
|
|
|
} else if (strcmp(argv[0], "toggle") == 0) {
|
|
|
|
view->border = (view->border + 1) % 3;
|
|
|
|
} else {
|
|
|
|
return cmd_results_new(CMD_INVALID, "border",
|
|
|
|
"Expected 'border <none|normal|pixel|toggle>' "
|
|
|
|
"or 'border pixel <px>'");
|
|
|
|
}
|
2018-09-01 21:28:13 +10:00
|
|
|
if (argc == 2) {
|
|
|
|
view->border_thickness = atoi(argv[1]);
|
|
|
|
}
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-05-31 22:02:20 +10:00
|
|
|
if (container_is_floating(view->swayc)) {
|
|
|
|
container_set_geometry_from_floating_view(view->swayc);
|
|
|
|
}
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-07-14 23:14:55 +10:00
|
|
|
arrange_windows(view->swayc);
|
2018-06-06 22:57:34 +10:00
|
|
|
|
2018-05-01 22:42:08 +10:00
|
|
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
|
|
|
if (seat->cursor) {
|
2018-05-21 13:12:33 +10:00
|
|
|
cursor_send_pointer_motion(seat->cursor, 0, false);
|
2018-05-01 22:42:08 +10:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:24:13 +10:00
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
|
|
|
}
|