Changeset 35749 in vbox for trunk/src/VBox
- Timestamp:
- Jan 28, 2011 9:17:46 AM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp
r35745 r35749 56 56 # include "VBoxUtils.h" 57 57 # include <Carbon/Carbon.h> 58 # include <QTimer> 58 59 #endif /* Q_WS_MAC */ 59 60 … … 303 304 304 305 #ifdef Q_WS_MAC 305 m_uDarwinKeyModifiers = GetCurrentEventKeyModifiers();306 m_uDarwinKeyModifiers = 0; 306 307 UICocoaApplication::instance()->registerForNativeEvents(RT_BIT_32(10) | RT_BIT_32(11) | RT_BIT_32(12) /* NSKeyDown | NSKeyUp | | NSFlagsChanged */, UIHotKeyEditor::darwinEventHandlerProc, this); 307 308 ::DarwinGrabKeyboard(false /* just modifiers */); 309 310 m_pRemoveTimer = new QTimer(this); 311 m_pRemoveTimer->setInterval(200); 312 connect(m_pRemoveTimer, SIGNAL(timeout()), 313 this, SLOT(removePendingKeys())); 308 314 #endif /* Q_WS_MAC */ 309 315 } … … 515 521 modifierMask = ::DarwinAdjustModifierMask(modifierMask, pvCocoaEvent); 516 522 UInt32 changed = m_uDarwinKeyModifiers ^ modifierMask; 517 m_uDarwinKeyModifiers = modifierMask;518 523 519 524 /* Convert to keycode: */ … … 526 531 if (changed) 527 532 { 533 /* Stop the delete pending keys timer. */ 534 m_pRemoveTimer->stop(); 535 /* If modifierMask is empty, no key is pressed anymore. Stop 536 * all key handling and the deletion of keys. This is the 537 * status the user want. */ 538 if (!modifierMask) 539 m_fStartNewSequence = true; 528 540 /* Key release: */ 529 if (!(changed & modifierMask))541 else if (!(changed & modifierMask)) 530 542 { 531 /* Remove pressed symbol: */ 532 m_pressedKeys.remove(iKeyCode); 533 534 /* If pressed key map is empty => start new sequence: */ 535 if (m_pressedKeys.isEmpty()) 536 m_fStartNewSequence = true; 543 /* Queue pressed symbol for removing: */ 544 m_removeKeys.insert(iKeyCode); 545 m_pRemoveTimer->start(); 537 546 } 538 547 /* Key press: */ … … 542 551 if (m_fStartNewSequence) 543 552 m_shownKeys.clear(); 544 553 /* Make sure any keys pending for removal are removed. */ 554 removePendingKeys(); 545 555 /* Check maximum combo size: */ 546 556 if (m_shownKeys.size() < UIHotKeyCombination::m_iMaxComboSize) … … 555 565 } 556 566 } 567 /* Save the new modifier mask state. */ 568 m_uDarwinKeyModifiers = modifierMask; 557 569 558 570 /* Update text: */ … … 563 575 return false; 564 576 } 577 578 void UIHotKeyEditor::removePendingKeys() 579 { 580 /* Stop the timer, we process all pending keys at once. */ 581 m_pRemoveTimer->stop(); 582 /* Something to do? */ 583 if (!m_removeKeys.isEmpty()) 584 { 585 /* Remove every key. */ 586 foreach(int v, m_removeKeys) 587 { 588 m_pressedKeys.remove(v); 589 m_shownKeys.remove(v); 590 } 591 m_removeKeys.clear(); 592 if (m_pressedKeys.isEmpty()) 593 m_fStartNewSequence = true; 594 } 595 /* Make sure the user see what happens. */ 596 updateText(); 597 } 598 565 599 #endif /* Q_WS_MAC */ 566 600 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h
r35730 r35749 90 90 bool m_fStartNewSequence; 91 91 92 #ifdef Q_WS_MAC 92 #ifdef RT_OS_DARWIN 93 QSet<int> m_removeKeys; 94 QTimer* m_pRemoveTimer; 93 95 /* The current modifier key mask. Used to figure out which modifier 94 96 * key was pressed when we get a kEventRawKeyModifiersChanged event. */ 95 97 uint32_t m_uDarwinKeyModifiers; 96 #endif /* Q_WS_MAC */ 98 private slots: 99 void removePendingKeys(); 100 #endif /* RT_OS_DARWIN */ 97 101 }; 98 102
Note:
See TracChangeset
for help on using the changeset viewer.