mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-14 21:10:07 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
bb237f5afa | |||
b083169ee4 | |||
538b48d08d | |||
de3b9a77e4 | |||
77c6cf4fe6 |
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);
|
||||
}
|
||||
|
45
main.c
45
main.c
@ -115,6 +115,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 +157,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 = {
|
||||
@ -357,6 +360,12 @@ wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
||||
flip_landscape();
|
||||
}
|
||||
|
||||
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,
|
||||
@ -519,7 +528,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) {
|
||||
@ -700,6 +720,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) {
|
||||
@ -711,8 +733,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);
|
||||
@ -764,8 +790,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")))
|
||||
@ -781,6 +807,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;
|
||||
@ -887,13 +914,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"))) {
|
||||
@ -1016,6 +1043,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