Add password buffer, refactor rendering/surfaces

This commit is contained in:
Drew DeVault 2018-04-03 14:31:30 -04:00
parent 1fe3cb8965
commit 066143adef
9 changed files with 262 additions and 51 deletions

View file

@ -15,18 +15,25 @@ struct swaylock_args {
bool show_indicator;
};
struct swaylock_password {
size_t size;
size_t len;
char *buffer;
};
struct swaylock_state {
struct wl_display *display;
struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct wl_shm *shm;
struct wl_list contexts;
struct wl_list surfaces;
struct swaylock_args args;
struct swaylock_password password;
struct swaylock_xkb xkb;
bool run_display;
};
struct swaylock_context {
struct swaylock_surface {
cairo_surface_t *image;
struct swaylock_state *state;
struct wl_output *output;
@ -38,4 +45,8 @@ struct swaylock_context {
struct wl_list link;
};
void swaylock_handle_key(struct swaylock_state *state,
xkb_keysym_t keysym, uint32_t codepoint);
void render_frame(struct swaylock_surface *surface);
#endif

33
include/unicode.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef _SWAY_UNICODE_H
#define _SWAY_UNICODE_H
#include <stddef.h>
#include <stdint.h>
// Technically UTF-8 supports up to 6 byte codepoints, but Unicode itself
// doesn't really bother with more than 4.
#define UTF8_MAX_SIZE 4
#define UTF8_INVALID 0x80
/**
* Grabs the next UTF-8 character and advances the string pointer
*/
uint32_t utf8_decode(const char **str);
/**
* Encodes a character as UTF-8 and returns the length of that character.
*/
size_t utf8_encode(char *str, uint32_t ch);
/**
* Returns the size of the next UTF-8 character
*/
int utf8_size(const char *str);
/**
* Returns the size of a UTF-8 character
*/
size_t utf8_chsize(uint32_t ch);
#endif