131 TBeepState iState; |
131 TBeepState iState; |
132 TInt iFrequency; |
132 TInt iFrequency; |
133 TTimeIntervalMicroSeconds iDuration; |
133 TTimeIntervalMicroSeconds iDuration; |
134 }; |
134 }; |
135 |
135 |
|
136 static QS60Beep* qt_S60Beep = 0; |
|
137 |
136 QS60Beep::~QS60Beep() |
138 QS60Beep::~QS60Beep() |
137 { |
139 { |
|
140 if (iToneUtil) { |
|
141 switch (iState) { |
|
142 case EBeepPlaying: |
|
143 iToneUtil->CancelPlay(); |
|
144 break; |
|
145 case EBeepNotPrepared: |
|
146 iToneUtil->CancelPrepare(); |
|
147 break; |
|
148 } |
|
149 } |
138 delete iToneUtil; |
150 delete iToneUtil; |
139 } |
151 } |
140 |
152 |
141 QS60Beep* QS60Beep::NewL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
153 QS60Beep* QS60Beep::NewL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
142 { |
154 { |
143 QS60Beep* self=new (ELeave) QS60Beep(); |
155 QS60Beep* self = new (ELeave) QS60Beep(); |
144 CleanupStack::PushL(self); |
156 CleanupStack::PushL(self); |
145 self->ConstructL(aFrequency, aDuration); |
157 self->ConstructL(aFrequency, aDuration); |
146 CleanupStack::Pop(); |
158 CleanupStack::Pop(); |
147 return self; |
159 return self; |
148 }; |
160 } |
149 |
161 |
150 void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
162 void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) |
151 { |
163 { |
152 iToneUtil=CMdaAudioToneUtility::NewL(*this); |
164 iToneUtil = CMdaAudioToneUtility::NewL(*this); |
153 iState=EBeepNotPrepared; |
165 iState = EBeepNotPrepared; |
154 iFrequency=aFrequency; |
166 iFrequency = aFrequency; |
155 iDuration=aDuration; |
167 iDuration = aDuration; |
156 iToneUtil->PrepareToPlayTone(iFrequency,iDuration); |
168 iToneUtil->PrepareToPlayTone(iFrequency, iDuration); |
157 } |
169 } |
158 |
170 |
159 void QS60Beep::Play() |
171 void QS60Beep::Play() |
160 { |
172 { |
161 if (iState != EBeepNotPrepared) { |
173 if (iState == EBeepPlaying) { |
162 if (iState == EBeepPlaying) { |
174 iToneUtil->CancelPlay(); |
163 iToneUtil->CancelPlay(); |
175 iState = EBeepPrepared; |
164 iState = EBeepPrepared; |
|
165 } |
|
166 } |
176 } |
167 |
177 |
168 iToneUtil->Play(); |
178 iToneUtil->Play(); |
169 iState = EBeepPlaying; |
179 iState = EBeepPlaying; |
170 } |
180 } |
171 |
181 |
172 void QS60Beep::MatoPrepareComplete(TInt aError) |
182 void QS60Beep::MatoPrepareComplete(TInt aError) |
173 { |
183 { |
174 if (aError == KErrNone) { |
184 if (aError == KErrNone) { |
175 iState = EBeepPrepared; |
185 iState = EBeepPrepared; |
|
186 Play(); |
176 } |
187 } |
177 } |
188 } |
178 |
189 |
179 void QS60Beep::MatoPlayComplete(TInt aError) |
190 void QS60Beep::MatoPlayComplete(TInt aError) |
180 { |
191 { |
181 Q_UNUSED(aError); |
192 Q_UNUSED(aError); |
182 iState=EBeepPrepared; |
193 iState = EBeepPrepared; |
183 } |
194 } |
184 |
195 |
185 |
196 |
186 QHash<TInt, TUint> QApplicationPrivate::scanCodeCache; |
197 QHash<TInt, TUint> QApplicationPrivate::scanCodeCache; |
187 |
198 |
463 |
472 |
464 m_longTapDetector->PointerEventL(pEvent); |
473 m_longTapDetector->PointerEventL(pEvent); |
465 QT_TRYCATCH_LEAVING(HandlePointerEvent(pEvent)); |
474 QT_TRYCATCH_LEAVING(HandlePointerEvent(pEvent)); |
466 } |
475 } |
467 |
476 |
468 typedef QPair<QWidget*,QMouseEvent> Event; |
|
469 |
|
470 /* |
|
471 * Helper function called by HandlePointerEvent - separated to keep that function readable |
|
472 */ |
|
473 static void generateEnterLeaveEvents(QList<Event> &events, QWidget *widgetUnderPointer, |
|
474 QPoint globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers) |
|
475 { |
|
476 //moved to another widget, create enter and leave events |
|
477 if (S60->lastPointerEventTarget) { |
|
478 QMouseEvent mEventLeave(QEvent::Leave, S60->lastPointerEventTarget->mapFromGlobal( |
|
479 S60->lastCursorPos), S60->lastCursorPos, button, QApplicationPrivate::mouse_buttons, |
|
480 modifiers); |
|
481 events.append(Event(S60->lastPointerEventTarget, mEventLeave)); |
|
482 } |
|
483 if (widgetUnderPointer) { |
|
484 QMouseEvent mEventEnter(QEvent::Enter, widgetUnderPointer->mapFromGlobal(globalPos), |
|
485 globalPos, button, QApplicationPrivate::mouse_buttons, modifiers); |
|
486 |
|
487 events.append(Event(widgetUnderPointer, mEventEnter)); |
|
488 #ifndef QT_NO_CURSOR |
|
489 S60->curWin = widgetUnderPointer->effectiveWinId(); |
|
490 if (!QApplication::overrideCursor()) { |
|
491 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
492 if (S60->brokenPointerCursors) |
|
493 qt_symbian_set_pointer_sprite(widgetUnderPointer->cursor()); |
|
494 else |
|
495 #endif |
|
496 qt_symbian_setWindowCursor(widgetUnderPointer->cursor(), S60->curWin); |
|
497 } |
|
498 #endif |
|
499 } |
|
500 } |
|
501 |
|
502 |
|
503 void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) |
477 void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) |
504 { |
478 { |
505 QMouseEvent::Type type; |
479 QMouseEvent::Type type; |
506 Qt::MouseButton button; |
480 Qt::MouseButton button; |
507 mapS60MouseEventTypeToQt(&type, &button, &pEvent); |
481 mapS60MouseEventTypeToQt(&type, &button, &pEvent); |
508 Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers); |
482 Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers); |
509 |
483 |
510 if (m_previousEventLongTap) |
|
511 if (type == QEvent::MouseButtonRelease){ |
|
512 button = Qt::RightButton; |
|
513 QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons & ~Qt::RightButton; |
|
514 m_previousEventLongTap = false; |
|
515 } |
|
516 if (type == QMouseEvent::None) |
|
517 return; |
|
518 |
|
519 // store events for later sending/saving |
|
520 QList<Event > events; |
|
521 |
|
522 QPoint widgetPos = QPoint(pEvent.iPosition.iX, pEvent.iPosition.iY); |
484 QPoint widgetPos = QPoint(pEvent.iPosition.iX, pEvent.iPosition.iY); |
523 TPoint controlScreenPos = PositionRelativeToScreen(); |
485 TPoint controlScreenPos = PositionRelativeToScreen(); |
524 QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos; |
486 QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos; |
525 |
487 S60->lastCursorPos = globalPos; |
526 // widgets interested in the event |
488 S60->lastPointerEventPos = widgetPos; |
|
489 |
|
490 QWidget *mouseGrabber = QWidget::mouseGrabber(); |
|
491 |
|
492 QWidget *popupWidget = qApp->activePopupWidget(); |
|
493 QWidget *popupReceiver = 0; |
|
494 if (popupWidget) { |
|
495 QWidget *popupChild = popupWidget->childAt(popupWidget->mapFromGlobal(globalPos)); |
|
496 popupReceiver = popupChild ? popupChild : popupWidget; |
|
497 } |
|
498 |
|
499 if (mouseGrabber) { |
|
500 if (popupReceiver) { |
|
501 sendMouseEvent(popupReceiver, type, globalPos, button, modifiers); |
|
502 } else { |
|
503 sendMouseEvent(mouseGrabber, type, globalPos, button, modifiers); |
|
504 } |
|
505 // No Enter/Leave events in grabbing mode. |
|
506 return; |
|
507 } |
|
508 |
527 QWidget *widgetUnderPointer = qwidget->childAt(widgetPos); |
509 QWidget *widgetUnderPointer = qwidget->childAt(widgetPos); |
528 if (!widgetUnderPointer) |
510 if (!widgetUnderPointer) |
529 widgetUnderPointer = qwidget; //i.e. this container widget |
511 widgetUnderPointer = qwidget; |
530 |
512 |
531 QWidget *widgetWithMouseGrab = QWidget::mouseGrabber(); |
513 QApplicationPrivate::dispatchEnterLeave(widgetUnderPointer, S60->lastPointerEventTarget); |
532 |
|
533 // handle auto grab of pointer when pressing / releasing |
|
534 if (!widgetWithMouseGrab && type == QEvent::MouseButtonPress) { |
|
535 //if previously auto-grabbed, generate a fake mouse release (platform bug: mouse release event was lost) |
|
536 if (S60->mousePressTarget) { |
|
537 QMouseEvent mEvent(QEvent::MouseButtonRelease, S60->mousePressTarget->mapFromGlobal(globalPos), globalPos, |
|
538 button, QApplicationPrivate::mouse_buttons, modifiers); |
|
539 events.append(Event(S60->mousePressTarget,mEvent)); |
|
540 } |
|
541 //auto grab the mouse |
|
542 widgetWithMouseGrab = S60->mousePressTarget = widgetUnderPointer; |
|
543 widgetWithMouseGrab->grabMouse(); |
|
544 } |
|
545 if (widgetWithMouseGrab && widgetWithMouseGrab == S60->mousePressTarget && type == QEvent::MouseButtonRelease) { |
|
546 //release the auto grab - note this release event still goes to the autograb widget |
|
547 S60->mousePressTarget = 0; |
|
548 widgetWithMouseGrab->releaseMouse(); |
|
549 } |
|
550 |
|
551 QWidget *widgetToReceiveMouseEvent; |
|
552 if (widgetWithMouseGrab) |
|
553 widgetToReceiveMouseEvent = widgetWithMouseGrab; |
|
554 else |
|
555 widgetToReceiveMouseEvent = widgetUnderPointer; |
|
556 |
|
557 //queue QEvent::Enter and QEvent::Leave, if the pointer has moved |
|
558 if (widgetUnderPointer != S60->lastPointerEventTarget && (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove)) |
|
559 generateEnterLeaveEvents(events, widgetUnderPointer, globalPos, button, modifiers); |
|
560 |
|
561 //save global state |
|
562 S60->lastCursorPos = globalPos; |
|
563 S60->lastPointerEventPos = widgetPos; |
|
564 S60->lastPointerEventTarget = widgetUnderPointer; |
514 S60->lastPointerEventTarget = widgetUnderPointer; |
|
515 |
|
516 QWidget *receiver; |
|
517 if (!popupReceiver && S60->mousePressTarget && type != QEvent::MouseButtonPress) { |
|
518 receiver = S60->mousePressTarget; |
|
519 if (type == QEvent::MouseButtonRelease) |
|
520 S60->mousePressTarget = 0; |
|
521 } else { |
|
522 receiver = popupReceiver ? popupReceiver : widgetUnderPointer; |
|
523 if (type == QEvent::MouseButtonPress) |
|
524 S60->mousePressTarget = receiver; |
|
525 } |
565 |
526 |
566 #if !defined(QT_NO_CURSOR) && !defined(Q_SYMBIAN_FIXED_POINTER_CURSORS) |
527 #if !defined(QT_NO_CURSOR) && !defined(Q_SYMBIAN_FIXED_POINTER_CURSORS) |
567 if (S60->brokenPointerCursors) |
528 if (S60->brokenPointerCursors) |
568 qt_symbian_move_cursor_sprite(); |
529 qt_symbian_move_cursor_sprite(); |
569 #endif |
530 #endif |
570 |
531 |
571 //queue this event. |
532 sendMouseEvent(receiver, type, globalPos, button, modifiers); |
572 Q_ASSERT(widgetToReceiveMouseEvent); |
533 } |
573 QMouseEvent mEvent(type, widgetToReceiveMouseEvent->mapFromGlobal(globalPos), globalPos, |
534 |
|
535 void QSymbianControl::sendMouseEvent( |
|
536 QWidget *receiver, |
|
537 QEvent::Type type, |
|
538 const QPoint &globalPos, |
|
539 Qt::MouseButton button, |
|
540 Qt::KeyboardModifiers modifiers) |
|
541 { |
|
542 Q_ASSERT(receiver); |
|
543 QMouseEvent mEvent(type, receiver->mapFromGlobal(globalPos), globalPos, |
574 button, QApplicationPrivate::mouse_buttons, modifiers); |
544 button, QApplicationPrivate::mouse_buttons, modifiers); |
575 events.append(Event(widgetToReceiveMouseEvent,mEvent)); |
|
576 QEventDispatcherS60 *dispatcher; |
545 QEventDispatcherS60 *dispatcher; |
577 // It is theoretically possible for someone to install a different event dispatcher. |
546 // It is theoretically possible for someone to install a different event dispatcher. |
578 if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(widgetToReceiveMouseEvent->d_func()->threadData->eventDispatcher)) != 0) { |
547 if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(receiver->d_func()->threadData->eventDispatcher)) != 0) { |
579 if (dispatcher->excludeUserInputEvents()) { |
548 if (dispatcher->excludeUserInputEvents()) { |
580 for (int i=0;i < events.count();++i) |
549 dispatcher->saveInputEvent(this, receiver, new QMouseEvent(mEvent)); |
581 { |
|
582 Event next = events[i]; |
|
583 dispatcher->saveInputEvent(this, next.first, new QMouseEvent(next.second)); |
|
584 } |
|
585 return; |
550 return; |
586 } |
551 } |
587 } |
552 } |
588 |
553 |
589 //send events in the queue |
554 sendMouseEvent(receiver, &mEvent); |
590 for (int i=0;i < events.count();++i) |
|
591 { |
|
592 Event next = events[i]; |
|
593 sendMouseEvent(next.first, &(next.second)); |
|
594 } |
|
595 } |
555 } |
596 |
556 |
597 bool QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent) |
557 bool QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent) |
598 { |
558 { |
599 return qt_sendSpontaneousEvent(widget, mEvent); |
559 return qt_sendSpontaneousEvent(widget, mEvent); |
669 if (type == EEventKeyUp) { |
629 if (type == EEventKeyUp) { |
670 if (keyCode == Qt::Key_Select) |
630 if (keyCode == Qt::Key_Select) |
671 fakeEvent.iType = TPointerEvent::EButton1Up; |
631 fakeEvent.iType = TPointerEvent::EButton1Up; |
672 S60->virtualMouseAccel = 1; |
632 S60->virtualMouseAccel = 1; |
673 S60->virtualMouseLastKey = 0; |
633 S60->virtualMouseLastKey = 0; |
|
634 switch (keyCode) { |
|
635 case Qt::Key_Left: |
|
636 S60->virtualMousePressedKeys &= ~QS60Data::Left; |
|
637 break; |
|
638 case Qt::Key_Right: |
|
639 S60->virtualMousePressedKeys &= ~QS60Data::Right; |
|
640 break; |
|
641 case Qt::Key_Up: |
|
642 S60->virtualMousePressedKeys &= ~QS60Data::Up; |
|
643 break; |
|
644 case Qt::Key_Down: |
|
645 S60->virtualMousePressedKeys &= ~QS60Data::Down; |
|
646 break; |
|
647 case Qt::Key_Select: |
|
648 S60->virtualMousePressedKeys &= ~QS60Data::Select; |
|
649 break; |
|
650 } |
674 } |
651 } |
675 else if (type == EEventKey) { |
652 else if (type == EEventKey) { |
676 switch (keyCode) { |
653 switch (keyCode) { |
677 case Qt::Key_Left: |
654 case Qt::Key_Left: |
|
655 S60->virtualMousePressedKeys |= QS60Data::Left; |
678 x -= S60->virtualMouseAccel; |
656 x -= S60->virtualMouseAccel; |
679 fakeEvent.iType = TPointerEvent::EMove; |
657 fakeEvent.iType = TPointerEvent::EMove; |
680 break; |
658 break; |
681 case Qt::Key_Right: |
659 case Qt::Key_Right: |
|
660 S60->virtualMousePressedKeys |= QS60Data::Right; |
682 x += S60->virtualMouseAccel; |
661 x += S60->virtualMouseAccel; |
683 fakeEvent.iType = TPointerEvent::EMove; |
662 fakeEvent.iType = TPointerEvent::EMove; |
684 break; |
663 break; |
685 case Qt::Key_Up: |
664 case Qt::Key_Up: |
|
665 S60->virtualMousePressedKeys |= QS60Data::Up; |
686 y -= S60->virtualMouseAccel; |
666 y -= S60->virtualMouseAccel; |
687 fakeEvent.iType = TPointerEvent::EMove; |
667 fakeEvent.iType = TPointerEvent::EMove; |
688 break; |
668 break; |
689 case Qt::Key_Down: |
669 case Qt::Key_Down: |
|
670 S60->virtualMousePressedKeys |= QS60Data::Down; |
690 y += S60->virtualMouseAccel; |
671 y += S60->virtualMouseAccel; |
691 fakeEvent.iType = TPointerEvent::EMove; |
672 fakeEvent.iType = TPointerEvent::EMove; |
692 break; |
673 break; |
693 case Qt::Key_Select: |
674 case Qt::Key_Select: |
694 fakeEvent.iType = TPointerEvent::EButton1Down; |
675 // Platform bug. If you start pressing several keys simultaneously (for |
|
676 // example for drag'n'drop), Symbian starts producing spurious up and |
|
677 // down messages for some keys. Therefore, make sure we have a clean slate |
|
678 // of pressed keys before starting a new button press. |
|
679 if (S60->virtualMousePressedKeys != 0) { |
|
680 S60->virtualMousePressedKeys |= QS60Data::Select; |
|
681 return EKeyWasConsumed; |
|
682 } else { |
|
683 S60->virtualMousePressedKeys |= QS60Data::Select; |
|
684 fakeEvent.iType = TPointerEvent::EButton1Down; |
|
685 } |
695 break; |
686 break; |
696 } |
687 } |
697 } |
688 } |
698 //clip to screen size (window server allows a sprite hotspot to be outside the screen) |
689 //clip to screen size (window server allows a sprite hotspot to be outside the screen) |
699 if (x < 0) |
690 if (x < 0) |
820 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
811 QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; |
821 |
812 |
822 if (!engine) |
813 if (!engine) |
823 return; |
814 return; |
824 |
815 |
|
816 const bool sendNativePaintEvents = qwidget->d_func()->extraData()->receiveNativePaintEvents; |
|
817 if (sendNativePaintEvents) { |
|
818 const QRect r = qt_TRect2QRect(controlRect); |
|
819 QMetaObject::invokeMethod(qwidget, "beginNativePaintEvent", Qt::DirectConnection, Q_ARG(QRect, r)); |
|
820 } |
|
821 |
825 // Map source rectangle into coordinates of the backing store. |
822 // Map source rectangle into coordinates of the backing store. |
826 const QPoint controlBase(controlRect.iTl.iX, controlRect.iTl.iY); |
823 const QPoint controlBase(controlRect.iTl.iX, controlRect.iTl.iY); |
827 const QPoint backingStoreBase = qwidget->mapTo(qwidget->window(), controlBase); |
824 const QPoint backingStoreBase = qwidget->mapTo(qwidget->window(), controlBase); |
828 const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size()); |
825 const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size()); |
829 |
826 |
830 if (engine->type() == QPaintEngine::Raster) { |
827 if (engine->type() == QPaintEngine::Raster) { |
831 QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); |
828 QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); |
832 CFbsBitmap *bitmap = s60Surface->symbianBitmap(); |
829 CFbsBitmap *bitmap = s60Surface->symbianBitmap(); |
833 CWindowGc &gc = SystemGc(); |
830 CWindowGc &gc = SystemGc(); |
834 |
831 |
835 if(!qwidget->d_func()->extraData()->disableBlit) { |
832 switch(qwidget->d_func()->extraData()->nativePaintMode) { |
|
833 case QWExtra::Disable: |
|
834 // Do nothing |
|
835 break; |
|
836 |
|
837 case QWExtra::Blit: |
836 if (qwidget->d_func()->isOpaque) |
838 if (qwidget->d_func()->isOpaque) |
837 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
839 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
838 gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); |
840 gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); |
839 } |
841 break; |
|
842 |
|
843 case QWExtra::ZeroFill: |
|
844 if (Window().DisplayMode() == EColor16MA) { |
|
845 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
846 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
847 gc.SetBrushColor(TRgb::Color16MA(0)); |
|
848 gc.Clear(controlRect); |
|
849 } else { |
|
850 gc.SetBrushColor(TRgb(0x000000)); |
|
851 gc.Clear(controlRect); |
|
852 }; |
|
853 break; |
|
854 |
|
855 default: |
|
856 Q_ASSERT(false); |
|
857 } |
840 } else { |
858 } else { |
841 surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); |
859 surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); |
|
860 } |
|
861 |
|
862 if (sendNativePaintEvents) { |
|
863 const QRect r = qt_TRect2QRect(controlRect); |
|
864 // The draw ops aren't actually sent to WSERV until the graphics |
|
865 // context is deactivated, which happens in the function calling |
|
866 // this one. We therefore delay the delivery of endNativePaintEvent, |
|
867 // to ensure that drawing has completed by the time the widget |
|
868 // receives the event. Note that, if the widget needs to ensure |
|
869 // that the draw ops have actually been executed into the output |
|
870 // framebuffer, a call to RWsSession::Flush is required in the |
|
871 // endNativePaintEvent implementation. |
|
872 QMetaObject::invokeMethod(qwidget, "endNativePaintEvent", Qt::QueuedConnection, Q_ARG(QRect, r)); |
842 } |
873 } |
843 } |
874 } |
844 |
875 |
845 void QSymbianControl::SizeChanged() |
876 void QSymbianControl::SizeChanged() |
846 { |
877 { |
901 if (QApplicationPrivate::popupWidgets != 0 |
937 if (QApplicationPrivate::popupWidgets != 0 |
902 || (qwidget->windowType() & Qt::Popup) == Qt::Popup) |
938 || (qwidget->windowType() & Qt::Popup) == Qt::Popup) |
903 return; |
939 return; |
904 |
940 |
905 if (IsFocused() && IsVisible()) { |
941 if (IsFocused() && IsVisible()) { |
|
942 if (m_symbianPopupIsOpen) { |
|
943 QWidget *fw = QApplication::focusWidget(); |
|
944 if (fw) { |
|
945 QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason); |
|
946 QCoreApplication::sendEvent(fw, &event); |
|
947 } |
|
948 m_symbianPopupIsOpen = false; |
|
949 } |
|
950 |
906 QApplication::setActiveWindow(qwidget->window()); |
951 QApplication::setActiveWindow(qwidget->window()); |
|
952 qwidget->d_func()->setWindowIcon_sys(true); |
|
953 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
907 #ifdef Q_WS_S60 |
954 #ifdef Q_WS_S60 |
908 // If widget is fullscreen, hide status pane and button container |
955 // If widget is fullscreen, hide status pane and button container |
909 // otherwise show them. |
956 // otherwise show them. |
910 CEikStatusPane* statusPane = S60->statusPane(); |
957 CEikStatusPane* statusPane = S60->statusPane(); |
911 CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); |
958 CEikButtonGroupContainer* buttonGroup = S60->buttonGroupContainer(); |
912 bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; |
959 bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; |
913 if (statusPane && (statusPane->IsVisible() == isFullscreen)) |
960 if (statusPane && (bool)statusPane->IsVisible() == isFullscreen) |
914 statusPane->MakeVisible(!isFullscreen); |
961 statusPane->MakeVisible(!isFullscreen); |
915 if (buttonGroup && (buttonGroup->IsVisible() == isFullscreen)) |
962 if (buttonGroup && (bool)buttonGroup->IsVisible() == isFullscreen) |
916 buttonGroup->MakeVisible(!isFullscreen); |
963 buttonGroup->MakeVisible(!isFullscreen); |
917 #endif |
964 #endif |
918 } else if (QApplication::activeWindow() == qwidget->window()) { |
965 } else if (QApplication::activeWindow() == qwidget->window()) { |
|
966 if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog()) { |
|
967 QWidget *fw = QApplication::focusWidget(); |
|
968 if (fw) { |
|
969 QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); |
|
970 QCoreApplication::sendEvent(fw, &event); |
|
971 } |
|
972 m_symbianPopupIsOpen = true; |
|
973 return; |
|
974 } |
|
975 |
919 QApplication::setActiveWindow(0); |
976 QApplication::setActiveWindow(0); |
920 } |
977 } |
921 // else { We don't touch the active window unless we were explicitly activated or deactivated } |
978 // else { We don't touch the active window unless we were explicitly activated or deactivated } |
922 } |
979 } |
923 |
980 |
924 void QSymbianControl::HandleResourceChange(int resourceType) |
981 void QSymbianControl::HandleResourceChange(int resourceType) |
925 { |
982 { |
926 switch (resourceType) { |
983 switch (resourceType) { |
927 case KInternalStatusPaneChange: |
984 case KInternalStatusPaneChange: |
928 qwidget->d_func()->setWindowIcon_sys(true); |
985 if (qwidget->isFullScreen()) { |
|
986 SetExtentToWholeScreen(); |
|
987 } else if (qwidget->isMaximized()) { |
|
988 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
989 SetExtent(r.iTl, r.Size()); |
|
990 } |
|
991 if (IsFocused() && IsVisible()) { |
|
992 qwidget->d_func()->setWindowIcon_sys(true); |
|
993 qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); |
|
994 } |
929 break; |
995 break; |
930 case KUidValueCoeFontChangeEvent: |
996 case KUidValueCoeFontChangeEvent: |
931 // font change event |
997 // font change event |
932 break; |
998 break; |
933 #ifdef Q_WS_S60 |
999 #ifdef Q_WS_S60 |