Break on function definitions

This commit is contained in:
Willow Barraco 2023-09-08 23:14:24 +02:00
parent 1a36f6d5f2
commit a152fd036f
No known key found for this signature in database
GPG Key ID: EABA44759877E02A
6 changed files with 274 additions and 118 deletions

View File

@ -1,2 +1,4 @@
BasedOnStyle: LLVM
IndentWidth: 4
AlwaysBreakAfterDefinitionReturnType: All
BreakBeforeBraces: Linux

41
drw.c
View File

@ -5,7 +5,9 @@
#include "drw.h"
#include "shm_open.h"
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s) {
void
drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
{
if (ds->buf) {
munmap(ds->pool_data, ds->size);
wl_buffer_destroy(ds->buf);
@ -19,13 +21,17 @@ void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s) {
setup_buffer(ds);
}
void drwsurf_flip(struct drwsurf *ds) {
void
drwsurf_flip(struct drwsurf *ds)
{
wl_surface_attach(ds->surf, ds->buf, 0, 0);
wl_surface_commit(ds->surf);
}
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) {
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)
{
cairo_save(d->cairo);
@ -47,8 +53,9 @@ void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
cairo_restore(d->cairo);
}
void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w,
uint32_t h) {
void
drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
{
cairo_save(d->cairo);
cairo_set_operator(d->cairo, CAIRO_OPERATOR_CLEAR);
@ -58,8 +65,10 @@ void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w,
cairo_restore(d->cairo);
}
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
uint32_t w, uint32_t h, bool over) {
void
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
uint32_t w, uint32_t h, bool over)
{
cairo_save(d->cairo);
if (over) {
@ -77,17 +86,23 @@ void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
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) {
void
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
{
drw_do_rectangle(d, color, x, y, w, h, false);
}
void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
uint32_t w, uint32_t h) {
void
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
uint32_t w, uint32_t h)
{
drw_do_rectangle(d, color, x, y, w, h, true);
}
uint32_t setup_buffer(struct drwsurf *drwsurf) {
uint32_t
setup_buffer(struct drwsurf *drwsurf)
{
int stride = drwsurf->width * 4;
drwsurf->size = stride * drwsurf->height;

View File

@ -19,7 +19,9 @@
#endif
#include KEYMAP
void kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index) {
void
kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index)
{
kb->prevlayout = kb->layout;
if ((kb->layer_index != kb->last_abc_index) && (kb->layout->abc)) {
kb->last_abc_layout = kb->layout;
@ -40,7 +42,9 @@ void kbd_switch_layout(struct kbd *kb, struct layout *l, size_t layer_index) {
kbd_draw_layout(kb);
}
void kbd_next_layer(struct kbd *kb, struct key *k, bool invert) {
void
kbd_next_layer(struct kbd *kb, struct key *k, bool invert)
{
size_t layer_index = kb->layer_index;
if ((kb->mods & Ctrl) || (kb->mods & Alt) || (kb->mods & AltGr) ||
((bool)kb->compose)) {
@ -100,7 +104,9 @@ void kbd_next_layer(struct kbd *kb, struct key *k, bool invert) {
kbd_switch_layout(kb, &kb->layouts[layer], layer_index);
}
uint8_t kbd_get_rows(struct layout *l) {
uint8_t
kbd_get_rows(struct layout *l)
{
uint8_t rows = 0;
struct key *k = l->keys;
while (k->type != Last) {
@ -112,7 +118,9 @@ uint8_t kbd_get_rows(struct layout *l) {
return rows + 1;
}
enum layout_id *kbd_init_layers(char *layer_names_list) {
enum layout_id *
kbd_init_layers(char *layer_names_list)
{
enum layout_id *layers;
uint8_t numlayers = 0;
bool found;
@ -150,8 +158,10 @@ enum layout_id *kbd_init_layers(char *layer_names_list) {
return layers;
}
void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list,
char *landscape_layer_names_list) {
void
kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list,
char *landscape_layer_names_list)
{
int i;
fprintf(stderr, "Initializing keyboard\n");
@ -191,7 +201,9 @@ void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list,
create_and_upload_keymap(kb, kb->layout->keymap_name, 0, 0);
}
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)
{
uint32_t x = 0, y = 0;
uint8_t rows = kbd_get_rows(l);
@ -222,7 +234,9 @@ void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
}
}
double kbd_get_row_length(struct key *k) {
double
kbd_get_row_length(struct key *k)
{
double l = 0.0;
while ((k->type != Last) && (k->type != EndRow)) {
l += k->width;
@ -231,7 +245,9 @@ double kbd_get_row_length(struct key *k) {
return l;
}
struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
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)
@ -247,7 +263,9 @@ struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
return NULL;
}
size_t kbd_get_layer_index(struct kbd *kb, struct layout *l) {
size_t
kbd_get_layer_index(struct kbd *kb, struct layout *l)
{
for (size_t i = 0; i < NumLayouts - 1; i++) {
if (l == &kb->layouts[i]) {
return i;
@ -256,7 +274,9 @@ size_t kbd_get_layer_index(struct kbd *kb, struct layout *l) {
return 0;
}
void kbd_unpress_key(struct kbd *kb, uint32_t time) {
void
kbd_unpress_key(struct kbd *kb, uint32_t time)
{
bool unlatch_shift = false;
if (kb->last_press) {
@ -295,7 +315,9 @@ void kbd_unpress_key(struct kbd *kb, uint32_t time) {
}
}
void kbd_release_key(struct kbd *kb, uint32_t time) {
void
kbd_release_key(struct kbd *kb, uint32_t time)
{
kbd_unpress_key(kb, time);
if (kb->print_intersect && kb->last_swipe) {
printf("\n");
@ -311,7 +333,9 @@ void kbd_release_key(struct kbd *kb, uint32_t time) {
drwsurf_flip(kb->popup_surf);
}
void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
void
kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y)
{
// Output intersecting keys
// (for external 'swiping'-based accelerators).
if (kb->print_intersect) {
@ -338,7 +362,9 @@ void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
drwsurf_flip(kb->popup_surf);
}
void kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
void
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
{
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod)) {
if ((k->type == NextLayer) || (k->type == BackLayer) ||
((k->type == Code) && (k->code == KEY_SPACE))) {
@ -471,7 +497,9 @@ void kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
drwsurf_flip(kb->popup_surf);
}
void kbd_print_key_stdout(struct kbd *kb, struct key *k) {
void
kbd_print_key_stdout(struct kbd *kb, struct key *k)
{
/* printed keys may slightly differ from the actual output
* we generally print what is on the key LABEL and only support the normal
* and shift layers. Other modifiers produce no output (Ctrl,Alt)
@ -509,7 +537,9 @@ void kbd_print_key_stdout(struct kbd *kb, struct key *k) {
fflush(stdout);
}
void kbd_clear_last_popup(struct kbd *kb) {
void
kbd_clear_last_popup(struct kbd *kb)
{
if (kb->last_popup_w && kb->last_popup_h) {
drw_do_clear(kb->popup_surf, kb->last_popup_x, kb->last_popup_y,
kb->last_popup_w, kb->last_popup_h);
@ -520,7 +550,9 @@ void kbd_clear_last_popup(struct kbd *kb) {
}
}
void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) {
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;
if (kb->debug)
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
@ -567,7 +599,9 @@ void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) {
}
}
void kbd_draw_layout(struct kbd *kb) {
void
kbd_draw_layout(struct kbd *kb)
{
struct drwsurf *d = kb->surf;
struct key *next_key = kb->layout->keys;
if (kb->debug)
@ -591,7 +625,9 @@ void kbd_draw_layout(struct kbd *kb) {
wl_surface_damage(d->surf, 0, 0, kb->w, kb->h);
}
void kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
void
kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount)
{
fprintf(stderr, "Resize %dx%d %f, %d layouts\n", kb->w, kb->h, kb->scale,
layoutcount);
@ -611,20 +647,25 @@ void kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
kbd_draw_layout(kb);
}
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)
{
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
height - (border * 2));
}
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
uint32_t height, uint32_t border, Color color) {
void
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
uint32_t height, uint32_t border, Color color)
{
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
height - (border * 2));
}
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)
{
int keymap_index = -1;
for (int i = 0; i < NUMKEYMAPS; i++) {
if (!strcmp(keymap_names[i], name)) {

214
main.c
View File

@ -165,7 +165,9 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
/* configuration, allows nested code to access above variables */
char *estrdup(const char *s) {
char *
estrdup(const char *s)
{
char *p;
if (!(p = strdup(s))) {
@ -176,9 +178,11 @@ char *estrdup(const char *s) {
return p;
}
void wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
void
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) {
wl_fixed_t x, wl_fixed_t y)
{
struct key *next_key;
uint32_t touch_x, touch_y;
@ -197,13 +201,17 @@ void wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
}
}
void wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
uint32_t time, int32_t id) {
void
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
uint32_t time, int32_t id)
{
kbd_release_key(&keyboard, time);
}
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) {
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)
{
uint32_t touch_x, touch_y;
touch_x = wl_fixed_to_int(x);
@ -212,27 +220,46 @@ void wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
kbd_motion_key(&keyboard, time, touch_x, touch_y);
}
void wl_touch_frame(void *data, struct wl_touch *wl_touch) {}
void
wl_touch_frame(void *data, struct wl_touch *wl_touch)
{
}
void wl_touch_cancel(void *data, struct wl_touch *wl_touch) {}
void
wl_touch_cancel(void *data, struct wl_touch *wl_touch)
{
}
void wl_touch_shape(void *data, struct wl_touch *wl_touch, int32_t id,
wl_fixed_t major, wl_fixed_t minor) {}
void
wl_touch_shape(void *data, struct wl_touch *wl_touch, int32_t id,
wl_fixed_t major, wl_fixed_t minor)
{
}
void wl_touch_orientation(void *data, struct wl_touch *wl_touch, int32_t id,
wl_fixed_t orientation) {}
void
wl_touch_orientation(void *data, struct wl_touch *wl_touch, int32_t id,
wl_fixed_t orientation)
{
}
void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t surface_x, wl_fixed_t surface_y) {}
void
wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
struct wl_surface *surface, wl_fixed_t surface_x,
wl_fixed_t surface_y)
{
}
void wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface) {
void
wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
struct wl_surface *surface)
{
cur_x = cur_y = -1;
}
void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
wl_fixed_t surface_x, wl_fixed_t surface_y) {
void
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
wl_fixed_t surface_x, wl_fixed_t surface_y)
{
cur_x = wl_fixed_to_int(surface_x);
cur_y = wl_fixed_to_int(surface_y);
@ -241,9 +268,10 @@ void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
}
}
void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, uint32_t time, uint32_t button,
uint32_t state) {
void
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state)
{
struct key *next_key;
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
@ -265,14 +293,18 @@ void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
}
}
void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
uint32_t axis, wl_fixed_t value) {
void
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
uint32_t axis, wl_fixed_t value)
{
kbd_next_layer(&keyboard, NULL, (value >= 0));
drwsurf_flip(keyboard.surf);
}
void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps) {
void
seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps)
{
if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
if (pointer == NULL) {
pointer = wl_seat_get_pointer(wl_seat);
@ -297,10 +329,15 @@ void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
}
}
void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {}
void
seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
{
}
void wl_surface_enter(void *data, struct wl_surface *wl_surface,
struct wl_output *wl_output) {
void
wl_surface_enter(void *data, struct wl_surface *wl_surface,
struct wl_output *wl_output)
{
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
if (wl_outputs[i].data == wl_output) {
current_output = &wl_outputs[i];
@ -311,11 +348,11 @@ void wl_surface_enter(void *data, struct wl_surface *wl_surface,
resize();
}
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) {
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)
{
struct Output *output = data;
// Swap width and height on rotated displays
@ -333,10 +370,14 @@ static void display_handle_geometry(void *data, struct wl_output *wl_output,
};
}
static void display_handle_done(void *data, struct wl_output *wl_output) {}
static void
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) {
static void
display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale)
{
struct Output *output = data;
output->scale = scale;
@ -345,9 +386,11 @@ static void display_handle_scale(void *data, struct wl_output *wl_output,
};
}
static void display_handle_mode(void *data, struct wl_output *wl_output,
uint32_t flags, int width, int height,
int refresh) {}
static void
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,
@ -355,8 +398,9 @@ static const struct wl_output_listener output_listener = {
.done = display_handle_done,
.scale = display_handle_scale};
static void xdg_wm_base_ping(void *data, struct xdg_wm_base *xdg_wm_base,
uint32_t serial) {
static void
xdg_wm_base_ping(void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
{
xdg_wm_base_pong(xdg_wm_base, serial);
}
@ -364,8 +408,10 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
.ping = xdg_wm_base_ping,
};
void handle_global(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version) {
void
handle_global(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version)
{
if (strcmp(interface, wl_compositor_interface.name) == 0) {
compositor =
wl_registry_bind(registry, name, &wl_compositor_interface, 3);
@ -404,8 +450,9 @@ void handle_global(void *data, struct wl_registry *registry, uint32_t name,
}
}
void handle_global_remove(void *data, struct wl_registry *registry,
uint32_t name) {
void
handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
{
for (int i = 0; i < WL_OUTPUTS_LIMIT; i += 1) {
if (wl_outputs[i].name == name) {
wl_output_destroy(wl_outputs[i].data);
@ -418,9 +465,10 @@ void handle_global_remove(void *data, struct wl_registry *registry,
}
}
static void xdg_popup_surface_configure(void *data,
struct xdg_surface *xdg_surface,
uint32_t serial) {
static void
xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
uint32_t serial)
{
xdg_surface_ack_configure(xdg_surface, serial);
drwsurf_flip(&popup_draw_surf);
}
@ -429,24 +477,30 @@ static const struct xdg_surface_listener xdg_popup_surface_listener = {
.configure = xdg_popup_surface_configure,
};
static void xdg_popup_configure(void *data, struct xdg_popup *xdg_popup,
int32_t x, int32_t y, int32_t width,
int32_t height) {
static void
xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, int32_t x,
int32_t y, int32_t width, int32_t height)
{
kbd_resize(&keyboard, layouts, NumLayouts);
drwsurf_flip(&draw_surf);
}
static void xdg_popup_done(void *data, struct xdg_popup *xdg_popup) {}
static void
xdg_popup_done(void *data, struct xdg_popup *xdg_popup)
{
}
static const struct xdg_popup_listener xdg_popup_listener = {
.configure = xdg_popup_configure,
.popup_done = xdg_popup_done,
};
static void wp_fractional_scale_prefered_scale(
static void
wp_fractional_scale_prefered_scale(
void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
uint32_t scale) {
uint32_t scale)
{
keyboard.pending_scale = (double)scale / 120;
}
@ -455,7 +509,9 @@ static const struct wp_fractional_scale_v1_listener
.preferred_scale = wp_fractional_scale_prefered_scale,
};
void resize() {
void
resize()
{
keyboard.landscape = current_output->w > current_output->h;
enum layout_id layer;
@ -484,8 +540,10 @@ void resize() {
}
}
void layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
uint32_t serial, uint32_t w, uint32_t h) {
void
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
uint32_t serial, uint32_t w, uint32_t h)
{
if (keyboard.w != w || keyboard.h != h ||
keyboard.scale != keyboard.pending_scale) {
keyboard.w = w;
@ -550,13 +608,17 @@ void layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
zwlr_layer_surface_v1_ack_configure(surface, serial);
}
void layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface) {
void
layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface)
{
zwlr_layer_surface_v1_destroy(surface);
wl_surface_destroy(draw_surf.surf);
run_display = false;
}
void usage(char *argv0) {
void
usage(char *argv0)
{
fprintf(stderr,
"usage: %s [-hov] [-H height] [-L landscape height] [-fn font] [-l "
"layers]\n",
@ -593,7 +655,9 @@ void usage(char *argv0) {
"landscape layers\n");
}
void list_layers() {
void
list_layers()
{
int i;
for (i = 0; i < NumLayouts - 1; i++) {
if (layouts[i].name) {
@ -602,7 +666,9 @@ void list_layers() {
}
}
void hide() {
void
hide()
{
if (!layer_surface) {
return;
}
@ -613,7 +679,9 @@ void hide() {
hidden = true;
}
void show() {
void
show()
{
if (layer_surface) {
return;
}
@ -636,16 +704,24 @@ void show() {
hidden = false;
}
void toggle_visibility() {
void
toggle_visibility()
{
if (hidden)
show();
else
hide();
}
void pipewarn() { fprintf(stderr, "wvkbd: cannot pipe data out.\n"); }
void
pipewarn()
{
fprintf(stderr, "wvkbd: cannot pipe data out.\n");
}
void set_kbd_colors(uint8_t *bgra, char *hex) {
void
set_kbd_colors(uint8_t *bgra, char *hex)
{
// bg, fg, text, high, swipe
int length = strlen(hex);
if (length == 6 || length == 8) {
@ -663,7 +739,9 @@ void set_kbd_colors(uint8_t *bgra, char *hex) {
}
}
int main(int argc, char **argv) {
int
main(int argc, char **argv)
{
/* parse command line arguments */
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
const char *fc_font_pattern = NULL;

View File

@ -34,7 +34,9 @@
#include "os-compatibility.h"
int os_fd_set_cloexec(int fd) {
int
os_fd_set_cloexec(int fd)
{
long flags;
if (fd == -1)
@ -50,7 +52,9 @@ int os_fd_set_cloexec(int fd) {
return 0;
}
static int set_cloexec_or_close(int fd) {
static int
set_cloexec_or_close(int fd)
{
if (os_fd_set_cloexec(fd) != 0) {
close(fd);
return -1;
@ -58,7 +62,9 @@ static int set_cloexec_or_close(int fd) {
return fd;
}
int os_socketpair_cloexec(int domain, int type, int protocol, int *sv) {
int
os_socketpair_cloexec(int domain, int type, int protocol, int *sv)
{
int ret;
#ifdef SOCK_CLOEXEC
@ -82,7 +88,9 @@ int os_socketpair_cloexec(int domain, int type, int protocol, int *sv) {
return -1;
}
int os_epoll_create_cloexec(void) {
int
os_epoll_create_cloexec(void)
{
int fd;
#ifdef EPOLL_CLOEXEC
@ -97,7 +105,9 @@ int os_epoll_create_cloexec(void) {
return set_cloexec_or_close(fd);
}
static int create_tmpfile_cloexec(char *tmpname) {
static int
create_tmpfile_cloexec(char *tmpname)
{
int fd;
#ifdef HAVE_MKOSTEMP
@ -136,7 +146,9 @@ static int create_tmpfile_cloexec(char *tmpname) {
* If posix_fallocate() is not supported, program may receive
* SIGBUS on accessing mmap()'ed file contents instead.
*/
int os_create_anonymous_file(off_t size) {
int
os_create_anonymous_file(off_t size)
{
static const char template[] = "/weston-shared-XXXXXX";
const char *path;
char *name;
@ -186,7 +198,9 @@ int os_create_anonymous_file(off_t size) {
}
#ifndef MISSING_STRCHRNUL
char *strchrnul(const char *s, int c) {
char *
strchrnul(const char *s, int c)
{
while (*s && *s != c)
s++;
return (char *)s;

View File

@ -5,7 +5,9 @@
#include <time.h>
#include <unistd.h>
static void randname(char *buf) {
static void
randname(char *buf)
{
struct timespec ts;
long r;
clock_gettime(CLOCK_REALTIME, &ts);
@ -16,7 +18,9 @@ static void randname(char *buf) {
}
}
static int create_shm_file(void) {
static int
create_shm_file(void)
{
int retries = 100;
int fd;
do {
@ -32,7 +36,9 @@ static int create_shm_file(void) {
return -1;
}
int allocate_shm_file(size_t size) {
int
allocate_shm_file(size_t size)
{
int fd = create_shm_file();
int ret;
if (fd < 0)