mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-12 18:32:48 +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
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
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 */
|
||||
static enum layout_id layers[] = {
|
||||
Full, // First layout is the default layout on startup
|
||||
Special,
|
||||
Emoji,
|
||||
Simple,
|
||||
SimpleGrid,
|
||||
Cyrillic,
|
||||
Arabic,
|
||||
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,
|
||||
Special, Emoji,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
#endif // config_def_h_INCLUDED
|
||||
|
||||
|
56
drw.c
56
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
|
||||
);
|
||||
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);
|
||||
|
||||
@ -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_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;
|
||||
}
|
||||
|
||||
|
13
drw.h
13
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,
|
||||
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);
|
||||
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);
|
||||
uint32_t setup_buffer(struct drwsurf *drwsurf);
|
||||
|
||||
#endif
|
||||
|
36
keyboard.c
36
keyboard.c
@ -22,7 +22,8 @@ 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)) {
|
||||
fprintf(stderr, "Switching to keymap %s\n", kb->layout->keymap_name);
|
||||
@ -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,7 +55,8 @@ void kbd_init(struct kbd *kb, struct layout * layouts, char * layer_names_list)
|
||||
|
||||
kb->layouts = layouts;
|
||||
|
||||
for (i = 0; i < NumLayouts - 1; i++);
|
||||
for (i = 0; i < NumLayouts - 1; i++)
|
||||
;
|
||||
fprintf(stderr, "Found %d layouts\n", i);
|
||||
|
||||
kb->layer_index = 0;
|
||||
@ -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;
|
||||
@ -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
|
||||
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
|
||||
@ -325,7 +330,8 @@ 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,
|
||||
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;
|
||||
@ -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++) {
|
||||
@ -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);
|
||||
}
|
||||
|
15
keyboard.h
15
keyboard.h
@ -16,12 +16,14 @@ 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)
|
||||
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
|
||||
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
|
||||
};
|
||||
@ -99,9 +101,8 @@ 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_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);
|
||||
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"
|
||||
|
@ -4389,6 +4389,4 @@ xkb_symbols \"(unnamed)\" {\
|
||||
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };\
|
||||
modifier_map Mod5 { <LVL3>, <MDSW> };\
|
||||
};\
|
||||
};"
|
||||
};
|
||||
|
||||
};"};
|
||||
|
@ -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:
|
||||
@ -1460,4 +1456,3 @@ static struct key keys_compose_bracket[] = {
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
|
56
main.c
56
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
|
||||
};
|
||||
.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);
|
||||
@ -412,7 +408,6 @@ main(int argc, char **argv) {
|
||||
keyboard.scheme1 = scheme1;
|
||||
keyboard.scheme1 = scheme1;
|
||||
|
||||
|
||||
int i;
|
||||
for (i = 1; argv[i]; i++) {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
10
shm_open.c
10
shm_open.c
@ -6,8 +6,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
randname(char *buf)
|
||||
{
|
||||
randname(char *buf) {
|
||||
struct timespec ts;
|
||||
long r;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
@ -19,8 +18,7 @@ randname(char *buf)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -6,4 +6,3 @@ int create_shm_file(void);
|
||||
int allocate_shm_file(size_t size);
|
||||
|
||||
#endif // shm_open_h_INCLUDED
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user