Make follow 'true' by default as per Openbox 3.6 specification.
Note: this is an interface change.
Fixes: issue #841
any windows, the cursor is centered on the given output.
*<action name="GoToDesktop" to="value" />*
- Switch to workspace. Supported values are "last", "left", "right" or the
- full name of a workspace or its index (starting at 1) as configured in
- rc.xml.
+ Switch to workspace.
-*<action name="SendToDesktop" to="value" />*
+ *to* The workspace to switch to. Supported values are "last", "left",
+ "right" or the full name of a workspace or its index (starting at 1)
+ as configured in rc.xml.
+
+*<action name="SendToDesktop" to="value" follow="yes" />*
Send active window to workspace.
- Supported values are the same as for GoToDesktop.
+
+ *to* The workspace to send the window to. Supported values are the same
+ as for GoToDesktop.
+
+ *follow* [yes|no] Also switch to the specified workspace. Default yes.
*<action name="None">*
If used as the only action for a binding: clear an earlier defined binding.
<menu id="workspaces" label="Workspace">
<item label="Move left">
<action name="SendToDesktop" to="left" />
- <action name="GoToDesktop" to="left" />
</item>
<item label="Move right">
<action name="SendToDesktop" to="right" />
- <action name="GoToDesktop" to="right" />
</item>
</menu>
<item label="Close">
};
struct action *action_create(const char *action_name);
+
void action_arg_add_str(struct action *action, char *key, const char *value);
+void action_arg_add_bool(struct action *action, char *key, bool value);
+
void action_arg_from_xml_node(struct action *action, char *nodename, char *content);
bool actions_contain_toggle_keybinds(struct wl_list *action_list);
#include <unistd.h>
#include <wlr/util/log.h>
#include "action.h"
+#include "common/get-bool.h"
#include "common/list.h"
#include "common/mem.h"
#include "common/spawn.h"
enum action_arg_type {
LAB_ACTION_ARG_STR = 0,
+ LAB_ACTION_ARG_BOOL,
};
struct action_arg {
char *value;
};
+struct action_arg_bool {
+ struct action_arg base;
+ bool value;
+};
+
enum action_type {
ACTION_TYPE_INVALID = 0,
ACTION_TYPE_NONE,
action_arg_add_str(action, NULL, content);
} else if (!strcmp(nodename, "to.action")) {
/* GoToDesktop, SendToDesktop */
- action_arg_add_str(action, NULL, content);
+ action_arg_add_str(action, "to", content);
+ } else if (!strcmp(nodename, "follow.action")) {
+ /* SendToDesktop */
+ action_arg_add_bool(action, "follow", get_bool(content));
} else if (!strcmp(nodename, "region.action")) {
/* SnapToRegion */
action_arg_add_str(action, NULL, content);
return ((struct action_arg_str *)arg)->value;
}
+static bool
+action_bool_from_arg(struct action_arg *arg)
+{
+ assert(arg->type == LAB_ACTION_ARG_BOOL);
+ return ((struct action_arg_bool *)arg)->value;
+}
+
static struct action_arg *
action_get_first_arg(struct action *action)
{
}
break;
case ACTION_TYPE_SEND_TO_DESKTOP:
- if (!arg) {
- wlr_log(WLR_ERROR, "Missing argument for SendToDesktop");
- break;
- }
if (view) {
+ struct action_arg *arg;
+ char *target_name = NULL;
struct workspace *target;
- char *target_name = action_str_from_arg(arg);
+ bool follow = true;
+
+ wl_list_for_each(arg, &action->args, link) {
+ if (!strcmp("to", arg->key)) {
+ target_name = action_str_from_arg(arg);
+ } else if (!strcmp("follow", arg->key)) {
+ follow = action_bool_from_arg(arg);
+ }
+ }
target = workspaces_find(view->workspace, target_name);
if (target) {
view_move_to_workspace(view, target);
+ if (follow) {
+ workspaces_switch_to(target);
+ }
}
}
break;
arg->value = xstrdup(value);
wl_list_append(&action->args, &arg->base.link);
}
+
+void
+action_arg_add_bool(struct action *action, char *key, bool value)
+{
+ struct action_arg_bool *arg = znew(*arg);
+ arg->base.type = LAB_ACTION_ARG_BOOL;
+ if (key) {
+ arg->base.key = xstrdup(key);
+ }
+ arg->value = value;
+ wl_list_append(&action->args, &arg->base.link);
+}
wlr_log(WLR_ERROR, "expect <action name=\"\"> element first. "
"nodename: '%s' content: '%s'", nodename, content);
} else {
+ /*
+ * Here we deal with action sub-elements such as <to>, <output>,
+ * <region>, <direction> and so on. This is common to key- and
+ * mousebinds.
+ */
action_arg_from_xml_node(current_keybind_action, nodename, content);
}
}
/* Workspace sub-menu */
struct menu *workspace_menu = menu_create(server, "workspaces", "");
current_item = item_create(workspace_menu, _("Move left"), false);
+ /*
+ * <action name="SendToDesktop"><follow> is true by default so
+ * GoToDesktop will be called as part of the action.
+ */
fill_item("name.action", "SendToDesktop");
fill_item("to.action", "left");
- fill_item("name.action", "GoToDesktop");
- fill_item("to.action", "left");
current_item = item_create(workspace_menu, _("Move right"), false);
fill_item("name.action", "SendToDesktop");
fill_item("to.action", "right");
- fill_item("name.action", "GoToDesktop");
- fill_item("to.action", "right");
current_item = item_create(menu, _("Workspace"), true);
current_item->submenu = workspace_menu;