summaryrefslogtreecommitdiffstats
path: root/sway/workspace.c
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-08-21 10:28:37 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-08-21 10:28:37 -0700
commit1a1ac64662a603fdeb7025bed3822e24f9158076 (patch)
tree4ac14ed2cb3942072824a3376337ea5492bf4e75 /sway/workspace.c
parentMerge pull request #110 from minus7/sign-comparsion-fix (diff)
downloadsway-1a1ac64662a603fdeb7025bed3822e24f9158076.tar.gz
sway-1a1ac64662a603fdeb7025bed3822e24f9158076.tar.zst
sway-1a1ac64662a603fdeb7025bed3822e24f9158076.zip
bugfixes, renames
Diffstat (limited to 'sway/workspace.c')
-rw-r--r--sway/workspace.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/sway/workspace.c b/sway/workspace.c
index d436da8e..80b67128 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -1,6 +1,7 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <wlc/wlc.h> 3#include <wlc/wlc.h>
4#include <string.h>
4#include "workspace.h" 5#include "workspace.h"
5#include "layout.h" 6#include "layout.h"
6#include "list.h" 7#include "list.h"
@@ -11,8 +12,6 @@
11#include "stringop.h" 12#include "stringop.h"
12#include "focus.h" 13#include "focus.h"
13 14
14swayc_t *active_workspace = NULL;
15
16char *workspace_next_name(void) { 15char *workspace_next_name(void) {
17 sway_log(L_DEBUG, "Workspace: Generating new name"); 16 sway_log(L_DEBUG, "Workspace: Generating new name");
18 int i; 17 int i;
@@ -48,7 +47,7 @@ char *workspace_next_name(void) {
48 } 47 }
49 48
50 // Make sure that the workspace doesn't already exist 49 // Make sure that the workspace doesn't already exist
51 if (workspace_find_by_name(target)) { 50 if (workspace_by_name(target)) {
52 list_free(args); 51 list_free(args);
53 continue; 52 continue;
54 } 53 }
@@ -79,22 +78,22 @@ swayc_t *workspace_create(const char* name) {
79 return new_workspace(parent, name); 78 return new_workspace(parent, name);
80} 79}
81 80
82bool workspace_by_name(swayc_t *view, void *data) { 81static bool _workspace_by_name(swayc_t *view, void *data) {
83 return (view->type == C_WORKSPACE) && 82 return (view->type == C_WORKSPACE) &&
84 (strcasecmp(view->name, (char *) data) == 0); 83 (strcasecmp(view->name, (char *) data) == 0);
85} 84}
86 85
87swayc_t *workspace_find_by_name(const char* name) { 86swayc_t *workspace_by_name(const char* name) {
88 return find_container(&root_container, workspace_by_name, (void *) name); 87 return swayc_by_test(&root_container, _workspace_by_name, (void *) name);
89} 88}
90 89
91void workspace_output_next() { 90void workspace_output_next() {
92 // Get the index of the workspace in the current output, and change the view to index+1 workspace. 91 // Get the index of the workspace in the current output, and change the view to index+1 workspace.
93 // if we're currently focused on the last workspace in the output, switch to the first 92 // if we're currently focused on the last workspace in the output, switch to the first
94 swayc_t *current_output = active_workspace->parent; 93 swayc_t *current_output = swayc_active_workspace()->parent;
95 int i; 94 int i;
96 for (i = 0; i < current_output->children->length - 1; i++) { 95 for (i = 0; i < current_output->children->length - 1; i++) {
97 if (strcmp((((swayc_t *)current_output->children->items[i])->name), active_workspace->name) == 0) { 96 if (strcmp((((swayc_t *)current_output->children->items[i])->name), swayc_active_workspace()->name) == 0) {
98 workspace_switch(current_output->children->items[i + 1]); 97 workspace_switch(current_output->children->items[i + 1]);
99 return; 98 return;
100 } 99 }
@@ -106,10 +105,10 @@ void workspace_next() {
106 // Get the index of the workspace in the current output, and change the view to index+1 workspace. 105 // Get the index of the workspace in the current output, and change the view to index+1 workspace.
107 // if we're currently focused on the last workspace in the output, change focus to there 106 // if we're currently focused on the last workspace in the output, change focus to there
108 // and call workspace_output_next(), as long as another output actually exists 107 // and call workspace_output_next(), as long as another output actually exists
109 swayc_t *current_output = active_workspace->parent; 108 swayc_t *current_output = swayc_active_workspace()->parent;
110 int i; 109 int i;
111 for (i = 0; i < current_output->children->length - 1; i++) { 110 for (i = 0; i < current_output->children->length - 1; i++) {
112 if (strcmp((((swayc_t *)current_output->children->items[i])->name), active_workspace->name) == 0) { 111 if (strcmp((((swayc_t *)current_output->children->items[i])->name), swayc_active_workspace()->name) == 0) {
113 workspace_switch(current_output->children->items[i + 1]); 112 workspace_switch(current_output->children->items[i + 1]);
114 return; 113 return;
115 } 114 }
@@ -134,10 +133,10 @@ void workspace_next() {
134void workspace_output_prev() { 133void workspace_output_prev() {
135 // Get the index of the workspace in the current output, and change the view to index+1 workspace 134 // Get the index of the workspace in the current output, and change the view to index+1 workspace
136 // if we're currently focused on the first workspace in the output, do nothing and return false 135 // if we're currently focused on the first workspace in the output, do nothing and return false
137 swayc_t *current_output = active_workspace->parent; 136 swayc_t *current_output = swayc_active_workspace()->parent;
138 int i; 137 int i;
139 for (i = 1; i < current_output->children->length; i++) { 138 for (i = 1; i < current_output->children->length; i++) {
140 if (strcmp((((swayc_t *)current_output->children->items[i])->name), active_workspace->name) == 0) { 139 if (strcmp((((swayc_t *)current_output->children->items[i])->name), swayc_active_workspace()->name) == 0) {
141 workspace_switch(current_output->children->items[i - 1]); 140 workspace_switch(current_output->children->items[i - 1]);
142 return; 141 return;
143 } 142 }
@@ -150,10 +149,10 @@ void workspace_prev() {
150 // if we're currently focused on the last workspace in the output, change focus to there 149 // if we're currently focused on the last workspace in the output, change focus to there
151 // and call workspace_output_next(), as long as another output actually exists 150 // and call workspace_output_next(), as long as another output actually exists
152 151
153 swayc_t *current_output = active_workspace->parent; 152 swayc_t *current_output = swayc_active_workspace()->parent;
154 int i; 153 int i;
155 for (i = 1; i < current_output->children->length; i++) { 154 for (i = 1; i < current_output->children->length; i++) {
156 if (strcmp((((swayc_t *)current_output->children->items[i])->name), active_workspace->name) == 0) { 155 if (strcmp((((swayc_t *)current_output->children->items[i])->name), swayc_active_workspace()->name) == 0) {
157 workspace_switch(current_output->children->items[i - 1]); 156 workspace_switch(current_output->children->items[i - 1]);
158 return; 157 return;
159 } 158 }