Bug 81170 - JJ: Desktop borders do not allow switching to diagonal desktop
Summary: JJ: Desktop borders do not allow switching to diagonal desktop
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-09 00:55 UTC by Antiphon
Modified: 2007-06-15 15:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antiphon 2004-05-09 00:55:53 UTC
Version:            (using KDE KDE 3.2.2)
Installed from:    Debian testing/unstable Packages
OS:          Linux

When the panel is configured so that the virtual desktops are arranged in the "classic" fashion, the active desktop border function does not allow the user to switch to a desktop which is diagonally across from the current one. 

When the mouse is moved to any screen corner, nothing happens, when instead, the diagonal desktop should be displayed.

(I apologize if "active desktop border" isn't the correct term. I'm typing this report on a a French machine.)
Comment 1 Lubos Lunak 2006-02-23 23:23:55 UTC
JJ: The code is in kdebase/kwin/workspace.cpp in Workspace::clientMoved().
Comment 2 Lubos Lunak 2007-06-15 15:06:21 UTC
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