diff options
-rw-r--r-- | common/cairo.c | 16 | ||||
-rw-r--r-- | common/pango.c | 58 | ||||
-rw-r--r-- | contrib/awesome.config | 63 | ||||
-rw-r--r-- | include/cairo.h | 2 | ||||
-rw-r--r-- | include/pango.h | 14 | ||||
-rw-r--r-- | include/sway/commands.h | 9 | ||||
-rw-r--r-- | include/swaybar/bar.h | 1 | ||||
-rw-r--r-- | include/swaylock/swaylock.h | 1 | ||||
-rw-r--r-- | sway/commands.c | 16 | ||||
-rw-r--r-- | sway/commands/bind.c | 2 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 11 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 2 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/ipc-server.c | 2 | ||||
-rw-r--r-- | sway/main.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 8 | ||||
-rw-r--r-- | sway/tree/root.c | 6 | ||||
-rw-r--r-- | sway/tree/view.c | 19 | ||||
-rw-r--r-- | sway/tree/workspace.c | 10 | ||||
-rw-r--r-- | swaybar/bar.c | 8 | ||||
-rw-r--r-- | swaybar/render.c | 7 | ||||
-rw-r--r-- | swaybar/status_line.c | 10 | ||||
-rw-r--r-- | swaylock/main.c | 8 | ||||
-rw-r--r-- | swaylock/render.c | 7 |
25 files changed, 130 insertions, 156 deletions
diff --git a/common/cairo.c b/common/cairo.c index c267c77c..e8231484 100644 --- a/common/cairo.c +++ b/common/cairo.c @@ -13,6 +13,22 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { (color >> (0*8) & 0xFF) / 255.0); } +cairo_subpixel_order_t to_cairo_subpixel_order(enum wl_output_subpixel subpixel) { + switch (subpixel) { + case WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB: + return CAIRO_SUBPIXEL_ORDER_RGB; + case WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR: + return CAIRO_SUBPIXEL_ORDER_BGR; + case WL_OUTPUT_SUBPIXEL_VERTICAL_RGB: + return CAIRO_SUBPIXEL_ORDER_VRGB; + case WL_OUTPUT_SUBPIXEL_VERTICAL_BGR: + return CAIRO_SUBPIXEL_ORDER_VBGR; + default: + return CAIRO_SUBPIXEL_ORDER_DEFAULT; + } + return CAIRO_SUBPIXEL_ORDER_DEFAULT; +} + cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, int width, int height) { int image_width = cairo_image_surface_get_width(image); diff --git a/common/pango.c b/common/pango.c index ea71ac4a..ba74692e 100644 --- a/common/pango.c +++ b/common/pango.c @@ -6,67 +6,47 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "cairo.h" #include "log.h" +#include "stringop.h" -int escape_markup_text(const char *src, char *dest, int dest_length) { - int length = 0; +size_t escape_markup_text(const char *src, char *dest) { + size_t length = 0; + if (dest) { + dest[0] = '\0'; + } while (src[0]) { switch (src[0]) { case '&': length += 5; - if (dest && dest_length - length >= 0) { - dest += sprintf(dest, "%s", "&"); - } else { - dest_length = -1; - } + lenient_strcat(dest, "&"); break; case '<': length += 4; - if (dest && dest_length - length >= 0) { - dest += sprintf(dest, "%s", "<"); - } else { - dest_length = -1; - } + lenient_strcat(dest, "<"); break; case '>': length += 4; - if (dest && dest_length - length >= 0) { - dest += sprintf(dest, "%s", ">"); - } else { - dest_length = -1; - } + lenient_strcat(dest, ">"); break; case '\'': length += 6; - if (dest && dest_length - length >= 0) { - dest += sprintf(dest, "%s", "'"); - } else { - dest_length = -1; - } + lenient_strcat(dest, "'"); break; case '"': length += 6; - if (dest && dest_length - length >= 0) { - dest += sprintf(dest, "%s", """); - } else { - dest_length = -1; - } + lenient_strcat(dest, """); break; default: - length += 1; - if (dest && dest_length - length >= 0) { - *(dest++) = *src; - } else { - dest_length = -1; + if (dest) { + dest[length] = *src; + dest[length + 1] = '\0'; } + length += 1; } src++; } - // if we could not fit the escaped string in dest, return -1 - if (dest && dest_length == -1) { - return -1; - } return length; } @@ -78,7 +58,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, char *buf; GError *error = NULL; if (pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, &error)) { - pango_layout_set_markup(layout, buf, -1); + pango_layout_set_text(layout, buf, -1); free(buf); } else { wlr_log(WLR_ERROR, "pango_parse_markup '%s' -> error %s", text, @@ -134,6 +114,10 @@ void pango_printf(cairo_t *cairo, const char *font, va_end(args); PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_get_font_options(cairo, fo); + pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo); + cairo_font_options_destroy(fo); pango_cairo_update_layout(cairo, layout); pango_cairo_show_layout(cairo, layout); g_object_unref(layout); diff --git a/contrib/awesome.config b/contrib/awesome.config deleted file mode 100644 index 41e17c91..00000000 --- a/contrib/awesome.config +++ /dev/null @@ -1,63 +0,0 @@ -# -# Replicate some of Awesome's default layout manipulation configuration for Sway -# -# Differences: -# - Layout switching doesn't use the spacebar (i.e. i3/Sway behavior to switch to/from floating windows) -# and uses the 'A' key instead (as in auto) -# - Resizing windows uses i3/Sway's more versatile Mod4+r -# - no tags -# - no Maximize/Minize, alternatives to Maximize would be to switch to Stacked/Tabbed layouts -# via Mod4+w or Mod4+s. -# - kill focused client is available on Mod4+Shift+q (instead of Mod4+Shift+c, which maps to Sway's -# config reload) -# - probably many more ... - -# Awesome-style container traversal using Vim-like binding -set $next j -set $prev k - -# -# Moving around: -# - # Move your focus around - bindsym $mod+$next focus next - bindsym $mod+$prev focus prev - - # _move_ the focused window with the same, but add Shift - bindsym $mod+Shift+$next move next - bindsym $mod+Shift+$prev move prev - -# -# Layout: -# - workspace_layout auto left - - # This is usually bound to $mod+space, but this works well in practice by keeping - # all the layout switching keys grouped together. - bindsym $mod+a layout auto next - bindsym $mod+Shift+a layout auto prev - - # Promote a child to master position in an auto layout - bindsym $mod+Control+Return move first - - # Increase/decrease number of master elements in auto layout - bindsym $mod+Shift+h layout auto master inc 1 - bindsym $mod+Shift+l layout auto master inc -1 - - # Increase/decrease number of slave element groups in auto layout - bindsym $mod+Control+h layout auto ncol inc 1 - bindsym $mod+Control+l layout auto ncol inc -1 - -# -# Resizing containers: -# Again, not really the way Awesome works well, but in spirit with i3/Sway and it works well. -# -mode "resize" { - bindsym Left resize shrink width 20 px - bindsym Down resize grow height 20 px - bindsym Up resize shrink height 20 px - bindsym Right resize grow width 20 px -} -bindsym $mod+r mode "resize" - -new_window pixel 1 diff --git a/include/cairo.h b/include/cairo.h index 31672705..86530b60 100644 --- a/include/cairo.h +++ b/include/cairo.h @@ -2,8 +2,10 @@ #define _SWAY_CAIRO_H #include <stdint.h> #include <cairo/cairo.h> +#include <wlr/types/wlr_output.h> void cairo_set_source_u32(cairo_t *cairo, uint32_t color); +cairo_subpixel_order_t to_cairo_subpixel_order(enum wl_output_subpixel subpixel); cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, int width, int height); diff --git a/include/pango.h b/include/pango.h index 09a535a5..6ab83c16 100644 --- a/include/pango.h +++ b/include/pango.h @@ -6,17 +6,13 @@ #include <cairo/cairo.h> #include <pango/pangocairo.h> -/* Utility function which escape characters a & < > ' ". +/** + * Utility function which escape characters a & < > ' ". * - * If the dest parameter is NULL, then the function returns the length of - * of the escaped src string. The dest_length doesn't matter. - * - * If the dest parameter is not NULL then the fuction escapes the src string - * an puts the escaped string in dest and returns the lenght of the escaped string. - * The dest_length parameter is the size of dest array. If the size of dest is not - * enough, then the function returns -1. + * The function returns the length of the escaped string, optionally writing the + * escaped string to dest if provided. */ -int escape_markup_text(const char *src, char *dest, int dest_length); +size_t escape_markup_text(const char *src, char *dest); PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text, double scale, bool markup); void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, diff --git a/include/sway/commands.h b/include/sway/commands.h index 226cf932..1654eb48 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -4,6 +4,8 @@ #include <wlr/util/edges.h> #include "config.h" +struct sway_container; + typedef struct cmd_results *sway_cmd(int argc, char **argv); struct cmd_handler { @@ -50,8 +52,13 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers, int handlers_size); /** * Parse and executes a command. + * + * If the command string contains criteria then the command will be executed on + * all matching containers. Otherwise, it'll run on the `con` container. If + * `con` is NULL then it'll run on the currently focused container. */ -struct cmd_results *execute_command(char *command, struct sway_seat *seat); +struct cmd_results *execute_command(char *command, struct sway_seat *seat, + struct sway_container *con); /** * Parse and handles a command during config file loading. * diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 4065fb8b..29e96159 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -81,6 +81,7 @@ struct swaybar_output { uint32_t width, height; int32_t scale; + enum wl_output_subpixel subpixel; struct pool_buffer buffers[2]; struct pool_buffer *current_buffer; }; diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h index 950cfaaf..2f0cd34d 100644 --- a/include/swaylock/swaylock.h +++ b/include/swaylock/swaylock.h @@ -82,6 +82,7 @@ struct swaylock_surface { bool frame_pending, dirty; uint32_t width, height; int32_t scale; + enum wl_output_subpixel subpixel; char *output_name; struct wl_list link; }; diff --git a/sway/commands.c b/sway/commands.c index 07169f1e..5b61f73a 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -237,7 +237,8 @@ static void set_config_node(struct sway_node *node) { } } -struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { +struct cmd_results *execute_command(char *_exec, struct sway_seat *seat, + struct sway_container *con) { // Even though this function will process multiple commands we will only // return the last error, if any (for now). (Since we have access to an // error string we could e.g. concatenate all errors there.) @@ -256,6 +257,15 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { } } + // This is the container or workspace which this command will run on. + // Ignored if the command string contains criteria. + struct sway_node *node; + if (con) { + node = &con->node; + } else { + node = seat_get_focus_inactive(seat, &root->node); + } + config->handler_context.seat = seat; head = exec; @@ -318,9 +328,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { } if (!config->handler_context.using_criteria) { - // without criteria, the command acts upon the focused - // container - set_config_node(seat_get_focus_inactive(seat, &root->node)); + set_config_node(node); struct cmd_results *res = handler->handle(argc-1, argv+1); if (res->status != CMD_SUCCESS) { free_argv(argc, argv); diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 047018e0..820c2a6a 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -321,7 +321,7 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) } config->handler_context.seat = seat; - struct cmd_results *results = execute_command(binding->command, NULL); + struct cmd_results *results = execute_command(binding->command, NULL, NULL); if (results->status == CMD_SUCCESS) { ipc_event_binding(binding_copy); } else { diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index d747e279..797f6b4c 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -6,6 +6,7 @@ #include <string.h> #include <time.h> #include <wlr/types/wlr_buffer.h> +#include "sway/config.h" #include "sway/debug.h" #include "sway/desktop.h" #include "sway/desktop/idle_inhibit_v1.h" @@ -390,6 +391,16 @@ static bool should_configure(struct sway_node *node, } struct sway_container_state *cstate = &node->sway_container->current; struct sway_container_state *istate = instruction->container_state; +#ifdef HAVE_XWAYLAND + // Xwayland views are position-aware and need to be reconfigured + // when their position changes. + if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) { + if (cstate->view_x != istate->view_x || + cstate->view_y != istate->view_y) { + return true; + } + } +#endif if (cstate->view_width == istate->view_width && cstate->view_height == istate->view_height) { return false; diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 00448be7..6d1ccdd7 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -401,7 +401,7 @@ static void handle_map(struct wl_listener *listener, void *data) { } else { if (view->container->parent) { arrange_container(view->container->parent); - } else { + } else if (view->container->workspace) { arrange_workspace(view->container->workspace); } } diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index d2c9a68b..95ca396c 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -398,7 +398,7 @@ static void handle_map(struct wl_listener *listener, void *data) { } else { if (view->container->parent) { arrange_container(view->container->parent); - } else { + } else if (view->container->workspace) { arrange_workspace(view->container->workspace); } } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 3619f202..a12ac854 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -394,7 +394,7 @@ static void handle_map(struct wl_listener *listener, void *data) { } else { if (view->container->parent) { arrange_container(view->container->parent); - } else { + } else if (view->container->workspace) { arrange_workspace(view->container->workspace); } } diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 8ae265f6..99959c97 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -580,7 +580,7 @@ void ipc_client_handle_command(struct ipc_client *client) { switch (client->current_command) { case IPC_COMMAND: { - struct cmd_results *results = execute_command(buf, NULL); + struct cmd_results *results = execute_command(buf, NULL, NULL); transaction_commit_dirty(); char *json = cmd_results_to_json(results); int length = strlen(json); diff --git a/sway/main.c b/sway/main.c index 3d7cd158..990f5f3a 100644 --- a/sway/main.c +++ b/sway/main.c @@ -429,7 +429,7 @@ int main(int argc, char **argv) { wlr_log(WLR_DEBUG, "Running deferred commands"); while (config->cmd_queue->length) { char *line = config->cmd_queue->items[0]; - struct cmd_results *res = execute_command(line, NULL); + struct cmd_results *res = execute_command(line, NULL, NULL); if (res->status != CMD_SUCCESS) { wlr_log(WLR_ERROR, "Error on line '%s': %s", line, res->error); } diff --git a/sway/tree/container.c b/sway/tree/container.c index b8af7564..53b127b7 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -463,11 +463,17 @@ static void update_title_texture(struct sway_container *con, cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); cairo_t *cairo = cairo_create(surface); + cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); + cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(output->wlr_output->subpixel)); + cairo_set_font_options(cairo, fo); + cairo_font_options_destroy(fo); cairo_set_source_rgba(cairo, class->background[0], class->background[1], class->background[2], class->background[3]); cairo_paint(cairo); PangoContext *pango = pango_cairo_create_context(cairo); - cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); cairo_set_source_rgba(cairo, class->text[0], class->text[1], class->text[2], class->text[3]); cairo_move_to(cairo, 0, 0); diff --git a/sway/tree/root.c b/sway/tree/root.c index ecc04ddb..d6f67bd7 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -265,10 +265,10 @@ void root_for_each_container(void (*f)(struct sway_container *con, void *data), // Scratchpad for (int i = 0; i < root->scratchpad->length; ++i) { struct sway_container *container = root->scratchpad->items[i]; - // If the container has a parent then it's visible on a workspace + // If the container has a workspace then it's visible on a workspace // and will have been iterated in the previous for loop. So we only // iterate the hidden scratchpad containers here. - if (!container->parent) { + if (!container->workspace) { f(container, data); container_for_each_child(container, f, data); } @@ -311,7 +311,7 @@ struct sway_container *root_find_container( // Scratchpad for (int i = 0; i < root->scratchpad->length; ++i) { struct sway_container *container = root->scratchpad->items[i]; - if (!container->parent) { + if (!container->workspace) { if (test(container, data)) { return container; } diff --git a/sway/tree/view.c b/sway/tree/view.c index 4398f518..e370443c 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -391,8 +391,6 @@ static bool view_has_executed_criteria(struct sway_view *view, } void view_execute_criteria(struct sway_view *view) { - struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_node *prior_focus = seat_get_focus(seat); list_t *criterias = criteria_for_view(view, CT_COMMAND); for (int i = 0; i < criterias->length; i++) { struct criteria *criteria = criterias->items[i]; @@ -403,16 +401,12 @@ void view_execute_criteria(struct sway_view *view) { } wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", criteria->raw, view, criteria->cmdlist); - seat_set_focus_container(seat, view->container); list_add(view->executed_criteria, criteria); - struct cmd_results *res = execute_command(criteria->cmdlist, NULL); - if (res->status != CMD_SUCCESS) { - wlr_log(WLR_ERROR, "Command '%s' failed: %s", res->input, res->error); - } + struct cmd_results *res = execute_command( + criteria->cmdlist, NULL, view->container); free_cmd_results(res); } list_free(criterias); - seat_set_focus(seat, prior_focus); } static struct sway_workspace *select_workspace(struct sway_view *view) { @@ -785,14 +779,9 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { } static char *escape_title(char *buffer) { - int length = escape_markup_text(buffer, NULL, 0); + size_t length = escape_markup_text(buffer, NULL); char *escaped_title = calloc(length + 1, sizeof(char)); - int result = escape_markup_text(buffer, escaped_title, length); - if (result != length) { - wlr_log(WLR_ERROR, "Could not escape title: %s", buffer); - free(escaped_title); - return buffer; - } + escape_markup_text(buffer, escaped_title); free(buffer); return escaped_title; } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 18746430..b0c440c1 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -389,13 +389,11 @@ bool workspace_switch(struct sway_workspace *workspace, struct sway_output *next_output = workspace->output; struct sway_workspace *next_output_prev_ws = output_get_active_workspace(next_output); - bool has_sticky = false; if (workspace != next_output_prev_ws) { for (int i = 0; i < next_output_prev_ws->floating->length; ++i) { struct sway_container *floater = next_output_prev_ws->floating->items[i]; if (floater->is_sticky) { - has_sticky = true; container_detach(floater); workspace_add_floating(workspace, floater); if (&floater->node == focus) { @@ -414,14 +412,6 @@ bool workspace_switch(struct sway_workspace *workspace, if (next == NULL) { next = &workspace->node; } - if (has_sticky) { - // If there's a sticky container, we might be setting focus to the same - // container that's already focused, so seat_set_focus is effectively a - // no op. We therefore need to send the IPC event and clean up the old - // workspace here. - ipc_event_workspace(active_ws, workspace, "focus"); - workspace_consider_destroy(active_ws); - } seat_set_focus(seat, next); arrange_workspace(workspace); cursor_send_pointer_motion(seat->cursor, 0, true); diff --git a/swaybar/bar.c b/swaybar/bar.c index 69069f40..ab307fd4 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -319,10 +319,14 @@ static bool bar_uses_output(struct swaybar *bar, const char *name) { return false; } -static void output_geometry(void *data, struct wl_output *output, int32_t x, +static void output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char *make, const char *model, int32_t transform) { - // Who cares + struct swaybar_output *output = data; + output->subpixel = subpixel; + if (output->surface) { + render_frame(output->bar, output); + } } static void output_mode(void *data, struct wl_output *output, uint32_t flags, diff --git a/swaybar/render.c b/swaybar/render.c index 26db80cb..9413dc57 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -495,6 +495,13 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) { cairo_surface_t *recorder = cairo_recording_surface_create( CAIRO_CONTENT_COLOR_ALPHA, NULL); cairo_t *cairo = cairo_create(recorder); + cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); + cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(output->subpixel)); + cairo_set_font_options(cairo, fo); + cairo_font_options_destroy(fo); cairo_save(cairo); cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); cairo_paint(cairo); diff --git a/swaybar/status_line.c b/swaybar/status_line.c index 401bf6f6..48b43248 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -67,9 +67,13 @@ bool status_handle_readable(struct status_line *status) { wl_list_init(&status->blocks); status->tokener = json_tokener_new(); - status->buffer_index = getdelim(&status->buffer, - &status->buffer_size, EOF, status->read); - return i3bar_handle_readable(status); + read_bytes = getdelim(&status->buffer, &status->buffer_size, EOF, status->read); + if (read_bytes > 0) { + status->buffer_index = read_bytes; + return i3bar_handle_readable(status); + } else { + return false; + } } wlr_log(WLR_DEBUG, "Using text protocol."); diff --git a/swaylock/main.c b/swaylock/main.c index 668a8742..c25c8eec 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -195,11 +195,15 @@ void damage_state(struct swaylock_state *state) { } } -static void handle_wl_output_geometry(void *data, struct wl_output *output, +static void handle_wl_output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char *make, const char *model, int32_t transform) { - // Who cares + struct swaylock_surface *surface = data; + surface->subpixel = subpixel; + if (surface->state->run_display) { + damage_surface(surface); + } } static void handle_wl_output_mode(void *data, struct wl_output *output, diff --git a/swaylock/render.c b/swaylock/render.c index 66c55965..fa8832bd 100644 --- a/swaylock/render.c +++ b/swaylock/render.c @@ -39,6 +39,13 @@ void render_frame(struct swaylock_surface *surface) { } cairo_t *cairo = surface->current_buffer->cairo; + cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); + cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(surface->subpixel)); + cairo_set_font_options(cairo, fo); + cairo_font_options_destroy(fo); cairo_identity_matrix(cairo); cairo_save(cairo); |