mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-12-24 13:56:23 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
764c39633a | ||
|
|
8106d7606d | ||
|
|
bb237f5afa | ||
|
|
b083169ee4 | ||
|
|
538b48d08d | ||
|
|
de3b9a77e4 | ||
|
|
77c6cf4fe6 | ||
|
|
927918ccc5 | ||
|
|
9f8e73b315 | ||
|
|
0e17680041 | ||
|
|
3cccdab2e8 | ||
|
|
2d01b8963b | ||
|
|
c457d697aa | ||
|
|
5471e2ea0e | ||
|
|
a126945401 | ||
|
|
aa9e8ab7ab | ||
|
|
d6439afcb9 | ||
|
|
6e52be343d |
12
config.def.h
12
config.def.h
@@ -1,24 +1,28 @@
|
||||
#ifndef config_def_h_INCLUDED
|
||||
#define config_def_h_INCLUDED
|
||||
|
||||
static const char *default_font = "Sans 14";
|
||||
#define DEFAULT_FONT "Sans 14"
|
||||
static const int transparency = 255;
|
||||
|
||||
struct clr_scheme scheme = {
|
||||
struct clr_scheme schemes[] = {
|
||||
{
|
||||
/* colors */
|
||||
.bg = {.bgra = {15, 15, 15, transparency}},
|
||||
.fg = {.bgra = {45, 45, 45, transparency}},
|
||||
.high = {.bgra = {100, 100, 100, transparency}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
};
|
||||
struct clr_scheme scheme1 = {
|
||||
.font = DEFAULT_FONT,
|
||||
},
|
||||
{
|
||||
/* colors */
|
||||
.bg = {.bgra = {15, 15, 15, transparency}},
|
||||
.fg = {.bgra = {32, 32, 32, transparency}},
|
||||
.high = {.bgra = {100, 100, 100, transparency}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
.font = DEFAULT_FONT,
|
||||
}
|
||||
};
|
||||
|
||||
/* layers is an ordered list of layouts, used to cycle through */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION = 0.14.1
|
||||
VERSION = 0.14.3
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
12
drw.c
12
drw.c
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "drw.h"
|
||||
#include "shm_open.h"
|
||||
#include "math.h"
|
||||
|
||||
void
|
||||
drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
|
||||
@@ -15,8 +16,8 @@ drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
|
||||
}
|
||||
|
||||
ds->scale = s;
|
||||
ds->width = w * s;
|
||||
ds->height = h * s;
|
||||
ds->width = ceil(w * s);
|
||||
ds->height = ceil(h * s);
|
||||
|
||||
setup_buffer(ds);
|
||||
}
|
||||
@@ -30,11 +31,14 @@ drwsurf_flip(struct drwsurf *ds)
|
||||
|
||||
void
|
||||
drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label)
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label,
|
||||
PangoFontDescription *font_description)
|
||||
{
|
||||
|
||||
cairo_save(d->cairo);
|
||||
|
||||
pango_layout_set_font_description(d->layout, font_description);
|
||||
|
||||
cairo_set_source_rgba(
|
||||
d->cairo, color.bgra[2] / (double)255, color.bgra[1] / (double)255,
|
||||
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
||||
@@ -134,8 +138,6 @@ setup_buffer(struct drwsurf *drwsurf)
|
||||
cairo_scale(drwsurf->cairo, drwsurf->scale, drwsurf->scale);
|
||||
cairo_set_antialias(drwsurf->cairo, CAIRO_ANTIALIAS_NONE);
|
||||
drwsurf->layout = pango_cairo_create_layout(drwsurf->cairo);
|
||||
pango_layout_set_font_description(drwsurf->layout,
|
||||
drwsurf->ctx->font_description);
|
||||
pango_layout_set_auto_dir(drwsurf->layout, false);
|
||||
cairo_save(drwsurf->cairo);
|
||||
|
||||
|
||||
4
drw.h
4
drw.h
@@ -6,7 +6,6 @@
|
||||
|
||||
struct drw {
|
||||
struct wl_shm *shm;
|
||||
PangoFontDescription *font_description;
|
||||
};
|
||||
struct drwsurf {
|
||||
uint32_t width, height, size;
|
||||
@@ -41,7 +40,8 @@ void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
|
||||
void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label);
|
||||
uint32_t w, uint32_t h, uint32_t b, const char *label,
|
||||
PangoFontDescription *font_description);
|
||||
|
||||
uint32_t setup_buffer(struct drwsurf *drwsurf);
|
||||
|
||||
|
||||
14
keyboard.c
14
keyboard.c
@@ -555,8 +555,7 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||
label);
|
||||
struct clr_scheme *scheme =
|
||||
(k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
||||
struct clr_scheme *scheme = &kb->schemes[k->scheme];
|
||||
|
||||
switch (type) {
|
||||
case None:
|
||||
@@ -575,7 +574,7 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
}
|
||||
|
||||
drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h,
|
||||
KBD_KEY_BORDER, label);
|
||||
KBD_KEY_BORDER, label, scheme->font_description);
|
||||
wl_surface_damage(kb->surf->surf, k->x, k->y, k->w, k->h);
|
||||
|
||||
if (type == Press || type == Unpress) {
|
||||
@@ -586,12 +585,13 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
kb->last_popup_w = k->w;
|
||||
kb->last_popup_h = k->h;
|
||||
|
||||
drw_fill_rectangle(kb->popup_surf, kb->scheme.bg, k->x,
|
||||
drw_fill_rectangle(kb->popup_surf, scheme->bg, k->x,
|
||||
kb->last_popup_y, k->w, k->h);
|
||||
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
|
||||
KBD_KEY_BORDER, scheme->high);
|
||||
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
|
||||
k->w, k->h, KBD_KEY_BORDER, label);
|
||||
k->w, k->h, KBD_KEY_BORDER, label,
|
||||
scheme->font_description);
|
||||
wl_surface_damage(kb->popup_surf->surf, k->x, kb->last_popup_y, k->w,
|
||||
k->h);
|
||||
}
|
||||
@@ -605,7 +605,7 @@ kbd_draw_layout(struct kbd *kb)
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw layout\n");
|
||||
|
||||
drw_fill_rectangle(d, kb->scheme.bg, 0, 0, kb->w, kb->h);
|
||||
drw_fill_rectangle(d, kb->schemes[0].bg, 0, 0, kb->w, kb->h);
|
||||
|
||||
while (next_key->type != Last) {
|
||||
if ((next_key->type == Pad) || (next_key->type == EndRow)) {
|
||||
@@ -678,7 +678,7 @@ create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
||||
size_t keymap_size = strlen(keymap_template) + 64;
|
||||
char *keymap_str = malloc(keymap_size);
|
||||
sprintf(keymap_str, keymap_template, comp_unichr, comp_shift_unichr);
|
||||
keymap_size = strlen(keymap_str);
|
||||
keymap_size = strlen(keymap_str) + 1;
|
||||
int keymap_fd = os_create_anonymous_file(keymap_size);
|
||||
if (keymap_fd < 0) {
|
||||
die("could not create keymap fd\n");
|
||||
|
||||
@@ -54,6 +54,8 @@ struct clr_scheme {
|
||||
Color high;
|
||||
Color swipe;
|
||||
Color text;
|
||||
char *font;
|
||||
PangoFontDescription *font_description;
|
||||
};
|
||||
|
||||
struct key {
|
||||
@@ -90,8 +92,7 @@ struct kbd {
|
||||
bool debug;
|
||||
|
||||
struct layout *layout;
|
||||
struct clr_scheme scheme;
|
||||
struct clr_scheme scheme1;
|
||||
struct clr_scheme *schemes;
|
||||
|
||||
bool print;
|
||||
bool print_intersect;
|
||||
|
||||
158
main.c
158
main.c
@@ -24,6 +24,9 @@
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
exit(1)
|
||||
|
||||
/* array size */
|
||||
#define countof(x) (sizeof(x) / sizeof(*x))
|
||||
|
||||
/* client state */
|
||||
static const char *namespace = "wlroots";
|
||||
static struct wl_display *display;
|
||||
@@ -43,6 +46,7 @@ static struct wp_fractional_scale_v1 *wfs_draw_surf;
|
||||
static struct wp_fractional_scale_manager_v1 *wfs_mgr;
|
||||
static struct wp_viewport *draw_surf_viewport, *popup_draw_surf_viewport;
|
||||
static struct wp_viewporter *viewporter;
|
||||
static bool popup_xdg_surface_configured;
|
||||
|
||||
struct Output {
|
||||
uint32_t name;
|
||||
@@ -112,6 +116,8 @@ static void seat_handle_name(void *data, struct wl_seat *wl_seat,
|
||||
|
||||
static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output);
|
||||
static void wl_surface_leave(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output);
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface,
|
||||
@@ -152,6 +158,7 @@ static const struct wl_seat_listener seat_listener = {
|
||||
|
||||
static const struct wl_surface_listener surface_listener = {
|
||||
.enter = wl_surface_enter,
|
||||
.leave = wl_surface_leave,
|
||||
};
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
@@ -184,6 +191,10 @@ wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, struct wl_surface *surface, int32_t id,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct key *next_key;
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
@@ -206,6 +217,10 @@ void
|
||||
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, int32_t id)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_release_key(&keyboard, time);
|
||||
}
|
||||
|
||||
@@ -213,6 +228,10 @@ void
|
||||
wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
touch_x = wl_fixed_to_int(x);
|
||||
@@ -261,6 +280,10 @@ void
|
||||
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
cur_x = wl_fixed_to_int(surface_x);
|
||||
cur_y = wl_fixed_to_int(surface_y);
|
||||
|
||||
@@ -273,6 +296,10 @@ void
|
||||
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct key *next_key;
|
||||
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||
|
||||
@@ -298,6 +325,10 @@ void
|
||||
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
uint32_t axis, wl_fixed_t value)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
||||
drwsurf_flip(keyboard.surf);
|
||||
}
|
||||
@@ -339,18 +370,27 @@ void
|
||||
wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output)
|
||||
{
|
||||
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
|
||||
struct Output *old_output = current_output;
|
||||
for (int i = 0; i < wl_outputs_size; i += 1) {
|
||||
if (wl_outputs[i].data == wl_output) {
|
||||
current_output = &wl_outputs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (current_output == old_output) {
|
||||
return;
|
||||
}
|
||||
|
||||
keyboard.preferred_scale = current_output->scale;
|
||||
|
||||
flip_landscape();
|
||||
}
|
||||
|
||||
void
|
||||
wl_surface_leave(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
int physical_width, int physical_height, int subpixel,
|
||||
@@ -421,7 +461,7 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
wl_registry_bind(registry, name, &wl_compositor_interface, 3);
|
||||
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
draw_ctx.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||
if (wl_outputs_size < WL_OUTPUTS_LIMIT) {
|
||||
struct Output *output = &wl_outputs[wl_outputs_size];
|
||||
output->data =
|
||||
@@ -457,10 +497,10 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
void
|
||||
handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
|
||||
{
|
||||
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
|
||||
for (int i = 0; i < wl_outputs_size; i += 1) {
|
||||
if (wl_outputs[i].name == name) {
|
||||
wl_output_destroy(wl_outputs[i].data);
|
||||
for (; i < WL_OUTPUTS_LIMIT - 1; i += 1) {
|
||||
for (; i < wl_outputs_size - 1; i += 1) {
|
||||
wl_outputs[i] = wl_outputs[i + 1];
|
||||
}
|
||||
wl_outputs_size -= 1;
|
||||
@@ -474,6 +514,7 @@ xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
popup_xdg_surface_configured = true;
|
||||
drwsurf_flip(&popup_draw_surf);
|
||||
}
|
||||
|
||||
@@ -485,9 +526,6 @@ static void
|
||||
xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, int32_t x,
|
||||
int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
|
||||
drwsurf_flip(&draw_surf);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -516,7 +554,18 @@ static const struct wp_fractional_scale_v1_listener
|
||||
void
|
||||
flip_landscape()
|
||||
{
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
bool previous_landscape = keyboard.landscape;
|
||||
|
||||
if (current_output) {
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
} else if (wl_outputs_size) {
|
||||
for (int i = 0; i < wl_outputs_size; i += 1) {
|
||||
if (wl_outputs[i].w > wl_outputs[i].h) {
|
||||
keyboard.landscape = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum layout_id layer;
|
||||
if (keyboard.landscape) {
|
||||
@@ -582,6 +631,7 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
wl_surface_set_input_region(popup_draw_surf.surf, empty_region);
|
||||
popup_xdg_surface =
|
||||
xdg_wm_base_get_xdg_surface(wm_base, popup_draw_surf.surf);
|
||||
popup_xdg_surface_configured = false;
|
||||
xdg_surface_add_listener(popup_xdg_surface, &xdg_popup_surface_listener,
|
||||
NULL);
|
||||
popup_xdg_popup = xdg_surface_get_popup(popup_xdg_surface, NULL,
|
||||
@@ -599,9 +649,13 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
}
|
||||
|
||||
wl_surface_commit(popup_draw_surf.surf);
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
drwsurf_flip(&draw_surf);
|
||||
} else {
|
||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -669,6 +723,15 @@ hide()
|
||||
return;
|
||||
}
|
||||
|
||||
if(wfs_draw_surf) {
|
||||
wp_fractional_scale_v1_destroy(wfs_draw_surf);
|
||||
wfs_draw_surf = NULL;
|
||||
}
|
||||
if(draw_surf_viewport) {
|
||||
wp_viewport_destroy(draw_surf_viewport);
|
||||
draw_surf_viewport = NULL;
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||
wl_surface_destroy(draw_surf.surf);
|
||||
layer_surface = NULL;
|
||||
@@ -684,6 +747,8 @@ show()
|
||||
|
||||
wl_display_sync(display);
|
||||
|
||||
flip_landscape();
|
||||
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
wl_surface_add_listener(draw_surf.surf, &surface_listener, NULL);
|
||||
if (wfs_mgr && viewporter) {
|
||||
@@ -695,8 +760,12 @@ show()
|
||||
wp_viewporter_get_viewport(viewporter, draw_surf.surf);
|
||||
}
|
||||
|
||||
struct wl_output *current_output_data = NULL;
|
||||
if (current_output)
|
||||
current_output_data = current_output->data;
|
||||
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
layer_shell, draw_surf.surf, NULL, layer, namespace);
|
||||
layer_shell, draw_surf.surf, current_output_data, layer, namespace);
|
||||
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||
@@ -747,9 +816,9 @@ main(int argc, char **argv)
|
||||
{
|
||||
/* parse command line arguments */
|
||||
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
|
||||
const char *fc_font_pattern = NULL;
|
||||
height = normal_height = KBD_PIXEL_HEIGHT;
|
||||
landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
char *fc_font_pattern = NULL;
|
||||
height = landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
normal_height = KBD_PIXEL_HEIGHT;
|
||||
|
||||
char *tmp;
|
||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||
@@ -764,9 +833,9 @@ main(int argc, char **argv)
|
||||
/* keyboard settings */
|
||||
keyboard.layers = (enum layout_id *)&layers;
|
||||
keyboard.landscape_layers = (enum layout_id *)&landscape_layers;
|
||||
keyboard.scheme = scheme;
|
||||
keyboard.schemes = schemes;
|
||||
keyboard.landscape = true;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.scheme1 = scheme1;
|
||||
keyboard.preferred_scale = 1;
|
||||
keyboard.preferred_fractional_scale = 0;
|
||||
|
||||
@@ -803,7 +872,7 @@ main(int argc, char **argv)
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.bg.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[0].bg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-alpha")) ||
|
||||
(!strcmp(argv[i], "--alpha"))) {
|
||||
if (i >= argc - 1) {
|
||||
@@ -817,68 +886,68 @@ main(int argc, char **argv)
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.fg.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[0].fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-fg-sp")) ||
|
||||
(!strcmp(argv[i], "--fg-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.fg.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[1].fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press")) ||
|
||||
(!strcmp(argv[i], "--press"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.high.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[0].high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press-sp")) ||
|
||||
(!strcmp(argv[i], "--press-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.high.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[1].high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe")) ||
|
||||
(!strcmp(argv[i], "--swipe"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.swipe.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[0].swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe-sp")) ||
|
||||
(!strcmp(argv[i], "--swipe-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.swipe.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[1].swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text")) ||
|
||||
(!strcmp(argv[i], "--text"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.text.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[0].text.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text-sp")) ||
|
||||
(!strcmp(argv[i], "--text-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.text.bgra, argv[++i]);
|
||||
set_kbd_colors(keyboard.schemes[1].text.bgra, argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-H")) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
height = normal_height = atoi(argv[++i]);
|
||||
normal_height = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-L")) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
landscape_height = atoi(argv[++i]);
|
||||
height = landscape_height = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-D")) {
|
||||
keyboard.debug = true;
|
||||
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||
@@ -906,16 +975,17 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (alpha_defined) {
|
||||
keyboard.scheme.bg.bgra[3] = alpha;
|
||||
keyboard.scheme.fg.bgra[3] = alpha;
|
||||
keyboard.scheme.high.bgra[3] = alpha;
|
||||
keyboard.scheme1.bg.bgra[3] = alpha;
|
||||
keyboard.scheme1.fg.bgra[3] = alpha;
|
||||
keyboard.scheme1.high.bgra[3] = alpha;
|
||||
keyboard.schemes[0].bg.bgra[3] = alpha;
|
||||
keyboard.schemes[0].fg.bgra[3] = alpha;
|
||||
keyboard.schemes[0].high.bgra[3] = alpha;
|
||||
keyboard.schemes[1].bg.bgra[3] = alpha;
|
||||
keyboard.schemes[1].fg.bgra[3] = alpha;
|
||||
keyboard.schemes[1].high.bgra[3] = alpha;
|
||||
}
|
||||
|
||||
if (!fc_font_pattern) {
|
||||
fc_font_pattern = default_font;
|
||||
if (fc_font_pattern) {
|
||||
for (i = 0; i < countof(schemes); i++)
|
||||
schemes[i].font = fc_font_pattern;
|
||||
}
|
||||
|
||||
display = wl_display_connect(NULL);
|
||||
@@ -960,8 +1030,10 @@ main(int argc, char **argv)
|
||||
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list,
|
||||
landscape_layer_names_list);
|
||||
|
||||
draw_ctx.font_description =
|
||||
pango_font_description_from_string(fc_font_pattern);
|
||||
for (i = 0; i < countof(schemes); i++) {
|
||||
schemes[i].font_description =
|
||||
pango_font_description_from_string(schemes[i].font);
|
||||
}
|
||||
|
||||
if (!hidden)
|
||||
show();
|
||||
@@ -998,6 +1070,12 @@ main(int argc, char **argv)
|
||||
|
||||
if (fds[WAYLAND_FD].revents & POLLIN)
|
||||
wl_display_dispatch(display);
|
||||
if (fds[WAYLAND_FD].revents & POLLERR) {
|
||||
die("Exceptional condition on wayland socket.\n");
|
||||
}
|
||||
if (fds[WAYLAND_FD].revents & POLLHUP) {
|
||||
die("Wayland socket has been disconnected.\n");
|
||||
}
|
||||
|
||||
if (fds[SIGNAL_FD].revents & POLLIN) {
|
||||
struct signalfd_siginfo si;
|
||||
@@ -1015,8 +1093,10 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (fc_font_pattern != default_font) {
|
||||
if (fc_font_pattern) {
|
||||
free((void *)fc_font_pattern);
|
||||
for (i = 0; i < countof(schemes); i++)
|
||||
schemes[i].font = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user