Skip to content

Commit 74a157c

Browse files
committed
wayland: set anchors on both size when auto-sizing
See swaywm/wlroots#2422, swaywm/sway#5712
1 parent cef94af commit 74a157c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

source/wayland/display.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,13 +1046,13 @@ wayland_display_setup ( GMainLoop *main_loop, NkBindings *bindings )
10461046

10471047
wayland->wlr_surface = zwlr_layer_shell_v1_get_layer_surface ( wayland->layer_shell, wayland->surface, NULL, ZWLR_LAYER_SHELL_V1_LAYER_TOP, "rofi" );
10481048

1049-
// ANCHOR_LEFT is needed to get the full screen width
1050-
zwlr_layer_surface_v1_set_anchor ( wayland->wlr_surface, ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT );
1049+
// Set size zero and anchor on all corners to get the usable screen size
1050+
// see https://github.com/swaywm/wlroots/pull/2422
1051+
zwlr_layer_surface_v1_set_anchor ( wayland->wlr_surface, ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT );
1052+
zwlr_layer_surface_v1_set_size ( wayland->wlr_surface, 0, 0 );
10511053
zwlr_layer_surface_v1_set_keyboard_interactivity ( wayland->wlr_surface, 1 );
10521054
zwlr_layer_surface_v1_add_listener ( wayland->wlr_surface, &wayland_layer_shell_surface_listener, NULL );
10531055

1054-
// By setting 0 here, we'll get some useful sizes in the configure event
1055-
zwlr_layer_surface_v1_set_size ( wayland->wlr_surface, 0, 0 );
10561056
wl_surface_add_listener ( wayland->surface, &wayland_surface_interface, wayland );
10571057
wl_surface_commit ( wayland->surface );
10581058
wl_display_roundtrip ( wayland->display );
@@ -1120,6 +1120,14 @@ display_set_surface_dimensions ( int width, int height, int loc )
11201120
default:
11211121
break;
11221122
}
1123+
1124+
if ( height == 0 ) {
1125+
wlr_anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
1126+
}
1127+
if ( width == 0 ) {
1128+
wlr_anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
1129+
}
1130+
11231131
zwlr_layer_surface_v1_set_anchor ( wayland->wlr_surface, wlr_anchor );
11241132
}
11251133

0 commit comments

Comments
 (0)