summaryrefslogtreecommitdiff
path: root/src/cursors
diff options
context:
space:
mode:
authorРуслан Ижбулатов <lrn1986@gmail.com>2016-08-22 15:23:29 +0000
committerJakub Steiner <jimmac@gmail.com>2016-08-22 20:36:42 +0200
commita6275c6cb201eae72a8839777a3ee5d0113738b9 (patch)
tree56ae129717ce9e70bdec9f6363d3f74917b855cd /src/cursors
parentb8a84340bd97732804047e71e8227fe211d1810f (diff)
downloadadwaita-icon-theme-a6275c6cb201eae72a8839777a3ee5d0113738b9.tar.gz
anicursorgen: change the PNG compression use logic
Previously anicursorgen used PNG compression for any cursor frames larger than 48x48, for no immediately apparent reason, even to me (the author of anicursorgen). Tests on Windows 10 revealed that this logic is faulty: Windows 10 does not recognize PNG-compressed frames as valid, thus all Adwaita cursors are effectively 32x32 and 48x48 (all larger frames are ignored by the OS). This becomes obvious in HiDPI mode, where the OS will try to use larger cursor sizes. Windows 10 loads up uncompressed cursors just fine, and stock Windows 10 cursors are uncompressed. However, animated cursors with large numbers of frames, when stored without compression, are also ignored by the OS (probably due to their massive size). My hypothesis is that the correct way of using PNG compression is to compress or not compress *all* frames, not just the large ones. However, verifying that requires more tests (or asking MS developers). In the end i've settled enabling PNG compression for all frames in animated cursors and disabling PNG compression for all frames in non-animated cursors. This works for Adwaita, and that's all we really need.
Diffstat (limited to 'src/cursors')
-rwxr-xr-xsrc/cursors/anicursorgen.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/cursors/anicursorgen.py b/src/cursors/anicursorgen.py
index 425eb736c..ad4b7c07e 100755
--- a/src/cursors/anicursorgen.py
+++ b/src/cursors/anicursorgen.py
@@ -128,7 +128,7 @@ def frames_have_animation (frames):
return False
-def make_cur (frames, args):
+def make_cur (frames, args, animated=False):
buf = io.BytesIO ()
buf.write (p ('<HHH', 0, 2, len (frames)))
frame_offsets = []
@@ -165,7 +165,17 @@ def make_cur (frames, args):
frame_png.close ()
frame_png = shadowed
- compressed = frame[0] > 48
+# Windows 10 fails to read PNG-compressed cursors for some reason
+# and the information about storing PNG-compressed cursors is
+# sparse. This is why PNG compression is not used.
+# Previously this was conditional on cursor size (<= 48 to be uncompressed).
+ compressed = False
+
+# On the other hand, Windows 10 refuses to read very large
+# uncompressed animated cursor files, but does accept
+# PNG-compressed animated cursors for some reason. Go figure.
+ if animated:
+ compressed = True
if compressed:
write_png (buf, frame, frame_png)
@@ -264,7 +274,7 @@ def make_ani (frames, out, args):
for frameset in framesets:
buf.write (b'icon')
- cur = make_cur (frameset, args)
+ cur = make_cur (frameset, args, animated=True)
cur_size = cur.seek (0, io.SEEK_END)
aligned_cur_size = cur_size
#if cur_size % 4 != 0: