< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java

Print this page




 527         }
 528         notifyListeners(ev);
 529     }
 530 
 531     static void processException(Throwable thr) {
 532         if (log.isLoggable(PlatformLogger.Level.WARNING)) {
 533             log.warning("Exception on Toolkit thread", thr);
 534         }
 535     }
 536 
 537     static native void awt_toolkit_init();
 538 
 539     @Override
 540     public void run() {
 541         awt_toolkit_init();
 542         run(PRIMARY_LOOP);
 543     }
 544 
 545     public void run(boolean loop)
 546     {

 547         XEvent ev = new XEvent();
 548         while(true) {
 549             // Fix for 6829923: we should gracefully handle toolkit thread interruption
 550             if (Thread.currentThread().isInterrupted()) {
 551                 // We expect interruption from the AppContext.dispose() method only.
 552                 // If the thread is interrupted from another place, let's skip it
 553                 // for compatibility reasons. Probably some time later we'll remove
 554                 // the check for AppContext.isDisposed() and will unconditionally
 555                 // break the loop here.
 556                 if (AppContext.getAppContext().isDisposed()) {
 557                     break;
 558                 }
 559             }
 560             awtLock();
 561             try {
 562                 if (loop == SECONDARY_LOOP) {
 563                     // In the secondary loop we may have already acquired awt_lock
 564                     // several times, so waitForEvents() might be unable to release
 565                     // the awt_lock and this causes lock up.
 566                     // For now, we just avoid waitForEvents in the secondary loop.


 581                 }
 582 
 583                 if (ev.get_type() != XConstants.NoExpose) {
 584                     eventNumber++;
 585                 }
 586                 if (awt_UseXKB_Calls && ev.get_type() ==  awt_XKBBaseEventCode) {
 587                     processXkbChanges(ev);
 588                 }
 589 
 590                 if (XDropTargetEventProcessor.processEvent(ev) ||
 591                     XDragSourceContextPeer.processEvent(ev)) {
 592                     continue;
 593                 }
 594 
 595                 if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
 596                     eventLog.finer("{0}", ev);
 597                 }
 598 
 599                 // Check if input method consumes the event
 600                 long w = 0;
 601                 if (windowToXWindow(ev.get_xany().get_window()) != null) {

 602                     Component owner =
 603                         XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
 604                     if (owner != null) {
 605                         XWindow ownerWindow = AWTAccessor.getComponentAccessor().getPeer(owner);
 606                         if (ownerWindow != null) {
 607                             w = ownerWindow.getContentWindow();
 608                         }
 609                     }
 610                 }
 611                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (
 612                         ev.get_type() == XConstants.KeyPress
 613                                 || ev.get_type() == XConstants.KeyRelease)) {
 614                     keyEventLog.fine("before XFilterEvent:" + ev);
 615                 }
 616                 if (XlibWrapper.XFilterEvent(ev.getPData(), w)) {
 617                     continue;
 618                 }
 619                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (
 620                         ev.get_type() == XConstants.KeyPress
 621                                 || ev.get_type() == XConstants.KeyRelease)) {




 527         }
 528         notifyListeners(ev);
 529     }
 530 
 531     static void processException(Throwable thr) {
 532         if (log.isLoggable(PlatformLogger.Level.WARNING)) {
 533             log.warning("Exception on Toolkit thread", thr);
 534         }
 535     }
 536 
 537     static native void awt_toolkit_init();
 538 
 539     @Override
 540     public void run() {
 541         awt_toolkit_init();
 542         run(PRIMARY_LOOP);
 543     }
 544 
 545     public void run(boolean loop)
 546     {
 547         Unsafe unsafe = Unsafe.getUnsafe();
 548         XEvent ev = new XEvent();
 549         while(true) {
 550             // Fix for 6829923: we should gracefully handle toolkit thread interruption
 551             if (Thread.currentThread().isInterrupted()) {
 552                 // We expect interruption from the AppContext.dispose() method only.
 553                 // If the thread is interrupted from another place, let's skip it
 554                 // for compatibility reasons. Probably some time later we'll remove
 555                 // the check for AppContext.isDisposed() and will unconditionally
 556                 // break the loop here.
 557                 if (AppContext.getAppContext().isDisposed()) {
 558                     break;
 559                 }
 560             }
 561             awtLock();
 562             try {
 563                 if (loop == SECONDARY_LOOP) {
 564                     // In the secondary loop we may have already acquired awt_lock
 565                     // several times, so waitForEvents() might be unable to release
 566                     // the awt_lock and this causes lock up.
 567                     // For now, we just avoid waitForEvents in the secondary loop.


 582                 }
 583 
 584                 if (ev.get_type() != XConstants.NoExpose) {
 585                     eventNumber++;
 586                 }
 587                 if (awt_UseXKB_Calls && ev.get_type() ==  awt_XKBBaseEventCode) {
 588                     processXkbChanges(ev);
 589                 }
 590 
 591                 if (XDropTargetEventProcessor.processEvent(ev) ||
 592                     XDragSourceContextPeer.processEvent(ev)) {
 593                     continue;
 594                 }
 595 
 596                 if (eventLog.isLoggable(PlatformLogger.Level.FINER)) {
 597                     eventLog.finer("{0}", ev);
 598                 }
 599 
 600                 // Check if input method consumes the event
 601                 long w = 0;
 602                 if (!unsafe.shouldBeInitialized(XKeyboardFocusManagerPeer.class)
 603                         && windowToXWindow(ev.get_xany().get_window()) != null) {
 604                     Component owner =
 605                         XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
 606                     if (owner != null) {
 607                         XWindow ownerWindow = AWTAccessor.getComponentAccessor().getPeer(owner);
 608                         if (ownerWindow != null) {
 609                             w = ownerWindow.getContentWindow();
 610                         }
 611                     }
 612                 }
 613                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (
 614                         ev.get_type() == XConstants.KeyPress
 615                                 || ev.get_type() == XConstants.KeyRelease)) {
 616                     keyEventLog.fine("before XFilterEvent:" + ev);
 617                 }
 618                 if (XlibWrapper.XFilterEvent(ev.getPData(), w)) {
 619                     continue;
 620                 }
 621                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && (
 622                         ev.get_type() == XConstants.KeyPress
 623                                 || ev.get_type() == XConstants.KeyRelease)) {


< prev index next >