[sip-comm-dev] [Issue 578] New - SIP Communicator should never steal the focus


#1

Hey Seb,

smazy@dev.java.net wrote:

https://sip-communicator.dev.java.net/issues/show_bug.cgi?id=578
                 Issue #|578
                 Summary>SIP Communicator should never steal the focus

------- Additional comments from smazy@dev.java.net Tue Feb 17 11:42:40 +0000 2009 -------
SIP Communicator sometimes steals the focus from the current application. An
example is when a chat window automatically opens after a new message was
received (video attached).

Agreed, although I am afraid this would not be possible. We have
actually discussed this previously:

https://sip-communicator.dev.java.net/servlets/BrowseList?list=dev&by=thread&from=1141170

and I don't believe anyone found a solution.

If there's anyone today, aware of a way to show java windows without
bringing them to the front, then please comment.

Cheers
Emil

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

window.setFocusableWindowState(false);
window.setVisible(true);

works for me but we don't really want a non focusable window, just a
window which is not focused at opening. Il also tried:

window.setFocusableWindowState(false);
window.setVisible(true);
window.toBack();
window.setFocusableWindowState(true);

but then I still had focus losses.

IMHO this is a big issue, really. We shouldn't ship a product that
steals focus, input and possibly sends it over the network. It is not
only a matter of convenience, but also security (even if the
convenience problem is already big enough).

Still looking for a solution, I'll post again if I find one.

···

On Tue, Feb 17, 2009 at 4:23 PM, Emil Ivov <emcho@sip-communicator.org> wrote:

If there's anyone today, aware of a way to show java windows without
bringing them to the front, then please comment.

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Guys,

Could you please clarify the OS on which it happens? I can see the
issue has its OS set to All. However, Windows specifically protects
against such cases and one needs to explicitly call
AllowSetForegroundWindow to get around it. Moreover, I don't clearly
remember seeing the issue on Windows Vista or 7. Anyway, I think it'll
be of use to anyone working on the issue to have an explicit
mentioning of the tested OS.

Thank you,
Lubo

···

On Tue, Feb 17, 2009 at 7:04 PM, Sébastien Mazy <smazy@dev.java.net> wrote:

On Tue, Feb 17, 2009 at 4:23 PM, Emil Ivov <emcho@sip-communicator.org> wrote:

If there's anyone today, aware of a way to show java windows without
bringing them to the front, then please comment.

window.setFocusableWindowState(false);
window.setVisible(true);

works for me but we don't really want a non focusable window, just a
window which is not focused at opening. Il also tried:

window.setFocusableWindowState(false);
window.setVisible(true);
window.toBack();
window.setFocusableWindowState(true);

but then I still had focus losses.

IMHO this is a big issue, really. We shouldn't ship a product that
steals focus, input and possibly sends it over the network. It is not
only a matter of convenience, but also security (even if the
convenience problem is already big enough).

Still looking for a solution, I'll post again if I find one.

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#4

I commited r5030 which fixes it for me.

However, focus is really window manager dependent and I'd appreciate
to have someone check for possible regressions under KDE (KWin),
Windows, MacOS. The expected behaviour is: when a new chat window is
opened, triggered by a new message, it is brought to front but not
focused.

···

On Tue, Feb 17, 2009 at 6:04 PM, Sébastien Mazy <smazy@dev.java.net> wrote:

Still looking for a solution, I'll post again if I find one.

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#5

Thanks, I've just added to the issue that it happens at least with
Metacity (and probably other window managers).

···

On Tue, Feb 17, 2009 at 6:14 PM, Lubomir Marinov <lubomir.marinov@gmail.com> wrote:

Could you please clarify the OS on which it happens? I can see the
issue has its OS set to All. However, Windows specifically protects
against such cases and one needs to explicitly call
AllowSetForegroundWindow to get around it. Moreover, I don't clearly
remember seeing the issue on Windows Vista or 7. Anyway, I think it'll
be of use to anyone working on the issue to have an explicit
mentioning of the tested OS.

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#6

Hey Seb,

Just tested on Mac OS X.

Opening a chat window manually or upon an incoming message causes the
following exception:

[java] java.lang.NullPointerException
     [java] at java.util.Hashtable.get(Hashtable.java:336)
     [java] at javax.swing.KeyboardManager.registerMenuBar(KeyboardManager.java:263)
     [java] at javax.swing.JMenuBar.addNotify(JMenuBar.java:679)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at javax.swing.JComponent.addNotify(JComponent.java:4478)
     [java] at javax.swing.JRootPane.addNotify(JRootPane.java:680)
     [java] at java.awt.Container.addNotify(Container.java:2544)
     [java] at java.awt.Window.addNotify(Window.java:467)
     [java] at java.awt.Frame.addNotify(Frame.java:501)
     [java] at java.awt.Window.show(Window.java:514)
     [java] at java.awt.Component.show(Component.java:1302)
     [java] at java.awt.Component.setVisible(Component.java:1255)
     [java] at net.java.sip.communicator.util.swing.SIPCommFrame.setVisible(SIPCommFrame.java:352)
     [java] at net.java.sip.communicator.impl.gui.main.chat.ChatWindowManager.openChat(ChatWindowManager.java:88)
     [java] at net.java.sip.communicator.impl.gui.DefaultContactEventHandler$RunMessageWindow.run(DefaultContactEventHandler.java:99)
     [java] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
     [java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
     [java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
     [java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
     [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
     [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
     [java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

As a result there is either no window open or, on occasions, a window
would open but it would not have any of the chat panes.

Incidentally, did you get a chance to test how this patch would behave
with the "Bring to front" option in the config form?

Cheers
Emil

Sébastien Mazy wrote:

···

On Tue, Feb 17, 2009 at 6:04 PM, Sébastien Mazy <smazy@dev.java.net> wrote:

Still looking for a solution, I'll post again if I find one.

I commited r5030 which fixes it for me.

However, focus is really window manager dependent and I'd appreciate
to have someone check for possible regressions under KDE (KWin),
Windows, MacOS. The expected behaviour is: when a new chat window is
opened, triggered by a new message, it is brought to front but not
focused.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#7

Hi all,

Could you please clarify the OS on which it happens? I can see the
issue has its OS set to All. However, Windows specifically protects
against such cases and one needs to explicitly call
AllowSetForegroundWindow to get around it. Moreover, I don't clearly
remember seeing the issue on Windows Vista or 7.

Lubomir, I found the time to test and unfortunaly I have to confirm the
focus is also stolen under Windows XP SP3. Not always, but most of the
time.

Just tested on Mac OS X.

Opening a chat window manually or upon an incoming message causes the
following exception:

[snip nasty exception]

The SVN commit was reverted short after noticing this.

I have absolutely no clue why it crashes. Furthermore, I'm disappointed
to report that the fix I commited did sometimes randomly not work under
Gnome (about 1 out of 10 tries fails).

Incidentally, did you get a chance to test how this patch would behave
with the "Bring to front" option in the config form?

No, but if we find a solution to the aforementioned problem, this is
will be easy to test and/or fix. Thanks for reminding me of this.

Another option is using a custom KeyboardFocusManager. I played a bit
with it and the only thing I got from it is a headache.

Cheers,

···

On Tue, Feb 17, 2009 at 07:14:33PM +0200, Lubomir Marinov wrote:
On Tue, Feb 17, 2009 at 11:05:04PM +0100, Emil Ivov wrote:

--
Sébastien Mazy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net