From e329c3d872d0f8f7f80984d12afd731457ccb08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 5 Mar 2004 13:39:27 +0000 Subject: [PATCH] Use a separate InputOnly window covering whole screen because it reportedly improves move/resize performance on some systems for some reason which I fail to see, but oh well. (http://lists.kde.org/?t=107302193400001&r=1&w=2) svn path=/trunk/kdebase/kwin/; revision=293755 --- client.cpp | 1 + client.h | 7 +++++++ events.cpp | 19 +++++++++++++++---- geometry.cpp | 16 +++++++++++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/client.cpp b/client.cpp index 4924b96d85..b5f3cebed5 100644 --- a/client.cpp +++ b/client.cpp @@ -74,6 +74,7 @@ Client::Client( Workspace *ws ) wspace( ws ), bridge( new Bridge( this )), move_faked_activity( false ), + move_resize_grab_window( None ), transient_for( NULL ), transient_for_id( None ), original_transient_for_id( None ), diff --git a/client.h b/client.h index d176246655..d53f82d67c 100644 --- a/client.h +++ b/client.h @@ -239,6 +239,7 @@ class Client : public QObject, public KDecorationDefines void keyPressEvent( uint key_code ); // FRAME ?? void updateMouseGrab(); + Window moveResizeGrabWindow() const; const QPoint calculateGravitation( bool invert, int gravity = 0 ) const; // FRAME public? @@ -389,6 +390,7 @@ private slots: bool buttonDown; bool moveResizeMode; bool move_faked_activity; + Window move_resize_grab_window; bool unrestrictedMoveResize; bool isMove() const { @@ -822,6 +824,11 @@ inline bool Client::hasUserTimeSupport() const return info->userTime() != -1U; } +inline Window Client::moveResizeGrabWindow() const + { + return move_resize_grab_window; + } + #ifdef NDEBUG kndbgstream& operator<<( kndbgstream& stream, const Client* ); kndbgstream& operator<<( kndbgstream& stream, const ClientList& ); diff --git a/events.cpp b/events.cpp index ec4af720e9..5ffbd39abf 100644 --- a/events.cpp +++ b/events.cpp @@ -255,6 +255,12 @@ bool Workspace::workspaceEvent( XEvent * e ) return true; } } + if( movingClient != NULL && movingClient->moveResizeGrabWindow() == e->xany.window + && ( e->type == MotionNotify || e->type == ButtonPress || e->type == ButtonRelease )) + { + if( movingClient->windowEvent( e )) + return true; + } switch (e->type) { @@ -1218,9 +1224,10 @@ bool Client::buttonReleaseEvent( Window w, int /*button*/, int state, int x, int XAllowEvents(qt_xdisplay(), SyncPointer, CurrentTime ); //qt_x_time); return true; } - if( w != frameId() && w != decorationId()) + if( w != moveResizeGrabWindow()) return true; - + x = this->x(); // translate from grab window to local coords + y = this->y(); if ( (state & ( Button1Mask & Button2Mask & Button3Mask )) == 0 ) { buttonDown = FALSE; @@ -1273,7 +1280,7 @@ static bool waitingMotionEvent() // return value matters only when filtering events before decoration gets them bool Client::motionNotifyEvent( Window w, int /*state*/, int x, int y, int x_root, int y_root ) { - if( w != frameId() && w != decorationId()) + if( w != frameId() && w != decorationId() && w != moveResizeGrabWindow()) return true; // care only about the whole frame if ( !buttonDown ) { @@ -1283,7 +1290,11 @@ bool Client::motionNotifyEvent( Window w, int /*state*/, int x, int y, int x_roo mode = newmode; return false; } - + if( w == moveResizeGrabWindow()) + { + x = this->x(); // translate from grab window to local coords + y = this->y(); + } if( !waitingMotionEvent()) handleMoveResize( x, y, x_root, y_root ); return true; diff --git a/geometry.cpp b/geometry.cpp index aac5694735..5fed2aacee 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1706,14 +1706,26 @@ bool Client::startMoveResize() bool has_grab = false; if( mode == PositionCenter ) setCursor( sizeAllCursor ); // change from arrow cursor if moving - if( XGrabPointer( qt_xdisplay(), frameId(), False, + // This reportedly improves smoothness of the moveresize operation, + // something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug* + // (http://lists.kde.org/?t=107302193400001&r=1&w=2) + XSetWindowAttributes attrs; + QRect r = workspace()->clientArea( FullArea, this ); + move_resize_grab_window = XCreateWindow( qt_xdisplay(), workspace()->rootWin(), r.x(), r.y(), + r.width(), r.height(), 0, CopyFromParent, InputOnly, CopyFromParent, 0, &attrs ); + XMapRaised( qt_xdisplay(), move_resize_grab_window ); + if( XGrabPointer( qt_xdisplay(), move_resize_grab_window, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask, GrabModeAsync, GrabModeAsync, None, cursor.handle(), qt_x_time ) == Success ) has_grab = true; if( XGrabKeyboard( qt_xdisplay(), frameId(), False, GrabModeAsync, GrabModeAsync, qt_x_time ) == Success ) has_grab = true; if( !has_grab ) // at least one grab is necessary in order to be able to finish move/resize + { + XDestroyWindow( qt_xdisplay(), move_resize_grab_window ); + move_resize_grab_window = None; return false; + } if ( maximizeMode() != MaximizeRestore ) resetMaximize(); moveResizeMode = true; @@ -1762,6 +1774,8 @@ void Client::leaveMoveResize() ungrabXServer(); XUngrabKeyboard( qt_xdisplay(), qt_x_time ); XUngrabPointer( qt_xdisplay(), qt_x_time ); + XDestroyWindow( qt_xdisplay(), move_resize_grab_window ); + move_resize_grab_window = None; workspace()->setClientIsMoving(0); if( move_faked_activity ) workspace()->unfakeActivity( this );