5 Commits

Author SHA1 Message Date
bb237f5afa Re-open the keyboard on the same output it was
Even if the user is focusing another output while the geometry change.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-03-03 11:33:58 +01:00
b083169ee4 Minimise visual glitches when starting
Most of the time, the first frame have to be rendered without knowing
which output is the current one. It means the first window could have
incorrect dimensions. This cause other program surface to shrink,
then grow back.

Let's try a smoother approach:

If we don't know the current output, we could check if one of them is
landscaped. If this is the case, we start landscaped to minimise the
visual glitch.

Also, the compositor might choose to not send any output geometry
information before the first surface role is assigned (sway master
829c75b9). Meaning after our initial set_size request. So we have to start
landscaped, and eventually flip to horizontal.

Thanks to the patch "Skip the first resize when landscaped while
starting", we do not draw multiple time on the buffer when we switch to vertical
mode.

This should cover most of the cases, and produce a more discrete
start.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-03-01 22:54:34 +01:00
538b48d08d fix fractional scalled buffer missing one pixel
Before 1920*1080 scaled 1.40 was giving a buffer width of 1919 pixels.

The buffer dimensions have to be ceiled here, instead of rounded.

The rest of the dimensions have to stay the same, here 1371x120.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-01-30 18:44:05 +01:00
de3b9a77e4 event loop: exit if the wayland socket disappears
(prevents infinite loop when your compositor crashes)

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-01-30 18:42:17 +01:00
77c6cf4fe6 implemented a stub wl_surface_leave
This fixes "listener function for opcode 1 of wl_surface is NULL" error in wayfire 0.8.0

Ref: https://github.com/jjsullivan5196/wvkbd/issues/52
2023-11-10 20:27:40 +01:00
2 changed files with 42 additions and 8 deletions

5
drw.c
View File

@ -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
View File

@ -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;