Community
Participate
Working Groups
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.
BB to construct a simple example that shows the problem and determine whether Widget.OBSCURED is burning us.
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(); } }
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.
Can you give me more information about why this is useful, or a test case which shows this flag to be problematic?
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.
How are you capturing the results of the expose event?
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 ***