[Java-gnome-developer] Unable to Activate an hidden Window from a third party library callback meth
Brought to you by:
afcowie
|
From: Frédéric L. <lab...@gm...> - 2010-04-12 21:38:45
|
Hi !
I'm working on a project which deals with building a Clipboard History tool.
I've built the tool out of the following components:
+ a java-gnome GTK app (developed by myself). (widget tree detailed at
the end of this post)
+ JXGrabkey (native shared library+ JNI Java bindings)
+ a custom native shared library used to monitor clipboard content (no
implications with this post)
I use JXGrabkey to register a global/system wide X11 hotkey in order to
hide/to put to front the application main window.
When the defined hotkey is pressed then released the JXGrabkey java binding
is called and calls a supplied java callback
which I implemented as follow
public static void hotkeyCallBack() {
clippo.toggleMainWindow();
}
where clippo is an instance of my app Class with the toggleMainWindow
implemented as follow :
void toggleMainWindow () {
if (isMainWindowVisible || isMainWindowMinimized) {
mainWindow.hide();
} else {
isMainWindowVisible=true;
isMainWindowMinimized=false;
mainWindow.grabFocus();
//clipItemListView.grabFocus();
}
}
This call back is not executed in the main Thread but in a Thread initiated
by JXGrabKey.
It works fine as the window is successfully hidden or shown but I experience
the following behavior :
When the window is show (hidden state to visible), the window stays
unselected and the keypress are still
sent to whatever window I was using prior using the hotkey.
For example while a Firefox window is opened, active and has focus (I can
scroll page using keyboard arrows),
I press the proper hotkey and my main Window is shown. This window has its
top level set to
true and it is centered with a WindowPosition.MOUSE so the Window is on top
of the display.
I tried using the grabFocus on my Window instance,the tree view instance or
the textinput instance,
aleas! the window keeps staying unselected/unactive (its title bar colour
indicates me it is unselected).
I move arrows the current window is still the browser one. If I click my
window comes active. (I want the user to
be able to do everything without mouse interactions).
Am I doing something the Wrong way. I've been browsing API javadocs without
finding Window.setActive
or obvious workaround.
Did I miss a point ? Am I doing something the wrong way ?
Are my troubles due to the TreadAwareness design of Java-gnome ?
Any ideas to implement the described behavior with a different code design ?
Fred L.
Widget Tree :
Window (mainWindow)
VBox
Treeview
Trextview
|