Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312642 - Browser VisibilityWindowListener events not reported correctly on linux-x86_64 and win32-win32-x86
Summary: Browser VisibilityWindowListener events not reported correctly on linux-x86_6...
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 11:05 EDT by Misha Koshelev CLA
Modified: 2010-05-12 17:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Misha Koshelev CLA 2010-05-12 11:05:22 EDT
Build Identifier: SWT 3.5.2 running outside Eclipse

Dear All:

I am using:
swt-3.5.2-gtk-linux-x86_64.jar (Firefox 3.0)
swt-3.5.2-win32-win32-x86.jar (IE 7? on Windows XP 64-bit)

On both, I am unable to get any events with VisibilityWindowListener. For example, the example found here:
http://www.java2s.com/Tutorial/Java/0280__SWT/AddingVisibilityWindowListener.htm
never calls the visibility listeners.

I have gotten around this by using the SWT.Show and SWT.Hide listeners for the parent shell as shown in following code snippet. Please correct me if I am missing something simple, but it seems per instructions I _should_ get notified or visibility changes (e.g., shell.open()) and I do _not_.

Thank you
Misha

---
	browser.addVisibilityWindowListener(new VisibilityWindowListener() {
		public void hide(WindowEvent event) {
		    debug("VisibilityWindowListener.hide: "+event);
		    setVisible(false);
		    synchronized(driver) {
			driver.notifyAll();
		    }
		} 
		public void show(WindowEvent event) {
		    debug("VisibilityWindowListener.show: "+event);
		    setVisible(true);
		    synchronized(driver) {
			driver.notifyAll();
		    }
		} 
	    });
	browser.getShell().addListener(SWT.Hide,new Listener() {
		public void handleEvent(Event event) {
		    debug("SWT.Hide,Listener.handleEvent: "+event);
		    setVisible(false);
		    synchronized(driver) {
			driver.notifyAll();
		    }
		}
	    });
	browser.getShell().addListener(SWT.Show,new Listener() {
		public void handleEvent(Event event) {
		    debug("SWT.Show,Listener.handleEvent: "+event);
		    setVisible(true);
		    synchronized(driver) {
			driver.notifyAll();
		    }
		}
	    });

Reproducible: Always
Comment 1 Grant Gayed CLA 2010-05-12 17:27:21 EDT
These listeners are invoked when an action in an existing Browser causes a second Browser to be opened.  The correct use of these listeners is demonstrated in http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet173.java .  To see them in action run the linked snippet and point it at a file with the following content:

<html>
<script type="text/javascript">
	setTimeout("window.open('http://www.eclipse.org', '', 'menubar=1,width=600, height=600');", 3000);
</script>
<body>
This test uses javascript to open a new window after 3 seconds.
</body>
</html>

Closing as WORKSFORME.  If the case above fails for you then please follow up here.