Bug 500703 - [GTK3.20+] Combo with SWT.READ_ONLY is garbled upon re-size
Summary: [GTK3.20+] Combo with SWT.READ_ONLY is garbled upon re-size
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.8 M7   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 488489 514189 515026 532883 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-01 13:58 EDT by Eric Williams CLA
Modified: 2018-09-24 06:06 EDT (History)
7 users (show)

See Also:


Attachments
Combo garbled on re-size if SWT.READ_ONLY is specified (6.40 KB, image/png)
2016-09-01 13:58 EDT, Eric Williams CLA
no flags Details
Snippet reproducing the issue (1.10 KB, text/x-java)
2016-09-01 14:00 EDT, Eric Williams CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Williams CLA 2016-09-01 13:58:00 EDT
Created attachment 263905 [details]
Combo garbled on re-size if SWT.READ_ONLY is specified

Creating a Combo with SWT.READ_ONLY causes garbling on re-sizes: specifically when changing the width. See the attached screenshot.
Comment 1 Eric Williams CLA 2016-09-01 14:00:59 EDT
Created attachment 263906 [details]
Snippet reproducing the issue
Comment 2 Eric Williams CLA 2016-09-02 10:44:54 EDT
My initial thoughts on this bug: it seems on GTK3.18, the Combo actually shrinks in size, i.e. the arrow on the right actually moves in the direction of the "Select..." label. On GTK3.20 the Combo doesn't change size, but is simply moved over, until it goes off the screen. On 3.20 the Combo never gets "compacted" like it does on 3.18.

More investigation to follow.
Comment 3 Eric Williams CLA 2016-09-05 16:36:02 EDT
Update: it seems the issue of the overdrawing is being caused by the Combo's clip being significantly larger than the allocation. Adjusting the clip using gtk_widget_set_clip() fixes the issue, but I need to find a proper place to put that call.

Also on GTK3.18 the Combo resizes from the right corner to the left, i.e. the arrow moves and the right side shrinks towards the beginning of the string. On 3.20 the opposite happens (with the set_clip fix), the Combo shrinks from the left side and the end of the sentence is still present.
Comment 4 Alexander Kurtakov CLA 2016-12-20 10:27:40 EST
(In reply to Eric Williams from comment #3)
> Update: it seems the issue of the overdrawing is being caused by the Combo's
> clip being significantly larger than the allocation. Adjusting the clip
> using gtk_widget_set_clip() fixes the issue, but I need to find a proper
> place to put that call.
> 
> Also on GTK3.18 the Combo resizes from the right corner to the left, i.e.
> the arrow moves and the right side shrinks towards the beginning of the
> string. On 3.20 the opposite happens (with the set_clip fix), the Combo
> shrinks from the left side and the end of the sentence is still present.

You probably need to override gtk_size_allocate in Combo for that. Feel free to share whatever info you have gathered and I'll continue it.
Comment 5 Eric Williams CLA 2016-12-20 10:51:48 EST
(In reply to Alexander Kurtakov from comment #4)
> You probably need to override gtk_size_allocate in Combo for that. Feel free
> to share whatever info you have gathered and I'll continue it.

I don't really have much more info apart from what's in comment 3. A good way to see this bug is to play around in GTK inspector. IIRC once the Combo is garbled, using GTK inspector you can see that the clip size is way larger than the Combo size.
Comment 6 Eric Williams CLA 2017-04-27 11:17:39 EDT
*** Bug 515026 has been marked as a duplicate of this bug. ***
Comment 7 Eric Williams CLA 2017-04-27 11:24:16 EDT
(In reply to Eric Williams from comment #6)
> *** Bug 515026 has been marked as a duplicate of this bug. ***

From bug 515026 comment 10: the commit that causes this bug is https://github.com/GNOME/gtk/commit/3e0694284785153944255a0501e84a76c491e4b4.
Comment 8 Eric Williams CLA 2017-04-27 16:43:55 EDT
Some more info:

This bug is a result of GTK3.20 minimum size changes. As of GTK3.20, many widgets do not shrink past their minimum size. In this case, the Combo stays the size of the largest text in its menu. This is already a departure from GTK3.18 behavior, since in 3.18 it was possible to shrink the Combo past its minimum size.

In addition to this, the commit mentioned in comment 7 causes the Combo to be overdrawn. There is a half solution to fix this, which involves manually setting the widget's clip in Combo.setBounds(). However, this does not solve the issue entirely as Alt-tabbing back and forth restores the clip to the wrong size and overdrawing happens again.

Still investigating a better fix.
Comment 9 Eclipse Genie CLA 2017-04-28 10:22:51 EDT
New Gerrit change created: https://git.eclipse.org/r/96035
Comment 10 Eric Williams CLA 2018-03-28 12:49:51 EDT
*** Bug 514189 has been marked as a duplicate of this bug. ***
Comment 11 Eric Williams CLA 2018-04-24 10:49:02 EDT
So there are actually two bugs here.

1) The overdrawing: this is where the Combo overdraws onto the Label next to it and makes quite a mess. It's caused by the commit referenced in comment 7, and can be fixed.

2) The Combo resize issue: this bug is what causes the left edge of the Combo to be moved "under" the Label. Instead of the right edge of the Combo shrinking in width towards the Label, the x position of the Combo's box becomes negative and thus wraps underneath the Label. The commit that introduces this is: https://github.com/GNOME/gtk/commit/222c43fc60362eeb97ce2d5e3a5583a69a2e30ef

I discovered this by reverting the commit from problem 1) in GTK, and noticed that problem 2) was still occurring.

I'll continue to look into problem 2), and I'll push a patch for problem 1) in the meantime.
Comment 13 Eric Williams CLA 2018-04-30 14:11:52 EDT
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/96035 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=7b0cb58a2aedcac5c0973ddf0a9b4ab467c9e875

Patch in master now.
Comment 14 Eric Williams CLA 2018-05-08 10:37:44 EDT
Verified in I20180507-2205.
Comment 15 Eric Williams CLA 2018-05-15 15:57:44 EDT
*** Bug 488489 has been marked as a duplicate of this bug. ***
Comment 16 Eric Williams CLA 2018-09-18 10:21:53 EDT
*** Bug 532883 has been marked as a duplicate of this bug. ***