diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-19 01:06:15 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-19 01:06:15 -0700 |
commit | c5a69828934bf07db9062bd5f24bb2ff94b45b4a (patch) | |
tree | 5d580fed19fa2aa25014fe234edc6db14cfaa652 | |
parent | fixed focus key handler (diff) | |
download | sway-c5a69828934bf07db9062bd5f24bb2ff94b45b4a.tar.gz sway-c5a69828934bf07db9062bd5f24bb2ff94b45b4a.tar.zst sway-c5a69828934bf07db9062bd5f24bb2ff94b45b4a.zip |
fixed some more bugs, moved layout_log into log.ch, restored focus_parent
-rw-r--r-- | include/log.h | 2 | ||||
-rw-r--r-- | include/workspace.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 10 | ||||
-rw-r--r-- | sway/container.c | 1 | ||||
-rw-r--r-- | sway/focus.c | 3 | ||||
-rw-r--r-- | sway/log.c | 59 | ||||
-rw-r--r-- | sway/workspace.c | 57 |
7 files changed, 70 insertions, 63 deletions
diff --git a/include/log.h b/include/log.h index 44f84940..7aea2ded 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _SWAY_LOG_H | 1 | #ifndef _SWAY_LOG_H |
2 | #define _SWAY_LOG_H | 2 | #define _SWAY_LOG_H |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include "container.h" | ||
4 | 5 | ||
5 | typedef enum { | 6 | typedef enum { |
6 | L_SILENT = 0, | 7 | L_SILENT = 0, |
@@ -15,4 +16,5 @@ void sway_log(int verbosity, const char* format, ...) __attribute__((format(prin | |||
15 | void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); | 16 | void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); |
16 | bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); | 17 | bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); |
17 | 18 | ||
19 | void layout_log(const swayc_t *c, int depth); | ||
18 | #endif | 20 | #endif |
diff --git a/include/workspace.h b/include/workspace.h index 8ce39bbd..042a15d9 100644 --- a/include/workspace.h +++ b/include/workspace.h | |||
@@ -15,6 +15,5 @@ void workspace_output_next(); | |||
15 | void workspace_next(); | 15 | void workspace_next(); |
16 | void workspace_output_prev(); | 16 | void workspace_output_prev(); |
17 | void workspace_prev(); | 17 | void workspace_prev(); |
18 | void layout_log(const swayc_t *c, int depth); | ||
19 | 18 | ||
20 | #endif | 19 | #endif |
diff --git a/sway/commands.c b/sway/commands.c index 6e1f1848..7dde78bd 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -182,20 +182,22 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
182 | if (view->type != C_VIEW) { | 182 | if (view->type != C_VIEW) { |
183 | return true; | 183 | return true; |
184 | } | 184 | } |
185 | int i; | ||
186 | // Change from nonfloating to floating | 185 | // Change from nonfloating to floating |
187 | if (!view->is_floating) { | 186 | if (!view->is_floating) { |
188 | remove_child(view); | 187 | //Remove view from its current location |
188 | destroy_container(remove_child(view)); | ||
189 | |||
190 | //and move it into workspace floating | ||
189 | add_floating(active_workspace,view); | 191 | add_floating(active_workspace,view); |
190 | view->x = (active_workspace->width - view->width)/2; | 192 | view->x = (active_workspace->width - view->width)/2; |
191 | view->y = (active_workspace->height - view->height)/2; | 193 | view->y = (active_workspace->height - view->height)/2; |
192 | arrange_windows(active_workspace, -1, -1); | ||
193 | if (view->desired_width != -1) { | 194 | if (view->desired_width != -1) { |
194 | view->width = view->desired_width; | 195 | view->width = view->desired_width; |
195 | } | 196 | } |
196 | if (view->desired_height != -1) { | 197 | if (view->desired_height != -1) { |
197 | view->height = view->desired_height; | 198 | view->height = view->desired_height; |
198 | } | 199 | } |
200 | arrange_windows(active_workspace, -1, -1); | ||
199 | } else { | 201 | } else { |
200 | // Delete the view from the floating list and unset its is_floating flag | 202 | // Delete the view from the floating list and unset its is_floating flag |
201 | // Using length-1 as the index is safe because the view must be the currently | 203 | // Using length-1 as the index is safe because the view must be the currently |
@@ -221,10 +223,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
221 | add_sibling(focused, view); | 223 | add_sibling(focused, view); |
222 | } | 224 | } |
223 | // Refocus on the view once its been put back into the layout | 225 | // Refocus on the view once its been put back into the layout |
224 | set_focused_container(view); | ||
225 | arrange_windows(active_workspace, -1, -1); | 226 | arrange_windows(active_workspace, -1, -1); |
226 | return true; | 227 | return true; |
227 | } | 228 | } |
229 | set_focused_container(view); | ||
228 | } | 230 | } |
229 | 231 | ||
230 | return true; | 232 | return true; |
diff --git a/sway/container.c b/sway/container.c index 9763f381..0a89f634 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -261,7 +261,6 @@ swayc_t *destroy_container(swayc_t *container) { | |||
261 | sway_log(L_DEBUG, "Container: Destroying container '%p'", container); | 261 | sway_log(L_DEBUG, "Container: Destroying container '%p'", container); |
262 | swayc_t *parent = container->parent; | 262 | swayc_t *parent = container->parent; |
263 | free_swayc(container); | 263 | free_swayc(container); |
264 | |||
265 | container = parent; | 264 | container = parent; |
266 | } | 265 | } |
267 | return container; | 266 | return container; |
diff --git a/sway/focus.c b/sway/focus.c index 0ee10694..7023d37d 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -146,6 +146,9 @@ void set_focused_container(swayc_t *c) { | |||
146 | // update container focus from here to root, making necessary changes along | 146 | // update container focus from here to root, making necessary changes along |
147 | // the way | 147 | // the way |
148 | swayc_t *p = c; | 148 | swayc_t *p = c; |
149 | if (p->type != C_OUTPUT && p->type != C_ROOT) { | ||
150 | p->is_focused = true; | ||
151 | } | ||
149 | while (p != &root_container) { | 152 | while (p != &root_container) { |
150 | update_focus(p); | 153 | update_focus(p); |
151 | p = p->parent; | 154 | p = p->parent; |
@@ -82,3 +82,62 @@ bool sway_assert(bool condition, const char* format, ...) { | |||
82 | 82 | ||
83 | return false; | 83 | return false; |
84 | } | 84 | } |
85 | |||
86 | #include "workspace.h" | ||
87 | |||
88 | /* XXX:DEBUG:XXX */ | ||
89 | static void container_log(const swayc_t *c) { | ||
90 | fprintf(stderr, "focus:%c|", | ||
91 | c->is_focused ? 'F' : //Focused | ||
92 | c == active_workspace ? 'W' : //active workspace | ||
93 | c == &root_container ? 'R' : //root | ||
94 | 'X');//not any others | ||
95 | fprintf(stderr,"(%p)",c); | ||
96 | fprintf(stderr,"(p:%p)",c->parent); | ||
97 | fprintf(stderr,"(f:%p)",c->focused); | ||
98 | fprintf(stderr,"(h:%ld)",c->handle); | ||
99 | fprintf(stderr,"Type:"); | ||
100 | fprintf(stderr, | ||
101 | c->type == C_ROOT ? "Root|" : | ||
102 | c->type == C_OUTPUT ? "Output|" : | ||
103 | c->type == C_WORKSPACE ? "Workspace|" : | ||
104 | c->type == C_CONTAINER ? "Container|" : | ||
105 | c->type == C_VIEW ? "View|" : "Unknown|"); | ||
106 | fprintf(stderr,"layout:"); | ||
107 | fprintf(stderr, | ||
108 | c->layout == L_NONE ? "NONE|" : | ||
109 | c->layout == L_HORIZ ? "Horiz|": | ||
110 | c->layout == L_VERT ? "Vert|": | ||
111 | c->layout == L_STACKED ? "Stacked|": | ||
112 | c->layout == L_FLOATING ? "Floating|": | ||
113 | "Unknown|"); | ||
114 | fprintf(stderr, "w:%d|h:%d|", c->width, c->height); | ||
115 | fprintf(stderr, "x:%d|y:%d|", c->x, c->y); | ||
116 | fprintf(stderr, "vis:%c|", c->visible?'t':'f'); | ||
117 | fprintf(stderr, "wgt:%d|", c->weight); | ||
118 | fprintf(stderr, "name:%.16s|", c->name); | ||
119 | fprintf(stderr, "children:%d\n",c->children?c->children->length:0); | ||
120 | } | ||
121 | void layout_log(const swayc_t *c, int depth) { | ||
122 | int i, d; | ||
123 | int e = c->children ? c->children->length : 0; | ||
124 | container_log(c); | ||
125 | if (e) { | ||
126 | for (i = 0; i < e; ++i) { | ||
127 | fputc('|',stderr); | ||
128 | for (d = 0; d < depth; ++d) fputc('-', stderr); | ||
129 | layout_log(c->children->items[i], depth + 1); | ||
130 | } | ||
131 | } | ||
132 | if (c->type == C_WORKSPACE) { | ||
133 | e = c->floating?c->floating->length:0; | ||
134 | if (e) { | ||
135 | for (i = 0; i < e; ++i) { | ||
136 | fputc('|',stderr); | ||
137 | for (d = 0; d < depth; ++d) fputc('=', stderr); | ||
138 | layout_log(c->floating->items[i], depth + 1); | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | /* XXX:DEBUG:XXX */ | ||
diff --git a/sway/workspace.c b/sway/workspace.c index 60108752..9b407c6a 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -182,60 +182,3 @@ void workspace_switch(swayc_t *workspace) { | |||
182 | set_focused_container(get_focused_view(workspace)); | 182 | set_focused_container(get_focused_view(workspace)); |
183 | arrange_windows(workspace, -1, -1); | 183 | arrange_windows(workspace, -1, -1); |
184 | } | 184 | } |
185 | |||
186 | /* XXX:DEBUG:XXX */ | ||
187 | static void container_log(const swayc_t *c) { | ||
188 | fprintf(stderr, "focus:%c|", | ||
189 | c->is_focused ? 'F' : //Focused | ||
190 | c == active_workspace ? 'W' : //active workspace | ||
191 | c == &root_container ? 'R' : //root | ||
192 | 'X');//not any others | ||
193 | fprintf(stderr,"(%p)",c); | ||
194 | fprintf(stderr,"(p:%p)",c->parent); | ||
195 | fprintf(stderr,"(f:%p)",c->focused); | ||
196 | fprintf(stderr,"(h:%ld)",c->handle); | ||
197 | fprintf(stderr,"Type:"); | ||
198 | fprintf(stderr, | ||
199 | c->type == C_ROOT ? "Root|" : | ||
200 | c->type == C_OUTPUT ? "Output|" : | ||
201 | c->type == C_WORKSPACE ? "Workspace|" : | ||
202 | c->type == C_CONTAINER ? "Container|" : | ||
203 | c->type == C_VIEW ? "View|" : "Unknown|"); | ||
204 | fprintf(stderr,"layout:"); | ||
205 | fprintf(stderr, | ||
206 | c->layout == L_NONE ? "NONE|" : | ||
207 | c->layout == L_HORIZ ? "Horiz|": | ||
208 | c->layout == L_VERT ? "Vert|": | ||
209 | c->layout == L_STACKED ? "Stacked|": | ||
210 | c->layout == L_FLOATING ? "Floating|": | ||
211 | "Unknown|"); | ||
212 | fprintf(stderr, "w:%d|h:%d|", c->width, c->height); | ||
213 | fprintf(stderr, "x:%d|y:%d|", c->x, c->y); | ||
214 | fprintf(stderr, "vis:%c|", c->visible?'t':'f'); | ||
215 | fprintf(stderr, "wgt:%d|", c->weight); | ||
216 | fprintf(stderr, "name:%.16s|", c->name); | ||
217 | fprintf(stderr, "children:%d\n",c->children?c->children->length:0); | ||
218 | } | ||
219 | void layout_log(const swayc_t *c, int depth) { | ||
220 | int i, d; | ||
221 | int e = c->children ? c->children->length : 0; | ||
222 | container_log(c); | ||
223 | if (e) { | ||
224 | for (i = 0; i < e; ++i) { | ||
225 | fputc('|',stderr); | ||
226 | for (d = 0; d < depth; ++d) fputc('-', stderr); | ||
227 | layout_log(c->children->items[i], depth + 1); | ||
228 | } | ||
229 | } | ||
230 | if (c->type == C_WORKSPACE) { | ||
231 | e = c->floating?c->floating->length:0; | ||
232 | if (e) { | ||
233 | for (i = 0; i < e; ++i) { | ||
234 | fputc('|',stderr); | ||
235 | for (d = 0; d < depth; ++d) fputc('-', stderr); | ||
236 | layout_log(c->floating->items[i], depth + 1); | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | /* XXX:DEBUG:XXX */ | ||