Ctrl-Fx desktop switching to make David happy
svn path=/trunk/kdebase/kwin/; revision=33636
This commit is contained in:
parent
b49242a017
commit
eb472b9ed5
4 changed files with 95 additions and 9 deletions
8
kwinbindings.cpp
Normal file
8
kwinbindings.cpp
Normal file
|
@ -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");
|
2
main.cpp
2
main.cpp
|
@ -89,7 +89,7 @@ bool Application::x11EventFilter( XEvent *e )
|
|||
if ( (*it)->workspaceEvent( e ) )
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
return KApplication::x11EventFilter( e );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include <kconfig.h>
|
||||
#include <kglobal.h>
|
||||
#include <kglobalaccel.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
|
16
workspace.h
16
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;
|
||||
|
|
Loading…
Reference in a new issue