Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT window lock with Openoffice on Linux
SWT window lock with Openoffice on Linux [message #764853] Tue, 13 December 2011 00:38 Go to next message
othman  is currently offline othman Friend
Messages: 1
Registered: December 2011
Junior Member
Hi,
i posted a SWT /Libreoffice bug at: bugs.freedesktop.org/show_bug.cgi?id=43415
it seems this didn't got attention in libreoffice forums. seems a hard issue for OOo developers.
I wonder if developers in SWT project could investigate this issue and propose a fix.
it seems this issue makes SWT uncapable to be integrated with Openoffice /libreoffice on Linux systems. it is probably a linux GTK issue .

i hope someone at this forum would be interested to help fixing this annoying issue.
i'm replicating the bug details below.

thanks.

-----------------
In my linux box, I created an extension that uses SWT browser to launch an swt
browser window.
when i close this window the whole Openoffice application freezes and becomes
unresponsive for some cases the whole libreoffice crashes after closing the SWt
window.
i suspect this to be related to some issue with GTK. if i remove a SWT call
"display.dispose()' LOo dose'nt crash but my SWT window becomes unusable . if i
try re-launch the SWT window again it doesn't shows up. removing the
display.dispose() solves the crash but makes my SWT window nu-usable. It seems
the bug is related to this 'display.dispose()' SWT statement which causes the
Loo to crash for some reason .
I'm providing the SWT code below. i also include a oxt demo to replicate this
issue on Linux.

import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.CloseWindowListener;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.browser.OpenWindowListener;
import org.eclipse.swt.browser.VisibilityWindowListener;
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
*
* @author othman
*/
public class SWTBrowser {

private Shell shell;
// private Browser browser;
private static final int WINDOW_WIDTH = 780;
private static final int WINDOW_HEIGHT = 570;

/**
* SWTBrowser application entry point
*
* @param args the command line arguments
*/
public static void main(String[] args) {
new SWTBrowser(args.length == 0 ? null : args[0]);
}

/**
* Constructor
*
* @param location the initial location to display
*/
public SWTBrowser(String location) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Main Window");
shell.setLayout(new FillLayout());
final Browser browser;
try {
browser = new Browser(shell, SWT.NONE);
} catch (SWTError e) {
System.out.println("Could not instantiate Browser: "
+ e.getMessage());
display.dispose();
return;
}
initialize(display, browser);
shell.open();
browser.setUrl(location);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();

}

/* register WindowEvent listeners */
static void initialize(final Display display, Browser browser) {
browser.addOpenWindowListener(new OpenWindowListener() {

@Override
public void open(WindowEvent event) {
if (!event.required) {
return; /* only do it if necessary */
}
Shell shell = new Shell(display);
shell.setText("New Window");
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
initialize(display, browser);
event.browser = browser;
}
});
browser.addVisibilityWindowListener(new VisibilityWindowListener() {

@Override
public void hide(WindowEvent event) {
Browser browser = (Browser) event.widget;
Shell shell = browser.getShell();
shell.setVisible(false);
}

@Override
public void show(WindowEvent event) {
Browser browser = (Browser) event.widget;
final Shell shell = browser.getShell();
if (event.location != null) {
shell.setLocation(event.location);
}
if (event.size != null) {
org.eclipse.swt.graphics.Point size = event.size;
shell.setSize(shell.computeSize(size.x, size.y));
}
shell.open();
}
});
browser.addCloseWindowListener(new CloseWindowListener() {

@Override
public void close(WindowEvent event) {
Browser browser = (Browser) event.widget;
Shell shell = browser.getShell();
shell.close();
}
});
}



/**
* This class implements a CloseWindowListener for SWTBrowser
*/
class BrowserCloseWindowListener implements CloseWindowListener {

/**
* Called when the parent window should be closed
*/
@Override
public void close(WindowEvent event) {

// Close the parent window
((Browser) event.widget).getShell().close();


}
}

/**
* This class implements a LocationListener for SWTBrowser
*/
class BrowserLocationListener implements LocationListener {
// The address text box to update

//private Text location;
/**
* Constructs an BrowserLocationListener
*
* @param text the address text box to update
*/
public BrowserLocationListener() {
// Store the address box for updates
}

/**
* Called before the location changes
*
* @param event the event
*/
@Override
public void changing(LocationEvent event) {
// Show the location that's loading
// System.out.println("Loading " + event.location + "...");
}

/**
* Called after the location changes
*
* @param event the event
*/
@Override
public void changed(LocationEvent event) {
// Show the loaded location
// System.out.println("loaded location : " + event.location);
/* if (event.location.contains("/callback?type=google")) {
display.timerExec(2000, new Runnable() {

public void run() {
if (!shell.isDisposed()) {
shell.dispose();
}
display.dispose();
}
});

}*/
}
}
}

I'm using the following software:
Libreoffice 3.4
openJDK 6
Linux 3.1.2-1-desktop i686
System: openSUSE 11.4 (i586)
KDE: 4.6.00 (4.6.0) "release 6"

[Updated on: Tue, 13 December 2011 00:44]

Report message to a moderator

Re: SWT window lock with Openoffice on Linux [message #1015280 is a reply to message #764853] Thu, 28 February 2013 02:43 Go to previous message
Nathan Robinson is currently offline Nathan RobinsonFriend
Messages: 1
Registered: February 2013
Junior Member
Well, I just ran into this issue. It wasn't with Open Office, but it was with my own application -- which was a GTK app.


What is happening is that display.dispose() does a whole lot of things, one of which is call 'OS.gdk_event_handler_set (0, 0, 0);' and, as one might think -- huh? It's removing the event handler!!

It makes sense, from the perspective of SWT, since it is removing the same event handler that SWT added earlier. It's good that it's cleaning up after itself.

Well, this is REALLY BAD if you want to keep on using GTK, since once you remove the event handler from GTK, as you can imagine, GTK stops responding to events. There can only be one main event handler, so to make GTK work again, you must re-add an event handler after SWT cleans itself up.

What gtkMain.c does on initialization is call: gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL);

Do that and GTK will work again.
-robinson
Previous Topic:Populate table row on tree item click using SWT
Next Topic:Problem with copying and pasting in XULRunner Browser on Eclipse
Goto Forum:
  


Current Time: Sat Apr 27 04:59:39 GMT 2024

Powered by FUDForum. Page generated in 0.03197 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top