mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 20:44:01 +01:00
fixed 2 small memory leaks & adds format attribute to log.
This commit is contained in:
parent
d3d0ba3a4b
commit
083d1eed1f
@ -31,6 +31,9 @@ static void free_swayc(swayc_t *c) {
|
||||
}
|
||||
remove_child(c->parent, c);
|
||||
}
|
||||
if (c->name) {
|
||||
free(c->name);
|
||||
}
|
||||
free(c);
|
||||
}
|
||||
|
||||
|
@ -88,22 +88,22 @@ static void handle_output_focused(wlc_handle output, bool focus) {
|
||||
static bool handle_view_created(wlc_handle handle) {
|
||||
swayc_t *focused = get_focused_container(&root_container);
|
||||
swayc_t *view = new_view(focused, handle);
|
||||
//Leave unamanaged windows alone
|
||||
if (view) {
|
||||
//Set maximize flag for windows.
|
||||
//TODO: floating windows have this unset
|
||||
wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
|
||||
unfocus_all(&root_container);
|
||||
focus_view(view);
|
||||
arrange_windows(view->parent, -1, -1);
|
||||
} else { //Unmanaged view
|
||||
wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
|
||||
if (!(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) {
|
||||
unfocus_all(&root_container);
|
||||
focus_view(view);
|
||||
}
|
||||
else {
|
||||
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
||||
wlc_view_focus(handle);
|
||||
}
|
||||
} else {
|
||||
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
||||
wlc_view_focus(handle);
|
||||
}
|
||||
if (wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
|
||||
unfocus_all(&root_container);
|
||||
focus_view(focused);
|
||||
arrange_windows(focused, -1, -1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -215,10 +215,10 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
|
||||
}
|
||||
|
||||
swayc_t *get_focused_container(swayc_t *parent) {
|
||||
if (parent->focused == NULL) {
|
||||
return parent;
|
||||
while (parent->focused) {
|
||||
parent = parent->focused;
|
||||
}
|
||||
return get_focused_container(parent->focused);
|
||||
return parent;
|
||||
}
|
||||
|
||||
void unfocus_all(swayc_t *container) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef _SWAY_LOG_H
|
||||
#define _SWAY_LOG_H
|
||||
|
||||
#ifndef __GNUC__
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
L_SILENT = 0,
|
||||
L_ERROR = 1,
|
||||
@ -8,9 +12,10 @@ typedef enum {
|
||||
L_DEBUG = 3,
|
||||
} log_importance_t;
|
||||
|
||||
|
||||
void init_log(int verbosity);
|
||||
void sway_log_colors(int mode);
|
||||
void sway_log(int verbosity, char* format, ...);
|
||||
void sway_abort(char* format, ...);
|
||||
void sway_log(int verbosity, char* format, ...)__attribute__((format (printf,2,3)));
|
||||
void sway_abort(char* format, ...) __attribute__((format (printf,1,2)));
|
||||
|
||||
#endif
|
||||
|
@ -67,6 +67,7 @@ list_t *split_string(const char *str, const char *delims) {
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
free(left);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -26,7 +26,7 @@ char *workspace_next_name(void) {
|
||||
list_t *args = split_string(command, " ");
|
||||
|
||||
if (strcmp("workspace", args->items[0]) == 0 && args->length > 1) {
|
||||
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", args->items[1]);
|
||||
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", (char *)args->items[1]);
|
||||
char* target = malloc(strlen(args->items[1]) + 1);
|
||||
strcpy(target, args->items[1]);
|
||||
while (*target == ' ' || *target == '\t')
|
||||
|
Loading…
Reference in New Issue
Block a user