diff options
| -rw-r--r-- | include/sway/commands.h | 2 | ||||
| -rw-r--r-- | sway/commands.c | 8 | ||||
| -rw-r--r-- | sway/config.c | 7 | ||||
| -rw-r--r-- | sway/config/bar.c | 1 | ||||
| -rw-r--r-- | sway/desktop/output.c | 40 | ||||
| -rw-r--r-- | sway/desktop/xwayland.c | 3 | ||||
| -rw-r--r-- | sway/input/keyboard.c | 3 | ||||
| -rw-r--r-- | sway/ipc-server.c | 12 | ||||
| -rw-r--r-- | sway/main.c | 3 | ||||
| -rw-r--r-- | sway/tree/container.c | 3 | ||||
| -rw-r--r-- | sway/tree/view.c | 8 | ||||
| -rw-r--r-- | sway/tree/workspace.c | 2 | 
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);   *   * Free the JSON string later on.   */ -const char *cmd_results_to_json(struct cmd_results *results); +char *cmd_results_to_json(struct cmd_results *results);  struct cmd_results *add_color(const char *name,  		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) {  	free(results);  } -const char *cmd_results_to_json(struct cmd_results *results) { +char *cmd_results_to_json(struct cmd_results *results) {  	json_object *result_array = json_object_new_array();  	json_object *root = json_object_new_object();  	json_object_object_add(root, "success", @@ -542,9 +542,9 @@ const char *cmd_results_to_json(struct cmd_results *results) {  	}  	json_object_array_add(result_array, root);  	const char *json = json_object_to_json_string(result_array); -	free(result_array); -	free(root); -	return json; +	char *res = strdup(json); +	json_object_put(result_array); +	return res;  }  /** 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) {  	list_free(config->cmd_queue);  	list_free(config->workspace_outputs);  	list_free(config->pid_workspaces); -	list_free(config->output_configs); +	if (config->output_configs) { +		for (int i = 0; i < config->output_configs->length; i++) { +			free_output_config(config->output_configs->items[i]); +		} +		list_free(config->output_configs); +	}  	if (config->input_configs) {  		for (int i = 0; i < config->input_configs->length; i++) {  			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) {  	if (!bar) {  		return;  	} +	free(bar->id);  	free(bar->mode);  	free(bar->position);  	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,  	size_t inner_width = width - TITLEBAR_H_PADDING * 2;  	// Marks -	size_t marks_width = 0; +	size_t marks_ob_width = 0; // output-buffer-local  	if (config->show_marks && marks_texture) {  		struct wlr_box texture_box;  		wlr_texture_get_size(marks_texture, @@ -540,11 +540,23 @@ static void render_titlebar(struct sway_output *output,  		}  		render_texture(output->wlr_output, output_damage, marks_texture,  			&texture_box, matrix, con->alpha); -		marks_width = texture_box.width; +		marks_ob_width = texture_box.width; + +		// Gap between the marks and bottom padding, for when the marks texture +		// height is smaller than the config's font height +		memcpy(&color, colors->background, sizeof(float) * 4); +		premultiply_alpha(color, con->alpha); +		box.x = texture_box.x; +		box.y = texture_box.y + texture_box.height; +		box.width = texture_box.width; +		box.height = config->font_height * output_scale - texture_box.height; +		if (box.height > 0) { +			render_rect(output->wlr_output, output_damage, &box, color); +		}  	}  	// Title text -	size_t title_width = 0; +	size_t title_ob_width = 0; // output-buffer-local  	if (title_texture) {  		struct wlr_box texture_box;  		wlr_texture_get_size(title_texture, @@ -557,12 +569,24 @@ static void render_titlebar(struct sway_output *output,  			WL_OUTPUT_TRANSFORM_NORMAL,  			0.0, output->wlr_output->transform_matrix); -		if (inner_width * output_scale - marks_width < texture_box.width) { -			texture_box.width = inner_width * output_scale - marks_width; +		if (inner_width * output_scale - marks_ob_width < texture_box.width) { +			texture_box.width = inner_width * output_scale - marks_ob_width;  		}  		render_texture(output->wlr_output, output_damage, title_texture,  			&texture_box, matrix, con->alpha); -		title_width = texture_box.width; +		title_ob_width = texture_box.width; + +		// Gap between the title and bottom padding, for when the title texture +		// height is smaller than the config's font height +		memcpy(&color, colors->background, sizeof(float) * 4); +		premultiply_alpha(color, con->alpha); +		box.x = texture_box.x; +		box.y = texture_box.y + texture_box.height; +		box.width = texture_box.width; +		box.height = config->font_height * output_scale - texture_box.height; +		if (box.height > 0) { +			render_rect(output->wlr_output, output_damage, &box, color); +		}  	}  	// Padding above title @@ -580,9 +604,9 @@ static void render_titlebar(struct sway_output *output,  	render_rect(output->wlr_output, output_damage, &box, color);  	// Filler between title and marks -	box.width = inner_width * output_scale - title_width - marks_width; +	box.width = inner_width * output_scale - title_ob_width - marks_ob_width;  	if (box.width > 0) { -		box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_width; +		box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_ob_width;  		box.y = (y + TITLEBAR_V_PADDING) * output_scale;  		box.height = config->font_height * output_scale;  		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) {  	if (view->swayc->instructions->length) {  		transaction_notify_view_ready_by_size(view,  				surface_state->width, surface_state->height); +	} else if (container_is_floating(view->swayc)) { +		view_update_size(view, surface_state->width, surface_state->height);  	} +  	view_damage_from(view);  } 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) {  	if (!keyboard) {  		return;  	} +	if (keyboard->keymap) { +		xkb_keymap_unref(keyboard->keymap); +	}  	wl_list_remove(&keyboard->keyboard_key.link);  	wl_list_remove(&keyboard->keyboard_modifiers.link);  	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) {  	close(ipc_socket);  	unlink(ipc_sockaddr->sun_path); +	while (ipc_client_list->length) { +		struct ipc_client *client = ipc_client_list->items[0]; +		ipc_client_disconnect(client); +	}  	list_free(ipc_client_list);  	if (ipc_sockaddr) { @@ -479,10 +483,10 @@ void ipc_client_handle_command(struct ipc_client *client) {  	case IPC_COMMAND:  	{  		struct cmd_results *results = execute_command(buf, NULL); -		const char *json = cmd_results_to_json(results); -		char reply[256]; -		int length = snprintf(reply, sizeof(reply), "%s", json); -		client_valid = ipc_send_reply(client, reply, (uint32_t)length); +		char *json = cmd_results_to_json(results); +		int length = strlen(json); +		client_valid = ipc_send_reply(client, json, (uint32_t)length); +		free(json);  		free_cmd_results(results);  		goto exit_cleanup;  	} 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 @@  #define _XOPEN_SOURCE 700  #define _POSIX_C_SOURCE 200112L  #include <getopt.h> +#include <pango/pangocairo.h>  #include <signal.h>  #include <stdbool.h>  #include <stdlib.h> @@ -441,5 +442,7 @@ int main(int argc, char **argv) {  		free_config(config);  	} +	pango_cairo_font_map_set_default(NULL); +  	return exit_value;  } 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) {  		return;  	}  	free(cont->name); +	free(cont->formatted_title);  	wlr_texture_destroy(cont->title_focused);  	wlr_texture_destroy(cont->title_focused_inactive);  	wlr_texture_destroy(cont->title_unfocused); @@ -782,7 +783,7 @@ static void update_title_texture(struct sway_container *con,  	double scale = output->sway_output->wlr_output->scale;  	int width = 0; -	int height = config->font_height * scale; +	int height = con->title_height * scale;  	cairo_t *c = cairo_create(NULL);  	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) {  	if (container_is_floating(focus)) {  		focus = focus->parent->parent;  	} -	free(criterias); +	list_free(criterias);  	cont = container_view_create(focus, view);  	view->surface = wlr_surface; @@ -574,6 +574,8 @@ void view_update_position(struct sway_view *view, double lx, double ly) {  	container_damage_whole(view->swayc);  	view->x = lx;  	view->y = ly; +	view->swayc->current.view_x = lx; +	view->swayc->current.view_y = ly;  	if (container_is_floating(view->swayc)) {  		container_set_geometry_from_floating_view(view->swayc);  	} @@ -587,6 +589,8 @@ void view_update_size(struct sway_view *view, int width, int height) {  	container_damage_whole(view->swayc);  	view->width = width;  	view->height = height; +	view->swayc->current.view_width = width; +	view->swayc->current.view_height = height;  	if (container_is_floating(view->swayc)) {  		container_set_geometry_from_floating_view(view->swayc);  	} @@ -919,7 +923,7 @@ static void update_marks_texture(struct sway_view *view,  	double scale = output->sway_output->wlr_output->scale;  	int width = 0; -	int height = config->font_height * scale; +	int height = view->swayc->title_height * scale;  	cairo_t *c = cairo_create(NULL);  	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) {  				free(target);  				target = _target;  				wlr_log(L_DEBUG, "Workspace: Found free name %s", _target); +			} else { +				free(_target);  			}  		}  		free(dup); | 
