2

I'm trying to get a program to automatically crop a screenshot of the display to the correct size of the visible window.

Using this command to get the size and the position of the window:

$ xdotool getwindowfocus getwindowgeometry
Window 104857603
  Position: 0,81 (screen: 0)
  Geometry: 1920x1027

Using this command to get the display geometry:

$ xdotool getdisplaygeometry
1920 1080

It would be intuitive to think that the first value of the window's position plus the first value of the window's geometry would be equal to the first value of the display's geometry, and in this case it does (0 + 1920 = 1920). However when looking at the second output value 81 + 1027 > 1080. Why does that happen?

Gustavo
  • 668
  • 13
  • 24
  • likely, window border & taskbar. – Doyousketch2 Jun 14 '21 at 05:35
  • I get roughly the same thing; in one setup with a `10,74` offset. See also [how this plays out (inconsistently) in cinnamon](https://github.com/linuxmint/muffin/issues/578). – Jonathan W. Feb 19 '22 at 21:39
  • For a different approach that may work better, see https://unix.stackexchange.com/questions/14159/how-do-i-find-the-window-dimensions-and-position-accurately-including-decoration – Jonathan W. Feb 19 '22 at 21:42

0 Answers0