Skip to content

Commit

Permalink
some applications seem to send signed ints in CARD32 for opaque region
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 30, 2024
1 parent a358f22 commit d625380
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions xpra/client/gtk3/window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,11 @@ def set_opaque_region(self, rectangles=()):
# noinspection PyArgumentList
r = Region()
for rect in rectangles:
rect = RectangleInt(*self.srect(*rect))
r.union(Region(rect))
# "opaque-region", aka "_NET_WM_OPAQUE_REGION" is meant to use unsigned values
# but some applications use 0xffffffff, so we have to validate it:
rvalues = tuple((int(v) if v < 2**32 else -1) for v in rect)
rectint = RectangleInt(*self.srect(*rvalues))
r.union(Region(rectint))

def do_set_region():
log("set_opaque_region(%s)", r)
Expand Down
3 changes: 2 additions & 1 deletion xpra/x11/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ def _handle_opaque_region_change(self) -> None:
v: Sequence[int] = tuple(self.prop_get("_NET_WM_OPAQUE_REGION", ["u32"]) or [])
if OPAQUE_REGION and len(v) % 4 == 0:
while v:
rectangles.append(v[:4])
rvalues = tuple((coord if coord < 2 ** 32 else -1) for coord in v[:4])
rectangles.append(rvalues)
v = v[4:]
metalog("_NET_WM_OPAQUE_REGION(%s)=%s (OPAQUE_REGION=%s)", v, rectangles, OPAQUE_REGION)
self._updateprop("opaque-region", tuple(rectangles))
Expand Down

0 comments on commit d625380

Please sign in to comment.