summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 642fa3ce..7e9169e8 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -8,7 +8,7 @@
8#include <ctype.h> 8#include <ctype.h>
9#include "stringop.h" 9#include "stringop.h"
10#include "layout.h" 10#include "layout.h"
11#include "movement.h" 11#include "focus.h"
12#include "log.h" 12#include "log.h"
13#include "workspace.h" 13#include "workspace.h"
14#include "commands.h" 14#include "commands.h"
@@ -171,6 +171,10 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) {
171} 171}
172 172
173static bool cmd_floating(struct sway_config *config, int argc, char **argv) { 173static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
174 if (!checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1)) {
175 return false;
176 }
177
174 if (strcasecmp(argv[0], "toggle") == 0) { 178 if (strcasecmp(argv[0], "toggle") == 0) {
175 swayc_t *view = get_focused_container(&root_container); 179 swayc_t *view = get_focused_container(&root_container);
176 // Prevent running floating commands on things like workspaces 180 // Prevent running floating commands on things like workspaces
@@ -215,11 +219,12 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
215 view->is_floating = false; 219 view->is_floating = false;
216 active_workspace->focused = NULL; 220 active_workspace->focused = NULL;
217 // Get the properly focused container, and add in the view there 221 // Get the properly focused container, and add in the view there
218 swayc_t *focused = focus_pointer(); 222 swayc_t *focused = container_under_pointer();
219 // If focused is null, it's because the currently focused container is a workspace 223 // If focused is null, it's because the currently focused container is a workspace
220 if (focused == NULL) { 224 if (focused == NULL) {
221 focused = active_workspace; 225 focused = active_workspace;
222 } 226 }
227 set_focused_container(focused);
223 228
224 sway_log(L_DEBUG, "Non-floating focused container is %p", focused); 229 sway_log(L_DEBUG, "Non-floating focused container is %p", focused);
225 230
@@ -232,7 +237,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
232 add_sibling(focused, view); 237 add_sibling(focused, view);
233 } 238 }
234 // Refocus on the view once its been put back into the layout 239 // Refocus on the view once its been put back into the layout
235 focus_view(view); 240 set_focused_container(view);
236 arrange_windows(active_workspace, -1, -1); 241 arrange_windows(active_workspace, -1, -1);
237 return true; 242 return true;
238 } 243 }
@@ -241,6 +246,14 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
241 return true; 246 return true;
242} 247}
243 248
249static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) {
250 if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) {
251 return false;
252 }
253 config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE);
254 return true;
255}
256
244static bool cmd_focus(struct sway_config *config, int argc, char **argv) { 257static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
245 if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) { 258 if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) {
246 return false; 259 return false;
@@ -345,7 +358,7 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay
345 else { 358 else {
346 sway_log(L_DEBUG, "Adding new container around current focused container"); 359 sway_log(L_DEBUG, "Adding new container around current focused container");
347 swayc_t *parent = new_container(focused, layout); 360 swayc_t *parent = new_container(focused, layout);
348 focus_view(focused); 361 set_focused_container(focused);
349 arrange_windows(parent, -1, -1); 362 arrange_windows(parent, -1, -1);
350 } 363 }
351 364
@@ -465,6 +478,7 @@ static struct cmd_handler handlers[] = {
465 { "exec_always", cmd_exec_always }, 478 { "exec_always", cmd_exec_always },
466 { "exit", cmd_exit }, 479 { "exit", cmd_exit },
467 { "floating", cmd_floating }, 480 { "floating", cmd_floating },
481 { "floating_modifier", cmd_floating_mod },
468 { "focus", cmd_focus }, 482 { "focus", cmd_focus },
469 { "focus_follows_mouse", cmd_focus_follows_mouse }, 483 { "focus_follows_mouse", cmd_focus_follows_mouse },
470 { "fullscreen", cmd_fullscreen }, 484 { "fullscreen", cmd_fullscreen },