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

Bug 189400

Summary: [Widgets] Link widgets flickers on resize
Product: [Eclipse Project] Platform Reporter: Michael Schneider <michschn>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact: Felipe Heidrich <eclipse.felipe>
Severity: normal    
Priority: P3 CC: snorthov
Version: 3.3Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Michael Schneider CLA 2007-05-28 07:11:38 EDT
Build ID: Build id: I20070503-1400

The flickering can be reproduced using the snippet below, just resize the shell. The flickering is the most obvious when using a background image, but can be seen without too.

package org.eclipse.swt.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;

public class Snippet182 {

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

		final Image image = new Image (display, 50, 50);
		GC gc = new GC (image);
		gc.setForeground(display.getSystemColor (SWT.COLOR_WHITE));
		gc.setBackground (display.getSystemColor (SWT.COLOR_GRAY));
		gc.fillGradientRectangle(0, 0, 50, 50, true);
		gc.dispose ();
		
		final Shell shell = new Shell(display);
		shell.setBackgroundImage(image);
		shell.setBackgroundMode(SWT.INHERIT_FORCE);
		final Link link = new Link(shell, SWT.NONE);
		link.setText("This a very simple <A>link</A> widget.");
		link.setSize(140, 40);
		shell.addControlListener(new ControlListener() {
			public void controlMoved(ControlEvent arg0) {
			}
			public void controlResized(ControlEvent arg0) {
				Rectangle clientArea = shell.getClientArea();
				link.setSize(clientArea.width, clientArea.height);
			}
		});
		shell.pack ();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Steve Northover CLA 2007-05-28 11:43:52 EDT
Note that setBackgroundImage() and setBackgroundMode() are being used.  Do they flicker without this?
Comment 2 Felipe Heidrich CLA 2008-03-12 18:26:33 EDT
Win32 SysLink just flash a lot (the foreground). I wrote a PI only example to prove it. 

When you set a image background in the parent it gets worse.
It doesn't flash when:
-color background in the parent;
-image background in the link;
-color background in the link.

The foreground just always flash.

Comment 3 Steve Northover CLA 2008-03-12 18:51:01 EDT
Please attach the code.  I'm pretty sure we could work around this by double buffering or getting in the way of WM_SIZE or ...

I'm not sure we should try, that's all.
Comment 4 Felipe Heidrich CLA 2008-03-13 10:39:00 EDT
Here is the code:

public static void main(String[] args) {
	OS.InitCommonControls();
	final int hwndShell = OS.CreateWindowEx (
		0,
		new TCHAR (0, "#32770", true),
		null,
		OS.WS_VISIBLE | OS.WS_OVERLAPPEDWINDOW,
		OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
		0,
		0,
		OS.GetModuleHandle (null),
		null);

	int linkFlags = OS.WS_CHILD | OS.WS_VISIBLE;//| OS.WS_CLIPSIBLINGS|OS.SS_NOTIFY| OS.SS_LEFTNOWORDWRAP;
	int linkExFlags = 0;
	final int hwndLink = OS.CreateWindowEx (
			linkExFlags,
			new TCHAR (0, "SysLink", true),
			new TCHAR (0, "&#60;some&gt; <a>bogus</a> \u2039hi\u203atext", true),
			linkFlags,
			0,0,0,0,
			hwndShell,//parent
			0,//menu
			OS.GetModuleHandle (null),//instance
			null);

	// SHELL WINPROC
	final int oldProc = OS.GetWindowLong (hwndShell, OS.GWL_WNDPROC);
	Object windowProc = new Object () {
		public int windowProc (int hwnd, int msg, int wParam, int lParam) {
			switch (msg) {
				case OS.WM_CLOSE:
					OS.PostMessage (hwnd, /*OS.WM_QUIT*/ 0x12, 0, 0);
				case OS.WM_SIZE:
					RECT rect = new RECT();
					OS.GetClientRect(hwndShell, rect);
					int flags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
					OS.SetWindowPos (hwndLink, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags);
					
					break;
			}
			return OS.CallWindowProc (oldProc, hwnd, msg, wParam, lParam);
		}
	};
	Callback newProc = new Callback (windowProc, "windowProc", 4);
	OS.SetWindowLong (hwndShell, OS.GWL_WNDPROC, newProc.getAddress ());
	
	OS.ShowWindow (hwndShell, OS.SW_SHOW);	
	MSG msg = new MSG ();
	while (OS.GetMessage (msg, 0, 0, 0)) {
		OS.TranslateMessage (msg);
		OS.DispatchMessage (msg);
	}
}
Comment 5 Felipe Heidrich CLA 2009-08-21 16:30:12 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 6 Leo Ufimtsev CLA 2017-08-03 12:32:17 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 7 Eclipse Genie CLA 2020-02-13 16:52:00 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.