From efb48f70efafed9806940bd7577fb70d1edd1af8 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sun, 3 Mar 2002 12:39:31 +0000 Subject: [PATCH] CT: fix my fix for Ctrl+ArrowKeys moving. Reviewed by Matthias Ettrich svn path=/trunk/kdebase/kwin/; revision=140544 --- client.cpp | 27 +++++++++++----------- client.h | 3 +-- workspace.cpp | 64 +++++++++++++++++++++++++-------------------------- 3 files changed, 46 insertions(+), 48 deletions(-) diff --git a/client.cpp b/client.cpp index f67d01b81b..bc9706e5fe 100644 --- a/client.cpp +++ b/client.cpp @@ -7,6 +7,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include #include #include +#include #include #include "workspace.h" #include "client.h" @@ -32,8 +34,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include #include #include -#include -#include // Needed for --enable-final // XIconincState is defined in workspace.cpp @@ -41,8 +41,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich #define IconicState XIconicState #endif -#include - namespace KWinInternal { // NET WM Protocol handler class @@ -2679,15 +2677,16 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo } -void Client::keyPressEvent( KKeyNative& keyX) +void Client::keyPressEvent( uint key_code ) { if ( !isMove() && !isResize() ) return; - bool is_control = keyX.mod() == KKeyNative::modX(KKey::CTRL); + bool is_control = key_code & KKeyNative::modX(KKey::CTRL); + key_code = key_code & 0xffff; int delta = is_control?1:8; QPoint pos = QCursor::pos(); - switch ( keyX.sym() ) { - case XK_Left: + switch ( key_code ) { + case Key_Left: pos.rx() -= delta; if ( isResize() && !resizeHorizontalDirectionFixed ) { resizeHorizontalDirectionFixed = TRUE; @@ -2696,7 +2695,7 @@ void Client::keyPressEvent( KKeyNative& keyX) setMouseCursor( mode ); } break; - case XK_Right: + case Key_Right: pos.rx() += delta; if ( isResize() && !resizeHorizontalDirectionFixed ) { resizeHorizontalDirectionFixed = TRUE; @@ -2705,7 +2704,7 @@ void Client::keyPressEvent( KKeyNative& keyX) setMouseCursor( mode ); } break; - case XK_Up: + case Key_Up: pos.ry() -= delta; if ( isResize() && !resizeVerticalDirectionFixed ) { resizeVerticalDirectionFixed = TRUE; @@ -2714,7 +2713,7 @@ void Client::keyPressEvent( KKeyNative& keyX) setMouseCursor( mode ); } break; - case XK_Down: + case Key_Down: pos.ry() += delta; if ( isResize() && !resizeVerticalDirectionFixed ) { resizeVerticalDirectionFixed = TRUE; @@ -2723,9 +2722,9 @@ void Client::keyPressEvent( KKeyNative& keyX) setMouseCursor( mode ); } break; - case XK_Return: - case XK_KP_Space: - case XK_KP_Enter: + case Key_Space: + case Key_Return: + case Key_Enter: clearbound(); stopMoveResize(); setGeometry( geom ); diff --git a/client.h b/client.h index 29aca5199a..9bbaa0b514 100644 --- a/client.h +++ b/client.h @@ -7,7 +7,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich #define CLIENT_H #include "options.h" -#include #include #include #include @@ -210,7 +209,7 @@ public: QString caption() const; void setCaption( const QString &); - void keyPressEvent( KKeyNative& keyX ); + void keyPressEvent( uint key_code ); void updateUserTime(); diff --git a/workspace.cpp b/workspace.cpp index 1cead06f57..befabb0242 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -434,7 +434,7 @@ void Workspace::init() if ( addSystemTrayWin( wins[i] ) ) continue; Client* c = clientFactory( wins[i] ); - addClient( c ); + addClient( c ); c->manage( TRUE ); if ( root != qt_xrootwin() ) { @@ -591,7 +591,7 @@ bool Workspace::workspaceEvent( XEvent * e ) // TODO may use QWidget:.create XReparentWindow( qt_xdisplay(), c->winId(), root, 0, 0 ); } - addClient( c ); + addClient( c ); } } if ( c ) { @@ -1088,7 +1088,7 @@ bool Workspace::keyPress(XKeyEvent& ev) kdDebug(125) << "Workspace::keyPress( " << keyX.key().toString() << " )" << endl; if (d->movingClient) { - d->movingClient->keyPressEvent(keyX); + d->movingClient->keyPressEvent(keyQt); return TRUE; } @@ -1214,14 +1214,14 @@ int Workspace::previousDesktop( int iDesktop ) const void Workspace::circulateDesktopApplications() { if ( desktops.count() <= 1 ) - return; + return; Client* first = desktops.first(); desktops.remove( first ); desktops.append( first ); Window* new_stack = new Window[ desktops.count() + 1 ]; int i = 0; for ( ClientList::ConstIterator it = desktops.fromLast(); it != desktops.end(); --it) - new_stack[i++] = (*it)->winId(); + new_stack[i++] = (*it)->winId(); XRestackWindows(qt_xdisplay(), new_stack, i); delete [] new_stack; } @@ -1229,23 +1229,23 @@ void Workspace::circulateDesktopApplications() void Workspace::addClient( Client* c ) { if ( c->isDesktop() ) { - if ( !desktops.isEmpty() ) { - Client* first = desktops.first(); - Window stack[2]; - stack[0] = first->winId(); - stack[1] = c->winId(); - XRestackWindows( qt_xdisplay(), stack, 2 ); - desktops.prepend( c ); - circulateDesktopApplications(); - } else { - c->lower(); - desktops.append( c ); - } + if ( !desktops.isEmpty() ) { + Client* first = desktops.first(); + Window stack[2]; + stack[0] = first->winId(); + stack[1] = c->winId(); + XRestackWindows( qt_xdisplay(), stack, 2 ); + desktops.prepend( c ); + circulateDesktopApplications(); + } else { + c->lower(); + desktops.append( c ); + } } else { - if ( c->wantsTabFocus() ) - focus_chain.append( c ); - clients.append( c ); - stacking_order.append( c ); + if ( c->wantsTabFocus() ) + focus_chain.append( c ); + clients.append( c ); + stacking_order.append( c ); } } @@ -1567,14 +1567,14 @@ void Workspace::clientHidden( Client* c ) } } } - if ( !c->isDesktop() && !desktops.isEmpty() ) - requestFocus( desktops.last() ); - else - focusToNull(); + if ( !c->isDesktop() && !desktops.isEmpty() ) + requestFocus( desktops.last() ); + else + focusToNull(); } else { - // if blocking focus, move focus to the desktop later if needed - // in order to avoid flickering - focusToNull(); + // if blocking focus, move focus to the desktop later if needed + // in order to avoid flickering + focusToNull(); } } @@ -1785,7 +1785,7 @@ void Workspace::smartPlacement(Client* c){ cyt = y; cyb = y + ch; QValueList::ConstIterator l; for(l = clients.begin(); l != clients.end() ; ++l ) { - if((*l)->isOnDesktop(desktop) && + if((*l)->isOnDesktop(desktop) && !(*l)->isIconified() && (*l) != c ) { xl = (*l)->x(); yt = (*l)->y(); @@ -1833,7 +1833,7 @@ void Workspace::smartPlacement(Client* c){ QValueList::ConstIterator l; for(l = clients.begin(); l != clients.end() ; ++l) { - if ( (*l)->isOnDesktop(desktop) && + if ( (*l)->isOnDesktop(desktop) && !(*l)->isIconified() && (*l) != c ) { xl = (*l)->x(); yt = (*l)->y(); @@ -1863,7 +1863,7 @@ void Workspace::smartPlacement(Client* c){ //test the position of each window on the desk QValueList::ConstIterator l; for( l = clients.begin(); l != clients.end() ; ++l ) { - if( (*l)->isOnDesktop(desktop) && + if( (*l)->isOnDesktop(desktop) && (*l) != c && !c->isIconified() ) { xl = (*l)->x(); yt = (*l)->y(); @@ -3280,7 +3280,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos ) QValueList::ConstIterator l; for (l = clients.begin();l != clients.end();++l ) { - if ((*l)->isOnDesktop(currentDesktop()) && + if ((*l)->isOnDesktop(currentDesktop()) && !(*l)->isIconified() #if 0 && (*l)->transientFor() == None