845 checkWidget(); |
845 checkWidget(); |
846 return forceFocus(OS.QT_OTHERFOCUSREASON); |
846 return forceFocus(OS.QT_OTHERFOCUSREASON); |
847 } |
847 } |
848 |
848 |
849 boolean forceFocus(int focusReason) { |
849 boolean forceFocus(int focusReason) { |
850 if (display.focusEvent == SWT.FocusOut) return false; |
850 if (Display.focusEvent == SWT.FocusOut) return false; |
851 Decorations shell = menuShell(); |
851 Decorations shell = menuShell(); |
852 shell.setSavedFocus(this); |
852 shell.setSavedFocus(this); |
853 if (!isEnabled() || !isVisible() || !isActive()) |
853 if (!isEnabled() || !isVisible() || !isActive()) |
854 return false; |
854 return false; |
855 if (isFocusControl()) |
855 if (isFocusControl()) |
1422 |
1422 |
1423 return data.internalGc.getHandle(); |
1423 return data.internalGc.getHandle(); |
1424 } |
1424 } |
1425 |
1425 |
1426 boolean isActive() { |
1426 boolean isActive() { |
1427 Dialog dialog = display.getModalDialog(); |
1427 Dialog dialog = Display.getModalDialog(); |
1428 if (dialog != null) { |
1428 if (dialog != null) { |
1429 Shell dialogShell = dialog.parent; |
1429 Shell dialogShell = dialog.parent; |
1430 if (dialogShell != null && !dialogShell.isDisposed()) { |
1430 if (dialogShell != null && !dialogShell.isDisposed()) { |
1431 if (dialogShell != getShell()) |
1431 if (dialogShell != getShell()) |
1432 return false; |
1432 return false; |
1433 } |
1433 } |
1434 } |
1434 } |
1435 Shell shell = null; |
1435 Shell shell = null; |
1436 Shell[] modalShells = display.modalShells; |
1436 Shell[] modalShells = Display.modalShells; |
1437 if (modalShells != null) { |
1437 if (modalShells != null) { |
1438 int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; |
1438 int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; |
1439 int index = modalShells.length; |
1439 int index = modalShells.length; |
1440 while (--index >= 0) { |
1440 while (--index >= 0) { |
1441 Shell modal = modalShells[index]; |
1441 Shell modal = modalShells[index]; |
1733 // The next widget we should move below of. |
1733 // The next widget we should move below of. |
1734 next = true; |
1734 next = true; |
1735 continue; |
1735 continue; |
1736 } |
1736 } |
1737 if (next) { |
1737 if (next) { |
1738 Widget widget = display.getWidget(children[iChild]); |
1738 Widget widget = Display.getWidget(children[iChild]); |
1739 if (widget != null && widget != this) { |
1739 if (widget != null && widget != this) { |
1740 if (widget instanceof org.eclipse.swt.widgets.Control) { |
1740 if (widget instanceof org.eclipse.swt.widgets.Control) { |
1741 controlAbove = (Control) widget; |
1741 controlAbove = (Control) widget; |
1742 break; |
1742 break; |
1743 } |
1743 } |
1983 if (widgetHandle == topHandle) |
1983 if (widgetHandle == topHandle) |
1984 sendEvent(SWT.Resize); |
1984 sendEvent(SWT.Resize); |
1985 } |
1985 } |
1986 |
1986 |
1987 boolean qt_event_shortcut(int key, int modifier, int character) { |
1987 boolean qt_event_shortcut(int key, int modifier, int character) { |
1988 display.mnemonicControl = this; |
1988 Display.mnemonicControl = this; |
1989 Control shortcutHandler = getShortcutHandler(); |
1989 Control shortcutHandler = getShortcutHandler(); |
1990 if (shortcutHandler == null) { |
1990 if (shortcutHandler == null) { |
1991 // If there's no shortcut handler then just activate the shortcut. |
1991 // If there's no shortcut handler then just activate the shortcut. |
1992 return false; |
1992 return false; |
1993 } |
1993 } |
1999 bufferFlush = true; |
1999 bufferFlush = true; |
2000 } |
2000 } |
2001 |
2001 |
2002 void qt_swt_event_focusWasGained() { |
2002 void qt_swt_event_focusWasGained() { |
2003 try { |
2003 try { |
2004 display.focusEvent = SWT.FocusIn; |
2004 Display.focusEvent = SWT.FocusIn; |
2005 sendEvent(SWT.FocusIn); |
2005 sendEvent(SWT.FocusIn); |
2006 } finally { |
2006 } finally { |
2007 if(display != null && !display.isDisposed()) { |
2007 if(display != null && !display.isDisposed()) { |
2008 display.focusEvent = SWT.None; |
2008 Display.focusEvent = SWT.None; |
2009 } |
2009 } |
2010 } |
2010 } |
2011 if(display != null && !display.isDisposed()) { |
2011 if(display != null && !display.isDisposed()) { |
2012 display.commandArranger.focusedControlChanged(); |
2012 Display.commandArranger.focusedControlChanged(); |
2013 } |
2013 } |
2014 } |
2014 } |
2015 void qt_swt_event_focusWasLost() { |
2015 void qt_swt_event_focusWasLost() { |
2016 try { |
2016 try { |
2017 display.focusEvent = SWT.FocusOut; |
2017 Display.focusEvent = SWT.FocusOut; |
2018 sendEvent(SWT.FocusOut); |
2018 sendEvent(SWT.FocusOut); |
2019 } finally { |
2019 } finally { |
2020 if(display != null && !display.isDisposed()) { |
2020 if(display != null && !display.isDisposed()) { |
2021 display.focusEvent = SWT.None; |
2021 Display.focusEvent = SWT.None; |
2022 } |
2022 } |
2023 } |
2023 } |
2024 } |
2024 } |
2025 |
2025 |
2026 void qt_swt_event_widgetPainted(int widgetHandle, int x, int y, int width, |
2026 void qt_swt_event_widgetPainted(int widgetHandle, int x, int y, int width, |
2612 Point oldPos = OS.QWidget_pos(topHandle); |
2612 Point oldPos = OS.QWidget_pos(topHandle); |
2613 if (resize) { |
2613 if (resize) { |
2614 if (oldSize.x != width || oldSize.y != height) { |
2614 if (oldSize.x != width || oldSize.y != height) { |
2615 if(isParentMirrored()) { |
2615 if(isParentMirrored()) { |
2616 try { |
2616 try { |
2617 display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; |
2617 Display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; |
2618 OS.QWidget_move(topHandle, oldPos.x - (width - oldSize.x), oldPos.y); |
2618 OS.QWidget_move(topHandle, oldPos.x - (width - oldSize.x), oldPos.y); |
2619 } finally { |
2619 } finally { |
2620 display.blockedQtEventType = OS.QEVENT_NONE; |
2620 Display.blockedQtEventType = OS.QEVENT_NONE; |
2621 } |
2621 } |
2622 } |
2622 } |
2623 // This will send a resize event |
2623 // This will send a resize event |
2624 OS.QWidget_resize(topHandle, width, height); |
2624 OS.QWidget_resize(topHandle, width, height); |
2625 result |= WidgetState.RESIZED; |
2625 result |= WidgetState.RESIZED; |
2713 state |= WidgetState.DISABLED; |
2713 state |= WidgetState.DISABLED; |
2714 } |
2714 } |
2715 Control control = null; |
2715 Control control = null; |
2716 boolean fixFocus = false; |
2716 boolean fixFocus = false; |
2717 if (!enabled) { |
2717 if (!enabled) { |
2718 if (display.focusEvent != SWT.FocusOut) { |
2718 if (Display.focusEvent != SWT.FocusOut) { |
2719 control = display.getFocusControl (); |
2719 control = display.getFocusControl (); |
2720 fixFocus = isFocusAncestor (control); |
2720 fixFocus = isFocusAncestor (control); |
2721 } |
2721 } |
2722 } |
2722 } |
2723 enableWidget(enabled); |
2723 enableWidget(enabled); |
3236 if(isDisposed()) return; |
3236 if(isDisposed()) return; |
3237 } |
3237 } |
3238 Control control = null; |
3238 Control control = null; |
3239 boolean fixFocus = false; |
3239 boolean fixFocus = false; |
3240 if (!visible) { |
3240 if (!visible) { |
3241 if (display.focusEvent != SWT.FocusOut) { |
3241 if (Display.focusEvent != SWT.FocusOut) { |
3242 control = display.getFocusControl (); |
3242 control = display.getFocusControl (); |
3243 fixFocus = isFocusAncestor (control); |
3243 fixFocus = isFocusAncestor (control); |
3244 } |
3244 } |
3245 } |
3245 } |
3246 if (!visible) { |
3246 if (!visible) { |
3394 |
3394 |
3395 // It doesn't make sense to activate mnemonic traversal by calling this |
3395 // It doesn't make sense to activate mnemonic traversal by calling this |
3396 // but if it's done then traversal is attempted relative to this control. |
3396 // but if it's done then traversal is attempted relative to this control. |
3397 // Normally it would be done relative to the control that had the |
3397 // Normally it would be done relative to the control that had the |
3398 // shortcut event. |
3398 // shortcut event. |
3399 display.mnemonicControl = this; |
3399 Display.mnemonicControl = this; |
3400 |
3400 |
3401 return doTraversal(event); |
3401 return doTraversal(event); |
3402 } |
3402 } |
3403 |
3403 |
3404 boolean traverseEscape() { |
3404 boolean traverseEscape() { |
3477 */ |
3477 */ |
3478 boolean traverseMnemonic(char key) { |
3478 boolean traverseMnemonic(char key) { |
3479 |
3479 |
3480 // SWT checks for mnemonic hit here |
3480 // SWT checks for mnemonic hit here |
3481 |
3481 |
3482 if (display.mnemonicControl == null) |
3482 if (Display.mnemonicControl == null) |
3483 return false; |
3483 return false; |
3484 Control nextControl = display.mnemonicControl.findNextControl(false); |
3484 Control nextControl = Display.mnemonicControl.findNextControl(false); |
3485 if (nextControl != null) { |
3485 if (nextControl != null) { |
3486 nextControl.setFocus(OS.QT_TABFOCUSREASON); |
3486 nextControl.setFocus(OS.QT_TABFOCUSREASON); |
3487 return true; |
3487 return true; |
3488 } |
3488 } |
3489 return false; |
3489 return false; |
3574 // Make XServer process all queued requests not discarding any events. |
3574 // Make XServer process all queued requests not discarding any events. |
3575 // Note that this is heavy and slow. Here goes everything, not only the |
3575 // Note that this is heavy and slow. Here goes everything, not only the |
3576 // one event we are waiting for. |
3576 // one event we are waiting for. |
3577 OS.QApplication_syncX(); |
3577 OS.QApplication_syncX(); |
3578 // Make Qt process all XEvents. |
3578 // Make Qt process all XEvents. |
3579 display.noInterrupt = true; |
3579 Display.noInterrupt = true; |
3580 OS.QCoreApplication_processEvents(Display.handle, |
3580 OS.QCoreApplication_processEvents(Display.handle, |
3581 OS.QEVENTLOOP_EXCLUDEUSERINPUTEVENTS); |
3581 OS.QEVENTLOOP_EXCLUDEUSERINPUTEVENTS); |
3582 display.noInterrupt = false; |
3582 Display.noInterrupt = false; |
3583 } |
3583 } |
3584 } |
3584 } |