From eb472b9ed5658cda6b16f87fd193c338e1195863 Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Sat, 13 Nov 1999 01:51:22 +0000 Subject: [PATCH] Ctrl-Fx desktop switching to make David happy svn path=/trunk/kdebase/kwin/; revision=33636 --- kwinbindings.cpp | 8 +++++ main.cpp | 2 +- workspace.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++----- workspace.h | 16 +++++++++- 4 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 kwinbindings.cpp diff --git a/kwinbindings.cpp b/kwinbindings.cpp new file mode 100644 index 0000000000..3f63a5228d --- /dev/null +++ b/kwinbindings.cpp @@ -0,0 +1,8 @@ + keys->insertItem(i18n("Switch to desktop 1"), "Switch to desktop 1" ,"CTRL+F1"); + keys->insertItem(i18n("Switch to desktop 2"), "Switch to desktop 2" ,"CTRL+F2"); + keys->insertItem(i18n("Switch to desktop 3"), "Switch to desktop 3" ,"CTRL+F3"); + keys->insertItem(i18n("Switch to desktop 4"), "Switch to desktop 4" ,"CTRL+F4"); + keys->insertItem(i18n("Switch to desktop 5"), "Switch to desktop 5" ,"CTRL+F5"); + keys->insertItem(i18n("Switch to desktop 6"), "Switch to desktop 6" ,"CTRL+F6"); + keys->insertItem(i18n("Switch to desktop 7"), "Switch to desktop 7" ,"CTRL+F7"); + keys->insertItem(i18n("Switch to desktop 8"), "Switch to desktop 8" ,"CTRL+F8"); diff --git a/main.cpp b/main.cpp index f90ece6ac4..e6966cfd15 100644 --- a/main.cpp +++ b/main.cpp @@ -89,7 +89,7 @@ bool Application::x11EventFilter( XEvent *e ) if ( (*it)->workspaceEvent( e ) ) return TRUE; } - return FALSE; + return KApplication::x11EventFilter( e ); } diff --git a/workspace.cpp b/workspace.cpp index fec7a99cb0..5e7b97d8aa 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include "workspace.h" #include "client.h" @@ -102,10 +104,13 @@ Workspace::Workspace() control_grab = FALSE; tab_grab = FALSE; tab_box = new TabBox( this ); + keys = 0; grabKey(XK_Tab, Mod1Mask); grabKey(XK_Tab, Mod1Mask | ShiftMask); grabKey(XK_Tab, ControlMask); grabKey(XK_Tab, ControlMask | ShiftMask); + createKeybindings(); + } Workspace::Workspace( WId rootwin ) @@ -122,14 +127,11 @@ Workspace::Workspace( WId rootwin ) SubstructureNotifyMask ); - init(); control_grab = FALSE; tab_grab = FALSE; - tab_box = new TabBox( this ); - grabKey(XK_Tab, Mod1Mask); - grabKey(XK_Tab, Mod1Mask | ShiftMask); - grabKey(XK_Tab, ControlMask); - grabKey(XK_Tab, ControlMask | ShiftMask); + tab_box = 0; + keys = 0; + init(); } void Workspace::init() @@ -194,6 +196,7 @@ Workspace::~Workspace() } delete tab_box; delete popup; + delete keys; } /*! @@ -328,6 +331,8 @@ Client* Workspace::findClient( WId w ) const /*! Returns the workspace's geometry + + \sa clientArea() */ QRect Workspace::geometry() const { @@ -344,6 +349,22 @@ QRect Workspace::geometry() const } } +/*! + Returns the workspace's client area. + + This is the area within the geometry() where clients can be placed, + i.e. the full geometry minus space for desktop panels, taskbars, + etc. + + Placement algorithms should refer to clientArea. + + \sa geometry() + */ +QRect Workspace::clientArea() const +{ + return geometry(); // for now +} + /* Destroys the client \a c @@ -789,7 +810,7 @@ void Workspace::randomPlacement(Client* c){ static int py = 2 * step; int tx,ty; - QRect maxRect = geometry(); // TODO + QRect maxRect = clientArea(); if (px < maxRect.x()) px = maxRect.x(); @@ -1091,3 +1112,46 @@ void Workspace::propagateDockwins() PropModeReplace, (unsigned char *)cl, dockwins.count()); delete [] cl; } + + +void Workspace::createKeybindings(){ + keys = new KGlobalAccel(); + +#include "kwinbindings.cpp" + + keys->connectItem( "Switch to desktop 1", this, SLOT( slotSwitchDesktop1() )); + keys->connectItem( "Switch to desktop 2", this, SLOT( slotSwitchDesktop2() )); + keys->connectItem( "Switch to desktop 3", this, SLOT( slotSwitchDesktop3() )); + keys->connectItem( "Switch to desktop 4", this, SLOT( slotSwitchDesktop4() )); + keys->connectItem( "Switch to desktop 5", this, SLOT( slotSwitchDesktop5() )); + keys->connectItem( "Switch to desktop 6", this, SLOT( slotSwitchDesktop6() )); + keys->connectItem( "Switch to desktop 7", this, SLOT( slotSwitchDesktop7() )); + keys->connectItem( "Switch to desktop 8", this, SLOT( slotSwitchDesktop8() )); + + keys->readSettings(); +} + +void Workspace::slotSwitchDesktop1(){ + setCurrentDesktop(1); +} +void Workspace::slotSwitchDesktop2(){ + setCurrentDesktop(2); +} +void Workspace::slotSwitchDesktop3(){ + setCurrentDesktop(3); +} +void Workspace::slotSwitchDesktop4(){ + setCurrentDesktop(4); +} +void Workspace::slotSwitchDesktop5(){ + setCurrentDesktop(5); +} +void Workspace::slotSwitchDesktop6(){ + setCurrentDesktop(6); +} +void Workspace::slotSwitchDesktop7(){ + setCurrentDesktop(7); +} +void Workspace::slotSwitchDesktop8(){ + setCurrentDesktop(8); +} diff --git a/workspace.h b/workspace.h index c0a3fd98ba..387235a511 100644 --- a/workspace.h +++ b/workspace.h @@ -36,6 +36,7 @@ public: Client* findClient( WId w ) const; QRect geometry() const; + QRect clientArea() const; bool destroyClient( Client* ); @@ -75,6 +76,18 @@ public: void makeFullScreen( Client* ); + +public slots: + // keybindings + void slotSwitchDesktop1(); + void slotSwitchDesktop2(); + void slotSwitchDesktop3(); + void slotSwitchDesktop4(); + void slotSwitchDesktop5(); + void slotSwitchDesktop6(); + void slotSwitchDesktop7(); + void slotSwitchDesktop8(); + protected: bool keyPress( XKeyEvent key ); @@ -82,8 +95,9 @@ protected: bool clientMessage( XClientMessageEvent msg ); private: - KGlobalAccel *keys; void init(); + KGlobalAccel *keys; + void createKeybindings(); WId root; ClientList clients; ClientList stacking_order;