mirror of
https://github.com/swaywm/sway.git
synced 2026-05-02 06:46:23 -04:00
Use sway_log functions instead of wlr_log
This commit is contained in:
parent
1185a8cc1f
commit
c7c1cf31f7
79 changed files with 377 additions and 372 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "background-image.h"
|
#include "background-image.h"
|
||||||
#include "cairo.h"
|
#include "cairo.h"
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ enum background_mode parse_background_mode(const char *mode) {
|
||||||
} else if (strcmp(mode, "solid_color") == 0) {
|
} else if (strcmp(mode, "solid_color") == 0) {
|
||||||
return BACKGROUND_MODE_SOLID_COLOR;
|
return BACKGROUND_MODE_SOLID_COLOR;
|
||||||
}
|
}
|
||||||
wlr_log(L_ERROR, "Unsupported background mode: %s", mode);
|
sway_log(L_ERROR, "Unsupported background mode: %s", mode);
|
||||||
return BACKGROUND_MODE_INVALID;
|
return BACKGROUND_MODE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ cairo_surface_t *load_background_image(const char *path) {
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
|
||||||
if (!pixbuf) {
|
if (!pixbuf) {
|
||||||
wlr_log(L_ERROR, "Failed to load background image (%s).",
|
sway_log(L_ERROR, "Failed to load background image (%s).",
|
||||||
err->message);
|
err->message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -38,11 +38,11 @@ cairo_surface_t *load_background_image(const char *path) {
|
||||||
image = cairo_image_surface_create_from_png(path);
|
image = cairo_image_surface_create_from_png(path);
|
||||||
#endif //HAVE_GDK_PIXBUF
|
#endif //HAVE_GDK_PIXBUF
|
||||||
if (!image) {
|
if (!image) {
|
||||||
wlr_log(L_ERROR, "Failed to read background image.");
|
sway_log(L_ERROR, "Failed to read background image.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
|
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "Failed to read background image: %s."
|
sway_log(L_ERROR, "Failed to read background image: %s."
|
||||||
#ifndef HAVE_GDK_PIXBUF
|
#ifndef HAVE_GDK_PIXBUF
|
||||||
"\nSway was compiled without gdk_pixbuf support, so only"
|
"\nSway was compiled without gdk_pixbuf support, so only"
|
||||||
"\nPNG images can be loaded. This is the likely cause."
|
"\nPNG images can be loaded. This is the likely cause."
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ struct ipc_response *ipc_recv_response(int socketfd) {
|
||||||
error_2:
|
error_2:
|
||||||
free(response);
|
free(response);
|
||||||
error_1:
|
error_1:
|
||||||
wlr_log(L_ERROR, "Unable to allocate memory for IPC response");
|
sway_log(L_ERROR, "Unable to allocate memory for IPC response");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
|
||||||
pango_layout_set_markup(layout, buf, -1);
|
pango_layout_set_markup(layout, buf, -1);
|
||||||
free(buf);
|
free(buf);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text,
|
sway_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text,
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
markup = false; // fallback to plain text
|
markup = false; // fallback to plain text
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ char *read_line(FILE *file) {
|
||||||
char *string = malloc(size);
|
char *string = malloc(size);
|
||||||
char lastChar = '\0';
|
char lastChar = '\0';
|
||||||
if (!string) {
|
if (!string) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
|
sway_log(L_ERROR, "Unable to allocate memory for read_line");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
@ -29,7 +29,7 @@ char *read_line(FILE *file) {
|
||||||
char *new_string = realloc(string, size *= 2);
|
char *new_string = realloc(string, size *= 2);
|
||||||
if (!new_string) {
|
if (!new_string) {
|
||||||
free(string);
|
free(string);
|
||||||
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
|
sway_log(L_ERROR, "Unable to allocate memory for read_line");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
string = new_string;
|
string = new_string;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ uint32_t parse_color(const char *color) {
|
||||||
|
|
||||||
int len = strlen(color);
|
int len = strlen(color);
|
||||||
if (len != 6 && len != 8) {
|
if (len != 6 && len != 8) {
|
||||||
wlr_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
|
sway_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
uint32_t res = (uint32_t)strtoul(color, NULL, 16);
|
uint32_t res = (uint32_t)strtoul(color, NULL, 16);
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ static struct cmd_handler seat_handlers[] = {
|
||||||
static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
|
static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
|
||||||
struct cmd_handler d = { .command=line };
|
struct cmd_handler d = { .command=line };
|
||||||
struct cmd_handler *res = NULL;
|
struct cmd_handler *res = NULL;
|
||||||
wlr_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_SEAT);
|
sway_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_SEAT);
|
||||||
|
|
||||||
bool config_loading = config->reading || !config->active;
|
bool config_loading = config->reading || !config->active;
|
||||||
|
|
||||||
|
|
@ -328,10 +328,10 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
|
||||||
cmd = argsep(&cmdlist, ",");
|
cmd = argsep(&cmdlist, ",");
|
||||||
cmd += strspn(cmd, whitespace);
|
cmd += strspn(cmd, whitespace);
|
||||||
if (strcmp(cmd, "") == 0) {
|
if (strcmp(cmd, "") == 0) {
|
||||||
wlr_log(L_INFO, "Ignoring empty command.");
|
sway_log(L_INFO, "Ignoring empty command.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
wlr_log(L_INFO, "Handling command '%s'", cmd);
|
sway_log(L_INFO, "Handling command '%s'", cmd);
|
||||||
//TODO better handling of argv
|
//TODO better handling of argv
|
||||||
int argc;
|
int argc;
|
||||||
char **argv = split_args(cmd, &argc);
|
char **argv = split_args(cmd, &argc);
|
||||||
|
|
@ -416,7 +416,7 @@ struct cmd_results *config_command(char *exec, enum cmd_status block) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_INFO, "handling config command '%s'", exec);
|
sway_log(L_INFO, "handling config command '%s'", exec);
|
||||||
// Endblock
|
// Endblock
|
||||||
if (**argv == '}') {
|
if (**argv == '}') {
|
||||||
results = cmd_results_new(CMD_BLOCK_END, NULL, NULL);
|
results = cmd_results_new(CMD_BLOCK_END, NULL, NULL);
|
||||||
|
|
@ -520,7 +520,7 @@ struct cmd_results *config_commands_command(char *exec) {
|
||||||
}
|
}
|
||||||
policy->context = context;
|
policy->context = context;
|
||||||
|
|
||||||
wlr_log(L_INFO, "Set command policy for %s to %d",
|
sway_log(L_INFO, "Set command policy for %s to %d",
|
||||||
policy->command, policy->context);
|
policy->command, policy->context);
|
||||||
|
|
||||||
results = cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
results = cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
@ -534,7 +534,7 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
|
||||||
const char *input, const char *format, ...) {
|
const char *input, const char *format, ...) {
|
||||||
struct cmd_results *results = malloc(sizeof(struct cmd_results));
|
struct cmd_results *results = malloc(sizeof(struct cmd_results));
|
||||||
if (!results) {
|
if (!results) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate command results");
|
sway_log(L_ERROR, "Unable to allocate command results");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
results->status = status;
|
results->status = status;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
|
||||||
criteria->target = join_args(argv, target_len);
|
criteria->target = join_args(argv, target_len);
|
||||||
|
|
||||||
list_add(config->criteria, criteria);
|
list_add(config->criteria, criteria);
|
||||||
wlr_log(L_DEBUG, "assign: '%s' -> '%s' added", criteria->raw,
|
sway_log(L_DEBUG, "assign: '%s' -> '%s' added", criteria->raw,
|
||||||
criteria->target);
|
criteria->target);
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
@ -52,6 +52,6 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
|
||||||
|
|
||||||
// Set current bar
|
// Set current bar
|
||||||
config->current_bar = bar;
|
config->current_bar = bar;
|
||||||
wlr_log(L_DEBUG, "Configuring bar %s", bar->id);
|
sway_log(L_DEBUG, "Configuring bar %s", bar->id);
|
||||||
return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
|
return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->binding_mode_indicator = true;
|
config->current_bar->binding_mode_indicator = true;
|
||||||
wlr_log(L_DEBUG, "Enabling binding mode indicator on bar: %s",
|
sway_log(L_DEBUG, "Enabling binding mode indicator on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->binding_mode_indicator = false;
|
config->current_bar->binding_mode_indicator = false;
|
||||||
wlr_log(L_DEBUG, "Disabling binding mode indicator on bar: %s",
|
sway_log(L_DEBUG, "Disabling binding mode indicator on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
|
return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) {
|
||||||
char *font = join_args(argv, argc);
|
char *font = join_args(argv, argc);
|
||||||
free(config->current_bar->font);
|
free(config->current_bar->font);
|
||||||
config->current_bar->font = strdup(font);
|
config->current_bar->font = strdup(font);
|
||||||
wlr_log(L_DEBUG, "Settings font '%s' for bar: %s",
|
sway_log(L_DEBUG, "Settings font '%s' for bar: %s",
|
||||||
config->current_bar->font, config->current_bar->id);
|
config->current_bar->font, config->current_bar->id);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_height(int argc, char **argv) {
|
||||||
"Invalid height value: %s", argv[0]);
|
"Invalid height value: %s", argv[0]);
|
||||||
}
|
}
|
||||||
config->current_bar->height = height;
|
config->current_bar->height = height;
|
||||||
wlr_log(L_DEBUG, "Setting bar height to %d on bar: %s",
|
sway_log(L_DEBUG, "Setting bar height to %d on bar: %s",
|
||||||
height, config->current_bar->id);
|
height, config->current_bar->id);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
|
||||||
if (!config->reading) {
|
if (!config->reading) {
|
||||||
ipc_event_barconfig_update(bar);
|
ipc_event_barconfig_update(bar);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s",
|
sway_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s",
|
||||||
bar->hidden_state, bar->id);
|
bar->hidden_state, bar->id);
|
||||||
}
|
}
|
||||||
// free old mode
|
// free old mode
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Renaming bar: '%s' to '%s'", oldname, name);
|
sway_log(L_DEBUG, "Renaming bar: '%s' to '%s'", oldname, name);
|
||||||
|
|
||||||
// free old bar id
|
// free old bar id
|
||||||
free(config->current_bar->id);
|
free(config->current_bar->id);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode
|
||||||
if (!config->reading) {
|
if (!config->reading) {
|
||||||
ipc_event_barconfig_update(bar);
|
ipc_event_barconfig_update(bar);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Setting mode: '%s' for bar: %s", bar->mode, bar->id);
|
sway_log(L_DEBUG, "Setting mode: '%s' for bar: %s", bar->mode, bar->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// free old mode
|
// free old mode
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
free_flat_list(split);
|
free_flat_list(split);
|
||||||
config->current_bar->modifier = mod;
|
config->current_bar->modifier = mod;
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
|
"Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
||||||
|
|
||||||
if (add_output) {
|
if (add_output) {
|
||||||
list_add(outputs, strdup(output));
|
list_add(outputs, strdup(output));
|
||||||
wlr_log(L_DEBUG, "Adding bar: '%s' to output '%s'",
|
sway_log(L_DEBUG, "Adding bar: '%s' to output '%s'",
|
||||||
config->current_bar->id, output);
|
config->current_bar->id, output);
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (strcasecmp("enabled", argv[0]) == 0) {
|
if (strcasecmp("enabled", argv[0]) == 0) {
|
||||||
config->current_bar->pango_markup = true;
|
config->current_bar->pango_markup = true;
|
||||||
wlr_log(L_DEBUG, "Enabling pango markup for bar: %s",
|
sway_log(L_DEBUG, "Enabling pango markup for bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("disabled", argv[0]) == 0) {
|
} else if (strcasecmp("disabled", argv[0]) == 0) {
|
||||||
config->current_bar->pango_markup = false;
|
config->current_bar->pango_markup = false;
|
||||||
wlr_log(L_DEBUG, "Disabling pango markup for bar: %s",
|
sway_log(L_DEBUG, "Disabling pango markup for bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
error = cmd_results_new(CMD_INVALID, "pango_markup",
|
error = cmd_results_new(CMD_INVALID, "pango_markup",
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
||||||
char *valid[] = { "top", "bottom", "left", "right" };
|
char *valid[] = { "top", "bottom", "left", "right" };
|
||||||
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
||||||
if (strcasecmp(valid[i], argv[0]) == 0) {
|
if (strcasecmp(valid[i], argv[0]) == 0) {
|
||||||
wlr_log(L_DEBUG, "Setting bar position '%s' for bar: %s",
|
sway_log(L_DEBUG, "Setting bar position '%s' for bar: %s",
|
||||||
argv[0], config->current_bar->id);
|
argv[0], config->current_bar->id);
|
||||||
config->current_bar->position = strdup(argv[0]);
|
config->current_bar->position = strdup(argv[0]);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
free(config->current_bar->separator_symbol);
|
free(config->current_bar->separator_symbol);
|
||||||
config->current_bar->separator_symbol = strdup(argv[0]);
|
config->current_bar->separator_symbol = strdup(argv[0]);
|
||||||
wlr_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s",
|
sway_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s",
|
||||||
config->current_bar->separator_symbol, config->current_bar->id);
|
config->current_bar->separator_symbol, config->current_bar->id);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
free(config->current_bar->status_command);
|
free(config->current_bar->status_command);
|
||||||
config->current_bar->status_command = join_args(argv, argc);
|
config->current_bar->status_command = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Feeding bar with status command: %s",
|
sway_log(L_DEBUG, "Feeding bar with status command: %s",
|
||||||
config->current_bar->status_command);
|
config->current_bar->status_command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->strip_workspace_numbers = true;
|
config->current_bar->strip_workspace_numbers = true;
|
||||||
wlr_log(L_DEBUG, "Stripping workspace numbers on bar: %s",
|
sway_log(L_DEBUG, "Stripping workspace numbers on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->strip_workspace_numbers = false;
|
config->current_bar->strip_workspace_numbers = false;
|
||||||
wlr_log(L_DEBUG, "Enabling workspace numbers on bar: %s",
|
sway_log(L_DEBUG, "Enabling workspace numbers on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
free(config->current_bar->swaybar_command);
|
free(config->current_bar->swaybar_command);
|
||||||
config->current_bar->swaybar_command = join_args(argv, argc);
|
config->current_bar->swaybar_command = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Using custom swaybar command: %s",
|
sway_log(L_DEBUG, "Using custom swaybar command: %s",
|
||||||
config->current_bar->swaybar_command);
|
config->current_bar->swaybar_command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->workspace_buttons = true;
|
config->current_bar->workspace_buttons = true;
|
||||||
wlr_log(L_DEBUG, "Enabling workspace buttons on bar: %s",
|
sway_log(L_DEBUG, "Enabling workspace buttons on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->workspace_buttons = false;
|
config->current_bar->workspace_buttons = false;
|
||||||
wlr_log(L_DEBUG, "Disabling workspace buttons on bar: %s",
|
sway_log(L_DEBUG, "Disabling workspace buttons on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, "workspace_buttons",
|
return cmd_results_new(CMD_INVALID, "workspace_buttons",
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (strcasecmp("yes", argv[0]) == 0) {
|
if (strcasecmp("yes", argv[0]) == 0) {
|
||||||
config->current_bar->wrap_scroll = true;
|
config->current_bar->wrap_scroll = true;
|
||||||
wlr_log(L_DEBUG, "Enabling wrap scroll on bar: %s",
|
sway_log(L_DEBUG, "Enabling wrap scroll on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else if (strcasecmp("no", argv[0]) == 0) {
|
} else if (strcasecmp("no", argv[0]) == 0) {
|
||||||
config->current_bar->wrap_scroll = false;
|
config->current_bar->wrap_scroll = false;
|
||||||
wlr_log(L_DEBUG, "Disabling wrap scroll on bar: %s",
|
sway_log(L_DEBUG, "Disabling wrap scroll on bar: %s",
|
||||||
config->current_bar->id);
|
config->current_bar->id);
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
||||||
for (int i = 0; i < mode_bindings->length; ++i) {
|
for (int i = 0; i < mode_bindings->length; ++i) {
|
||||||
struct sway_binding *config_binding = mode_bindings->items[i];
|
struct sway_binding *config_binding = mode_bindings->items[i];
|
||||||
if (binding_key_compare(binding, config_binding)) {
|
if (binding_key_compare(binding, config_binding)) {
|
||||||
wlr_log(L_DEBUG, "overwriting old binding with command '%s'",
|
sway_log(L_DEBUG, "overwriting old binding with command '%s'",
|
||||||
config_binding->command);
|
config_binding->command);
|
||||||
free_sway_binding(config_binding);
|
free_sway_binding(config_binding);
|
||||||
mode_bindings->items[i] = binding;
|
mode_bindings->items[i] = binding;
|
||||||
|
|
@ -157,7 +157,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
||||||
list_add(mode_bindings, binding);
|
list_add(mode_bindings, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "bindsym - Bound %s to command %s",
|
sway_log(L_DEBUG, "bindsym - Bound %s to command %s",
|
||||||
argv[0], binding->command);
|
argv[0], binding->command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +227,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
||||||
for (int i = 0; i < mode_bindings->length; ++i) {
|
for (int i = 0; i < mode_bindings->length; ++i) {
|
||||||
struct sway_binding *config_binding = mode_bindings->items[i];
|
struct sway_binding *config_binding = mode_bindings->items[i];
|
||||||
if (binding_key_compare(binding, config_binding)) {
|
if (binding_key_compare(binding, config_binding)) {
|
||||||
wlr_log(L_DEBUG, "overwriting old binding with command '%s'",
|
sway_log(L_DEBUG, "overwriting old binding with command '%s'",
|
||||||
config_binding->command);
|
config_binding->command);
|
||||||
free_sway_binding(config_binding);
|
free_sway_binding(config_binding);
|
||||||
mode_bindings->items[i] = binding;
|
mode_bindings->items[i] = binding;
|
||||||
|
|
@ -239,7 +239,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
||||||
list_add(mode_bindings, binding);
|
list_add(mode_bindings, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "bindcode - Bound %s to command %s",
|
sway_log(L_DEBUG, "bindcode - Bound %s to command %s",
|
||||||
argv[0], binding->command);
|
argv[0], binding->command);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ struct cmd_results *cmd_exec(int argc, char **argv) {
|
||||||
if (!config->active) return cmd_results_new(CMD_DEFER, "exec", NULL);
|
if (!config->active) return cmd_results_new(CMD_DEFER, "exec", NULL);
|
||||||
if (config->reloading) {
|
if (config->reloading) {
|
||||||
char *args = join_args(argv, argc);
|
char *args = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Ignoring 'exec %s' due to reload", args);
|
sway_log(L_DEBUG, "Ignoring 'exec %s' due to reload", args);
|
||||||
free(args);
|
free(args);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
||||||
|
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
if (strcmp((char*)*argv, "--no-startup-id") == 0) {
|
if (strcmp((char*)*argv, "--no-startup-id") == 0) {
|
||||||
wlr_log(L_INFO, "exec switch '--no-startup-id' not supported, ignored.");
|
sway_log(L_INFO, "exec switch '--no-startup-id' not supported, ignored.");
|
||||||
if ((error = checkarg(argc - 1, "exec_always", EXPECTED_MORE_THAN, 0))) {
|
if ((error = checkarg(argc - 1, "exec_always", EXPECTED_MORE_THAN, 0))) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
@ -35,11 +35,11 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
||||||
strncpy(cmd, tmp, sizeof(cmd) - 1);
|
strncpy(cmd, tmp, sizeof(cmd) - 1);
|
||||||
cmd[sizeof(cmd) - 1] = 0;
|
cmd[sizeof(cmd) - 1] = 0;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
wlr_log(L_DEBUG, "Executing %s", cmd);
|
sway_log(L_DEBUG, "Executing %s", cmd);
|
||||||
|
|
||||||
int fd[2];
|
int fd[2];
|
||||||
if (pipe(fd) != 0) {
|
if (pipe(fd) != 0) {
|
||||||
wlr_log(L_ERROR, "Unable to create pipe for fork");
|
sway_log(L_ERROR, "Unable to create pipe for fork");
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
@ -75,7 +75,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
||||||
// cleanup child process
|
// cleanup child process
|
||||||
wait(0);
|
wait(0);
|
||||||
if (*child > 0) {
|
if (*child > 0) {
|
||||||
wlr_log(L_DEBUG, "Child process created with pid %d", *child);
|
sway_log(L_DEBUG, "Child process created with pid %d", *child);
|
||||||
// TODO: add PID to active workspace
|
// TODO: add PID to active workspace
|
||||||
} else {
|
} else {
|
||||||
free(child);
|
free(child);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct cmd_results *cmd_for_window(int argc, char **argv) {
|
||||||
criteria->cmdlist = join_args(argv + 1, argc - 1);
|
criteria->cmdlist = join_args(argv + 1, argc - 1);
|
||||||
|
|
||||||
list_add(config->criteria, criteria);
|
list_add(config->criteria, criteria);
|
||||||
wlr_log(L_DEBUG, "for_window: '%s' -> '%s' added", criteria->raw, criteria->cmdlist);
|
sway_log(L_DEBUG, "for_window: '%s' -> '%s' added", criteria->raw, criteria->cmdlist);
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
||||||
if (!config->handler_context.input_config) {
|
if (!config->handler_context.input_config) {
|
||||||
return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
|
return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "entering input block: %s", argv[0]);
|
sway_log(L_DEBUG, "entering input block: %s", argv[0]);
|
||||||
return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
|
return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, "events",
|
return cmd_results_new(CMD_FAILURE, "events",
|
||||||
"No input device defined.");
|
"No input device defined.");
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "events for device: %s",
|
sway_log(L_DEBUG, "events for device: %s",
|
||||||
current_input_config->identifier);
|
current_input_config->identifier);
|
||||||
struct input_config *new_config =
|
struct input_config *new_config =
|
||||||
new_input_config(current_input_config->identifier);
|
new_input_config(current_input_config->identifier);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
|
||||||
"Expected 'tap <enabled|disabled>'");
|
"Expected 'tap <enabled|disabled>'");
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-tap for device: %s",
|
sway_log(L_DEBUG, "apply-tap for device: %s",
|
||||||
current_input_config->identifier);
|
current_input_config->identifier);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
|
||||||
|
|
||||||
new_config->xkb_layout = strdup(argv[0]);
|
new_config->xkb_layout = strdup(argv[0]);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-xkb_layout for device: %s layout: %s",
|
sway_log(L_DEBUG, "apply-xkb_layout for device: %s layout: %s",
|
||||||
current_input_config->identifier, new_config->xkb_layout);
|
current_input_config->identifier, new_config->xkb_layout);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
|
||||||
|
|
||||||
new_config->xkb_model = strdup(argv[0]);
|
new_config->xkb_model = strdup(argv[0]);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-xkb_model for device: %s model: %s",
|
sway_log(L_DEBUG, "apply-xkb_model for device: %s model: %s",
|
||||||
current_input_config->identifier, new_config->xkb_model);
|
current_input_config->identifier, new_config->xkb_model);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
|
||||||
|
|
||||||
new_config->xkb_options = strdup(argv[0]);
|
new_config->xkb_options = strdup(argv[0]);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-xkb_options for device: %s options: %s",
|
sway_log(L_DEBUG, "apply-xkb_options for device: %s options: %s",
|
||||||
current_input_config->identifier, new_config->xkb_options);
|
current_input_config->identifier, new_config->xkb_options);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
|
||||||
|
|
||||||
new_config->xkb_rules = strdup(argv[0]);
|
new_config->xkb_rules = strdup(argv[0]);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-xkb_rules for device: %s rules: %s",
|
sway_log(L_DEBUG, "apply-xkb_rules for device: %s rules: %s",
|
||||||
current_input_config->identifier, new_config->xkb_rules);
|
current_input_config->identifier, new_config->xkb_rules);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
|
||||||
|
|
||||||
new_config->xkb_variant = strdup(argv[0]);
|
new_config->xkb_variant = strdup(argv[0]);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "apply-xkb_variant for device: %s variant: %s",
|
sway_log(L_DEBUG, "apply-xkb_variant for device: %s variant: %s",
|
||||||
current_input_config->identifier, new_config->xkb_variant);
|
current_input_config->identifier, new_config->xkb_variant);
|
||||||
apply_input_config(new_config);
|
apply_input_config(new_config);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if ((config->reading && new_mode) || (!config->reading && !new_mode)) {
|
if ((config->reading && new_mode) || (!config->reading && !new_mode)) {
|
||||||
wlr_log(L_DEBUG, "Switching to mode `%s'",mode->name);
|
sway_log(L_DEBUG, "Switching to mode `%s'",mode->name);
|
||||||
}
|
}
|
||||||
// Set current mode
|
// Set current mode
|
||||||
config->current_mode = mode;
|
config->current_mode = mode;
|
||||||
|
|
|
||||||
|
|
@ -222,12 +222,12 @@ static struct cmd_results *cmd_output_background(struct output_config *output,
|
||||||
if (src) {
|
if (src) {
|
||||||
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Unable to allocate background source");
|
"Unable to allocate background source");
|
||||||
}
|
}
|
||||||
free(conf);
|
free(conf);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Unable to allocate background source");
|
sway_log(L_ERROR, "Unable to allocate background source");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!src || access(src, F_OK) == -1) {
|
if (!src || access(src, F_OK) == -1) {
|
||||||
|
|
@ -257,7 +257,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
|
|
||||||
struct output_config *output = new_output_config(argv[0]);
|
struct output_config *output = new_output_config(argv[0]);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
wlr_log(L_ERROR, "Failed to allocate output config");
|
sway_log(L_ERROR, "Failed to allocate output config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,7 +305,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
list_add(config->output_configs, output);
|
list_add(config->output_configs, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
||||||
"position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)",
|
"position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)",
|
||||||
output->name, output->enabled, output->width, output->height,
|
output->name, output->enabled, output->width, output->height,
|
||||||
output->refresh_rate, output->x, output->y, output->scale,
|
output->refresh_rate, output->x, output->y, output->scale,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
|
||||||
"Workspace already exists");
|
"Workspace already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name);
|
sway_log(L_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name);
|
||||||
free(workspace->name);
|
free(workspace->name);
|
||||||
workspace->name = new_name;
|
workspace->name = new_name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ static void resize_tiled(int amount, enum resize_axis axis) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"Found the proper parent: %p. It has %d l conts, and %d r conts",
|
"Found the proper parent: %p. It has %d l conts, and %d r conts",
|
||||||
parent->parent, minor_weight, major_weight);
|
parent->parent, minor_weight, major_weight);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ struct cmd_results *cmd_seat(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, NULL,
|
return cmd_results_new(CMD_FAILURE, NULL,
|
||||||
"Couldn't allocate config");
|
"Couldn't allocate config");
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "entering seat block: %s", argv[0]);
|
sway_log(L_DEBUG, "entering seat block: %s", argv[0]);
|
||||||
return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL);
|
return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ struct cmd_results *cmd_set(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[0][0] != '$') {
|
if (argv[0][0] != '$') {
|
||||||
wlr_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]);
|
sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]);
|
||||||
|
|
||||||
size_t size = snprintf(NULL, 0, "$%s", argv[0]);
|
size_t size = snprintf(NULL, 0, "$%s", argv[0]);
|
||||||
tmp = malloc(size + 1);
|
tmp = malloc(size + 1);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ struct cmd_results *cmd_swaybg_command(int argc, char **argv) {
|
||||||
free(config->swaybg_command);
|
free(config->swaybg_command);
|
||||||
}
|
}
|
||||||
config->swaybg_command = join_args(argv, argc);
|
config->swaybg_command = join_args(argv, argc);
|
||||||
wlr_log(L_DEBUG, "Using custom swaybg command: %s",
|
sway_log(L_DEBUG, "Using custom swaybg command: %s",
|
||||||
config->swaybg_command);
|
config->swaybg_command);
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
|
||||||
free(old); // workspaces can only be assigned to a single output
|
free(old); // workspaces can only be assigned to a single output
|
||||||
list_del(config->workspace_outputs, i);
|
list_del(config->workspace_outputs, i);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Assigning workspace %s to output %s", wso->workspace, wso->output);
|
sway_log(L_DEBUG, "Assigning workspace %s to output %s", wso->workspace, wso->output);
|
||||||
list_add(config->workspace_outputs, wso);
|
list_add(config->workspace_outputs, wso);
|
||||||
} else {
|
} else {
|
||||||
if (config->reading || !config->active) {
|
if (config->reading || !config->active) {
|
||||||
|
|
|
||||||
|
|
@ -270,12 +270,12 @@ static char *get_config_path(void) {
|
||||||
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
||||||
char *config_home = malloc(strlen(home) + strlen("/.config") + 1);
|
char *config_home = malloc(strlen(home) + strlen("/.config") + 1);
|
||||||
if (!config_home) {
|
if (!config_home) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate $HOME/.config");
|
sway_log(L_ERROR, "Unable to allocate $HOME/.config");
|
||||||
} else {
|
} else {
|
||||||
strcpy(config_home, home);
|
strcpy(config_home, home);
|
||||||
strcat(config_home, "/.config");
|
strcat(config_home, "/.config");
|
||||||
setenv("XDG_CONFIG_HOME", config_home, 1);
|
setenv("XDG_CONFIG_HOME", config_home, 1);
|
||||||
wlr_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home);
|
sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home);
|
||||||
free(config_home);
|
free(config_home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +301,7 @@ static char *get_config_path(void) {
|
||||||
const char *current_config_path;
|
const char *current_config_path;
|
||||||
|
|
||||||
static bool load_config(const char *path, struct sway_config *config) {
|
static bool load_config(const char *path, struct sway_config *config) {
|
||||||
wlr_log(L_INFO, "Loading config from %s", path);
|
sway_log(L_INFO, "Loading config from %s", path);
|
||||||
current_config_path = path;
|
current_config_path = path;
|
||||||
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
@ -310,13 +310,13 @@ static bool load_config(const char *path, struct sway_config *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
wlr_log(L_ERROR, "Unable to find a config file!");
|
sway_log(L_ERROR, "Unable to find a config file!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *f = fopen(path, "r");
|
FILE *f = fopen(path, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
wlr_log(L_ERROR, "Unable to open %s for reading", path);
|
sway_log(L_ERROR, "Unable to open %s for reading", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ static bool load_config(const char *path, struct sway_config *config) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (!config_load_success) {
|
if (!config_load_success) {
|
||||||
wlr_log(L_ERROR, "Error(s) loading config!");
|
sway_log(L_ERROR, "Error(s) loading config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
current_config_path = NULL;
|
current_config_path = NULL;
|
||||||
|
|
@ -347,7 +347,7 @@ bool load_main_config(const char *file, bool is_active) {
|
||||||
|
|
||||||
config_defaults(config);
|
config_defaults(config);
|
||||||
if (is_active) {
|
if (is_active) {
|
||||||
wlr_log(L_DEBUG, "Performing configuration file reload");
|
sway_log(L_DEBUG, "Performing configuration file reload");
|
||||||
config->reloading = true;
|
config->reloading = true;
|
||||||
config->active = true;
|
config->active = true;
|
||||||
}
|
}
|
||||||
|
|
@ -363,7 +363,7 @@ bool load_main_config(const char *file, bool is_active) {
|
||||||
/*
|
/*
|
||||||
DIR *dir = opendir(SYSCONFDIR "/sway/security.d");
|
DIR *dir = opendir(SYSCONFDIR "/sway/security.d");
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"%s does not exist, sway will have no security configuration"
|
"%s does not exist, sway will have no security configuration"
|
||||||
" and will probably be broken", SYSCONFDIR "/sway/security.d");
|
" and will probably be broken", SYSCONFDIR "/sway/security.d");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -392,7 +392,7 @@ bool load_main_config(const char *file, bool is_active) {
|
||||||
if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 ||
|
if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 ||
|
||||||
(((s.st_mode & 0777) != 0644) &&
|
(((s.st_mode & 0777) != 0644) &&
|
||||||
(s.st_mode & 0777) != 0444)) {
|
(s.st_mode & 0777) != 0444)) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Refusing to load %s - it must be owned by root "
|
"Refusing to load %s - it must be owned by root "
|
||||||
"and mode 644 or 444", _path);
|
"and mode 644 or 444", _path);
|
||||||
success = false;
|
success = false;
|
||||||
|
|
@ -430,7 +430,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
||||||
len = len + strlen(parent_dir) + 2;
|
len = len + strlen(parent_dir) + 2;
|
||||||
full_path = malloc(len * sizeof(char));
|
full_path = malloc(len * sizeof(char));
|
||||||
if (!full_path) {
|
if (!full_path) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Unable to allocate full path to included config");
|
"Unable to allocate full path to included config");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +441,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
||||||
free(full_path);
|
free(full_path);
|
||||||
|
|
||||||
if (real_path == NULL) {
|
if (real_path == NULL) {
|
||||||
wlr_log(L_DEBUG, "%s not found.", path);
|
sway_log(L_DEBUG, "%s not found.", path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,7 +450,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
||||||
for (j = 0; j < config->config_chain->length; ++j) {
|
for (j = 0; j < config->config_chain->length; ++j) {
|
||||||
char *old_path = config->config_chain->items[j];
|
char *old_path = config->config_chain->items[j];
|
||||||
if (strcmp(real_path, old_path) == 0) {
|
if (strcmp(real_path, old_path) == 0) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"%s already included once, won't be included again.",
|
"%s already included once, won't be included again.",
|
||||||
real_path);
|
real_path);
|
||||||
free(real_path);
|
free(real_path);
|
||||||
|
|
@ -504,7 +504,7 @@ bool load_include_configs(const char *path, struct sway_config *config) {
|
||||||
// restore wd
|
// restore wd
|
||||||
if (chdir(wd) < 0) {
|
if (chdir(wd) < 0) {
|
||||||
free(wd);
|
free(wd);
|
||||||
wlr_log(L_ERROR, "failed to restore working directory");
|
sway_log(L_ERROR, "failed to restore working directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -546,13 +546,13 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
switch(res->status) {
|
switch(res->status) {
|
||||||
case CMD_FAILURE:
|
case CMD_FAILURE:
|
||||||
case CMD_INVALID:
|
case CMD_INVALID:
|
||||||
wlr_log(L_ERROR, "Error on line %i '%s': %s (%s)", line_number,
|
sway_log(L_ERROR, "Error on line %i '%s': %s (%s)", line_number,
|
||||||
line, res->error, config->current_config);
|
line, res->error, config->current_config);
|
||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_DEFER:
|
case CMD_DEFER:
|
||||||
wlr_log(L_DEBUG, "Deferring command `%s'", line);
|
sway_log(L_DEBUG, "Deferring command `%s'", line);
|
||||||
list_add(config->cmd_queue, strdup(line));
|
list_add(config->cmd_queue, strdup(line));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -560,7 +560,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_MODE;
|
block = CMD_BLOCK_MODE;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -568,7 +568,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_INPUT;
|
block = CMD_BLOCK_INPUT;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -576,7 +576,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_SEAT;
|
block = CMD_BLOCK_SEAT;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -584,7 +584,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_BAR;
|
block = CMD_BLOCK_BAR;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -592,7 +592,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_BAR) {
|
if (block == CMD_BLOCK_BAR) {
|
||||||
block = CMD_BLOCK_BAR_COLORS;
|
block = CMD_BLOCK_BAR_COLORS;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -600,7 +600,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_COMMANDS;
|
block = CMD_BLOCK_COMMANDS;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -608,7 +608,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_END) {
|
if (block == CMD_BLOCK_END) {
|
||||||
block = CMD_BLOCK_IPC;
|
block = CMD_BLOCK_IPC;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -616,56 +616,56 @@ bool read_config(FILE *file, struct sway_config *config) {
|
||||||
if (block == CMD_BLOCK_IPC) {
|
if (block == CMD_BLOCK_IPC) {
|
||||||
block = CMD_BLOCK_IPC_EVENTS;
|
block = CMD_BLOCK_IPC_EVENTS;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Invalid block '%s'", line);
|
sway_log(L_ERROR, "Invalid block '%s'", line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_END:
|
case CMD_BLOCK_END:
|
||||||
switch(block) {
|
switch(block) {
|
||||||
case CMD_BLOCK_MODE:
|
case CMD_BLOCK_MODE:
|
||||||
wlr_log(L_DEBUG, "End of mode block");
|
sway_log(L_DEBUG, "End of mode block");
|
||||||
config->current_mode = config->modes->items[0];
|
config->current_mode = config->modes->items[0];
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_INPUT:
|
case CMD_BLOCK_INPUT:
|
||||||
wlr_log(L_DEBUG, "End of input block");
|
sway_log(L_DEBUG, "End of input block");
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_SEAT:
|
case CMD_BLOCK_SEAT:
|
||||||
wlr_log(L_DEBUG, "End of seat block");
|
sway_log(L_DEBUG, "End of seat block");
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_BAR:
|
case CMD_BLOCK_BAR:
|
||||||
wlr_log(L_DEBUG, "End of bar block");
|
sway_log(L_DEBUG, "End of bar block");
|
||||||
config->current_bar = NULL;
|
config->current_bar = NULL;
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_BAR_COLORS:
|
case CMD_BLOCK_BAR_COLORS:
|
||||||
wlr_log(L_DEBUG, "End of bar colors block");
|
sway_log(L_DEBUG, "End of bar colors block");
|
||||||
block = CMD_BLOCK_BAR;
|
block = CMD_BLOCK_BAR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_COMMANDS:
|
case CMD_BLOCK_COMMANDS:
|
||||||
wlr_log(L_DEBUG, "End of commands block");
|
sway_log(L_DEBUG, "End of commands block");
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_IPC:
|
case CMD_BLOCK_IPC:
|
||||||
wlr_log(L_DEBUG, "End of IPC block");
|
sway_log(L_DEBUG, "End of IPC block");
|
||||||
block = CMD_BLOCK_END;
|
block = CMD_BLOCK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_IPC_EVENTS:
|
case CMD_BLOCK_IPC_EVENTS:
|
||||||
wlr_log(L_DEBUG, "End of IPC events block");
|
sway_log(L_DEBUG, "End of IPC events block");
|
||||||
block = CMD_BLOCK_IPC;
|
block = CMD_BLOCK_IPC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_BLOCK_END:
|
case CMD_BLOCK_END:
|
||||||
wlr_log(L_ERROR, "Unmatched }");
|
sway_log(L_ERROR, "Unmatched }");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:;
|
default:;
|
||||||
|
|
@ -699,7 +699,7 @@ char *do_var_replacement(char *str) {
|
||||||
int vvlen = strlen(var->value);
|
int vvlen = strlen(var->value);
|
||||||
char *newstr = malloc(strlen(str) - vnlen + vvlen + 1);
|
char *newstr = malloc(strlen(str) - vnlen + vvlen + 1);
|
||||||
if (!newstr) {
|
if (!newstr) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Unable to allocate replacement "
|
"Unable to allocate replacement "
|
||||||
"during variable expansion");
|
"during variable expansion");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static void terminate_swaybar(pid_t pid) {
|
static void terminate_swaybar(pid_t pid) {
|
||||||
wlr_log(L_DEBUG, "Terminating swaybar %d", pid);
|
sway_log(L_DEBUG, "Terminating swaybar %d", pid);
|
||||||
int ret = kill(-pid, SIGTERM);
|
int ret = kill(-pid, SIGTERM);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid);
|
sway_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid);
|
||||||
} else {
|
} else {
|
||||||
int status;
|
int status;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
@ -157,7 +157,7 @@ void invoke_swaybar(struct bar_config *bar) {
|
||||||
// Pipe to communicate errors
|
// Pipe to communicate errors
|
||||||
int filedes[2];
|
int filedes[2];
|
||||||
if (pipe(filedes) == -1) {
|
if (pipe(filedes) == -1) {
|
||||||
wlr_log(L_ERROR, "Pipe setup failed! Cannot fork into bar");
|
sway_log(L_ERROR, "Pipe setup failed! Cannot fork into bar");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,17 +187,17 @@ void invoke_swaybar(struct bar_config *bar) {
|
||||||
execvp(cmd[0], cmd);
|
execvp(cmd[0], cmd);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Spawned swaybar %d", bar->pid);
|
sway_log(L_DEBUG, "Spawned swaybar %d", bar->pid);
|
||||||
close(filedes[0]);
|
close(filedes[0]);
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
if (read(filedes[1], &len, sizeof(int)) == sizeof(int)) {
|
if (read(filedes[1], &len, sizeof(int)) == sizeof(int)) {
|
||||||
char *buf = malloc(len);
|
char *buf = malloc(len);
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
wlr_log(L_ERROR, "Cannot allocate error string");
|
sway_log(L_ERROR, "Cannot allocate error string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (read(filedes[1], buf, len)) {
|
if (read(filedes[1], buf, len)) {
|
||||||
wlr_log(L_ERROR, "%s", buf);
|
sway_log(L_ERROR, "%s", buf);
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +234,7 @@ void load_swaybars() {
|
||||||
if (bar->pid != 0) {
|
if (bar->pid != 0) {
|
||||||
terminate_swaybar(bar->pid);
|
terminate_swaybar(bar->pid);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
|
sway_log(L_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
|
||||||
invoke_swaybar(bar);
|
invoke_swaybar(bar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
struct input_config *new_input_config(const char* identifier) {
|
struct input_config *new_input_config(const char* identifier) {
|
||||||
struct input_config *input = calloc(1, sizeof(struct input_config));
|
struct input_config *input = calloc(1, sizeof(struct input_config));
|
||||||
if (!input) {
|
if (!input) {
|
||||||
wlr_log(L_DEBUG, "Unable to allocate input config");
|
sway_log(L_DEBUG, "Unable to allocate input config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "new_input_config(%s)", identifier);
|
sway_log(L_DEBUG, "new_input_config(%s)", identifier);
|
||||||
if (!(input->identifier = strdup(identifier))) {
|
if (!(input->identifier = strdup(identifier))) {
|
||||||
free(input);
|
free(input);
|
||||||
wlr_log(L_DEBUG, "Unable to allocate input config");
|
sway_log(L_DEBUG, "Unable to allocate input config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
|
||||||
struct input_config *copy_input_config(struct input_config *ic) {
|
struct input_config *copy_input_config(struct input_config *ic) {
|
||||||
struct input_config *copy = calloc(1, sizeof(struct input_config));
|
struct input_config *copy = calloc(1, sizeof(struct input_config));
|
||||||
if (copy == NULL) {
|
if (copy == NULL) {
|
||||||
wlr_log(L_ERROR, "could not allocate input config");
|
sway_log(L_ERROR, "could not allocate input config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
merge_input_config(copy, ic);
|
merge_input_config(copy, ic);
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ static void set_mode(struct wlr_output *output, int width, int height,
|
||||||
float refresh_rate) {
|
float refresh_rate) {
|
||||||
int mhz = (int)(refresh_rate * 1000);
|
int mhz = (int)(refresh_rate * 1000);
|
||||||
if (wl_list_empty(&output->modes)) {
|
if (wl_list_empty(&output->modes)) {
|
||||||
wlr_log(L_DEBUG, "Assigning custom mode to %s", output->name);
|
sway_log(L_DEBUG, "Assigning custom mode to %s", output->name);
|
||||||
wlr_output_set_custom_mode(output, width, height, mhz);
|
wlr_output_set_custom_mode(output, width, height, mhz);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -106,9 +106,9 @@ static void set_mode(struct wlr_output *output, int width, int height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!best) {
|
if (!best) {
|
||||||
wlr_log(L_ERROR, "Configured mode for %s not available", output->name);
|
sway_log(L_ERROR, "Configured mode for %s not available", output->name);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Assigning configured mode to %s", output->name);
|
sway_log(L_DEBUG, "Assigning configured mode to %s", output->name);
|
||||||
wlr_output_set_mode(output, best);
|
wlr_output_set_mode(output, best);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ static void set_mode(struct wlr_output *output, int width, int height,
|
||||||
void terminate_swaybg(pid_t pid) {
|
void terminate_swaybg(pid_t pid) {
|
||||||
int ret = kill(pid, SIGTERM);
|
int ret = kill(pid, SIGTERM);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wlr_log(L_ERROR, "Unable to terminate swaybg [pid: %d]", pid);
|
sway_log(L_ERROR, "Unable to terminate swaybg [pid: %d]", pid);
|
||||||
} else {
|
} else {
|
||||||
int status;
|
int status;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
@ -142,22 +142,22 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oc && oc->width > 0 && oc->height > 0) {
|
if (oc && oc->width > 0 && oc->height > 0) {
|
||||||
wlr_log(L_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width,
|
sway_log(L_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width,
|
||||||
oc->height, oc->refresh_rate);
|
oc->height, oc->refresh_rate);
|
||||||
set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
|
set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
|
||||||
}
|
}
|
||||||
if (oc && oc->scale > 0) {
|
if (oc && oc->scale > 0) {
|
||||||
wlr_log(L_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
|
sway_log(L_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
|
||||||
wlr_output_set_scale(wlr_output, oc->scale);
|
wlr_output_set_scale(wlr_output, oc->scale);
|
||||||
}
|
}
|
||||||
if (oc && oc->transform >= 0) {
|
if (oc && oc->transform >= 0) {
|
||||||
wlr_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
|
sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
|
||||||
wlr_output_set_transform(wlr_output, oc->transform);
|
wlr_output_set_transform(wlr_output, oc->transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find position for it
|
// Find position for it
|
||||||
if (oc && (oc->x != -1 || oc->y != -1)) {
|
if (oc && (oc->x != -1 || oc->y != -1)) {
|
||||||
wlr_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
|
sway_log(L_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
|
||||||
wlr_output_layout_add(output_layout, wlr_output, oc->x, oc->y);
|
wlr_output_layout_add(output_layout, wlr_output, oc->x, oc->y);
|
||||||
} else {
|
} else {
|
||||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||||
|
|
@ -185,7 +185,7 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
|
||||||
terminate_swaybg(output->sway_output->bg_pid);
|
terminate_swaybg(output->sway_output->bg_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Setting background for output %d to %s",
|
sway_log(L_DEBUG, "Setting background for output %d to %s",
|
||||||
output_i, oc->background);
|
output_i, oc->background);
|
||||||
|
|
||||||
size_t len = snprintf(NULL, 0, "%s %d %s %s",
|
size_t len = snprintf(NULL, 0, "%s %d %s %s",
|
||||||
|
|
@ -193,13 +193,13 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
|
||||||
output_i, oc->background, oc->background_option);
|
output_i, oc->background, oc->background_option);
|
||||||
char *command = malloc(len + 1);
|
char *command = malloc(len + 1);
|
||||||
if (!command) {
|
if (!command) {
|
||||||
wlr_log(L_DEBUG, "Unable to allocate swaybg command");
|
sway_log(L_DEBUG, "Unable to allocate swaybg command");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
snprintf(command, len + 1, "%s %d %s %s",
|
snprintf(command, len + 1, "%s %d %s %s",
|
||||||
config->swaybg_command ? config->swaybg_command : "swaybg",
|
config->swaybg_command ? config->swaybg_command : "swaybg",
|
||||||
output_i, oc->background, oc->background_option);
|
output_i, oc->background, oc->background_option);
|
||||||
wlr_log(L_DEBUG, "-> %s", command);
|
sway_log(L_DEBUG, "-> %s", command);
|
||||||
|
|
||||||
char *const cmd[] = { "sh", "-c", command, NULL };
|
char *const cmd[] = { "sh", "-c", command, NULL };
|
||||||
output->sway_output->bg_pid = fork();
|
output->sway_output->bg_pid = fork();
|
||||||
|
|
@ -210,11 +210,11 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
|
||||||
if (oc && oc->dpms_state != DPMS_IGNORE) {
|
if (oc && oc->dpms_state != DPMS_IGNORE) {
|
||||||
switch (oc->dpms_state) {
|
switch (oc->dpms_state) {
|
||||||
case DPMS_ON:
|
case DPMS_ON:
|
||||||
wlr_log(L_DEBUG, "Turning on screen");
|
sway_log(L_DEBUG, "Turning on screen");
|
||||||
wlr_output_enable(wlr_output, true);
|
wlr_output_enable(wlr_output, true);
|
||||||
break;
|
break;
|
||||||
case DPMS_OFF:
|
case DPMS_OFF:
|
||||||
wlr_log(L_DEBUG, "Turning off screen");
|
sway_log(L_DEBUG, "Turning off screen");
|
||||||
wlr_output_enable(wlr_output, false);
|
wlr_output_enable(wlr_output, false);
|
||||||
break;
|
break;
|
||||||
case DPMS_IGNORE:
|
case DPMS_IGNORE:
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
struct seat_config *new_seat_config(const char* name) {
|
struct seat_config *new_seat_config(const char* name) {
|
||||||
struct seat_config *seat = calloc(1, sizeof(struct seat_config));
|
struct seat_config *seat = calloc(1, sizeof(struct seat_config));
|
||||||
if (!seat) {
|
if (!seat) {
|
||||||
wlr_log(L_DEBUG, "Unable to allocate seat config");
|
sway_log(L_DEBUG, "Unable to allocate seat config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "new_seat_config(%s)", name);
|
sway_log(L_DEBUG, "new_seat_config(%s)", name);
|
||||||
seat->name = strdup(name);
|
seat->name = strdup(name);
|
||||||
if (!sway_assert(seat->name, "could not allocate name for seat")) {
|
if (!sway_assert(seat->name, "could not allocate name for seat")) {
|
||||||
free(seat);
|
free(seat);
|
||||||
|
|
@ -34,7 +34,7 @@ struct seat_attachment_config *seat_attachment_config_new() {
|
||||||
struct seat_attachment_config *attachment =
|
struct seat_attachment_config *attachment =
|
||||||
calloc(1, sizeof(struct seat_attachment_config));
|
calloc(1, sizeof(struct seat_attachment_config));
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
wlr_log(L_DEBUG, "cannot allocate attachment config");
|
sway_log(L_DEBUG, "cannot allocate attachment config");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return attachment;
|
return attachment;
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ struct criteria *criteria_parse(char *raw, char **error_arg) {
|
||||||
}
|
}
|
||||||
unescape(value);
|
unescape(value);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Found pair: %s=%s", name, value);
|
sway_log(L_DEBUG, "Found pair: %s=%s", name, value);
|
||||||
if (!parse_token(criteria, name, value)) {
|
if (!parse_token(criteria, name, value)) {
|
||||||
*error_arg = error;
|
*error_arg = error;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ void arrange_layers(struct sway_output *output) {
|
||||||
|
|
||||||
if (memcmp(&usable_area, &output->usable_area,
|
if (memcmp(&usable_area, &output->usable_area,
|
||||||
sizeof(struct wlr_box)) != 0) {
|
sizeof(struct wlr_box)) != 0) {
|
||||||
wlr_log(L_DEBUG, "Usable area changed, rearranging output");
|
sway_log(L_DEBUG, "Usable area changed, rearranging output");
|
||||||
memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
|
memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
|
||||||
arrange_output(output->swayc);
|
arrange_output(output->swayc);
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +262,7 @@ static void unmap(struct sway_layer_surface *sway_layer) {
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct sway_layer_surface *sway_layer =
|
struct sway_layer_surface *sway_layer =
|
||||||
wl_container_of(listener, sway_layer, destroy);
|
wl_container_of(listener, sway_layer, destroy);
|
||||||
wlr_log(L_DEBUG, "Layer surface destroyed (%s)",
|
sway_log(L_DEBUG, "Layer surface destroyed (%s)",
|
||||||
sway_layer->layer_surface->namespace);
|
sway_layer->layer_surface->namespace);
|
||||||
if (sway_layer->layer_surface->mapped) {
|
if (sway_layer->layer_surface->mapped) {
|
||||||
unmap(sway_layer);
|
unmap(sway_layer);
|
||||||
|
|
@ -304,7 +304,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_layer_surface *layer_surface = data;
|
struct wlr_layer_surface *layer_surface = data;
|
||||||
struct sway_server *server =
|
struct sway_server *server =
|
||||||
wl_container_of(listener, server, layer_shell_surface);
|
wl_container_of(listener, server, layer_shell_surface);
|
||||||
wlr_log(L_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
|
sway_log(L_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
|
||||||
"size %dx%d margin %d,%d,%d,%d",
|
"size %dx%d margin %d,%d,%d,%d",
|
||||||
layer_surface->namespace, layer_surface->layer, layer_surface->layer,
|
layer_surface->namespace, layer_surface->layer, layer_surface->layer,
|
||||||
layer_surface->client_pending.desired_width,
|
layer_surface->client_pending.desired_width,
|
||||||
|
|
|
||||||
|
|
@ -1106,7 +1106,7 @@ static void handle_scale(struct wl_listener *listener, void *data) {
|
||||||
void handle_new_output(struct wl_listener *listener, void *data) {
|
void handle_new_output(struct wl_listener *listener, void *data) {
|
||||||
struct sway_server *server = wl_container_of(listener, server, new_output);
|
struct sway_server *server = wl_container_of(listener, server, new_output);
|
||||||
struct wlr_output *wlr_output = data;
|
struct wlr_output *wlr_output = data;
|
||||||
wlr_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
||||||
|
|
||||||
struct sway_output *output = calloc(1, sizeof(struct sway_output));
|
struct sway_output *output = calloc(1, sizeof(struct sway_output));
|
||||||
if (!output) {
|
if (!output) {
|
||||||
|
|
|
||||||
|
|
@ -241,11 +241,11 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_xdg_surface *xdg_surface = data;
|
struct wlr_xdg_surface *xdg_surface = data;
|
||||||
|
|
||||||
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
||||||
wlr_log(L_DEBUG, "New xdg_shell popup");
|
sway_log(L_DEBUG, "New xdg_shell popup");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
sway_log(L_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
||||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||||
wlr_xdg_surface_ping(xdg_surface);
|
wlr_xdg_surface_ping(xdg_surface);
|
||||||
wlr_xdg_toplevel_set_maximized(xdg_surface, true);
|
wlr_xdg_toplevel_set_maximized(xdg_surface, true);
|
||||||
|
|
|
||||||
|
|
@ -241,11 +241,11 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_xdg_surface_v6 *xdg_surface = data;
|
struct wlr_xdg_surface_v6 *xdg_surface = data;
|
||||||
|
|
||||||
if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
||||||
wlr_log(L_DEBUG, "New xdg_shell_v6 popup");
|
sway_log(L_DEBUG, "New xdg_shell_v6 popup");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
sway_log(L_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
||||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||||
wlr_xdg_surface_v6_ping(xdg_surface);
|
wlr_xdg_surface_v6_ping(xdg_surface);
|
||||||
wlr_xdg_toplevel_v6_set_maximized(xdg_surface, true);
|
wlr_xdg_toplevel_v6_set_maximized(xdg_surface, true);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
|
||||||
struct sway_xwayland_unmanaged *surface =
|
struct sway_xwayland_unmanaged *surface =
|
||||||
calloc(1, sizeof(struct sway_xwayland_unmanaged));
|
calloc(1, sizeof(struct sway_xwayland_unmanaged));
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
wlr_log(L_ERROR, "Allocation failed");
|
sway_log(L_ERROR, "Allocation failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,12 +341,12 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
if (wlr_xwayland_surface_is_unmanaged(xsurface) ||
|
if (wlr_xwayland_surface_is_unmanaged(xsurface) ||
|
||||||
xsurface->override_redirect) {
|
xsurface->override_redirect) {
|
||||||
wlr_log(L_DEBUG, "New xwayland unmanaged surface");
|
sway_log(L_DEBUG, "New xwayland unmanaged surface");
|
||||||
create_unmanaged(xsurface);
|
create_unmanaged(xsurface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'",
|
sway_log(L_DEBUG, "New xwayland surface title='%s' class='%s'",
|
||||||
xsurface->title, xsurface->class);
|
xsurface->title, xsurface->class);
|
||||||
|
|
||||||
struct sway_xwayland_view *xwayland_view =
|
struct sway_xwayland_view *xwayland_view =
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
||||||
// TODO: check cursor mode
|
// TODO: check cursor mode
|
||||||
if (focused_client == NULL ||
|
if (focused_client == NULL ||
|
||||||
event->seat_client->client != focused_client) {
|
event->seat_client->client != focused_client) {
|
||||||
wlr_log(L_DEBUG, "denying request to set cursor from unfocused client");
|
sway_log(L_DEBUG, "denying request to set cursor from unfocused client");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ static char *get_device_identifier(struct wlr_input_device *device) {
|
||||||
int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1;
|
int len = snprintf(NULL, 0, fmt, vendor, product, name) + 1;
|
||||||
char *identifier = malloc(len);
|
char *identifier = malloc(len);
|
||||||
if (!identifier) {
|
if (!identifier) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate unique input device name");
|
sway_log(L_ERROR, "Unable to allocate unique input device name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,74 +104,74 @@ static void input_manager_libinput_config_pointer(
|
||||||
}
|
}
|
||||||
|
|
||||||
libinput_device = wlr_libinput_get_device_handle(wlr_device);
|
libinput_device = wlr_libinput_get_device_handle(wlr_device);
|
||||||
wlr_log(L_DEBUG, "input_manager_libinput_config_pointer(%s)",
|
sway_log(L_DEBUG, "input_manager_libinput_config_pointer(%s)",
|
||||||
ic->identifier);
|
ic->identifier);
|
||||||
|
|
||||||
if (ic->accel_profile != INT_MIN) {
|
if (ic->accel_profile != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)",
|
||||||
ic->identifier, ic->accel_profile);
|
ic->identifier, ic->accel_profile);
|
||||||
libinput_device_config_accel_set_profile(libinput_device,
|
libinput_device_config_accel_set_profile(libinput_device,
|
||||||
ic->accel_profile);
|
ic->accel_profile);
|
||||||
}
|
}
|
||||||
if (ic->click_method != INT_MIN) {
|
if (ic->click_method != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)",
|
||||||
ic->identifier, ic->click_method);
|
ic->identifier, ic->click_method);
|
||||||
libinput_device_config_click_set_method(libinput_device,
|
libinput_device_config_click_set_method(libinput_device,
|
||||||
ic->click_method);
|
ic->click_method);
|
||||||
}
|
}
|
||||||
if (ic->drag_lock != INT_MIN) {
|
if (ic->drag_lock != INT_MIN) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
|
"libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)",
|
||||||
ic->identifier, ic->click_method);
|
ic->identifier, ic->click_method);
|
||||||
libinput_device_config_tap_set_drag_lock_enabled(libinput_device,
|
libinput_device_config_tap_set_drag_lock_enabled(libinput_device,
|
||||||
ic->drag_lock);
|
ic->drag_lock);
|
||||||
}
|
}
|
||||||
if (ic->dwt != INT_MIN) {
|
if (ic->dwt != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)",
|
||||||
ic->identifier, ic->dwt);
|
ic->identifier, ic->dwt);
|
||||||
libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
|
libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt);
|
||||||
}
|
}
|
||||||
if (ic->left_handed != INT_MIN) {
|
if (ic->left_handed != INT_MIN) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"libinput_config_pointer(%s) left_handed_set_enabled(%d)",
|
"libinput_config_pointer(%s) left_handed_set_enabled(%d)",
|
||||||
ic->identifier, ic->left_handed);
|
ic->identifier, ic->left_handed);
|
||||||
libinput_device_config_left_handed_set(libinput_device,
|
libinput_device_config_left_handed_set(libinput_device,
|
||||||
ic->left_handed);
|
ic->left_handed);
|
||||||
}
|
}
|
||||||
if (ic->middle_emulation != INT_MIN) {
|
if (ic->middle_emulation != INT_MIN) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
|
"libinput_config_pointer(%s) middle_emulation_set_enabled(%d)",
|
||||||
ic->identifier, ic->middle_emulation);
|
ic->identifier, ic->middle_emulation);
|
||||||
libinput_device_config_middle_emulation_set_enabled(libinput_device,
|
libinput_device_config_middle_emulation_set_enabled(libinput_device,
|
||||||
ic->middle_emulation);
|
ic->middle_emulation);
|
||||||
}
|
}
|
||||||
if (ic->natural_scroll != INT_MIN) {
|
if (ic->natural_scroll != INT_MIN) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
|
"libinput_config_pointer(%s) natural_scroll_set_enabled(%d)",
|
||||||
ic->identifier, ic->natural_scroll);
|
ic->identifier, ic->natural_scroll);
|
||||||
libinput_device_config_scroll_set_natural_scroll_enabled(
|
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||||
libinput_device, ic->natural_scroll);
|
libinput_device, ic->natural_scroll);
|
||||||
}
|
}
|
||||||
if (ic->pointer_accel != FLT_MIN) {
|
if (ic->pointer_accel != FLT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)",
|
||||||
ic->identifier, ic->pointer_accel);
|
ic->identifier, ic->pointer_accel);
|
||||||
libinput_device_config_accel_set_speed(libinput_device,
|
libinput_device_config_accel_set_speed(libinput_device,
|
||||||
ic->pointer_accel);
|
ic->pointer_accel);
|
||||||
}
|
}
|
||||||
if (ic->scroll_method != INT_MIN) {
|
if (ic->scroll_method != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)",
|
||||||
ic->identifier, ic->scroll_method);
|
ic->identifier, ic->scroll_method);
|
||||||
libinput_device_config_scroll_set_method(libinput_device,
|
libinput_device_config_scroll_set_method(libinput_device,
|
||||||
ic->scroll_method);
|
ic->scroll_method);
|
||||||
}
|
}
|
||||||
if (ic->send_events != INT_MIN) {
|
if (ic->send_events != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)",
|
||||||
ic->identifier, ic->send_events);
|
ic->identifier, ic->send_events);
|
||||||
libinput_device_config_send_events_set_mode(libinput_device,
|
libinput_device_config_send_events_set_mode(libinput_device,
|
||||||
ic->send_events);
|
ic->send_events);
|
||||||
}
|
}
|
||||||
if (ic->tap != INT_MIN) {
|
if (ic->tap != INT_MIN) {
|
||||||
wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
|
sway_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)",
|
||||||
ic->identifier, ic->tap);
|
ic->identifier, ic->tap);
|
||||||
libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
|
libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +187,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "removing device: '%s'",
|
sway_log(L_DEBUG, "removing device: '%s'",
|
||||||
input_device->identifier);
|
input_device->identifier);
|
||||||
|
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
|
|
@ -217,7 +217,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
|
||||||
input_device->identifier = get_device_identifier(device);
|
input_device->identifier = get_device_identifier(device);
|
||||||
wl_list_insert(&input->devices, &input_device->link);
|
wl_list_insert(&input->devices, &input_device->link);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "adding device: '%s'",
|
sway_log(L_DEBUG, "adding device: '%s'",
|
||||||
input_device->identifier);
|
input_device->identifier);
|
||||||
|
|
||||||
if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
|
||||||
|
|
@ -226,7 +226,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
if (!input_has_seat_configuration(input)) {
|
if (!input_has_seat_configuration(input)) {
|
||||||
wlr_log(L_DEBUG, "no seat configuration, using default seat");
|
sway_log(L_DEBUG, "no seat configuration, using default seat");
|
||||||
seat = input_manager_get_seat(input, default_seat);
|
seat = input_manager_get_seat(input, default_seat);
|
||||||
seat_add_device(seat, input_device);
|
seat_add_device(seat, input_device);
|
||||||
return;
|
return;
|
||||||
|
|
@ -256,7 +256,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!added) {
|
if (!added) {
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"device '%s' is not configured on any seats",
|
"device '%s' is not configured on any seats",
|
||||||
input_device->identifier);
|
input_device->identifier);
|
||||||
}
|
}
|
||||||
|
|
@ -282,7 +282,7 @@ static void handle_inhibit_deactivate(struct wl_listener *listener, void *data)
|
||||||
seat_set_exclusive_client(seat, NULL);
|
seat_set_exclusive_client(seat, NULL);
|
||||||
struct sway_container *previous = seat_get_focus(seat);
|
struct sway_container *previous = seat_get_focus(seat);
|
||||||
if (previous) {
|
if (previous) {
|
||||||
wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
|
sway_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
|
||||||
container_type_to_str(previous->type), previous->name);
|
container_type_to_str(previous->type), previous->name);
|
||||||
// Hack to get seat to re-focus the return value of get_focus
|
// Hack to get seat to re-focus the return value of get_focus
|
||||||
seat_set_focus(seat, previous->parent);
|
seat_set_focus(seat, previous->parent);
|
||||||
|
|
@ -359,7 +359,7 @@ void input_manager_apply_input_config(struct sway_input_manager *input,
|
||||||
|
|
||||||
void input_manager_apply_seat_config(struct sway_input_manager *input,
|
void input_manager_apply_seat_config(struct sway_input_manager *input,
|
||||||
struct seat_config *seat_config) {
|
struct seat_config *seat_config) {
|
||||||
wlr_log(L_DEBUG, "applying new seat config for seat %s",
|
sway_log(L_DEBUG, "applying new seat config for seat %s",
|
||||||
seat_config->name);
|
seat_config->name);
|
||||||
struct sway_seat *seat = input_manager_get_seat(input, seat_config->name);
|
struct sway_seat *seat = input_manager_get_seat(input, seat_config->name);
|
||||||
if (!seat) {
|
if (!seat) {
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,13 @@ static bool binding_matches_key_state(struct sway_binding *binding,
|
||||||
|
|
||||||
static void keyboard_execute_command(struct sway_keyboard *keyboard,
|
static void keyboard_execute_command(struct sway_keyboard *keyboard,
|
||||||
struct sway_binding *binding) {
|
struct sway_binding *binding) {
|
||||||
wlr_log(L_DEBUG, "running command for binding: %s",
|
sway_log(L_DEBUG, "running command for binding: %s",
|
||||||
binding->command);
|
binding->command);
|
||||||
config_clear_handler_context(config);
|
config_clear_handler_context(config);
|
||||||
config->handler_context.seat = keyboard->seat_device->sway_seat;
|
config->handler_context.seat = keyboard->seat_device->sway_seat;
|
||||||
struct cmd_results *results = execute_command(binding->command, NULL);
|
struct cmd_results *results = execute_command(binding->command, NULL);
|
||||||
if (results->status != CMD_SUCCESS) {
|
if (results->status != CMD_SUCCESS) {
|
||||||
wlr_log(L_DEBUG, "could not run command for binding: %s (%s)",
|
sway_log(L_DEBUG, "could not run command for binding: %s (%s)",
|
||||||
binding->command, results->error);
|
binding->command, results->error);
|
||||||
}
|
}
|
||||||
free_cmd_results(results);
|
free_cmd_results(results);
|
||||||
|
|
@ -473,7 +473,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
|
||||||
xkb_keymap_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
xkb_keymap_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
|
||||||
if (!keymap) {
|
if (!keymap) {
|
||||||
wlr_log(L_DEBUG, "cannot configure keyboard: keymap does not exist");
|
sway_log(L_DEBUG, "cannot configure keyboard: keymap does not exist");
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ static void seat_send_activate(struct sway_container *con,
|
||||||
struct sway_seat *seat) {
|
struct sway_seat *seat) {
|
||||||
if (con->type == C_VIEW) {
|
if (con->type == C_VIEW) {
|
||||||
if (!seat_is_input_allowed(seat, con->sway_view->surface)) {
|
if (!seat_is_input_allowed(seat, con->sway_view->surface)) {
|
||||||
wlr_log(L_DEBUG, "Refusing to set focus, input is inhibited");
|
sway_log(L_DEBUG, "Refusing to set focus, input is inhibited");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
view_set_activated(con->sway_view, true);
|
view_set_activated(con->sway_view, true);
|
||||||
|
|
@ -205,7 +205,7 @@ static struct sway_seat_container *seat_container_from_container(
|
||||||
|
|
||||||
seat_con = calloc(1, sizeof(struct sway_seat_container));
|
seat_con = calloc(1, sizeof(struct sway_seat_container));
|
||||||
if (seat_con == NULL) {
|
if (seat_con == NULL) {
|
||||||
wlr_log(L_ERROR, "could not allocate seat container");
|
sway_log(L_ERROR, "could not allocate seat container");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
||||||
struct input_config *ic = input_device_get_config(
|
struct input_config *ic = input_device_get_config(
|
||||||
sway_device->input_device);
|
sway_device->input_device);
|
||||||
if (ic != NULL) {
|
if (ic != NULL) {
|
||||||
wlr_log(L_DEBUG, "Applying input config to %s",
|
sway_log(L_DEBUG, "Applying input config to %s",
|
||||||
sway_device->input_device->identifier);
|
sway_device->input_device->identifier);
|
||||||
|
|
||||||
mapped_to_output = ic->mapped_to_output;
|
mapped_to_output = ic->mapped_to_output;
|
||||||
|
|
@ -300,7 +300,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
||||||
mapped_to_output = sway_device->input_device->wlr_device->output_name;
|
mapped_to_output = sway_device->input_device->wlr_device->output_name;
|
||||||
}
|
}
|
||||||
if (mapped_to_output != NULL) {
|
if (mapped_to_output != NULL) {
|
||||||
wlr_log(L_DEBUG, "Mapping input device %s to output %s",
|
sway_log(L_DEBUG, "Mapping input device %s to output %s",
|
||||||
sway_device->input_device->identifier, mapped_to_output);
|
sway_device->input_device->identifier, mapped_to_output);
|
||||||
struct sway_container *output = NULL;
|
struct sway_container *output = NULL;
|
||||||
for (int i = 0; i < root_container.children->length; ++i) {
|
for (int i = 0; i < root_container.children->length; ++i) {
|
||||||
|
|
@ -314,7 +314,7 @@ static void seat_apply_input_config(struct sway_seat *seat,
|
||||||
wlr_cursor_map_input_to_output(seat->cursor->cursor,
|
wlr_cursor_map_input_to_output(seat->cursor->cursor,
|
||||||
sway_device->input_device->wlr_device,
|
sway_device->input_device->wlr_device,
|
||||||
output->sway_output->wlr_output);
|
output->sway_output->wlr_output);
|
||||||
wlr_log(L_DEBUG, "Mapped to output %s", output->name);
|
sway_log(L_DEBUG, "Mapped to output %s", output->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -394,7 +394,7 @@ void seat_configure_device(struct sway_seat *seat,
|
||||||
seat_configure_tablet_tool(seat, seat_device);
|
seat_configure_tablet_tool(seat, seat_device);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_TABLET_PAD:
|
case WLR_INPUT_DEVICE_TABLET_PAD:
|
||||||
wlr_log(L_DEBUG, "TODO: configure tablet pad");
|
sway_log(L_DEBUG, "TODO: configure tablet pad");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -409,11 +409,11 @@ void seat_add_device(struct sway_seat *seat,
|
||||||
struct sway_seat_device *seat_device =
|
struct sway_seat_device *seat_device =
|
||||||
calloc(1, sizeof(struct sway_seat_device));
|
calloc(1, sizeof(struct sway_seat_device));
|
||||||
if (!seat_device) {
|
if (!seat_device) {
|
||||||
wlr_log(L_DEBUG, "could not allocate seat device");
|
sway_log(L_DEBUG, "could not allocate seat device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "adding device %s to seat %s",
|
sway_log(L_DEBUG, "adding device %s to seat %s",
|
||||||
input_device->identifier, seat->wlr_seat->name);
|
input_device->identifier, seat->wlr_seat->name);
|
||||||
|
|
||||||
seat_device->sway_seat = seat;
|
seat_device->sway_seat = seat;
|
||||||
|
|
@ -432,7 +432,7 @@ void seat_remove_device(struct sway_seat *seat,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "removing device %s from seat %s",
|
sway_log(L_DEBUG, "removing device %s from seat %s",
|
||||||
input_device->identifier, seat->wlr_seat->name);
|
input_device->identifier, seat->wlr_seat->name);
|
||||||
|
|
||||||
seat_device_destroy(seat_device);
|
seat_device_destroy(seat_device);
|
||||||
|
|
@ -652,7 +652,7 @@ void seat_set_focus_layer(struct sway_seat *seat,
|
||||||
seat->focused_layer = NULL;
|
seat->focused_layer = NULL;
|
||||||
struct sway_container *previous = seat_get_focus(seat);
|
struct sway_container *previous = seat_get_focus(seat);
|
||||||
if (previous) {
|
if (previous) {
|
||||||
wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
|
sway_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
|
||||||
container_type_to_str(previous->type), previous->name);
|
container_type_to_str(previous->type), previous->name);
|
||||||
// Hack to get seat to re-focus the return value of get_focus
|
// Hack to get seat to re-focus the return value of get_focus
|
||||||
seat_set_focus(seat, previous->parent);
|
seat_set_focus(seat, previous->parent);
|
||||||
|
|
|
||||||
|
|
@ -127,32 +127,32 @@ struct sockaddr_un *ipc_user_sockaddr(void) {
|
||||||
int ipc_handle_connection(int fd, uint32_t mask, void *data) {
|
int ipc_handle_connection(int fd, uint32_t mask, void *data) {
|
||||||
(void) fd;
|
(void) fd;
|
||||||
struct sway_server *server = data;
|
struct sway_server *server = data;
|
||||||
wlr_log(L_DEBUG, "Event on IPC listening socket");
|
sway_log(L_DEBUG, "Event on IPC listening socket");
|
||||||
assert(mask == WL_EVENT_READABLE);
|
assert(mask == WL_EVENT_READABLE);
|
||||||
|
|
||||||
int client_fd = accept(ipc_socket, NULL, NULL);
|
int client_fd = accept(ipc_socket, NULL, NULL);
|
||||||
if (client_fd == -1) {
|
if (client_fd == -1) {
|
||||||
wlr_log_errno(L_ERROR, "Unable to accept IPC client connection");
|
sway_log_errno(L_ERROR, "Unable to accept IPC client connection");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags;
|
int flags;
|
||||||
if ((flags = fcntl(client_fd, F_GETFD)) == -1
|
if ((flags = fcntl(client_fd, F_GETFD)) == -1
|
||||||
|| fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
|
|| fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
|
||||||
wlr_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket");
|
sway_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((flags = fcntl(client_fd, F_GETFL)) == -1
|
if ((flags = fcntl(client_fd, F_GETFL)) == -1
|
||||||
|| fcntl(client_fd, F_SETFL, flags|O_NONBLOCK) == -1) {
|
|| fcntl(client_fd, F_SETFL, flags|O_NONBLOCK) == -1) {
|
||||||
wlr_log_errno(L_ERROR, "Unable to set NONBLOCK on IPC client socket");
|
sway_log_errno(L_ERROR, "Unable to set NONBLOCK on IPC client socket");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ipc_client *client = malloc(sizeof(struct ipc_client));
|
struct ipc_client *client = malloc(sizeof(struct ipc_client));
|
||||||
if (!client) {
|
if (!client) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate ipc client");
|
sway_log(L_ERROR, "Unable to allocate ipc client");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -168,12 +168,12 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) {
|
||||||
client->write_buffer_len = 0;
|
client->write_buffer_len = 0;
|
||||||
client->write_buffer = malloc(client->write_buffer_size);
|
client->write_buffer = malloc(client->write_buffer_size);
|
||||||
if (!client->write_buffer) {
|
if (!client->write_buffer) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate ipc client write buffer");
|
sway_log(L_ERROR, "Unable to allocate ipc client write buffer");
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "New client: fd %d", client_fd);
|
sway_log(L_DEBUG, "New client: fd %d", client_fd);
|
||||||
list_add(ipc_client_list, client);
|
list_add(ipc_client_list, client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -184,22 +184,22 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
|
||||||
struct ipc_client *client = data;
|
struct ipc_client *client = data;
|
||||||
|
|
||||||
if (mask & WL_EVENT_ERROR) {
|
if (mask & WL_EVENT_ERROR) {
|
||||||
wlr_log(L_ERROR, "IPC Client socket error, removing client");
|
sway_log(L_ERROR, "IPC Client socket error, removing client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WL_EVENT_HANGUP) {
|
if (mask & WL_EVENT_HANGUP) {
|
||||||
wlr_log(L_DEBUG, "Client %d hung up", client->fd);
|
sway_log(L_DEBUG, "Client %d hung up", client->fd);
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Client %d readable", client->fd);
|
sway_log(L_DEBUG, "Client %d readable", client->fd);
|
||||||
|
|
||||||
int read_available;
|
int read_available;
|
||||||
if (ioctl(client_fd, FIONREAD, &read_available) == -1) {
|
if (ioctl(client_fd, FIONREAD, &read_available) == -1) {
|
||||||
wlr_log_errno(L_INFO, "Unable to read IPC socket buffer size");
|
sway_log_errno(L_INFO, "Unable to read IPC socket buffer size");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -221,13 +221,13 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {
|
||||||
// Should be fully available, because read_available >= ipc_header_size
|
// Should be fully available, because read_available >= ipc_header_size
|
||||||
ssize_t received = recv(client_fd, buf, ipc_header_size, 0);
|
ssize_t received = recv(client_fd, buf, ipc_header_size, 0);
|
||||||
if (received == -1) {
|
if (received == -1) {
|
||||||
wlr_log_errno(L_INFO, "Unable to receive header from IPC client");
|
sway_log_errno(L_INFO, "Unable to receive header from IPC client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(buf, ipc_magic, sizeof(ipc_magic)) != 0) {
|
if (memcmp(buf, ipc_magic, sizeof(ipc_magic)) != 0) {
|
||||||
wlr_log(L_DEBUG, "IPC header check failed");
|
sway_log(L_DEBUG, "IPC header check failed");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ static void ipc_send_event(const char *json_string, enum ipc_command_type event)
|
||||||
}
|
}
|
||||||
client->current_command = event;
|
client->current_command = event;
|
||||||
if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) {
|
if (!ipc_send_reply(client, json_string, (uint32_t) strlen(json_string))) {
|
||||||
wlr_log_errno(L_INFO, "Unable to send reply to IPC client");
|
sway_log_errno(L_INFO, "Unable to send reply to IPC client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +272,7 @@ void ipc_event_workspace(struct sway_container *old,
|
||||||
if (!ipc_has_event_listeners(IPC_EVENT_WORKSPACE)) {
|
if (!ipc_has_event_listeners(IPC_EVENT_WORKSPACE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Sending workspace::%s event", change);
|
sway_log(L_DEBUG, "Sending workspace::%s event", change);
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string(change));
|
json_object_object_add(obj, "change", json_object_new_string(change));
|
||||||
if (strcmp("focus", change) == 0) {
|
if (strcmp("focus", change) == 0) {
|
||||||
|
|
@ -300,7 +300,7 @@ void ipc_event_window(struct sway_container *window, const char *change) {
|
||||||
if (!ipc_has_event_listeners(IPC_EVENT_WINDOW)) {
|
if (!ipc_has_event_listeners(IPC_EVENT_WINDOW)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Sending window::%s event", change);
|
sway_log(L_DEBUG, "Sending window::%s event", change);
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string(change));
|
json_object_object_add(obj, "change", json_object_new_string(change));
|
||||||
json_object_object_add(obj, "container", ipc_json_describe_container_recursive(window));
|
json_object_object_add(obj, "container", ipc_json_describe_container_recursive(window));
|
||||||
|
|
@ -314,7 +314,7 @@ void ipc_event_barconfig_update(struct bar_config *bar) {
|
||||||
if (!ipc_has_event_listeners(IPC_EVENT_BARCONFIG_UPDATE)) {
|
if (!ipc_has_event_listeners(IPC_EVENT_BARCONFIG_UPDATE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Sending barconfig_update event");
|
sway_log(L_DEBUG, "Sending barconfig_update event");
|
||||||
json_object *json = ipc_json_describe_bar_config(bar);
|
json_object *json = ipc_json_describe_bar_config(bar);
|
||||||
|
|
||||||
const char *json_string = json_object_to_json_string(json);
|
const char *json_string = json_object_to_json_string(json);
|
||||||
|
|
@ -326,7 +326,7 @@ void ipc_event_mode(const char *mode) {
|
||||||
if (!ipc_has_event_listeners(IPC_EVENT_MODE)) {
|
if (!ipc_has_event_listeners(IPC_EVENT_MODE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Sending mode::%s event", mode);
|
sway_log(L_DEBUG, "Sending mode::%s event", mode);
|
||||||
json_object *obj = json_object_new_object();
|
json_object *obj = json_object_new_object();
|
||||||
json_object_object_add(obj, "change", json_object_new_string(mode));
|
json_object_object_add(obj, "change", json_object_new_string(mode));
|
||||||
|
|
||||||
|
|
@ -339,13 +339,13 @@ int ipc_client_handle_writable(int client_fd, uint32_t mask, void *data) {
|
||||||
struct ipc_client *client = data;
|
struct ipc_client *client = data;
|
||||||
|
|
||||||
if (mask & WL_EVENT_ERROR) {
|
if (mask & WL_EVENT_ERROR) {
|
||||||
wlr_log(L_ERROR, "IPC Client socket error, removing client");
|
sway_log(L_ERROR, "IPC Client socket error, removing client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WL_EVENT_HANGUP) {
|
if (mask & WL_EVENT_HANGUP) {
|
||||||
wlr_log(L_DEBUG, "Client %d hung up", client->fd);
|
sway_log(L_DEBUG, "Client %d hung up", client->fd);
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -354,14 +354,14 @@ int ipc_client_handle_writable(int client_fd, uint32_t mask, void *data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Client %d writable", client->fd);
|
sway_log(L_DEBUG, "Client %d writable", client->fd);
|
||||||
|
|
||||||
ssize_t written = write(client->fd, client->write_buffer, client->write_buffer_len);
|
ssize_t written = write(client->fd, client->write_buffer, client->write_buffer_len);
|
||||||
|
|
||||||
if (written == -1 && errno == EAGAIN) {
|
if (written == -1 && errno == EAGAIN) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (written == -1) {
|
} else if (written == -1) {
|
||||||
wlr_log_errno(L_INFO, "Unable to send data from queue to IPC client");
|
sway_log_errno(L_INFO, "Unable to send data from queue to IPC client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -386,7 +386,7 @@ void ipc_client_disconnect(struct ipc_client *client) {
|
||||||
shutdown(client->fd, SHUT_RDWR);
|
shutdown(client->fd, SHUT_RDWR);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_INFO, "IPC Client %d disconnected", client->fd);
|
sway_log(L_INFO, "IPC Client %d disconnected", client->fd);
|
||||||
wl_event_source_remove(client->event_source);
|
wl_event_source_remove(client->event_source);
|
||||||
if (client->writable_event_source) {
|
if (client->writable_event_source) {
|
||||||
wl_event_source_remove(client->writable_event_source);
|
wl_event_source_remove(client->writable_event_source);
|
||||||
|
|
@ -447,7 +447,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
|
|
||||||
char *buf = malloc(client->payload_length + 1);
|
char *buf = malloc(client->payload_length + 1);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
wlr_log_errno(L_INFO, "Unable to allocate IPC payload");
|
sway_log_errno(L_INFO, "Unable to allocate IPC payload");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -456,7 +456,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
ssize_t received = recv(client->fd, buf, client->payload_length, 0);
|
ssize_t received = recv(client->fd, buf, client->payload_length, 0);
|
||||||
if (received == -1)
|
if (received == -1)
|
||||||
{
|
{
|
||||||
wlr_log_errno(L_INFO, "Unable to receive payload from IPC client");
|
sway_log_errno(L_INFO, "Unable to receive payload from IPC client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
free(buf);
|
free(buf);
|
||||||
return;
|
return;
|
||||||
|
|
@ -512,7 +512,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
struct json_object *request = json_tokener_parse(buf);
|
struct json_object *request = json_tokener_parse(buf);
|
||||||
if (request == NULL) {
|
if (request == NULL) {
|
||||||
ipc_send_reply(client, "{\"success\": false}", 18);
|
ipc_send_reply(client, "{\"success\": false}", 18);
|
||||||
wlr_log_errno(L_INFO, "Failed to read request");
|
sway_log_errno(L_INFO, "Failed to read request");
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -534,7 +534,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
} else {
|
} else {
|
||||||
ipc_send_reply(client, "{\"success\": false}", 18);
|
ipc_send_reply(client, "{\"success\": false}", 18);
|
||||||
json_object_put(request);
|
json_object_put(request);
|
||||||
wlr_log_errno(L_INFO, "Failed to parse request");
|
sway_log_errno(L_INFO, "Failed to parse request");
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -636,12 +636,12 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wlr_log(L_INFO, "Unknown IPC command type %i", client->current_command);
|
sway_log(L_INFO, "Unknown IPC command type %i", client->current_command);
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc_send_reply(client, error_denied, (uint32_t)strlen(error_denied));
|
ipc_send_reply(client, error_denied, (uint32_t)strlen(error_denied));
|
||||||
wlr_log(L_DEBUG, "Denied IPC client access to %i", client->current_command);
|
sway_log(L_DEBUG, "Denied IPC client access to %i", client->current_command);
|
||||||
|
|
||||||
exit_cleanup:
|
exit_cleanup:
|
||||||
client->payload_length = 0;
|
client->payload_length = 0;
|
||||||
|
|
@ -665,14 +665,14 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client->write_buffer_size > 4e6) { // 4 MB
|
if (client->write_buffer_size > 4e6) { // 4 MB
|
||||||
wlr_log(L_ERROR, "Client write buffer too big, disconnecting client");
|
sway_log(L_ERROR, "Client write buffer too big, disconnecting client");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *new_buffer = realloc(client->write_buffer, client->write_buffer_size);
|
char *new_buffer = realloc(client->write_buffer, client->write_buffer_size);
|
||||||
if (!new_buffer) {
|
if (!new_buffer) {
|
||||||
wlr_log(L_ERROR, "Unable to reallocate ipc client write buffer");
|
sway_log(L_ERROR, "Unable to reallocate ipc client write buffer");
|
||||||
ipc_client_disconnect(client);
|
ipc_client_disconnect(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -689,6 +689,6 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay
|
||||||
ipc_client_handle_writable, client);
|
ipc_client_handle_writable, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Added IPC reply to client %d queue: %s", client->fd, payload);
|
sway_log(L_DEBUG, "Added IPC reply to client %d queue: %s", client->fd, payload);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
52
sway/main.c
52
sway/main.c
|
|
@ -15,7 +15,7 @@
|
||||||
#include <sys/capability.h>
|
#include <sys/capability.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/debug.h"
|
#include "sway/debug.h"
|
||||||
|
|
@ -128,7 +128,7 @@ static void log_env() {
|
||||||
"SWAYSOCK"
|
"SWAYSOCK"
|
||||||
};
|
};
|
||||||
for (size_t i = 0; i < sizeof(log_vars) / sizeof(char *); ++i) {
|
for (size_t i = 0; i < sizeof(log_vars) / sizeof(char *); ++i) {
|
||||||
wlr_log(L_INFO, "%s=%s", log_vars[i], getenv(log_vars[i]));
|
sway_log(L_INFO, "%s=%s", log_vars[i], getenv(log_vars[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,14 +143,14 @@ static void log_distro() {
|
||||||
for (size_t i = 0; i < sizeof(paths) / sizeof(char *); ++i) {
|
for (size_t i = 0; i < sizeof(paths) / sizeof(char *); ++i) {
|
||||||
FILE *f = fopen(paths[i], "r");
|
FILE *f = fopen(paths[i], "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
wlr_log(L_INFO, "Contents of %s:", paths[i]);
|
sway_log(L_INFO, "Contents of %s:", paths[i]);
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
char *line;
|
char *line;
|
||||||
if (!(line = read_line(f))) {
|
if (!(line = read_line(f))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*line) {
|
if (*line) {
|
||||||
wlr_log(L_INFO, "%s", line);
|
sway_log(L_INFO, "%s", line);
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +163,7 @@ static void log_kernel() {
|
||||||
return;
|
return;
|
||||||
FILE *f = popen("uname -a", "r");
|
FILE *f = popen("uname -a", "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
wlr_log(L_INFO, "Unable to determine kernel version");
|
sway_log(L_INFO, "Unable to determine kernel version");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
|
|
@ -172,7 +172,7 @@ static void log_kernel() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*line) {
|
if (*line) {
|
||||||
wlr_log(L_INFO, "%s", line);
|
sway_log(L_INFO, "%s", line);
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
@ -183,14 +183,14 @@ static void security_sanity_check() {
|
||||||
// TODO: Notify users visually if this has issues
|
// TODO: Notify users visually if this has issues
|
||||||
struct stat s;
|
struct stat s;
|
||||||
if (stat("/proc", &s)) {
|
if (stat("/proc", &s)) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"!! DANGER !! /proc is not available - sway CANNOT enforce security rules!");
|
"!! DANGER !! /proc is not available - sway CANNOT enforce security rules!");
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
cap_flag_value_t v;
|
cap_flag_value_t v;
|
||||||
cap_t cap = cap_get_proc();
|
cap_t cap = cap_get_proc();
|
||||||
if (!cap || cap_get_flag(cap, CAP_SYS_PTRACE, CAP_PERMITTED, &v) != 0 || v != CAP_SET) {
|
if (!cap || cap_get_flag(cap, CAP_SYS_PTRACE, CAP_PERMITTED, &v) != 0 || v != CAP_SET) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"!! DANGER !! Sway does not have CAP_SYS_PTRACE and cannot enforce security rules for processes running as other users.");
|
"!! DANGER !! Sway does not have CAP_SYS_PTRACE and cannot enforce security rules for processes running as other users.");
|
||||||
}
|
}
|
||||||
if (cap) {
|
if (cap) {
|
||||||
|
|
@ -206,13 +206,13 @@ static void executable_sanity_check() {
|
||||||
stat(exe, &sb);
|
stat(exe, &sb);
|
||||||
// We assume that cap_get_file returning NULL implies ENODATA
|
// We assume that cap_get_file returning NULL implies ENODATA
|
||||||
if (sb.st_mode & (S_ISUID|S_ISGID) && cap_get_file(exe)) {
|
if (sb.st_mode & (S_ISUID|S_ISGID) && cap_get_file(exe)) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"sway executable has both the s(g)uid bit AND file caps set.");
|
"sway executable has both the s(g)uid bit AND file caps set.");
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"This is strongly discouraged (and completely broken).");
|
"This is strongly discouraged (and completely broken).");
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Please clear one of them (either the suid bit, or the file caps).");
|
"Please clear one of them (either the suid bit, or the file caps).");
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"If unsure, strip the file caps.");
|
"If unsure, strip the file caps.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
@ -223,16 +223,16 @@ static void executable_sanity_check() {
|
||||||
static void drop_permissions(bool keep_caps) {
|
static void drop_permissions(bool keep_caps) {
|
||||||
if (getuid() != geteuid() || getgid() != getegid()) {
|
if (getuid() != geteuid() || getgid() != getegid()) {
|
||||||
if (setgid(getgid()) != 0) {
|
if (setgid(getgid()) != 0) {
|
||||||
wlr_log(L_ERROR, "Unable to drop root");
|
sway_log(L_ERROR, "Unable to drop root");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (setuid(getuid()) != 0) {
|
if (setuid(getuid()) != 0) {
|
||||||
wlr_log(L_ERROR, "Unable to drop root");
|
sway_log(L_ERROR, "Unable to drop root");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (setuid(0) != -1) {
|
if (setuid(0) != -1) {
|
||||||
wlr_log(L_ERROR, "Root privileges can be restored.");
|
sway_log(L_ERROR, "Root privileges can be restored.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
@ -240,11 +240,11 @@ static void drop_permissions(bool keep_caps) {
|
||||||
// Drop every cap except CAP_SYS_PTRACE
|
// Drop every cap except CAP_SYS_PTRACE
|
||||||
cap_t caps = cap_init();
|
cap_t caps = cap_init();
|
||||||
cap_value_t keep = CAP_SYS_PTRACE;
|
cap_value_t keep = CAP_SYS_PTRACE;
|
||||||
wlr_log(L_INFO, "Dropping extra capabilities");
|
sway_log(L_INFO, "Dropping extra capabilities");
|
||||||
if (cap_set_flag(caps, CAP_PERMITTED, 1, &keep, CAP_SET) ||
|
if (cap_set_flag(caps, CAP_PERMITTED, 1, &keep, CAP_SET) ||
|
||||||
cap_set_flag(caps, CAP_EFFECTIVE, 1, &keep, CAP_SET) ||
|
cap_set_flag(caps, CAP_EFFECTIVE, 1, &keep, CAP_SET) ||
|
||||||
cap_set_proc(caps)) {
|
cap_set_proc(caps)) {
|
||||||
wlr_log(L_ERROR, "Failed to drop extra capabilities");
|
sway_log(L_ERROR, "Failed to drop extra capabilities");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -335,22 +335,22 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// TODO: switch logging over to wlroots?
|
// TODO: switch logging over to wlroots?
|
||||||
if (debug) {
|
if (debug) {
|
||||||
wlr_log_init(L_DEBUG, NULL);
|
sway_log_init(L_DEBUG, NULL);
|
||||||
} else if (verbose || validate) {
|
} else if (verbose || validate) {
|
||||||
wlr_log_init(L_INFO, NULL);
|
sway_log_init(L_INFO, NULL);
|
||||||
} else {
|
} else {
|
||||||
wlr_log_init(L_ERROR, NULL);
|
sway_log_init(L_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc) { // Behave as IPC client
|
if (optind < argc) { // Behave as IPC client
|
||||||
if(optind != 1) {
|
if(optind != 1) {
|
||||||
wlr_log(L_ERROR, "Don't use options with the IPC client");
|
sway_log(L_ERROR, "Don't use options with the IPC client");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
drop_permissions(false);
|
drop_permissions(false);
|
||||||
char *socket_path = getenv("SWAYSOCK");
|
char *socket_path = getenv("SWAYSOCK");
|
||||||
if (!socket_path) {
|
if (!socket_path) {
|
||||||
wlr_log(L_ERROR, "Unable to retrieve socket path");
|
sway_log(L_ERROR, "Unable to retrieve socket path");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
char *command = join_args(argv + optind, argc - optind);
|
char *command = join_args(argv + optind, argc - optind);
|
||||||
|
|
@ -364,7 +364,7 @@ int main(int argc, char **argv) {
|
||||||
if (getuid() != geteuid() || getgid() != getegid()) {
|
if (getuid() != geteuid() || getgid() != getegid()) {
|
||||||
// Retain capabilities after setuid()
|
// Retain capabilities after setuid()
|
||||||
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
|
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
|
||||||
wlr_log(L_ERROR, "Cannot keep caps after setuid()");
|
sway_log(L_ERROR, "Cannot keep caps after setuid()");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
suid = true;
|
suid = true;
|
||||||
|
|
@ -385,7 +385,7 @@ int main(int argc, char **argv) {
|
||||||
// prevent ipc from crashing sway
|
// prevent ipc from crashing sway
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
wlr_log(L_INFO, "Starting sway version " SWAY_VERSION);
|
sway_log(L_INFO, "Starting sway version " SWAY_VERSION);
|
||||||
|
|
||||||
layout_init();
|
layout_init();
|
||||||
|
|
||||||
|
|
@ -417,7 +417,7 @@ int main(int argc, char **argv) {
|
||||||
char *line = config->cmd_queue->items[0];
|
char *line = config->cmd_queue->items[0];
|
||||||
struct cmd_results *res = execute_command(line, NULL);
|
struct cmd_results *res = execute_command(line, NULL);
|
||||||
if (res->status != CMD_SUCCESS) {
|
if (res->status != CMD_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "Error on line '%s': %s", line, res->error);
|
sway_log(L_ERROR, "Error on line '%s': %s", line, res->error);
|
||||||
}
|
}
|
||||||
free_cmd_results(res);
|
free_cmd_results(res);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
@ -428,7 +428,7 @@ int main(int argc, char **argv) {
|
||||||
server_run(&server);
|
server_run(&server);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_INFO, "Shutting down sway");
|
sway_log(L_INFO, "Shutting down sway");
|
||||||
|
|
||||||
server_fini(&server);
|
server_fini(&server);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
#include <wlr/types/wlr_server_decoration.h>
|
#include <wlr/types/wlr_server_decoration.h>
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
#include <wlr/types/wlr_xdg_output.h>
|
#include <wlr/types/wlr_xdg_output.h>
|
||||||
#include <wlr/util/log.h>
|
|
||||||
// TODO WLR: make Xwayland optional
|
// TODO WLR: make Xwayland optional
|
||||||
#include <wlr/xwayland.h>
|
#include <wlr/xwayland.h>
|
||||||
|
#include "log.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/server.h"
|
#include "sway/server.h"
|
||||||
|
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
|
|
||||||
bool server_init(struct sway_server *server) {
|
bool server_init(struct sway_server *server) {
|
||||||
wlr_log(L_DEBUG, "Initializing Wayland server");
|
sway_log(L_DEBUG, "Initializing Wayland server");
|
||||||
|
|
||||||
server->wl_display = wl_display_create();
|
server->wl_display = wl_display_create();
|
||||||
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
||||||
server->backend = wlr_backend_autocreate(server->wl_display);
|
server->backend = wlr_backend_autocreate(server->wl_display);
|
||||||
|
|
||||||
if (!server->backend) {
|
if (!server->backend) {
|
||||||
wlr_log(L_ERROR, "Unable to create backend");
|
sway_log(L_ERROR, "Unable to create backend");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
|
struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
|
||||||
|
|
@ -100,7 +100,7 @@ bool server_init(struct sway_server *server) {
|
||||||
|
|
||||||
server->socket = wl_display_add_socket_auto(server->wl_display);
|
server->socket = wl_display_add_socket_auto(server->wl_display);
|
||||||
if (!server->socket) {
|
if (!server->socket) {
|
||||||
wlr_log(L_ERROR, "Unable to open wayland socket");
|
sway_log(L_ERROR, "Unable to open wayland socket");
|
||||||
wlr_backend_destroy(server->backend);
|
wlr_backend_destroy(server->backend);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -115,11 +115,11 @@ void server_fini(struct sway_server *server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_run(struct sway_server *server) {
|
void server_run(struct sway_server *server) {
|
||||||
wlr_log(L_INFO, "Running compositor on wayland display '%s'",
|
sway_log(L_INFO, "Running compositor on wayland display '%s'",
|
||||||
server->socket);
|
server->socket);
|
||||||
setenv("WAYLAND_DISPLAY", server->socket, true);
|
setenv("WAYLAND_DISPLAY", server->socket, true);
|
||||||
if (!wlr_backend_start(server->backend)) {
|
if (!wlr_backend_start(server->backend)) {
|
||||||
wlr_log(L_ERROR, "Failed to start backend");
|
sway_log(L_ERROR, "Failed to start backend");
|
||||||
wlr_backend_destroy(server->backend);
|
wlr_backend_destroy(server->backend);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ void arrange_output(struct sway_container *output) {
|
||||||
output->y = output_box->y;
|
output->y = output_box->y;
|
||||||
output->width = output_box->width;
|
output->width = output_box->width;
|
||||||
output->height = output_box->height;
|
output->height = output_box->height;
|
||||||
wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
|
sway_log(L_DEBUG, "Arranging output '%s' at %f,%f",
|
||||||
output->name, output->x, output->y);
|
output->name, output->x, output->y);
|
||||||
for (int i = 0; i < output->children->length; ++i) {
|
for (int i = 0; i < output->children->length; ++i) {
|
||||||
struct sway_container *workspace = output->children->items[i];
|
struct sway_container *workspace = output->children->items[i];
|
||||||
|
|
@ -69,13 +69,13 @@ void arrange_workspace(struct sway_container *workspace) {
|
||||||
}
|
}
|
||||||
struct sway_container *output = workspace->parent;
|
struct sway_container *output = workspace->parent;
|
||||||
struct wlr_box *area = &output->sway_output->usable_area;
|
struct wlr_box *area = &output->sway_output->usable_area;
|
||||||
wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
sway_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
||||||
area->width, area->height, area->x, area->y);
|
area->width, area->height, area->x, area->y);
|
||||||
workspace->width = area->width;
|
workspace->width = area->width;
|
||||||
workspace->height = area->height;
|
workspace->height = area->height;
|
||||||
workspace->x = area->x;
|
workspace->x = area->x;
|
||||||
workspace->y = area->y;
|
workspace->y = area->y;
|
||||||
wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
|
sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
|
||||||
workspace->name, workspace->x, workspace->y);
|
workspace->name, workspace->x, workspace->y);
|
||||||
arrange_children_of(workspace);
|
arrange_children_of(workspace);
|
||||||
container_damage_whole(workspace);
|
container_damage_whole(workspace);
|
||||||
|
|
@ -111,12 +111,12 @@ static void apply_horiz_layout(struct sway_container *parent) {
|
||||||
double scale = parent->width / total_width;
|
double scale = parent->width / total_width;
|
||||||
|
|
||||||
// Resize windows
|
// Resize windows
|
||||||
wlr_log(L_DEBUG, "Arranging %p horizontally", parent);
|
sway_log(L_DEBUG, "Arranging %p horizontally", parent);
|
||||||
double child_x = parent->x;
|
double child_x = parent->x;
|
||||||
struct sway_container *child;
|
struct sway_container *child;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
child = parent->children->items[i];
|
child = parent->children->items[i];
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, child->width, scale);
|
child, child->type, child->width, scale);
|
||||||
child->x = child_x;
|
child->x = child_x;
|
||||||
|
|
@ -159,12 +159,12 @@ static void apply_vert_layout(struct sway_container *parent) {
|
||||||
double scale = parent_height / total_height;
|
double scale = parent_height / total_height;
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
wlr_log(L_DEBUG, "Arranging %p vertically", parent);
|
sway_log(L_DEBUG, "Arranging %p vertically", parent);
|
||||||
double child_y = parent->y + parent_offset;
|
double child_y = parent->y + parent_offset;
|
||||||
struct sway_container *child;
|
struct sway_container *child;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
child = parent->children->items[i];
|
child = parent->children->items[i];
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, child->height, scale);
|
child, child->type, child->height, scale);
|
||||||
child->x = parent->x;
|
child->x = parent->x;
|
||||||
|
|
@ -217,7 +217,7 @@ void arrange_children_of(struct sway_container *parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
|
sway_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
|
||||||
parent->name, parent->width, parent->height, parent->x, parent->y);
|
parent->name, parent->width, parent->height, parent->x, parent->y);
|
||||||
|
|
||||||
// Calculate x, y, width and height of children
|
// Calculate x, y, width and height of children
|
||||||
|
|
@ -233,7 +233,7 @@ void arrange_children_of(struct sway_container *parent) {
|
||||||
apply_tabbed_or_stacked_layout(parent);
|
apply_tabbed_or_stacked_layout(parent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wlr_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout);
|
sway_log(L_DEBUG, "TODO: arrange layout type %d", parent->layout);
|
||||||
apply_horiz_layout(parent);
|
apply_horiz_layout(parent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ static list_t *get_bfs_queue() {
|
||||||
if (!bfs_queue) {
|
if (!bfs_queue) {
|
||||||
bfs_queue = create_list();
|
bfs_queue = create_list();
|
||||||
if (!bfs_queue) {
|
if (!bfs_queue) {
|
||||||
wlr_log(L_ERROR, "could not allocate list for bfs queue");
|
sway_log(L_ERROR, "could not allocate list for bfs queue");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +209,7 @@ static struct sway_container *container_output_destroy(
|
||||||
// clear the wlr_output reference to this container
|
// clear the wlr_output reference to this container
|
||||||
output->sway_output->wlr_output->data = NULL;
|
output->sway_output->wlr_output->data = NULL;
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
|
sway_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
|
||||||
_container_destroy(output);
|
_container_destroy(output);
|
||||||
return &root_container;
|
return &root_container;
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +229,7 @@ static struct sway_container *container_workspace_destroy(
|
||||||
struct sway_container *parent = workspace->parent;
|
struct sway_container *parent = workspace->parent;
|
||||||
if (workspace->children->length == 0) {
|
if (workspace->children->length == 0) {
|
||||||
// destroy the WS if there are no children (TODO check for floating)
|
// destroy the WS if there are no children (TODO check for floating)
|
||||||
wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
|
sway_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
|
||||||
ipc_event_workspace(workspace, NULL, "empty");
|
ipc_event_workspace(workspace, NULL, "empty");
|
||||||
} else {
|
} else {
|
||||||
// Move children to a different workspace on this output
|
// Move children to a different workspace on this output
|
||||||
|
|
@ -242,7 +242,7 @@ static struct sway_container *container_workspace_destroy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "moving children to different workspace '%s' -> '%s'",
|
sway_log(L_DEBUG, "moving children to different workspace '%s' -> '%s'",
|
||||||
workspace->name, new_workspace->name);
|
workspace->name, new_workspace->name);
|
||||||
for (int i = 0; i < workspace->children->length; i++) {
|
for (int i = 0; i < workspace->children->length; i++) {
|
||||||
container_move_to(workspace->children->items[i], new_workspace);
|
container_move_to(workspace->children->items[i], new_workspace);
|
||||||
|
|
@ -258,7 +258,7 @@ static struct sway_container *container_workspace_destroy(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void container_root_finish(struct sway_container *con) {
|
static void container_root_finish(struct sway_container *con) {
|
||||||
wlr_log(L_ERROR, "TODO: destroy the root container");
|
sway_log(L_ERROR, "TODO: destroy the root container");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool container_reap_empty(struct sway_container *con) {
|
bool container_reap_empty(struct sway_container *con) {
|
||||||
|
|
@ -269,7 +269,7 @@ bool container_reap_empty(struct sway_container *con) {
|
||||||
break;
|
break;
|
||||||
case C_WORKSPACE:
|
case C_WORKSPACE:
|
||||||
if (!workspace_is_visible(con) && con->children->length == 0) {
|
if (!workspace_is_visible(con) && con->children->length == 0) {
|
||||||
wlr_log(L_DEBUG, "Destroying workspace via reaper");
|
sway_log(L_DEBUG, "Destroying workspace via reaper");
|
||||||
container_workspace_destroy(con);
|
container_workspace_destroy(con);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +346,7 @@ struct sway_container *container_destroy(struct sway_container *con) {
|
||||||
_container_destroy(con);
|
_container_destroy(con);
|
||||||
break;
|
break;
|
||||||
case C_TYPES:
|
case C_TYPES:
|
||||||
wlr_log(L_ERROR, "container_destroy called on an invalid "
|
sway_log(L_ERROR, "container_destroy called on an invalid "
|
||||||
"container");
|
"container");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ struct sway_container *container_view_create(struct sway_container *sibling,
|
||||||
}
|
}
|
||||||
const char *title = view_get_title(sway_view);
|
const char *title = view_get_title(sway_view);
|
||||||
struct sway_container *swayc = container_create(C_VIEW);
|
struct sway_container *swayc = container_create(C_VIEW);
|
||||||
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s",
|
sway_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s",
|
||||||
swayc, title, sibling, sibling ? sibling->type : 0, sibling->name);
|
swayc, title, sibling, sibling ? sibling->type : 0, sibling->name);
|
||||||
// Setup values
|
// Setup values
|
||||||
swayc->sway_view = sway_view;
|
swayc->sway_view = sway_view;
|
||||||
|
|
@ -627,7 +627,7 @@ void container_for_each_descendant_bfs(struct sway_container *con,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue == NULL) {
|
if (queue == NULL) {
|
||||||
wlr_log(L_ERROR, "could not allocate list");
|
sway_log(L_ERROR, "could not allocate list");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ void container_insert_child(struct sway_container *parent,
|
||||||
if (old_parent) {
|
if (old_parent) {
|
||||||
container_remove_child(child);
|
container_remove_child(child);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Inserting id:%zd at index %d", child->id, i);
|
sway_log(L_DEBUG, "Inserting id:%zd at index %d", child->id, i);
|
||||||
list_insert(parent->children, i, child);
|
list_insert(parent->children, i, child);
|
||||||
child->parent = parent;
|
child->parent = parent;
|
||||||
container_handle_fullscreen_reparent(child, old_parent);
|
container_handle_fullscreen_reparent(child, old_parent);
|
||||||
|
|
@ -126,7 +126,7 @@ struct sway_container *container_add_sibling(struct sway_container *fixed,
|
||||||
|
|
||||||
void container_add_child(struct sway_container *parent,
|
void container_add_child(struct sway_container *parent,
|
||||||
struct sway_container *child) {
|
struct sway_container *child) {
|
||||||
wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)",
|
sway_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)",
|
||||||
child, child->type, child->width, child->height,
|
child, child->type, child->width, child->height,
|
||||||
parent, parent->type, parent->width, parent->height);
|
parent, parent->type, parent->width, parent->height);
|
||||||
struct sway_container *old_parent = child->parent;
|
struct sway_container *old_parent = child->parent;
|
||||||
|
|
@ -340,7 +340,7 @@ void container_move(struct sway_container *container,
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = current->parent;
|
parent = current->parent;
|
||||||
wlr_log(L_DEBUG, "Visiting %p %s '%s'", current,
|
sway_log(L_DEBUG, "Visiting %p %s '%s'", current,
|
||||||
container_type_to_str(current->type), current->name);
|
container_type_to_str(current->type), current->name);
|
||||||
|
|
||||||
int index = index_child(current);
|
int index = index_child(current);
|
||||||
|
|
@ -358,12 +358,12 @@ void container_move(struct sway_container *container,
|
||||||
root_container.sway_root->output_layout, wlr_dir,
|
root_container.sway_root->output_layout, wlr_dir,
|
||||||
current->sway_output->wlr_output, ref_lx, ref_ly);
|
current->sway_output->wlr_output, ref_lx, ref_ly);
|
||||||
if (!next) {
|
if (!next) {
|
||||||
wlr_log(L_DEBUG, "Hit edge of output, nowhere else to go");
|
sway_log(L_DEBUG, "Hit edge of output, nowhere else to go");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct sway_output *next_output = next->data;
|
struct sway_output *next_output = next->data;
|
||||||
current = next_output->swayc;
|
current = next_output->swayc;
|
||||||
wlr_log(L_DEBUG, "Selected next output (%s)", current->name);
|
sway_log(L_DEBUG, "Selected next output (%s)", current->name);
|
||||||
// Select workspace and get outta here
|
// Select workspace and get outta here
|
||||||
current = seat_get_focus_inactive(
|
current = seat_get_focus_inactive(
|
||||||
config->handler_context.seat, current);
|
config->handler_context.seat, current);
|
||||||
|
|
@ -376,11 +376,11 @@ void container_move(struct sway_container *container,
|
||||||
case C_WORKSPACE:
|
case C_WORKSPACE:
|
||||||
if (!is_parallel(current->layout, move_dir)) {
|
if (!is_parallel(current->layout, move_dir)) {
|
||||||
if (current->children->length > 2) {
|
if (current->children->length > 2) {
|
||||||
wlr_log(L_DEBUG, "Rejiggering the workspace (%d kiddos)",
|
sway_log(L_DEBUG, "Rejiggering the workspace (%d kiddos)",
|
||||||
current->children->length);
|
current->children->length);
|
||||||
workspace_rejigger(current, container, move_dir);
|
workspace_rejigger(current, container, move_dir);
|
||||||
} else if (current->children->length == 2) {
|
} else if (current->children->length == 2) {
|
||||||
wlr_log(L_DEBUG, "Changing workspace layout");
|
sway_log(L_DEBUG, "Changing workspace layout");
|
||||||
current->layout =
|
current->layout =
|
||||||
move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ?
|
move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ?
|
||||||
L_HORIZ : L_VERT;
|
L_HORIZ : L_VERT;
|
||||||
|
|
@ -389,7 +389,7 @@ void container_move(struct sway_container *container,
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Selecting output");
|
sway_log(L_DEBUG, "Selecting output");
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -399,10 +399,10 @@ void container_move(struct sway_container *container,
|
||||||
if ((index == parent->children->length - 1 && offs > 0)
|
if ((index == parent->children->length - 1 && offs > 0)
|
||||||
|| (index == 0 && offs < 0)) {
|
|| (index == 0 && offs < 0)) {
|
||||||
if (current->parent == container->parent) {
|
if (current->parent == container->parent) {
|
||||||
wlr_log(L_DEBUG, "Hit limit, selecting parent");
|
sway_log(L_DEBUG, "Hit limit, selecting parent");
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Hit limit, "
|
sway_log(L_DEBUG, "Hit limit, "
|
||||||
"promoting descendant to sibling");
|
"promoting descendant to sibling");
|
||||||
// Special case
|
// Special case
|
||||||
struct sway_container *old_parent = container->parent;
|
struct sway_container *old_parent = container->parent;
|
||||||
|
|
@ -415,10 +415,10 @@ void container_move(struct sway_container *container,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sibling = parent->children->items[index + offs];
|
sibling = parent->children->items[index + offs];
|
||||||
wlr_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id);
|
sway_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Moving up to find a parallel container");
|
sway_log(L_DEBUG, "Moving up to find a parallel container");
|
||||||
current = current->parent;
|
current = current->parent;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -437,12 +437,12 @@ void container_move(struct sway_container *container,
|
||||||
switch (sibling->type) {
|
switch (sibling->type) {
|
||||||
case C_VIEW:
|
case C_VIEW:
|
||||||
if (sibling->parent == container->parent) {
|
if (sibling->parent == container->parent) {
|
||||||
wlr_log(L_DEBUG, "Swapping siblings");
|
sway_log(L_DEBUG, "Swapping siblings");
|
||||||
sibling->parent->children->items[index + offs] = container;
|
sibling->parent->children->items[index + offs] = container;
|
||||||
sibling->parent->children->items[index] = sibling;
|
sibling->parent->children->items[index] = sibling;
|
||||||
arrange_children_of(sibling->parent);
|
arrange_children_of(sibling->parent);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Promoting to sibling of cousin");
|
sway_log(L_DEBUG, "Promoting to sibling of cousin");
|
||||||
container_insert_child(sibling->parent, container,
|
container_insert_child(sibling->parent, container,
|
||||||
index_child(sibling) + (offs > 0 ? 0 : 1));
|
index_child(sibling) + (offs > 0 ? 0 : 1));
|
||||||
container->width = container->height = 0;
|
container->width = container->height = 0;
|
||||||
|
|
@ -455,8 +455,8 @@ void container_move(struct sway_container *container,
|
||||||
case C_CONTAINER:
|
case C_CONTAINER:
|
||||||
if (is_parallel(sibling->layout, move_dir)) {
|
if (is_parallel(sibling->layout, move_dir)) {
|
||||||
int limit = container_limit(sibling, invert_movement(move_dir));
|
int limit = container_limit(sibling, invert_movement(move_dir));
|
||||||
wlr_log(L_DEBUG, "limit: %d", limit);
|
sway_log(L_DEBUG, "limit: %d", limit);
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"Reparenting container (parallel) to index %d "
|
"Reparenting container (parallel) to index %d "
|
||||||
"(move dir: %d)", limit, move_dir);
|
"(move dir: %d)", limit, move_dir);
|
||||||
container_insert_child(sibling, container, limit);
|
container_insert_child(sibling, container, limit);
|
||||||
|
|
@ -465,7 +465,7 @@ void container_move(struct sway_container *container,
|
||||||
arrange_children_of(old_parent);
|
arrange_children_of(old_parent);
|
||||||
sibling = NULL;
|
sibling = NULL;
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "Reparenting container (perpendicular)");
|
sway_log(L_DEBUG, "Reparenting container (perpendicular)");
|
||||||
container_remove_child(container);
|
container_remove_child(container);
|
||||||
struct sway_container *focus_inactive = seat_get_focus_inactive(
|
struct sway_container *focus_inactive = seat_get_focus_inactive(
|
||||||
config->handler_context.seat, sibling);
|
config->handler_context.seat, sibling);
|
||||||
|
|
@ -473,15 +473,15 @@ void container_move(struct sway_container *container,
|
||||||
while (focus_inactive->parent != sibling) {
|
while (focus_inactive->parent != sibling) {
|
||||||
focus_inactive = focus_inactive->parent;
|
focus_inactive = focus_inactive->parent;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Focus inactive: id:%zd",
|
sway_log(L_DEBUG, "Focus inactive: id:%zd",
|
||||||
focus_inactive->id);
|
focus_inactive->id);
|
||||||
sibling = focus_inactive;
|
sibling = focus_inactive;
|
||||||
continue;
|
continue;
|
||||||
} else if (sibling->children->length) {
|
} else if (sibling->children->length) {
|
||||||
wlr_log(L_DEBUG, "No focus-inactive, adding arbitrarily");
|
sway_log(L_DEBUG, "No focus-inactive, adding arbitrarily");
|
||||||
container_add_sibling(sibling->children->items[0], container);
|
container_add_sibling(sibling->children->items[0], container);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_DEBUG, "No kiddos, adding container alone");
|
sway_log(L_DEBUG, "No kiddos, adding container alone");
|
||||||
container_add_child(sibling, container);
|
container_add_child(sibling, container);
|
||||||
}
|
}
|
||||||
container->width = container->height = 0;
|
container->width = container->height = 0;
|
||||||
|
|
@ -579,7 +579,7 @@ static struct sway_container *get_swayc_in_output_direction(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws == NULL) {
|
if (ws == NULL) {
|
||||||
wlr_log(L_ERROR, "got an output without a workspace");
|
sway_log(L_ERROR, "got an output without a workspace");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -750,7 +750,7 @@ struct sway_container *container_get_in_direction(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct sway_container *desired_con = parent->children->items[desired];
|
struct sway_container *desired_con = parent->children->items[desired];
|
||||||
wlr_log(L_DEBUG,
|
sway_log(L_DEBUG,
|
||||||
"cont %d-%p dir %i sibling %d: %p", idx,
|
"cont %d-%p dir %i sibling %d: %p", idx,
|
||||||
container, dir, desired, desired_con);
|
container, dir, desired, desired_con);
|
||||||
struct sway_container *next = seat_get_focus_inactive_view(seat, desired_con);
|
struct sway_container *next = seat_get_focus_inactive_view(seat, desired_con);
|
||||||
|
|
@ -814,7 +814,7 @@ struct sway_container *container_split(struct sway_container *child,
|
||||||
|
|
||||||
struct sway_container *cont = container_create(C_CONTAINER);
|
struct sway_container *cont = container_create(C_CONTAINER);
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "creating container %p around %p", cont, child);
|
sway_log(L_DEBUG, "creating container %p around %p", cont, child);
|
||||||
|
|
||||||
cont->prev_layout = L_NONE;
|
cont->prev_layout = L_NONE;
|
||||||
cont->width = child->width;
|
cont->width = child->width;
|
||||||
|
|
@ -855,7 +855,7 @@ struct sway_container *container_split(struct sway_container *child,
|
||||||
void container_recursive_resize(struct sway_container *container,
|
void container_recursive_resize(struct sway_container *container,
|
||||||
double amount, enum resize_edge edge) {
|
double amount, enum resize_edge edge) {
|
||||||
bool layout_match = true;
|
bool layout_match = true;
|
||||||
wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
|
sway_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
|
||||||
if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
|
if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
|
||||||
container->width += amount;
|
container->width += amount;
|
||||||
layout_match = container->layout == L_HORIZ;
|
layout_match = container->layout == L_HORIZ;
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ struct sway_container *output_create(
|
||||||
|
|
||||||
if (strcasecmp(name, cur->name) == 0 ||
|
if (strcasecmp(name, cur->name) == 0 ||
|
||||||
strcasecmp(identifier, cur->name) == 0) {
|
strcasecmp(identifier, cur->name) == 0) {
|
||||||
wlr_log(L_DEBUG, "Matched output config for %s", name);
|
sway_log(L_DEBUG, "Matched output config for %s", name);
|
||||||
oc = cur;
|
oc = cur;
|
||||||
}
|
}
|
||||||
if (strcasecmp("*", cur->name) == 0) {
|
if (strcasecmp("*", cur->name) == 0) {
|
||||||
wlr_log(L_DEBUG, "Matched wildcard output config for %s", name);
|
sway_log(L_DEBUG, "Matched wildcard output config for %s", name);
|
||||||
all = cur;
|
all = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ struct sway_container *output_create(
|
||||||
|
|
||||||
// Create workspace
|
// Create workspace
|
||||||
char *ws_name = workspace_next_name(output->name);
|
char *ws_name = workspace_next_name(output->name);
|
||||||
wlr_log(L_DEBUG, "Creating default workspace %s", ws_name);
|
sway_log(L_DEBUG, "Creating default workspace %s", ws_name);
|
||||||
struct sway_container *ws = workspace_create(output, ws_name);
|
struct sway_container *ws = workspace_create(output, ws_name);
|
||||||
// Set each seat's focus if not already set
|
// Set each seat's focus if not already set
|
||||||
struct sway_seat *seat = NULL;
|
struct sway_seat *seat = NULL;
|
||||||
|
|
|
||||||
|
|
@ -404,17 +404,17 @@ void view_execute_criteria(struct sway_view *view) {
|
||||||
list_t *criterias = criteria_for_view(view, CT_COMMAND);
|
list_t *criterias = criteria_for_view(view, CT_COMMAND);
|
||||||
for (int i = 0; i < criterias->length; i++) {
|
for (int i = 0; i < criterias->length; i++) {
|
||||||
struct criteria *criteria = criterias->items[i];
|
struct criteria *criteria = criterias->items[i];
|
||||||
wlr_log(L_DEBUG, "Checking criteria %s", criteria->raw);
|
sway_log(L_DEBUG, "Checking criteria %s", criteria->raw);
|
||||||
if (view_has_executed_criteria(view, criteria)) {
|
if (view_has_executed_criteria(view, criteria)) {
|
||||||
wlr_log(L_DEBUG, "Criteria already executed");
|
sway_log(L_DEBUG, "Criteria already executed");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "for_window '%s' matches view %p, cmd: '%s'",
|
sway_log(L_DEBUG, "for_window '%s' matches view %p, cmd: '%s'",
|
||||||
criteria->raw, view, criteria->cmdlist);
|
criteria->raw, view, criteria->cmdlist);
|
||||||
list_add(view->executed_criteria, criteria);
|
list_add(view->executed_criteria, criteria);
|
||||||
struct cmd_results *res = execute_command(criteria->cmdlist, NULL);
|
struct cmd_results *res = execute_command(criteria->cmdlist, NULL);
|
||||||
if (res->status != CMD_SUCCESS) {
|
if (res->status != CMD_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
|
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
|
||||||
}
|
}
|
||||||
free_cmd_results(res);
|
free_cmd_results(res);
|
||||||
// view must be focused for commands to affect it,
|
// view must be focused for commands to affect it,
|
||||||
|
|
@ -541,7 +541,7 @@ static void view_subsurface_create(struct sway_view *view,
|
||||||
struct wlr_subsurface *subsurface) {
|
struct wlr_subsurface *subsurface) {
|
||||||
struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));
|
struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
wlr_log(L_ERROR, "Allocation failed");
|
sway_log(L_ERROR, "Allocation failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
view_child_init(child, NULL, view, subsurface->surface);
|
view_child_init(child, NULL, view, subsurface->surface);
|
||||||
|
|
@ -714,7 +714,7 @@ static char *escape_title(char *buffer) {
|
||||||
char *escaped_title = calloc(length + 1, sizeof(char));
|
char *escaped_title = calloc(length + 1, sizeof(char));
|
||||||
int result = escape_markup_text(buffer, escaped_title, length);
|
int result = escape_markup_text(buffer, escaped_title, length);
|
||||||
if (result != length) {
|
if (result != length) {
|
||||||
wlr_log(L_ERROR, "Could not escape title: %s", buffer);
|
sway_log(L_ERROR, "Could not escape title: %s", buffer);
|
||||||
free(escaped_title);
|
free(escaped_title);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ struct sway_container *workspace_create(struct sway_container *output,
|
||||||
output = get_workspace_initial_output(name);
|
output = get_workspace_initial_output(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name);
|
sway_log(L_DEBUG, "Added workspace %s for output %s", name, output->name);
|
||||||
struct sway_container *workspace = container_create(C_WORKSPACE);
|
struct sway_container *workspace = container_create(C_WORKSPACE);
|
||||||
|
|
||||||
workspace->x = output->x;
|
workspace->x = output->x;
|
||||||
|
|
@ -101,7 +101,7 @@ static bool workspace_valid_on_output(const char *output_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
char *workspace_next_name(const char *output_name) {
|
char *workspace_next_name(const char *output_name) {
|
||||||
wlr_log(L_DEBUG, "Workspace: Generating new workspace name for output %s",
|
sway_log(L_DEBUG, "Workspace: Generating new workspace name for output %s",
|
||||||
output_name);
|
output_name);
|
||||||
int l = 1;
|
int l = 1;
|
||||||
// Scan all workspace bindings to find the next available workspace name,
|
// Scan all workspace bindings to find the next available workspace name,
|
||||||
|
|
@ -124,7 +124,7 @@ char *workspace_next_name(const char *output_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("workspace", cmd) == 0 && name) {
|
if (strcmp("workspace", cmd) == 0 && name) {
|
||||||
wlr_log(L_DEBUG, "Got valid workspace command for target: '%s'", name);
|
sway_log(L_DEBUG, "Got valid workspace command for target: '%s'", name);
|
||||||
char *_target = strdup(name);
|
char *_target = strdup(name);
|
||||||
strip_quotes(_target);
|
strip_quotes(_target);
|
||||||
while (isspace(*_target)) {
|
while (isspace(*_target)) {
|
||||||
|
|
@ -154,7 +154,7 @@ char *workspace_next_name(const char *output_name) {
|
||||||
temp[length - 1] = '\0';
|
temp[length - 1] = '\0';
|
||||||
free(_target);
|
free(_target);
|
||||||
_target = temp;
|
_target = temp;
|
||||||
wlr_log(L_DEBUG, "Isolated name from workspace number: '%s'", _target);
|
sway_log(L_DEBUG, "Isolated name from workspace number: '%s'", _target);
|
||||||
|
|
||||||
// Make sure the workspace number doesn't already exist
|
// Make sure the workspace number doesn't already exist
|
||||||
if (workspace_by_number(_target)) {
|
if (workspace_by_number(_target)) {
|
||||||
|
|
@ -183,7 +183,7 @@ char *workspace_next_name(const char *output_name) {
|
||||||
order = binding->order;
|
order = binding->order;
|
||||||
free(target);
|
free(target);
|
||||||
target = _target;
|
target = _target;
|
||||||
wlr_log(L_DEBUG, "Workspace: Found free name %s", _target);
|
sway_log(L_DEBUG, "Workspace: Found free name %s", _target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(dup);
|
free(dup);
|
||||||
|
|
@ -201,7 +201,7 @@ char *workspace_next_name(const char *output_name) {
|
||||||
}
|
}
|
||||||
char *name = malloc(l + 1);
|
char *name = malloc(l + 1);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
wlr_log(L_ERROR, "Could not allocate workspace name");
|
sway_log(L_ERROR, "Could not allocate workspace name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sprintf(name, "%d", ws_num++);
|
sprintf(name, "%d", ws_num++);
|
||||||
|
|
@ -377,7 +377,7 @@ bool workspace_switch(struct sway_container *workspace) {
|
||||||
free(prev_workspace_name);
|
free(prev_workspace_name);
|
||||||
prev_workspace_name = malloc(strlen(active_ws->name) + 1);
|
prev_workspace_name = malloc(strlen(active_ws->name) + 1);
|
||||||
if (!prev_workspace_name) {
|
if (!prev_workspace_name) {
|
||||||
wlr_log(L_ERROR, "Unable to allocate previous workspace name");
|
sway_log(L_ERROR, "Unable to allocate previous workspace name");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
strcpy(prev_workspace_name, active_ws->name);
|
strcpy(prev_workspace_name, active_ws->name);
|
||||||
|
|
@ -385,7 +385,7 @@ bool workspace_switch(struct sway_container *workspace) {
|
||||||
|
|
||||||
// TODO: Deal with sticky containers
|
// TODO: Deal with sticky containers
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Switching to workspace %p:%s",
|
sway_log(L_DEBUG, "Switching to workspace %p:%s",
|
||||||
workspace, workspace->name);
|
workspace, workspace->name);
|
||||||
struct sway_container *next = seat_get_focus_inactive(seat, workspace);
|
struct sway_container *next = seat_get_focus_inactive(seat, workspace);
|
||||||
if (next == NULL) {
|
if (next == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ static void swaybar_output_free(struct swaybar_output *output) {
|
||||||
if (!output) {
|
if (!output) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Removing output %s", output->name);
|
sway_log(L_DEBUG, "Removing output %s", output->name);
|
||||||
zwlr_layer_surface_v1_destroy(output->layer_surface);
|
zwlr_layer_surface_v1_destroy(output->layer_surface);
|
||||||
wl_surface_destroy(output->surface);
|
wl_surface_destroy(output->surface);
|
||||||
wl_output_destroy(output->output);
|
wl_output_destroy(output->output);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "swaybar/config.h"
|
#include "swaybar/config.h"
|
||||||
#include "swaybar/status_line.h"
|
#include "swaybar/status_line.h"
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ static bool i3bar_parse_json(struct status_line *status, const char *text) {
|
||||||
status_error(status, "[failed to parse i3bar json]");
|
status_error(status, "[failed to parse i3bar json]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Got i3bar json: '%s'", text);
|
sway_log(L_DEBUG, "Got i3bar json: '%s'", text);
|
||||||
for (size_t i = 0; i < json_object_array_length(results); ++i) {
|
for (size_t i = 0; i < json_object_array_length(results); ++i) {
|
||||||
json_object *full_text, *short_text, *color, *min_width, *align, *urgent;
|
json_object *full_text, *short_text, *color, *min_width, *align, *urgent;
|
||||||
json_object *name, *instance, *separator, *separator_block_width;
|
json_object *name, *instance, *separator, *separator_block_width;
|
||||||
|
|
@ -193,7 +193,7 @@ bool i3bar_handle_readable(struct status_line *status) {
|
||||||
|
|
||||||
void i3bar_block_send_click(struct status_line *status,
|
void i3bar_block_send_click(struct status_line *status,
|
||||||
struct i3bar_block *block, int x, int y, uint32_t button) {
|
struct i3bar_block *block, int x, int y, uint32_t button) {
|
||||||
wlr_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)");
|
sway_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)");
|
||||||
if (!block->name || !status->i3bar_state.click_events) {
|
if (!block->name || !status->i3bar_state.click_events) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "swaybar/config.h"
|
#include "swaybar/config.h"
|
||||||
#include "swaybar/ipc.h"
|
#include "swaybar/ipc.h"
|
||||||
#include "ipc-client.h"
|
#include "ipc-client.h"
|
||||||
|
|
@ -327,7 +327,7 @@ bool handle_ipc_readable(struct swaybar *bar) {
|
||||||
json_object *result = json_tokener_parse(resp->payload);
|
json_object *result = json_tokener_parse(resp->payload);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
free_ipc_response(resp);
|
free_ipc_response(resp);
|
||||||
wlr_log(L_ERROR, "failed to parse payload as json");
|
sway_log(L_ERROR, "failed to parse payload as json");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
json_object *json_change, *json_pango_markup;
|
json_object *json_change, *json_pango_markup;
|
||||||
|
|
@ -340,7 +340,7 @@ bool handle_ipc_readable(struct swaybar *bar) {
|
||||||
bar->config->mode = strdup(change);
|
bar->config->mode = strdup(change);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "failed to parse response");
|
sway_log(L_ERROR, "failed to parse response");
|
||||||
json_object_put(result);
|
json_object_put(result);
|
||||||
free_ipc_response(resp);
|
free_ipc_response(resp);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "swaybar/bar.h"
|
#include "swaybar/bar.h"
|
||||||
#include "ipc-client.h"
|
#include "ipc-client.h"
|
||||||
|
|
||||||
|
|
@ -75,13 +75,13 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
wlr_log_init(L_DEBUG, NULL);
|
sway_log_init(L_DEBUG, NULL);
|
||||||
} else {
|
} else {
|
||||||
wlr_log_init(L_ERROR, NULL);
|
sway_log_init(L_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bar_id) {
|
if (!bar_id) {
|
||||||
wlr_log(L_ERROR, "No bar_id passed. "
|
sway_log(L_ERROR, "No bar_id passed. "
|
||||||
"Provide --bar_id or let sway start swaybar");
|
"Provide --bar_id or let sway start swaybar");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ int main(int argc, char **argv) {
|
||||||
if (!socket_path) {
|
if (!socket_path) {
|
||||||
socket_path = get_socketpath();
|
socket_path = get_socketpath();
|
||||||
if (!socket_path) {
|
if (!socket_path) {
|
||||||
wlr_log(L_ERROR, "Unable to retrieve socket path");
|
sway_log(L_ERROR, "Unable to retrieve socket path");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "swaybar/config.h"
|
#include "swaybar/config.h"
|
||||||
#include "swaybar/status_line.h"
|
#include "swaybar/status_line.h"
|
||||||
#include "readline.h"
|
#include "readline.h"
|
||||||
|
|
@ -49,14 +49,14 @@ bool status_handle_readable(struct status_line *status) {
|
||||||
json_object *version;
|
json_object *version;
|
||||||
if (json_object_object_get_ex(proto, "version", &version)
|
if (json_object_object_get_ex(proto, "version", &version)
|
||||||
&& json_object_get_int(version) == 1) {
|
&& json_object_get_int(version) == 1) {
|
||||||
wlr_log(L_DEBUG, "Switched to i3bar protocol.");
|
sway_log(L_DEBUG, "Switched to i3bar protocol.");
|
||||||
status->protocol = PROTOCOL_I3BAR;
|
status->protocol = PROTOCOL_I3BAR;
|
||||||
}
|
}
|
||||||
json_object *click_events;
|
json_object *click_events;
|
||||||
if (json_object_object_get_ex(
|
if (json_object_object_get_ex(
|
||||||
proto, "click_events", &click_events)
|
proto, "click_events", &click_events)
|
||||||
&& json_object_get_boolean(click_events)) {
|
&& json_object_get_boolean(click_events)) {
|
||||||
wlr_log(L_DEBUG, "Enabled click events.");
|
sway_log(L_DEBUG, "Enabled click events.");
|
||||||
status->i3bar_state.click_events = true;
|
status->i3bar_state.click_events = true;
|
||||||
const char *events_array = "[\n";
|
const char *events_array = "[\n";
|
||||||
ssize_t len = strlen(events_array);
|
ssize_t len = strlen(events_array);
|
||||||
|
|
@ -91,7 +91,7 @@ struct status_line *status_line_init(char *cmd) {
|
||||||
int pipe_read_fd[2];
|
int pipe_read_fd[2];
|
||||||
int pipe_write_fd[2];
|
int pipe_write_fd[2];
|
||||||
if (pipe(pipe_read_fd) != 0 || pipe(pipe_write_fd) != 0) {
|
if (pipe(pipe_read_fd) != 0 || pipe(pipe_write_fd) != 0) {
|
||||||
wlr_log(L_ERROR, "Unable to create pipes for status_command fork");
|
sway_log(L_ERROR, "Unable to create pipes for status_command fork");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include "background-image.h"
|
#include "background-image.h"
|
||||||
#include "pool-buffer.h"
|
#include "pool-buffer.h"
|
||||||
#include "cairo.h"
|
#include "cairo.h"
|
||||||
|
|
@ -48,7 +48,7 @@ struct swaybg_state {
|
||||||
bool is_valid_color(const char *color) {
|
bool is_valid_color(const char *color) {
|
||||||
int len = strlen(color);
|
int len = strlen(color);
|
||||||
if (len != 7 || color[0] != '#') {
|
if (len != 7 || color[0] != '#') {
|
||||||
wlr_log(L_ERROR, "%s is not a valid color for swaybg. "
|
sway_log(L_ERROR, "%s is not a valid color for swaybg. "
|
||||||
"Color should be specified as #rrggbb (no alpha).", color);
|
"Color should be specified as #rrggbb (no alpha).", color);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -185,10 +185,10 @@ int main(int argc, const char **argv) {
|
||||||
struct swaybg_args args = {0};
|
struct swaybg_args args = {0};
|
||||||
struct swaybg_state state = {0};
|
struct swaybg_state state = {0};
|
||||||
state.args = &args;
|
state.args = &args;
|
||||||
wlr_log_init(L_DEBUG, NULL);
|
sway_log_init(L_DEBUG, NULL);
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
wlr_log(L_ERROR, "Do not run this program manually. "
|
sway_log(L_ERROR, "Do not run this program manually. "
|
||||||
"See man 5 sway and look for output options.");
|
"See man 5 sway and look for output options.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -244,3 +244,8 @@ int main(int argc, const char **argv) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Required by common code */
|
||||||
|
void sway_terminate(int code) {
|
||||||
|
exit(code);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-util.h>
|
#include <wayland-util.h>
|
||||||
#include <wlr/config.h>
|
#include <wlr/config.h>
|
||||||
#include <wlr/util/log.h>
|
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
|
#include "log.h"
|
||||||
#include "idle-client-protocol.h"
|
#include "idle-client-protocol.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
@ -58,14 +58,14 @@ static void cmd_exec(void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char *param = (char *)data;
|
char *param = (char *)data;
|
||||||
wlr_log(L_DEBUG, "Cmd exec %s", param);
|
sway_log(L_DEBUG, "Cmd exec %s", param);
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
char *const cmd[] = { "sh", "-c", param, NULL, };
|
char *const cmd[] = { "sh", "-c", param, NULL, };
|
||||||
execvp(cmd[0], cmd);
|
execvp(cmd[0], cmd);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Spawned process %d", pid);
|
sway_log(L_DEBUG, "Spawned process %d", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SWAY_IDLE_HAS_SYSTEMD) || defined(SWAY_IDLE_HAS_ELOGIND)
|
#if defined(SWAY_IDLE_HAS_SYSTEMD) || defined(SWAY_IDLE_HAS_ELOGIND)
|
||||||
|
|
@ -73,7 +73,7 @@ static int lock_fd = -1;
|
||||||
static int ongoing_fd = -1;
|
static int ongoing_fd = -1;
|
||||||
|
|
||||||
static int release_lock(void *data) {
|
static int release_lock(void *data) {
|
||||||
wlr_log(L_INFO, "Releasing sleep lock %d", ongoing_fd);
|
sway_log(L_INFO, "Releasing sleep lock %d", ongoing_fd);
|
||||||
if (ongoing_fd >= 0) {
|
if (ongoing_fd >= 0) {
|
||||||
close(ongoing_fd);
|
close(ongoing_fd);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ void acquire_sleep_lock() {
|
||||||
int ret = sd_bus_default_system(&bus);
|
int ret = sd_bus_default_system(&bus);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to open D-Bus connection: %s",
|
sway_log(L_ERROR, "Failed to open D-Bus connection: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -99,17 +99,17 @@ void acquire_sleep_lock() {
|
||||||
&error, &msg, "ssss", "sleep", "swayidle",
|
&error, &msg, "ssss", "sleep", "swayidle",
|
||||||
"Setup Up Lock Screen", "delay");
|
"Setup Up Lock Screen", "delay");
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to send Inhibit signal: %s",
|
sway_log(L_ERROR, "Failed to send Inhibit signal: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
} else {
|
} else {
|
||||||
ret = sd_bus_message_read(msg, "h", &lock_fd);
|
ret = sd_bus_message_read(msg, "h", &lock_fd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR,
|
sway_log(L_ERROR,
|
||||||
"Failed to parse D-Bus response for Inhibit: %s",
|
"Failed to parse D-Bus response for Inhibit: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wlr_log(L_INFO, "Got sleep lock: %d", lock_fd);
|
sway_log(L_INFO, "Got sleep lock: %d", lock_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
||||||
|
|
@ -117,10 +117,10 @@ static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
||||||
bool going_down = true;
|
bool going_down = true;
|
||||||
int ret = sd_bus_message_read(msg, "b", &going_down);
|
int ret = sd_bus_message_read(msg, "b", &going_down);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to parse D-Bus response for Inhibit: %s",
|
sway_log(L_ERROR, "Failed to parse D-Bus response for Inhibit: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "PrepareForSleep signal received %d", going_down);
|
sway_log(L_DEBUG, "PrepareForSleep signal received %d", going_down);
|
||||||
if (!going_down) {
|
if (!going_down) {
|
||||||
acquire_sleep_lock();
|
acquire_sleep_lock();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -137,7 +137,7 @@ static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
||||||
wl_event_loop_add_timer(state.event_loop, release_lock, NULL);
|
wl_event_loop_add_timer(state.event_loop, release_lock, NULL);
|
||||||
wl_event_source_timer_update(source, 1000);
|
wl_event_source_timer_update(source, 1000);
|
||||||
}
|
}
|
||||||
wlr_log(L_DEBUG, "Prepare for sleep done");
|
sway_log(L_DEBUG, "Prepare for sleep done");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ void setup_sleep_listener() {
|
||||||
|
|
||||||
int ret = sd_bus_default_system(&bus);
|
int ret = sd_bus_default_system(&bus);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to open D-Bus connection: %s",
|
sway_log(L_ERROR, "Failed to open D-Bus connection: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ void setup_sleep_listener() {
|
||||||
"/org/freedesktop/login1");
|
"/org/freedesktop/login1");
|
||||||
ret = sd_bus_add_match(bus, NULL, str, prepare_for_sleep, NULL);
|
ret = sd_bus_add_match(bus, NULL, str, prepare_for_sleep, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(L_ERROR, "Failed to add D-Bus match: %s", strerror(-ret));
|
sway_log(L_ERROR, "Failed to add D-Bus match: %s", strerror(-ret));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
acquire_sleep_lock();
|
acquire_sleep_lock();
|
||||||
|
|
@ -200,7 +200,7 @@ static const struct wl_registry_listener registry_listener = {
|
||||||
|
|
||||||
static void handle_idle(void *data, struct org_kde_kwin_idle_timeout *timer) {
|
static void handle_idle(void *data, struct org_kde_kwin_idle_timeout *timer) {
|
||||||
struct swayidle_timeout_cmd *cmd = data;
|
struct swayidle_timeout_cmd *cmd = data;
|
||||||
wlr_log(L_DEBUG, "idle state");
|
sway_log(L_DEBUG, "idle state");
|
||||||
if (cmd && cmd->idle_cmd && cmd->idle_cmd->callback) {
|
if (cmd && cmd->idle_cmd && cmd->idle_cmd->callback) {
|
||||||
cmd->idle_cmd->callback(cmd->idle_cmd->param);
|
cmd->idle_cmd->callback(cmd->idle_cmd->param);
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,7 @@ static void handle_idle(void *data, struct org_kde_kwin_idle_timeout *timer) {
|
||||||
|
|
||||||
static void handle_resume(void *data, struct org_kde_kwin_idle_timeout *timer) {
|
static void handle_resume(void *data, struct org_kde_kwin_idle_timeout *timer) {
|
||||||
struct swayidle_timeout_cmd *cmd = data;
|
struct swayidle_timeout_cmd *cmd = data;
|
||||||
wlr_log(L_DEBUG, "active state");
|
sway_log(L_DEBUG, "active state");
|
||||||
if (cmd && cmd->resume_cmd && cmd->resume_cmd->callback) {
|
if (cmd && cmd->resume_cmd && cmd->resume_cmd->callback) {
|
||||||
cmd->resume_cmd->callback(cmd->resume_cmd->param);
|
cmd->resume_cmd->callback(cmd->resume_cmd->param);
|
||||||
}
|
}
|
||||||
|
|
@ -221,12 +221,12 @@ static const struct org_kde_kwin_idle_timeout_listener idle_timer_listener = {
|
||||||
|
|
||||||
struct swayidle_cmd *parse_command(int argc, char **argv) {
|
struct swayidle_cmd *parse_command(int argc, char **argv) {
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
wlr_log(L_ERROR, "Too few parameters for command in parse_command");
|
sway_log(L_ERROR, "Too few parameters for command in parse_command");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct swayidle_cmd *cmd = calloc(1, sizeof(struct swayidle_cmd));
|
struct swayidle_cmd *cmd = calloc(1, sizeof(struct swayidle_cmd));
|
||||||
wlr_log(L_DEBUG, "Command: %s", argv[0]);
|
sway_log(L_DEBUG, "Command: %s", argv[0]);
|
||||||
cmd->callback = cmd_exec;
|
cmd->callback = cmd_exec;
|
||||||
cmd->param = argv[0];
|
cmd->param = argv[0];
|
||||||
return cmd;
|
return cmd;
|
||||||
|
|
@ -234,7 +234,7 @@ struct swayidle_cmd *parse_command(int argc, char **argv) {
|
||||||
|
|
||||||
int parse_timeout(int argc, char **argv) {
|
int parse_timeout(int argc, char **argv) {
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
wlr_log(L_ERROR, "Too few parameters to timeout command. "
|
sway_log(L_ERROR, "Too few parameters to timeout command. "
|
||||||
"Usage: timeout <seconds> <command>");
|
"Usage: timeout <seconds> <command>");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ int parse_timeout(int argc, char **argv) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
int seconds = strtoul(argv[1], &endptr, 10);
|
int seconds = strtoul(argv[1], &endptr, 10);
|
||||||
if (errno != 0 || *endptr != '\0') {
|
if (errno != 0 || *endptr != '\0') {
|
||||||
wlr_log(L_ERROR, "Invalid timeout parameter '%s', it should be a "
|
sway_log(L_ERROR, "Invalid timeout parameter '%s', it should be a "
|
||||||
"numeric value representing seconds", optarg);
|
"numeric value representing seconds", optarg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
@ -250,13 +250,13 @@ int parse_timeout(int argc, char **argv) {
|
||||||
calloc(1, sizeof(struct swayidle_timeout_cmd));
|
calloc(1, sizeof(struct swayidle_timeout_cmd));
|
||||||
cmd->timeout = seconds * 1000;
|
cmd->timeout = seconds * 1000;
|
||||||
|
|
||||||
wlr_log(L_DEBUG, "Register idle timeout at %d ms", cmd->timeout);
|
sway_log(L_DEBUG, "Register idle timeout at %d ms", cmd->timeout);
|
||||||
wlr_log(L_DEBUG, "Setup idle");
|
sway_log(L_DEBUG, "Setup idle");
|
||||||
cmd->idle_cmd = parse_command(argc - 2, &argv[2]);
|
cmd->idle_cmd = parse_command(argc - 2, &argv[2]);
|
||||||
|
|
||||||
int result = 3;
|
int result = 3;
|
||||||
if (argc >= 5 && !strcmp("resume", argv[3])) {
|
if (argc >= 5 && !strcmp("resume", argv[3])) {
|
||||||
wlr_log(L_DEBUG, "Setup resume");
|
sway_log(L_DEBUG, "Setup resume");
|
||||||
cmd->resume_cmd = parse_command(argc - 4, &argv[4]);
|
cmd->resume_cmd = parse_command(argc - 4, &argv[4]);
|
||||||
result = 5;
|
result = 5;
|
||||||
}
|
}
|
||||||
|
|
@ -266,14 +266,14 @@ int parse_timeout(int argc, char **argv) {
|
||||||
|
|
||||||
int parse_sleep(int argc, char **argv) {
|
int parse_sleep(int argc, char **argv) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
wlr_log(L_ERROR, "Too few parameters to before-sleep command. "
|
sway_log(L_ERROR, "Too few parameters to before-sleep command. "
|
||||||
"Usage: before-sleep <command>");
|
"Usage: before-sleep <command>");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_cmd = parse_command(argc - 1, &argv[1]);
|
lock_cmd = parse_command(argc - 1, &argv[1]);
|
||||||
if (lock_cmd) {
|
if (lock_cmd) {
|
||||||
wlr_log(L_DEBUG, "Setup sleep lock: %s", lock_cmd->param);
|
sway_log(L_DEBUG, "Setup sleep lock: %s", lock_cmd->param);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
|
@ -300,10 +300,10 @@ int parse_args(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
wlr_log_init(L_DEBUG, NULL);
|
sway_log_init(L_DEBUG, NULL);
|
||||||
wlr_log(L_DEBUG, "Loglevel debug");
|
sway_log(L_DEBUG, "Loglevel debug");
|
||||||
} else {
|
} else {
|
||||||
wlr_log_init(L_INFO, NULL);
|
sway_log_init(L_INFO, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -312,13 +312,13 @@ int parse_args(int argc, char *argv[]) {
|
||||||
int i = optind;
|
int i = optind;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
if (!strcmp("timeout", argv[i])) {
|
if (!strcmp("timeout", argv[i])) {
|
||||||
wlr_log(L_DEBUG, "Got timeout");
|
sway_log(L_DEBUG, "Got timeout");
|
||||||
i += parse_timeout(argc - i, &argv[i]);
|
i += parse_timeout(argc - i, &argv[i]);
|
||||||
} else if (!strcmp("before-sleep", argv[i])) {
|
} else if (!strcmp("before-sleep", argv[i])) {
|
||||||
wlr_log(L_DEBUG, "Got before-sleep");
|
sway_log(L_DEBUG, "Got before-sleep");
|
||||||
i += parse_sleep(argc - i, &argv[i]);
|
i += parse_sleep(argc - i, &argv[i]);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Unsupported command '%s'", argv[i]);
|
sway_log(L_ERROR, "Unsupported command '%s'", argv[i]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ static int display_event(int fd, uint32_t mask, void *data) {
|
||||||
sway_terminate(0);
|
sway_terminate(0);
|
||||||
}
|
}
|
||||||
if (wl_display_dispatch(state.display) < 0) {
|
if (wl_display_dispatch(state.display) < 0) {
|
||||||
wlr_log_errno(L_ERROR, "wl_display_dispatch failed, exiting");
|
sway_log_errno(L_ERROR, "wl_display_dispatch failed, exiting");
|
||||||
sway_terminate(0);
|
sway_terminate(0);
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -353,7 +353,7 @@ static int display_event(int fd, uint32_t mask, void *data) {
|
||||||
void register_idle_timeout(void *item) {
|
void register_idle_timeout(void *item) {
|
||||||
struct swayidle_timeout_cmd *cmd = item;
|
struct swayidle_timeout_cmd *cmd = item;
|
||||||
if (cmd == NULL || !cmd->timeout) {
|
if (cmd == NULL || !cmd->timeout) {
|
||||||
wlr_log(L_ERROR, "Invalid idle cmd, will not register");
|
sway_log(L_ERROR, "Invalid idle cmd, will not register");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.idle_timer =
|
state.idle_timer =
|
||||||
|
|
@ -362,7 +362,7 @@ void register_idle_timeout(void *item) {
|
||||||
org_kde_kwin_idle_timeout_add_listener(state.idle_timer,
|
org_kde_kwin_idle_timeout_add_listener(state.idle_timer,
|
||||||
&idle_timer_listener, cmd);
|
&idle_timer_listener, cmd);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Could not create idle timer");
|
sway_log(L_ERROR, "Could not create idle timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -376,7 +376,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
state.display = wl_display_connect(NULL);
|
state.display = wl_display_connect(NULL);
|
||||||
if (state.display == NULL) {
|
if (state.display == NULL) {
|
||||||
wlr_log(L_ERROR, "Failed to create display");
|
sway_log(L_ERROR, "Failed to create display");
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,11 +387,11 @@ int main(int argc, char *argv[]) {
|
||||||
state.event_loop = wl_event_loop_create();
|
state.event_loop = wl_event_loop_create();
|
||||||
|
|
||||||
if (idle_manager == NULL) {
|
if (idle_manager == NULL) {
|
||||||
wlr_log(L_ERROR, "Display doesn't support idle protocol");
|
sway_log(L_ERROR, "Display doesn't support idle protocol");
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
if (seat == NULL) {
|
if (seat == NULL) {
|
||||||
wlr_log(L_ERROR, "Seat error");
|
sway_log(L_ERROR, "Seat error");
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,7 +403,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!should_run) {
|
if (!should_run) {
|
||||||
wlr_log(L_INFO, "No command specified! Nothing to do, will exit");
|
sway_log(L_INFO, "No command specified! Nothing to do, will exit");
|
||||||
sway_terminate(0);
|
sway_terminate(0);
|
||||||
}
|
}
|
||||||
list_foreach(state.timeout_cmds, register_idle_timeout);
|
list_foreach(state.timeout_cmds, register_idle_timeout);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ void sway_terminate(int exit_code) {
|
||||||
static void daemonize() {
|
static void daemonize() {
|
||||||
int fds[2];
|
int fds[2];
|
||||||
if (pipe(fds) != 0) {
|
if (pipe(fds) != 0) {
|
||||||
wlr_log(L_ERROR, "Failed to pipe");
|
sway_log(L_ERROR, "Failed to pipe");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
|
|
@ -56,7 +56,7 @@ static void daemonize() {
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
uint8_t success;
|
uint8_t success;
|
||||||
if (read(fds[0], &success, 1) != 1 || !success) {
|
if (read(fds[0], &success, 1) != 1 || !success) {
|
||||||
wlr_log(L_ERROR, "Failed to daemonize");
|
sway_log(L_ERROR, "Failed to daemonize");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
|
|
@ -174,7 +174,7 @@ static void handle_xdg_output_logical_position(void *data,
|
||||||
|
|
||||||
static void handle_xdg_output_name(void *data, struct zxdg_output_v1 *output,
|
static void handle_xdg_output_name(void *data, struct zxdg_output_v1 *output,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
wlr_log(L_DEBUG, "output name is %s", name);
|
sway_log(L_DEBUG, "output name is %s", name);
|
||||||
struct swaylock_surface *surface = data;
|
struct swaylock_surface *surface = data;
|
||||||
surface->xdg_output = output;
|
surface->xdg_output = output;
|
||||||
surface->output_name = strdup(name);
|
surface->output_name = strdup(name);
|
||||||
|
|
@ -290,10 +290,10 @@ static void load_image(char *arg, struct swaylock_state *state) {
|
||||||
}
|
}
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (image->output_name) {
|
if (image->output_name) {
|
||||||
wlr_log(L_ERROR, "Multiple images defined for output %s",
|
sway_log(L_ERROR, "Multiple images defined for output %s",
|
||||||
image->output_name);
|
image->output_name);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_ERROR, "Multiple default images defined");
|
sway_log(L_ERROR, "Multiple default images defined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,7 +313,7 @@ static void load_image(char *arg, struct swaylock_state *state) {
|
||||||
}
|
}
|
||||||
wl_list_insert(&state->images, &image->link);
|
wl_list_insert(&state->images, &image->link);
|
||||||
state->args.mode = BACKGROUND_MODE_FILL;
|
state->args.mode = BACKGROUND_MODE_FILL;
|
||||||
wlr_log(L_DEBUG, "Loaded image %s for output %s",
|
sway_log(L_DEBUG, "Loaded image %s for output %s",
|
||||||
image->path, image->output_name ? image->output_name : "*");
|
image->path, image->output_name ? image->output_name : "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,7 +352,7 @@ int main(int argc, char **argv) {
|
||||||
};
|
};
|
||||||
wl_list_init(&state.images);
|
wl_list_init(&state.images);
|
||||||
|
|
||||||
wlr_log_init(L_DEBUG, NULL);
|
sway_log_init(L_DEBUG, NULL);
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
@ -416,13 +416,13 @@ int main(int argc, char **argv) {
|
||||||
wl_display_roundtrip(state.display);
|
wl_display_roundtrip(state.display);
|
||||||
assert(state.compositor && state.layer_shell && state.shm);
|
assert(state.compositor && state.layer_shell && state.shm);
|
||||||
if (!state.input_inhibit_manager) {
|
if (!state.input_inhibit_manager) {
|
||||||
wlr_log(L_ERROR, "Compositor does not support the input inhibitor "
|
sway_log(L_ERROR, "Compositor does not support the input inhibitor "
|
||||||
"protocol, refusing to run insecurely");
|
"protocol, refusing to run insecurely");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_list_empty(&state.surfaces)) {
|
if (wl_list_empty(&state.surfaces)) {
|
||||||
wlr_log(L_DEBUG, "Exiting - no outputs to show on.");
|
sway_log(L_DEBUG, "Exiting - no outputs to show on.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,7 +438,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
wl_display_roundtrip(state.display);
|
wl_display_roundtrip(state.display);
|
||||||
} else {
|
} else {
|
||||||
wlr_log(L_INFO, "Compositor does not support zxdg output manager, "
|
sway_log(L_INFO, "Compositor does not support zxdg output manager, "
|
||||||
"images assigned to named outputs will not work");
|
"images assigned to named outputs will not work");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wlr/util/log.h>
|
#include "log.h"
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include "swaylock/swaylock.h"
|
#include "swaylock/swaylock.h"
|
||||||
#include "swaylock/seat.h"
|
#include "swaylock/seat.h"
|
||||||
|
|
@ -53,15 +53,15 @@ static bool attempt_password(struct swaylock_password *pw) {
|
||||||
// TODO: only call pam_start once. keep the same handle the whole time
|
// TODO: only call pam_start once. keep the same handle the whole time
|
||||||
if ((pam_err = pam_start("swaylock", username,
|
if ((pam_err = pam_start("swaylock", username,
|
||||||
&local_conversation, &local_auth_handle)) != PAM_SUCCESS) {
|
&local_conversation, &local_auth_handle)) != PAM_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "PAM returned error %d", pam_err);
|
sway_log(L_ERROR, "PAM returned error %d", pam_err);
|
||||||
}
|
}
|
||||||
if ((pam_err = pam_authenticate(local_auth_handle, 0)) != PAM_SUCCESS) {
|
if ((pam_err = pam_authenticate(local_auth_handle, 0)) != PAM_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "pam_authenticate failed");
|
sway_log(L_ERROR, "pam_authenticate failed");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
// TODO: only call pam_end once we succeed at authing. refresh tokens beforehand
|
// TODO: only call pam_end once we succeed at authing. refresh tokens beforehand
|
||||||
if ((pam_err = pam_end(local_auth_handle, pam_err)) != PAM_SUCCESS) {
|
if ((pam_err = pam_end(local_auth_handle, pam_err)) != PAM_SUCCESS) {
|
||||||
wlr_log(L_ERROR, "pam_end failed");
|
sway_log(L_ERROR, "pam_end failed");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
clear_password_buffer(pw);
|
clear_password_buffer(pw);
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wlr/util/log.h>
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
#include "log.h"
|
||||||
#include "swaylock/swaylock.h"
|
#include "swaylock/swaylock.h"
|
||||||
#include "swaylock/seat.h"
|
#include "swaylock/seat.h"
|
||||||
|
|
||||||
|
|
@ -34,13 +34,13 @@ static void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
||||||
struct swaylock_state *state = data;
|
struct swaylock_state *state = data;
|
||||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
|
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
|
||||||
close(fd);
|
close(fd);
|
||||||
wlr_log(L_ERROR, "Unknown keymap format %d, aborting", format);
|
sway_log(L_ERROR, "Unknown keymap format %d, aborting", format);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||||
if (map_shm == MAP_FAILED) {
|
if (map_shm == MAP_FAILED) {
|
||||||
close(fd);
|
close(fd);
|
||||||
wlr_log(L_ERROR, "Unable to initialize keymap shm, aborting");
|
sway_log(L_ERROR, "Unable to initialize keymap shm, aborting");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
struct xkb_keymap *keymap = xkb_keymap_new_from_string(
|
struct xkb_keymap *keymap = xkb_keymap_new_from_string(
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ int main(int argc, char **argv) {
|
||||||
char *socket_path = NULL;
|
char *socket_path = NULL;
|
||||||
char *cmdtype = NULL;
|
char *cmdtype = NULL;
|
||||||
|
|
||||||
wlr_log_init(L_INFO, NULL);
|
sway_log_init(L_INFO, NULL);
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue