mirror of
https://github.com/swaywm/sway.git
synced 2024-11-13 05:54:11 +01:00
Merge pull request #155 from Luminarys/master
Added in workspace back_and_forth
This commit is contained in:
commit
0ab71f5f0a
@ -5,6 +5,8 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
|
||||||
|
extern char *prev_workspace_name;
|
||||||
|
|
||||||
char *workspace_next_name(void);
|
char *workspace_next_name(void);
|
||||||
swayc_t *workspace_create(const char*);
|
swayc_t *workspace_create(const char*);
|
||||||
swayc_t *workspace_by_name(const char*);
|
swayc_t *workspace_by_name(const char*);
|
||||||
|
@ -800,26 +800,36 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) {
|
|||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
// Handle workspace next/prev
|
// Handle workspace next/prev
|
||||||
if (strcmp(argv[0], "next") == 0) {
|
if (strcasecmp(argv[0], "next") == 0) {
|
||||||
workspace_switch(workspace_next());
|
workspace_switch(workspace_next());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[0], "prev") == 0) {
|
if (strcasecmp(argv[0], "prev") == 0) {
|
||||||
workspace_switch(workspace_prev());
|
workspace_switch(workspace_prev());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle workspace output_next/prev
|
// Handle workspace output_next/prev
|
||||||
if (strcmp(argv[0], "next_on_output") == 0) {
|
if (strcasecmp(argv[0], "next_on_output") == 0) {
|
||||||
workspace_switch(workspace_output_next());
|
workspace_switch(workspace_output_next());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[0], "prev_on_output") == 0) {
|
if (strcasecmp(argv[0], "prev_on_output") == 0) {
|
||||||
workspace_switch(workspace_output_prev());
|
workspace_switch(workspace_output_prev());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (strcasecmp(argv[0], "back_and_forth") == 0) {
|
||||||
|
if (prev_workspace_name) {
|
||||||
|
if (workspace_by_name(prev_workspace_name)) {
|
||||||
|
workspace_switch(workspace_by_name(prev_workspace_name));
|
||||||
|
} else {
|
||||||
|
workspace_switch(workspace_create(prev_workspace_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
swayc_t *workspace = workspace_by_name(argv[0]);
|
swayc_t *workspace = workspace_by_name(argv[0]);
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
char *prev_workspace_name;
|
||||||
|
|
||||||
char *workspace_next_name(void) {
|
char *workspace_next_name(void) {
|
||||||
sway_log(L_DEBUG, "Workspace: Generating new name");
|
sway_log(L_DEBUG, "Workspace: Generating new name");
|
||||||
int i;
|
int i;
|
||||||
@ -180,6 +182,11 @@ void workspace_switch(swayc_t *workspace) {
|
|||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!prev_workspace_name || strcmp(prev_workspace_name, swayc_active_workspace()->name) != 0) {
|
||||||
|
prev_workspace_name = malloc(strlen(swayc_active_workspace()->name) + 1);
|
||||||
|
strcpy(prev_workspace_name, swayc_active_workspace()->name);
|
||||||
|
}
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
|
sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
|
||||||
set_focused_container(get_focused_view(workspace));
|
set_focused_container(get_focused_view(workspace));
|
||||||
arrange_windows(workspace, -1, -1);
|
arrange_windows(workspace, -1, -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user