CT: fix my fix for Ctrl+ArrowKeys moving. Reviewed by Matthias Ettrich

svn path=/trunk/kdebase/kwin/; revision=140544
This commit is contained in:
Cristian Tibirna 2002-03-03 12:39:31 +00:00
parent e5e8ee00c1
commit efb48f70ef
3 changed files with 46 additions and 48 deletions

View file

@ -7,6 +7,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <klocale.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kkeynative.h>
#include <kshortcut.h>
#include <dcopclient.h>
#include <qapplication.h>
@ -20,6 +21,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <qobjectlist.h>
#include <qdatetime.h>
#include <qtimer.h>
#include <kwin.h>
#include <kiconloader.h>
#include "workspace.h"
#include "client.h"
@ -32,8 +34,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include <X11/keysym.h>
#include <X11/keysymdef.h>
// Needed for --enable-final
// XIconincState is defined in workspace.cpp
@ -41,8 +41,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#define IconicState XIconicState
#endif
#include <kwin.h>
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 );

View file

@ -7,7 +7,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#define CLIENT_H
#include "options.h"
#include <kkeynative.h>
#include <qframe.h>
#include <qvbox.h>
#include <qpixmap.h>
@ -210,7 +209,7 @@ public:
QString caption() const;
void setCaption( const QString &);
void keyPressEvent( KKeyNative& keyX );
void keyPressEvent( uint key_code );
void updateUserTime();

View file

@ -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<Client*>::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<Client*>::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<Client*>::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<Client *>::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