Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Commits 06d22a8..fad5bc2
  • Loading branch information
jirutka committed Nov 29, 2023
2 parents 61a100b + fad5bc2 commit adde37a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
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
1 change: 0 additions & 1 deletion include/swaylock.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,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
4 changes: 3 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ endif

wayland_client = dependency('wayland-client', version: '>=1.20.0')
wayland_protos = dependency('wayland-protocols', version: '>=1.25', fallback: 'wayland-protocols')
wayland_scanner = dependency('wayland-scanner', version: '>=1.15.0')
# use native version of wayland-scanner when cross-compiling
# meson does this too: https://github.com/mesonbuild/meson/blob/c649a2b8c59c9f49affca9bd89c126bfa0f54449/mesonbuild/modules/unstable_wayland.py#L48-L53
wayland_scanner = dependency('wayland-scanner', version: '>=1.15.0', native: true)
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
omp = dependency('openmp')
Expand Down
3 changes: 2 additions & 1 deletion password.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ void clear_password_buffer(struct swaylock_password *pw) {

static bool backspace(struct swaylock_password *pw) {
if (pw->len != 0) {
pw->buffer[--pw->len] = 0;
pw->len -= utf8_last_size(pw->buffer);
pw->buffer[pw->len] = 0;
return true;
}
return false;
Expand Down
7 changes: 0 additions & 7 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,3 @@ void render_frame(struct swaylock_surface *surface) {

wl_surface_commit(surface->surface);
}

void render_frames(struct swaylock_state *state) {
struct swaylock_surface *surface;
wl_list_for_each(surface, &state->surfaces, link) {
render_frame(surface);
}
}
13 changes: 13 additions & 0 deletions unicode.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "unicode.h"

int utf8_last_size(const char *str) {
int len = 0;
char *pos = strchr(str, '\0');
while (pos > str) {
--pos; ++len;
if ((*pos & 0xc0) != 0x80) {
return len;
}
}
return 0;
}

size_t utf8_chsize(uint32_t ch) {
if (ch < 0x80) {
return 1;
Expand Down

0 comments on commit adde37a

Please sign in to comment.