Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release prevents taking screenshots larger than screen size #41

Closed
peesock opened this issue Jun 24, 2023 · 4 comments · Fixed by #42
Closed

New release prevents taking screenshots larger than screen size #41

peesock opened this issue Jun 24, 2023 · 4 comments · Fixed by #42
Assignees
Labels

Comments

@peesock
Copy link

peesock commented Jun 24, 2023

In the previous release, if you had a window larger than your screen, you could still take a screenshot of the entire window. This is no longer possible:

#!/bin/sh
select="$(hacksaw -f "-i %i -g %g")" 
# my window: "-i 27311718 -g 3028x4036+-554+-1478", screen size is 1920x1080

# new release:
shotgun -f png $select test-1
# stderr: Invalid geometry

# old release (in build dir):
./shotgun -f png $select test-2
# makes big image

Note that using the OLD release of shotgun in an interactive shell also does NOT work:

$ ./shotgun -f png -i 27311718 -g 3028x4036+-554+-1478 test-3  
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  73 (X_GetImage)
  Serial number of failed request:  20
  Current serial number in output stream:  20

While it does in a file. I don't know why. Tested in zsh, bash, and dash.

This feature might seem almost useless, but I do use it from time to time for things like taking screenshots of MPV or feh when I want to share a large image quickly, or capturing GUI programs with window size dependent behavior, like how spek (audio spectrum analyzer) only increases resolution with window size.

@9ary
Copy link
Member

9ary commented Jun 24, 2023

So this is expected to work, but the geometry string you're passing is invalid. 3028x4036+-554+-1478 should be 3028x4036-554-1478. This might be a hacksaw bug, and I don't think it worked with xli- oh, actually, it looks like it's pretty subtle but should work there: https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/ParseGeom.c
The parser there should in fact accept two signs in a row!
While the new parser is intentionally slightly stricter than xlib's for our purposes, this should be fixed for compatibility.

As for the error with the old version, I have no idea why that's happening. I would need to know exactly what's being passed to XGetImage and a few other things, but considering we've moved on from xlib, let's focus on fixing regressions.

@9ary 9ary self-assigned this Jun 24, 2023
@9ary 9ary added the bug label Jun 24, 2023
9ary added a commit that referenced this issue Jun 24, 2023
Apparently hacksaw will emit `+-` for negative coordinates, and the xlib
geometry parser subtly accepted those.

Fixes: #41
@9ary
Copy link
Member

9ary commented Jun 24, 2023

@peesock can you verify that #42 fixes this for you?

@peesock
Copy link
Author

peesock commented Jun 24, 2023

Yes, seems to work fine now :) Thanks

@peesock peesock closed this as completed Jun 24, 2023
@9ary
Copy link
Member

9ary commented Jun 24, 2023

Thanks for reporting and testing! In general though, please don't close issues before the fix is merged.
I've released 2.5.1 which contains the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants