mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-13 14:34:36 +02:00
applied clang-format (no functional changes), but exempted custom include order in keyboard.c and main.c
This commit is contained in:
committed by
John Sullivan
parent
4695a78e25
commit
bb1eff09be
60
drw.c
60
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user