Skip to content

Commit

Permalink
Don't reset buffer if window size not changed
Browse files Browse the repository at this point in the history
Resolves the problem with canvas reset on window focus lost.

Signed-off-by: Artem Senichev <[email protected]>
  • Loading branch information
artemsen committed Jun 11, 2024
1 parent 392e654 commit 912fcd7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,6 @@ static void on_xdg_surface_configure(void* data, struct xdg_surface* surface,
{
xdg_surface_ack_configure(surface, serial);

if (!recreate_buffers()) {
ctx.state = state_error;
return;
}

if (ctx.xdg.initialized) {
ui_redraw();
} else {
Expand All @@ -443,10 +438,22 @@ static void handle_xdg_toplevel_configure(void* data, struct xdg_toplevel* lvl,
int32_t width, int32_t height,
struct wl_array* states)
{
bool reset_buffers = (ctx.wnd.current == NULL);

if (width && height) {
const size_t new_width = width * ctx.wnd.scale;
const size_t new_height = height * ctx.wnd.scale;
if (width != (int32_t)ctx.wnd.width ||
height != (int32_t)ctx.wnd.height) {
ctx.wnd.width = new_width;
ctx.wnd.height = new_height;
reset_buffers = true;
}
ctx.xdg.initialized = true;
ctx.wnd.width = width * ctx.wnd.scale;
ctx.wnd.height = height * ctx.wnd.scale;
}

if (reset_buffers && !recreate_buffers()) {
ctx.state = state_error;
}
}

Expand Down

0 comments on commit 912fcd7

Please sign in to comment.