Skip to content

Fix intersection calculation bug in rect_paint_needed - #52

Open
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/comp-rect-intersection
Open

Fix intersection calculation bug in rect_paint_needed#52
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/comp-rect-intersection

Conversation

@jEsuSdA

@jEsuSdA jEsuSdA commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Fixes two copy-paste errors in the intersection rectangle calculation that could cause windows to be incorrectly skipped during painting.

Problem

The intersection rectangle calculation in rect_paint_needed() had two copy-paste errors:

x2 = (ignore_reg->x2 < reg->x2) ? ignore_reg->x1 : reg->x1;  // should be x2
y2 = (ignore_reg->y2 < reg->y2) ? ignore_reg->y1 : reg->y1;  // should be y2

This produced incorrect intersection dimensions, which could cause w*h to be negative or wrong, leading to the ignore region being computed incorrectly and windows that should be painted being skipped.

Solution

Correct the ternary operators to use x2 and y2 respectively:

x2 = (ignore_reg->x2 < reg->x2) ? ignore_reg->x2 : reg->x2;
y2 = (ignore_reg->y2 < reg->y2) ? ignore_reg->y2 : reg->y2;

Scope

  • Only comp_rect.c is touched (2 lines)
  • make clean && make produces zero warnings, zero errors

Impact

Fixes a correctness bug in the occlusion culling logic. On certain window layouts (overlapping windows with specific positions), this could cause visible windows to not be painted.

The intersection rectangle calculation had two copy-paste errors where
the x2 and y2 values were incorrectly using x1/y1 instead of x2/y2 in
the ternary operators:

  x2 = (ignore_reg->x2 < reg->x2) ? ignore_reg->x1 : reg->x1;
  y2 = (ignore_reg->y2 < reg->y2) ? ignore_reg->y1 : reg->y1;

This produced incorrect intersection dimensions, which could cause
w*h to be negative or wrong, leading to the ignore region being
computed incorrectly and windows that should be painted being skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant