Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] gaps: fixes for edge cases & better alignment with i3-gaps syntax #2131

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main(int argc, const char **argv) {
}

int desired_output = atoi(argv[1]);
sway_log(WLR_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
sway_log(L_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
int i;
struct output_state *output = registry->outputs->items[desired_output];
struct window *window = window_setup(registry, 100, 100, false);
Expand Down
6 changes: 3 additions & 3 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Use `sway_log(importance, fmt, ...)` to log. The following importances are
available:

* `WLR_DEBUG`: Debug messages, only shows with `sway -d`
* `WLR_INFO`: Informational messages
* `WLR_ERROR`: Error messages
* `L_DEBUG`: Debug messages, only shows with `sway -d`
* `L_INFO`: Informational messages
* `L_ERROR`: Error messages

`sway_log` is a macro that calls `_sway_log` with the current filename and line
number, which are written into the log with your message.
Expand Down
8 changes: 4 additions & 4 deletions common/background-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum background_mode parse_background_mode(const char *mode) {
} else if (strcmp(mode, "solid_color") == 0) {
return BACKGROUND_MODE_SOLID_COLOR;
}
wlr_log(WLR_ERROR, "Unsupported background mode: %s", mode);
wlr_log(L_ERROR, "Unsupported background mode: %s", mode);
return BACKGROUND_MODE_INVALID;
}

Expand All @@ -28,7 +28,7 @@ cairo_surface_t *load_background_image(const char *path) {
GError *err = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &err);
if (!pixbuf) {
wlr_log(WLR_ERROR, "Failed to load background image (%s).",
wlr_log(L_ERROR, "Failed to load background image (%s).",
err->message);
return false;
}
Expand All @@ -38,11 +38,11 @@ cairo_surface_t *load_background_image(const char *path) {
image = cairo_image_surface_create_from_png(path);
#endif //HAVE_GDK_PIXBUF
if (!image) {
wlr_log(WLR_ERROR, "Failed to read background image.");
wlr_log(L_ERROR, "Failed to read background image.");
return NULL;
}
if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
wlr_log(WLR_ERROR, "Failed to read background image: %s."
wlr_log(L_ERROR, "Failed to read background image: %s."
#ifndef HAVE_GDK_PIXBUF
"\nSway was compiled without gdk_pixbuf support, so only"
"\nPNG images can be loaded. This is the likely cause."
Expand Down
2 changes: 1 addition & 1 deletion common/ipc-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct ipc_response *ipc_recv_response(int socketfd) {
error_2:
free(response);
error_1:
wlr_log(WLR_ERROR, "Unable to allocate memory for IPC response");
wlr_log(L_ERROR, "Unable to allocate memory for IPC response");
return NULL;
}

Expand Down
15 changes: 0 additions & 15 deletions common/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"

list_t *create_list(void) {
list_t *list = malloc(sizeof(list_t));
Expand Down Expand Up @@ -83,20 +82,6 @@ void list_swap(list_t *list, int src, int dest) {
list->items[dest] = tmp;
}

void list_move_to_end(list_t *list, void *item) {
int i;
for (i = 0; i < list->length; ++i) {
if (list->items[i] == item) {
break;
}
}
if (!sway_assert(i < list->length, "Item not found in list")) {
return;
}
list_del(list, i);
list_add(list, item);
}

static void list_rotate(list_t *list, int from, int to) {
void *tmp = list->items[to];

Expand Down
4 changes: 2 additions & 2 deletions common/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void sway_terminate(int code);
void _sway_abort(const char *format, ...) {
va_list args;
va_start(args, format);
_wlr_vlog(WLR_ERROR, format, args);
_wlr_vlog(L_ERROR, format, args);
va_end(args);
sway_terminate(EXIT_FAILURE);
}
Expand All @@ -20,7 +20,7 @@ bool _sway_assert(bool condition, const char *format, ...) {

va_list args;
va_start(args, format);
_wlr_vlog(WLR_ERROR, format, args);
_wlr_vlog(L_ERROR, format, args);
va_end(args);

#ifndef NDEBUG
Expand Down
2 changes: 1 addition & 1 deletion common/pango.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
pango_layout_set_markup(layout, buf, -1);
free(buf);
} else {
wlr_log(WLR_ERROR, "pango_parse_markup '%s' -> error %s", text,
wlr_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text,
error->message);
g_error_free(error);
markup = false; // fallback to plain text
Expand Down
4 changes: 2 additions & 2 deletions common/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ char *read_line(FILE *file) {
char *string = malloc(size);
char lastChar = '\0';
if (!string) {
wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
while (1) {
Expand All @@ -30,7 +30,7 @@ char *read_line(FILE *file) {
char *new_string = realloc(string, size *= 2);
if (!new_string) {
free(string);
wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
wlr_log(L_ERROR, "Unable to allocate memory for read_line");
return NULL;
}
string = new_string;
Expand Down
2 changes: 1 addition & 1 deletion common/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static const struct {

int utf8_size(const char *s) {
uint8_t c = (uint8_t)*s;
for (size_t i = 0; i < sizeof(sizes) / sizeof(*sizes); ++i) {
for (size_t i = 0; i < sizeof(sizes) / 2; ++i) {
if ((c & sizes[i].mask) == sizes[i].result) {
return sizes[i].octets;
}
Expand Down
4 changes: 2 additions & 2 deletions common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pid_t get_parent_pid(pid_t child) {
token = strtok(NULL, sep); // parent pid
parent = strtol(token, NULL, 10);
}
free(buffer);

fclose(stat);
}

Expand All @@ -113,7 +113,7 @@ uint32_t parse_color(const char *color) {

int len = strlen(color);
if (len != 6 && len != 8) {
wlr_log(WLR_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
wlr_log(L_DEBUG, "Invalid color %s, defaulting to color 0xFFFFFFFF", color);
return 0xFFFFFFFF;
}
uint32_t res = (uint32_t)strtoul(color, NULL, 16);
Expand Down
1 change: 1 addition & 0 deletions completions/zsh/_swaymsg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ types=(
'get_marks'
'get_bar_config'
'get_version'
'get_clipboard'
)

_arguments -s \
Expand Down
5 changes: 2 additions & 3 deletions include/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ enum ipc_command_type {
IPC_GET_MARKS = 5,
IPC_GET_BAR_CONFIG = 6,
IPC_GET_VERSION = 7,
IPC_GET_BINDING_MODES = 8,
IPC_GET_CONFIG = 9,

// sway-specific command types
IPC_GET_INPUTS = 100,
IPC_GET_SEATS = 101,
IPC_GET_CLIPBOARD = 101,
IPC_GET_SEATS = 102,

// Events sent from sway to clients. Events have the highest bits set.
IPC_EVENT_WORKSPACE = ((1<<31) | 0),
Expand Down
2 changes: 0 additions & 2 deletions include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to
void list_stable_sort(list_t *list, int compare(const void *a, const void *b));
// swap two elements in a list
void list_swap(list_t *list, int src, int dest);
// move item to end of list
void list_move_to_end(list_t *list, void *item);
#endif
10 changes: 2 additions & 8 deletions include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@
#include <stdbool.h>
#include <wlr/util/log.h>

#ifdef __GNUC__
#define ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
#else
#define ATTRIB_PRINTF(start, end)
#endif

void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
#define sway_abort(FMT, ...) \
_sway_abort("[%s:%d] " FMT, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
_sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)

bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
#define sway_assert(COND, FMT, ...) \
_sway_assert(COND, "[%s:%d] %s:" FMT, _wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
_sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)

void error_handler(int sig);

Expand Down
3 changes: 2 additions & 1 deletion include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void free_cmd_results(struct cmd_results *results);
*
* Free the JSON string later on.
*/
char *cmd_results_to_json(struct cmd_results *results);
const char *cmd_results_to_json(struct cmd_results *results);

struct cmd_results *add_color(const char *name,
char *buffer, const char *color);
Expand All @@ -95,6 +95,7 @@ sway_cmd cmd_client_unfocused;
sway_cmd cmd_client_urgent;
sway_cmd cmd_client_placeholder;
sway_cmd cmd_client_background;
sway_cmd cmd_clipboard;
sway_cmd cmd_commands;
sway_cmd cmd_debuglog;
sway_cmd cmd_default_border;
Expand Down
10 changes: 6 additions & 4 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct sway_mode {
char *name;
list_t *keysym_bindings;
list_t *keycode_bindings;
bool pango;
};

struct input_config_mapped_from_region {
Expand Down Expand Up @@ -271,10 +270,11 @@ enum ipc_feature {
IPC_FEATURE_EVENT_WINDOW = 2048,
IPC_FEATURE_EVENT_BINDING = 4096,
IPC_FEATURE_EVENT_INPUT = 8192,
IPC_FEATURE_GET_SEATS = 16384,
IPC_FEATURE_GET_CLIPBOARD = 16384,
IPC_FEATURE_GET_SEATS = 32768,

IPC_FEATURE_ALL_COMMANDS =
1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384,
1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384 | 32768,
IPC_FEATURE_ALL_EVENTS = 256 | 512 | 1024 | 2048 | 4096 | 8192,

IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS,
Expand Down Expand Up @@ -340,7 +340,6 @@ struct sway_config {
int gaps_outer;

list_t *config_chain;
const char *current_config_path;
const char *current_config;

enum sway_container_border border;
Expand Down Expand Up @@ -496,4 +495,7 @@ void config_update_font_height(bool recalculate);
/* Global config singleton. */
extern struct sway_config *config;

/* Config file currently being read */
extern const char *current_config_path;

#endif
4 changes: 0 additions & 4 deletions include/sway/desktop.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <wlr/types/wlr_surface.h>

struct sway_container;

void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
bool whole);

void desktop_damage_whole_container(struct sway_container *con);
28 changes: 0 additions & 28 deletions include/sway/desktop/idle_inhibit_v1.h

This file was deleted.

4 changes: 3 additions & 1 deletion include/sway/ipc-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ struct sway_server;

void ipc_init(struct sway_server *server);

void ipc_terminate(void);

struct sockaddr_un *ipc_user_sockaddr(void);

void ipc_event_workspace(struct sway_container *old,
struct sway_container *new, const char *change);
void ipc_event_window(struct sway_container *window, const char *change);
void ipc_event_barconfig_update(struct bar_config *bar);
void ipc_event_mode(const char *mode, bool pango);
void ipc_event_mode(const char *mode);

#endif
43 changes: 0 additions & 43 deletions include/sway/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ struct sway_output {
} events;
};

/**
* Contains a surface's root geometry information. For instance, when rendering
* a popup, this will contain the parent view's position and size.
*/
struct root_geometry {
double x, y;
int width, height;
float rotation;
};

void output_damage_whole(struct sway_output *output);

void output_damage_surface(struct sway_output *output, double ox, double oy,
Expand All @@ -64,37 +54,4 @@ void output_damage_whole_container(struct sway_output *output,
struct sway_container *output_by_name(const char *name);

void output_enable(struct sway_output *output);

bool output_has_opaque_lockscreen(struct sway_output *output,
struct sway_seat *seat);

struct sway_container *output_get_active_workspace(struct sway_output *output);

void output_render(struct sway_output *output, struct timespec *when,
pixman_region32_t *damage);

bool output_get_surface_box(struct root_geometry *geo,
struct sway_output *output, struct wlr_surface *surface, int sx, int sy,
struct wlr_box *surface_box);

void output_surface_for_each_surface(struct wlr_surface *surface,
double ox, double oy, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data);

void output_view_for_each_surface(struct sway_view *view,
struct sway_output *output, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data);

void output_layer_for_each_surface(struct wl_list *layer_surfaces,
struct root_geometry *geo, wlr_surface_iterator_func_t iterator,
void *user_data);

void output_unmanaged_for_each_surface(struct wl_list *unmanaged,
struct sway_output *output, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data);

void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
struct sway_output *output, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data);

#endif
Loading