mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-14 03:12:47 +01:00
Handle hide and show signals
This commit is contained in:
parent
e73316bd7c
commit
450d43ff44
5
drw.c
5
drw.c
@ -29,8 +29,8 @@ static struct wl_callback_listener frame_listener = {
|
|||||||
|
|
||||||
void
|
void
|
||||||
drwsurf_flip(struct drwsurf *ds) {
|
drwsurf_flip(struct drwsurf *ds) {
|
||||||
struct wl_callback *cb = wl_surface_frame(ds->surf);
|
ds->cb = wl_surface_frame(ds->surf);
|
||||||
wl_callback_add_listener(cb, &frame_listener, (void *)ds);
|
wl_callback_add_listener(ds->cb, &frame_listener, (void *)ds);
|
||||||
|
|
||||||
wl_surface_attach(ds->surf, ds->buf, 0, 0);
|
wl_surface_attach(ds->surf, ds->buf, 0, 0);
|
||||||
wl_surface_commit(ds->surf);
|
wl_surface_commit(ds->surf);
|
||||||
@ -40,6 +40,7 @@ void
|
|||||||
surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
||||||
struct drwsurf *ds = (struct drwsurf *)data;
|
struct drwsurf *ds = (struct drwsurf *)data;
|
||||||
wl_callback_destroy(cb);
|
wl_callback_destroy(cb);
|
||||||
|
ds->cb = NULL;
|
||||||
|
|
||||||
drwsurf_flip(ds);
|
drwsurf_flip(ds);
|
||||||
}
|
}
|
||||||
|
1
drw.h
1
drw.h
@ -15,6 +15,7 @@ struct drwsurf {
|
|||||||
struct wl_surface *surf;
|
struct wl_surface *surf;
|
||||||
struct wl_buffer *buf;
|
struct wl_buffer *buf;
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
|
struct wl_callback *cb;
|
||||||
unsigned char *pool_data;
|
unsigned char *pool_data;
|
||||||
|
|
||||||
cairo_t *cairo;
|
cairo_t *cairo;
|
||||||
|
57
main.c
57
main.c
@ -7,6 +7,7 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -42,6 +43,7 @@ static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
|
|||||||
static bool run_display = true;
|
static bool run_display = true;
|
||||||
static int cur_x = -1, cur_y = -1;
|
static int cur_x = -1, cur_y = -1;
|
||||||
static struct kbd keyboard;
|
static struct kbd keyboard;
|
||||||
|
static uint32_t height;
|
||||||
|
|
||||||
/* event handler prototypes */
|
/* event handler prototypes */
|
||||||
static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
@ -320,12 +322,54 @@ usage(char *argv0)
|
|||||||
fprintf(stderr, " -fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
fprintf(stderr, " -fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
freeze(int sigint)
|
||||||
|
{
|
||||||
|
signal(SIGUSR1, freeze);
|
||||||
|
if (!layer_surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||||
|
wl_surface_destroy(draw_surf.surf);
|
||||||
|
layer_surface = NULL;
|
||||||
|
if (draw_surf.cb) {
|
||||||
|
wl_callback_destroy(draw_surf.cb);
|
||||||
|
draw_surf.cb = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unfreeze(int sigint)
|
||||||
|
{
|
||||||
|
signal(SIGUSR2, unfreeze);
|
||||||
|
if (layer_surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_display_sync(display);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||||
|
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);
|
||||||
|
wl_surface_commit(draw_surf.surf);
|
||||||
|
|
||||||
|
wl_display_roundtrip(display);
|
||||||
|
drwsurf_flip(&draw_surf);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv) {
|
main(int argc, char **argv) {
|
||||||
/* parse command line arguments */
|
/* parse command line arguments */
|
||||||
char *layer_names_list = NULL;
|
char *layer_names_list = NULL;
|
||||||
const char *fc_font_pattern = NULL;
|
const char *fc_font_pattern = NULL;
|
||||||
uint32_t height = KBD_PIXEL_HEIGHT;
|
height = KBD_PIXEL_HEIGHT;
|
||||||
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||||
@ -430,7 +474,16 @@ main(int argc, char **argv) {
|
|||||||
wl_display_roundtrip(display);
|
wl_display_roundtrip(display);
|
||||||
drwsurf_flip(&draw_surf);
|
drwsurf_flip(&draw_surf);
|
||||||
|
|
||||||
while (wl_display_dispatch(display) != -1 && run_display) {
|
signal(SIGUSR1, freeze);
|
||||||
|
signal(SIGUSR2, unfreeze);
|
||||||
|
|
||||||
|
while (run_display) {
|
||||||
|
while (wl_display_dispatch(display) != -1 && layer_surface) {
|
||||||
|
}
|
||||||
|
wl_display_roundtrip(display);
|
||||||
|
while (run_display && !layer_surface) {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fc_font_pattern != default_font) {
|
if (fc_font_pattern != default_font) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user