Add WindowStateChanged event.
Not currently considering activation state. Change-Id: Iea9265d35536947b6cc85639bd9839e9fda69bdf Reviewed-on: http://codereview.qt.nokia.com/2609 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
7d07ca2488
commit
8dc2f81c9f
@ -510,6 +510,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
|
||||
case QWindowSystemInterfacePrivate::ActivatedWindow:
|
||||
QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
|
||||
break;
|
||||
case QWindowSystemInterfacePrivate::WindowStateChanged:
|
||||
QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
|
||||
break;
|
||||
case QWindowSystemInterfacePrivate::Close:
|
||||
QGuiApplicationPrivate::processCloseEvent(
|
||||
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
|
||||
@ -690,6 +693,15 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
|
||||
self->notifyActiveWindowChange(previous);
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
|
||||
{
|
||||
if (QWindow *window = wse->window.data()) {
|
||||
QWindowStateChangeEvent e(window->windowState());
|
||||
window->d_func()->windowState = wse->newState;
|
||||
QGuiApplication::sendSpontaneousEvent(window, &e);
|
||||
}
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
|
||||
{
|
||||
if (e->tlw.isNull())
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
|
||||
|
||||
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
|
||||
static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
|
||||
|
||||
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
|
||||
|
||||
|
@ -80,6 +80,13 @@ void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
|
||||
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||
}
|
||||
|
||||
void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowState newState)
|
||||
{
|
||||
QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
|
||||
new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);
|
||||
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
|
||||
}
|
||||
|
||||
void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
|
||||
{
|
||||
QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
static void handleEnterEvent(QWindow *w);
|
||||
static void handleLeaveEvent(QWindow *w);
|
||||
static void handleWindowActivated(QWindow *w);
|
||||
static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
|
||||
|
||||
static void handleMapEvent(QWindow *w);
|
||||
static void handleUnmapEvent(QWindow *w);
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
Enter,
|
||||
Leave,
|
||||
ActivatedWindow,
|
||||
WindowStateChanged,
|
||||
Mouse,
|
||||
Wheel,
|
||||
Key,
|
||||
@ -69,14 +70,14 @@ public:
|
||||
|
||||
class WindowSystemEvent {
|
||||
public:
|
||||
WindowSystemEvent(EventType t)
|
||||
explicit WindowSystemEvent(EventType t)
|
||||
: type(t) { }
|
||||
EventType type;
|
||||
};
|
||||
|
||||
class CloseEvent : public WindowSystemEvent {
|
||||
public:
|
||||
CloseEvent(QWindow *w)
|
||||
explicit CloseEvent(QWindow *w)
|
||||
: WindowSystemEvent(Close), window(w) { }
|
||||
QWeakPointer<QWindow> window;
|
||||
};
|
||||
@ -92,7 +93,7 @@ public:
|
||||
|
||||
class EnterEvent : public WindowSystemEvent {
|
||||
public:
|
||||
EnterEvent(QWindow *enter)
|
||||
explicit EnterEvent(QWindow *enter)
|
||||
: WindowSystemEvent(Enter), enter(enter)
|
||||
{ }
|
||||
QWeakPointer<QWindow> enter;
|
||||
@ -100,7 +101,7 @@ public:
|
||||
|
||||
class LeaveEvent : public WindowSystemEvent {
|
||||
public:
|
||||
LeaveEvent(QWindow *leave)
|
||||
explicit LeaveEvent(QWindow *leave)
|
||||
: WindowSystemEvent(Leave), leave(leave)
|
||||
{ }
|
||||
QWeakPointer<QWindow> leave;
|
||||
@ -108,12 +109,22 @@ public:
|
||||
|
||||
class ActivatedWindowEvent : public WindowSystemEvent {
|
||||
public:
|
||||
ActivatedWindowEvent(QWindow *activatedWindow)
|
||||
explicit ActivatedWindowEvent(QWindow *activatedWindow)
|
||||
: WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
|
||||
{ }
|
||||
QWeakPointer<QWindow> activated;
|
||||
};
|
||||
|
||||
class WindowStateChangedEvent : public WindowSystemEvent {
|
||||
public:
|
||||
WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState)
|
||||
: WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState)
|
||||
{ }
|
||||
|
||||
QWeakPointer<QWindow> window;
|
||||
Qt::WindowState newState;
|
||||
};
|
||||
|
||||
class UserEvent : public WindowSystemEvent {
|
||||
public:
|
||||
UserEvent(QWindow * w, ulong time, EventType t)
|
||||
|
@ -114,6 +114,10 @@ bool QWidgetWindow::event(QEvent *event)
|
||||
handleExposeEvent(static_cast<QExposeEvent *>(event));
|
||||
return true;
|
||||
|
||||
case QEvent::WindowStateChange:
|
||||
handleWindowStateChangedEvent(static_cast<QWindowStateChangeEvent *>(event));
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -385,4 +389,14 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event)
|
||||
m_widget->d_func()->syncBackingStore(event->region());
|
||||
}
|
||||
|
||||
void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event)
|
||||
{
|
||||
// QWindow does currently not know 'active'.
|
||||
Qt::WindowStates eventState = event->oldState();
|
||||
if (m_widget->windowState() & Qt::WindowActive)
|
||||
eventState |= Qt::WindowActive;
|
||||
QWindowStateChangeEvent widgetEvent(eventState);
|
||||
QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -76,6 +76,7 @@ protected:
|
||||
void handleWheelEvent(QWheelEvent *);
|
||||
void handleDragEvent(QEvent *);
|
||||
void handleExposeEvent(QExposeEvent *);
|
||||
void handleWindowStateChangedEvent(QWindowStateChangeEvent *event);
|
||||
|
||||
private:
|
||||
void updateGeometry();
|
||||
|
Loading…
Reference in New Issue
Block a user