mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 10:52:47 +01:00
applied clang-format (no functional changes), but exempted custom include order in keyboard.c and main.c
This commit is contained in:
parent
4695a78e25
commit
bb1eff09be
@ -88,7 +88,7 @@ PenaltyExcessCharacter: 1000000
|
|||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
PointerAlignment: Right
|
PointerAlignment: Right
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: true
|
SortIncludes: false
|
||||||
SortUsingDeclarations: true
|
SortUsingDeclarations: true
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: true
|
||||||
|
11
config.def.h
11
config.def.h
@ -21,22 +21,15 @@ struct clr_scheme scheme1 = {
|
|||||||
/* layers is an ordered list of layouts, used to cycle through */
|
/* layers is an ordered list of layouts, used to cycle through */
|
||||||
static enum layout_id layers[] = {
|
static enum layout_id layers[] = {
|
||||||
Full, // First layout is the default layout on startup
|
Full, // First layout is the default layout on startup
|
||||||
Special,
|
Special, Emoji, Simple, SimpleGrid, Cyrillic, Arabic,
|
||||||
Emoji,
|
|
||||||
Simple,
|
|
||||||
SimpleGrid,
|
|
||||||
Cyrillic,
|
|
||||||
Arabic,
|
|
||||||
NumLayouts // signals the last item, may not be omitted
|
NumLayouts // signals the last item, may not be omitted
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layers is an ordered list of layouts, used to cycle through */
|
/* layers is an ordered list of layouts, used to cycle through */
|
||||||
static enum layout_id landscape_layers[] = {
|
static enum layout_id landscape_layers[] = {
|
||||||
Landscape, // First layout is the default layout on startup
|
Landscape, // First layout is the default layout on startup
|
||||||
Special,
|
Special, Emoji,
|
||||||
Emoji,
|
|
||||||
NumLayouts // signals the last item, may not be omitted
|
NumLayouts // signals the last item, may not be omitted
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // config_def_h_INCLUDED
|
#endif // config_def_h_INCLUDED
|
||||||
|
|
||||||
|
56
drw.c
56
drw.c
@ -1,6 +1,6 @@
|
|||||||
#include <wayland-client.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <wayland-client.h>
|
||||||
|
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "shm_open.h"
|
#include "shm_open.h"
|
||||||
@ -23,9 +23,8 @@ drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s) {
|
|||||||
static void surface_frame_callback(void *data, struct wl_callback *cb,
|
static void surface_frame_callback(void *data, struct wl_callback *cb,
|
||||||
uint32_t time);
|
uint32_t time);
|
||||||
|
|
||||||
static struct wl_callback_listener frame_listener = {
|
static struct wl_callback_listener frame_listener = {.done =
|
||||||
.done = surface_frame_callback
|
surface_frame_callback};
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
drwsurf_flip(struct drwsurf *ds) {
|
drwsurf_flip(struct drwsurf *ds) {
|
||||||
@ -46,20 +45,14 @@ surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_draw_text(struct drwsurf *d, Color color,
|
drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
uint32_t x, uint32_t y,
|
uint32_t w, uint32_t h, const char *label) {
|
||||||
uint32_t w, uint32_t h,
|
|
||||||
const char *label) {
|
|
||||||
|
|
||||||
cairo_save(d->cairo);
|
cairo_save(d->cairo);
|
||||||
|
|
||||||
cairo_set_source_rgba(
|
cairo_set_source_rgba(
|
||||||
d->cairo,
|
d->cairo, color.bgra[2] / (double)255, color.bgra[1] / (double)255,
|
||||||
color.bgra[2] / (double)255,
|
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
||||||
color.bgra[1] / (double)255,
|
|
||||||
color.bgra[0] / (double)255,
|
|
||||||
color.bgra[3] / (double)255
|
|
||||||
);
|
|
||||||
cairo_move_to(d->cairo, x + (double)w / 2.0, y + (double)h / 2.0);
|
cairo_move_to(d->cairo, x + (double)w / 2.0, y + (double)h / 2.0);
|
||||||
|
|
||||||
pango_layout_set_text(d->layout, label, -1);
|
pango_layout_set_text(d->layout, label, -1);
|
||||||
@ -67,7 +60,8 @@ drw_draw_text(struct drwsurf *d, Color color,
|
|||||||
int width, height;
|
int width, height;
|
||||||
pango_layout_get_size(d->layout, &width, &height);
|
pango_layout_get_size(d->layout, &width, &height);
|
||||||
|
|
||||||
cairo_rel_move_to(d->cairo, - ((double)width / PANGO_SCALE) / 2, - ((double)height / PANGO_SCALE) / 2);
|
cairo_rel_move_to(d->cairo, -((double)width / PANGO_SCALE) / 2,
|
||||||
|
-((double)height / PANGO_SCALE) / 2);
|
||||||
pango_cairo_show_layout(d->cairo, d->layout);
|
pango_cairo_show_layout(d->cairo, d->layout);
|
||||||
cairo_restore(d->cairo);
|
cairo_restore(d->cairo);
|
||||||
|
|
||||||
@ -83,12 +77,8 @@ drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
|||||||
|
|
||||||
cairo_rectangle(d->cairo, x, y, w, h);
|
cairo_rectangle(d->cairo, x, y, w, h);
|
||||||
cairo_set_source_rgba(
|
cairo_set_source_rgba(
|
||||||
d->cairo,
|
d->cairo, color.bgra[2] / (double)255, color.bgra[1] / (double)255,
|
||||||
color.bgra[2] / (double)255,
|
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
||||||
color.bgra[1] / (double)255,
|
|
||||||
color.bgra[0] / (double)255,
|
|
||||||
color.bgra[3] / (double)255
|
|
||||||
);
|
|
||||||
cairo_fill(d->cairo);
|
cairo_fill(d->cairo);
|
||||||
|
|
||||||
cairo_restore(d->cairo);
|
cairo_restore(d->cairo);
|
||||||
@ -97,8 +87,7 @@ drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
setup_buffer(struct drwsurf *drwsurf)
|
setup_buffer(struct drwsurf *drwsurf) {
|
||||||
{
|
|
||||||
int stride = drwsurf->width * 4;
|
int stride = drwsurf->width * 4;
|
||||||
drwsurf->size = stride * drwsurf->height;
|
drwsurf->size = stride * drwsurf->height;
|
||||||
|
|
||||||
@ -107,31 +96,32 @@ setup_buffer(struct drwsurf *drwsurf)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
drwsurf->pool_data = mmap(NULL, drwsurf->size,
|
drwsurf->pool_data =
|
||||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
mmap(NULL, drwsurf->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (drwsurf->pool_data == MAP_FAILED) {
|
if (drwsurf->pool_data == MAP_FAILED) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_shm_pool *pool = wl_shm_create_pool(drwsurf->ctx->shm, fd, drwsurf->size);
|
struct wl_shm_pool *pool =
|
||||||
drwsurf->buf = wl_shm_pool_create_buffer(pool, 0,
|
wl_shm_create_pool(drwsurf->ctx->shm, fd, drwsurf->size);
|
||||||
drwsurf->width, drwsurf->height, stride, WL_SHM_FORMAT_ARGB8888);
|
drwsurf->buf = wl_shm_pool_create_buffer(
|
||||||
|
pool, 0, drwsurf->width, drwsurf->height, stride, WL_SHM_FORMAT_ARGB8888);
|
||||||
wl_shm_pool_destroy(pool);
|
wl_shm_pool_destroy(pool);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
cairo_surface_t *s = cairo_image_surface_create_for_data(drwsurf->pool_data,
|
cairo_surface_t *s = cairo_image_surface_create_for_data(
|
||||||
CAIRO_FORMAT_ARGB32,
|
drwsurf->pool_data, CAIRO_FORMAT_ARGB32, drwsurf->width, drwsurf->height,
|
||||||
drwsurf->width, drwsurf->height, stride);
|
stride);
|
||||||
|
|
||||||
drwsurf->cairo = cairo_create(s);
|
drwsurf->cairo = cairo_create(s);
|
||||||
cairo_scale(drwsurf->cairo, drwsurf->scale, drwsurf->scale);
|
cairo_scale(drwsurf->cairo, drwsurf->scale, drwsurf->scale);
|
||||||
drwsurf->layout = pango_cairo_create_layout(drwsurf->cairo);
|
drwsurf->layout = pango_cairo_create_layout(drwsurf->cairo);
|
||||||
pango_layout_set_font_description(drwsurf->layout, drwsurf->ctx->font_description);
|
pango_layout_set_font_description(drwsurf->layout,
|
||||||
|
drwsurf->ctx->font_description);
|
||||||
cairo_save(drwsurf->cairo);
|
cairo_save(drwsurf->cairo);
|
||||||
|
|
||||||
wl_surface_set_buffer_scale(drwsurf->surf, drwsurf->scale);
|
wl_surface_set_buffer_scale(drwsurf->surf, drwsurf->scale);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
drw.h
13
drw.h
@ -31,17 +31,12 @@ typedef union {
|
|||||||
uint32_t color;
|
uint32_t color;
|
||||||
} Color;
|
} Color;
|
||||||
|
|
||||||
void
|
void drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
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);
|
||||||
|
|
||||||
void
|
void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
drw_draw_text(struct drwsurf *d, Color color,
|
uint32_t w, uint32_t h, const char *label);
|
||||||
uint32_t x, uint32_t y,
|
|
||||||
uint32_t w, uint32_t h,
|
|
||||||
const char *label);
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t setup_buffer(struct drwsurf *drwsurf);
|
||||||
setup_buffer(struct drwsurf *drwsurf);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
36
keyboard.c
36
keyboard.c
@ -22,7 +22,8 @@ void
|
|||||||
kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
||||||
kb->prevlayout = kb->layout;
|
kb->prevlayout = kb->layout;
|
||||||
kb->layout = l;
|
kb->layout = l;
|
||||||
if (kb->debug) fprintf(stderr, "Switching to layout %s)\n", kb->layout->name);
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "Switching to layout %s)\n", kb->layout->name);
|
||||||
if ((!kb->prevlayout) ||
|
if ((!kb->prevlayout) ||
|
||||||
(strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
|
(strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
|
||||||
fprintf(stderr, "Switching to keymap %s\n", kb->layout->keymap_name);
|
fprintf(stderr, "Switching to keymap %s\n", kb->layout->keymap_name);
|
||||||
@ -44,8 +45,8 @@ kbd_get_rows(struct layout *l) {
|
|||||||
return rows + 1;
|
return rows + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list) {
|
kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
bool found;
|
bool found;
|
||||||
@ -54,7 +55,8 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
|
|||||||
|
|
||||||
kb->layouts = layouts;
|
kb->layouts = layouts;
|
||||||
|
|
||||||
for (i = 0; i < NumLayouts - 1; i++);
|
for (i = 0; i < NumLayouts - 1; i++)
|
||||||
|
;
|
||||||
fprintf(stderr, "Found %d layouts\n", i);
|
fprintf(stderr, "Found %d layouts\n", i);
|
||||||
|
|
||||||
kb->layer_index = 0;
|
kb->layer_index = 0;
|
||||||
@ -150,7 +152,8 @@ struct key *
|
|||||||
kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
|
kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
|
||||||
struct layout *l = kb->layout;
|
struct layout *l = kb->layout;
|
||||||
struct key *k = l->keys;
|
struct key *k = l->keys;
|
||||||
if (kb->debug) fprintf(stderr, "get key: +%d+%d\n", x, y);
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "get key: +%d+%d\n", x, y);
|
||||||
while (k->type != Last) {
|
while (k->type != Last) {
|
||||||
if ((k->type != EndRow) && (k->type != Pad) && (k->type != Pad) &&
|
if ((k->type != EndRow) && (k->type != Pad) && (k->type != Pad) &&
|
||||||
(x >= k->x) && (y >= k->y) && (x < k->x + k->w) && (y < k->y + k->h)) {
|
(x >= k->x) && (y >= k->y) && (x < k->x + k->w) && (y < k->y + k->h)) {
|
||||||
@ -191,7 +194,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
||||||
(k->layout)) {
|
(k->layout)) {
|
||||||
kb->compose++;
|
kb->compose++;
|
||||||
if (kb->debug) fprintf(stderr, "showing compose %d\n", kb->compose);
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "showing compose %d\n", kb->compose);
|
||||||
kbd_switch_layout(kb, k->layout);
|
kbd_switch_layout(kb, k->layout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -215,7 +219,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
if (kb->print)
|
if (kb->print)
|
||||||
kbd_print_key_stdout(kb, k);
|
kbd_print_key_stdout(kb, k);
|
||||||
if (kb->compose) {
|
if (kb->compose) {
|
||||||
if (kb->debug) fprintf(stderr, "pressing composed key\n");
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "pressing composed key\n");
|
||||||
kb->compose++;
|
kb->compose++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -268,7 +273,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
// copy code as unicode chr by setting a temporary keymap
|
// copy code as unicode chr by setting a temporary keymap
|
||||||
kb->last_press = k;
|
kb->last_press = k;
|
||||||
kbd_draw_key(kb, k, true);
|
kbd_draw_key(kb, k, true);
|
||||||
if (kb->debug) fprintf(stderr, "pressing copy key\n");
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "pressing copy key\n");
|
||||||
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code, k->code_mod);
|
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code, k->code_mod);
|
||||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
|
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
|
||||||
@ -281,7 +287,6 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
kbd_print_key_stdout(struct kbd *kb, struct key *k) {
|
kbd_print_key_stdout(struct kbd *kb, struct key *k) {
|
||||||
/* printed keys may slightly differ from the actual output
|
/* printed keys may slightly differ from the actual output
|
||||||
@ -325,7 +330,8 @@ void
|
|||||||
kbd_draw_key(struct kbd *kb, struct key *k, bool pressed) {
|
kbd_draw_key(struct kbd *kb, struct key *k, bool pressed) {
|
||||||
struct drwsurf *d = kb->surf;
|
struct drwsurf *d = kb->surf;
|
||||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
const char *label = (kb->mods & Shift) ? 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,
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||||
label);
|
label);
|
||||||
struct clr_scheme *scheme = (k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
struct clr_scheme *scheme = (k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
||||||
Color *fill = pressed ? &scheme->high : &scheme->fg;
|
Color *fill = pressed ? &scheme->high : &scheme->fg;
|
||||||
@ -338,7 +344,8 @@ kbd_draw_layout(struct kbd *kb) {
|
|||||||
struct drwsurf *d = kb->surf;
|
struct drwsurf *d = kb->surf;
|
||||||
struct key *next_key = kb->layout->keys;
|
struct key *next_key = kb->layout->keys;
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
if (kb->debug) fprintf(stderr, "Draw layout");
|
if (kb->debug)
|
||||||
|
fprintf(stderr, "Draw layout");
|
||||||
|
|
||||||
drw_fill_rectangle(d, kb->scheme.bg, 0, 0, kb->w, kb->h);
|
drw_fill_rectangle(d, kb->scheme.bg, 0, 0, kb->w, kb->h);
|
||||||
|
|
||||||
@ -357,7 +364,8 @@ void
|
|||||||
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
|
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
|
||||||
struct drwsurf *d = kb->surf;
|
struct drwsurf *d = kb->surf;
|
||||||
|
|
||||||
fprintf(stderr, "Resize %dx%d %d, %d layouts\n", kb->w, kb->h, kb->s, layoutcount);
|
fprintf(stderr, "Resize %dx%d %d, %d layouts\n", kb->w, kb->h, kb->s,
|
||||||
|
layoutcount);
|
||||||
|
|
||||||
drwsurf_resize(d, kb->w, kb->h, kb->s);
|
drwsurf_resize(d, kb->w, kb->h, kb->s);
|
||||||
for (int i = 0; i < layoutcount; i++) {
|
for (int i = 0; i < layoutcount; i++) {
|
||||||
@ -403,7 +411,7 @@ create_and_upload_keymap(struct kbd * kb, const char *name, uint32_t comp_unichr
|
|||||||
die("kb.vkbd = NULL\n");
|
die("kb.vkbd = NULL\n");
|
||||||
}
|
}
|
||||||
strcpy(ptr, keymap_str);
|
strcpy(ptr, keymap_str);
|
||||||
zwp_virtual_keyboard_v1_keymap(
|
zwp_virtual_keyboard_v1_keymap(kb->vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
||||||
kb->vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size);
|
keymap_fd, keymap_size);
|
||||||
free((void *)keymap_str);
|
free((void *)keymap_str);
|
||||||
}
|
}
|
||||||
|
15
keyboard.h
15
keyboard.h
@ -16,12 +16,14 @@ enum key_type {
|
|||||||
Pad = 0, // Padding, not a pressable key
|
Pad = 0, // Padding, not a pressable key
|
||||||
Code, // A normal key emitting a keycode
|
Code, // A normal key emitting a keycode
|
||||||
Mod, // A modifier key
|
Mod, // A modifier key
|
||||||
Copy, //Copy key, copies the unicode value specified in code (creates and activates temporary keymap)
|
Copy, // Copy key, copies the unicode value specified in code (creates and
|
||||||
|
// activates temporary keymap)
|
||||||
// used for keys that are not part of the keymap
|
// used for keys that are not part of the keymap
|
||||||
Layout, // Layout switch to a specific layout
|
Layout, // Layout switch to a specific layout
|
||||||
BackLayer, // Layout switch to the layout that was previously active
|
BackLayer, // Layout switch to the layout that was previously active
|
||||||
NextLayer, // Layout switch to the next layout in the layers sequence
|
NextLayer, // Layout switch to the next layout in the layers sequence
|
||||||
Compose, //Compose modifier key, switches to a specific associated layout upon next keypress
|
Compose, // Compose modifier key, switches to a specific associated layout
|
||||||
|
// upon next keypress
|
||||||
EndRow, // Incidates the end of a key row
|
EndRow, // Incidates the end of a key row
|
||||||
Last, // Indicated the end of a layout
|
Last, // Indicated the end of a layout
|
||||||
};
|
};
|
||||||
@ -99,9 +101,8 @@ struct kbd {
|
|||||||
struct zwp_virtual_keyboard_v1 *vkbd;
|
struct zwp_virtual_keyboard_v1 *vkbd;
|
||||||
};
|
};
|
||||||
|
|
||||||
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y,
|
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t width, uint32_t height, uint32_t border,
|
uint32_t height, uint32_t border, Color color);
|
||||||
Color color);
|
|
||||||
|
|
||||||
void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list);
|
void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list);
|
||||||
void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height);
|
void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height);
|
||||||
@ -116,8 +117,8 @@ uint8_t kbd_get_rows(struct layout *l);
|
|||||||
double kbd_get_row_length(struct key *k);
|
double kbd_get_row_length(struct key *k);
|
||||||
void kbd_switch_layout(struct kbd *kb, struct layout *l);
|
void kbd_switch_layout(struct kbd *kb, struct layout *l);
|
||||||
|
|
||||||
void create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
void create_and_upload_keymap(struct kbd *kb, const char *name,
|
||||||
uint32_t comp_shift_unichr);
|
uint32_t comp_unichr, uint32_t comp_shift_unichr);
|
||||||
|
|
||||||
#ifndef LAYOUT
|
#ifndef LAYOUT
|
||||||
#error "make sure to define LAYOUT"
|
#error "make sure to define LAYOUT"
|
||||||
|
@ -4389,6 +4389,4 @@ xkb_symbols \"(unnamed)\" {\
|
|||||||
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };\
|
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };\
|
||||||
modifier_map Mod5 { <LVL3>, <MDSW> };\
|
modifier_map Mod5 { <LVL3>, <MDSW> };\
|
||||||
};\
|
};\
|
||||||
};"
|
};"};
|
||||||
};
|
|
||||||
|
|
||||||
|
@ -63,21 +63,19 @@ enum layout_id {
|
|||||||
NumLayouts,
|
NumLayouts,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[], keys_cyrillic[],
|
static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[],
|
||||||
keys_arabic[],
|
keys_cyrillic[], keys_arabic[], keys_emoji[], keys_landscape[],
|
||||||
keys_emoji[],
|
|
||||||
keys_landscape[],
|
|
||||||
keys_compose_a[], keys_compose_e[], keys_compose_y[], keys_compose_u[],
|
keys_compose_a[], keys_compose_e[], keys_compose_y[], keys_compose_u[],
|
||||||
keys_compose_i[], keys_compose_o[], keys_compose_w[],
|
keys_compose_i[], keys_compose_o[], keys_compose_w[], keys_compose_r[],
|
||||||
keys_compose_r[], keys_compose_t[], keys_compose_p[], keys_compose_s[],
|
keys_compose_t[], keys_compose_p[], keys_compose_s[], keys_compose_d[],
|
||||||
keys_compose_d[], keys_compose_f[], keys_compose_g[], keys_compose_h[],
|
keys_compose_f[], keys_compose_g[], keys_compose_h[], keys_compose_j[],
|
||||||
keys_compose_j[], keys_compose_k[], keys_compose_l[], keys_compose_z[],
|
keys_compose_k[], keys_compose_l[], keys_compose_z[], keys_compose_x[],
|
||||||
keys_compose_x[], keys_compose_c[], keys_compose_v[], keys_compose_b[],
|
keys_compose_c[], keys_compose_v[], keys_compose_b[], keys_compose_n[],
|
||||||
keys_compose_n[], keys_compose_m[], keys_compose_math[],
|
keys_compose_m[], keys_compose_math[], keys_compose_punctuation[],
|
||||||
keys_compose_punctuation[], keys_compose_bracket[], keys_compose_cyr_i[],
|
keys_compose_bracket[], keys_compose_cyr_i[], keys_compose_cyr_j[],
|
||||||
keys_compose_cyr_j[], keys_compose_cyr_e[], keys_compose_cyr_u[],
|
keys_compose_cyr_e[], keys_compose_cyr_u[], keys_compose_cyr_l[],
|
||||||
keys_compose_cyr_l[], keys_compose_cyr_n[], keys_compose_cyr_tse[],
|
keys_compose_cyr_n[], keys_compose_cyr_tse[], keys_compose_cyr_che[],
|
||||||
keys_compose_cyr_che[], keys_compose_cyr_g[], keys_compose_cyr_k[];
|
keys_compose_cyr_g[], keys_compose_cyr_k[];
|
||||||
|
|
||||||
static struct layout layouts[NumLayouts] = {
|
static struct layout layouts[NumLayouts] = {
|
||||||
[Full] = {keys_full, "latin", "full"}, // second parameter is the keymap name
|
[Full] = {keys_full, "latin", "full"}, // second parameter is the keymap name
|
||||||
@ -129,8 +127,6 @@ static struct layout layouts[NumLayouts] = {
|
|||||||
[ComposeCyrK] = {keys_compose_cyr_k, "cyrillic"},
|
[ComposeCyrK] = {keys_compose_cyr_k, "cyrillic"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* key layouts
|
/* key layouts
|
||||||
*
|
*
|
||||||
* define keys like:
|
* define keys like:
|
||||||
@ -1460,4 +1456,3 @@ static struct key keys_compose_bracket[] = {
|
|||||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||||
{"", "", 0.0, Last},
|
{"", "", 0.0, Last},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
56
main.c
56
main.c
@ -5,9 +5,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -127,8 +127,7 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
|
|||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
estrdup(const char *s)
|
estrdup(const char *s) {
|
||||||
{
|
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (!(p = strdup(s))) {
|
if (!(p = strdup(s))) {
|
||||||
@ -236,8 +235,9 @@ void
|
|||||||
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {}
|
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, int physical_width, int physical_height, int subpixel, const char *make, const char *model, int transform)
|
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||||
{
|
int physical_width, int physical_height, int subpixel,
|
||||||
|
const char *make, const char *model, int transform) {
|
||||||
if (transform % 2 == 0 && keyboard.landscape) {
|
if (transform % 2 == 0 && keyboard.landscape) {
|
||||||
keyboard.landscape = false;
|
keyboard.landscape = false;
|
||||||
height = normal_height;
|
height = normal_height;
|
||||||
@ -264,28 +264,22 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_done(void *data, struct wl_output *wl_output)
|
display_handle_done(void *data, struct wl_output *wl_output) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale)
|
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale) {
|
||||||
{
|
|
||||||
keyboard.s = scale;
|
keyboard.s = scale;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int width, int height, int refresh)
|
display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
|
||||||
{
|
int width, int height, int refresh) {}
|
||||||
}
|
|
||||||
|
|
||||||
static const struct wl_output_listener output_listener = {
|
static const struct wl_output_listener output_listener = {
|
||||||
.geometry = display_handle_geometry,
|
.geometry = display_handle_geometry,
|
||||||
.mode = display_handle_mode,
|
.mode = display_handle_mode,
|
||||||
.done = display_handle_done,
|
.done = display_handle_done,
|
||||||
.scale = display_handle_scale
|
.scale = display_handle_scale};
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||||
@ -334,9 +328,11 @@ layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(char *argv0)
|
usage(char *argv0) {
|
||||||
{
|
fprintf(stderr,
|
||||||
fprintf(stderr, "usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l layers]\n", argv0);
|
"usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l "
|
||||||
|
"layers]\n",
|
||||||
|
argv0);
|
||||||
fprintf(stderr, "Options:\n");
|
fprintf(stderr, "Options:\n");
|
||||||
fprintf(stderr, " -D - Enable debug\n");
|
fprintf(stderr, " -D - Enable debug\n");
|
||||||
fprintf(stderr, " -o - Print press keys to standard output\n");
|
fprintf(stderr, " -o - Print press keys to standard output\n");
|
||||||
@ -347,8 +343,7 @@ usage(char *argv0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeze(int sigint)
|
freeze(int sigint) {
|
||||||
{
|
|
||||||
signal(SIGUSR1, freeze);
|
signal(SIGUSR1, freeze);
|
||||||
if (!layer_surface) {
|
if (!layer_surface) {
|
||||||
return;
|
return;
|
||||||
@ -364,8 +359,7 @@ freeze(int sigint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unfreeze(int sigint)
|
unfreeze(int sigint) {
|
||||||
{
|
|
||||||
signal(SIGUSR2, unfreeze);
|
signal(SIGUSR2, unfreeze);
|
||||||
if (layer_surface) {
|
if (layer_surface) {
|
||||||
return;
|
return;
|
||||||
@ -373,7 +367,8 @@ unfreeze(int sigint)
|
|||||||
|
|
||||||
wl_display_sync(display);
|
wl_display_sync(display);
|
||||||
|
|
||||||
draw_surf.surf = wl_compositor_create_surface(compositor);;
|
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||||
|
;
|
||||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||||
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
||||||
|
|
||||||
@ -381,7 +376,8 @@ unfreeze(int sigint)
|
|||||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||||
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, false);
|
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, false);
|
||||||
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener, NULL);
|
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener,
|
||||||
|
NULL);
|
||||||
wl_surface_commit(draw_surf.surf);
|
wl_surface_commit(draw_surf.surf);
|
||||||
|
|
||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
@ -412,7 +408,6 @@ main(int argc, char **argv) {
|
|||||||
keyboard.scheme1 = scheme1;
|
keyboard.scheme1 = scheme1;
|
||||||
keyboard.scheme1 = scheme1;
|
keyboard.scheme1 = scheme1;
|
||||||
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; argv[i]; i++) {
|
for (i = 1; argv[i]; i++) {
|
||||||
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
||||||
@ -491,9 +486,11 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list);
|
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list);
|
||||||
|
|
||||||
draw_surf.surf = wl_compositor_create_surface(compositor);;
|
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||||
|
;
|
||||||
|
|
||||||
draw_ctx.font_description = pango_font_description_from_string(fc_font_pattern);
|
draw_ctx.font_description =
|
||||||
|
pango_font_description_from_string(fc_font_pattern);
|
||||||
|
|
||||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||||
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
||||||
@ -502,7 +499,8 @@ main(int argc, char **argv) {
|
|||||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||||
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, false);
|
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, false);
|
||||||
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener, NULL);
|
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener,
|
||||||
|
NULL);
|
||||||
wl_surface_commit(draw_surf.surf);
|
wl_surface_commit(draw_surf.surf);
|
||||||
|
|
||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
|
10
shm_open.c
10
shm_open.c
@ -6,8 +6,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
randname(char *buf)
|
randname(char *buf) {
|
||||||
{
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
long r;
|
long r;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
@ -19,8 +18,7 @@ randname(char *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_shm_file(void)
|
create_shm_file(void) {
|
||||||
{
|
|
||||||
int retries = 100;
|
int retries = 100;
|
||||||
int fd;
|
int fd;
|
||||||
do {
|
do {
|
||||||
@ -37,8 +35,7 @@ create_shm_file(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
allocate_shm_file(size_t size)
|
allocate_shm_file(size_t size) {
|
||||||
{
|
|
||||||
int fd = create_shm_file();
|
int fd = create_shm_file();
|
||||||
int ret;
|
int ret;
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
@ -52,4 +49,3 @@ allocate_shm_file(size_t size)
|
|||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,4 +6,3 @@ int create_shm_file(void);
|
|||||||
int allocate_shm_file(size_t size);
|
int allocate_shm_file(size_t size);
|
||||||
|
|
||||||
#endif // shm_open_h_INCLUDED
|
#endif // shm_open_h_INCLUDED
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user