Skip to content

Instantly share code, notes, and snippets.

@raidzero
Created February 13, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raidzero/234480a144c3b8092c8ddcef76b4abd5 to your computer and use it in GitHub Desktop.
Save raidzero/234480a144c3b8092c8ddcef76b4abd5 to your computer and use it in GitHub Desktop.
rudimentary raise command for swaymsg
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 3ed00763..ae1e3f31 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -154,6 +154,7 @@ sway_cmd cmd_no_focus;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_popup_during_fullscreen;
+sway_cmd cmd_raise;
sway_cmd cmd_reject;
sway_cmd cmd_reload;
sway_cmd cmd_rename;
diff --git a/sway/commands.c b/sway/commands.c
index 3fc4f86e..9e3c37d2 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -117,6 +117,7 @@ static struct cmd_handler command_handlers[] = {
{ "move", cmd_move },
{ "nop", cmd_nop },
{ "opacity", cmd_opacity },
+ { "raise", cmd_raise },
{ "reload", cmd_reload },
{ "rename", cmd_rename },
{ "resize", cmd_resize },
diff --git a/sway/commands/raise.c b/sway/commands/raise.c
new file mode 100644
index 00000000..a5a1218f
--- /dev/null
+++ b/sway/commands/raise.c
@@ -0,0 +1,19 @@
+#include "log.h"
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
+#include "sway/tree/container.h"
+#include "sway/tree/view.h"
+#include "sway/commands.h"
+
+struct cmd_results *cmd_raise(int argc, char **argv) {
+ if (!root->outputs->length) {
+ return cmd_results_new(CMD_INVALID,
+ "Can't run this command while there's no outputs connected.");
+ }
+ struct sway_container *con = config->handler_context.container;
+
+ if (con) {
+ container_raise_floating(con);
+ }
+ return cmd_results_new(CMD_SUCCESS, NULL);
+}
diff --git a/sway/meson.build b/sway/meson.build
index 293a4ed2..d9134cbb 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -75,6 +75,7 @@ sway_sources = files(
'commands/nop.c',
'commands/output.c',
'commands/popup_during_fullscreen.c',
+ 'commands/raise.c',
'commands/reload.c',
'commands/rename.c',
'commands/resize.c',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment