Bug 171223 - Under gtk/Linux always all figures of the FigureCanvas are repainted (if double buffering is not disabled)
Summary: Under gtk/Linux always all figures of the FigureCanvas are repainted (if doub...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Bogdan Gheorghe CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2007-01-22 09:46 EST by Micha Riser CLA
Modified: 2018-05-30 10:51 EDT (History)
4 users (show)

See Also:


Attachments
Program showing the problem (1.74 KB, text/x-java)
2007-01-22 09:50 EST, Micha Riser CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Micha Riser CLA 2007-01-22 09:46:48 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Create a FigureCanvas with multiple lables
2. Invoke paint() on one label
3. All labels are repainted instead of only the one requested!

This does not happen under Windows or if the SWT.NONE style is given on creating the FigureCanvas. 

More information:
GEF is version 3.2.1.v20060921

The bug might as well be in the gtk/swt. I traced it and the problem seems to be that the clipping region is 0 in the gc that comes with the SWT paint event:

(from Line 105 in LightWeightSystem)
canvas.addListener(SWT.Paint, new Listener() {
		public void handleEvent(Event e) {
			LightweightSystem.this.paint(e.gc);
		}
	});

The event object has the x,y,width and height set to the rectangle that needs repainting. Invoking e.gc.getClipping() however returns a rectangle for the whole figure. This is done in the paint(GC) method of the DeferredUpdateManager when the SWTGraphics object is created. So a workaround might be to pass the clipping rectangle from the event together with the gc to the paint methods and use this to create the SWTGraphics object.
Comment 1 Micha Riser CLA 2007-01-22 09:50:07 EST
Created attachment 57256 [details]
Program showing the problem

This example shows that all figures are repainted.

Expected output:
...
request repaint of label 4
paint label 4

Actual output:
...
request repaint of label 4
paint label 1
paint label 2
paint label 3
paint label 4
paint label 5
paint label 6
Comment 2 Sandi Schoellhammer CLA 2007-01-26 08:27:04 EST
I can verify this one. 

A workaround is to hook into the control before the lightweightsystem does it and then set the clipping on the GC when a paint event occurs. I haven't added OS detection for the workaround.

Extending GraphicalViewerImpl and override this method:

@Override
    protected LightweightSystem createLightweightSystem() {
        return new LightweightSystem() {
            private Canvas canvas;
            @Override
            protected void addListeners() {
                canvas.addPaintListener(new PaintListener() {
                    public void paintControl(PaintEvent e) {
                        e.gc.setClipping(e.x, e.y, e.width, e.height);
                    }
                });
                super.addListeners();
            }  
          
            @Override
            public void setControl(Canvas c) {
                canvas = c;
                super.setControl(c);
            }
        };
    }
Comment 3 Randy Hudson CLA 2007-01-26 13:09:10 EST
Please move this bug to the SWT component in Platform.
Comment 4 Steve Northover CLA 2007-01-30 08:56:49 EST
Seems really strange that the right clipping is in the paint rectangle but not in the GC (as implied by comment #2).
Comment 5 Steve Northover CLA 2007-01-30 08:57:35 EST
... I meant to say "clipping is in the paint event rectangle" ...
Comment 6 Micha Riser CLA 2009-06-24 04:02:40 EDT
I re-run my example application and the bug does not show any more with
* GEF 3.4.1

I do not know what has changed though.


Comment 7 Eric Williams CLA 2018-05-16 11:39:43 EDT
Do you still experience this issue?
Comment 8 Eric Williams CLA 2018-05-30 10:51:31 EDT
Closing this bug now due to age and inactivity. Please re-open this ticket if the issue is reproducible on 4.8 with GTK3.22.