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.16k stars 79 forks source link

maim --select return std::runtime_error with mouse focus on open html select form #146

Closed BarbUk closed 6 years ago

BarbUk commented 6 years ago

Step to reproduce the issue:

Maim return:

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

Unfortunately this is unavoidable. X11 only allows one mouse grab at a time. Maim requires a mouse grab to prevent mouse events from falling though. Your html form is grabbing the mouse for the same reason.

There might be a clever solution to avoid the problem, but maim is currently following protocol.

BarbUk commented 6 years ago

Thanks for your feedback.

The working solution is to use maim without --select, and to crop the resulting screenshot.

liquiddandruff commented 5 years ago

I just encountered this issue, along with below stack trace from journalctl.

Thanks for the explanation and workaround of not including --select and just taking a full screencap, but might I suggest this edge case to be handled more gracefully. For example, echoing to stdout exactly why the cursor can't be grabbed (because of X11 restriction), suggesting to retry without --select, and handling this runtime error without dumping core.

Jan 04 02:06:48 ansible systemd-coredump[3438]: Process 3435 (maim) of user 1000 dumped core.

                                                Stack trace of thread 3435:
                                                #0  0x00007f69e81aed7f raise (libc.so.6)
                                                #1  0x00007f69e8199672 abort (libc.so.6)
                                                #2  0x00007f69e83e058e _ZN9__gnu_cxx27__verbose_terminate_handlerEv (libstdc++.so.6)
                                                #3  0x00007f69e83e6dfa _ZN10__cxxabiv111__terminateEPFvvE (libstdc++.so.6)
                                                #4  0x00007f69e83e6e57 _ZSt9terminatev (libstdc++.so.6)
                                                #5  0x00007f69e83e70ac __cxa_throw (libstdc++.so.6)
                                                #6  0x00007f69e86be037 n/a (libslopy.so.7.4)
                                                #7  0x00007f69e86c1c96 _ZN4slop16XShapeSlopSelectEPNS_11SlopOptionsE (libslopy.so.7.4)
                                                #8  0x00007f69e86c386e _ZN4slop10SlopSelectEPNS_11SlopOptionsE (libslopy.so.7.4)
                                                #9  0x000055f1b6509fc4 _Z3appiPPc (maim)
                                                #10 0x000055f1b6502a56 main (maim)
                                                #11 0x00007f69e819b223 __libc_start_main (libc.so.6)
                                                #12 0x000055f1b6502a8e _start (maim)