mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-04-20 15:56:46 +02:00
Merge branch 'jjsullivan5196:master' into feature/desktop-layout
This commit is contained in:
commit
621079c221
@ -2,6 +2,7 @@
|
|||||||
#define config_def_h_INCLUDED
|
#define config_def_h_INCLUDED
|
||||||
|
|
||||||
#define DEFAULT_FONT "Sans 14"
|
#define DEFAULT_FONT "Sans 14"
|
||||||
|
#define DEFAULT_ROUNDING 5
|
||||||
static const int transparency = 255;
|
static const int transparency = 255;
|
||||||
|
|
||||||
struct clr_scheme schemes[] = {
|
struct clr_scheme schemes[] = {
|
||||||
@ -13,6 +14,7 @@ struct clr_scheme schemes[] = {
|
|||||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||||
.text = {.color = UINT32_MAX},
|
.text = {.color = UINT32_MAX},
|
||||||
.font = DEFAULT_FONT,
|
.font = DEFAULT_FONT,
|
||||||
|
.rounding = DEFAULT_ROUNDING,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
/* colors */
|
/* colors */
|
||||||
@ -22,6 +24,7 @@ struct clr_scheme schemes[] = {
|
|||||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||||
.text = {.color = UINT32_MAX},
|
.text = {.color = UINT32_MAX},
|
||||||
.font = DEFAULT_FONT,
|
.font = DEFAULT_FONT,
|
||||||
|
.rounding = DEFAULT_ROUNDING,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
42
config.h
Normal file
42
config.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#ifndef config_def_h_INCLUDED
|
||||||
|
#define config_def_h_INCLUDED
|
||||||
|
|
||||||
|
#define DEFAULT_FONT "Sans 14"
|
||||||
|
static const int transparency = 255;
|
||||||
|
|
||||||
|
struct clr_scheme schemes[] = {
|
||||||
|
{
|
||||||
|
/* colors */
|
||||||
|
.bg = {.bgra = {54, 42, 40, transparency}},
|
||||||
|
.fg = {.bgra = {164, 114, 98, transparency}},
|
||||||
|
.high = {.bgra = {100, 100, 100, transparency}},
|
||||||
|
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||||
|
.text = {.color = UINT32_MAX},
|
||||||
|
.font = DEFAULT_FONT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* colors */
|
||||||
|
.bg = {.bgra = {54, 42, 40, transparency}},
|
||||||
|
.fg = {.bgra = {90, 71, 68, transparency}},
|
||||||
|
.high = {.bgra = {100, 100, 100, transparency}},
|
||||||
|
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||||
|
.text = {.color = UINT32_MAX},
|
||||||
|
.font = DEFAULT_FONT,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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,
|
||||||
|
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
|
||||||
|
LandscapeSpecial,
|
||||||
|
NumLayouts // signals the last item, may not be omitted
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // config_def_h_INCLUDED
|
@ -1,4 +1,4 @@
|
|||||||
VERSION = 0.14.3
|
VERSION = 0.16
|
||||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
MANPREFIX = ${PREFIX}/share/man
|
MANPREFIX = ${PREFIX}/share/man
|
||||||
|
43
drw.c
43
drw.c
@ -71,7 +71,7 @@ drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
|||||||
|
|
||||||
void
|
void
|
||||||
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
uint32_t w, uint32_t h, bool over)
|
uint32_t w, uint32_t h, bool over, int rounding)
|
||||||
{
|
{
|
||||||
cairo_save(d->cairo);
|
cairo_save(d->cairo);
|
||||||
|
|
||||||
@ -81,27 +81,48 @@ drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
|||||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator(d->cairo, CAIRO_OPERATOR_SOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_rectangle(d->cairo, x, y, w, h);
|
if (rounding > 0) {
|
||||||
cairo_set_source_rgba(
|
double radius = rounding / 1.0;
|
||||||
d->cairo, color.bgra[2] / (double)255, color.bgra[1] / (double)255,
|
double degrees = M_PI / 180.0;
|
||||||
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
|
||||||
cairo_fill(d->cairo);
|
|
||||||
|
|
||||||
cairo_restore(d->cairo);
|
cairo_new_sub_path (d->cairo);
|
||||||
|
cairo_arc (d->cairo, x + w - radius, y + radius, radius, -90 * degrees, 0 * degrees);
|
||||||
|
cairo_arc (d->cairo, x + w - radius, y + h - radius, radius, 0 * degrees, 90 * degrees);
|
||||||
|
cairo_arc (d->cairo, x + radius, y + h - radius, radius, 90 * degrees, 180 * degrees);
|
||||||
|
cairo_arc (d->cairo, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
|
||||||
|
cairo_close_path (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_fill (d->cairo);
|
||||||
|
cairo_set_source_rgba(d->cairo, 0, 0, 0, 0.9);
|
||||||
|
cairo_set_line_width(d->cairo, 1.0);
|
||||||
|
cairo_stroke(d->cairo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
|
cairo_fill(d->cairo);
|
||||||
|
|
||||||
|
cairo_restore(d->cairo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
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, int rounding)
|
||||||
{
|
{
|
||||||
drw_do_rectangle(d, color, x, y, w, h, false);
|
drw_do_rectangle(d, color, x, y, w, h, false, rounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
uint32_t w, uint32_t h)
|
uint32_t w, uint32_t h, int rounding)
|
||||||
{
|
{
|
||||||
drw_do_rectangle(d, color, x, y, w, h, true);
|
drw_do_rectangle(d, color, x, y, w, h, true, rounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
6
drw.h
6
drw.h
@ -33,11 +33,11 @@ typedef union {
|
|||||||
void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y,
|
void drw_do_clear(struct drwsurf *d, uint32_t x, uint32_t y,
|
||||||
uint32_t w, uint32_t h);
|
uint32_t w, uint32_t h);
|
||||||
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
uint32_t w, uint32_t h, bool fill);
|
uint32_t w, uint32_t h, bool fill, int rounding);
|
||||||
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);
|
uint32_t w, uint32_t h, int rounding);
|
||||||
void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||||
uint32_t w, uint32_t h);
|
uint32_t w, uint32_t h, int rounding);
|
||||||
|
|
||||||
void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
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 w, uint32_t h, uint32_t b, const char *label,
|
||||||
|
42
keyboard.c
42
keyboard.c
@ -276,13 +276,23 @@ kbd_get_layer_index(struct kbd *kb, struct layout *l)
|
|||||||
void
|
void
|
||||||
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||||
{
|
{
|
||||||
bool unlatch_shift = false;
|
bool unlatch_shift, unlatch_ctrl, unlatch_alt, unlatch_super, unlatch_altgr;
|
||||||
|
unlatch_shift = unlatch_ctrl = unlatch_alt = unlatch_super = unlatch_altgr = false;
|
||||||
|
|
||||||
if (kb->last_press) {
|
if (kb->last_press) {
|
||||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||||
|
unlatch_ctrl = (kb->mods & Ctrl) == Ctrl;
|
||||||
|
unlatch_alt = (kb->mods & Alt) == Alt;
|
||||||
|
unlatch_super = (kb->mods & Super) == Super;
|
||||||
|
unlatch_altgr = (kb->mods & AltGr) == AltGr;
|
||||||
|
|
||||||
if (unlatch_shift) {
|
if (unlatch_shift) kb->mods ^= Shift;
|
||||||
kb->mods ^= Shift;
|
if (unlatch_ctrl) kb->mods ^= Ctrl;
|
||||||
|
if (unlatch_alt) kb->mods ^= Alt;
|
||||||
|
if (unlatch_super) kb->mods ^= Super;
|
||||||
|
if (unlatch_altgr) kb->mods ^= AltGr;
|
||||||
|
|
||||||
|
if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +314,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
|
|||||||
if (kb->compose >= 2) {
|
if (kb->compose >= 2) {
|
||||||
kb->compose = 0;
|
kb->compose = 0;
|
||||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||||
} else if (unlatch_shift) {
|
} else if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||||
kbd_draw_layout(kb);
|
kbd_draw_layout(kb);
|
||||||
} else {
|
} else {
|
||||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||||
@ -418,7 +428,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
|
|||||||
break;
|
break;
|
||||||
case Mod:
|
case Mod:
|
||||||
kb->mods ^= k->code;
|
kb->mods ^= k->code;
|
||||||
if (k->code == Shift) {
|
if ((k->code == Shift) || (k->code == CapsLock)) {
|
||||||
kbd_draw_layout(kb);
|
kbd_draw_layout(kb);
|
||||||
} else {
|
} else {
|
||||||
if (kb->mods & k->code) {
|
if (kb->mods & k->code) {
|
||||||
@ -551,7 +561,7 @@ kbd_clear_last_popup(struct kbd *kb)
|
|||||||
void
|
void
|
||||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
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;
|
const char *label = ((kb->mods & Shift)||(kb->mods & CapsLock)) ? k->shift_label : k->label;
|
||||||
if (kb->debug)
|
if (kb->debug)
|
||||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||||
label);
|
label);
|
||||||
@ -561,15 +571,15 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
|||||||
case None:
|
case None:
|
||||||
case Unpress:
|
case Unpress:
|
||||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||||
scheme->fg);
|
scheme->fg, scheme->rounding);
|
||||||
break;
|
break;
|
||||||
case Press:
|
case Press:
|
||||||
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||||
scheme->high);
|
scheme->high, scheme->rounding);
|
||||||
break;
|
break;
|
||||||
case Swipe:
|
case Swipe:
|
||||||
draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
|
||||||
scheme->swipe);
|
scheme->swipe, scheme->rounding);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,9 +596,9 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
|||||||
kb->last_popup_h = k->h;
|
kb->last_popup_h = k->h;
|
||||||
|
|
||||||
drw_fill_rectangle(kb->popup_surf, scheme->bg, k->x,
|
drw_fill_rectangle(kb->popup_surf, scheme->bg, k->x,
|
||||||
kb->last_popup_y, k->w, k->h);
|
kb->last_popup_y, k->w, k->h, scheme->rounding);
|
||||||
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
|
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
|
||||||
KBD_KEY_BORDER, scheme->high);
|
KBD_KEY_BORDER, scheme->high, scheme->rounding);
|
||||||
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
|
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
|
||||||
k->w, k->h, KBD_KEY_BORDER, label,
|
k->w, k->h, KBD_KEY_BORDER, label,
|
||||||
scheme->font_description);
|
scheme->font_description);
|
||||||
@ -605,7 +615,7 @@ kbd_draw_layout(struct kbd *kb)
|
|||||||
if (kb->debug)
|
if (kb->debug)
|
||||||
fprintf(stderr, "Draw layout\n");
|
fprintf(stderr, "Draw layout\n");
|
||||||
|
|
||||||
drw_fill_rectangle(d, kb->schemes[0].bg, 0, 0, kb->w, kb->h);
|
drw_fill_rectangle(d, kb->schemes[0].bg, 0, 0, kb->w, kb->h, 0);
|
||||||
|
|
||||||
while (next_key->type != Last) {
|
while (next_key->type != Last) {
|
||||||
if ((next_key->type == Pad) || (next_key->type == EndRow)) {
|
if ((next_key->type == Pad) || (next_key->type == EndRow)) {
|
||||||
@ -647,17 +657,17 @@ kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount)
|
|||||||
|
|
||||||
void
|
void
|
||||||
draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t height, uint32_t border, Color color)
|
uint32_t height, uint32_t border, Color color, int rounding)
|
||||||
{
|
{
|
||||||
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||||
height - (border * 2));
|
height - (border * 2), rounding);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t height, uint32_t border, Color color)
|
uint32_t height, uint32_t border, Color color, int rounding)
|
||||||
{
|
{
|
||||||
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||||
height - (border * 2));
|
height - (border * 2), rounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -55,6 +55,7 @@ struct clr_scheme {
|
|||||||
Color swipe;
|
Color swipe;
|
||||||
Color text;
|
Color text;
|
||||||
char *font;
|
char *font;
|
||||||
|
int rounding;
|
||||||
PangoFontDescription *font_description;
|
PangoFontDescription *font_description;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -121,9 +122,9 @@ struct kbd {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t height, uint32_t border, Color color);
|
uint32_t height, uint32_t border, Color color, int rounding);
|
||||||
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||||
uint32_t height, uint32_t border, Color color);
|
uint32_t height, uint32_t border, Color color, int rounding);
|
||||||
|
|
||||||
void kbd_init(struct kbd *kb, struct layout *layouts,
|
void kbd_init(struct kbd *kb, struct layout *layouts,
|
||||||
char *layer_names_list, char *landscape_layer_names_list);
|
char *layer_names_list, char *landscape_layer_names_list);
|
||||||
|
42
main.c
42
main.c
@ -46,6 +46,7 @@ static struct wp_fractional_scale_v1 *wfs_draw_surf;
|
|||||||
static struct wp_fractional_scale_manager_v1 *wfs_mgr;
|
static struct wp_fractional_scale_manager_v1 *wfs_mgr;
|
||||||
static struct wp_viewport *draw_surf_viewport, *popup_draw_surf_viewport;
|
static struct wp_viewport *draw_surf_viewport, *popup_draw_surf_viewport;
|
||||||
static struct wp_viewporter *viewporter;
|
static struct wp_viewporter *viewporter;
|
||||||
|
static bool popup_xdg_surface_configured;
|
||||||
|
|
||||||
struct Output {
|
struct Output {
|
||||||
uint32_t name;
|
uint32_t name;
|
||||||
@ -75,6 +76,7 @@ static int cur_x = -1, cur_y = -1;
|
|||||||
static bool cur_press = false;
|
static bool cur_press = false;
|
||||||
static struct kbd keyboard;
|
static struct kbd keyboard;
|
||||||
static uint32_t height, normal_height, landscape_height;
|
static uint32_t height, normal_height, landscape_height;
|
||||||
|
static int rounding = DEFAULT_ROUNDING;
|
||||||
static bool hidden = false;
|
static bool hidden = false;
|
||||||
|
|
||||||
/* event handler prototypes */
|
/* event handler prototypes */
|
||||||
@ -190,6 +192,10 @@ wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
|||||||
uint32_t time, struct wl_surface *surface, int32_t id,
|
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)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct key *next_key;
|
struct key *next_key;
|
||||||
uint32_t touch_x, touch_y;
|
uint32_t touch_x, touch_y;
|
||||||
|
|
||||||
@ -212,6 +218,10 @@ void
|
|||||||
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||||
uint32_t time, int32_t id)
|
uint32_t time, int32_t id)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
kbd_release_key(&keyboard, time);
|
kbd_release_key(&keyboard, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +229,10 @@ void
|
|||||||
wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t touch_x, touch_y;
|
uint32_t touch_x, touch_y;
|
||||||
|
|
||||||
touch_x = wl_fixed_to_int(x);
|
touch_x = wl_fixed_to_int(x);
|
||||||
@ -267,6 +281,10 @@ void
|
|||||||
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||||
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cur_x = wl_fixed_to_int(surface_x);
|
cur_x = wl_fixed_to_int(surface_x);
|
||||||
cur_y = wl_fixed_to_int(surface_y);
|
cur_y = wl_fixed_to_int(surface_y);
|
||||||
|
|
||||||
@ -279,6 +297,10 @@ void
|
|||||||
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||||
uint32_t time, uint32_t button, uint32_t state)
|
uint32_t time, uint32_t button, uint32_t state)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct key *next_key;
|
struct key *next_key;
|
||||||
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||||
|
|
||||||
@ -304,6 +326,10 @@ void
|
|||||||
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||||
uint32_t axis, wl_fixed_t value)
|
uint32_t axis, wl_fixed_t value)
|
||||||
{
|
{
|
||||||
|
if(!popup_xdg_surface_configured) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
||||||
drwsurf_flip(keyboard.surf);
|
drwsurf_flip(keyboard.surf);
|
||||||
}
|
}
|
||||||
@ -489,6 +515,7 @@ xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
|
|||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
xdg_surface_ack_configure(xdg_surface, serial);
|
xdg_surface_ack_configure(xdg_surface, serial);
|
||||||
|
popup_xdg_surface_configured = true;
|
||||||
drwsurf_flip(&popup_draw_surf);
|
drwsurf_flip(&popup_draw_surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,6 +632,7 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
|||||||
wl_surface_set_input_region(popup_draw_surf.surf, empty_region);
|
wl_surface_set_input_region(popup_draw_surf.surf, empty_region);
|
||||||
popup_xdg_surface =
|
popup_xdg_surface =
|
||||||
xdg_wm_base_get_xdg_surface(wm_base, popup_draw_surf.surf);
|
xdg_wm_base_get_xdg_surface(wm_base, popup_draw_surf.surf);
|
||||||
|
popup_xdg_surface_configured = false;
|
||||||
xdg_surface_add_listener(popup_xdg_surface, &xdg_popup_surface_listener,
|
xdg_surface_add_listener(popup_xdg_surface, &xdg_popup_surface_listener,
|
||||||
NULL);
|
NULL);
|
||||||
popup_xdg_popup = xdg_surface_get_popup(popup_xdg_surface, NULL,
|
popup_xdg_popup = xdg_surface_get_popup(popup_xdg_surface, NULL,
|
||||||
@ -653,6 +681,7 @@ usage(char *argv0)
|
|||||||
" -O - Print intersected keys to standard output\n");
|
" -O - Print intersected keys to standard output\n");
|
||||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||||
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
||||||
|
fprintf(stderr, " -R [int] - Rounding radius in pixels\n");
|
||||||
fprintf(stderr, " --fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
fprintf(stderr, " --fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||||
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
||||||
fprintf(
|
fprintf(
|
||||||
@ -770,7 +799,7 @@ set_kbd_colors(uint8_t *bgra, char *hex)
|
|||||||
// bg, fg, text, high, swipe
|
// bg, fg, text, high, swipe
|
||||||
int length = strlen(hex);
|
int length = strlen(hex);
|
||||||
if (length == 6 || length == 8) {
|
if (length == 6 || length == 8) {
|
||||||
char subhex[2];
|
char subhex[3] = { 0 };
|
||||||
memcpy(subhex, hex, 2);
|
memcpy(subhex, hex, 2);
|
||||||
bgra[2] = (int)strtol(subhex, NULL, 16);
|
bgra[2] = (int)strtol(subhex, NULL, 16);
|
||||||
memcpy(subhex, hex + 2, 2);
|
memcpy(subhex, hex + 2, 2);
|
||||||
@ -921,6 +950,12 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
height = landscape_height = atoi(argv[++i]);
|
height = landscape_height = atoi(argv[++i]);
|
||||||
|
} else if (!strcmp(argv[i], "-R")) {
|
||||||
|
if (i >= argc - 1) {
|
||||||
|
usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
rounding = atoi(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-D")) {
|
} else if (!strcmp(argv[i], "-D")) {
|
||||||
keyboard.debug = true;
|
keyboard.debug = true;
|
||||||
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||||
@ -961,6 +996,11 @@ main(int argc, char **argv)
|
|||||||
schemes[i].font = fc_font_pattern;
|
schemes[i].font = fc_font_pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rounding != DEFAULT_ROUNDING) {
|
||||||
|
for (i = 0; i < countof(schemes); i++)
|
||||||
|
schemes[i].rounding = rounding;
|
||||||
|
}
|
||||||
|
|
||||||
display = wl_display_connect(NULL);
|
display = wl_display_connect(NULL);
|
||||||
if (display == NULL) {
|
if (display == NULL) {
|
||||||
die("Failed to create display\n");
|
die("Failed to create display\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user