From: David Rosca Date: Thu, 08 Oct 2015 18:46:45 +0000 Subject: Use NETRootInfo to initiate wm move operation X-Git-Url: http://quickgit.kde.org/?p=breeze.git&a=commitdiff&h=ca72ca904f7fb8872667322bf5143e2b81eaf2f3 --- Use NETRootInfo to initiate wm move operation Also remove hack that messes with cursor position, which results in window sometimes rendered in wrong position for a moment after starting window move. REVIEW: 125522 BUG: 353749 --- --- a/kstyle/breezewindowmanager.cpp +++ b/kstyle/breezewindowmanager.cpp @@ -83,6 +83,14 @@ #if BREEZE_HAVE_X11 #include +#include + +#if BREEZE_USE_KDE4 +#include +#else +#include +#endif + #endif namespace Breeze @@ -139,11 +147,8 @@ //* application-wise event. /** needed to catch end of XMoveResize events */ - bool appMouseEvent( QObject*, QEvent* event ) - { - - // store target window (see later) - QWidget* window( _parent->_target.data()->window() ); + bool appMouseEvent( QObject*, QEvent* ) + { /* post some mouseRelease event to the target, in order to counter balance @@ -151,19 +156,6 @@ */ QMouseEvent mouseEvent( QEvent::MouseButtonRelease, _parent->_dragPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); qApp->sendEvent( _parent->_target.data(), &mouseEvent ); - - if( event->type() == QEvent::MouseMove ) - { - /* - HACK: quickly move the main cursor out of the window and back - this is needed to get the focus right for the window children - the origin of this issue is unknown at the moment - */ - const QPoint cursor = QCursor::pos(); - QCursor::setPos(window->mapToGlobal( window->rect().topRight() ) + QPoint(1, 0) ); - QCursor::setPos(cursor); - - } return false; @@ -194,19 +186,6 @@ _appEventFilter = new AppEventFilter( this ); qApp->installEventFilter( _appEventFilter ); - #if BREEZE_HAVE_X11 - _moveResizeAtom = 0; - if( Helper::isX11() ) - { - // create move-resize atom - xcb_connection_t* connection( Helper::connection() ); - const QString atomName( QStringLiteral( "_NET_WM_MOVERESIZE" ) ); - xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, atomName.size(), qPrintable( atomName ) ) ); - ScopedPointer reply( xcb_intern_atom_reply( connection, cookie, nullptr) ); - _moveResizeAtom = reply ? reply->atom:0; - } - #endif - } //_____________________________________________________________ @@ -755,43 +734,15 @@ const qreal dpiRatio = 1; #endif - // from bespin/virtuality - xcb_button_release_event_t releaseEvent; - memset(&releaseEvent, 0, sizeof(releaseEvent)); - - releaseEvent.response_type = XCB_BUTTON_RELEASE; - releaseEvent.event = window; - releaseEvent.child = XCB_WINDOW_NONE; - releaseEvent.root = QX11Info::appRootWindow(); - releaseEvent.event_x = _dragPoint.x()*dpiRatio; - releaseEvent.event_y = _dragPoint.y()*dpiRatio; - releaseEvent.root_x = position.x()*dpiRatio; - releaseEvent.root_y = position.y()*dpiRatio; - releaseEvent.detail = XCB_BUTTON_INDEX_1; - releaseEvent.state = XCB_BUTTON_MASK_1; - releaseEvent.time = XCB_CURRENT_TIME; - releaseEvent.same_screen = true; - xcb_send_event( connection, false, window, XCB_EVENT_MASK_BUTTON_RELEASE, reinterpret_cast(&releaseEvent)); + #if BREEZE_USE_KDE4 + Display* net_connection = QX11Info::display(); + #else + xcb_connection_t* net_connection = connection; + #endif xcb_ungrab_pointer( connection, XCB_TIME_CURRENT_TIME ); - - // from QtCurve - xcb_client_message_event_t clientMessageEvent; - memset(&clientMessageEvent, 0, sizeof(clientMessageEvent)); - - clientMessageEvent.response_type = XCB_CLIENT_MESSAGE; - clientMessageEvent.format = 32; - clientMessageEvent.window = window; - clientMessageEvent.type = _moveResizeAtom; - clientMessageEvent.data.data32[0] = position.x()*dpiRatio; - clientMessageEvent.data.data32[1] = position.y()*dpiRatio; - clientMessageEvent.data.data32[2] = 8; // NET::Move - clientMessageEvent.data.data32[3] = XCB_KEY_BUT_MASK_BUTTON_1; - xcb_send_event( connection, false, QX11Info::appRootWindow(), - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, reinterpret_cast(&clientMessageEvent) ); - - xcb_flush( connection ); + NETRootInfo rootInfo( net_connection, NET::WMMoveResize ); + rootInfo.moveResizeRequest( window, position.x() * dpiRatio, position.y() * dpiRatio, NET::Move ); #else --- a/kstyle/breezewindowmanager.h +++ b/kstyle/breezewindowmanager.h @@ -31,10 +31,6 @@ #include #include -#if BREEZE_HAVE_X11 -#include -#endif - namespace Breeze { @@ -260,10 +256,6 @@ //* application event filter QObject* _appEventFilter; - #if BREEZE_HAVE_X11 - xcb_atom_t _moveResizeAtom; - #endif - //* allow access of all private members to the app event filter friend class AppEventFilter;