summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-08-15 21:21:20 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-08-15 21:21:20 -0700
commit083d1eed1f61f8cc7397031f1ab987022ba6868e (patch)
tree22d5c72c3352139cf0adda5f9b8c4c5e6245f73c
parentMerge pull request #35 from taiyu-len/master (diff)
downloadsway-083d1eed1f61f8cc7397031f1ab987022ba6868e.tar.gz
sway-083d1eed1f61f8cc7397031f1ab987022ba6868e.tar.zst
sway-083d1eed1f61f8cc7397031f1ab987022ba6868e.zip
fixed 2 small memory leaks & adds format attribute to log.
-rw-r--r--sway/container.c3
-rw-r--r--sway/handlers.c22
-rw-r--r--sway/layout.c6
-rw-r--r--sway/log.h9
-rw-r--r--sway/stringop.c1
-rw-r--r--sway/workspace.c2
6 files changed, 26 insertions, 17 deletions
diff --git a/sway/container.c b/sway/container.c
index 98941b2c..d1c8a7de 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -31,6 +31,9 @@ static void free_swayc(swayc_t *c) {
31 } 31 }
32 remove_child(c->parent, c); 32 remove_child(c->parent, c);
33 } 33 }
34 if (c->name) {
35 free(c->name);
36 }
34 free(c); 37 free(c);
35} 38}
36 39
diff --git a/sway/handlers.c b/sway/handlers.c
index 9944be33..6f4cb477 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -88,22 +88,22 @@ static void handle_output_focused(wlc_handle output, bool focus) {
88static bool handle_view_created(wlc_handle handle) { 88static bool handle_view_created(wlc_handle handle) {
89 swayc_t *focused = get_focused_container(&root_container); 89 swayc_t *focused = get_focused_container(&root_container);
90 swayc_t *view = new_view(focused, handle); 90 swayc_t *view = new_view(focused, handle);
91 //Leave unamanaged windows alone
91 if (view) { 92 if (view) {
92 //Set maximize flag for windows.
93 //TODO: floating windows have this unset
94 wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
95 unfocus_all(&root_container);
96 focus_view(view);
97 arrange_windows(view->parent, -1, -1); 93 arrange_windows(view->parent, -1, -1);
98 } else { //Unmanaged view 94 wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
95 if (!(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) {
96 unfocus_all(&root_container);
97 focus_view(view);
98 }
99 else {
100 wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
101 wlc_view_focus(handle);
102 }
103 } else {
99 wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); 104 wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
100 wlc_view_focus(handle); 105 wlc_view_focus(handle);
101 } 106 }
102 if (wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
103 unfocus_all(&root_container);
104 focus_view(focused);
105 arrange_windows(focused, -1, -1);
106 }
107 return true; 107 return true;
108} 108}
109 109
diff --git a/sway/layout.c b/sway/layout.c
index 918da9f0..8cf88be3 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -215,10 +215,10 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
215} 215}
216 216
217swayc_t *get_focused_container(swayc_t *parent) { 217swayc_t *get_focused_container(swayc_t *parent) {
218 if (parent->focused == NULL) { 218 while (parent->focused) {
219 return parent; 219 parent = parent->focused;
220 } 220 }
221 return get_focused_container(parent->focused); 221 return parent;
222} 222}
223 223
224void unfocus_all(swayc_t *container) { 224void unfocus_all(swayc_t *container) {
diff --git a/sway/log.h b/sway/log.h
index e5075a39..3e8c55f0 100644
--- a/sway/log.h
+++ b/sway/log.h
@@ -1,6 +1,10 @@
1#ifndef _SWAY_LOG_H 1#ifndef _SWAY_LOG_H
2#define _SWAY_LOG_H 2#define _SWAY_LOG_H
3 3
4#ifndef __GNUC__
5# define __attribute__(x)
6#endif
7
4typedef enum { 8typedef enum {
5 L_SILENT = 0, 9 L_SILENT = 0,
6 L_ERROR = 1, 10 L_ERROR = 1,
@@ -8,9 +12,10 @@ typedef enum {
8 L_DEBUG = 3, 12 L_DEBUG = 3,
9} log_importance_t; 13} log_importance_t;
10 14
15
11void init_log(int verbosity); 16void init_log(int verbosity);
12void sway_log_colors(int mode); 17void sway_log_colors(int mode);
13void sway_log(int verbosity, char* format, ...); 18void sway_log(int verbosity, char* format, ...)__attribute__((format (printf,2,3)));
14void sway_abort(char* format, ...); 19void sway_abort(char* format, ...) __attribute__((format (printf,1,2)));
15 20
16#endif 21#endif
diff --git a/sway/stringop.c b/sway/stringop.c
index bbc0bcdf..b944a43d 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -67,6 +67,7 @@ list_t *split_string(const char *str, const char *delims) {
67 j++; 67 j++;
68 i++; 68 i++;
69 } 69 }
70 free(left);
70 } 71 }
71 } 72 }
72 return res; 73 return res;
diff --git a/sway/workspace.c b/sway/workspace.c
index 49a1224f..a08877be 100644
--- a/sway/workspace.c
+++ b/sway/workspace.c
@@ -26,7 +26,7 @@ char *workspace_next_name(void) {
26 list_t *args = split_string(command, " "); 26 list_t *args = split_string(command, " ");
27 27
28 if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) { 28 if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
29 sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]); 29 sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", (char *)args->items[1]);
30 char* target = malloc(strlen(args->items[1]) + 1); 30 char* target = malloc(strlen(args->items[1]) + 1);
31 strcpy(target, args->items[1]); 31 strcpy(target, args->items[1]);
32 while (*target == ' ' || *target == '\t') 32 while (*target == ' ' || *target == '\t')