small optimizations

svn path=/trunk/kdebase/kwin/; revision=44233
This commit is contained in:
Matthias Ettrich 2000-03-21 20:02:27 +00:00
parent bff6c83557
commit c2b5722a6b
5 changed files with 56 additions and 57 deletions

View file

@ -19,6 +19,7 @@
extern Atom qt_wm_state;
extern Time kwin_time;
extern void updateTime(); // defined in workspace.cpp
static bool resizeHorizontalDirectionFixed = FALSE;
static bool resizeVerticalDirectionFixed = FALSE;
@ -158,15 +159,6 @@ QSizePolicy WindowWrapper::sizePolicy() const
}
/**
Gives layout the illusion the wrapper was visible
*/
void WindowWrapper::pseudoShow()
{
clearWState( WState_ForceHide );
}
void WindowWrapper::resizeEvent( QResizeEvent * )
{
if ( win ) {
@ -206,7 +198,7 @@ void WindowWrapper::releaseWindow()
((Client*)parentWidget())->workspace()->rootWin(),
parentWidget()->x(),
parentWidget()->y() );
XRemoveFromSaveSet(qt_xdisplay(), win );
invalidateWindow();
}
@ -226,8 +218,8 @@ bool WindowWrapper::x11Event( XEvent * e)
switch (e->xbutton.button) {
case Button1:
com = options->commandAll1();
break;
case Button2:
break;
case Button2:
com = options->commandAll2();
break;
case Button3:
@ -238,8 +230,8 @@ bool WindowWrapper::x11Event( XEvent * e)
switch (e->xbutton.button) {
case Button1:
com = options->commandWindow1();
break;
case Button2:
break;
case Button2:
com = options->commandWindow2();
break;
case Button3:
@ -251,7 +243,7 @@ bool WindowWrapper::x11Event( XEvent * e)
}
bool replay = ( (Client*)parentWidget() )->performMouseCommand( com,
QPoint( e->xbutton.x_root, e->xbutton.y_root) );
XAllowEvents(qt_xdisplay(), replay? ReplayPointer : SyncPointer, kwin_time);
return TRUE;
}
@ -374,7 +366,7 @@ void Client::manage( bool isMapped )
// // transient_for workaround for broken qt snapshot, #####
// placementDone = TRUE;
// }
if ( !placementDone ) {
workspace()->doPlacement( this );
@ -609,7 +601,7 @@ bool Client::configureRequest( XConfigureRequestEvent& e )
// first, get rid of a window border
XWindowChanges wc;
unsigned int value_mask = 0;
wc.border_width = 0;
value_mask = CWBorderWidth;
XConfigureWindow( qt_xdisplay(), win, value_mask, & wc );
@ -667,7 +659,7 @@ bool Client::propertyNotify( XPropertyEvent& e )
else if ( e.atom == atoms->kwm_win_icon ) {
getWMHints(); // for the icons
}
break;
}
return TRUE;
@ -933,6 +925,11 @@ void Client::mouseMoveEvent( QMouseEvent * e)
break;
}
}
// slow down the window manager in order to give the client time
// to process the configure event. Results in a better overal
// performance.
updateTime();
}
/*!

View file

@ -26,8 +26,6 @@ public:
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
void pseudoShow();
protected:
void resizeEvent( QResizeEvent * );
void showEvent( QShowEvent* );

View file

@ -21,9 +21,6 @@
#include <kaboutdata.h>
#include <klocale.h>
static const char *version = "0.9";
static const char *description = I18N_NOOP( "KDE Window Manager." );
static KCmdLineOptions cmdOptions[] =
{
@ -108,7 +105,7 @@ exit (0);
}
bool kwiniface::process(const QCString &fun, const QByteArray &, QCString& replyType, QByteArray &)
{
{
fprintf(stderr,"Logout Call Recieved\n");
if ( fun == "logout()" )
{
@ -140,10 +137,10 @@ bool Application::x11EventFilter( XEvent *e )
case PropertyNotify:
kwin_time = e->xproperty.time;
break;
case ConfigureNotify:
case ConfigureNotify:
{
if ( e->xconfigure.window != e->xconfigure.event )
return TRUE;
if ( e->xconfigure.window != e->xconfigure.event )
return TRUE;
}
break;
default:
@ -163,9 +160,16 @@ static void sighandler(int) {
QApplication::exit();
}
static const char *version = "0.4";
static const char *description = I18N_NOOP( "The KDE window manager." );
int main( int argc, char * argv[] )
{
KAboutData aboutData( "kwin", I18N_NOOP("KWin"), version, description);
KAboutData aboutData( "kwin", I18N_NOOP("KWin"),
version, description, KAboutData::License_BSD,
"(c) 1999-2000, The KDE Developers");
aboutData.addAuthor("Matthias Ettrich",0, "ettrich@kde.org");
aboutData.addAuthor("Daniel M. Duley",0, "mosfet@kde.org");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions( cmdOptions );

View file

@ -165,14 +165,14 @@ void StdClient::slotReset()
if (button[6])
button[6]->setIconSet( *question_mark_pix );
}
StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
{
create_pixmaps();
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
QGridLayout* g = new QGridLayout( this, 0, 0, 2 );
g->setRowStretch( 1, 10 );
g->addWidget( windowWrapper(), 1, 1 );
@ -317,7 +317,7 @@ void StdClient::stickyChange( bool s)
button[1]->setIconSet( s?*pindown_pix:*pinup_pix );
}
void StdClient::paintEvent( QPaintEvent* )
void StdClient::paintEvent( QPaintEvent* e)
{
QPainter p( this );
QRect t = titlebar->geometry();

View file

@ -48,7 +48,7 @@ int Shape::shapeEvent()
}
static void updateTime()
void updateTime()
{
static QWidget* w = 0;
if ( !w )
@ -260,14 +260,14 @@ bool Workspace::workspaceEvent( XEvent * e )
// SubstructureNotifyMask. e->xany.window is the window the
// event is reported to. Take care not to confuse Qt.
c = findClient( e->xunmap.window );
if ( c )
return c->windowEvent( e );
// check for dock windows
if ( removeDockwin( e->xunmap.window ) )
return TRUE;
if ( e->xunmap.event == root ) {
// keep track of map/unmap for own own windows to avoid
// race conditions
@ -275,7 +275,7 @@ bool Workspace::workspaceEvent( XEvent * e )
if ( c )
return c->windowEvent( e );
}
if ( e->xunmap.event != e->xunmap.window ) // hide wm typical event from Qt
return TRUE;
case MapNotify:
@ -357,7 +357,7 @@ bool Workspace::workspaceEvent( XEvent * e )
wc.stack_mode = Above;
value_mask = e->xconfigurerequest.value_mask | CWBorderWidth;
XConfigureWindow( qt_xdisplay(), e->xconfigurerequest.window, value_mask, & wc );
return TRUE;
}
break;
@ -369,7 +369,7 @@ bool Workspace::workspaceEvent( XEvent * e )
if ( mouse_emulation )
return keyPressMouseEmulation( e->xkey );
return keyPress(e->xkey);
case KeyRelease:
case KeyRelease:
if ( QWidget::keyboardGrabber() ) {
freeKeyboard( FALSE );
break;
@ -616,7 +616,7 @@ bool Workspace::keyRelease(XKeyEvent key)
tab_box->hide();
tab_grab = false;
if ( tab_box->currentClient() ){
activateClient( tab_box->currentClient() );
}
}
@ -918,7 +918,7 @@ QPopupMenu* Workspace::clientPopup( Client* c )
popup->setFont(KGlobal::menuFont());
connect( popup, SIGNAL( aboutToShow() ), this, SLOT( clientPopupAboutToShow() ) );
connect( popup, SIGNAL( activated(int) ), this, SLOT( clientPopupActivated(int) ) );
PluginMenu *deco = new PluginMenu(&mgr, popup);
deco->setFont(KGlobal::menuFont());
@ -933,14 +933,14 @@ QPopupMenu* Workspace::clientPopup( Client* c )
popup->insertItem( i18n("Mi&nimize"), Options::IconifyOp );
popup->insertItem( i18n("Ma&ximize"), Options::MaximizeOp );
popup->insertItem( i18n("Sh&ade"), Options::ShadeOp );
popup->insertSeparator();
popup->insertItem(i18n("&Decoration"), deco );
popup->insertItem(i18n("&To desktop"), desk_popup );
popup->insertSeparator();
QString k = KAccel::keyToString( keys->currentKey( "Window close" ), true );
popup->insertItem(i18n("&Close")+'\t'+k, Options::CloseOp );
}
@ -1045,7 +1045,7 @@ void Workspace::smartPlacement(Client* c){
*/
const int none = 0, h_wrong = -1, w_wrong = -2; // overlap types
long int overlap, min_overlap;
long int overlap, min_overlap = 0;
int x_optimal, y_optimal;
int possible;
@ -1078,10 +1078,10 @@ void Workspace::smartPlacement(Client* c){
for(l = clients.begin(); l != clients.end() ; ++l ) {
if((*l)->isOnDesktop(currentDesktop()) && (*l) != desktop_client &&
!(*l)->isIconified() && (*l) != c ) {
xl = (*l)->x(); yt = (*l)->y();
xr = xl + (*l)->width(); yb = yt + (*l)->height();
//if windows overlap, calc the overall overlapping
if((cxl < xr) && (cxr > xl) &&
(cyt < yb) && (cyb > yt)) {
@ -1120,20 +1120,20 @@ void Workspace::smartPlacement(Client* c){
// compare to the position of each client on the current desk
QValueList<Client*>::ConstIterator l;
for(l = clients.begin(); l != clients.end() ; ++l) {
if ( (*l)->isOnDesktop(currentDesktop()) && (*l) != desktop_client &&
!(*l)->isIconified() && (*l) != c ) {
xl = (*l)->x(); yt = (*l)->y();
xr = xl + (*l)->width(); yb = yt + (*l)->height();
// if not enough room above or under the current tested client
// determine the first non-overlapped x position
if( ( y < yb ) && ( yt < ch + y ) ) {
if( xr > x )
possible = possible < xr ? possible : xr;
if( xl - cw > x )
possible = possible < xl - cw ? possible : xl - cw;
}
@ -1154,13 +1154,13 @@ void Workspace::smartPlacement(Client* c){
for( l = clients.begin(); l != clients.end() ; ++l ) {
if( (*l)->isOnDesktop( currentDesktop() ) && (*l) != desktop_client &&
(*l) != c && !c->isIconified() ) {
xl = (*l)->x(); yt = (*l)->y();
xr = xl + (*l)->width(); yb = yt + (*l)->height();
if( yb > y)
possible = possible < yb ? possible : yb;
if( yt - ch > y )
possible = possible < yt - ch ? possible : yt - ch;
}
@ -1171,7 +1171,7 @@ void Workspace::smartPlacement(Client* c){
while( overlap != none && overlap != h_wrong );
// place the window
c->move( x_optimal, y_optimal );
c->move( x_optimal, y_optimal );
}
@ -1864,7 +1864,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos )
ly = (*l)->y();
lrx = lx + (*l)->width();
lry = ly + (*l)->height();
if( ( ( cy <= lry ) && ( cy >= ly ) ) ||
( ( ry >= ly ) && ( ry <= lry ) ) ||
( ( ly >= cy ) && ( lry <= ry ) ) ) {
@ -1879,7 +1879,7 @@ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos )
nx = lx - cw;
}
}
if( ( ( cx <= lrx ) && ( cx >= lx ) ) ||
( ( rx >= lx ) && ( rx <= lrx ) ) ||
( ( lx >= cx ) && ( lrx <= rx ) ) ) {
@ -1953,7 +1953,7 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent key )
XQueryPointer( qt_xdisplay(), w, &root, &child,
&root_x, &root_y, &lx, &ly, &state );
} while ( child != None && child != w );
if ( c && !c->isActive() )
activateClient( c );