add --survive-close feature

This commit is contained in:
Leon Henrik Plickat 2023-11-17 15:27:56 +01:00
commit ab5d2cb726
2 changed files with 24 additions and 1 deletions

View file

@ -17,6 +17,7 @@ wayneko \- Neko on Wayland
.OP \-\-outline\-colour 0xRRGGBB[AA] .OP \-\-outline\-colour 0xRRGGBB[AA]
.OP \-\-type neko|inu|random .OP \-\-type neko|inu|random
.OP \-\-follow\-pointer true|false .OP \-\-follow\-pointer true|false
.OP \-\-survive\-close
.YS .YS
. .
. .
@ -63,6 +64,15 @@ This option lets you choose between neko and her friend inu.
Set whether neko follows the pointer when it approaches the bottom of the output Set whether neko follows the pointer when it approaches the bottom of the output
.RE .RE
. .
.P
\fB\-\-survive\-close\fR
.RS
If this flag is used, wayneko will recreate the surface after it has been closed.
This allows neko to migrate outputs should the one she is currently on be
disconnected, but may cause some undesired behaviour should the server try to
close the surface for a different reason.
.RE
.
. .
.SH AUTHOR .SH AUTHOR
.P .P

View file

@ -31,6 +31,7 @@ const char usage[] =
" --background-colour 0xRRGGBB[AA]\n" " --background-colour 0xRRGGBB[AA]\n"
" --outline-colour 0xRRGGBB[AA]\n" " --outline-colour 0xRRGGBB[AA]\n"
" --type neko|inu|random\n" " --type neko|inu|random\n"
" --survive-close\n"
"\n"; "\n";
pixman_color_t bg_colour; pixman_color_t bg_colour;
@ -71,6 +72,7 @@ size_t animation_ticks_until_next_frame = 10;
enum Neko current_neko = NEKO_STARE; enum Neko current_neko = NEKO_STARE;
enum Type type = NEKO; enum Type type = NEKO;
bool follow_pointer = true; bool follow_pointer = true;
bool recreate_surface_on_close = false;
struct Seat struct Seat
{ {
@ -1040,6 +1042,7 @@ static void surface_destroy (void)
wl_surface_destroy(surface.wl_surface ); wl_surface_destroy(surface.wl_surface );
surface.wl_surface = NULL; surface.wl_surface = NULL;
} }
surface.configured = false;
} }
static void layer_surface_handle_configure (void *data, struct zwlr_layer_surface_v1 *layer_surface, static void layer_surface_handle_configure (void *data, struct zwlr_layer_surface_v1 *layer_surface,
@ -1064,11 +1067,19 @@ static void layer_surface_handle_configure (void *data, struct zwlr_layer_surfac
surface_next_frame(); surface_next_frame();
} }
static const struct wl_callback_listener sync_callback_listener;
static void layer_surface_handle_closed (void *data, struct zwlr_layer_surface_v1 *layer_surface) static void layer_surface_handle_closed (void *data, struct zwlr_layer_surface_v1 *layer_surface)
{ {
(void)data; (void)data;
(void)layer_surface; (void)layer_surface;
surface_destroy(); surface_destroy();
if (recreate_surface_on_close)
{
sync_callback = wl_display_sync(wl_display);
wl_callback_add_listener(sync_callback, &sync_callback_listener, NULL);
}
else
loop = false; loop = false;
} }
@ -1253,6 +1264,8 @@ int main (int argc, char *argv[])
fputs(usage, stderr); fputs(usage, stderr);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
else if ( strcmp(argv[i], "--survive-close") == 0 )
recreate_surface_on_close = true;
else if ( strcmp(argv[i], "--background-colour") == 0 ) else if ( strcmp(argv[i], "--background-colour") == 0 )
{ {
if (!colour_from_flag(&bg_colour, argc, argv, &i)) if (!colour_from_flag(&bg_colour, argc, argv, &i))