From 37f338e5edc6d7b70b5a4eaf63326f2a22d7bfbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 21 Sep 2011 17:39:34 +0200 Subject: [PATCH] Fixed geometry issues. We need to compare against the window's currently known geometry to know when to send resize and move events. Also make sure at least one resize event is sent, instead of sending one before each expose. Change-Id: Id7ebe4c1c0e723af9198c668a0c736d64efdbf3e Reviewed-on: http://codereview.qt-project.org/5364 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/gui/kernel/qguiapplication.cpp | 9 ++++----- src/gui/kernel/qwindow.cpp | 8 ++++++++ src/gui/kernel/qwindow.h | 2 ++ src/gui/kernel/qwindow_p.h | 2 ++ src/plugins/platforms/xcb/qxcbwindow.cpp | 12 +++--------- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a19ae4824f..2aaa2e65f8 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -701,16 +701,18 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr return; QRect newRect = e->newGeometry; - QRect cr = window->geometry(); + QRect cr = window->d_func()->geometry; bool isResize = cr.size() != newRect.size(); bool isMove = cr.topLeft() != newRect.topLeft(); window->d_func()->geometry = newRect; - if (isResize) { + if (isResize || window->d_func()->resizeEventPending) { QResizeEvent e(newRect.size(), cr.size()); QGuiApplication::sendSpontaneousEvent(window, &e); + + window->d_func()->resizeEventPending = false; } if (isMove) { @@ -925,9 +927,6 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E QWindow *window = e->exposed.data(); - QResizeEvent resizeEvent(window->handle()->geometry().size(), window->size()); - QGuiApplication::sendSpontaneousEvent(window, &resizeEvent); - QExposeEvent exposeEvent(e->region); QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b0faed7992..759ee8dbc4 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -537,6 +537,10 @@ void QWindow::exposeEvent(QExposeEvent *) { } +void QWindow::moveEvent(QMoveEvent *) +{ +} + void QWindow::resizeEvent(QResizeEvent *) { } @@ -568,6 +572,10 @@ bool QWindow::event(QEvent *event) mouseDoubleClickEvent(static_cast(event)); break; + case QEvent::Move: + moveEvent(static_cast(event)); + break; + case QEvent::Resize: resizeEvent(static_cast(event)); break; diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 0a74e64300..4bb1ff77a5 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -60,6 +60,7 @@ QT_MODULE(Gui) class QWindowPrivate; class QExposeEvent; +class QMoveEvent; class QResizeEvent; class QShowEvent; class QHideEvent; @@ -195,6 +196,7 @@ Q_SIGNALS: protected: virtual void exposeEvent(QExposeEvent *); virtual void resizeEvent(QResizeEvent *); + virtual void moveEvent(QMoveEvent *); virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 38b90fdd73..8a3bc0d7fe 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -67,6 +67,7 @@ public: , platformWindow(0) , visible(false) , windowState(Qt::WindowNoState) + , resizeEventPending(true) , maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX) , modality(Qt::NonModal) , transientParent(0) @@ -99,6 +100,7 @@ public: QString windowTitle; QRect geometry; Qt::WindowState windowState; + bool resizeEventPending; QSize minimumSize; QSize maximumSize; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index cde450e8e6..5458674ae2 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -343,6 +343,8 @@ void QXcbWindow::setGeometry(const QRect &rect) qBound(1, rect.height(), XCOORD_MAX) }; Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); + + xcb_flush(xcb_connection()); } QMargins QXcbWindow::frameMargins() const @@ -1168,15 +1170,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) { - int xpos = geometry().x(); - int ypos = geometry().y(); - - if ((event->width == geometry().width() && event->height == geometry().height()) || event->x != 0 || event->y != 0) { - xpos = event->x; - ypos = event->y; - } - - QRect rect(xpos, ypos, event->width, event->height); + QRect rect(event->x, event->y, event->width, event->height); QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect);