mirror of
https://github.com/swaywm/sway.git
synced 2025-01-27 05:18:49 +01:00
swaynag: reduce roundtrips when rendering frames
This reduces flicker when toggling the detail view.
This commit is contained in:
parent
2535a2e9f9
commit
131026b190
1 changed files with 33 additions and 28 deletions
|
@ -260,17 +260,24 @@ void render_frame(struct swaynag *swaynag) {
|
|||
cairo_paint(cairo);
|
||||
cairo_restore(cairo);
|
||||
uint32_t height = render_to_cairo(cairo, swaynag);
|
||||
if (height != swaynag->height) {
|
||||
if (swaynag->height == 0) {
|
||||
// for first commit, set required size but do not attach a buffer
|
||||
zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
|
||||
height);
|
||||
wl_surface_commit(swaynag->surface);
|
||||
wl_display_roundtrip(swaynag->display);
|
||||
} else {
|
||||
goto cleanup;
|
||||
}
|
||||
if (height != swaynag->height) {
|
||||
zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
|
||||
height);
|
||||
}
|
||||
|
||||
swaynag->current_buffer = get_next_buffer(swaynag->shm,
|
||||
swaynag->buffers,
|
||||
swaynag->width * swaynag->scale,
|
||||
swaynag->height * swaynag->scale);
|
||||
height * swaynag->scale);
|
||||
if (!swaynag->current_buffer) {
|
||||
sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame.");
|
||||
goto cleanup;
|
||||
|
@ -290,8 +297,6 @@ void render_frame(struct swaynag *swaynag) {
|
|||
wl_surface_damage(swaynag->surface, 0, 0,
|
||||
swaynag->width, swaynag->height);
|
||||
wl_surface_commit(swaynag->surface);
|
||||
wl_display_roundtrip(swaynag->display);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cairo_surface_destroy(recorder);
|
||||
|
|
Loading…
Reference in a new issue