naelstrof / maim

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
Other
2.15k stars 78 forks source link

what(): Couldn't grab the mouse after 10 tries. #231

Closed nsajko closed 3 years ago

nsajko commented 3 years ago

I have the Archlinux package maim 5.6.3 with Xorg 1.20.11 and Qt5 5.15.2.

I start maim like this: maim -u -m 10 -s -o p.png

Usually taking screenshots works just fine, but there's this one Qt 5 program called Graphia, where if I open a drop-down menu and try to take a screenshot, maim fails with this output:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Couldn't grab the mouse after 10 tries.

It also says "Aborted" and dumps core.

foxpy commented 3 years ago

This has something to do with the way Xorg handles input. Context menus in Xorg are especially awful in this regard. I am running i3 window manager and none of my key bindings work whenever I have context menu open (drives me crazy from time to time).

I belive that maim can do nothing about this issue. The only good solution is to capture whole screen after some short timer (so you have time to open context menu) and crop/edit screenshot manually after capture.

P. S. Allowing arbitrary applications to grab away keyboard input from window manager or other programs is a scary dumb design decision, I have no idea why is Xorg done like this.

naelstrof commented 3 years ago

Yeah, this is an Xorg issue, if maim can't grab the mouse, then mouse events would fall through. (Causing clicks to actually affect the desktop.)

There's no mouse grab queue, so other apps can easily get exclusive control. This also works in reverse (maim can prevent QT or i3 menus from functioning properly as well.)

It's a big pain but something that we just have to live with-- unless X decides to rework the mouse grab system.