mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-13 14:34:36 +02:00
Compare commits
27 Commits
v0.14.3
...
5648dafc4f
Author | SHA1 | Date | |
---|---|---|---|
5648dafc4f | |||
ca53099c9d | |||
29639c28d5 | |||
745a0b6f53 | |||
c742b58f51 | |||
97efb1de74 | |||
125664afd5 | |||
6041473421 | |||
9cc8931b46 | |||
7d195c8217 | |||
d5db545dcc | |||
7d677d23b7 | |||
fe3257450a | |||
1852b3ab06 | |||
9d130e7fd2 | |||
2f72b176cb | |||
acb1b4eeff | |||
ba778478e6 | |||
d423720553 | |||
e3081fb6e9 | |||
8106d7606d | |||
02261b5f01 | |||
bb237f5afa | |||
b083169ee4 | |||
538b48d08d | |||
de3b9a77e4 | |||
77c6cf4fe6 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,6 +5,7 @@
|
||||
include/config.h
|
||||
.gdb_history
|
||||
*.log
|
||||
wvkbd
|
||||
config.h
|
||||
wvkbd
|
||||
wvkbd-mobintl
|
||||
wvkbd-desktop
|
||||
|
15
Makefile
15
Makefile
@ -10,9 +10,10 @@ PKGS = wayland-client xkbcommon pangocairo
|
||||
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
|
||||
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
|
||||
|
||||
PKG_CONFIG ?= pkg-config
|
||||
CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" -DKEYMAP=\"keymap.${LAYOUT}.h\"
|
||||
CFLAGS += $(shell pkg-config --cflags $(PKGS))
|
||||
LDFLAGS += $(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS))
|
||||
LDFLAGS += $(shell $(PKG_CONFIG) --libs $(PKGS)) -lm -lutil -lrt
|
||||
|
||||
WAYLAND_HEADERS = $(wildcard proto/*.xml)
|
||||
|
||||
@ -20,9 +21,12 @@ HDRS = $(WAYLAND_HEADERS:.xml=-client-protocol.h)
|
||||
WAYLAND_SRC = $(HDRS:.h=.c)
|
||||
SOURCES = $(WVKBD_SOURCES) $(WAYLAND_SRC)
|
||||
|
||||
SCDOC=scdoc
|
||||
DOCS = wvkbd.1
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: ${BIN}
|
||||
all: ${BIN} ${DOCS}
|
||||
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
@ -39,11 +43,14 @@ wvkbd-${LAYOUT}: config.h $(OBJECTS) layout.${LAYOUT}.h
|
||||
$(CC) -o wvkbd-${LAYOUT} $(OBJECTS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) ${BIN}
|
||||
rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) ${BIN} ${DOCS}
|
||||
|
||||
format:
|
||||
clang-format -i $(WVKBD_SOURCES) $(WVKBD_HEADERS)
|
||||
|
||||
%: %.scd
|
||||
$(SCDOC) < $< > $@
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f ${NAME}-${LAYOUT} ${DESTDIR}${PREFIX}/bin
|
||||
|
@ -1,6 +1,6 @@
|
||||
# wvkbd - On-screen keyboard for wlroots that sucks less
|
||||
|
||||
<img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl.jpg" width=300 /> <img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl-cyrillic.jpg" width=300 />
|
||||
<img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl.jpg" width=300 /> <img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl-cyrillic.jpg" width=300 />
|
||||
|
||||
This project aims to deliver a minimal but practically usable implementation of a wlroots on-screen
|
||||
keyboard in legible C. This will **only** be a keyboard, not a feedback buzzer,
|
||||
@ -25,7 +25,7 @@ new features.
|
||||
- Automatic portrait/landscape detection and subsequent layout switching
|
||||
|
||||
|
||||
<img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl-landscape.jpg" width=640 />
|
||||
<img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl-landscape.jpg" width=640 />
|
||||
|
||||
There are some areas that still need work:
|
||||
|
||||
@ -42,6 +42,8 @@ You'll need the following developer packages
|
||||
- wayland-client
|
||||
- xkbcommon
|
||||
|
||||
You also need [scdoc](https://git.sr.ht/~sircmpwn/scdoc/) to generate the documentation.
|
||||
|
||||
Make any customizations you would like in `config.def.h` and run `make`
|
||||
|
||||
The default set of layouts is called `mobintl` *(mobile international)*, which groups various layouts aimed at mobile devices
|
||||
@ -51,6 +53,8 @@ You can, however, define your own layouts by copying and modifying `layout.mobin
|
||||
(replace `mobintl` for something like `yourlayout`). Then make your layout set using `make LAYOUT=yourlayout`, and
|
||||
the resulting binary will be `wvkbd-yourlayout`
|
||||
|
||||
For example there is now a desktop layout that can be built by `make LAYOUT=desktop` and installed afterwards with `make install LAYOUT=desktop`
|
||||
|
||||
## Usage
|
||||
|
||||
Run `wvkbd-mobintl` (or the binary for your custom layout set).
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define config_def_h_INCLUDED
|
||||
|
||||
#define DEFAULT_FONT "Sans 14"
|
||||
#define DEFAULT_ROUNDING 5
|
||||
static const int transparency = 255;
|
||||
|
||||
struct clr_scheme schemes[] = {
|
||||
@ -13,6 +14,7 @@ struct clr_scheme schemes[] = {
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
.font = DEFAULT_FONT,
|
||||
.rounding = DEFAULT_ROUNDING,
|
||||
},
|
||||
{
|
||||
/* colors */
|
||||
@ -22,6 +24,7 @@ struct clr_scheme schemes[] = {
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
.font = DEFAULT_FONT,
|
||||
.rounding = DEFAULT_ROUNDING,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
VERSION = 0.14.3
|
||||
VERSION = 0.16.1
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
50
drw.c
50
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);
|
||||
}
|
||||
@ -70,7 +71,7 @@ drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||
|
||||
void
|
||||
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool over)
|
||||
uint32_t w, uint32_t h, bool over, int rounding)
|
||||
{
|
||||
cairo_save(d->cairo);
|
||||
|
||||
@ -80,27 +81,50 @@ drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_SOURCE);
|
||||
}
|
||||
|
||||
cairo_rectangle(d->cairo, x, y, w, h);
|
||||
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);
|
||||
cairo_fill(d->cairo);
|
||||
if (rounding > 0) {
|
||||
double radius = rounding / 1.0;
|
||||
double degrees = M_PI / 180.0;
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
cairo_new_sub_path (d->cairo);
|
||||
cairo_arc (d->cairo, x + w - radius, y + radius, radius, -90 * degrees, 0 * degrees);
|
||||
cairo_arc (d->cairo, x + w - radius, y + h - radius, radius, 0 * degrees, 90 * degrees);
|
||||
cairo_arc (d->cairo, x + radius, y + h - radius, radius, 90 * degrees, 180 * degrees);
|
||||
cairo_arc (d->cairo, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
|
||||
cairo_close_path (d->cairo);
|
||||
|
||||
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);
|
||||
cairo_fill (d->cairo);
|
||||
cairo_set_source_rgba(d->cairo, 0, 0, 0, 0.9);
|
||||
cairo_set_line_width(d->cairo, 1.0);
|
||||
cairo_stroke(d->cairo);
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
}
|
||||
else {
|
||||
cairo_rectangle(d->cairo, x, y, w, h);
|
||||
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);
|
||||
cairo_fill(d->cairo);
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h)
|
||||
uint32_t w, uint32_t h, int rounding)
|
||||
{
|
||||
drw_do_rectangle(d, color, x, y, w, h, false);
|
||||
drw_do_rectangle(d, color, x, y, w, h, false, rounding);
|
||||
}
|
||||
|
||||
void
|
||||
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h)
|
||||
uint32_t w, uint32_t h, int rounding)
|
||||
{
|
||||
drw_do_rectangle(d, color, x, y, w, h, true);
|
||||
drw_do_rectangle(d, color, x, y, w, h, true, rounding);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
6
drw.h
6
drw.h
@ -33,11 +33,11 @@ typedef union {
|
||||
void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool fill);
|
||||
uint32_t w, uint32_t h, bool fill, int rounding);
|
||||
void drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
uint32_t w, uint32_t h, int rounding);
|
||||
void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
uint32_t w, uint32_t h, int rounding);
|
||||
|
||||
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,
|
||||
|
47
keyboard.c
47
keyboard.c
@ -3,6 +3,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <ctype.h>
|
||||
#include "keyboard.h"
|
||||
#include "drw.h"
|
||||
#include "os-compatibility.h"
|
||||
@ -276,13 +277,23 @@ kbd_get_layer_index(struct kbd *kb, struct layout *l)
|
||||
void
|
||||
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||
{
|
||||
bool unlatch_shift = false;
|
||||
bool unlatch_shift, unlatch_ctrl, unlatch_alt, unlatch_super, unlatch_altgr;
|
||||
unlatch_shift = unlatch_ctrl = unlatch_alt = unlatch_super = unlatch_altgr = false;
|
||||
|
||||
if (kb->last_press) {
|
||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||
unlatch_ctrl = (kb->mods & Ctrl) == Ctrl;
|
||||
unlatch_alt = (kb->mods & Alt) == Alt;
|
||||
unlatch_super = (kb->mods & Super) == Super;
|
||||
unlatch_altgr = (kb->mods & AltGr) == AltGr;
|
||||
|
||||
if (unlatch_shift) {
|
||||
kb->mods ^= Shift;
|
||||
if (unlatch_shift) kb->mods ^= Shift;
|
||||
if (unlatch_ctrl) kb->mods ^= Ctrl;
|
||||
if (unlatch_alt) kb->mods ^= Alt;
|
||||
if (unlatch_super) kb->mods ^= Super;
|
||||
if (unlatch_altgr) kb->mods ^= AltGr;
|
||||
|
||||
if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -304,7 +315,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||
if (kb->compose >= 2) {
|
||||
kb->compose = 0;
|
||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||
} else if (unlatch_shift) {
|
||||
} else if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||
@ -418,7 +429,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
|
||||
break;
|
||||
case Mod:
|
||||
kb->mods ^= k->code;
|
||||
if (k->code == Shift) {
|
||||
if ((k->code == Shift) || (k->code == CapsLock)) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
if (kb->mods & k->code) {
|
||||
@ -527,7 +538,8 @@ kbd_print_key_stdout(struct kbd *kb, struct key *k)
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
if ((kb->mods & Shift) || (kb->mods & CapsLock))
|
||||
if ((kb->mods & Shift) ||
|
||||
((kb->mods & CapsLock) & (strlen(k->label) == 1 && isalpha(k->label[0]))))
|
||||
printf("%s", k->shift_label);
|
||||
else if (!(kb->mods & Ctrl) && !(kb->mods & Alt) && !(kb->mods & Super))
|
||||
printf("%s", k->label);
|
||||
@ -551,7 +563,8 @@ kbd_clear_last_popup(struct kbd *kb)
|
||||
void
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
{
|
||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
||||
const char *label = ((kb->mods & Shift)||((kb->mods & CapsLock) &&
|
||||
strlen(k->label) == 1 && isalpha(k->label[0]))) ? k->shift_label : k->label;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||
label);
|
||||
@ -561,15 +574,15 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
case None:
|
||||
case Unpress:
|
||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->fg);
|
||||
scheme->fg, scheme->rounding);
|
||||
break;
|
||||
case Press:
|
||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->high);
|
||||
scheme->high, scheme->rounding);
|
||||
break;
|
||||
case Swipe:
|
||||
draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||
scheme->swipe);
|
||||
scheme->swipe, scheme->rounding);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -586,9 +599,9 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
kb->last_popup_h = k->h;
|
||||
|
||||
drw_fill_rectangle(kb->popup_surf, scheme->bg, k->x,
|
||||
kb->last_popup_y, k->w, k->h);
|
||||
kb->last_popup_y, k->w, k->h, scheme->rounding);
|
||||
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
|
||||
KBD_KEY_BORDER, scheme->high);
|
||||
KBD_KEY_BORDER, scheme->high, scheme->rounding);
|
||||
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
|
||||
k->w, k->h, KBD_KEY_BORDER, label,
|
||||
scheme->font_description);
|
||||
@ -605,7 +618,7 @@ kbd_draw_layout(struct kbd *kb)
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw layout\n");
|
||||
|
||||
drw_fill_rectangle(d, kb->schemes[0].bg, 0, 0, kb->w, kb->h);
|
||||
drw_fill_rectangle(d, kb->schemes[0].bg, 0, 0, kb->w, kb->h, 0);
|
||||
|
||||
while (next_key->type != Last) {
|
||||
if ((next_key->type == Pad) || (next_key->type == EndRow)) {
|
||||
@ -647,17 +660,17 @@ kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount)
|
||||
|
||||
void
|
||||
draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color)
|
||||
uint32_t height, uint32_t border, Color color, int rounding)
|
||||
{
|
||||
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
height - (border * 2), rounding);
|
||||
}
|
||||
void
|
||||
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color)
|
||||
uint32_t height, uint32_t border, Color color, int rounding)
|
||||
{
|
||||
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
height - (border * 2), rounding);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -55,6 +55,7 @@ struct clr_scheme {
|
||||
Color swipe;
|
||||
Color text;
|
||||
char *font;
|
||||
int rounding;
|
||||
PangoFontDescription *font_description;
|
||||
};
|
||||
|
||||
@ -121,9 +122,9 @@ struct kbd {
|
||||
};
|
||||
|
||||
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color);
|
||||
uint32_t height, uint32_t border, Color color, int rounding);
|
||||
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color);
|
||||
uint32_t height, uint32_t border, Color color, int rounding);
|
||||
|
||||
void kbd_init(struct kbd *kb, struct layout *layouts,
|
||||
char *layer_names_list, char *landscape_layer_names_list);
|
||||
|
10245
keymap.desktop.h
Normal file
10245
keymap.desktop.h
Normal file
File diff suppressed because it is too large
Load Diff
1769
layout.desktop.h
Normal file
1769
layout.desktop.h
Normal file
File diff suppressed because it is too large
Load Diff
111
main.c
111
main.c
@ -46,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;
|
||||
@ -64,7 +65,7 @@ static struct drw draw_ctx;
|
||||
static struct drwsurf draw_surf, popup_draw_surf;
|
||||
|
||||
/* layer surface parameters */
|
||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
|
||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;
|
||||
static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
@ -75,6 +76,7 @@ static int cur_x = -1, cur_y = -1;
|
||||
static bool cur_press = false;
|
||||
static struct kbd keyboard;
|
||||
static uint32_t height, normal_height, landscape_height;
|
||||
static int rounding = DEFAULT_ROUNDING;
|
||||
static bool hidden = false;
|
||||
|
||||
/* event handler prototypes */
|
||||
@ -115,6 +117,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,
|
||||
@ -128,6 +132,7 @@ static void layer_surface_configure(void *data,
|
||||
static void layer_surface_closed(void *data,
|
||||
struct zwlr_layer_surface_v1 *surface);
|
||||
static void flip_landscape();
|
||||
static void show();
|
||||
|
||||
/* event handlers */
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
@ -155,6 +160,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 = {
|
||||
@ -187,6 +193,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;
|
||||
|
||||
@ -209,6 +219,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);
|
||||
}
|
||||
|
||||
@ -216,6 +230,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);
|
||||
@ -264,6 +282,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);
|
||||
|
||||
@ -276,6 +298,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;
|
||||
|
||||
@ -301,6 +327,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);
|
||||
}
|
||||
@ -357,6 +387,12 @@ wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
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,
|
||||
@ -480,6 +516,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);
|
||||
}
|
||||
|
||||
@ -519,7 +556,13 @@ 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) {
|
||||
keyboard.landscape = wl_outputs[0].w > wl_outputs[0].h;
|
||||
}
|
||||
|
||||
enum layout_id layer;
|
||||
if (keyboard.landscape) {
|
||||
@ -536,10 +579,25 @@ flip_landscape()
|
||||
keyboard.last_abc_layout = keyboard.layout;
|
||||
keyboard.last_abc_index = 0;
|
||||
|
||||
if (layer_surface) {
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
if (layer_surface && previous_landscape != keyboard.landscape) {
|
||||
if (popup_xdg_popup) {
|
||||
xdg_popup_destroy(popup_xdg_popup);
|
||||
popup_xdg_popup = NULL;
|
||||
}
|
||||
if (popup_xdg_surface) {
|
||||
xdg_surface_destroy(popup_xdg_surface);
|
||||
popup_xdg_surface = NULL;
|
||||
}
|
||||
if (popup_draw_surf.surf) {
|
||||
wl_surface_destroy(popup_draw_surf.surf);
|
||||
popup_draw_surf.surf = NULL;
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||
layer_surface = NULL;
|
||||
wl_surface_destroy(draw_surf.surf);
|
||||
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,6 +643,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,
|
||||
@ -633,6 +692,7 @@ usage(char *argv0)
|
||||
" -O - Print intersected keys to standard output\n");
|
||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
||||
fprintf(stderr, " -R [int] - Rounding radius in pixels\n");
|
||||
fprintf(stderr, " --fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
||||
fprintf(
|
||||
@ -700,6 +760,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) {
|
||||
@ -711,8 +773,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);
|
||||
@ -744,7 +810,7 @@ set_kbd_colors(uint8_t *bgra, char *hex)
|
||||
// bg, fg, text, high, swipe
|
||||
int length = strlen(hex);
|
||||
if (length == 6 || length == 8) {
|
||||
char subhex[2];
|
||||
char subhex[3] = { 0 };
|
||||
memcpy(subhex, hex, 2);
|
||||
bgra[2] = (int)strtol(subhex, NULL, 16);
|
||||
memcpy(subhex, hex + 2, 2);
|
||||
@ -764,8 +830,8 @@ main(int argc, char **argv)
|
||||
/* parse command line arguments */
|
||||
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
|
||||
char *fc_font_pattern = NULL;
|
||||
height = normal_height = KBD_PIXEL_HEIGHT;
|
||||
landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
height = landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
normal_height = KBD_PIXEL_HEIGHT;
|
||||
|
||||
char *tmp;
|
||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||
@ -781,6 +847,7 @@ main(int argc, char **argv)
|
||||
keyboard.layers = (enum layout_id *)&layers;
|
||||
keyboard.landscape_layers = (enum layout_id *)&landscape_layers;
|
||||
keyboard.schemes = schemes;
|
||||
keyboard.landscape = true;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.preferred_scale = 1;
|
||||
keyboard.preferred_fractional_scale = 0;
|
||||
@ -887,13 +954,19 @@ main(int argc, char **argv)
|
||||
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], "-R")) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
rounding = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-D")) {
|
||||
keyboard.debug = true;
|
||||
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||
@ -934,6 +1007,11 @@ main(int argc, char **argv)
|
||||
schemes[i].font = fc_font_pattern;
|
||||
}
|
||||
|
||||
if (rounding != DEFAULT_ROUNDING) {
|
||||
for (i = 0; i < countof(schemes); i++)
|
||||
schemes[i].rounding = rounding;
|
||||
}
|
||||
|
||||
display = wl_display_connect(NULL);
|
||||
if (display == NULL) {
|
||||
die("Failed to create display\n");
|
||||
@ -964,6 +1042,9 @@ main(int argc, char **argv)
|
||||
die("virtual_keyboard_manager not available\n");
|
||||
}
|
||||
|
||||
// A second round-trip to receive wl_outputs events
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
empty_region = wl_compositor_create_region(compositor);
|
||||
popup_xdg_positioner = xdg_wm_base_create_positioner(wm_base);
|
||||
|
||||
@ -1016,6 +1097,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;
|
||||
|
76
wvkbd.1
76
wvkbd.1
@ -1,76 +0,0 @@
|
||||
.TH "wvkbd" "1" "2022-03-12"
|
||||
.P
|
||||
.SH NAME
|
||||
.P
|
||||
wvkbd - on-screen keyboard for wlroots
|
||||
.P
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
wvkbd-mobintl [OPTION]...
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
wvkbd is an on-screen keyboard for wlroots that sucks less.
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.P
|
||||
\fB-D\fR
|
||||
.RS 4
|
||||
enable debug
|
||||
.P
|
||||
.RE
|
||||
\fB-o\fR
|
||||
.RS 4
|
||||
print pressed keys to standard output
|
||||
.P
|
||||
.RE
|
||||
\fB-O\fR
|
||||
.RS 4
|
||||
print intersected keys to standard output
|
||||
.P
|
||||
.RE
|
||||
\fB-l\fR
|
||||
.RS 4
|
||||
comma separated list of layers
|
||||
.P
|
||||
.RE
|
||||
\fB--landscape-layers\fR
|
||||
.RS 4
|
||||
comma separated list of layers used in landscape mode
|
||||
.P
|
||||
.RE
|
||||
\fB-H\fR \fIPX\fR
|
||||
.RS 4
|
||||
height in pixels
|
||||
.P
|
||||
.RE
|
||||
\fB-L\fR \fIPX\fR
|
||||
.RS 4
|
||||
landscape height in pixels
|
||||
.P
|
||||
.RE
|
||||
\fB--fn\fR \fIFONT\fR
|
||||
.RS 4
|
||||
set font (e.g: DejaVu Sans 20)
|
||||
.P
|
||||
.RE
|
||||
\fB--hidden\fR
|
||||
.RS 4
|
||||
start hidden (send SIGUSR2 to show, SIGUSR1 to hide, SIGRTMIN to toggle)
|
||||
.P
|
||||
.RE
|
||||
\fB-v\fR, \fB--version\fR
|
||||
.RS 4
|
||||
print version
|
||||
.P
|
||||
.RE
|
||||
\fB-h\fR, \fB--help\fR
|
||||
.RS 4
|
||||
show help
|
||||
.P
|
||||
.RE
|
||||
.SH AUTHORS
|
||||
.P
|
||||
Created by John Sullivan <jsullivan@csumb.edu>, maintained by the Sxmo project in
|
||||
collaboration with other open source contributors. For more information about wvkbd development, see
|
||||
<https://git.sr.ht/~proycon/wvkbd> or <https://github.com/jjsullivan5196/wvkbd>.
|
129
wvkbd.1.scd
Normal file
129
wvkbd.1.scd
Normal file
@ -0,0 +1,129 @@
|
||||
wvkbd(1)
|
||||
|
||||
# NAME
|
||||
|
||||
wvkbd - on-screen virtual keyboard for wayland compositors using wlroots
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
wvkbd-mobintl [OPTIONS]...
|
||||
|
||||
*NOTE*: Your binary may have a different suffix depending on which layout you compiled.
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
This project aims to deliver a minimal but practically usable implementation of
|
||||
a wlroots on-screen keyboard in legible C. This will _only_ be a keyboard, not
|
||||
a feedback buzzer, led blinker, or anything that requires more than what's
|
||||
needed to input text quickly. The end product should be a static codebase that
|
||||
can be patched to add new features.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
*-D*
|
||||
enable debug mode.
|
||||
|
||||
*-o*
|
||||
print pressed keys to standard output.
|
||||
|
||||
*-O*
|
||||
print intersected keys to standard output.
|
||||
|
||||
*-l* _layers_
|
||||
comma separated list of layers in vertical/portrait mode.
|
||||
|
||||
*--landscape-layers* _layers_
|
||||
comma separated list of layers used in horizontal/landscape mode.
|
||||
|
||||
*--list-layers*
|
||||
prints a list of all available layers.
|
||||
|
||||
*-H* _pixels_
|
||||
Height of the keyboard in pixels, for vertical/portrait mode.
|
||||
|
||||
*-L* _pixels_
|
||||
Height of the keyboard in pixels, for horizontal/landscape mode
|
||||
|
||||
*--fn* _font_
|
||||
set font and size (e.g. DejaVu Sans 20)
|
||||
|
||||
*--hidden*
|
||||
Start hidden (send SIGUSR2 to show).
|
||||
|
||||
*--alpha* _int_
|
||||
Set alpha value (i.e. transparency) for all colors [0-255]
|
||||
|
||||
*--bg* _rrggbb|aa_
|
||||
Set color of background
|
||||
|
||||
*--fg* _rrggbb|aa_
|
||||
Set color of keys
|
||||
|
||||
*--fg-sp* _rrggbb|aa_
|
||||
Set color of special keys
|
||||
|
||||
*--press* _rrggbb|aa_
|
||||
Set color of pressed keys
|
||||
|
||||
*--press-sp* _rrggbb|aa_
|
||||
Set color of pressed special keys
|
||||
|
||||
*--swipe* _rrggbb|aa_
|
||||
Set color of swiped keys
|
||||
|
||||
*--swipe-sp* _rrggbb|aa_
|
||||
Set color of swiped special keys
|
||||
|
||||
*--text* _rrggbb|aa_
|
||||
Set color text on keys
|
||||
|
||||
*--text-sp* _rrggbb|aa_
|
||||
Set color text on special keys
|
||||
|
||||
*--version*
|
||||
Print version information
|
||||
|
||||
*-h*, *--help*
|
||||
Print usage help
|
||||
|
||||
|
||||
# SIGNALS
|
||||
|
||||
You can send signals to wvkbd to hide/show it (e.g. using _kill_(1) with _-s_):
|
||||
|
||||
*SIGUSR1*
|
||||
Hide the keyboard.
|
||||
|
||||
*SIGUSR2*
|
||||
Show the keyboard
|
||||
|
||||
*SIGRTMIN*
|
||||
Toggle visibility
|
||||
|
||||
# COMPOSE BUTTON
|
||||
|
||||
The default mobile international layout features a Compose button (*Cmp*)
|
||||
which, when combined with another key, opens up a layout that offers variants
|
||||
for that key. This is similar to functionality that other keyboards implemented
|
||||
using a *long press* (wvkbd has no such notion, holding a key will repeat
|
||||
it like on a physical keyboard).
|
||||
|
||||
For example, press Cmp + a to access variants with diacritics like á,à,â,ä, etc..
|
||||
|
||||
Most layouts also feature the following that are less obvious:
|
||||
|
||||
- Press Cmp and . to access more punctuation
|
||||
- Press Cmp and - or , to access 'mathematical' symbols (+,-,=,etc)
|
||||
- Press Cmp and ' or 0 or 9 to access more brackets and quotes
|
||||
- Press Cmp and q to access emojis
|
||||
|
||||
Last, but not least, pressing Cmp + space or Cmp + ⌨ or Cmp + Abc opens up an
|
||||
index that allows you to immediately jump to any layout by name, even layouts
|
||||
not explicitly added to your layers on startup.
|
||||
|
||||
# AUTHORS
|
||||
|
||||
Created by John Sullivan <jsullivan@csumb.edu>, maintained by the Sxmo project
|
||||
<https://sxmo.org> in collaboration with other open source contributors. For
|
||||
more information about wvkbd development, see <https://git.sr.ht/~proycon/wvkbd>
|
||||
or <https://github.com/jjsullivan5196/wvkbd>.
|
Reference in New Issue
Block a user