diff options
Diffstat (limited to 'twin/geometry.cpp')
-rw-r--r-- | twin/geometry.cpp | 468 |
1 files changed, 331 insertions, 137 deletions
diff --git a/twin/geometry.cpp b/twin/geometry.cpp index 5c71e7c1f..581c07ac1 100644 --- a/twin/geometry.cpp +++ b/twin/geometry.cpp @@ -40,7 +40,7 @@ namespace KWinInternal Resizes the workspace after an XRANDR screen size change */ void Workspace::desktopResized() - { +{ //printf("Workspace::desktopResized()\n"); TQRect geom = TDEApplication::desktop()->geometry(); NETSize desktop_geometry; @@ -49,24 +49,17 @@ void Workspace::desktopResized() rootInfo->setDesktopGeometry( -1, desktop_geometry ); updateClientArea( true ); - checkElectricBorders( true ); - } + destroyActiveBorders(); + updateActiveBorders(); +} /*! Resizes the workspace after kdesktop signals a desktop resize */ void Workspace::kDestopResized() - { - //printf("Workspace::kDesktopResized()\n"); - TQRect geom = TDEApplication::desktop()->geometry(); - NETSize desktop_geometry; - desktop_geometry.width = geom.width(); - desktop_geometry.height = geom.height(); - rootInfo->setDesktopGeometry( -1, desktop_geometry ); - - updateClientArea( true ); - checkElectricBorders( true ); - } +{ + desktopResized(); +} /*! Updates the current client areas according to the current clients. @@ -344,23 +337,23 @@ TQPoint Workspace::adjustClientPosition( Client* c, TQPoint pos ) int snap = options->borderSnapZone; //snap trigger if (snap) { - if ((sOWO?(cx<xmin):true) && (QABS(xmin-cx)<snap)) + if ((sOWO?(cx<xmin):true) && (TQABS(xmin-cx)<snap)) { deltaX = xmin-cx; nx = xmin; } - if ((sOWO?(rx>xmax):true) && (QABS(rx-xmax)<snap) && (QABS(xmax-rx) < deltaX)) + if ((sOWO?(rx>xmax):true) && (TQABS(rx-xmax)<snap) && (TQABS(xmax-rx) < deltaX)) { deltaX = rx-xmax; nx = xmax - cw; } - if ((sOWO?(cy<ymin):true) && (QABS(ymin-cy)<snap)) + if ((sOWO?(cy<ymin):true) && (TQABS(ymin-cy)<snap)) { deltaY = ymin-cy; ny = ymin; } - if ((sOWO?(ry>ymax):true) && (QABS(ry-ymax)<snap) && (QABS(ymax-ry) < deltaY)) + if ((sOWO?(ry>ymax):true) && (TQABS(ry-ymax)<snap) && (TQABS(ymax-ry) < deltaY)) { deltaY =ry-ymax; ny = ymax - ch; @@ -387,14 +380,14 @@ TQPoint Workspace::adjustClientPosition( Client* c, TQPoint pos ) (( ry >= ly ) && ( ry <= lry )) || (( cy <= ly ) && ( ry >= lry )) ) { - if ((sOWO?(cx<lrx):true) && (QABS(lrx-cx)<snap) && ( QABS(lrx -cx) < deltaX) ) + if ((sOWO?(cx<lrx):true) && (TQABS(lrx-cx)<snap) && ( TQABS(lrx -cx) < deltaX) ) { - deltaX = QABS( lrx - cx ); + deltaX = TQABS( lrx - cx ); nx = lrx; } - if ((sOWO?(rx>lx):true) && (QABS(rx-lx)<snap) && ( QABS( rx - lx )<deltaX) ) + if ((sOWO?(rx>lx):true) && (TQABS(rx-lx)<snap) && ( TQABS( rx - lx )<deltaX) ) { - deltaX = QABS(rx - lx); + deltaX = TQABS(rx - lx); nx = lx - cw; } } @@ -403,15 +396,15 @@ TQPoint Workspace::adjustClientPosition( Client* c, TQPoint pos ) (( rx >= lx ) && ( rx <= lrx )) || (( cx <= lx ) && ( rx >= lrx )) ) { - if ((sOWO?(cy<lry):true) && (QABS(lry-cy)<snap) && (QABS( lry -cy ) < deltaY)) + if ((sOWO?(cy<lry):true) && (TQABS(lry-cy)<snap) && (TQABS( lry -cy ) < deltaY)) { - deltaY = QABS( lry - cy ); + deltaY = TQABS( lry - cy ); ny = lry; } - //if ( (QABS( ry-ly ) < snap) && (QABS( ry - ly ) < deltaY )) - if ((sOWO?(ry>ly):true) && (QABS(ry-ly)<snap) && (QABS( ry - ly ) < deltaY )) + //if ( (TQABS( ry-ly ) < snap) && (TQABS( ry - ly ) < deltaY )) + if ((sOWO?(ry>ly):true) && (TQABS(ry-ly)<snap) && (TQABS( ry - ly ) < deltaY )) { - deltaY = QABS( ry - ly ); + deltaY = TQABS( ry - ly ); ny = ly - ch; } } @@ -458,30 +451,30 @@ TQRect Workspace::adjustClientSize( Client* c, TQRect moveResizeGeom, int mode ) deltaY = int(snap); #define SNAP_BORDER_TOP \ - if ((sOWO?(newcy<ymin):true) && (QABS(ymin-newcy)<deltaY)) \ + if ((sOWO?(newcy<ymin):true) && (TQABS(ymin-newcy)<deltaY)) \ { \ - deltaY = QABS(ymin-newcy); \ + deltaY = TQABS(ymin-newcy); \ newcy = ymin; \ } #define SNAP_BORDER_BOTTOM \ - if ((sOWO?(newry>ymax):true) && (QABS(ymax-newry)<deltaY)) \ + if ((sOWO?(newry>ymax):true) && (TQABS(ymax-newry)<deltaY)) \ { \ - deltaY = QABS(ymax-newcy); \ + deltaY = TQABS(ymax-newcy); \ newry = ymax; \ } #define SNAP_BORDER_LEFT \ - if ((sOWO?(newcx<xmin):true) && (QABS(xmin-newcx)<deltaX)) \ + if ((sOWO?(newcx<xmin):true) && (TQABS(xmin-newcx)<deltaX)) \ { \ - deltaX = QABS(xmin-newcx); \ + deltaX = TQABS(xmin-newcx); \ newcx = xmin; \ } #define SNAP_BORDER_RIGHT \ - if ((sOWO?(newrx>xmax):true) && (QABS(xmax-newrx)<deltaX)) \ + if ((sOWO?(newrx>xmax):true) && (TQABS(xmax-newrx)<deltaX)) \ { \ - deltaX = QABS(xmax-newrx); \ + deltaX = TQABS(xmax-newrx); \ newrx = xmax; \ } switch ( mode ) @@ -550,30 +543,30 @@ TQRect Workspace::adjustClientSize( Client* c, TQRect moveResizeGeom, int mode ) #define SNAP_WINDOW_TOP if ( (sOWO?(newcy<lry):true) \ && WITHIN_WIDTH \ - && (QABS( lry - newcy ) < deltaY) ) { \ - deltaY = QABS( lry - newcy ); \ + && (TQABS( lry - newcy ) < deltaY) ) { \ + deltaY = TQABS( lry - newcy ); \ newcy=lry; \ } #define SNAP_WINDOW_BOTTOM if ( (sOWO?(newry>ly):true) \ && WITHIN_WIDTH \ - && (QABS( ly - newry ) < deltaY) ) { \ - deltaY = QABS( ly - newry ); \ + && (TQABS( ly - newry ) < deltaY) ) { \ + deltaY = TQABS( ly - newry ); \ newry=ly; \ } #define SNAP_WINDOW_LEFT if ( (sOWO?(newcx<lrx):true) \ && WITHIN_HEIGHT \ - && (QABS( lrx - newcx ) < deltaX)) { \ - deltaX = QABS( lrx - newcx ); \ + && (TQABS( lrx - newcx ) < deltaX)) { \ + deltaX = TQABS( lrx - newcx ); \ newcx=lrx; \ } #define SNAP_WINDOW_RIGHT if ( (sOWO?(newrx>lx):true) \ && WITHIN_HEIGHT \ - && (QABS( lx - newrx ) < deltaX)) \ + && (TQABS( lx - newrx ) < deltaX)) \ { \ - deltaX = QABS( lx - newrx ); \ + deltaX = TQABS( lx - newrx ); \ newrx=lx; \ } @@ -686,7 +679,7 @@ void Workspace::updateTopMenuGeometry( Client* c ) static Atom msg_type_atom = XInternAtom( tqt_xdisplay(), "_KDE_TOPMENU_MINSIZE", False ); ev.xclient.message_type = msg_type_atom; ev.xclient.format = 32; - ev.xclient.data.l[0] = GET_QT_X_TIME(); + ev.xclient.data.l[0] = get_tqt_x_time(); ev.xclient.data.l[1] = topmenu_space->width(); ev.xclient.data.l[2] = topmenu_space->height(); ev.xclient.data.l[3] = 0; @@ -1458,6 +1451,8 @@ const TQPoint Client::calculateGravitation( bool invert, int gravity ) const void Client::configureRequest( int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool ) { + inhibitConfigureRequests = true; + configureRequestTimer->start(100, true); if( gravity == 0 ) // default (nonsense) value for the argument gravity = xSizeHint.win_gravity; if( value_mask & ( CWX | CWY )) @@ -1906,7 +1901,7 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust ) if( horizontal ) max_mode = MaximizeMode( max_mode ^ MaximizeHorizontal ); } - + max_mode = rules()->checkMaximize( max_mode ); if( !adjust && max_mode == old_mode ) return; @@ -1955,9 +1950,9 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust ) { max_mode = MaximizeHorizontal; maxmode_restore = MaximizeRestore; - } + } } - + switch (max_mode) { @@ -2223,8 +2218,8 @@ void Client::updateFullScreenHack( const TQRect& geom ) workspace()->updateClientLayer( this ); // active fullscreens get different layer } -static TQRect* visible_bound = 0; -static GeometryTip* geometryTip = 0; +static TQRect* visible_bound = nullptr; +static GeometryTip* geometryTip = nullptr; void Client::drawbound( const TQRect& geom ) { @@ -2247,7 +2242,7 @@ void Client::doDrawbound( const TQRect& geom, bool clear ) if( decoration != NULL && decoration->drawbound( geom, clear )) return; // done by decoration TQPainter p ( workspace()->desktopWidget() ); - p.setPen( TQPen( Qt::white, 5 ) ); + p.setPen( TQPen( TQt::white, 5 ) ); p.setRasterOp( TQt::XorROP ); // the line is 5 pixel thick, so compensate for the extra two pixels // on outside (#88657) @@ -2265,44 +2260,43 @@ void Client::doDrawbound( const TQRect& geom, bool clear ) p.drawRect( g ); } -void Client::positionGeometryTip() - { - assert( isMove() || isResize()); +void Client::positionGeometryTip() { + assert(isMove() || isResize()); + // Position and Size display - if (options->showGeometryTip()) - { - if( !geometryTip ) - { // save under is not necessary with opaque, and seem to make things slower + if (options->showGeometryTip()) { + if (!geometryTip) { + // save under is not necessary with opaque, and seem to make things slower bool save_under = ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) - || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ); + || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ); geometryTip = new GeometryTip( &xSizeHint, save_under ); - } - TQRect wgeom( moveResizeGeom ); // position of the frame, size of the window itself - wgeom.setWidth( wgeom.width() - ( width() - clientSize().width())); - wgeom.setHeight( wgeom.height() - ( height() - clientSize().height())); - if( isShade()) - wgeom.setHeight( 0 ); - geometryTip->setGeometry( wgeom ); - if( !geometryTip->isVisible()) - { + } + + // position of the frame, size of the window itself + TQRect wgeom(isActiveBorderMaximizing() ? activeBorderMaximizeGeometry() : moveResizeGeom); + wgeom.setWidth(wgeom.width() - (width() - clientSize().width())); + wgeom.setHeight(isShade() ? 0 : wgeom.height() - (height() - clientSize().height())); + + geometryTip->setGeometry(wgeom); + if (!geometryTip->isVisible()) { geometryTip->show(); geometryTip->raise(); - } } } +} class EatAllPaintEvents - : public QObject + : public TQObject { protected: virtual bool eventFilter( TQObject* o, TQEvent* e ) - { return e->type() == TQEvent::Paint && TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(geometryTip); } + { return e->type() == TQEvent::Paint && o != geometryTip; } }; static EatAllPaintEvents* eater = 0; bool Client::startMoveResize() - { +{ assert( !moveResizeMode ); assert( TQWidget::keyboardGrabber() == NULL ); assert( TQWidget::mouseGrabber() == NULL ); @@ -2319,33 +2313,68 @@ bool Client::startMoveResize() XMapRaised( tqt_xdisplay(), move_resize_grab_window ); if( XGrabPointer( tqt_xdisplay(), move_resize_grab_window, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask, - GrabModeAsync, GrabModeAsync, move_resize_grab_window, cursor.handle(), GET_QT_X_TIME() ) == Success ) + GrabModeAsync, GrabModeAsync, move_resize_grab_window, cursor.handle(), get_tqt_x_time() ) == Success ) has_grab = true; - if( XGrabKeyboard( tqt_xdisplay(), frameId(), False, GrabModeAsync, GrabModeAsync, GET_QT_X_TIME() ) == Success ) + if( XGrabKeyboard( tqt_xdisplay(), frameId(), False, GrabModeAsync, GrabModeAsync, get_tqt_x_time() ) == Success ) has_grab = true; if( !has_grab ) // at least one grab is necessary in order to be able to finish move/resize - { + { XDestroyWindow( tqt_xdisplay(), move_resize_grab_window ); move_resize_grab_window = None; return false; - } - if ( maximizeMode() != MaximizeRestore ) - resetMaximize(); + } + removeShadow(); moveResizeMode = true; + initialMoveResizeGeom = geometry(); + + if (activeTiled) + { + // Restore original geometry + activeTiled = false; + if (options->resetMaximizedWindowGeometry() && isMove()) { + /* Original geometry might be smaller than the tiled one, so the + * mouse pointer might appear off-window when untiling. + * Here we center the window horizontally under the mouse pointer. + * This should work with most window decorations. + */ + activeTiledOrigGeom.moveLeft(TQCursor::pos().x() - (activeTiledOrigGeom.width() / 2)); + moveOffset.setX(TQCursor::pos().x() - activeTiledOrigGeom.x()); + + setGeometry(activeTiledOrigGeom); + } + } + + if ( maximizeMode() != MaximizeRestore ) + { + if (options->resetMaximizedWindowGeometry() && isMove()) { + maximize(MaximizeRestore); + } + else { + resetMaximize(); + } + activeTiled = false; + } + + moveResizeGeom = geometry(); workspace()->setClientIsMoving(this); - initialMoveResizeGeom = moveResizeGeom = geometry(); checkUnrestrictedMoveResize(); + // rule out non opaque windows from useless translucency settings, maybe resizes? if ((isResize() && options->removeShadowsOnResize) || (isMove() && options->removeShadowsOnMove)) + { setShadowSize(0); - if (rules()->checkMoveResizeMode( options->moveMode ) == Options::Opaque){ + } + + if (rules()->checkMoveResizeMode( options->moveMode ) == Options::Opaque) + { savedOpacity_ = opacity_; setOpacity(options->translucentMovingWindows, options->movingWindowOpacity); } + if ( ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ) ) - { + { grabXServer(); kapp->sendPostedEvents(); // we have server grab -> nothing should cause paint events @@ -2353,27 +2382,59 @@ bool Client::startMoveResize() // paint events on some widgets due to FocusIn(?) // eat them, otherwise XOR painting will be broken (#58054) // paint events for the geometrytip need to be allowed, though - eater = new EatAllPaintEvents; + // eater = new EatAllPaintEvents; // not needed anymore? kapp->installEventFilter( eater ); - } + } Notify::raise( isResize() ? Notify::ResizeStart : Notify::MoveStart ); - return true; + + if (options->activeBorders() == Options::ActiveSwitchOnMove || + options->activeBorders() == Options::ActiveTileMaximize || + options->activeBorders() == Options::ActiveTileOnly) + + { + workspace()->reserveActiveBorderSwitching(true); } + return true; +} + void Client::finishMoveResize( bool cancel ) - { +{ leaveMoveResize(); - if( cancel ) - setGeometry( initialMoveResizeGeom ); + + if (!isActiveBorderMaximizing()) { + setGeometry(cancel ? initialMoveResizeGeom : moveResizeGeom); + } + else - setGeometry( moveResizeGeom ); + { + kdDebug() <<"finishing moveresize in active mode, cancel is " << cancel << endl; + activeMaximizing = false; + activeTiled = true; + activeTiledOrigGeom = initialMoveResizeGeom; + switch (activeMode) + { + case ActiveMaximizeMode: { + if (!cancel) { + bool full = (maximizeMode() == MaximizeFull); + setMaximize(!full, !full); + } + break; + } + default: + setGeometry(cancel ? initialMoveResizeGeom + : activeBorderMaximizeGeometry()); + } + activeTiledOrigGeom.moveTopLeft(rect().topLeft()); + } + checkMaximizeGeometry(); // FRAME update(); Notify::raise( isResize() ? Notify::ResizeEnd : Notify::MoveEnd ); - } +} void Client::leaveMoveResize() - { +{ // rule out non opaque windows from useless translucency settings, maybe resizes? if (rules()->checkMoveResizeMode( options->moveMode ) == Options::Opaque) setOpacity(true, savedOpacity_); @@ -2389,8 +2450,8 @@ void Client::leaveMoveResize() if ( ( isMove() && rules()->checkMoveResizeMode( options->moveMode ) != Options::Opaque ) || ( isResize() && rules()->checkMoveResizeMode( options->resizeMode ) != Options::Opaque ) ) ungrabXServer(); - XUngrabKeyboard( tqt_xdisplay(), GET_QT_X_TIME() ); - XUngrabPointer( tqt_xdisplay(), GET_QT_X_TIME() ); + XUngrabKeyboard( tqt_xdisplay(), get_tqt_x_time() ); + XUngrabPointer( tqt_xdisplay(), get_tqt_x_time() ); XDestroyWindow( tqt_xdisplay(), move_resize_grab_window ); move_resize_grab_window = None; workspace()->setClientIsMoving(0); @@ -2401,12 +2462,19 @@ void Client::leaveMoveResize() delete eater; eater = 0; if (options->shadowEnabled(isActive())) - { + { drawIntersectingShadows(); updateOpacityCache(); - } } + if (options->activeBorders() == Options::ActiveSwitchOnMove || + options->activeBorders() == Options::ActiveTileMaximize || + options->activeBorders() == Options::ActiveTileOnly) + { + workspace()->reserveActiveBorderSwitching(false); + } +} + // This function checks if it actually makes sense to perform a restricted move/resize. // If e.g. the titlebar is already outside of the workarea, there's no point in performing // a restricted move resize, because then e.g. resize would also move the window (#74555). @@ -2417,7 +2485,7 @@ void Client::checkUnrestrictedMoveResize() return; TQRect desktopArea = workspace()->clientArea( WorkArea, moveResizeGeom.center(), desktop()); int left_marge, right_marge, top_marge, bottom_marge, titlebar_marge; - // restricted move/resize - keep at least part of the titlebar always visible + // restricted move/resize - keep at least part of the titlebar always visible // how much must remain visible when moved away in that direction left_marge = KMIN( 100 + border_right, moveResizeGeom.width()); right_marge = KMIN( 100 + border_left, moveResizeGeom.width()); @@ -2452,27 +2520,22 @@ void Client::checkUnrestrictedMoveResize() } } -void Client::handleMoveResize( int x, int y, int x_root, int y_root ) - { - if(( mode == PositionCenter && !isMovable()) - || ( mode != PositionCenter && ( isShade() || !isResizable()))) +void Client::handleMoveResize(int x, int y, int x_root, int y_root) { + if ( (mode == PositionCenter && !isMovable()) + || (mode != PositionCenter && (isShade() || !isResizable())) ) return; - if ( !moveResizeMode ) - { - TQPoint p( TQPoint( x, y ) - moveOffset ); - if (p.manhattanLength() >= 6) - { - if( !startMoveResize()) - { + if (!moveResizeMode) { + TQPoint p(TQPoint( x, y ) - moveOffset); + if (p.manhattanLength() >= 6) { + if (!startMoveResize()) { buttonDown = false; setCursor( mode ); return; - } } - else - return; } + else return; + } // ShadeHover or ShadeActive, ShadeNormal was already avoided above if ( mode != PositionCenter && shade_mode != ShadeNone ) @@ -2493,8 +2556,8 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) int left_marge, right_marge, top_marge, bottom_marge, titlebar_marge; if( unrestrictedMoveResize ) // unrestricted, just don't let it go out completely left_marge = right_marge = top_marge = bottom_marge = titlebar_marge = 5; - else // restricted move/resize - keep at least part of the titlebar always visible - { + else // restricted move/resize - keep at least part of the titlebar always visible + { // how much must remain visible when moved away in that direction left_marge = KMIN( 100 + border_right, moveResizeGeom.width()); right_marge = KMIN( 100 + border_left, moveResizeGeom.width()); @@ -2502,16 +2565,16 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) titlebar_marge = initialMoveResizeGeom.height(); top_marge = border_bottom; bottom_marge = border_top; - } + } bool update = false; - if( isResize()) - { + if (isResize()) + { // first resize (without checking constraints), then snap, then check bounds, then check constraints TQRect orig = initialMoveResizeGeom; Sizemode sizemode = SizemodeAny; switch ( mode ) - { + { case PositionTopLeft: moveResizeGeom = TQRect( topleft, orig.bottomRight() ) ; break; @@ -2544,7 +2607,7 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) default: assert( false ); break; - } + } // adjust new size to snap to other windows/borders moveResizeGeom = workspace()->adjustClientSize( this, moveResizeGeom, mode ); @@ -2567,7 +2630,7 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) bottomright = TQPoint( moveResizeGeom.left() + size.width() - 1, moveResizeGeom.top() + size.height() - 1 ); orig = moveResizeGeom; switch ( mode ) - { // these 4 corners ones are copied from above + { // these 4 corners ones are copied from above case PositionTopLeft: moveResizeGeom = TQRect( topleft, orig.bottomRight() ) ; break; @@ -2599,12 +2662,12 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) default: assert( false ); break; - } - if( moveResizeGeom.size() != previousMoveResizeGeom.size()) - update = true; } - else if( isMove()) - { + if (moveResizeGeom.size() != previousMoveResizeGeom.size()) + update = true; + } + else if (isMove()) + { assert( mode == PositionCenter ); // first move, then snap, then check bounds moveResizeGeom.moveTopLeft( topleft ); @@ -2621,29 +2684,160 @@ void Client::handleMoveResize( int x, int y, int x_root, int y_root ) moveResizeGeom.moveLeft(desktopArea.right() - right_marge ); if( moveResizeGeom.topLeft() != previousMoveResizeGeom.topLeft()) update = true; - } + } else - assert( false ); + assert(false); - if( update ) + if (update) + { + bool active = isActiveBorderMaximizing(); + auto mode = active ? options->tilingMode + : isResize() ? options->resizeMode : options->moveMode; + + if (rules()->checkMoveResizeMode(mode) == Options::Opaque) { - if( rules()->checkMoveResizeMode - ( isResize() ? options->resizeMode : options->moveMode ) == Options::Opaque ) - { - setGeometry( moveResizeGeom ); + setGeometry(active ? activeBorderMaximizeGeometry() : moveResizeGeom); positionGeometryTip(); - } - else if( rules()->checkMoveResizeMode - ( isResize() ? options->resizeMode : options->moveMode ) == Options::Transparent ) + } + else if (rules()->checkMoveResizeMode(mode) == Options::Transparent) + { + /* It's necessary to move the geometry tip when there's no outline + * shown, otherwise it would cause repaint problems in case + * they overlap; the paint event will come after this, + * so the geometry tip will be painted above the outline + */ + clearbound(); + positionGeometryTip(); + drawbound(active ? activeBorderMaximizeGeometry() : moveResizeGeom); + } + } + if (isMove()) { + workspace()->checkActiveBorder(globalPos, get_tqt_x_time()); + } +} + +void Client::setActiveBorderMode( ActiveMaximizingMode mode ) +{ + activeMode = mode; +} + +ActiveMaximizingMode Client::activeBorderMode() const +{ + return activeMode; +} + +void Client::setActiveBorder(ActiveBorder border) { + currentActiveBorder = border; +} + +ActiveBorder Client::activeBorder() const { + return currentActiveBorder; +} + +bool Client::isActiveBorderMaximizing() const +{ + return activeMaximizing; +} + +void Client::setActiveBorderMaximizing( bool maximizing ) +{ + activeMaximizing = maximizing; + bool opaque = rules()->checkMoveResizeMode(options->tilingMode) == Options::Opaque; + + if (maximizing || opaque) { + clearbound(); + } + + if (maximizing && !opaque) { + drawbound(activeBorderMaximizeGeometry()); + } +} + +void Client::cancelActiveBorderMaximizing() { + if (!activeMaximizing) return; + activeMaximizing = false; + + // If we are in transparent mode, we need to clear out the bound we had drawn + if (rules()->checkMoveResizeMode(options->tilingMode) == Options::Transparent) { + clearbound(); + } +} + +TQRect Client::activeBorderMaximizeGeometry() +{ + TQRect ret; + TQRect max = workspace()->clientArea(MaximizeArea, TQCursor::pos(), workspace()->currentDesktop()); + switch (activeBorderMode()) + { + case ActiveMaximizeMode: + { + if (maximizeMode() == MaximizeFull) + ret = geometryRestore(); + else + ret = max; + break; + } + + case ActiveTilingMode: + { + switch (activeBorder()) { - clearbound(); // it's necessary to move the geometry tip when there's no outline - positionGeometryTip(); // shown, otherwise it would cause repaint problems in case - drawbound( moveResizeGeom ); // they overlap; the paint event will come after this, - } // so the geometry tip will be painted above the outline + case ActiveLeft: + { + ret = TQRect( max.x(), max.y(), max.width()/2, max.height() ); + break; + } + case ActiveRight: + { + ret = TQRect( max.x() + max.width()/2, max.y(), max.width()/2, max.height() ); + break; + } + case ActiveTop: + { + ret = TQRect( max.x(), max.y(), max.width(), max.height()/2 ); + break; + } + case ActiveBottom: + { + ret = TQRect( max.x(), max.y() + max.height()/2, max.width(), max.height()/2 ); + break; + } + case ActiveTopLeft: + { + ret = TQRect( max.x(), max.y(), max.width()/2, max.height()/2 ); + break; + } + case ActiveTopRight: + { + ret = TQRect( max.x() + max.width()/2, max.y(), max.width()/2, max.height()/2 ); + break; + } + case ActiveBottomLeft: + { + ret = TQRect( max.x(), max.y() + max.height()/2, max.width()/2, max.height()/2 ); + break; + } + case ActiveBottomRight: + { + ret = TQRect( max.x() + max.width()/2, max.y() + max.height()/2, max.width()/2, max.height()/2); + break; + } + } } - if ( isMove() ) - workspace()->clientMoved(globalPos, GET_QT_X_TIME()); } + return ret; +} +void Client::tileToBorder(ActiveBorder border) { + if (!isResizable()) return; + activeTiled = true; + setActiveBorderMode(ActiveTilingMode); + setActiveBorder(border); + TQRect geo = activeBorderMaximizeGeometry(); + if (geo.isValid() && !geo.isEmpty()) { + setGeometry(geo); + } + workspace()->raiseClient(this); +} } // namespace |