Re: [Java-gnome-developer] Unable to Activate an hidden Window from a third party library callback
Brought to you by:
afcowie
|
From: Andrew C. <an...@op...> - 2010-04-12 22:45:58
|
On Mon, 2010-04-12 at 23:38 +0200, Frédéric LABBE wrote:
>
> I'm working on a project which deals with building a Clipboard History
> tool.
Hey, cool. Neat.
> I use JXGrabkey to register a global/system wide X11 hotkey in order
> to hide/to put to front the application main window.
So the question seems to be how to properly implement a desktop wide
hotkey. That's interesting.
The window manager gets away with this, obviously, but the question is
how other apps can register such a thing. I've noticed a few
applications that seem to do so. Hamster Applet's preference dialog has
a "global hotkey" Entry which contains (on my system anyway)
"<Super>+H", for example.
Maybe we could have a look at their code (which is Python, I'm afraid)
to see what they're doing.
> void toggleMainWindow () {
I have something similar in Slashtime. Keeping the state variables about
whether you are minimized or not is trickier than it should be; I think
the compositors of the last few years have messed with (ie) the
VisibilityEvents.
> 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
Oh, it works, ok :)
> 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.
Yeah, Widget's grabFocus() is about focus within the application. It's a
lot harder to force the window manager to do something if you're not the
currently active application.
Did you try Window's present()?
http://java-gnome.sourceforge.net/4.0/doc/api/org/gnome/gtk/Window.html#present()
> Did I miss a point ? Am I doing something the wrong way ?
I don't think so, but you're outside the boundaries of a single
application, so we need to work cooperatively with the window manager.
There's only so much we can do there; getting focus behaviour right
between applications (ie, preventing focus stealing) has taken the
window-manager people years to get right.
> Are my troubles due to the TreadAwareness design of Java-gnome ?
No, I don't think so (ie, it's working, not crashing or blocking, so
you're probably ok).
But the fact you're having to go straight to X (instead of letting GDK
do it for you) is a very bad sign; that usually causes problems.
>
> Any ideas to implement the described behavior with a different code
> design ?
Not off hand, but then I've never tried to come up with a global hot
key. If I had to guess, the right question to ask is "what's the GNOME
way to take a keypress globally", perhaps
http://live.gnome.org/ControlCenter/ApplicationDefinedKeybindings
Once we know what we're doing, then we can figure out what to add to
java-gnome if we need to.
AfC
Sydney
--
Andrew Frederick Cowie
Operational Dynamics is an operations and engineering consultancy
focusing on IT strategy, organizational architecture, systems
review, and effective procedures for change management: enabling
successful deployment of mission critical information technology in
enterprises, worldwide.
http://www.operationaldynamics.com/
Sydney New York Toronto London
|