-
Notifications
You must be signed in to change notification settings - Fork 30
[GTK3] Issue 371 - Fix crash when taking a snapshot on Wayland #465
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
Conversation
5f3e92e
to
5f771d3
Compare
For example, this code snippet will cause WindowBuilder to crash, when opened on Wayland:
Because the button "111" is partially outside the visible area, we are unable to create a snapshot of it. This seems to be an issue within Wayland itself. And I don't know if/how this could be resolved. So my solution is to delegate this problem to SWT, which seems to have a much more stable snapshot implementation. |
fb4526f
to
a24be13
Compare
As mentioned in the initial comment, this should fix the crash when using WindowBuilder with Wayland. In short, taking a screenshot of a partially mapped widget is not something that Wayland can handle very well. @vogella Since you initially reported the bug, can you check whether the JUnit tests finish on your machine, when using this branch? I'm using X11, so I only have limited access to Wayland, so I can't say for certain whether I've missed something. The pull request might still a draft, but I don't expect any major deviation from the current solution. Please note that there is a high chance that the preview in the Design page will be complete blank (on Wayland at least). It seems like taking a simple screenshot of a widget is also something that doesn't work very well in Wayland. But that problem also exists on the master. See eclipse-platform/eclipse.platform.swt#673. |
b7dd260
to
62d6de7
Compare
@ptziegler sorry, this week busy with something else. If it is still relevent next week, please ping me again, unfortunately my Eclipse email flow is steady and without me looking at it regulary, things scroll out of sight fast. |
No worries :) Even though I only used a very limited Wayland test-environment, I was able to reproduce and fix the problem within it. So I assume it should work in general. |
ec67122
to
2aa6ecb
Compare
In short, our implementation doesn't seem to support taking snapshots of partially unmapped widgets when running Wayland instead of X11. Instead of trying to implement a workaround in native code, I think it's more efficient (for both the sake of complexity and maintainability) to elevate our snapshot mechanism from C to Java code. Where necessary, we call the native GTK methods either by the GTK/GDK class or via wrapper methods implemented by WindowBuilder. The snapshot is taken by creating a new image using the bounds of the widget and by painting the area it's occupying on the screen via GC. Note that this approach assumes that the widget isn't obstructed. But a similar restriction already exists on the native implementation. Shells represent a special edge-case. Instead of only taking a snapshot of the client area, the whole shell is considered. This way the title bar is included as well, rendering the explicit painting of its decorations obsolete.
In short, our implementation doesn't seem to support taking snapshots of
partially unmapped widgets when running Wayland instead of X11.
Instead of trying to implement a workaround in native code, I think it's
more efficient (for both the sake of complexity and maintainability) to
elevate our snapshot mechanism from C to Java code. Where necessary, we
call the native GTK methods either by the GTK/GDK class or via wrapper
methods implemented by WindowBuilder.
The snapshot is taken by creating a new image using the bounds of the
widget and by painting the area it's occupying on the screen via GC.
Note that this approach assumes that the widget isn't obstructed. But a
similar restriction already exists on the native implementation.
Shells represent a special edge-case. Instead of only taking a snapshot
of the client area, the whole shell is considered. This way the title
bar is included as well, rendering the explicit painting of its
decorations obsolete.
Using the high-level SWT API for taking the snapshot also means we can
drastically reduce the complexity of our code. Instead of having to deal
with pointers, we can use the high-level construct of images.
May resolve #371