United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5091224 : Non-focusable windows steal focus from desktop windows

Details
Type:
Bug
Submit Date:
2004-08-24
Status:
Resolved
Updated Date:
2006-02-07
Project Name:
JDK
Resolved Date:
2006-02-07
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Backport:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: dm97671			Date: 08/24/2004


It has been noticed that while non-focusable Windows in Java might not
steal focus from Java Windows of the same application, they usually do
steal focus from Windows of other applications on the desktop. We should
investigate if it is possible to implement non-focusable windows that
are non-focusable for the desktop.

Example of this behavior is the one that is provied by Win32 API flags
WS_EX_NOACTIVATE.
======================================================================

                                    

Comments
EVALUATION

The suggested fix is for Win2K ang greater. New CR for Win9x has been filed - 6371856.
                                     
2006-01-12
SUGGESTED FIX

------- awt_Window.cpp -------
*** /tmp/sccs.3oaqnG	Thu Dec 29 15:31:03 2005
--- awt_Window.cpp	Thu Dec 29 15:19:46 2005
***************
*** 1722,1733 ****
      AwtWindow *window = NULL;
      
      PDATA pData;
      JNI_CHECK_PEER_GOTO(self, ret);
      window = (AwtWindow *)pData;
!     window->SetFocusableWindow(isFocusableWindow);
!  
    ret:
      env->DeleteGlobalRef(self);
      delete sfws;
  }
  
--- 1722,1742 ----
      AwtWindow *window = NULL;
      
      PDATA pData;
      JNI_CHECK_PEER_GOTO(self, ret);
      window = (AwtWindow *)pData;
! 
!     if (IS_WIN2000) {
!         if (!isFocusableWindow) {
!             window->SetStyleEx(window->GetStyleEx() | WS_EX_APPWINDOW | AWT_WS_EX_NOACTIVATE);
!         } else {
!             window->SetStyleEx(window->GetStyleEx() & ~WS_EX_APPWINDOW & ~AWT_WS_EX_NOACTIVATE); 
!         }
!     }
! 
!     window->SetFocusableWindow(isFocusableWindow); 
! 
    ret:
      env->DeleteGlobalRef(self);
      delete sfws;
  }
  

------- awt_Window.h -------
*** /tmp/sccs.IAaqvG	Thu Dec 29 15:31:03 2005
--- awt_Window.h	Thu Dec 29 15:18:49 2005
***************
*** 18,27 ****
--- 18,30 ----
  
  #ifndef WH_MOUSE_LL
  #define WH_MOUSE_LL 14
  #endif
  
+ // WS_EX_NOACTIVATE is not defined in the headers we build with
+ #define AWT_WS_EX_NOACTIVATE        0x08000000L
+ 
  class AwtFrame;
  
  /************************************************************************
   * AwtWindow class
   */
                                     
2005-12-29
EVALUATION

WS_EX_NOACTIVATE window style can be used here.
                                     
2005-12-27



Hardware and Software, Engineered to Work Together