~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to plugins/wall/src/wall.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-22 06:58:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3352.
  • Revision ID: package-import@ubuntu.com-20130822065807-17nlzez0d30y09so
Tags: upstream-0.9.10+13.10.20130822
ImportĀ upstreamĀ versionĀ 0.9.10+13.10.20130822

Show diffs side-by-side

added added

removed removed

Lines of Context:
352
352
void
353
353
WallScreen::releaseMoveWindow ()
354
354
{
355
 
    CompWindow *window;
356
 
 
357
 
    window = screen->findWindow (moveWindow);
358
 
    if (window)
359
 
        window->syncPosition ();
360
 
 
361
355
    moveWindow = 0;
362
356
}
363
357
 
501
495
 
502
496
            moveViewport (-dx, -dy, None);
503
497
        }
504
 
        if (event->xclient.message_type == Atoms::xdndEnter)
505
 
        {
506
 
            toggleEdges (true);
507
 
            edgeDrag = true;
508
 
        }
509
 
        else if (event->xclient.message_type == Atoms::xdndLeave)
510
 
            edgeDrag = false;
511
498
 
512
499
        break;
513
500
 
514
501
        case FocusIn:
515
502
        case FocusOut:
516
 
            if (event->xfocus.mode == NotifyGrab)
517
 
                poller.start ();
518
 
            else if (event->xfocus.mode == NotifyUngrab)
519
 
                poller.stop ();
520
 
        break;
 
503
            /* Edges on when grabbed */
 
504
            if (!optionGetEdgeflipPointer ())
 
505
            {
 
506
                if (event->xfocus.mode == NotifyGrab)
 
507
                    toggleEdges (true);
 
508
                else if (event->xfocus.mode == NotifyUngrab)
 
509
                    toggleEdges (false);
 
510
            }
521
511
 
522
512
        case ConfigureNotify:
523
 
 
524
 
             if (event->xconfigure.window == screen->root ())
525
 
                updateScreenEdgeRegions ();
526
 
 
 
513
        break;
 
514
 
 
515
        default:
527
516
        break;
528
517
    }
529
518
 
531
520
}
532
521
 
533
522
/*
534
 
 * Borrowed this from PrivateScreen::updateScreenEdges
535
 
 *
 
523
 * When a dnd type window is mapped toggle edge flip dnd windows back on
 
524
 * _NET_WM_WINDOW_TYPE_DND windows. This will not detect all dnd windows
 
525
 * but it will detect the EWMH-compliant ones without resorting to
 
526
 * hacks involving selection stealing.
536
527
 */
537
 
 
538
 
#define SCREEN_EDGE_NUM         8
539
 
 
540
 
void
541
 
WallScreen::updateScreenEdgeRegions ()
542
 
{
543
 
    edgeRegion = CompRegion (0, 0, screen->width (), screen->height ());
544
 
    noEdgeRegion = CompRegion (0, 0, screen->width (), screen->height ());
545
 
 
546
 
    struct screenEdgeGeometry {
547
 
        int xw, x0;
548
 
        int yh, y0;
549
 
        int ww, w0;
550
 
        int hh, h0;
551
 
    } geometry[SCREEN_EDGE_NUM] = {
552
 
        { 0,  0,   0,  2,   0,  2,   1, -4 }, /* left */
553
 
        { 1, -2,   0,  2,   0,  2,   1, -4 }, /* right */
554
 
        { 0,  2,   0,  0,   1, -4,   0,  2 }, /* top */
555
 
        { 0,  2,   1, -2,   1, -4,   0,  2 }, /* bottom */
556
 
        { 0,  0,   0,  0,   0,  2,   0,  2 }, /* top-left */
557
 
        { 1, -2,   0,  0,   0,  2,   0,  2 }, /* top-right */
558
 
        { 0,  0,   1, -2,   0,  2,   0,  2 }, /* bottom-left */
559
 
        { 1, -2,   1, -2,   0,  2,   0,  2 }  /* bottom-right */
560
 
    };
561
 
 
562
 
    for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)
563
 
    {
564
 
        CompRegion edge (geometry[i].xw * screen->width () +
565
 
                         geometry[i].x0,
566
 
                         geometry[i].yh * screen->height () +
567
 
                         geometry[i].y0,
568
 
                         geometry[i].ww * screen->width () +
569
 
                         geometry[i].w0,
570
 
                         geometry[i].hh * screen->height () +
571
 
                         geometry[i].h0);
572
 
 
573
 
        noEdgeRegion -= edgeRegion;
574
 
    }
575
 
 
576
 
    edgeRegion -= noEdgeRegion;
577
 
}
578
 
 
579
 
#undef SCREEN_EDGE_NUM
580
 
 
581
 
void
582
 
WallScreen::positionUpdate (const CompPoint &pos)
583
 
{
584
 
    if (edgeDrag)
585
 
        return;
586
 
 
587
 
    if (edgeRegion.contains (pos))
588
 
        toggleEdges (false);
589
 
    else if (noEdgeRegion.contains (pos))
590
 
    {
591
 
        if (!screen->grabbed ())
592
 
            poller.stop ();
593
 
        toggleEdges (true);
594
 
    }
 
528
void
 
529
WallWindow::windowNotify (CompWindowNotify n)
 
530
{
 
531
    WallScreen *ws = WallScreen::get (screen);
 
532
    bool toggleOnDnd = ws->optionGetEdgeflipDnd ();
 
533
 
 
534
    switch (n)
 
535
    {
 
536
        case CompWindowNotifyMap:
 
537
            if (window->type () & CompWindowTypeDndMask && toggleOnDnd)
 
538
                ws->toggleEdges (true);
 
539
            break;
 
540
        case CompWindowNotifyUnmap:
 
541
            if (window->type () & CompWindowTypeDndMask && toggleOnDnd)
 
542
                ws->toggleEdges (false);
 
543
            break;
 
544
        default:
 
545
            break;
 
546
    }
 
547
 
 
548
    window->windowNotify (n);
595
549
}
596
550
 
597
551
void
654
608
void
655
609
WallWindow::grabNotify (int          x,
656
610
                        int          y,
657
 
                        unsigned int width,
658
 
                        unsigned int height)
 
611
                        unsigned int state,
 
612
                        unsigned int mask)
659
613
{
660
 
    WallScreen::get (screen)->toggleEdges (true);
661
 
    WallScreen::get (screen)->edgeDrag = true;
 
614
    if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
 
615
        WallScreen::get (screen)->windowIsDragMoved = true;
662
616
 
663
 
    window->grabNotify (x, y, width, height);
 
617
    window->grabNotify (x, y, state, mask);
664
618
}
665
619
 
666
620
void
667
621
WallWindow::ungrabNotify ()
668
622
{
669
 
    WallScreen::get (screen)->edgeDrag = false;
 
623
    WallScreen::get (screen)->windowIsDragMoved = false;
670
624
 
671
625
    window->ungrabNotify ();
672
626
}
810
764
WallScreen::initiateFlip (Direction         direction,
811
765
                          CompAction::State state)
812
766
{
 
767
    CompOption::Vector o (0);
 
768
 
813
769
    int dx, dy;
814
770
    int amountX, amountY;
815
771
 
816
 
    if (screen->otherGrabExist ("wall", "move", "group-drag", 0))
817
 
        return false;
818
 
 
819
 
    if (state & CompAction::StateInitEdgeDnd)
820
 
    {
821
 
        if (!optionGetEdgeflipDnd ())
822
 
            return false;
823
 
 
824
 
        if (screen->otherGrabExist ("wall", 0))
825
 
            return false;
826
 
    }
827
 
    else if (screen->grabExist ("move"))
828
 
    {
829
 
        if (!optionGetEdgeflipMove ())
830
 
            return false;
831
 
    }
832
 
    else if (screen->grabExist ("group-drag"))
833
 
    {
834
 
        if (!optionGetEdgeflipDnd ())
835
 
            return false;
836
 
    }
837
 
    else if (!optionGetEdgeflipPointer ())
838
 
    {
839
 
        toggleEdges (false);
840
 
        poller.start ();
841
 
        return false;
842
 
    }
843
 
 
844
 
    switch (direction) {
 
772
    const bool allowFlipDnd = (state & CompAction::StateInitEdgeDnd) &&
 
773
                              optionGetEdgeflipDnd ();
 
774
    const bool allowFlipMove = (windowIsDragMoved &&
 
775
                                optionGetEdgeflipMove ());
 
776
    const bool allowFlipPointer = optionGetEdgeflipPointer ();
 
777
 
 
778
    if (!allowFlipDnd &&
 
779
        !allowFlipMove &&
 
780
        !allowFlipPointer)
 
781
        return false;
 
782
 
 
783
    switch (direction)
 
784
    {
845
785
    case Left:
846
 
        dx = -1; dy = 0;
 
786
        dx = -1;
 
787
        dy = 0;
847
788
        break;
 
789
 
848
790
    case Right:
849
 
        dx = 1; dy = 0;
 
791
        dx = 1;
 
792
        dy = 0;
850
793
        break;
 
794
 
851
795
    case Up:
852
 
        dx = 0; dy = -1;
 
796
        dx = 0;
 
797
        dy = -1;
853
798
        break;
 
799
 
854
800
    case Down:
855
 
        dx = 0; dy = 1;
 
801
        dx = 0;
 
802
        dy = 1;
856
803
        break;
 
804
 
857
805
    default:
858
 
        dx = 0; dy = 0;
 
806
        dx = 0;
 
807
        dy = 0;
859
808
        break;
860
809
    }
861
810
 
1619
1568
            ww->isSliding = !optionGetNoSlideMatch ().evaluate (w);
1620
1569
        }
1621
1570
        break;
 
1571
    case WallOptions::EdgeflipPointer:
 
1572
        toggleEdges (optionGetEdgeflipPointer ());
 
1573
        break;
1622
1574
 
1623
1575
    default:
1624
1576
        break;
1679
1631
    moveWindow (None),
1680
1632
    focusDefault (true),
1681
1633
    transform (NoTransformation),
1682
 
    edgeDrag (false)
 
1634
    windowIsDragMoved (false)
1683
1635
{
1684
1636
    ScreenInterface::setHandler (screen);
1685
1637
    CompositeScreenInterface::setHandler (cScreen);
1746
1698
    setNotify (ArrowShadowColor);
1747
1699
    setNotify (NoSlideMatch);
1748
1700
    setNotify (EdgeflipPointer);
1749
 
 
1750
 
    updateScreenEdgeRegions ();
1751
 
 
1752
 
    poller.setCallback (boost::bind (&WallScreen::positionUpdate, this,
1753
 
                                     _1));
1754
1701
}
1755
1702
 
1756
1703
WallScreen::~WallScreen ()
1777
1724
bool
1778
1725
WallPluginVTable::init ()
1779
1726
{
1780
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
1781
 
        return false;
1782
 
    if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
1783
 
        return false;
1784
 
    if (!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
1785
 
        return false;
1786
 
    if (!CompPlugin::checkPluginABI ("mousepoll", COMPIZ_MOUSEPOLL_ABI))
1787
 
        return false;
 
1727
    if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION)            &&
 
1728
        CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI)  &&
 
1729
        CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
 
1730
        return true;
1788
1731
 
1789
 
    return true;
 
1732
    return false;
1790
1733
}
1791