thenaterhood / gscreenshot

A simple graphical frontend for multiple screenshot backends including scrot, imagemagick, PIL, imlib2, and grim.
58 stars 6 forks source link

Bug: region selection incorrect on Wayland with scaling #195

Closed davisrichard437 closed 1 week ago

davisrichard437 commented 2 weeks ago

Summary

I am having trouble using gscreenshot's region capture on Wayland. I am using sway with fractional scaling (1.5x). When I attempt to take a screenshot via a region selection, the resulting image is of a smaller region than I selected, with corners up and to the left of the selected region.

gscreenshot examples

For example, here is a screenshot of the entire screen (no region selection):

image

And here is a screenshot where I have used selected the entire screen as a region:

image

I do not have this problem when sway is unscaled (swaymsg output eDP-1 scale 1.0 or similar). Here is a screenshot using a region selection of the whole screen with 1.0 scaling:

image

The problem persists with 2.0 scaling, so it is not an issue of fractional or whole-number scaling. Here is a screenshot using region selection of the whole screen with 2.0 scaling:

image

This screenshot is (visually) exactly half the screen, so I imagine the program somehow misinterprets scaled coordinates.

grim/slurp examples

I do not have this same problem with "raw" grim/slurp region selection (grim -g "$(slurp)").

No region selection:

image

Region selection of the entire screen:

image

Some information

Using grim screenshot backend
gscreenshot 3.5.1; A simple screenshot tool supporting multiple backends.
Available features: Cursor Capture (gscreenshot), Full Screen Capture (grim), Alternate Cursor (gscreenshot), Region Selection (slurp), Reuse Region (slurp)
https://github.com/thenaterhood/gscreenshot
...
thenaterhood commented 2 weeks ago

That's very interesting! For context about how gscreenshot does region selection, it takes a screenshot of the entire display then crops it based on the output of the region selection tool, in your case slurp. It's possible that gscreenshot needs to adjust something by the scaling ratio.

thenaterhood commented 2 weeks ago

Reproducible in KDE

thenaterhood commented 1 week ago

This should be working in gscreenshot 3.6.1

davisrichard437 commented 1 week ago

I'm afraid it still doesn't work for me, but I'll do some more digging

thenaterhood commented 4 days ago

Try out version 3.6.2 which I just released this morning and see if it works any better. One of the Gtk calls was wrong and gscreenshot was falling back to another method of getting the scaling that might not have been accurate on your setup.

davisrichard437 commented 3 days ago

Unfortunately no, now I get something like this:

image

It seems to be larger (dilated down and to the right) than the region selection I had chosen, even going off the screen. For comparison, with grim/slurp:

image

One thing to consider is that I am currently using two monitors with different scaling; this could potentially be a problem in detecting scaling. One is a 1920x1080 external display with no scaling and the other is a 2256x1504 laptop screen with 1.5 scaling. However, even when I disconnect the external display, the problem persists, so I doubt this is the cause of the issue.

If it would help, I'd be happy to run a version with debugging/print statements and send the output here.