Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 474459 - Scrolled composite of composite is not scrolling in linux GTK3 when using style (SWT.BORDER)
Summary: Scrolled composite of composite is not scrolling in linux GTK3 when using sty...
Status: CLOSED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.4.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-06 22:24 EDT by Abhishek Singh CLA
Modified: 2016-04-27 00:25 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Abhishek Singh CLA 2015-08-06 22:24:47 EDT
I have this application that has a scrolled composite containing a grid of composites. Here is the code below:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class ScrolledCompositeExample {
    public static class CustomWidget extends Composite {
        public CustomWidget(Composite parent, int style) {
            super(parent, style);
            setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
            RowLayout rowLayout = new RowLayout();
            rowLayout.spacing = 50;
            setLayout(rowLayout);
            Label label1 = new Label(this, SWT.NONE);

            label1.setText("This is one label" + SWT.getVersion());

            Label labelMain = new Label(this, SWT.NONE);
            labelMain.setText("This is another label");

            Button button = new Button(this, SWT.PUSH);
            button.setText("This is a button ");
        }
    }

    public static void main(String[] args) {
        Display display = new Display();

        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());

        final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.BORDER);

        final Composite parent = new Composite(scrollComposite, SWT.NONE);
        for (int i = 0; i <= 500; i++) {
            CustomWidget item = new CustomWidget(parent, SWT.BORDER);
            GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
            gd.heightHint = 80;
            item.setLayoutData(gd);
        }
        GridLayout layout = new GridLayout(1, true);
        layout.horizontalSpacing = -1;
        layout.verticalSpacing = -1;

        parent.setLayout(layout);

        scrollComposite.setContent(parent);
        scrollComposite.setExpandVertical(true);
        scrollComposite.setExpandHorizontal(true);
        scrollComposite.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));

        shell.setSize(1000, 500);
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }

}


This works properly on Windows SWT. I can scroll using the mouse scroll wheel when my mouse is over the composites.

However the same code does not work on Linux GTK3 SWT. The window does not scroll when the mouse is over the composites. It only scrolls when I m over the scroll bar or when I reduce the composite to not FILL the parent composite. I really want the ability to allow scrolling over the customWidget composites since I plan to use this on a touch panel.
Comment 1 Leo Ufimtsev CLA 2015-08-07 17:41:11 EDT
Does snippet5 scroll for you?
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet5.java

I recall I had to use setContent(.) to get scrolling to work, but it seems like you're already usigng it in your code.

Do you know which version of Gtk3?
Comment 2 Abhishek Singh CLA 2015-08-10 08:08:16 EDT
Hi Leo,

Yes the Snippet5 example works for me. 

Playing with the examples more I think the  issue is with the SWT style BORDER

Scrolling works in GTK when 
       Composite b1 = new Composite(c1, SWT.NONE);

But when I make it 
       Composite b1 = new Composite(c1, SWT.BORDER);

So in my sample below if you change the style of Custom Widget to SWT.NONE then it works in GTK3 but when I pass in SWT.BORDER then the scrolling stops. 

The version of GTK3 that I am using is gtk3-3.10.9-2.fc20.x86_64
  Name        : gtk3
  Version     : 3.10.9
  Release     : 2.fc20
  Architecture: x86_64

Regards
Abhishek
Comment 3 Eclipse Genie CLA 2015-12-18 11:30:44 EST
New Gerrit change created: https://git.eclipse.org/r/63039
Comment 4 Alexander Kurtakov CLA 2016-04-01 05:37:06 EDT
This looks like duplicate of bug 479580 . Would you please try with Neon M6? It should be fixed there.
Comment 5 Alexander Kurtakov CLA 2016-04-27 00:25:18 EDT
 4 weeks without reply from report. Marking the bug as closed as I can't reproduce it anymore. If the problem still persists for you with latest Neon please reopen with details.