Bug 148954 - Debugger does not return focus to main window
Debugger does not return focus to main window
Status: VERIFIED WORKSFORME
Product: platform
Classification: Unclassified
Component: Window System
6.x
PC Linux
: P3 (vote)
: 6.x
Assigned To: mslama
issues@platform
: A11Y, FOCUS, UI
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-02 12:43 UTC by Tomas Danek
Modified: 2009-01-28 09:53 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Danek 2008-10-02 12:43:43 UTC
Product Version: NetBeans IDE Dev (Build 20081002085508)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Linux version 2.6.24-19-generic running on i386; UTF-8; en_US (nb)
Userdir: /tmp/ud
-----------------
- created j2se project (anagram game)
- invoked debug target (using build.xml node)
- debugger is started, jframe is opened
- close the frame window, debugger finished, but focus is not returned to main window, Netbeans if flashing in status
bar (but no modal dialog is present), and focus cannot be obtained by clicking into main window.

reproducible for me, Ubuntu + KDE. Run target works fine.
Comment 1 Martin Entlicher 2008-10-02 16:28:00 UTC
Works fine for me.
I did not much get what do you mean by "invoked debug target (using build.xml node)", but it worked both ways. Via
AnagramGame -> Debug and AnagrameGame -> build.xml -> Run Target -> Debug.
Comment 2 Martin Entlicher 2008-10-02 16:30:15 UTC
Please test with other applications on your system. If you close one, does the focus move to the previous one?
Comment 3 Tomas Danek 2008-10-03 10:35:29 UTC
> I did not much get what do you mean by "invoked debug target (using build.xml node)"

I expanded build.xml node, and invoked "Run target" on debug target. Anyway I'm not sure if this matters. 

I wouldn't say the problem is in desktop manager or wherever, important thing is that i cannot reproduce when running
"run" target, only with "debug" target.

And just one more note: it is not always reproducible on first attempt in my environment. But once i reproduce, I'm able
to reproduce constantly.
Comment 4 Daniel Prusa 2008-10-06 13:46:28 UTC
Not reproducible for me on Windows. I have made several attempts and there have not been any problems with the focus.
Comment 5 Martin Entlicher 2008-10-06 17:16:57 UTC
According to tests, so far it seems that it's reproducible only on KDE.

When closing the GUI of the application, focus is transferred back to the NetBeans IDE when the application is executed
via "Run". But not when it's executed via "Debug". The user needs to switch to some other app and then back to NetBeans
in order to get the focus to the IDE. Therefore this is an accessibility and usability problem.
Comment 6 Martin Entlicher 2008-10-07 00:10:22 UTC
Installed KDE and reproduced.
Investigating... seems to be caused by some focus request of the IDE. KDE is confused by this.
Comment 7 Martin Entlicher 2008-10-07 12:46:04 UTC
:-) The problem is, that IDE tries to move the focus to the main window! When it does not try to do so, all works fine.

Moving to core/windows for further investigation, it can be a bug in NetBeans window system, or Swing, or KDE.
This bug can not be reproduced after this patch:
diff -r 209b78feb8ba core.windows/src/org/netbeans/core/windows/view/DefaultView.java
--- a/core.windows/src/org/netbeans/core/windows/view/DefaultView.java  Mon Oct 06 18:11:25 2008 +0200
+++ b/core.windows/src/org/netbeans/core/windows/view/DefaultView.java  Tue Oct 07 13:38:45 2008 +0200
@@ -348,7 +348,7 @@
                 if(modeView != null) {
                     modeView.removeTopComponent((TopComponent)viewEvent.getNewValue());
                 }
-                hierarchy.activateMode(wsa.getActiveModeAccessor());
+                //hierarchy.activateMode(wsa.getActiveModeAccessor());
             } else if(changeType == CHANGE_TOPCOMPONENT_DISPLAY_NAME_CHANGED) {
                 if(DEBUG) {
                     debugLog("TopComponent display name changed, tc=" + viewEvent.getNewValue()); // NOI18N

The problematic behavior seems to be caused by request of the focus after debugger TopComponents are closed. If all
debugger-related top components are closed explicitely before the end of the debugger session, the problem can not be
reproduced.
From my tests it looks like the faulty behavior is caused by TopComponent.requestFocus() called at
AbstractModeContainer.java:197. This is deprecated, thus perhaps some other method will do the job...
The method calls JComponent.requestFocus(), thus the problem can be in Swing as well.
Comment 8 David Simonek 2008-10-08 17:29:17 UTC
Well, what to do? TopComponent.requestFocus() is deprecated but only for Winsys API clients, not for winsys code, which
needs to call it (it delegates to JComponent.requestFocus).

This is almost certainly bug between JDK x KDE. Maybe we can change call to requestFocusInWindow, but other than that
it's wontfix.

Also personally I think this is P3/P4, not P2.
Comment 9 David Simonek 2008-10-10 13:03:20 UTC
potential fix: 4396eec9b3b0

I modified code in AbstractModeContainer.focusSelectedTopComponent to call requestFocusInWindow instead of requestFocus
when netbeans has no focused window at the moment.

musilt and mentlicher, please try to verify my fix, thank you.
Comment 10 Quality Engineering 2008-10-11 17:18:48 UTC
Integrated into 'main-golden', will be available in build *200810111401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4396eec9b3b0
User: Dafe Simonek <dsimonek@netbeans.org>
Log: #148954: requestFocusInWindow instead of requestFocus when system is not active in OS context
Comment 11 Tomas Danek 2008-10-13 15:12:33 UTC
great, great, works fine now, thanks Dafe...verified!

Product Version: NetBeans IDE Dev (Build 200810111401)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Linux version 2.6.24-19-generic running on i386; UTF-8; en_US (nb)
Userdir: /tmp/ud
Comment 12 mslama 2009-01-27 12:31:56 UTC
Sorry this causes regression. See issue #156694. If TopComponent.requestActive is called, TC is docked in main window
and main window is not active ie. does not have focus we MUST call java.awt.Component.requestFocus to make main window
active. Period. If KDE refuses to activate window when we call request focus on that window then again sorry it is
problem of KDE. File issue against KDE. We do not want to break IDE functionality due to KDE bug.

I am going to rollback this fix.
Comment 13 mslama 2009-01-27 12:45:20 UTC
Fix is rollbacked

core-main #c9f1f7c344ff

We will investigate and eventually add specific fix for KDE
Comment 14 mslama 2009-01-27 13:31:51 UTC
It looks there is no reliable way how to detect if Gnome or KDE desktop is running. Only thing I found is to check if
KDE_FULL_SESSION or GNOME_DESKTOP_SESSION_ID environment variables are set.
Comment 15 mslama 2009-01-27 14:13:03 UTC
We cannot reproduce it now with KDE 4.1.4 on Ubuntu Intrepid 8.10, JDK 6u12 b04, NB 090127. I tried with and without
'ergonomics' cluster. I tried to debug Anagram game and after closing its window I do not see that problem with not
being able to activate IDE window. I even tried to activate different window first so that IDE is not just below Anagram
window in z-order.
Comment 16 Tomas Danek 2009-01-27 14:19:07 UTC
verified.
Comment 17 Quality Engineering 2009-01-28 09:53:40 UTC
Integrated into 'main-golden', will be available in build *200901280348* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c9f1f7c344ff
User: Marek Slama <mslama@netbeans.org>
Log: Rollback fix of #148954 due to regression.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo