From ac87507e171630df8a69eb7b3efbf0f676caccbf Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 2 Nov 2000 08:33:00 +0000 Subject: [PATCH] And here we go, now we have to snapping styles in kwin, the classic "magnetic" style and the new "barrier" style. To enable the new style insert MagneticBorders=off in your kwinrc. The gui for the control center will follow the next days. Anybody a good idea how to call it ? Two radiobuttons, one "Magnetic borders", the other one "Barrier Borders" ? Alex svn path=/trunk/kdebase/kwin/; revision=69692 --- options.cpp | 1 + options.h | 5 ++ workspace.cpp | 178 ++++++++++++++++++++++++++------------------------ 3 files changed, 100 insertions(+), 84 deletions(-) diff --git a/options.cpp b/options.cpp index 62a15fb168..6e451f7665 100644 --- a/options.cpp +++ b/options.cpp @@ -183,6 +183,7 @@ void Options::reload() borderSnapZone = config->readNumEntry("BorderSnapZone", 10); windowSnapZone = config->readNumEntry("WindowSnapZone", 10); + magneticBorders=config->readBoolEntry("MagneticBorders",true); OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade") ); diff --git a/options.h b/options.h index d7868146de..fdf59dab34 100644 --- a/options.h +++ b/options.h @@ -163,6 +163,11 @@ public: int windowSnapZone; + /** + * use magnetic or barrier borders + */ + bool magneticBorders; + /** * whether we animate the minimization of windows or not */ diff --git a/workspace.cpp b/workspace.cpp index ca068f6967..b8099eec47 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2397,103 +2397,113 @@ void Workspace::slotWindowResize() */ QPoint Workspace::adjustClientPosition( Client* c, QPoint pos ) { - //CT 16mar98, 27May98 - magics: BorderSnapZone, WindowSnapZone - //CT adapted for kwin on 25Nov1999 - if (options->windowSnapZone || options->borderSnapZone ) { + //CT 16mar98, 27May98 - magics: BorderSnapZone, WindowSnapZone + //CT adapted for kwin on 25Nov1999 + //aleXXX added option for different snapping style 02Nov2000 + if (options->windowSnapZone || options->borderSnapZone ) + { + bool mB=options->magneticBorders; + QRect maxRect = clientArea(); + int xmin = maxRect.left(); + int xmax = maxRect.right()+1; //desk size + int ymin = maxRect.top(); + int ymax = maxRect.bottom()+1; - int snap; //snap trigger + int cx(pos.x()); + int cy(pos.y()); + int cw(c->width()); + int ch(c->height()); + int rx(cx+cw); + int ry(cy+ch); //these don't change - QRect maxRect = clientArea(); - int xmin = maxRect.left(); - int xmax = maxRect.right()+1; //desk size - int ymin = maxRect.top(); - int ymax = maxRect.bottom()+1; - int cx, cy, rx, ry, cw, ch; //these don't change + int nx(cx), ny(cy); //buffers + int deltaX(xmax); + int deltaY(ymax); //minimum distance to other clients - int nx, ny; //buffers - int deltaX = xmax, deltaY = ymax; //minimum distance to other clients + int lx, ly, lrx, lry; //coords and size for the comparison client, l - int lx, ly, lrx, lry; //coords and size for the comparison client, l + // border snap + int snap = options->borderSnapZone; //snap trigger + if (snap) + { + if ((mB?true:(cxxmax)) && (QABS(rx-xmax)width()); - ry = cy + (ch = c->height()); - - // border snap - snap = options->borderSnapZone; - if (snap) { - if ( QABS(cx-xmin) < snap ){ - deltaX = QABS(cx - xmin); - nx = xmin; - } - if ((QABS(xmax-rx) < snap) && (QABS(xmax-rx) < deltaX)) { - deltaX = QABS(xmax-rx); - nx = xmax - cw; + if ((mB?true:(cyymax)) && (QABS(ry-ymax)windowSnapZone; + if (snap) + { + QValueList::ConstIterator l; + for (l = clients.begin();l != clients.end();++l ) + { + if ((*l)->isOnDesktop(currentDesktop()) && (*l) != desktop_client && + !(*l)->isIconified() && (*l)->transientFor() == None && (*l) != c ) + { + lx = (*l)->x(); + ly = (*l)->y(); + lrx = lx + (*l)->width(); + lry = ly + (*l)->height(); - // windows snap - snap = options->windowSnapZone; - if (snap) { - QValueList::ConstIterator l; - for (l = clients.begin();l != clients.end();++l ) { - if((*l)->isOnDesktop(currentDesktop()) && (*l) != desktop_client && - !(*l)->isIconified() && (*l)->transientFor() == None && - (*l) != c ) { - lx = (*l)->x(); - ly = (*l)->y(); - lrx = lx + (*l)->width(); - lry = ly + (*l)->height(); + if ( (( cy <= lry ) && ( cy >= ly )) || + (( ry >= ly ) && ( ry <= lry )) || + (( cy <= ly ) && ( ry >= lry )) ) + { + if ((mB?true:(cxlx)) && (QABS(rx-lx)= ly ) ) || - ( ( ry >= ly ) && ( ry <= lry ) ) || - ( ( ly >= cy ) && ( lry <= ry ) ) ) { - if ( ( QABS( lrx - cx ) < snap ) && - ( QABS( lrx -cx ) < deltaX ) ) { - deltaX = QABS( lrx - cx ); - nx = lrx; - } - if ( ( QABS( rx - lx ) < snap ) && - ( QABS( rx - lx ) < deltaX ) ) { - deltaX = QABS(rx - lx); - nx = lx - cw; - } - } - - if( ( ( cx <= lrx ) && ( cx >= lx ) ) || - ( ( rx >= lx ) && ( rx <= lrx ) ) || - ( ( lx >= cx ) && ( lrx <= rx ) ) ) { - if ( ( QABS( lry - cy ) < snap ) && - ( QABS( lry -cy ) < deltaY ) ) { - deltaY = QABS( lry - cy ); - ny = lry; - } - if ( ( QABS( ry-ly ) < snap ) && - ( QABS( ry - ly ) < deltaY ) ) { - deltaY = QABS( ry - ly ); - ny = ly - ch; - } - } - } + if ( (( cx <= lrx ) && ( cx >= lx )) || + (( rx >= lx ) && ( rx <= lrx )) || + (( cx <= lx ) && ( rx >= lrx )) ) + { + if ((mB?true:(cyly)) && (QABS(ry-ly)