mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
This is a bit hacky. The main problem is that there is no way to tell cairo to limit the width. It will wrap text accordingly to width and height, it will add ellipsizes if it overlow the box, but if a word width is larger than the box width, it will write it. To avoid that, I make sure we don't go too much to the left, and I redraw the background at the right of the keys. This is not visible cause we damage track correctly the updated buffer coordinates. I also moved the damage tracking from do_rectangle and draw_text to higher draw_key and draw_layout.
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#ifndef __DRW_H
|
|
#define __DRW_H
|
|
|
|
#include <pango/pangocairo.h>
|
|
#include <stdbool.h>
|
|
|
|
struct drw {
|
|
struct wl_shm *shm;
|
|
PangoFontDescription *font_description;
|
|
};
|
|
struct drwsurf {
|
|
uint32_t width, height, scale, size;
|
|
|
|
struct drw *ctx;
|
|
struct wl_surface *surf;
|
|
struct wl_buffer *buf;
|
|
struct wl_shm *shm;
|
|
unsigned char *pool_data;
|
|
|
|
cairo_t *cairo;
|
|
PangoLayout *layout;
|
|
};
|
|
struct kbd;
|
|
|
|
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s);
|
|
void drwsurf_flip(struct drwsurf *ds);
|
|
|
|
typedef union {
|
|
uint8_t bgra[4];
|
|
uint32_t color;
|
|
} Color;
|
|
|
|
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h, bool fill);
|
|
void drw_fill_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);
|
|
|
|
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);
|
|
|
|
uint32_t setup_buffer(struct drwsurf *drwsurf);
|
|
|
|
#endif
|