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

Bug 323092

Summary: ScrollBar SelectionEvent detail field not being set correctly at end of a drag
Product: [Eclipse Project] Platform Reporter: Thomas Kockerbauer <tkoecker>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
This patch should fix the problem none

Description Thomas Kockerbauer CLA 2010-08-18 18:23:59 EDT
I have the same problem that was reported in bug 104779 a few years ago. The SelectionEvents generated by the ScrollBar widget sometimes do not have SWT.NONE set in the detail field of the event at the end of dragging (especially if I release the mouse button while still dragging).
I had a look into the source code (ScrollBar.java) and found something that has not been changed since revision 1.61 (which was the commit for bug 104779) and it looks like this never could have worked:

The "detail" field in ScrollBar (which is not the same as in the event) is set to gtk constant values (e.g. OS.GTK_SCROLL_JUMP) but is later checked against SWT.DRAG.
Also the "detail" field is always cleared after the switch statement in gtk_value_changed() (in addition to the next line where it is cleared when the "detail" field is != OS.GTK_SCROLL_JUMP), so the check in gtk_event_after will never trigger.

I've attached a patch which fixes the problem for me.
Comment 1 Thomas Kockerbauer CLA 2010-08-18 18:26:13 EDT
Created attachment 176942 [details]
This patch should fix the problem
Comment 2 Felipe Heidrich CLA 2010-08-20 10:32:32 EDT
Not sure why they got this wrong in bug 104779.

I see your code makes sense, good patch.
I'll run a quick test and release it. Thank you very much.
Comment 3 Felipe Heidrich CLA 2010-08-20 12:24:43 EDT
On my machine this always work.

SWT.DRAG == GTK_SCROLL_JUMP == 1

and

I always was receive a gtk_change_value (not followed by gtk_value_changed) before the key up event-after.

-- 

In your case, I believe you are not getting the last gtk_change_value, so the code that always sets detail = NONE (without testing dragSent) is burning you.

The confusing part is need of the dragSent flag, it also wants to make sure the user gets at least one detail=DRAG before sending a detail=NONE (is case gtk_value_changed is never called: the user click the thumb and hold, but doesn't move, then released the button).


Anyhow, your code is correct.

Fixed in HEAD > 20100820