mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-12-24 13:56:23 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
764c39633a | ||
|
|
8106d7606d | ||
|
|
bb237f5afa | ||
|
|
b083169ee4 | ||
|
|
538b48d08d | ||
|
|
de3b9a77e4 | ||
|
|
77c6cf4fe6 | ||
|
|
927918ccc5 | ||
|
|
9f8e73b315 | ||
|
|
0e17680041 |
@@ -1,4 +1,4 @@
|
||||
VERSION = 0.14.2
|
||||
VERSION = 0.14.3
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
||||
5
drw.c
5
drw.c
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "drw.h"
|
||||
#include "shm_open.h"
|
||||
#include "math.h"
|
||||
|
||||
void
|
||||
drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
|
||||
@@ -15,8 +16,8 @@ drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s)
|
||||
}
|
||||
|
||||
ds->scale = s;
|
||||
ds->width = w * s;
|
||||
ds->height = h * s;
|
||||
ds->width = ceil(w * s);
|
||||
ds->height = ceil(h * s);
|
||||
|
||||
setup_buffer(ds);
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
||||
size_t keymap_size = strlen(keymap_template) + 64;
|
||||
char *keymap_str = malloc(keymap_size);
|
||||
sprintf(keymap_str, keymap_template, comp_unichr, comp_shift_unichr);
|
||||
keymap_size = strlen(keymap_str);
|
||||
keymap_size = strlen(keymap_str) + 1;
|
||||
int keymap_fd = os_create_anonymous_file(keymap_size);
|
||||
if (keymap_fd < 0) {
|
||||
die("could not create keymap fd\n");
|
||||
|
||||
75
main.c
75
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_viewport *draw_surf_viewport, *popup_draw_surf_viewport;
|
||||
static struct wp_viewporter *viewporter;
|
||||
static bool popup_xdg_surface_configured;
|
||||
|
||||
struct Output {
|
||||
uint32_t name;
|
||||
@@ -115,6 +116,8 @@ static void seat_handle_name(void *data, struct wl_seat *wl_seat,
|
||||
|
||||
static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output);
|
||||
static void wl_surface_leave(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output);
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface,
|
||||
@@ -155,6 +158,7 @@ static const struct wl_seat_listener seat_listener = {
|
||||
|
||||
static const struct wl_surface_listener surface_listener = {
|
||||
.enter = wl_surface_enter,
|
||||
.leave = wl_surface_leave,
|
||||
};
|
||||
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
@@ -187,6 +191,10 @@ 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)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct key *next_key;
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
@@ -209,6 +217,10 @@ void
|
||||
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, int32_t id)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_release_key(&keyboard, time);
|
||||
}
|
||||
|
||||
@@ -216,6 +228,10 @@ 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)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
touch_x = wl_fixed_to_int(x);
|
||||
@@ -264,6 +280,10 @@ void
|
||||
wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
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_y = wl_fixed_to_int(surface_y);
|
||||
|
||||
@@ -276,6 +296,10 @@ void
|
||||
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct key *next_key;
|
||||
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||
|
||||
@@ -301,6 +325,10 @@ void
|
||||
wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
uint32_t axis, wl_fixed_t value)
|
||||
{
|
||||
if(!popup_xdg_surface_configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
||||
drwsurf_flip(keyboard.surf);
|
||||
}
|
||||
@@ -354,12 +382,15 @@ wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
}
|
||||
|
||||
keyboard.preferred_scale = current_output->scale;
|
||||
|
||||
flip_landscape();
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
drwsurf_flip(&draw_surf);
|
||||
}
|
||||
|
||||
void
|
||||
wl_surface_leave(void *data, struct wl_surface *wl_surface,
|
||||
struct wl_output *wl_output) {
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
int physical_width, int physical_height, int subpixel,
|
||||
@@ -483,6 +514,7 @@ xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
popup_xdg_surface_configured = true;
|
||||
drwsurf_flip(&popup_draw_surf);
|
||||
}
|
||||
|
||||
@@ -522,7 +554,18 @@ static const struct wp_fractional_scale_v1_listener
|
||||
void
|
||||
flip_landscape()
|
||||
{
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
bool previous_landscape = keyboard.landscape;
|
||||
|
||||
if (current_output) {
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
} else if (wl_outputs_size) {
|
||||
for (int i = 0; i < wl_outputs_size; i += 1) {
|
||||
if (wl_outputs[i].w > wl_outputs[i].h) {
|
||||
keyboard.landscape = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum layout_id layer;
|
||||
if (keyboard.landscape) {
|
||||
@@ -588,6 +631,7 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
wl_surface_set_input_region(popup_draw_surf.surf, empty_region);
|
||||
popup_xdg_surface =
|
||||
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,
|
||||
NULL);
|
||||
popup_xdg_popup = xdg_surface_get_popup(popup_xdg_surface, NULL,
|
||||
@@ -703,6 +747,8 @@ show()
|
||||
|
||||
wl_display_sync(display);
|
||||
|
||||
flip_landscape();
|
||||
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
wl_surface_add_listener(draw_surf.surf, &surface_listener, NULL);
|
||||
if (wfs_mgr && viewporter) {
|
||||
@@ -714,8 +760,12 @@ show()
|
||||
wp_viewporter_get_viewport(viewporter, draw_surf.surf);
|
||||
}
|
||||
|
||||
struct wl_output *current_output_data = NULL;
|
||||
if (current_output)
|
||||
current_output_data = current_output->data;
|
||||
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
layer_shell, draw_surf.surf, NULL, layer, namespace);
|
||||
layer_shell, draw_surf.surf, current_output_data, layer, namespace);
|
||||
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||
@@ -767,8 +817,8 @@ main(int argc, char **argv)
|
||||
/* parse command line arguments */
|
||||
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
|
||||
char *fc_font_pattern = NULL;
|
||||
height = normal_height = KBD_PIXEL_HEIGHT;
|
||||
landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
height = landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
normal_height = KBD_PIXEL_HEIGHT;
|
||||
|
||||
char *tmp;
|
||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||
@@ -784,6 +834,7 @@ main(int argc, char **argv)
|
||||
keyboard.layers = (enum layout_id *)&layers;
|
||||
keyboard.landscape_layers = (enum layout_id *)&landscape_layers;
|
||||
keyboard.schemes = schemes;
|
||||
keyboard.landscape = true;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.preferred_scale = 1;
|
||||
keyboard.preferred_fractional_scale = 0;
|
||||
@@ -890,13 +941,13 @@ main(int argc, char **argv)
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
height = normal_height = atoi(argv[++i]);
|
||||
normal_height = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-L")) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
landscape_height = atoi(argv[++i]);
|
||||
height = landscape_height = atoi(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-D")) {
|
||||
keyboard.debug = true;
|
||||
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||
@@ -1019,6 +1070,12 @@ main(int argc, char **argv)
|
||||
|
||||
if (fds[WAYLAND_FD].revents & POLLIN)
|
||||
wl_display_dispatch(display);
|
||||
if (fds[WAYLAND_FD].revents & POLLERR) {
|
||||
die("Exceptional condition on wayland socket.\n");
|
||||
}
|
||||
if (fds[WAYLAND_FD].revents & POLLHUP) {
|
||||
die("Wayland socket has been disconnected.\n");
|
||||
}
|
||||
|
||||
if (fds[SIGNAL_FD].revents & POLLIN) {
|
||||
struct signalfd_siginfo si;
|
||||
|
||||
Reference in New Issue
Block a user