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
This commit is contained in:
Luboš Luňák 2004-03-05 13:39:27 +00:00
parent be8387b70e
commit e329c3d872
4 changed files with 38 additions and 5 deletions

View file

@ -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 ),

View file

@ -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& );

View file

@ -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;

View file

@ -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 );