GNOME Bugzilla – Bug 749053
Adwaita-icon-theme cursors have bad non-X11 compatibility
Last modified: 2015-05-13 17:26:41 UTC
I've looked for a way to use Adwaita cursors on non-X11 backends (W32, to be specific; with GTK), and found the cursor generator lacking. First, i need to be able to get cursors without shadows (W32 WM can draw shadows, if user switches the appropriate option on). Also, i need it to be able to generate smaller cursors in bigger canvases (because of the way cursor size is controlled on W32). That meant that hotspots hardcoded into xcursorgen input files can no longer be relied upon (scaling moves the hotspots), so they must be generated somehow. And scaled cursors should probably be aligned somewhere (to the center or to a corner). And forking an Inkscape process 2000 times isn't fun on W32 either.
Created attachment 303007 [details] [review] Name all the shadows
Created attachment 303008 [details] [review] Add a hotspots layer
Created attachment 303009 [details] [review] Major renderpngs modifications * Depends on Python Pillow library now * Add the --remove-shadows option. Renders cursors without shadows. This depends on the shadows having appropriate names in adwaita.svg * Add the --hotspots option. Renders hotspots into separate pngs, then finds its coordinates and writes out the xcursorgen input file accordingly. This depends on hotspots layer being present in the adwaita.svg. * Add the --scales option. Makes all cursor canvases one size higher than they normally are (24->32, 32->48 etc). Renders extra cursor variants that are 125% and 150% larger than the nominal size (hence the canvas size increase - otherwise scaled up versions won't fit at all). * Add the --min-canvas-size option. Makes all cursor canvases at least this big (padding smaller cursors when necessary). * Add the --fps option. Used to adjust the frame duration written into xcursorgen input files. * Add the --anicursorgen option. Changes the format of the files into something that anicursorgen understands better (changes frame duration from milliseconds to jiffies). * Add the --corner-align option. Aligns cursors to the top-left corner instead of centering them on the canvas. * Inkscape is now being run in shell mode (one instance, fed with commands via stdin).
After thinking a bit more about the way X draws the cursor, i've realized that on X the L and XL cursors will actually be S and XS: nominal cursor size is set by the system; using a theme that has smaller cursors on canvas of the same size will make them look smaller. This acts as L and XL on W32 only because W32 uses the small-cursor-on-larger-canvas by default, so bigger cursors on the same canvas just look bigger. That's going to confuse the hell out of cursor theme maintainers, but the end users will only see what the maintainers will show them, and that would be "S" and "XS" for the X11 versions of the "L" and "XL" themes. Still, maybe more neutral (S1 and S2?) names should be chosen instead.
Thanks for all this work. even ifmotivated by Windows cursors a lot of this is useful for X. Before I even test this I'd like to point out things I like about this - there is one script to get the final output - things just work by default, parameters sort out special needs. - metadata like click coordicantes/hotspots are defined visually, on canvas The thing I don't quite grok/like is why do all the work to name shadows? I would expect separating them out onto a new layer and toggle its visibility like abetter approach (with --remove-shadows). Anything that removes manual work from the maintainer gets extra points...
Created attachment 303056 [details] [review] Add a hotspots layer v2: * Expanded the patch to cover the recently-added extra icons
Created attachment 303057 [details] [review] Move all shadows to a separate layer Also remove some duplicate objects
Created attachment 303058 [details] [review] Major renderpngs modifications v2: * Filters out shadows by removing the 'shadows' layer, not by ignoring specially-named objects * Hotspots and shadows filtering is merged in a single class * Renamed --negate to --invert * Add the --number-of-renderers option. Allows multiple Inkscape instances to be run in parallel for rendering speed increase on multicore systems. * Misc logic fixes and refactoring
Created attachment 303316 [details] [review] Add a hotspots layer v3: * Align hotspots to 24x24 pixels a bit better
Created attachment 303317 [details] [review] Add InvertFilter This filter is used in new in-SVG color inversion
Created attachment 303318 [details] [review] Major renderpngs modifications v3: * Filter SVG files from memory to avoid leaking a file descriptor * Make slices and hotspots normally invisible * New inversion code (inverts in SVG, not in rendered PNG). Quality is somewhat worse than it was with previous version, but at least it doesn't invert shadows.
Created attachment 303319 [details] [review] Add anicursorgen.py Like xcursorgen, but written in Python and generates Windows cursors.
Created attachment 303324 [details] [review] add InvertFilter v2: Change the filter parameters to affect transparency differently. These are not suitable for cursors (destroys outlines), but work just fine for shadows.
Created attachment 303325 [details] [review] Major renderpngs modifications v4: * Change the behaviour of the inverter. Now it combines inverting the shadow in SVG and inverting the resulting PNG image.
Created attachment 303326 [details] [review] Add anicursorgen.py v2: * Add utf-8 markings to the source
Attachment 303057 [details] pushed as b7723b0 - Move all shadows to a separate layer Attachment 303316 [details] pushed as 595c0b0 - Add a hotspots layer Attachment 303324 [details] pushed as e60a5be - add InvertFilter Attachment 303325 [details] pushed as 778e229 - Major renderpngs modifications Attachment 303326 [details] pushed as 315db6b - Add anicursorgen.py