Merge pull request #3447 from emersion/remove-swaylock-includes

Remove swaylock headers and unicode.c
This commit is contained in:
Drew DeVault 2019-01-17 08:13:19 -05:00 committed by GitHub
commit 5a0c4234b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 273 deletions

View File

@ -9,7 +9,6 @@ lib_sway_common = static_library(
'list.c',
'pango.c',
'stringop.c',
'unicode.c',
'util.c'
),
dependencies: [

View File

@ -1,101 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include "unicode.h"
size_t utf8_chsize(uint32_t ch) {
if (ch < 0x80) {
return 1;
} else if (ch < 0x800) {
return 2;
} else if (ch < 0x10000) {
return 3;
}
return 4;
}
static const uint8_t masks[] = {
0x7F,
0x1F,
0x0F,
0x07,
0x03,
0x01
};
uint32_t utf8_decode(const char **char_str) {
uint8_t **s = (uint8_t **)char_str;
uint32_t cp = 0;
if (**s < 128) {
// shortcut
cp = **s;
++*s;
return cp;
}
int size = utf8_size((char *)*s);
if (size == -1) {
++*s;
return UTF8_INVALID;
}
uint8_t mask = masks[size - 1];
cp = **s & mask;
++*s;
while (--size) {
cp <<= 6;
cp |= **s & 0x3f;
++*s;
}
return cp;
}
size_t utf8_encode(char *str, uint32_t ch) {
size_t len = 0;
uint8_t first;
if (ch < 0x80) {
first = 0;
len = 1;
} else if (ch < 0x800) {
first = 0xc0;
len = 2;
} else if (ch < 0x10000) {
first = 0xe0;
len = 3;
} else {
first = 0xf0;
len = 4;
}
for (size_t i = len - 1; i > 0; --i) {
str[i] = (ch & 0x3f) | 0x80;
ch >>= 6;
}
str[0] = ch | first;
return len;
}
static const struct {
uint8_t mask;
uint8_t result;
int octets;
} sizes[] = {
{ 0x80, 0x00, 1 },
{ 0xE0, 0xC0, 2 },
{ 0xF0, 0xE0, 3 },
{ 0xF8, 0xF0, 4 },
{ 0xFC, 0xF8, 5 },
{ 0xFE, 0xF8, 6 },
{ 0x80, 0x80, -1 },
};
int utf8_size(const char *s) {
uint8_t c = (uint8_t)*s;
for (size_t i = 0; i < sizeof(sizes) / sizeof(*sizes); ++i) {
if ((c & sizes[i].mask) == sizes[i].result) {
return sizes[i].octets;
}
}
return -1;
}

View File

@ -1,21 +0,0 @@
#ifndef _SWAYLOCK_SEAT_H
#define _SWAYLOCK_SEAT_H
#include <xkbcommon/xkbcommon.h>
struct swaylock_xkb {
bool caps_lock;
bool control;
struct xkb_state *state;
struct xkb_context *context;
struct xkb_keymap *keymap;
};
struct swaylock_seat {
struct swaylock_state *state;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
};
extern const struct wl_seat_listener seat_listener;
#endif

View File

@ -1,117 +0,0 @@
#ifndef _SWAYLOCK_H
#define _SWAYLOCK_H
#include <stdbool.h>
#include <stdint.h>
#include <wayland-client.h>
#include "background-image.h"
#include "cairo.h"
#include "pool-buffer.h"
#include "swaylock/seat.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
enum auth_state {
AUTH_STATE_IDLE,
AUTH_STATE_CLEAR,
AUTH_STATE_INPUT,
AUTH_STATE_INPUT_NOP,
AUTH_STATE_BACKSPACE,
AUTH_STATE_VALIDATING,
AUTH_STATE_INVALID,
};
struct swaylock_colorset {
uint32_t input;
uint32_t cleared;
uint32_t caps_lock;
uint32_t verifying;
uint32_t wrong;
};
struct swaylock_colors {
uint32_t background;
uint32_t bs_highlight;
uint32_t key_highlight;
uint32_t caps_lock_bs_highlight;
uint32_t caps_lock_key_highlight;
uint32_t separator;
struct swaylock_colorset inside;
struct swaylock_colorset line;
struct swaylock_colorset ring;
struct swaylock_colorset text;
};
struct swaylock_args {
struct swaylock_colors colors;
enum background_mode mode;
char *font;
uint32_t radius;
uint32_t thickness;
bool ignore_empty;
bool show_indicator;
bool show_caps_lock_text;
bool show_caps_lock_indicator;
bool daemonize;
};
struct swaylock_password {
size_t len;
char buffer[1024];
};
struct swaylock_state {
struct loop *eventloop;
struct loop_timer *clear_indicator_timer; // clears the indicator
struct loop_timer *clear_password_timer; // clears the password buffer
struct loop_timer *verify_password_timer;
struct wl_display *display;
struct wl_compositor *compositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager;
struct wl_shm *shm;
struct wl_list surfaces;
struct wl_list images;
struct swaylock_args args;
struct swaylock_password password;
struct swaylock_xkb xkb;
enum auth_state auth_state;
bool run_display;
struct zxdg_output_manager_v1 *zxdg_output_manager;
};
struct swaylock_surface {
cairo_surface_t *image;
struct swaylock_state *state;
struct wl_output *output;
uint32_t output_global_name;
struct zxdg_output_v1 *xdg_output;
struct wl_surface *surface;
struct zwlr_layer_surface_v1 *layer_surface;
struct pool_buffer buffers[2];
struct pool_buffer *current_buffer;
bool frame_pending, dirty;
uint32_t width, height;
int32_t scale;
enum wl_output_subpixel subpixel;
char *output_name;
struct wl_list link;
};
// There is exactly one swaylock_image for each -i argument
struct swaylock_image {
char *path;
char *output_name;
cairo_surface_t *cairo_surface;
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);
void render_frames(struct swaylock_state *state);
void damage_surface(struct swaylock_surface *surface);
void damage_state(struct swaylock_state *state);
void initialize_pw_backend(void);
bool attempt_password(struct swaylock_password *pw);
void clear_password_buffer(struct swaylock_password *pw);
#endif

View File

@ -1,33 +0,0 @@
#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