Skip to content

Commit

Permalink
[WaylandWindow] Unmap surface before sending activation request
Browse files Browse the repository at this point in the history
Fixes #117
  • Loading branch information
alebastr committed Feb 26, 2024
1 parent a4c8135 commit c7472ec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
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
28 changes: 20 additions & 8 deletions source/wayland/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,14 +1402,23 @@ static void wayland_layer_shell_surface_configure(
zwlr_layer_surface_v1_ack_configure(surface, serial);
}

static void wayland_surface_destroy(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;
}
}

static void
wayland_layer_shell_surface_closed(void *data,
struct zwlr_layer_surface_v1 *surface) {
g_debug("Layer shell surface closed");

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

// In this case, we recreate the layer shell surface the best we can and
// re-initialize everything:
Expand Down Expand Up @@ -1626,15 +1635,18 @@ void display_set_surface_dimensions(int width, int height, int x_margin,
-y_margin, x_margin);
}

static void wayland_display_early_cleanup(void) {}

static void wayland_display_cleanup(void) {
static void wayland_display_early_cleanup(void) {
if (wayland->main_loop_source == NULL) {
return;
}

if (wayland->surface != NULL) {
wl_surface_destroy(wayland->surface);
wayland_surface_destroy();
wl_display_flush(wayland->display);
}

static void wayland_display_cleanup(void) {
if (wayland->main_loop_source == NULL) {
return;
}

nk_bindings_seat_free(wayland->bindings_seat);
Expand Down
2 changes: 1 addition & 1 deletion source/wayland/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ 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_early_cleanup(); }

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

0 comments on commit c7472ec

Please sign in to comment.