resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
511 stars 51 forks source link

`-l opacity` does not work as documented #281

Closed mimuki closed 6 months ago

mimuki commented 1 year ago

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

N-R-K commented 1 year ago

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 commented 1 year ago

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 :)

daltomi commented 1 year ago

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);
N-R-K commented 1 year ago

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 commented 1 year ago

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.
daltomi commented 1 year ago

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.