Skip to content

Commit

Permalink
[WaylandWindow] Unmap surface before sending activation request
Browse files Browse the repository at this point in the history
Fixes lbonn#117
  • Loading branch information
alebastr committed Feb 26, 2024
1 parent a4c8135 commit 0eabb36
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/wayland.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void display_buffer_pool_free(display_buffer_pool *pool);

cairo_surface_t *display_buffer_pool_get_next_buffer(display_buffer_pool *pool);
void display_surface_commit(cairo_surface_t *surface);
void display_surface_unmap(void);

gboolean display_get_surface_dimensions(int *width, int *height);
void display_set_surface_dimensions(int width, int height, int x_margin,
Expand Down
1 change: 1 addition & 0 deletions source/modes/wayland-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ static ModeMode wayland_window_mode_result(Mode *sw, int mretv,
} else if (mretv & MENU_QUICK_SWITCH) {
retv = (ModeMode)(mretv & MENU_LOWER_MASK);
} else if ((mretv & MENU_OK)) {
rofi_view_hide();
ForeignToplevelHandle *toplevel =
(ForeignToplevelHandle *)g_list_nth_data(pd->toplevels, selected_line);
foreign_toplevel_handle_activate(toplevel, pd->wayland->last_seat->seat);
Expand Down
17 changes: 14 additions & 3 deletions source/wayland/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ void display_surface_commit(cairo_surface_t *surface) {
wl_surface_commit(wayland->surface);
}

void display_surface_unmap(void) {
if (wayland->wlr_surface != NULL) {
zwlr_layer_surface_v1_destroy(wayland->wlr_surface);
wayland->wlr_surface = NULL;
}
if (wayland->surface != NULL) {
wl_surface_destroy(wayland->surface);
wayland->surface = NULL;
}
wl_display_flush(wayland->display);
}

static void wayland_frame_callback(void *data, struct wl_callback *callback,
uint32_t timestamp) {
if (wayland->frame_cb != NULL) {
Expand Down Expand Up @@ -1409,6 +1421,7 @@ wayland_layer_shell_surface_closed(void *data,

zwlr_layer_surface_v1_destroy(surface);
wl_surface_destroy(wayland->surface);
wayland->wlr_surface = NULL;
wayland->surface = NULL;

// In this case, we recreate the layer shell surface the best we can and
Expand Down Expand Up @@ -1633,9 +1646,7 @@ static void wayland_display_cleanup(void) {
return;
}

if (wayland->surface != NULL) {
wl_surface_destroy(wayland->surface);
}
display_surface_unmap();

nk_bindings_seat_free(wayland->bindings_seat);
g_hash_table_unref(wayland->seats_by_name);
Expand Down
5 changes: 4 additions & 1 deletion source/wayland/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ static int wayland_rofi_view_calculate_window_height(RofiViewState *state) {
return widget_get_desired_height(main_window, state->width);
}

static void wayland_rofi_view_hide(void) {}
static void wayland_rofi_view_hide(void) {
display_surface_unmap();
display_early_cleanup();
}

static void wayland_rofi_view_cleanup() {
g_debug("Cleanup.");
Expand Down

0 comments on commit 0eabb36

Please sign in to comment.