diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 701a9143..32e52849 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -85,7 +85,7 @@ static void adjust_box_to_workspace_offset(struct wlr_box *box, float scroll_percent = output->workspace_scroll.percent; int ws_dimen; - int *box_coord; + int *box_coord = NULL; switch (output->workspace_scroll.direction) { case SWIPE_GESTURE_DIRECTION_NONE: return; @@ -99,6 +99,10 @@ static void adjust_box_to_workspace_offset(struct wlr_box *box, break; } + if (box_coord == NULL || ws_dimen == 0) { + return; + } + *box_coord -= ws_dimen * scroll_percent; if (!on_focused_workspace) { if (scroll_percent > 0) { @@ -117,8 +121,8 @@ static void adjust_damage_to_workspace_bounds(pixman_region32_t *damage, float scroll_percent = output->workspace_scroll.percent; int x = 0, y = 0; - int ws_dimen; - int *coord; + int ws_dimen = 0; + int *coord = NULL; switch (output->workspace_scroll.direction) { case SWIPE_GESTURE_DIRECTION_NONE: return; @@ -132,6 +136,10 @@ static void adjust_damage_to_workspace_bounds(pixman_region32_t *damage, break; } + if (coord == NULL || ws_dimen == 0) { + return; + } + *coord = round(-ws_dimen * scroll_percent); if (!on_focused_workspace) { if (scroll_percent > 0) {