"import" blocking keyboard I/O

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nobodaddy
Posts: 3
Joined: 2019-07-03T05:46:25-07:00
Authentication code: 1152

"import" blocking keyboard I/O

Post by nobodaddy »

Hi all.

For the last 15+ years, when I did a screenshot, I'd type

$ import foo.png

... and then switch virtual desktops (I have this config'd on fluxbox to be Ctrl-Alt arrow), drag a rectangle across the area I wanted to capture, and that would be that.

After recently upgrading (Slackware), this no longer works. When I type 'import', all keyboard I/O stops, and if I try to use the mouse + toolbar to switch, this is (naturally) interpeted by 'import' as my selection.

I've tried '-screen' and other command line options to no avail, and have searched the problem extensively on the web. I've messed around with 'policy.xml', without result. Honestly, the longstanding default behavior just poof changed, and I'm at a loss.

I realize I can determine the target window, import it, and then edit it (or constrain the geometry in the original import). That's a significant increase in my previous workflow that I'd rather avoid, enough to spend an hour+ trying to get the old default behavior back.

Thanks for any help! Slackware current (kernel 4.19.49), imagemagick-6.9.10_49-x86_64-1
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: "import" blocking keyboard I/O

Post by magick »

We received a couple of reports where the drawing rectangle that defines the area to import was not rendering properly. Errant lines would persist as the rectangle was dragged across the screen. Adding a patch to get exclusive access to the X server resolved the problem, see XGrabServer(). The errant behaviour started a few years ago suggesting a recent change in the X server behaviour triggered the need for exclusive access to the X server as the capture rectangle is drawn.
nobodaddy
Posts: 3
Joined: 2019-07-03T05:46:25-07:00
Authentication code: 1152

Re: "import" blocking keyboard I/O

Post by nobodaddy »

Thanks for the reply!
magick wrote: 2019-07-03T09:34:27-07:00 Adding a patch to get exclusive access to the X server resolved the problem, see XGrabServer(). The errant behaviour started a few years ago suggesting a recent change in the X server behaviour triggered the need for exclusive access to the X server as the capture rectangle is drawn.
It sounds like that would do it. I don't see any reference to this in the Changelog...

https://github.com/ImageMagick/ImageMag ... /ChangeLog

... but I was on an older version (6.7.7) and upgraded to 6.9.10, so a time horizon of "a few years" would fit.

Is the only workaround to explicitly grab a specific window, e.g. w/ '-window $someID' or the like? Perhaps I should add a menu option or key binding (e.g. "Print Screen") so I can be on the right desktop and point, drop the screenshot in some directory. Grounds for further research.

Thanks again for any further feedback; I'll post back my fix to save the next poor slob some effort.
nobodaddy
Posts: 3
Joined: 2019-07-03T05:46:25-07:00
Authentication code: 1152

Re: "import" blocking keyboard I/O

Post by nobodaddy »

nobodaddy wrote: 2019-07-03T16:52:13-07:00 ...
magick wrote: 2019-07-03T09:34:27-07:00 Adding a patch to get exclusive access to the X server resolved the problem, see XGrabServer(). The errant behaviour started a few years ago suggesting a recent change in the X server behaviour triggered the need for exclusive access to the X server as the capture rectangle is drawn.
...
Perhaps I should add a menu option or key binding (e.g. "Print Screen") so I can be on the right desktop and point, drop the screenshot in some directory. Grounds for further research.
Here it is, for anyone else unable to switch desktops and import.

Make a file, say "screenshot". 'chmod' it to make it executable (e.g. chmod 755...) and drop it somewhere in your executable $PATH. Here's the shellcode, which drops a screenshot in the "screenshots" directory if it exists, or just in your $HOME directory (some might want to drop it on their ~/Desktop or the like - just change the line starting with "dest=...").

Code: Select all

#! /bin/sh

dest="$HOME/screenshots"
[ ! -d "$dest" ] && dest="$HOME"
target=$dest/$(date +%y%m%d%H%M%S).png

sleep .25

import $target

unset target
unset dest
The 'sleep' is somewhat gratuitous, but prevents accidental clicking.

Finally, one must add this to the GUI's menu, which for fluxbox entails putting "[exec] (screenshot) {screenshot}" in the '~/.fluxbox/menu' file.

One caveat to remember - 'import' doesn't necessarily play nice with overlapping windows; don't have any when you do this. This is longstanding behavior, but might surprise a newbie.

Thanks again!
Post Reply