Skip to content

Commit

Permalink
Merge branch 'master' into fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka authored Dec 1, 2023
2 parents 223e466 + cf64ee6 commit 0c870df
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 251 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ The following table shows the relation between the swaylock-effect and swaylock
* Alpine Linux: [swaylock-effects](https://pkgs.alpinelinux.org/packages?name=swaylock-effects)
* Arch Linux (AUR): [swaylock-effects](https://aur.archlinux.org/packages/swaylock-effects/) / [swaylock-effects-git](https://aur.archlinux.org/packages/swaylock-effects-git/)
* Fedora (Copr): [swaylock-effects](https://copr.fedorainfracloud.org/coprs/trs-sod/swaylock-effects)
* FreeBSD: [swaylock-effects](https://www.freshports.org/x11/swaylock-effects/)
* Guix: [swaylock-effects](https://packages.guix.gnu.org/packages/swaylock-effects)
* Nix: [swaylock-effects](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/window-managers/sway/lock-effects.nix)

The original [mortie/swaylock-effects](https://github.com/mortie/swaylock-effects) (now unmaintained)
has been packaged for:

* Fedora (Copr): [swaylock-effects](https://copr.fedorainfracloud.org/coprs/eddsalkield/swaylock-effects/)
(thanks to Edd Salkield)
* FreeBSD: [swaylock-effects](https://www.freshports.org/x11/swaylock-effects/)
* Gentoo (GURU overlay): [swaylock-effects](https://gpo.zugaina.org/Overlays/guru/gui-apps/swaylock-effects)
* T2 SDE: [swaylock-effects](https://t2sde.org/packages/swaylock-effects)

Expand Down
9 changes: 7 additions & 2 deletions background-image.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,14 @@ void render_background_image(cairo_t *cairo, cairo_surface_t *image,
break;
}
case BACKGROUND_MODE_CENTER:
/*
* Align the unscaled image to integer pixel boundaries
* in order to prevent loss of clarity (this only matters
* for odd-sized images).
*/
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 - width / 2,
(double)buffer_height / 2 - height / 2);
(int)((double)buffer_width / 2 - width / 2),
(int)((double)buffer_height / 2 - height / 2));
break;
case BACKGROUND_MODE_TILE: {
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image);
Expand Down
4 changes: 2 additions & 2 deletions comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "comm.h"
#include "log.h"
#include "swaylock.h"
#include "password-buffer.h"

static int comm[2][2] = {{-1, -1}, {-1, -1}};

Expand All @@ -19,9 +20,8 @@ ssize_t read_comm_request(char **buf_ptr) {
return -1;
}
swaylock_log(LOG_DEBUG, "received pw check request");
char *buf = malloc(size);
char *buf = password_buffer_create(size);
if (!buf) {
swaylock_log_errno(LOG_ERROR, "failed to malloc pw buffer");
return -1;
}
size_t offs = 0;
Expand Down
2 changes: 1 addition & 1 deletion completions/bash/swaylock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

_swaylock()
{
local cur prev
local cur prev short long scaling
_get_comp_words_by_ref -n : cur prev

short=(
Expand Down
39 changes: 39 additions & 0 deletions completions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false)

datadir = get_option('datadir')

if get_option('zsh-completions')
zsh_files = files(
'zsh/_swaylock',
)
zsh_install_dir = datadir + '/zsh/site-functions'

install_data(zsh_files, install_dir: zsh_install_dir)
endif

if get_option('bash-completions')
bash_files = files(
'bash/swaylock',
)
if bash_comp.found()
bash_install_dir = bash_comp.get_variable('completionsdir')
else
bash_install_dir = datadir + '/bash-completion/completions'
endif

install_data(bash_files, install_dir: bash_install_dir)
endif

if get_option('fish-completions')
fish_files = files(
'fish/swaylock.fish',
)
if fish_comp.found()
fish_install_dir = fish_comp.get_variable('completionsdir')
else
fish_install_dir = datadir + '/fish/vendor_completions.d'
endif

install_data(fish_files, install_dir: fish_install_dir)
endif
3 changes: 0 additions & 3 deletions include/cairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
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);

cairo_surface_t *cairo_surface_duplicate(cairo_surface_t *src);

#if HAVE_GDK_PIXBUF
Expand Down
9 changes: 9 additions & 0 deletions include/password-buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _SWAY_PASSWORD_BUFFER_H
#define _SWAY_PASSWORD_BUFFER_H

#include <stddef.h>

char *password_buffer_create(size_t size);
void password_buffer_destroy(char *buffer, size_t size);

#endif
7 changes: 2 additions & 5 deletions include/swaylock.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct swaylock_args {

struct swaylock_password {
size_t len;
char buffer[1024];
size_t buffer_len;
char *buffer;
};

struct swaylock_state {
Expand All @@ -112,7 +113,6 @@ struct swaylock_state {
int failed_attempts;
size_t n_screenshots_done;
bool run_display;
struct zxdg_output_manager_v1 *zxdg_output_manager;
struct ext_session_lock_manager_v1 *ext_session_lock_manager_v1;
struct ext_session_lock_v1 *ext_session_lock_v1;
char *fingerprint_msg;
Expand All @@ -130,7 +130,6 @@ struct swaylock_surface {
struct swaylock_state *state;
struct wl_output *output;
uint32_t output_global_name;
struct zxdg_output_v1 *xdg_output;
struct wl_surface *surface;
struct wl_surface *child; // surface made into subsurface
struct wl_subsurface *subsurface;
Expand All @@ -139,7 +138,6 @@ struct swaylock_surface {
struct ext_session_lock_surface_v1 *ext_session_lock_surface_v1;
struct pool_buffer buffers[2];
struct pool_buffer indicator_buffers[2];
struct pool_buffer *current_buffer;
struct swaylock_fade fade;
int events_pending;
bool configured;
Expand Down Expand Up @@ -168,7 +166,6 @@ void swaylock_handle_touch(struct swaylock_state *state);
void render_frame_background(struct swaylock_surface *surface, bool commit);
void render_background_fade(struct swaylock_surface *surface, uint32_t time);
void render_frame(struct swaylock_surface *surface);
void render_frames(struct swaylock_state *state);
void damage_surface(struct swaylock_surface *surface);
void damage_state(struct swaylock_state *state);
void clear_password_buffer(struct swaylock_password *pw);
Expand Down
8 changes: 8 additions & 0 deletions include/unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

#define UTF8_INVALID 0x80

/**
* Gets the size in bytes of the last utf8 character in a NULL terminated string
* This function does not validate that the buffer contains correct utf8 data;
* it merely looks for the first byte that correctly denotes the beginning of a
* utf8 character.
*/
int utf8_last_size(const char *str);

/**
* Grabs the next UTF-8 character and advances the string pointer
*/
Expand Down
2 changes: 1 addition & 1 deletion loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void loop_poll(struct loop *loop) {
}

int ret = poll(loop->fds, loop->fd_length, ms);
if (ret < 0) {
if (ret < 0 && errno != EINTR) {
swaylock_log_errno(LOG_ERROR, "poll failed");
exit(1);
}
Expand Down
Loading

0 comments on commit 0c870df

Please sign in to comment.