Merge pull request #210 from sce/focus_output
commands: Learn 'focus output <direction|name>'
This commit is contained in:
commit
239f4bd0ba
|
@ -53,6 +53,11 @@ Commands
|
||||||
container, which is useful, for example, to open a sibling of the parent
|
container, which is useful, for example, to open a sibling of the parent
|
||||||
container, or to move the entire container around.
|
container, or to move the entire container around.
|
||||||
|
|
||||||
|
**focus** output <direction|name>::
|
||||||
|
Direction may be one of _up_, _down_, _left_, _right_. The directional focus
|
||||||
|
commands will move the focus to the output in that direction. When name is
|
||||||
|
given the focus is changed to the output with that name.
|
||||||
|
|
||||||
**focus** mode_toggle::
|
**focus** mode_toggle::
|
||||||
Toggles focus between floating view and tiled view.
|
Toggles focus between floating view and tiled view.
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
#include "output.h"
|
||||||
#include "handlers.h"
|
#include "handlers.h"
|
||||||
#include "sway.h"
|
#include "sway.h"
|
||||||
#include "resize.h"
|
#include "resize.h"
|
||||||
|
@ -372,7 +373,20 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
|
||||||
static struct cmd_results *cmd_focus(int argc, char **argv) {
|
static struct cmd_results *cmd_focus(int argc, char **argv) {
|
||||||
if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file.");
|
if (config->reading) return cmd_results_new(CMD_FAILURE, "focus", "Can't be used in config file.");
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1))) {
|
if (argc > 0 && strcasecmp(argv[0], "output") == 0) {
|
||||||
|
swayc_t *output = NULL;
|
||||||
|
if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 2))) {
|
||||||
|
return error;
|
||||||
|
} else if (!(output = output_by_name(argv[1]))) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "focus output",
|
||||||
|
"Can't find output with name/at direction %s", argv[1]);
|
||||||
|
} else if (!workspace_switch(swayc_active_workspace_for(output))) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "focus output",
|
||||||
|
"Switching to workspace on output '%s' was blocked", argv[1]);
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
} else if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
static int floating_toggled_index = 0;
|
static int floating_toggled_index = 0;
|
||||||
|
@ -424,6 +438,9 @@ static struct cmd_results *cmd_focus(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "focus",
|
||||||
|
"Expected 'focus <direction|parent|mode_toggle>' or 'focus output <direction|name>'");
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,15 +289,16 @@ void move_container_to(swayc_t* container, swayc_t* destination) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
swayc_t *parent = remove_child(container);
|
swayc_t *parent = remove_child(container);
|
||||||
// reset container geometry
|
|
||||||
container->width = container->height = 0;
|
|
||||||
|
|
||||||
// Send to new destination
|
// Send to new destination
|
||||||
if (container->is_floating) {
|
if (container->is_floating) {
|
||||||
add_floating(swayc_active_workspace_for(destination), container);
|
add_floating(swayc_active_workspace_for(destination), container);
|
||||||
} else if (destination->type == C_WORKSPACE) {
|
} else if (destination->type == C_WORKSPACE) {
|
||||||
|
// reset container geometry
|
||||||
|
container->width = container->height = 0;
|
||||||
add_child(destination, container);
|
add_child(destination, container);
|
||||||
} else {
|
} else {
|
||||||
|
// reset container geometry
|
||||||
|
container->width = container->height = 0;
|
||||||
add_sibling(destination, container);
|
add_sibling(destination, container);
|
||||||
}
|
}
|
||||||
// Destroy old container if we need to
|
// Destroy old container if we need to
|
||||||
|
|
Loading…
Reference in a new issue