mirror of
https://github.com/swaywm/sway.git
synced 2025-11-06 13:29:50 -05:00
commit
2f6dd0687b
15 changed files with 550 additions and 346 deletions
|
|
@ -8,7 +8,7 @@
|
|||
#include <ctype.h>
|
||||
#include "stringop.h"
|
||||
#include "layout.h"
|
||||
#include "movement.h"
|
||||
#include "focus.h"
|
||||
#include "log.h"
|
||||
#include "workspace.h"
|
||||
#include "commands.h"
|
||||
|
|
@ -171,6 +171,10 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) {
|
|||
}
|
||||
|
||||
static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[0], "toggle") == 0) {
|
||||
swayc_t *view = get_focused_container(&root_container);
|
||||
// Prevent running floating commands on things like workspaces
|
||||
|
|
@ -215,11 +219,12 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|||
view->is_floating = false;
|
||||
active_workspace->focused = NULL;
|
||||
// Get the properly focused container, and add in the view there
|
||||
swayc_t *focused = focus_pointer();
|
||||
swayc_t *focused = container_under_pointer();
|
||||
// If focused is null, it's because the currently focused container is a workspace
|
||||
if (focused == NULL) {
|
||||
focused = active_workspace;
|
||||
}
|
||||
set_focused_container(focused);
|
||||
|
||||
sway_log(L_DEBUG, "Non-floating focused container is %p", focused);
|
||||
|
||||
|
|
@ -232,7 +237,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|||
add_sibling(focused, view);
|
||||
}
|
||||
// Refocus on the view once its been put back into the layout
|
||||
focus_view(view);
|
||||
set_focused_container(view);
|
||||
arrange_windows(active_workspace, -1, -1);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -241,6 +246,14 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) {
|
||||
return false;
|
||||
}
|
||||
config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) {
|
||||
return false;
|
||||
|
|
@ -345,7 +358,7 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay
|
|||
else {
|
||||
sway_log(L_DEBUG, "Adding new container around current focused container");
|
||||
swayc_t *parent = new_container(focused, layout);
|
||||
focus_view(focused);
|
||||
set_focused_container(focused);
|
||||
arrange_windows(parent, -1, -1);
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +478,7 @@ static struct cmd_handler handlers[] = {
|
|||
{ "exec_always", cmd_exec_always },
|
||||
{ "exit", cmd_exit },
|
||||
{ "floating", cmd_floating },
|
||||
{ "floating_modifier", cmd_floating_mod },
|
||||
{ "focus", cmd_focus },
|
||||
{ "focus_follows_mouse", cmd_focus_follows_mouse },
|
||||
{ "fullscreen", cmd_fullscreen },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue