Bug 582359 - Fix NS_ACTIVATE and NS_DEACTIVATE in Qt Port r=dougt

This commit is contained in:
Oleg Romashin 2010-07-28 18:05:56 -07:00
Родитель 6729589680
Коммит db5b115750
4 изменённых файлов: 43 добавлений и 24 удалений

Просмотреть файл

@ -41,14 +41,14 @@ void MozQWidget::activate()
{
// ensure that the keyboard is hidden when we activate the window
hideVKB();
mReceiver->DispatchActivateEvent();
mReceiver->DispatchActivateEventOnTopLevelWindow();
}
void MozQWidget::deactivate()
{
// ensure that the keyboard is hidden when we deactivate the window
hideVKB();
mReceiver->DispatchDeactivateEvent();
mReceiver->DispatchDeactivateEventOnTopLevelWindow();
}
void MozQWidget::resizeEvent(QGraphicsSceneResizeEvent* aEvent)

Просмотреть файл

@ -78,33 +78,32 @@ class MozQGraphicsViewEvents
{
public:
MozQGraphicsViewEvents(QGraphicsView* aView, MozQWidget* aTopLevel)
: mTopLevelWidget(aTopLevel)
, mView(aView)
MozQGraphicsViewEvents(QGraphicsView* aView)
: mView(aView)
{ }
void handleEvent(QEvent* aEvent)
void handleEvent(QEvent* aEvent, MozQWidget* aTopLevel)
{
if (!aEvent)
return;
if (aEvent->type() == QEvent::WindowActivate) {
if (mTopLevelWidget)
mTopLevelWidget->activate();
if (aTopLevel)
aTopLevel->activate();
}
if (aEvent->type() == QEvent::WindowDeactivate) {
if (mTopLevelWidget)
mTopLevelWidget->deactivate();
if (aTopLevel)
aTopLevel->deactivate();
}
}
void handleResizeEvent(QResizeEvent* aEvent)
void handleResizeEvent(QResizeEvent* aEvent, MozQWidget* aTopLevel)
{
if (!aEvent)
return;
if (mTopLevelWidget) {
if (aTopLevel) {
// transfer new size to graphics widget
mTopLevelWidget->setGeometry(0.0, 0.0,
aTopLevel->setGeometry(0.0, 0.0,
static_cast<qreal>(aEvent->size().width()),
static_cast<qreal>(aEvent->size().height()));
// resize scene rect to vieport size,
@ -114,14 +113,14 @@ public:
}
}
bool handleCloseEvent(QCloseEvent* aEvent)
bool handleCloseEvent(QCloseEvent* aEvent, MozQWidget* aTopLevel)
{
if (!aEvent)
return false;
if (mTopLevelWidget) {
if (aTopLevel) {
// close graphics widget instead, this view will be discarded
// automatically
QApplication::postEvent(mTopLevelWidget, new QCloseEvent(*aEvent));
QApplication::postEvent(aTopLevel, new QCloseEvent(*aEvent));
aEvent->ignore();
return true;
}
@ -130,7 +129,6 @@ public:
}
private:
MozQWidget* mTopLevelWidget;
QGraphicsView* mView;
};
@ -146,7 +144,7 @@ class MozQGraphicsView : public QGraphicsView
public:
MozQGraphicsView(MozQWidget* aTopLevel, QWidget * aParent = nsnull)
: QGraphicsView (new QGraphicsScene(), aParent)
, mEventHandler(this, aTopLevel)
, mEventHandler(this)
, mTopLevelWidget(aTopLevel)
{
scene()->addItem(aTopLevel);
@ -156,19 +154,19 @@ protected:
virtual bool event(QEvent* aEvent)
{
mEventHandler.handleEvent(aEvent);
mEventHandler.handleEvent(aEvent, mTopLevelWidget);
return QGraphicsView::event(aEvent);
}
virtual void resizeEvent(QResizeEvent* aEvent)
{
mEventHandler.handleResizeEvent(aEvent);
mEventHandler.handleResizeEvent(aEvent, mTopLevelWidget);
QGraphicsView::resizeEvent(aEvent);
}
virtual void closeEvent (QCloseEvent* aEvent)
{
if (!mEventHandler.handleCloseEvent(aEvent))
if (!mEventHandler.handleCloseEvent(aEvent, mTopLevelWidget))
QGraphicsView::closeEvent(aEvent);
}

Просмотреть файл

@ -1311,10 +1311,11 @@ nsEventStatus
nsWindow::OnFocusInEvent(QEvent *aEvent)
{
LOGFOCUS(("OnFocusInEvent [%p]\n", (void *)this));
if (!mWidget)
return nsEventStatus_eIgnore;
DispatchActivateEvent();
DispatchActivateEventOnTopLevelWindow();
LOGFOCUS(("Events sent from focus in event [%p]\n", (void *)this));
return nsEventStatus_eIgnore;
@ -1325,8 +1326,10 @@ nsWindow::OnFocusOutEvent(QEvent *aEvent)
{
LOGFOCUS(("OnFocusOutEvent [%p]\n", (void *)this));
if (mWidget)
DispatchDeactivateEvent();
if (!mWidget)
return nsEventStatus_eIgnore;
DispatchDeactivateEventOnTopLevelWindow();
LOGFOCUS(("Done with container focus out [%p]\n", (void *)this));
return nsEventStatus_eIgnore;
@ -2247,6 +2250,22 @@ nsWindow::DispatchDeactivateEvent(void)
DispatchEvent(&event, status);
}
void
nsWindow::DispatchActivateEventOnTopLevelWindow(void)
{
nsWindow * topLevelWindow = static_cast<nsWindow*>(GetTopLevelWidget());
if (topLevelWindow != nsnull)
topLevelWindow->DispatchActivateEvent();
}
void
nsWindow::DispatchDeactivateEventOnTopLevelWindow(void)
{
nsWindow * topLevelWindow = static_cast<nsWindow*>(GetTopLevelWidget());
if (topLevelWindow != nsnull)
topLevelWindow->DispatchDeactivateEvent();
}
void
nsWindow::DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus)
{

Просмотреть файл

@ -205,6 +205,8 @@ public:
void DispatchActivateEvent(void);
void DispatchDeactivateEvent(void);
void DispatchActivateEventOnTopLevelWindow(void);
void DispatchDeactivateEventOnTopLevelWindow(void);
void DispatchResizeEvent(nsIntRect &aRect, nsEventStatus &aStatus);
nsEventStatus DispatchEvent(nsGUIEvent *aEvent) {