summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h2
-rw-r--r--sway/commands.c8
-rw-r--r--sway/config.c7
-rw-r--r--sway/config/bar.c1
-rw-r--r--sway/desktop/output.c40
-rw-r--r--sway/desktop/xwayland.c3
-rw-r--r--sway/input/keyboard.c3
-rw-r--r--sway/ipc-server.c12
-rw-r--r--sway/main.c3
-rw-r--r--sway/tree/container.c3
-rw-r--r--sway/tree/view.c8
-rw-r--r--sway/tree/workspace.c2
12 files changed, 71 insertions, 21 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 7ca0bda8..6d17144a 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -79,7 +79,7 @@ void free_cmd_results(struct cmd_results *results);
79 * 79 *
80 * Free the JSON string later on. 80 * Free the JSON string later on.
81 */ 81 */
82const char *cmd_results_to_json(struct cmd_results *results); 82char *cmd_results_to_json(struct cmd_results *results);
83 83
84struct cmd_results *add_color(const char *name, 84struct cmd_results *add_color(const char *name,
85 char *buffer, const char *color); 85 char *buffer, const char *color);
diff --git a/sway/commands.c b/sway/commands.c
index 5b67e1ec..ef477f38 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -527,7 +527,7 @@ void free_cmd_results(struct cmd_results *results) {
527 free(results); 527 free(results);
528} 528}
529 529
530const char *cmd_results_to_json(struct cmd_results *results) { 530char *cmd_results_to_json(struct cmd_results *results) {
531 json_object *result_array = json_object_new_array(); 531 json_object *result_array = json_object_new_array();
532 json_object *root = json_object_new_object(); 532 json_object *root = json_object_new_object();
533 json_object_object_add(root, "success", 533 json_object_object_add(root, "success",
@@ -542,9 +542,9 @@ const char *cmd_results_to_json(struct cmd_results *results) {
542 } 542 }
543 json_object_array_add(result_array, root); 543 json_object_array_add(result_array, root);
544 const char *json = json_object_to_json_string(result_array); 544 const char *json = json_object_to_json_string(result_array);
545 free(result_array); 545 char *res = strdup(json);
546 free(root); 546 json_object_put(result_array);
547 return json; 547 return res;
548} 548}
549 549
550/** 550/**
diff --git a/sway/config.c b/sway/config.c
index 0aae1696..89b7d349 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -87,7 +87,12 @@ void free_config(struct sway_config *config) {
87 list_free(config->cmd_queue); 87 list_free(config->cmd_queue);
88 list_free(config->workspace_outputs); 88 list_free(config->workspace_outputs);
89 list_free(config->pid_workspaces); 89 list_free(config->pid_workspaces);
90 list_free(config->output_configs); 90 if (config->output_configs) {
91 for (int i = 0; i < config->output_configs->length; i++) {
92 free_output_config(config->output_configs->items[i]);
93 }
94 list_free(config->output_configs);
95 }
91 if (config->input_configs) { 96 if (config->input_configs) {
92 for (int i = 0; i < config->input_configs->length; i++) { 97 for (int i = 0; i < config->input_configs->length; i++) {
93 free_input_config(config->input_configs->items[i]); 98 free_input_config(config->input_configs->items[i]);
diff --git a/sway/config/bar.c b/sway/config/bar.c
index b97076a0..ee062c6a 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -30,6 +30,7 @@ void free_bar_config(struct bar_config *bar) {
30 if (!bar) { 30 if (!bar) {
31 return; 31 return;
32 } 32 }
33 free(bar->id);
33 free(bar->mode); 34 free(bar->mode);
34 free(bar->position); 35 free(bar->position);
35 free(bar->hidden_state); 36 free(bar->hidden_state);
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index e5a42db0..336163ea 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -521,7 +521,7 @@ static void render_titlebar(struct sway_output *output,
521 size_t inner_width = width - TITLEBAR_H_PADDING * 2; 521 size_t inner_width = width - TITLEBAR_H_PADDING * 2;
522 522
523 // Marks 523 // Marks
524 size_t marks_width = 0; 524 size_t marks_ob_width = 0; // output-buffer-local
525 if (config->show_marks && marks_texture) { 525 if (config->show_marks && marks_texture) {
526 struct wlr_box texture_box; 526 struct wlr_box texture_box;
527 wlr_texture_get_size(marks_texture, 527 wlr_texture_get_size(marks_texture,
@@ -540,11 +540,23 @@ static void render_titlebar(struct sway_output *output,
540 } 540 }
541 render_texture(output->wlr_output, output_damage, marks_texture, 541 render_texture(output->wlr_output, output_damage, marks_texture,
542 &texture_box, matrix, con->alpha); 542 &texture_box, matrix, con->alpha);
543 marks_width = texture_box.width; 543 marks_ob_width = texture_box.width;
544
545 // Gap between the marks and bottom padding, for when the marks texture
546 // height is smaller than the config's font height
547 memcpy(&color, colors->background, sizeof(float) * 4);
548 premultiply_alpha(color, con->alpha);
549 box.x = texture_box.x;
550 box.y = texture_box.y + texture_box.height;
551 box.width = texture_box.width;
552 box.height = config->font_height * output_scale - texture_box.height;
553 if (box.height > 0) {
554 render_rect(output->wlr_output, output_damage, &box, color);
555 }
544 } 556 }
545 557
546 // Title text 558 // Title text
547 size_t title_width = 0; 559 size_t title_ob_width = 0; // output-buffer-local
548 if (title_texture) { 560 if (title_texture) {
549 struct wlr_box texture_box; 561 struct wlr_box texture_box;
550 wlr_texture_get_size(title_texture, 562 wlr_texture_get_size(title_texture,
@@ -557,12 +569,24 @@ static void render_titlebar(struct sway_output *output,
557 WL_OUTPUT_TRANSFORM_NORMAL, 569 WL_OUTPUT_TRANSFORM_NORMAL,
558 0.0, output->wlr_output->transform_matrix); 570 0.0, output->wlr_output->transform_matrix);
559 571
560 if (inner_width * output_scale - marks_width < texture_box.width) { 572 if (inner_width * output_scale - marks_ob_width < texture_box.width) {
561 texture_box.width = inner_width * output_scale - marks_width; 573 texture_box.width = inner_width * output_scale - marks_ob_width;
562 } 574 }
563 render_texture(output->wlr_output, output_damage, title_texture, 575 render_texture(output->wlr_output, output_damage, title_texture,
564 &texture_box, matrix, con->alpha); 576 &texture_box, matrix, con->alpha);
565 title_width = texture_box.width; 577 title_ob_width = texture_box.width;
578
579 // Gap between the title and bottom padding, for when the title texture
580 // height is smaller than the config's font height
581 memcpy(&color, colors->background, sizeof(float) * 4);
582 premultiply_alpha(color, con->alpha);
583 box.x = texture_box.x;
584 box.y = texture_box.y + texture_box.height;
585 box.width = texture_box.width;
586 box.height = config->font_height * output_scale - texture_box.height;
587 if (box.height > 0) {
588 render_rect(output->wlr_output, output_damage, &box, color);
589 }
566 } 590 }
567 591
568 // Padding above title 592 // Padding above title
@@ -580,9 +604,9 @@ static void render_titlebar(struct sway_output *output,
580 render_rect(output->wlr_output, output_damage, &box, color); 604 render_rect(output->wlr_output, output_damage, &box, color);
581 605
582 // Filler between title and marks 606 // Filler between title and marks
583 box.width = inner_width * output_scale - title_width - marks_width; 607 box.width = inner_width * output_scale - title_ob_width - marks_ob_width;
584 if (box.width > 0) { 608 if (box.width > 0) {
585 box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_width; 609 box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_ob_width;
586 box.y = (y + TITLEBAR_V_PADDING) * output_scale; 610 box.y = (y + TITLEBAR_V_PADDING) * output_scale;
587 box.height = config->font_height * output_scale; 611 box.height = config->font_height * output_scale;
588 render_rect(output->wlr_output, output_damage, &box, color); 612 render_rect(output->wlr_output, output_damage, &box, color);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 0669a485..b2874cfe 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -283,7 +283,10 @@ static void handle_commit(struct wl_listener *listener, void *data) {
283 if (view->swayc->instructions->length) { 283 if (view->swayc->instructions->length) {
284 transaction_notify_view_ready_by_size(view, 284 transaction_notify_view_ready_by_size(view,
285 surface_state->width, surface_state->height); 285 surface_state->width, surface_state->height);
286 } else if (container_is_floating(view->swayc)) {
287 view_update_size(view, surface_state->width, surface_state->height);
286 } 288 }
289
287 view_damage_from(view); 290 view_damage_from(view);
288} 291}
289 292
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index ec149d06..182536de 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -420,6 +420,9 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) {
420 if (!keyboard) { 420 if (!keyboard) {
421 return; 421 return;
422 } 422 }
423 if (keyboard->keymap) {
424 xkb_keymap_unref(keyboard->keymap);
425 }
423 wl_list_remove(&keyboard->keyboard_key.link); 426 wl_list_remove(&keyboard->keyboard_key.link);
424 wl_list_remove(&keyboard->keyboard_modifiers.link); 427 wl_list_remove(&keyboard->keyboard_modifiers.link);
425 free(keyboard); 428 free(keyboard);
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 8cfd9f26..abdaa237 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -64,6 +64,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
64 close(ipc_socket); 64 close(ipc_socket);
65 unlink(ipc_sockaddr->sun_path); 65 unlink(ipc_sockaddr->sun_path);
66 66
67 while (ipc_client_list->length) {
68 struct ipc_client *client = ipc_client_list->items[0];
69 ipc_client_disconnect(client);
70 }
67 list_free(ipc_client_list); 71 list_free(ipc_client_list);
68 72
69 if (ipc_sockaddr) { 73 if (ipc_sockaddr) {
@@ -479,10 +483,10 @@ void ipc_client_handle_command(struct ipc_client *client) {
479 case IPC_COMMAND: 483 case IPC_COMMAND:
480 { 484 {
481 struct cmd_results *results = execute_command(buf, NULL); 485 struct cmd_results *results = execute_command(buf, NULL);
482 const char *json = cmd_results_to_json(results); 486 char *json = cmd_results_to_json(results);
483 char reply[256]; 487 int length = strlen(json);
484 int length = snprintf(reply, sizeof(reply), "%s", json); 488 client_valid = ipc_send_reply(client, json, (uint32_t)length);
485 client_valid = ipc_send_reply(client, reply, (uint32_t)length); 489 free(json);
486 free_cmd_results(results); 490 free_cmd_results(results);
487 goto exit_cleanup; 491 goto exit_cleanup;
488 } 492 }
diff --git a/sway/main.c b/sway/main.c
index 96e41bbc..ec7353be 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -1,6 +1,7 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#define _POSIX_C_SOURCE 200112L 2#define _POSIX_C_SOURCE 200112L
3#include <getopt.h> 3#include <getopt.h>
4#include <pango/pangocairo.h>
4#include <signal.h> 5#include <signal.h>
5#include <stdbool.h> 6#include <stdbool.h>
6#include <stdlib.h> 7#include <stdlib.h>
@@ -441,5 +442,7 @@ int main(int argc, char **argv) {
441 free_config(config); 442 free_config(config);
442 } 443 }
443 444
445 pango_cairo_font_map_set_default(NULL);
446
444 return exit_value; 447 return exit_value;
445} 448}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 3614d4e7..5fdcb6e3 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -151,6 +151,7 @@ void container_free(struct sway_container *cont) {
151 return; 151 return;
152 } 152 }
153 free(cont->name); 153 free(cont->name);
154 free(cont->formatted_title);
154 wlr_texture_destroy(cont->title_focused); 155 wlr_texture_destroy(cont->title_focused);
155 wlr_texture_destroy(cont->title_focused_inactive); 156 wlr_texture_destroy(cont->title_focused_inactive);
156 wlr_texture_destroy(cont->title_unfocused); 157 wlr_texture_destroy(cont->title_unfocused);
@@ -782,7 +783,7 @@ static void update_title_texture(struct sway_container *con,
782 783
783 double scale = output->sway_output->wlr_output->scale; 784 double scale = output->sway_output->wlr_output->scale;
784 int width = 0; 785 int width = 0;
785 int height = config->font_height * scale; 786 int height = con->title_height * scale;
786 787
787 cairo_t *c = cairo_create(NULL); 788 cairo_t *c = cairo_create(NULL);
788 get_text_size(c, config->font, &width, NULL, scale, config->pango_markup, 789 get_text_size(c, config->font, &width, NULL, scale, config->pango_markup,
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 6b4daa82..3ef79fa8 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -514,7 +514,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
514 if (container_is_floating(focus)) { 514 if (container_is_floating(focus)) {
515 focus = focus->parent->parent; 515 focus = focus->parent->parent;
516 } 516 }
517 free(criterias); 517 list_free(criterias);
518 cont = container_view_create(focus, view); 518 cont = container_view_create(focus, view);
519 519
520 view->surface = wlr_surface; 520 view->surface = wlr_surface;
@@ -574,6 +574,8 @@ void view_update_position(struct sway_view *view, double lx, double ly) {
574 container_damage_whole(view->swayc); 574 container_damage_whole(view->swayc);
575 view->x = lx; 575 view->x = lx;
576 view->y = ly; 576 view->y = ly;
577 view->swayc->current.view_x = lx;
578 view->swayc->current.view_y = ly;
577 if (container_is_floating(view->swayc)) { 579 if (container_is_floating(view->swayc)) {
578 container_set_geometry_from_floating_view(view->swayc); 580 container_set_geometry_from_floating_view(view->swayc);
579 } 581 }
@@ -587,6 +589,8 @@ void view_update_size(struct sway_view *view, int width, int height) {
587 container_damage_whole(view->swayc); 589 container_damage_whole(view->swayc);
588 view->width = width; 590 view->width = width;
589 view->height = height; 591 view->height = height;
592 view->swayc->current.view_width = width;
593 view->swayc->current.view_height = height;
590 if (container_is_floating(view->swayc)) { 594 if (container_is_floating(view->swayc)) {
591 container_set_geometry_from_floating_view(view->swayc); 595 container_set_geometry_from_floating_view(view->swayc);
592 } 596 }
@@ -919,7 +923,7 @@ static void update_marks_texture(struct sway_view *view,
919 923
920 double scale = output->sway_output->wlr_output->scale; 924 double scale = output->sway_output->wlr_output->scale;
921 int width = 0; 925 int width = 0;
922 int height = config->font_height * scale; 926 int height = view->swayc->title_height * scale;
923 927
924 cairo_t *c = cairo_create(NULL); 928 cairo_t *c = cairo_create(NULL);
925 get_text_size(c, config->font, &width, NULL, scale, false, "%s", buffer); 929 get_text_size(c, config->font, &width, NULL, scale, false, "%s", buffer);
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 2db06a31..51f0fcb4 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -191,6 +191,8 @@ char *workspace_next_name(const char *output_name) {
191 free(target); 191 free(target);
192 target = _target; 192 target = _target;
193 wlr_log(L_DEBUG, "Workspace: Found free name %s", _target); 193 wlr_log(L_DEBUG, "Workspace: Found free name %s", _target);
194 } else {
195 free(_target);
194 } 196 }
195 } 197 }
196 free(dup); 198 free(dup);