From 8c5a34d32281adfaa5ca164169cb51c1212fd9f3 Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Thu, 29 Nov 2001 23:59:54 +0000 Subject: [PATCH] Take into account a wide range of pager-layouts, the pager can set the required layout via DCOP. Used for desktop left/right/up/down. svn path=/trunk/kdebase/kwin/; revision=124773 --- KWinInterface.h | 1 + options.cpp | 8 ---- options.h | 6 --- workspace.cpp | 121 ++++++++++++++++++++++++++++++++++++++++-------- workspace.h | 4 ++ 5 files changed, 106 insertions(+), 34 deletions(-) diff --git a/KWinInterface.h b/KWinInterface.h index 2cf828cd59..d628000126 100644 --- a/KWinInterface.h +++ b/KWinInterface.h @@ -16,6 +16,7 @@ class KWinInterface : virtual public DCOPObject virtual void refresh() = 0; virtual void doNotManage(QString)= 0; virtual void showWindowMenuAt(unsigned long winId, int x, int y)= 0; + virtual void setDesktopLayout(int orientation, int x, int y)= 0; virtual void setCurrentDesktop(int)= 0; virtual int currentDesktop() const = 0; virtual void nextDesktop() = 0; diff --git a/options.cpp b/options.cpp index a28c834270..e4bc731504 100644 --- a/options.cpp +++ b/options.cpp @@ -228,14 +228,6 @@ void Options::reload() ignorePositionClasses = config->readListEntry("IgnorePositionClasses"); - - // desktop settings - - config->setGroup("Desktops"); - desktopRows = config->readNumEntry( "DesktopRows", 2 ); - if ( desktopRows < 1 ) - desktopRows = 1; - // Mouse bindings config->setGroup( "MouseBindings"); CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise")); diff --git a/options.h b/options.h index 6eb0968575..d23fce083a 100644 --- a/options.h +++ b/options.h @@ -116,12 +116,6 @@ public: bool xineramaMovementEnabled; bool xineramaMaximizeEnabled; - /** - Number of desktop rowsd - */ - int desktopRows; - - /** MoveResizeMode, either Tranparent or Opaque. */ diff --git a/workspace.cpp b/workspace.cpp index 455fba9eac..ff5fe647c7 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -105,7 +105,10 @@ public: electric_right_border(None), electric_time_first(0), electric_time_last(0), - movingClient(0) + movingClient(0), + layoutOrientation(Qt::Vertical), + layoutX(-1), + layoutY(2) { }; ~WorkspacePrivate() {}; KStartupInfo* startup; @@ -123,6 +126,9 @@ public: Time electric_time_last; QPoint electric_push_point; Client *movingClient; + Qt::Orientation layoutOrientation; + int layoutX; + int layoutY; }; }; @@ -2543,6 +2549,7 @@ void Workspace::setNumberOfDesktops( int n ) if ( n == number_of_desktops ) return; number_of_desktops = n; + rootInfo->setNumberOfDesktops( number_of_desktops ); saveDesktopSettings(); @@ -2770,34 +2777,108 @@ void Workspace::slotSwitchDesktopPrevious(){ d = numberOfDesktops(); setCurrentDesktop(d); } -void Workspace::slotSwitchDesktopRight(){ - int d = currentDesktop() + options->desktopRows; - if ( d > numberOfDesktops() ) - d -= numberOfDesktops(); - setCurrentDesktop(d); +void Workspace::setDesktopLayout(int o, int x, int y) +{ + d->layoutOrientation = (Qt::Orientation) o; + d->layoutX = x; + d->layoutY = y; } + +void Workspace::calcDesktopLayout(int &x, int &y) +{ + x = d->layoutX; + y = d->layoutY; + if ((x == -1) && (y > 0)) + x = (numberOfDesktops()+y-1) / y; + else if ((y == -1) && (x > 0)) + y = (numberOfDesktops()+x-1) / x; + + if (x == -1) + x = 1; + if (y == -1) + y = 1; +} + +void Workspace::slotSwitchDesktopRight() +{ + int x,y; + calcDesktopLayout(x,y); + int dt = currentDesktop()-1; + if (d->layoutOrientation == Qt::Vertical) + { + dt += y; + if ( dt >= numberOfDesktops() ) + dt -= numberOfDesktops(); + } + else + { + int d = (dt % x) + 1; + if (d >= x) + d -= x; + dt = dt - (dt % x) + d; + } + setCurrentDesktop(dt+1); +} + void Workspace::slotSwitchDesktopLeft(){ - int d = currentDesktop() - options->desktopRows; - if ( d < 1 ) - d += numberOfDesktops(); - setCurrentDesktop(d); + int x,y; + calcDesktopLayout(x,y); + int dt = currentDesktop()-1; + if (d->layoutOrientation == Qt::Vertical) + { + dt -= y; + if ( dt < 0 ) + dt += numberOfDesktops(); + } + else + { + int d = (dt % x) - 1; + if (d < 0) + d += x; + dt = dt - (dt % x) + d; + } + setCurrentDesktop(dt+1); } + void Workspace::slotSwitchDesktopUp(){ - int d = currentDesktop(); - if ( (d-1) % options->desktopRows == 0 ) - d += options->desktopRows - 1; + int x,y; + calcDesktopLayout(x,y); + int dt = currentDesktop()-1; + if (d->layoutOrientation == Qt::Horizontal) + { + dt -= x; + if ( dt < 0 ) + dt += numberOfDesktops(); + } else - d--; - setCurrentDesktop(d); + { + int d = (dt % y) - 1; + if (d < 0) + d += y; + dt = dt - (dt % y) + d; + } + setCurrentDesktop(dt+1); } + void Workspace::slotSwitchDesktopDown(){ - int d = currentDesktop(); - if ( d % options->desktopRows == 0 ) - d -= options->desktopRows - 1; + int x,y; + calcDesktopLayout(x,y); + int dt = currentDesktop()-1; + if (d->layoutOrientation == Qt::Horizontal) + { + dt += x; + if ( dt >= numberOfDesktops() ) + dt -= numberOfDesktops(); + } else - d++; - setCurrentDesktop(d); + { + int d = (dt % y) + 1; + if (d >= y) + d -= y; + dt = dt - (dt % y) + d; + } + setCurrentDesktop(dt+1); } void Workspace::slotSwitchToDesktop( int i ) diff --git a/workspace.h b/workspace.h index 0980d216f6..7af9aafaa6 100644 --- a/workspace.h +++ b/workspace.h @@ -225,6 +225,7 @@ public: void previousDesktop(); QString desktopName( int desk ); + void setDesktopLayout(int o, int x, int y); bool isNotManaged( const QString& title ); @@ -373,6 +374,9 @@ private: // ------------------ + void calcDesktopLayout(int &x, int &y); + + SystemTrayWindowList systemTrayWins; int current_desktop;