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

Region selection in "import" command produce corrupted graphics and output (Unexpected lines). #1460

Closed
3 tasks done
OmarEmaraDev opened this issue Jan 24, 2019 · 6 comments · Fixed by #1563
Closed
3 tasks done
Milestone

Comments

@OmarEmaraDev
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

When taking a screenshot using the command import test.png, the rectangle lines used to visualize the selected region leave trails and artifacts, those lines are preserved and are visible in the final image. This gif illustrates the problem:

Problem

Steps to Reproduce

Execute: import test.png

System Configuration

  • ImageMagick version: 7.0.8
  • Environment (Operating system, version and so on): Arch Linux. Deepin Desktop Environment. Using AMDGPU driver with Mesa's RadeonSI OpenGL implementation on an RX 590.
  • Additional information:
Features: Cipher DPC HDRI Modules OpenCL OpenMP 
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib

This question on SuperUser seem to be related.

@urban-warrior
Copy link
Member

urban-warrior commented Jan 26, 2019

The ImageMagick code that supports "rubber banding" has worked well and remained unchanged for nearly 20 years now. Recently we have on occasion seen the behavior you reported suggesting a change and / or bug in the Windows manager or in the X11 protocol. We'll investigate but it will likely take some time to track the source of this problem particularly since we currently cannot reproduce the problem.

@OmarEmaraDev
Copy link
Contributor Author

@urban-warrior Do you mind pointing me to the source code for the drawing? I might try and solve this myself, since I can replicate it readily.

@urban-warrior
Copy link
Member

Take a look @ MagickCore/XSelectWindow(). XSelectWindow() allows a user to select a window using the mouse. If the mouse moves, a cropping rectangle is drawn and the extents of the rectangle is returned.

@OmarEmaraDev
Copy link
Contributor Author

@urban-warrior It seems the unexpected results are resulted from applications redrawing the regions where the selection happens, thus rubber banding fails.

Grabbing the X server before performing the selection solves the problem. I tried it in multiple situations and it worked fine. Is there an objection to this approach?

@urban-warrior
Copy link
Member

We grab the pointer but your suggesting we grab the server as well. Easy enough to do. Can you create a pull request with the patch or I suspect its just a few lines, you can post it here.

@OmarEmaraDev
Copy link
Contributor Author

@urban-warrior The patch is indeed simple. However, I am not sure how to create diffs. So I just created a pull request #1563. I also added more details to explain why the server should be grabbed.

One question though, what is the significance of (void) in the function call (void) XGrabServer(display);?

@dlemstra dlemstra added this to the 7.0.8-43 milestone Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants