summaryrefslogtreecommitdiffstats
path: root/sway/workspace.c
diff options
context:
space:
mode:
authorLibravatar Taiyu <taiyu.len@gmail.com>2015-08-14 12:42:19 -0700
committerLibravatar Taiyu <taiyu.len@gmail.com>2015-08-14 12:42:19 -0700
commitb8cba33c013e580e6e793ec67a5442407d94a002 (patch)
treed3a197d4297269716049fa6c09ad59ef350cfff5 /sway/workspace.c
parentMerge pull request #26 from Luminarys/master (diff)
downloadsway-b8cba33c013e580e6e793ec67a5442407d94a002.tar.gz
sway-b8cba33c013e580e6e793ec67a5442407d94a002.tar.zst
sway-b8cba33c013e580e6e793ec67a5442407d94a002.zip
changed swayc related functions, cleaned up some functions, moved wlc related things into handlers
Diffstat (limited to 'sway/workspace.c')
-rw-r--r--sway/workspace.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/sway/workspace.c b/sway/workspace.c
index 906d0c5d..88596dfe 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -6,6 +6,7 @@
6#include "list.h" 6#include "list.h"
7#include "log.h" 7#include "log.h"
8#include "container.h" 8#include "container.h"
9#include "handlers.h"
9#include "config.h" 10#include "config.h"
10#include "stringop.h" 11#include "stringop.h"
11 12
@@ -71,16 +72,7 @@ swayc_t *workspace_create(const char* name) {
71 while(parent->type != C_OUTPUT) { 72 while(parent->type != C_OUTPUT) {
72 parent = parent->parent; 73 parent = parent->parent;
73 } 74 }
74 75 return new_workspace(parent, name);
75 swayc_t *workspace = create_container(parent, -1);
76 workspace->type = C_WORKSPACE;
77 workspace->name = strdup(name);
78 workspace->width = parent->width;
79 workspace->height = parent->height;
80 workspace->layout = L_HORIZ; // todo: thing
81
82 add_child(parent, workspace);
83 return workspace;
84} 76}
85 77
86bool workspace_by_name(swayc_t *view, void *data) { 78bool workspace_by_name(swayc_t *view, void *data) {
@@ -88,23 +80,13 @@ bool workspace_by_name(swayc_t *view, void *data) {
88 (strcasecmp(view->name, (char *) data) == 0); 80 (strcasecmp(view->name, (char *) data) == 0);
89} 81}
90 82
91bool workspace_destroy(swayc_t *workspace) {
92 //Dont destroy if there are children
93 if (workspace->children->length) {
94 return false;
95 }
96 sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name);
97 free_swayc(workspace);
98 return true;
99}
100
101void set_mask(swayc_t *view, void *data) { 83void set_mask(swayc_t *view, void *data) {
102 uint32_t *p = data; 84 uint32_t *p = data;
103 85
104 if(view->type == C_VIEW) { 86 if(view->type == C_VIEW) {
105 wlc_view_set_mask(view->handle, *p); 87 wlc_view_set_mask(view->handle, *p);
106 view->visible = (*p == 2);
107 } 88 }
89 view->visible = (*p == 2);
108} 90}
109 91
110swayc_t *workspace_find_by_name(const char* name) { 92swayc_t *workspace_find_by_name(const char* name) {
@@ -123,9 +105,9 @@ void workspace_switch(swayc_t *workspace) {
123 container_map(workspace, set_mask, &mask); 105 container_map(workspace, set_mask, &mask);
124 106
125 wlc_output_set_mask(wlc_get_focused_output(), 2); 107 wlc_output_set_mask(wlc_get_focused_output(), 2);
126 unfocus_all(active_workspace); 108 unfocus_all(&root_container);
127 focus_view(workspace); 109 focus_view(workspace);
128 workspace_destroy(active_workspace); 110 destroy_workspace(active_workspace);
129 } 111 }
130 active_workspace = workspace; 112 active_workspace = workspace;
131} 113}