diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmousehandler.cpp | 10 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 26 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 33 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.h | 4 |
5 files changed, 77 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 2a98b7f404..48d43857e9 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -151,6 +151,16 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, return true; } compressMouseMove(&msg); + // Eat mouse move after size grip drag. + if (msg.message == WM_MOUSEMOVE) { + QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle()); + if (platformWindow->testFlag(QWindowsWindow::SizeGripOperation)) { + MSG mouseMsg; + while (PeekMessage(&mouseMsg, platformWindow->handle(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ; + platformWindow->clearFlag(QWindowsWindow::SizeGripOperation); + return true; + } + } const QPoint client(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); // Enter new window: track to generate leave event. if (m_windowUnderMouse != window) { diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index b96d61561c..e49b215422 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1402,6 +1402,32 @@ void QWindowsWindow::setMouseGrabEnabled_sys(bool grab) } } +static inline DWORD cornerToWinOrientation(Qt::Corner corner) +{ + switch (corner) { + case Qt::TopLeftCorner: + return 0xf004; // SZ_SIZETOPLEFT; + case Qt::TopRightCorner: + return 0xf005; // SZ_SIZETOPRIGHT + case Qt::BottomLeftCorner: + return 0xf007; // SZ_SIZEBOTTOMLEFT + case Qt::BottomRightCorner: + return 0xf008; // SZ_SIZEBOTTOMRIGHT + } + return 0; +} + +bool QWindowsWindow::startSystemResize(const QPoint &, Qt::Corner corner) +{ + if (!GetSystemMenu(m_data.hwnd, FALSE)) + return false; + + ReleaseCapture(); + PostMessage(m_data.hwnd, WM_SYSCOMMAND, cornerToWinOrientation(corner), 0); + setFlag(SizeGripOperation); + return true; +} + #ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const { diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index ee45be18cd..2fd401029e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -122,7 +122,8 @@ public: OpenGLSurface = 0x10, OpenGLDoubleBuffered = 0x20, OpenGlPixelFormatInitialized = 0x40, - BlockedByModal = 0x80 + BlockedByModal = 0x80, + SizeGripOperation = 0x100 }; struct WindowData @@ -173,6 +174,8 @@ public: virtual bool setKeyboardGrabEnabled(bool grab); virtual bool setMouseGrabEnabled(bool grab); + virtual bool startSystemResize(const QPoint &pos, Qt::Corner corner); + Qt::WindowState windowState_sys() const; Qt::WindowStates windowStates_sys() const; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 390628d291..a1ac5c5eb1 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1670,4 +1670,37 @@ void QXcbWindow::setCursor(xcb_cursor_t cursor) xcb_flush(xcb_connection()); } +#ifdef XCB_USE_XLIB + +bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) +{ + const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); + if (!connection()->wmSupport()->isSupportedByWM(moveResize)) + return false; + XEvent xev; + xev.xclient.type = ClientMessage; + xev.xclient.message_type = moveResize; + Display *display = (Display *)connection()->xlib_display(); + xev.xclient.display = display; + xev.xclient.window = xcb_window(); + xev.xclient.format = 32; + const QPoint globalPos = window()->mapToGlobal(pos); + xev.xclient.data.l[0] = globalPos.x(); + xev.xclient.data.l[1] = globalPos.y(); + const bool bottom = corner == Qt::BottomRightCorner || corner == Qt::BottomLeftCorner; + const bool left = corner == Qt::BottomLeftCorner || corner == Qt::TopLeftCorner; + if (bottom) + xev.xclient.data.l[2] = left ? 6 : 4; // bottomleft/bottomright + else + xev.xclient.data.l[2] = left ? 0 : 2; // topleft/topright + xev.xclient.data.l[3] = Button1; + xev.xclient.data.l[4] = 0; + XUngrabPointer(display, CurrentTime); + XSendEvent(display, m_screen->root(), False, + SubstructureRedirectMask | SubstructureNotifyMask, &xev); + return true; +} + +#endif // XCB_USE_XLIB + QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index c3ea4af83c..6cafa0330b 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -107,6 +107,10 @@ public: QSurfaceFormat format() const; +#ifdef XCB_USE_XLIB + bool startSystemResize(const QPoint &pos, Qt::Corner corner); +#endif // XCB_USE_XLIB + xcb_window_t xcb_window() const { return m_window; } uint depth() const { return m_depth; } QImage::Format imageFormat() const { return m_imageFormat; } |