Summary: | JJ: Desktop borders do not allow switching to diagonal desktop | ||
---|---|---|---|
Product: | [Plasma] kwin | Reporter: | Antiphon <antiphon99> |
Component: | general | Assignee: | KWin default assignee <kwin-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Antiphon
2004-05-09 00:55:53 UTC
JJ: The code is in kdebase/kwin/workspace.cpp in Workspace::clientMoved(). SVN commit 675918 by lunakl: Allow also diagonal desktop switching with electric borders. Don't warp the mouse so much after the switch. BUG: 81170 BUG: 129423 M +35 -56 workspace.cpp --- trunk/KDE/kdebase/workspace/kwin/workspace.cpp #675917:675918 @@ -2225,20 +2225,13 @@ void Workspace::reserveElectricBorderSwitching( bool reserve ) { - if( reserve ) - { - reserveElectricBorder( ElectricTop ); - reserveElectricBorder( ElectricBottom ); - reserveElectricBorder( ElectricLeft ); - reserveElectricBorder( ElectricRight ); - } - else - { - unreserveElectricBorder( ElectricTop ); - unreserveElectricBorder( ElectricBottom ); - unreserveElectricBorder( ElectricLeft ); - unreserveElectricBorder( ElectricRight ); - } + for( int pos = 0; + pos < ELECTRIC_COUNT; + ++pos ) + if( reserve ) + reserveElectricBorder( static_cast< ElectricBorder >( pos )); + else + unreserveElectricBorder( static_cast< ElectricBorder >( pos )); } void Workspace::reserveElectricBorder( ElectricBorder border ) @@ -2328,54 +2321,40 @@ // reset the pointer to find out wether the user is really pushing // (the direction back from which it came, starting from top clockwise) - static int xdiff[ ELECTRIC_COUNT ] = { 0, -1, -1, -1, 0, 1, 1, 1 }; - static int ydiff[ ELECTRIC_COUNT ] = { 1, 1, 0, -1, -1, -1, 0, 1 }; + const int xdiff[ ELECTRIC_COUNT ] = { 0, -1, -1, -1, 0, 1, 1, 1 }; + const int ydiff[ ELECTRIC_COUNT ] = { 1, 1, 0, -1, -1, -1, 0, 1 }; QCursor::setPos( pos.x() + xdiff[ border ], pos.y() + ydiff[ border ] ); } -void Workspace::electricBorderSwitchDesktop( ElectricBorder border, const QPoint& pos ) +void Workspace::electricBorderSwitchDesktop( ElectricBorder border, const QPoint& _pos ) { - QRect r = QApplication::desktop()->geometry(); - int offset; - - int desk_before = currentDesktop(); - switch(border) + QPoint pos = _pos; + int desk = currentDesktop(); + const int OFFSET = 10; + if( border == ElectricLeft || border == ElectricTopLeft || border == ElectricBottomLeft ) { - case ElectricLeft: - slotSwitchDesktopLeft(); - if (currentDesktop() != desk_before) - { - offset = r.width() / 5; - QCursor::setPos(r.width() - offset, pos.y()); - } - break; - case ElectricRight: - slotSwitchDesktopRight(); - if (currentDesktop() != desk_before) - { - offset = r.width() / 5; - QCursor::setPos(offset, pos.y()); - } - break; - case ElectricTop: - slotSwitchDesktopUp(); - if (currentDesktop() != desk_before) - { - offset = r.height() / 5; - QCursor::setPos(pos.x(), r.height() - offset); - } - break; - case ElectricBottom: - slotSwitchDesktopDown(); - if (currentDesktop() != desk_before) - { - offset = r.height() / 5; - QCursor::setPos(pos.x(), offset); - } - break; - default: - break; + desk = desktopToLeft( desk ); + pos.setX( displayWidth() - 1 - OFFSET ); } + if( border == ElectricRight || border == ElectricTopRight || border == ElectricBottomRight ) + { + desk = desktopToRight( desk ); + pos.setX( OFFSET ); + } + if( border == ElectricTop || border == ElectricTopLeft || border == ElectricTopRight ) + { + desk = desktopUp( desk ); + pos.setY( displayHeight() - 1 - OFFSET ); + } + if( border == ElectricBottom || border == ElectricBottomLeft || border == ElectricBottomRight ) + { + desk = desktopDown( desk ); + pos.setY( OFFSET ); + } + int desk_before = currentDesktop(); + setCurrentDesktop( desk ); + if( currentDesktop() != desk_before ) + QCursor::setPos( pos ); } // this function is called when the user entered an electric border |