commit bb1eff09be8bbd5153376dd8a651e89316c6c73c
parent 4695a78e2520eb83b2f2fd6a6e51ab60d78f1050
Author: Maarten van Gompel <proycon@anaproy.nl>
Date: Sun, 19 Sep 2021 14:23:51 +0200
applied clang-format (no functional changes), but exempted custom include order in keyboard.c and main.c
Diffstat:
M | .clang-format | | | 2 | +- |
M | config.def.h | | | 39 | ++++++++++++++++----------------------- |
M | drw.c | | | 60 | +++++++++++++++++++++++++----------------------------------- |
M | drw.h | | | 19 | +++++++------------ |
M | keyboard.c | | | 94 | +++++++++++++++++++++++++++++++++++++++++++------------------------------------ |
M | keyboard.h | | | 47 | ++++++++++++++++++++++++----------------------- |
M | keymap.mobintl.h | | | 20 | +++++++++----------- |
M | layout.mobintl.h | | | 37 | ++++++++++++++++--------------------- |
M | main.c | | | 70 | ++++++++++++++++++++++++++++++++++------------------------------------ |
M | shm_open.c | | | 12 | ++++-------- |
M | shm_open.h | | | 1 | - |
11 files changed, 187 insertions(+), 214 deletions(-)
diff --git a/.clang-format b/.clang-format
@@ -88,7 +88,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
-SortIncludes: true
+SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
diff --git a/config.def.h b/config.def.h
@@ -4,39 +4,32 @@
static const char *default_font = "Monospace 14";
struct clr_scheme scheme = {
- /* colors */
- .bg = {.bgra = {15, 15, 15, 225}},
- .fg = {.bgra = {45, 45, 45, 225}},
- .high = {.bgra = {100, 100, 100, 225}},
- .text = {.color = UINT32_MAX},
+ /* colors */
+ .bg = {.bgra = {15, 15, 15, 225}},
+ .fg = {.bgra = {45, 45, 45, 225}},
+ .high = {.bgra = {100, 100, 100, 225}},
+ .text = {.color = UINT32_MAX},
};
struct clr_scheme scheme1 = {
- /* colors */
- .bg = {.bgra = {15, 15, 15, 225}},
- .fg = {.bgra = {32, 32, 32, 225}},
- .high = {.bgra = {100, 100, 100, 225}},
- .text = {.color = UINT32_MAX},
+ /* colors */
+ .bg = {.bgra = {15, 15, 15, 225}},
+ .fg = {.bgra = {32, 32, 32, 225}},
+ .high = {.bgra = {100, 100, 100, 225}},
+ .text = {.color = UINT32_MAX},
};
/* layers is an ordered list of layouts, used to cycle through */
static enum layout_id layers[] = {
- Full, //First layout is the default layout on startup
- Special,
- Emoji,
- Simple,
- SimpleGrid,
- Cyrillic,
- Arabic,
- NumLayouts //signals the last item, may not be omitted
+ Full, // First layout is the default layout on startup
+ Special, Emoji, Simple, SimpleGrid, Cyrillic, Arabic,
+ NumLayouts // signals the last item, may not be omitted
};
/* layers is an ordered list of layouts, used to cycle through */
static enum layout_id landscape_layers[] = {
- Landscape, //First layout is the default layout on startup
- Special,
- Emoji,
- NumLayouts //signals the last item, may not be omitted
+ Landscape, // First layout is the default layout on startup
+ Special, Emoji,
+ NumLayouts // signals the last item, may not be omitted
};
#endif // config_def_h_INCLUDED
-
diff --git a/drw.c b/drw.c
@@ -1,6 +1,6 @@
-#include <wayland-client.h>
#include <sys/mman.h>
#include <unistd.h>
+#include <wayland-client.h>
#include "drw.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,
uint32_t time);
-static struct wl_callback_listener frame_listener = {
- .done = surface_frame_callback
-};
+static struct wl_callback_listener frame_listener = {.done =
+ surface_frame_callback};
void
drwsurf_flip(struct drwsurf *ds) {
@@ -46,20 +45,14 @@ surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
}
void
-drw_draw_text(struct drwsurf *d, Color color,
- uint32_t x, uint32_t y,
- uint32_t w, uint32_t h,
- const char *label) {
+drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
+ uint32_t w, uint32_t h, const char *label) {
cairo_save(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_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_move_to(d->cairo, x + (double)w / 2.0, y + (double)h / 2.0);
pango_layout_set_text(d->layout, label, -1);
@@ -67,7 +60,8 @@ drw_draw_text(struct drwsurf *d, Color color,
int 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);
cairo_restore(d->cairo);
@@ -76,19 +70,15 @@ drw_draw_text(struct drwsurf *d, Color color,
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) {
cairo_save(d->cairo);
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
- );
+ 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);
@@ -97,8 +87,7 @@ drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
}
uint32_t
-setup_buffer(struct drwsurf *drwsurf)
-{
+setup_buffer(struct drwsurf *drwsurf) {
int stride = drwsurf->width * 4;
drwsurf->size = stride * drwsurf->height;
@@ -107,31 +96,32 @@ setup_buffer(struct drwsurf *drwsurf)
return 1;
}
- drwsurf->pool_data = mmap(NULL, drwsurf->size,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ drwsurf->pool_data =
+ mmap(NULL, drwsurf->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (drwsurf->pool_data == MAP_FAILED) {
close(fd);
return 1;
}
- struct wl_shm_pool *pool = wl_shm_create_pool(drwsurf->ctx->shm, fd, drwsurf->size);
- drwsurf->buf = wl_shm_pool_create_buffer(pool, 0,
- drwsurf->width, drwsurf->height, stride, WL_SHM_FORMAT_ARGB8888);
+ struct wl_shm_pool *pool =
+ wl_shm_create_pool(drwsurf->ctx->shm, fd, drwsurf->size);
+ drwsurf->buf = wl_shm_pool_create_buffer(
+ pool, 0, drwsurf->width, drwsurf->height, stride, WL_SHM_FORMAT_ARGB8888);
wl_shm_pool_destroy(pool);
close(fd);
- cairo_surface_t *s = cairo_image_surface_create_for_data(drwsurf->pool_data,
- CAIRO_FORMAT_ARGB32,
- drwsurf->width, drwsurf->height, stride);
+ cairo_surface_t *s = cairo_image_surface_create_for_data(
+ drwsurf->pool_data, CAIRO_FORMAT_ARGB32, drwsurf->width, drwsurf->height,
+ stride);
drwsurf->cairo = cairo_create(s);
cairo_scale(drwsurf->cairo, drwsurf->scale, drwsurf->scale);
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);
wl_surface_set_buffer_scale(drwsurf->surf, drwsurf->scale);
return 0;
}
-
diff --git a/drw.h b/drw.h
@@ -31,17 +31,12 @@ typedef union {
uint32_t color;
} Color;
-void
-drw_fill_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,
- const char *label);
-
-uint32_t
-setup_buffer(struct drwsurf *drwsurf);
+void drw_fill_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, const char *label);
+
+uint32_t setup_buffer(struct drwsurf *drwsurf);
#endif
diff --git a/keyboard.c b/keyboard.c
@@ -22,9 +22,10 @@ void
kbd_switch_layout(struct kbd *kb, struct layout *l) {
kb->prevlayout = kb->layout;
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) ||
- (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);
create_and_upload_keymap(kb, kb->layout->keymap_name, 0, 0);
}
@@ -44,8 +45,8 @@ kbd_get_rows(struct layout *l) {
return rows + 1;
}
-
-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) {
char *s;
int i;
bool found;
@@ -54,8 +55,9 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
kb->layouts = layouts;
- for (i = 0; i < NumLayouts - 1; i++);
- fprintf(stderr, "Found %d layouts\n",i);
+ for (i = 0; i < NumLayouts - 1; i++)
+ ;
+ fprintf(stderr, "Found %d layouts\n", i);
kb->layer_index = 0;
@@ -81,9 +83,9 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
fprintf(stderr, "No such layer: %s\n", s);
exit(3);
}
- s = strtok(NULL,",");
+ s = strtok(NULL, ",");
}
- kb->layers[numlayers] = NumLayouts; //mark the end of the sequence
+ kb->layers[numlayers] = NumLayouts; // mark the end of the sequence
if (numlayers == 0) {
fprintf(stderr, "No layers defined\n");
exit(3);
@@ -95,7 +97,7 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
while (lid != NumLayouts) {
lid = kb->layers[++i];
}
- fprintf(stderr, "Found %d layers\n",i);
+ fprintf(stderr, "Found %d layers\n", i);
enum layout_id layer;
if (kb->landscape) {
@@ -150,7 +152,8 @@ struct key *
kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
struct layout *l = kb->layout;
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) {
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)) {
@@ -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) &&
(k->layout)) {
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);
return;
}
@@ -215,7 +219,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
if (kb->print)
kbd_print_key_stdout(kb, k);
if (kb->compose) {
- if (kb->debug) fprintf(stderr, "pressing composed key\n");
+ if (kb->debug)
+ fprintf(stderr, "pressing composed key\n");
kb->compose++;
}
break;
@@ -228,11 +233,11 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
break;
case Layout:
- //switch to the layout determined by the key
+ // switch to the layout determined by the key
kbd_switch_layout(kb, k->layout);
break;
case Compose:
- //switch to the associated layout determined by the *next* keypress
+ // switch to the associated layout determined by the *next* keypress
if (kb->compose == 0) {
kb->compose = 1;
} else {
@@ -241,7 +246,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
kbd_draw_key(kb, k, (bool)kb->compose);
break;
case NextLayer:
- //switch to the next layout in the layer sequence
+ // switch to the next layout in the layer sequence
kb->layer_index++;
enum layout_id layer;
if (kb->landscape) {
@@ -260,15 +265,16 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
kbd_switch_layout(kb, &kb->layouts[layer]);
break;
case BackLayer:
- //switch to the previously active layout
+ // switch to the previously active layout
if (kb->prevlayout)
kbd_switch_layout(kb, kb->prevlayout);
break;
case Copy:
- //copy code as unicode chr by setting a temporary keymap
+ // copy code as unicode chr by setting a temporary keymap
kb->last_press = k;
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);
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
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
kbd_print_key_stdout(struct kbd *kb, struct key *k) {
/* printed keys may slightly differ from the actual output
@@ -292,21 +297,21 @@ kbd_print_key_stdout(struct kbd *kb, struct key *k) {
bool handled = true;
if (k->type == Code) {
switch (k->code) {
- case KEY_SPACE:
- printf(" ");
- break;
- case KEY_ENTER:
- printf("\n");
- break;
- case KEY_BACKSPACE:
- printf("\b");
- break;
- case KEY_TAB:
- printf("\t");
- break;
- default:
- handled = false;
- break;
+ case KEY_SPACE:
+ printf(" ");
+ break;
+ case KEY_ENTER:
+ printf("\n");
+ break;
+ case KEY_BACKSPACE:
+ printf("\b");
+ break;
+ case KEY_TAB:
+ printf("\t");
+ break;
+ default:
+ handled = false;
+ break;
}
} else if (k->type != Copy) {
return;
@@ -325,8 +330,9 @@ void
kbd_draw_key(struct kbd *kb, struct key *k, bool pressed) {
struct drwsurf *d = kb->surf;
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,
- label);
+ 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);
Color *fill = pressed ? &scheme->high : &scheme->fg;
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, *fill);
@@ -338,7 +344,8 @@ kbd_draw_layout(struct kbd *kb) {
struct drwsurf *d = kb->surf;
struct key *next_key = kb->layout->keys;
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);
@@ -357,7 +364,8 @@ void
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
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);
for (int i = 0; i < layoutcount; i++) {
@@ -374,7 +382,7 @@ draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
}
void
-create_and_upload_keymap(struct kbd * kb, const char *name, uint32_t comp_unichr,
+create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
uint32_t comp_shift_unichr) {
int keymap_index = -1;
for (int i = 0; i < NUMKEYMAPS; i++) {
@@ -383,10 +391,10 @@ create_and_upload_keymap(struct kbd * kb, const char *name, uint32_t comp_unichr
}
}
if (keymap_index == -1) {
- fprintf(stderr,"No such keymap defined: %s\n", name);
+ fprintf(stderr, "No such keymap defined: %s\n", name);
exit(9);
}
- const char * keymap_template = keymaps[keymap_index];
+ const char *keymap_template = keymaps[keymap_index];
const size_t keymap_size = strlen(keymap_template) + 64;
char *keymap_str = malloc(keymap_size);
sprintf(keymap_str, keymap_template, comp_unichr, comp_shift_unichr);
@@ -403,7 +411,7 @@ create_and_upload_keymap(struct kbd * kb, const char *name, uint32_t comp_unichr
die("kb.vkbd = NULL\n");
}
strcpy(ptr, keymap_str);
- zwp_virtual_keyboard_v1_keymap(
- kb->vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size);
+ zwp_virtual_keyboard_v1_keymap(kb->vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
+ keymap_fd, keymap_size);
free((void *)keymap_str);
}
diff --git a/keyboard.h b/keyboard.h
@@ -13,17 +13,19 @@ struct layout;
struct kbd;
enum key_type {
- Pad = 0, //Padding, not a pressable key
- Code, //A normal key emitting a keycode
- Mod, //A modifier key
- 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
- Layout, //Layout switch to a specific layout
- BackLayer, //Layout switch to the layout that was previously active
- NextLayer, //Layout switch to the next layout in the layers sequence
- Compose, //Compose modifier key, switches to a specific associated layout upon next keypress
- EndRow, //Incidates the end of a key row
- Last, //Indicated the end of a layout
+ Pad = 0, // Padding, not a pressable key
+ Code, // A normal key emitting a keycode
+ Mod, // A modifier key
+ 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
+ Layout, // Layout switch to a specific layout
+ BackLayer, // Layout switch to the layout that was previously active
+ NextLayer, // Layout switch to the next layout in the layers sequence
+ Compose, // Compose modifier key, switches to a specific associated layout
+ // upon next keypress
+ EndRow, // Incidates the end of a key row
+ Last, // Indicated the end of a layout
};
/* Modifiers passed to the virtual_keyboard protocol. They are based on
@@ -53,12 +55,12 @@ struct key {
const enum key_type type;
const uint32_t
- code; /* code: key scancode or modifier name (see
- * `/usr/include/linux/input-event-codes.h` for scancode names, and
- * `keyboard.h` for modifiers)
- * XKB keycodes are +8 */
- struct layout *layout; // pointer back to the parent layout that holds this
- // key
+ code; /* code: key scancode or modifier name (see
+ * `/usr/include/linux/input-event-codes.h` for scancode names, and
+ * `keyboard.h` for modifiers)
+ * XKB keycodes are +8 */
+ struct layout *layout; // pointer back to the parent layout that holds this
+ // key
const uint32_t code_mod; /* modifier to force when this key is pressed */
uint8_t scheme; // index of the scheme to use
bool reset_mod; /* reset modifiers when clicked */
@@ -99,11 +101,10 @@ struct kbd {
struct zwp_virtual_keyboard_v1 *vkbd;
};
-void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y,
- uint32_t width, uint32_t height, uint32_t border,
- Color color);
+void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
+ uint32_t height, uint32_t border, 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);
struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y);
void kbd_unpress_key(struct kbd *kb, uint32_t time);
@@ -116,8 +117,8 @@ uint8_t kbd_get_rows(struct layout *l);
double kbd_get_row_length(struct key *k);
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,
- uint32_t comp_shift_unichr);
+void create_and_upload_keymap(struct kbd *kb, const char *name,
+ uint32_t comp_unichr, uint32_t comp_shift_unichr);
#ifndef LAYOUT
#error "make sure to define LAYOUT"
diff --git a/keymap.mobintl.h b/keymap.mobintl.h
@@ -1,11 +1,11 @@
#define NUMKEYMAPS 3
-static const char * keymap_names[] = {"latin","cyrillic","arabic"};
+static const char *keymap_names[] = {"latin", "cyrillic", "arabic"};
-static const char * keymaps[NUMKEYMAPS] = {
+static const char *keymaps[NUMKEYMAPS] = {
- //LATIN
- "xkb_keymap {\
+ // LATIN
+ "xkb_keymap {\
xkb_keycodes \"(unnamed)\" {\
minimum = 8;\
maximum = 255;\
@@ -1468,8 +1468,8 @@ xkb_symbols \"(unnamed)\" {\
\
};\
",
- //CYRILLIC
- "xkb_keymap {\
+ // CYRILLIC
+ "xkb_keymap {\
xkb_keycodes \"(unnamed)\" {\
minimum = 8;\
maximum = 255;\
@@ -2931,8 +2931,8 @@ xkb_symbols \"(unnamed)\" {\
\
};\
",
- //ARABIC
- "xkb_keymap {\
+ // ARABIC
+ "xkb_keymap {\
xkb_keycodes \"(unnamed)\" {\
minimum = 8;\
maximum = 255;\
@@ -4389,6 +4389,4 @@ xkb_symbols \"(unnamed)\" {\
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };\
modifier_map Mod5 { <LVL3>, <MDSW> };\
};\
-};"
-};
-
+};"};
diff --git a/layout.mobintl.h b/layout.mobintl.h
@@ -63,21 +63,19 @@ enum layout_id {
NumLayouts,
};
-static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[], keys_cyrillic[],
- keys_arabic[],
- keys_emoji[],
- keys_landscape[],
+static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[],
+ keys_cyrillic[], keys_arabic[], keys_emoji[], keys_landscape[],
keys_compose_a[], keys_compose_e[], keys_compose_y[], keys_compose_u[],
- keys_compose_i[], keys_compose_o[], keys_compose_w[],
- keys_compose_r[], keys_compose_t[], keys_compose_p[], keys_compose_s[],
- keys_compose_d[], keys_compose_f[], keys_compose_g[], keys_compose_h[],
- keys_compose_j[], keys_compose_k[], keys_compose_l[], keys_compose_z[],
- keys_compose_x[], keys_compose_c[], keys_compose_v[], keys_compose_b[],
- keys_compose_n[], keys_compose_m[], keys_compose_math[],
- keys_compose_punctuation[], keys_compose_bracket[], keys_compose_cyr_i[],
- keys_compose_cyr_j[], keys_compose_cyr_e[], keys_compose_cyr_u[],
- keys_compose_cyr_l[], keys_compose_cyr_n[], keys_compose_cyr_tse[],
- keys_compose_cyr_che[], keys_compose_cyr_g[], keys_compose_cyr_k[];
+ keys_compose_i[], keys_compose_o[], keys_compose_w[], keys_compose_r[],
+ keys_compose_t[], keys_compose_p[], keys_compose_s[], keys_compose_d[],
+ keys_compose_f[], keys_compose_g[], keys_compose_h[], keys_compose_j[],
+ keys_compose_k[], keys_compose_l[], keys_compose_z[], keys_compose_x[],
+ keys_compose_c[], keys_compose_v[], keys_compose_b[], keys_compose_n[],
+ keys_compose_m[], keys_compose_math[], keys_compose_punctuation[],
+ keys_compose_bracket[], keys_compose_cyr_i[], keys_compose_cyr_j[],
+ keys_compose_cyr_e[], keys_compose_cyr_u[], keys_compose_cyr_l[],
+ keys_compose_cyr_n[], keys_compose_cyr_tse[], keys_compose_cyr_che[],
+ keys_compose_cyr_g[], keys_compose_cyr_k[];
static struct layout layouts[NumLayouts] = {
[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"},
};
-
-
/* key layouts
*
* define keys like:
@@ -711,14 +707,14 @@ static struct key keys_emoji[] = {
{"😛", "😜", 1.0, Copy, 0x1f61b, 0, 0x1f61c},
{"😮", "😝", 1.0, Copy, 0x1f62e, 0, 0x1f61d},
{"😟", "😞", 1.0, Copy, 0x1f61f, 0, 0x1f61e},
- {"😟", "🥺", 1.0, Copy, 0x1f620, 0, 0x1f97a },
+ {"😟", "🥺", 1.0, Copy, 0x1f620, 0, 0x1f97a},
{"😢", "👿", 1.0, Copy, 0x1f622, 0, 0x1f47f},
{"😭", "😯", 1.0, Copy, 0x1f62d, 0, 0x1f62f},
{"😳", "😕", 1.0, Copy, 0x1f633, 0, 0x1f615},
{"😴", "😵", 1.0, Copy, 0x1f634, 0, 0x1f635},
- {"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme=1},
+ {"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme = 1},
{"", "", 0.0, EndRow},
- {"Abc", "Abc", 1.0, BackLayer, .scheme=1},
+ {"Abc", "Abc", 1.0, BackLayer, .scheme = 1},
{"👆", "👊", 1.0, Copy, 0x1f446, 0, 0x1f44a},
{"👇", "👌", 1.0, Copy, 0x1f447, 0, 0x1f44c},
{"👈", "👏", 1.0, Copy, 0x1f448, 0, 0x1f44f},
@@ -726,7 +722,7 @@ static struct key keys_emoji[] = {
{"👋", "🙌", 1.0, Copy, 0x1f603, 0, 0x1f44c},
{"👍", "✅", 1.0, Copy, 0x1f604, 0, 0x2705},
{"👎", "💪", 1.0, Copy, 0x1f605, 0, 0x1f606},
- {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
{"", "", 0.0, Last},
};
@@ -1460,4 +1456,3 @@ static struct key keys_compose_bracket[] = {
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
{"", "", 0.0, Last},
};
-
diff --git a/main.c b/main.c
@@ -5,9 +5,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <unistd.h>
#include <wayland-client.h>
#include <wchar.h>
-#include <unistd.h>
#include "keyboard.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 */
char *
-estrdup(const char *s)
-{
+estrdup(const char *s) {
char *p;
if (!(p = strdup(s))) {
@@ -236,8 +235,9 @@ void
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {}
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) {
keyboard.landscape = false;
height = normal_height;
@@ -264,28 +264,22 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, i
}
static void
-display_handle_done(void *data, struct wl_output *wl_output)
-{
-}
+display_handle_done(void *data, struct wl_output *wl_output) {}
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;
-
}
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 = {
- .geometry = display_handle_geometry,
- .mode = display_handle_mode,
- .done = display_handle_done,
- .scale = display_handle_scale
-};
+ .geometry = display_handle_geometry,
+ .mode = display_handle_mode,
+ .done = display_handle_done,
+ .scale = display_handle_scale};
void
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
-usage(char *argv0)
-{
- fprintf(stderr, "usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l layers]\n", argv0);
+usage(char *argv0) {
+ fprintf(stderr,
+ "usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l "
+ "layers]\n",
+ argv0);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -D - Enable debug\n");
fprintf(stderr, " -o - Print press keys to standard output\n");
@@ -347,8 +343,7 @@ usage(char *argv0)
}
void
-freeze(int sigint)
-{
+freeze(int sigint) {
signal(SIGUSR1, freeze);
if (!layer_surface) {
return;
@@ -364,8 +359,7 @@ freeze(int sigint)
}
void
-unfreeze(int sigint)
-{
+unfreeze(int sigint) {
signal(SIGUSR2, unfreeze);
if (layer_surface) {
return;
@@ -373,7 +367,8 @@ unfreeze(int sigint)
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_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_exclusive_zone(layer_surface, height);
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_display_roundtrip(display);
@@ -405,14 +401,13 @@ main(int argc, char **argv) {
landscape_height = atoi(tmp);
/* keyboard settings */
- keyboard.layers = (enum layout_id *) &layers;
- keyboard.landscape_layers = (enum layout_id *) &landscape_layers;
+ keyboard.layers = (enum layout_id *)&layers;
+ keyboard.landscape_layers = (enum layout_id *)&landscape_layers;
keyboard.scheme = scheme;
keyboard.layer_index = 0;
keyboard.scheme1 = scheme1;
keyboard.scheme1 = scheme1;
-
int i;
for (i = 1; argv[i]; i++) {
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
@@ -489,11 +484,13 @@ main(int argc, char **argv) {
die("failed to init virtual keyboard_manager\n");
}
- 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_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_exclusive_zone(layer_surface, height);
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_display_roundtrip(display);
@@ -521,7 +519,7 @@ main(int argc, char **argv) {
}
if (fc_font_pattern != default_font) {
- free((void*) fc_font_pattern);
+ free((void *)fc_font_pattern);
}
return 0;
diff --git a/shm_open.c b/shm_open.c
@@ -6,21 +6,19 @@
#include <unistd.h>
static void
-randname(char *buf)
-{
+randname(char *buf) {
struct timespec ts;
long r;
clock_gettime(CLOCK_REALTIME, &ts);
r = ts.tv_nsec;
for (int i = 0; i < 6; ++i) {
- buf[i] = 'A'+(r&15)+(r&16)*2;
+ buf[i] = 'A' + (r & 15) + (r & 16) * 2;
r >>= 5;
}
}
static int
-create_shm_file(void)
-{
+create_shm_file(void) {
int retries = 100;
int fd;
do {
@@ -37,8 +35,7 @@ create_shm_file(void)
}
int
-allocate_shm_file(size_t size)
-{
+allocate_shm_file(size_t size) {
int fd = create_shm_file();
int ret;
if (fd < 0)
@@ -52,4 +49,3 @@ allocate_shm_file(size_t size)
}
return fd;
}
-
diff --git a/shm_open.h b/shm_open.h
@@ -6,4 +6,3 @@ int create_shm_file(void);
int allocate_shm_file(size_t size);
#endif // shm_open_h_INCLUDED
-