some more keybindings

less race conditions with map/unmap thanks to BlackboxTechnology(tm)

svn path=/trunk/kdebase/kwin/; revision=77544
This commit is contained in:
Matthias Ettrich 2001-01-11 23:41:07 +00:00
parent 4e97288705
commit 33f78a855b
8 changed files with 129 additions and 73 deletions

View file

@ -154,6 +154,17 @@ static void sendClientMessage(Window w, Atom a, long x){
*/
const long ClientWinMask = KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
KeymapStateMask |
ButtonMotionMask |
PointerMotionMask | // need this, too!
EnterWindowMask | LeaveWindowMask |
FocusChangeMask |
ExposureMask |
StructureNotifyMask |
SubstructureRedirectMask;
WindowWrapper::WindowWrapper( WId w, Client *parent, const char* name)
: QWidget( parent, name )
@ -176,19 +187,7 @@ WindowWrapper::WindowWrapper( WId w, Client *parent, const char* name)
XConfigureWindow( qt_xdisplay(), win, CWBorderWidth, &wc );
// overwrite Qt-defaults because we need SubstructureNotifyMask
XSelectInput( qt_xdisplay(), winId(),
KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
KeymapStateMask |
ButtonMotionMask |
PointerMotionMask | // need this, too!
EnterWindowMask | LeaveWindowMask |
FocusChangeMask |
ExposureMask |
StructureNotifyMask |
SubstructureRedirectMask |
SubstructureNotifyMask
);
XSelectInput( qt_xdisplay(), winId(), ClientWinMask | SubstructureNotifyMask );
XSelectInput( qt_xdisplay(), w,
FocusChangeMask |
@ -316,7 +315,9 @@ void WindowWrapper::map()
}
XMoveResizeWindow( qt_xdisplay(), win,
0, 0, width(), height() );
XSelectInput( qt_xdisplay(), winId(), ClientWinMask );
XMapRaised( qt_xdisplay(), win );
XSelectInput( qt_xdisplay(), winId(), ClientWinMask | SubstructureNotifyMask );
}
}
@ -325,8 +326,11 @@ void WindowWrapper::map()
*/
void WindowWrapper::unmap()
{
if ( win )
if ( win ) {
XSelectInput( qt_xdisplay(), winId(), ClientWinMask );
XUnmapWindow( qt_xdisplay(), win );
XSelectInput( qt_xdisplay(), winId(), ClientWinMask | SubstructureNotifyMask );
}
}
@ -479,11 +483,6 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags
cmap = None;
getWMHints();
getWindowProtocols();
getWmNormalHints(); // get xSizeHint
fetchName();
Window ww;
if ( !XGetTransientForHint( qt_xdisplay(), (Window) win, &ww ) )
transient_for = None;
@ -493,6 +492,11 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags
verifyTransientFor();
}
getWMHints();
getWindowProtocols();
getWmNormalHints(); // get xSizeHint
fetchName();
if ( mainClient()->isSticky() )
setSticky( TRUE );
@ -1698,12 +1702,12 @@ void Client::iconify()
return;
}
Events::raise( Events::Iconify );
setMappingState( IconicState );
if ( (!isTransient() || mainClient() == this ) && isVisible() )
animateIconifyOrDeiconify( TRUE );
hide();
setMappingState( IconicState );
workspace()->iconifyOrDeiconifyTransientsOf( this );
}
@ -1960,7 +1964,7 @@ bool Client::x11Event( XEvent * e)
&& workspace()->topClientOnDesktop() != this ) {
delete autoRaiseTimer;
autoRaiseTimer = new QTimer( this );
connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaiseTimerDone() ) );
connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaise() ) );
autoRaiseTimer->start( options->autoRaiseInterval, TRUE );
}
@ -2096,9 +2100,6 @@ void Client::setShade( bool s )
if ( !wasNorthWest )
clearWFlags( WNorthWestGravity );
resize (s );
XEvent tmpE;
while ( XCheckTypedWindowEvent( qt_xdisplay(), windowWrapper()->winId(), UnmapNotify, &tmpE ) )
; // eat event
} else {
int h = height();
QSize s( sizeForWindowSize( windowWrapper()->size(), TRUE ) );
@ -2120,9 +2121,6 @@ void Client::setShade( bool s )
activateLayout();
if ( isActive() )
workspace()->requestFocus( this );
XEvent tmpE;
while ( XCheckTypedWindowEvent( qt_xdisplay(), windowWrapper()->winId(), MapNotify, &tmpE ) )
; // eat event
}
workspace()->iconifyOrDeiconifyTransientsOf( this );
@ -2208,6 +2206,12 @@ void Client::getWMHints()
// get the icons, allow scaling
icon_pix = KWin::icon( win, 32, 32, TRUE );
miniicon_pix = KWin::icon( win, 16, 16, TRUE );
if ( icon_pix.isNull() && mainClient() != this ) {
icon_pix = mainClient()->icon_pix;
miniicon_pix = mainClient()->miniicon_pix;
}
if ( !isWithdrawn() )
iconChange();
@ -2612,6 +2616,31 @@ QCString Client::wmCommand()
return result;
}
QCString Client::resourceName()
{
QCString result;
XClassHint classHint;
if ( XGetClassHint( qt_xdisplay(), win, &classHint ) ) {
result = classHint.res_name;
XFree( classHint.res_name );
XFree( classHint.res_class );
}
return result;
}
QCString Client::resourceClass()
{
QCString result;
XClassHint classHint;
if ( XGetClassHint( qt_xdisplay(), win, &classHint ) ) {
result = classHint.res_class;
XFree( classHint.res_name );
XFree( classHint.res_class );
}
return result;
}
void Client::activateLayout()
{
if ( layout() )
@ -2802,7 +2831,6 @@ QPixmap Client::animationPixmap( int w )
}
void Client::autoRaise()
{
workspace()->raiseClient( this );
@ -2810,23 +2838,6 @@ void Client::autoRaise()
autoRaiseTimer = 0;
}
void Client::autoRaiseTimerDone()
{
// ensure there's no popup menu open
if ( XGrabPointer( qt_xdisplay(), workspace()->rootWin(), TRUE,
(uint)(ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask |
LeaveWindowMask | PointerMotionMask),
GrabModeAsync, GrabModeAsync,
None, None, kwin_time ) == GrabSuccess ) {
XUngrabPointer( qt_xdisplay(), kwin_time);
autoRaise();
} else {
// if there is, try again
autoRaiseTimer->start( options->autoRaiseInterval, TRUE );
}
}
/*!
Clones settings from other client. Used in
Workspace::slotResetAllClients()

View file

@ -173,6 +173,8 @@ public:
QCString windowRole();
QCString sessionId();
QCString wmCommand();
QCString resourceName();
QCString resourceClass();
QRect adjustedClientArea( const QRect& area ) const;
@ -194,7 +196,6 @@ public slots:
void toggleSticky();
void contextHelp();
void autoRaise();
void autoRaiseTimerDone();
protected:
void paintEvent( QPaintEvent * );

View file

@ -14,8 +14,12 @@
keys->insertItem(i18n("Switch to desktop 14"), "Switch to desktop 14" ,"CTRL+SHIFT+F2");
keys->insertItem(i18n("Switch to desktop 15"), "Switch to desktop 15" ,"CTRL+SHIFT+F3");
keys->insertItem(i18n("Switch to desktop 16"), "Switch to desktop 16" ,"CTRL+SHIFT+F4");
keys->insertItem(i18n("Switch one desktop to the left"), "Switch desktop left" ,"");
keys->insertItem(i18n("Switch to next desktop"), "Switch desktop next" ,"");
keys->insertItem(i18n("Switch to previous desktop"), "Switch desktop previous" ,"");
keys->insertItem(i18n("Switch one desktop to the right"), "Switch desktop right" ,"");
keys->insertItem(i18n("Switch one desktop to the left"), "Switch desktop left" ,"");
keys->insertItem(i18n("Switch one desktop up"), "Switch desktop up" ,"");
keys->insertItem(i18n("Switch one desktop down"), "Switch desktop down" ,"");
keys->insertItem(i18n("Window operations menu"), "Pop-up window operations menu" ,"ALT+F3");
keys->insertItem(i18n("Window close"),"Window close", "ALT+F4");

View file

@ -197,7 +197,7 @@ extern "C" { int kdemain(int, char *[]); }
int kdemain( int argc, char * argv[] )
{
/*
Display* dpy = XOpenDisplay( NULL );
if ( !dpy ) {
fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n",
@ -230,7 +230,8 @@ int kdemain( int argc, char * argv[] )
perror("putenv()");
}
}
*/
KAboutData aboutData( "kwin", I18N_NOOP("KWin"),
version, description, KAboutData::License_BSD,
"(c) 1999-2000, The KDE Developers");

View file

@ -162,9 +162,6 @@ void Options::reload()
if ( val == "CDE" )
altTabStyle = CDE;
// Enable the grab of control-TAB?
useControlTab = config->readBoolEntry ("ControlTab", TRUE);
val = config->readEntry("Placement","Smart");
if (val == "Smart") placement = Smart;
else if (val == "Random") placement = Random;
@ -190,6 +187,16 @@ void Options::reload()
ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
// desktop settings
config->setGroup("Desktops");
// Enable the grab of control-TAB?
useControlTab = config->readBoolEntry ("ControlTab", TRUE);
desktopRows = config->readNumEntry( "DesktopRows", 2 );
if ( desktopRows < 1 )
desktopRows = 1;
// Mouse bindings
config->setGroup( "MouseBindings");
CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"));

View file

@ -98,6 +98,11 @@ public:
Control-TAB shortcut to switch virtual desktop.
*/
bool useControlTab;
/**
Number of desktop rowsd
*/
int desktopRows;
/**

View file

@ -1670,7 +1670,7 @@ void Workspace::lowerClient( Client* c )
for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) {
new_stack[i++] = (*it)->winId();
}
XRaiseWindow(qt_xdisplay(), new_stack[0]);
// XRaiseWindow(qt_xdisplay(), new_stack[0]);
XRestackWindows(qt_xdisplay(), new_stack, i);
delete [] new_stack;
@ -1757,7 +1757,7 @@ void Workspace::raiseClient( Client* c )
for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) {
new_stack[i++] = (*it)->winId();
}
XRaiseWindow(qt_xdisplay(), new_stack[0]);
// XRaiseWindow(qt_xdisplay(), new_stack[0]);
XRestackWindows(qt_xdisplay(), new_stack, i);
delete [] new_stack;
@ -1951,17 +1951,6 @@ void Workspace::setCurrentDesktop( int new_desktop ){
} else {
focusToNull();
}
QApplication::syncX();
XEvent tmpE;
for ( ClientList::ConstIterator it = mapList.begin(); it != mapList.end(); ++it) {
while ( XCheckTypedWindowEvent( qt_xdisplay(), (*it)->windowWrapper()->winId(), UnmapNotify, &tmpE ) )
; // eat event
}
for ( ClientList::ConstIterator it = unmapList.begin(); it != unmapList.end(); ++it) {
while ( XCheckTypedWindowEvent( qt_xdisplay(), (*it)->windowWrapper()->winId(), MapNotify, &tmpE ) )
; // eat event
}
}
@ -2120,8 +2109,12 @@ void Workspace::createKeybindings(){
keys->connectItem( "Switch to desktop 14", this, SLOT( slotSwitchDesktop14() ));
keys->connectItem( "Switch to desktop 15", this, SLOT( slotSwitchDesktop15() ));
keys->connectItem( "Switch to desktop 16", this, SLOT( slotSwitchDesktop16() ));
keys->connectItem( "Switch desktop previous", this, SLOT( slotSwitchDesktopPrevious() ));
keys->connectItem( "Switch desktop next", this, SLOT( slotSwitchDesktopNext() ));
keys->connectItem( "Switch desktop left", this, SLOT( slotSwitchDesktopLeft() ));
keys->connectItem( "Switch desktop right", this, SLOT( slotSwitchDesktopRight() ));
keys->connectItem( "Switch desktop up", this, SLOT( slotSwitchDesktopUp() ));
keys->connectItem( "Switch desktop down", this, SLOT( slotSwitchDesktopDown() ));
keys->connectItem( "Pop-up window operations menu", this, SLOT( slotWindowOperations() ) );
keys->connectItem( "Window close", this, SLOT( slotWindowClose() ) );
@ -2191,17 +2184,47 @@ void Workspace::slotSwitchDesktop15(){
void Workspace::slotSwitchDesktop16(){
setCurrentDesktop(16);
}
void Workspace::slotSwitchDesktopNext(){
int d = currentDesktop() + 1;
if ( d > numberOfDesktops() )
d = 1;
setCurrentDesktop(d);
}
void Workspace::slotSwitchDesktopPrevious(){
int d = currentDesktop() - 1;
if ( d <= 0 )
d = numberOfDesktops();
setCurrentDesktop(d);
}
void Workspace::slotSwitchDesktopRight(){
int d = currentDesktop() + 1;
if ( d > number_of_desktops )
d = 1;
setCurrentDesktop(d);
int d = currentDesktop() + options->desktopRows;
if ( d > numberOfDesktops() )
d -= numberOfDesktops();
setCurrentDesktop(d);
}
void Workspace::slotSwitchDesktopLeft(){
int d = currentDesktop() - 1;
if ( d <= 0 )
d = number_of_desktops;
setCurrentDesktop(d);
int d = currentDesktop() - options->desktopRows;
if ( d < 1 )
d += numberOfDesktops();
setCurrentDesktop(d);
}
void Workspace::slotSwitchDesktopUp(){
int d = currentDesktop();
if ( (d-1) % options->desktopRows == 0 )
d += options->desktopRows - 1;
else
d--;
setCurrentDesktop(d);
}
void Workspace::slotSwitchDesktopDown(){
int d = currentDesktop();
if ( d % options->desktopRows == 0 )
d -= options->desktopRows - 1;
else
d++;
setCurrentDesktop(d);
}
/*!

View file

@ -209,8 +209,12 @@ public slots:
void slotSwitchDesktop14();
void slotSwitchDesktop15();
void slotSwitchDesktop16();
void slotSwitchDesktopNext();
void slotSwitchDesktopPrevious();
void slotSwitchDesktopRight();
void slotSwitchDesktopLeft();
void slotSwitchDesktopUp();
void slotSwitchDesktopDown();
void slotWindowMaximize();
void slotWindowMaximizeVertical();