Ticket #8188: EnhancedRaise.diff

File EnhancedRaise.diff, 2.3 KB (added by devine, 12 years ago)

Makes Workspaces auto-raise work nicer.

  • src/apps/workspaces/Workspaces.cpp

    diff --git a/src/apps/workspaces/Workspaces.cpp b/src/apps/workspaces/Workspaces.cpp
    index 043fd18..415bd84 100644
    a b WorkspacesView::MouseMoved(BPoint where, uint32 transit,  
    531531        return;
    532532
    533533    // Auto-Raise
     534   
     535    // Note: The Window Tab (decoration) will get in the way if placed
     536    // on the top edge. Rewrite when SAT Decorator API is documented.
    534537
    535538    where = ConvertToScreen(where);
    536539    BScreen screen(window);
    537     BRect frame = screen.Frame();
    538     if (where.x == frame.left || where.x == frame.right
    539         || where.y == frame.top || where.y == frame.bottom) {
    540         // cursor is on screen edge
    541         if (window->Frame().Contains(where))
    542             window->Activate();
     540    BRect screenFrame = screen.Frame();
     541   
     542    if (where.x == screenFrame.left || where.x == screenFrame.right
     543        || where.y == screenFrame.top || where.y == screenFrame.bottom){
     544           
     545        BRect windowFrame = window->Frame();  // The actual Workspaces app frame
     546        BPoint center(screenFrame.right / 2.0, screenFrame.bottom / 2.0);
     547        BRect topLeftQuad = BRect(BPoint(0,0), center);
     548        BRect topRightQuad = BRect(BPoint(center.x,0),
     549                             BPoint(screenFrame.right, center.y));
     550        BRect bottomLeftQuad = BRect(BPoint(0,center.y),
     551                               BPoint(center.x,screenFrame.bottom));
     552       
     553        float fOffset = kScreenBorderOffset / 2.0; // kScreenBorderOffset is twice what we need.
     554       
     555        // If pointer is in top-left quad...
     556        if (topLeftQuad.Contains(where)){
     557            if (BRect(
     558                    windowFrame.left - fOffset,
     559                    windowFrame.top - fOffset,
     560                    windowFrame.right,
     561                    windowFrame.bottom
     562                ).Contains(where))
     563                window->Activate();
     564        }
     565        else if (topRightQuad.Contains(where)){
     566            if (BRect(
     567                    windowFrame.left,         
     568                    windowFrame.top - fOffset,
     569                    windowFrame.right + fOffset,
     570                    windowFrame.bottom
     571                ).Contains(where))
     572                window->Activate();
     573        }
     574        else if (bottomLeftQuad.Contains(where)){
     575                if (BRect(
     576                    windowFrame.left - fOffset,
     577                    windowFrame.top,
     578                    windowFrame.right,
     579                    windowFrame.bottom + fOffset
     580                ).Contains(where))
     581                window->Activate();
     582        }
     583        else {
     584                if (BRect(
     585                    windowFrame.left,
     586                    windowFrame.top,
     587                    windowFrame.right + fOffset,
     588                    windowFrame.bottom + fOffset
     589                ).Contains(where))
     590                window->Activate();
     591        }
    543592    }
    544593}
    545594