scrot icon indicating copy to clipboard operation
scrot copied to clipboard

`-l opacity` does not work as documented

Open mimuki opened this issue 2 years ago • 6 comments

According to the man page, running a command like scrot -s -l width=8,color="#ff79c6",opacity=255,mode=edge should result in an opaque pink border, and should be not transparent at all.

Instead, opacity=255 is slightly see through, but opacity=100 is completely opaque.

I'm not familiar with C and might be misunderstanding this line, but it looks like this isn't a bug, just the documentation being wrong. https://github.com/resurrecting-open-source-projects/scrot/blob/5ef8a82612a57ebd8b70cc45eaea437cbcfed741/src/selection_edge.c#L79

mimuki avatar May 03 '23 04:05 mimuki

I can't really find any documentation on _NET_WM_WINDOW_OPACITY - it's not described in EWMH and seems to be something non-standard. Only thing I found was this comment in Tk source code which suggest the atom works by mapping [0x0, 0xFFFFFFFF] to [0%, 100%] transparency.

If that's the case, then the bug I think is in the source code. Not the documentation.

N-R-K avatar May 06 '23 17:05 N-R-K

This will be hard for me to fix because I don't use a compositor. If you change that line to the following:

	unsigned long opacity = opt.lineOpacity * (0xFFFFFFFFu / 255);

does that work as expected?

If my understanding of _NET_WM_WINDOW_OPACITY is correct, then it should work. But I'll need help from people who can actually test it out and report back :)

N-R-K avatar May 06 '23 18:05 N-R-K

The opacity values for the 'edge' selection mode is between 10% and 100% At some point the function call was removed:

int const lineOpacity = optionsParseRequireRange(opt.lineOpacity, 10, 100);

daltomi avatar May 25 '23 17:05 daltomi

It was:

    const int lineOpacity = optionsParseRequireRange(opt.lineOpacity,
            SELECTION_EDGE_OPACITY_MIN, SELECTION_OPACITY_MAX);

The SELECTION_EDGE_OPACITY_{MIN,MAX} constants got removed in ff88b0b0cd38137113319cb86e423cb1fe4d6b3a for some reason.

N-R-K avatar May 25 '23 17:05 N-R-K

The opacity values for the 'edge' selection mode is between 10% and 100%

@daltomi What do you think should be done now?

  1. Change the code back to using [10, 100] for edge and fix the manpage.
  2. Change the code to use [0, 255] as documented in the manpage.

N-R-K avatar May 26 '23 09:05 N-R-K

El Fri, 26 May 2023 02:12:24 -0700 NRK @.***> escribió:

  1. Change the code back to using [10, 100] for edge and fix the manpage.
  2. Change the code to use [0, 255] as documented in the manpage.

Yes, I also agree with option 2, TIA.

daltomi avatar May 26 '23 11:05 daltomi