Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 529431

Summary: [GTK3.10+] Snippet294 fails to draw Region
Product: [Eclipse Project] Platform Reporter: Eric Williams <ericwill>
Component: SWTAssignee: Eric Williams <ericwill>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dwille, Lars.Vogel
Version: 4.8   
Target Milestone: 4.8 M7   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/116370
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=f4d292bc19c8e894a4caa26ef5d113d800ad7b6b
https://git.eclipse.org/r/120388
https://git.eclipse.org/r/120655
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf
https://git.eclipse.org/r/120949
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=f6cd30d358f78f2fea020a56b9310faf02b437da
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=7ac153d75bbe583d855662ea077c9ab158c18169
https://bugs.eclipse.org/bugs/show_bug.cgi?id=498217
Whiteboard:
Bug Depends on:    
Bug Blocks: 527444    
Attachments:
Description Flags
Image showing problem when drawing ControlDecoration's hover none

Description Eric Williams CLA 2018-01-04 15:45:32 EST
Running Snippet294 on GTK3.10+ yields a button with no Region drawn over it. GTK2 and GTK3.8- are unaffected.
Comment 1 Eric Williams CLA 2018-01-30 14:17:42 EST
The commit which causes the bug is the following: https://github.com/GNOME/gtk/commit/d22fd7223c75f4720ddb982c659efb0d8d7543c4
Comment 2 Eric Williams CLA 2018-01-30 14:45:37 EST
*** Bug 508599 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2018-01-30 14:51:02 EST
New Gerrit change created: https://git.eclipse.org/r/116370
Comment 4 Eric Williams CLA 2018-02-14 15:47:22 EST
Update: I filed a bug upstream with GTK and they have told this issue is WONTFIX.

The drawing model in GTK3.10 changed such that only native (toplevel) windows are receiving expose (draw) events. This means setRegion() is non-functioning for most widgets except for Shell. 

We can bypass this on X11 using gdk_window_ensure_native() but it breaks a lot of stuff (like Button click events) and other important functionality. On Wayland this doesn't work at all so it's even less ideal.

Another option is to clip the Cairo contexts provided with gtk_draw() to literally shape the widget. I am investigating this approach right now to see whether it's feasible or not.
Comment 6 Eric Williams CLA 2018-03-09 15:15:47 EST
(In reply to Eclipse Genie from comment #5)
> Gerrit change https://git.eclipse.org/r/116370 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=f4d292bc19c8e894a4caa26ef5d113d800ad7b6b

I've merged the drawing portion of this bug. A creative solution will be needed for input handling and events.
Comment 7 Eclipse Genie CLA 2018-03-28 15:57:13 EDT
New Gerrit change created: https://git.eclipse.org/r/120388
Comment 8 Daniel Wille CLA 2018-04-02 16:21:26 EDT
Created attachment 273398 [details]
Image showing problem when drawing ControlDecoration's hover

I'm seeing a slight visual bug that I believe was caused by commit f4d292bc19. When I hover over a ControlDecoration, the hover graphics that are shown look incorrect. I've attached an image from the "New Java Class" wizard that demonstrates. You can see the square box containing the text, and at the bottom there's the "V" shape that is supposed to make the box look like it's sort of popping out of the area where you're hovering. However you can see the area to the left and right of the "V" part of the shape are filled in with the background color of the text area.
Comment 9 Eric Williams CLA 2018-04-02 16:33:15 EDT
(In reply to Daniel Wille from comment #8)
> Created attachment 273398 [details]
> Image showing problem when drawing ControlDecoration's hover
> 
> I'm seeing a slight visual bug that I believe was caused by commit
> f4d292bc19. When I hover over a ControlDecoration, the hover graphics that
> are shown look incorrect. I've attached an image from the "New Java Class"
> wizard that demonstrates. You can see the square box containing the text,
> and at the bottom there's the "V" shape that is supposed to make the box
> look like it's sort of popping out of the area where you're hovering.
> However you can see the area to the left and right of the "V" part of the
> shape are filled in with the background color of the text area.

I can reproduce the issue you describe on 4.7.3, so it cannot be caused by that commit.

I briefly investigated and the issue seems to happen only on Wayland, as 4.7.3 with X11 doesn't exhibit the bug. Please file a separate bug report with bug 516841 as a blocker.
Comment 10 Daniel Wille CLA 2018-04-02 17:52:24 EDT
> I can reproduce the issue you describe on 4.7.3, so it cannot be caused by
> that commit.
> 
> I briefly investigated and the issue seems to happen only on Wayland, as
> 4.7.3 with X11 doesn't exhibit the bug. Please file a separate bug report
> with bug 516841 as a blocker.

That's interesting. My guess would be that this has just always been broken on Wayland. In my case I'm working with CentOS 7.4 / GTK 3.22 / X11 and it definitely doesn't manifest until the changes in Control.setRegion(Region) are introduced. ControlDecoration calls Shell.setRegion(Region), which in turn calls Control.setRegion(Region) in order to affect the shape of its Shell (the code refers to it as a "hover with an arrow pointer"). Reverting the changes to Control.setRegion(Region) does restore the previous behavior for me.

Is the GTK behavior change perhaps only applicable for Control's, and not necessary for Shell's? Perhaps the previous code should be maintained in Shell.getRegion(Region) in place of a call to super.getRegion(Region)?
Comment 11 Eric Williams CLA 2018-04-02 21:21:25 EDT
(In reply to Daniel Wille from comment #10)
> That's interesting. My guess would be that this has just always been broken
> on Wayland. In my case I'm working with CentOS 7.4 / GTK 3.22 / X11 and it
> definitely doesn't manifest until the changes in Control.setRegion(Region)
> are introduced. ControlDecoration calls Shell.setRegion(Region), which in
> turn calls Control.setRegion(Region) in order to affect the shape of its
> Shell (the code refers to it as a "hover with an arrow pointer"). Reverting
> the changes to Control.setRegion(Region) does restore the previous behavior
> for me.

My apologies, you are correct! I really do have to wonder, why is this decoration a Shell modified with setRegion, when we have tooltips? Seems like more work than necessary.


> Is the GTK behavior change perhaps only applicable for Control's, and not
> necessary for Shell's? Perhaps the previous code should be maintained in
> Shell.getRegion(Region) in place of a call to super.getRegion(Region)?

I'll have to investigate. This bug isn't closed yet because there is still some work to be done, but this regression will come first.
Comment 12 Eclipse Genie CLA 2018-04-03 14:01:52 EDT
New Gerrit change created: https://git.eclipse.org/r/120655
Comment 14 Eric Williams CLA 2018-04-03 15:27:14 EDT
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/120655 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf

This fixes the issue with ControlDecorations from comment 8.
Comment 15 Eclipse Genie CLA 2018-04-10 11:27:35 EDT
New Gerrit change created: https://git.eclipse.org/r/120949
Comment 17 Eric Williams CLA 2018-04-11 12:19:36 EDT
(In reply to Eclipse Genie from comment #16)
> Gerrit change https://git.eclipse.org/r/120949 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=f6cd30d358f78f2fea020a56b9310faf02b437da

Second commit that fixes drawing for widgets that are children of Scrollable and such.
Comment 19 Eric Williams CLA 2018-04-16 16:05:01 EDT
(In reply to Eclipse Genie from comment #18)
> Gerrit change https://git.eclipse.org/r/120388 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=7ac153d75bbe583d855662ea077c9ab158c18169

Input handling fixes in master now.
Comment 20 Eric Williams CLA 2018-05-08 10:32:26 EDT
Verified in I20180507-2205.