src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java

Print this page




 409      * This function should be executed on eventHandlerThread
 410      * @param submenuToShow submenu to be shown or null
 411      * to hide currently showing submenu
 412      */
 413     private void doShowSubmenu(XMenuPeer submenuToShow) {
 414         XMenuWindow menuWindowToShow = (submenuToShow != null) ? submenuToShow.getMenuWindow() : null;
 415         Dimension dim = null;
 416         Rectangle bounds = null;
 417         //ensureCreated can invoke XWindowPeer.init() ->
 418         //XWindowPeer.initGraphicsConfiguration() ->
 419         //Window.getGraphicsConfiguration()
 420         //that tries to obtain Component.AWTTreeLock.
 421         //So it should be called outside awtLock()
 422         if (menuWindowToShow != null) {
 423             menuWindowToShow.ensureCreated();
 424         }
 425         XToolkit.awtLock();
 426         try {
 427             synchronized(getMenuTreeLock()) {
 428                 if (showingSubmenu != submenuToShow) {
 429                     if (log.isLoggable(PlatformLogger.FINER)) {
 430                         log.finest("Changing showing submenu");
 431                     }
 432                     if (showingSubmenu != null) {
 433                         XMenuWindow showingSubmenuWindow = showingSubmenu.getMenuWindow();
 434                         if (showingSubmenuWindow != null) {
 435                             showingSubmenuWindow.hide();
 436                         }
 437                     }
 438                     if (submenuToShow != null) {
 439                         dim = menuWindowToShow.getDesiredSize();
 440                         bounds = menuWindowToShow.getParentMenuWindow().getSubmenuBounds(submenuToShow.getBounds(), dim);
 441                         menuWindowToShow.show(bounds);
 442                     }
 443                     showingSubmenu = submenuToShow;
 444                 }
 445             }
 446         } finally {
 447             XToolkit.awtUnlock();
 448         }
 449     }


1105                       wnd.selectItem(null, false);
1106                   }
1107               } else {
1108                   //Mouse is dragged outside menu windows
1109                   //clear selection in leaf to reflect it
1110                   if (cwnd != null) {
1111                       cwnd.selectItem(null, false);
1112                   }
1113               }
1114               break;
1115         }
1116     }
1117 
1118     /**
1119      * Performs handling of java keyboard event
1120      * Note that this function should be invoked
1121      * only from root of menu window's hierarchy
1122      * that grabs input focus
1123      */
1124     void doHandleJavaKeyEvent(KeyEvent event) {
1125         if (log.isLoggable(PlatformLogger.FINER)) log.finer(event.toString());


1126         if (event.getID() != KeyEvent.KEY_PRESSED) {
1127             return;
1128         }
1129         final int keyCode = event.getKeyCode();
1130         XBaseMenuWindow cwnd = getShowingLeaf();
1131         XMenuItemPeer citem = cwnd.getSelectedItem();
1132         switch(keyCode) {
1133           case KeyEvent.VK_UP:
1134           case KeyEvent.VK_KP_UP:
1135               if (!(cwnd instanceof XMenuBarPeer)) {
1136                   //If active window is not menu bar,
1137                   //move selection up
1138                   cwnd.selectItem(cwnd.getPrevSelectableItem(), false);
1139               }
1140               break;
1141           case KeyEvent.VK_DOWN:
1142           case KeyEvent.VK_KP_DOWN:
1143               if (cwnd instanceof XMenuBarPeer) {
1144                   //If active window is menu bar show current submenu
1145                   selectItem(getSelectedItem(), true);




 409      * This function should be executed on eventHandlerThread
 410      * @param submenuToShow submenu to be shown or null
 411      * to hide currently showing submenu
 412      */
 413     private void doShowSubmenu(XMenuPeer submenuToShow) {
 414         XMenuWindow menuWindowToShow = (submenuToShow != null) ? submenuToShow.getMenuWindow() : null;
 415         Dimension dim = null;
 416         Rectangle bounds = null;
 417         //ensureCreated can invoke XWindowPeer.init() ->
 418         //XWindowPeer.initGraphicsConfiguration() ->
 419         //Window.getGraphicsConfiguration()
 420         //that tries to obtain Component.AWTTreeLock.
 421         //So it should be called outside awtLock()
 422         if (menuWindowToShow != null) {
 423             menuWindowToShow.ensureCreated();
 424         }
 425         XToolkit.awtLock();
 426         try {
 427             synchronized(getMenuTreeLock()) {
 428                 if (showingSubmenu != submenuToShow) {
 429                     if (log.isLoggable(PlatformLogger.FINEST)) {
 430                         log.finest("Changing showing submenu");
 431                     }
 432                     if (showingSubmenu != null) {
 433                         XMenuWindow showingSubmenuWindow = showingSubmenu.getMenuWindow();
 434                         if (showingSubmenuWindow != null) {
 435                             showingSubmenuWindow.hide();
 436                         }
 437                     }
 438                     if (submenuToShow != null) {
 439                         dim = menuWindowToShow.getDesiredSize();
 440                         bounds = menuWindowToShow.getParentMenuWindow().getSubmenuBounds(submenuToShow.getBounds(), dim);
 441                         menuWindowToShow.show(bounds);
 442                     }
 443                     showingSubmenu = submenuToShow;
 444                 }
 445             }
 446         } finally {
 447             XToolkit.awtUnlock();
 448         }
 449     }


1105                       wnd.selectItem(null, false);
1106                   }
1107               } else {
1108                   //Mouse is dragged outside menu windows
1109                   //clear selection in leaf to reflect it
1110                   if (cwnd != null) {
1111                       cwnd.selectItem(null, false);
1112                   }
1113               }
1114               break;
1115         }
1116     }
1117 
1118     /**
1119      * Performs handling of java keyboard event
1120      * Note that this function should be invoked
1121      * only from root of menu window's hierarchy
1122      * that grabs input focus
1123      */
1124     void doHandleJavaKeyEvent(KeyEvent event) {
1125         if (log.isLoggable(PlatformLogger.FINER)) {
1126             log.finer(event.toString());
1127         }
1128         if (event.getID() != KeyEvent.KEY_PRESSED) {
1129             return;
1130         }
1131         final int keyCode = event.getKeyCode();
1132         XBaseMenuWindow cwnd = getShowingLeaf();
1133         XMenuItemPeer citem = cwnd.getSelectedItem();
1134         switch(keyCode) {
1135           case KeyEvent.VK_UP:
1136           case KeyEvent.VK_KP_UP:
1137               if (!(cwnd instanceof XMenuBarPeer)) {
1138                   //If active window is not menu bar,
1139                   //move selection up
1140                   cwnd.selectItem(cwnd.getPrevSelectableItem(), false);
1141               }
1142               break;
1143           case KeyEvent.VK_DOWN:
1144           case KeyEvent.VK_KP_DOWN:
1145               if (cwnd instanceof XMenuBarPeer) {
1146                   //If active window is menu bar show current submenu
1147                   selectItem(getSelectedItem(), true);