Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 82087 - Native text components not receiving expose notifications
Summary: Native text components not receiving expose notifications
Status: RESOLVED DUPLICATE of bug 26095
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Billy Biggs CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-03 08:13 EST by Srimanth CLA
Modified: 2005-03-14 14:50 EST (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 Srimanth CLA 2005-01-03 08:13:58 EST
For some components like Text, SWT somehow seems to be blocking notification of
EXPOSE-EVENTs to the native GTK control. When a parent of a Text control is sent
an explicit EXPOSE-EVENT, all the children except the Text are getting the
notifications. In the Widget.windowProc() method, the expose events are not
processed if the Widget.OBSCURED flag is set on them - this could have something
to do with the stopping of the notification. The text components seem to have 
this efficiency coded to reduce expensive text drawing. 
There should be a programmatic way (api/public field) of telling the text to be
or not to be efficient/stop EXPOSE-EVENT notifications.
Comment 1 Steve Northover CLA 2005-01-04 13:21:15 EST
BB to construct a simple example that shows the problem and determine whether 
Widget.OBSCURED is burning us.
Comment 2 Billy Biggs CLA 2005-01-05 15:38:40 EST
This code works for me.  Can you give me an example where it fails?

public class Bug82087 {
	public static void main(String [] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Click to redraw() the shell.");
		button.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent e) {}
			public void widgetSelected(SelectionEvent e) {
				System.out.println("Calling shell.redraw():");
				Rectangle r = shell.getClientArea();
				shell.redraw(r.x,r.y,r.width,r.height,true);
			}
		});
		
		Text text = new Text(shell, SWT.NONE);
		text.addListener(SWT.Paint, new Listener() {
			public void handleEvent(Event event) {
				System.out.println("Text: SWT.Paint");
			}});
		Composite composite = new Composite(shell, SWT.NONE);
		composite.addListener(SWT.Paint, new Listener() {
			public void handleEvent(Event event) {
				System.out.println("Composite: SWT.Paint");
			}});
		shell.pack();
		shell.open();
		while(!shell.isDisposed()) {
			if(!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}
}
Comment 3 Srimanth CLA 2005-01-21 11:50:30 EST
The way I became aware of this problem was that I have some native code which 
sends expose events to the native widgets. However when I send expose events 
to obscured GTK text widgets, the GTK widgets do not receive requests to 
repaint themselves. After digging through a bit it was found that SWT stops 
the propgation of the expose event to native widgets which are obscured. 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=65269 

It would be helpful to have an API/setting which would allow the propagation 
of the expose-event even if the widget is obscured.
Comment 4 Billy Biggs CLA 2005-01-21 12:10:51 EST
Can you give me more information about why this is useful, or a test case which
shows this flag to be problematic?
Comment 5 Srimanth CLA 2005-01-21 12:27:51 EST
This would be helpful for us in doing off-screen/hidden GTK SWT application 
screen capture. If there is any SWT application which is offscreen or hidden 
behind other applications, we need to send paint requests (via expose events) 
to all the native widgets. Having the expose events blocked from reaching the 
native widgets would not allow them to paint their contents.
Some API/setting of being able to tell the widget to allow expose events to 
pass through even when hidden/obscured would be very helpful.
Comment 6 Billy Biggs CLA 2005-01-21 13:07:16 EST
How are you capturing the results of the expose event?
Comment 7 Billy Biggs CLA 2005-03-14 14:50:34 EST
Adding API to change this behaviour is not appropriate as it exposes an
implementation detail that is subject to change.  The OBSCURED code may be
removed anyway for other reasons, but it is an important performance
optimization and so we must be careful.

I am marking this as a duplicate of bug 26095 which is tracking the enhancement
request for an API to capture widget contents since this is the desired
functionality.  The upstream bug requesting this feature in GTK+ is here:

  http://bugzilla.gnome.org/show_bug.cgi?id=164854

Note that I could not reproduce any specific problems with the Text widget
compared to other widgets.  If you have evidence that shows we are doing
something incorrect with Text widgets in particular, please feel free to re-open
this bug.

*** This bug has been marked as a duplicate of 26095 ***