コード例 #1
0
ファイル: tree.cpp プロジェクト: peacelake/kwm
void SwapNodeWindowIDs(tree_node *A, tree_node *B)
{
    if(A && B)
    {
        DEBUG("SwapNodeWindowIDs() " << A->WindowID << " with " << B->WindowID)
        int TempWindowID = A->WindowID;
        A->WindowID = B->WindowID;
        B->WindowID = TempWindowID;
        ResizeWindowToContainerSize(A);
        ResizeWindowToContainerSize(B);
    }
コード例 #2
0
ファイル: node.cpp プロジェクト: koekeishiya/kwm
void ResizeWindowToContainerSize()
{
    ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
    if(!Window)
        return;

    ResizeWindowToContainerSize(Window);
}
コード例 #3
0
ファイル: tree.cpp プロジェクト: JakimLi/kwm
void ApplyLinkNodeContainer(link_node *Link)
{
    if(Link)
    {
        ResizeWindowToContainerSize(Link);
        if(Link->Next)
            ApplyLinkNodeContainer(Link->Next);
    }
}
コード例 #4
0
ファイル: node.cpp プロジェクト: koekeishiya/kwm
void ResizeWindowToContainerSize(ax_window *Window)
{
    if(Window)
    {
        ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
        if(!Window)
            return;

        ax_display *Display = AXLibWindowDisplay(Window);
        space_info *SpaceInfo = &WindowTree[Display->Space->Identifier];

        tree_node *Node = GetTreeNodeFromWindowID(SpaceInfo->RootNode, Window->ID);
        if(Node)
            ResizeWindowToContainerSize(Node);

        if(!Node)
        {
            link_node *Link = GetLinkNodeFromWindowID(SpaceInfo->RootNode, Window->ID);
            if(Link)
                ResizeWindowToContainerSize(Link);
        }
    }
}
コード例 #5
0
ファイル: tree.cpp プロジェクト: JakimLi/kwm
void ApplyTreeNodeContainer(tree_node *Node)
{
    if(Node)
    {
        if(Node->WindowID != -1)
            ResizeWindowToContainerSize(Node);

        if(Node->List)
            ApplyLinkNodeContainer(Node->List);

        if(Node->LeftChild)
            ApplyTreeNodeContainer(Node->LeftChild);

        if(Node->RightChild)
            ApplyTreeNodeContainer(Node->RightChild);
    }
}
コード例 #6
0
ファイル: interpreter.cpp プロジェクト: rmcintosh/kwm
internal void
KwmWindowCommand(std::vector<std::string> &Tokens)
{
    if(Tokens[1] == "-f")
    {
        if(Tokens[2] == "north")
            ShiftWindowFocusDirected(0);
        else if(Tokens[2] == "east")
            ShiftWindowFocusDirected(90);
        else if(Tokens[2] == "south")
            ShiftWindowFocusDirected(180);
        else if(Tokens[2] == "west")
            ShiftWindowFocusDirected(270);
        else if(Tokens[2] == "prev")
            ShiftWindowFocus(-1);
        else if(Tokens[2] == "next")
            ShiftWindowFocus(1);
        else if(Tokens[2] == "curr")
            FocusWindowBelowCursor();
        else
            FocusWindowByID(ConvertStringToUint(Tokens[2]));
    }
    else if(Tokens[1] == "-fm")
    {
        if(Tokens[2] == "prev")
            ShiftSubTreeWindowFocus(-1);
        else if(Tokens[2] == "next")
            ShiftSubTreeWindowFocus(1);
    }
    else if(Tokens[1] == "-s")
    {
        if(Tokens[2] == "north")
            SwapFocusedWindowDirected(0);
        else if(Tokens[2] == "east")
            SwapFocusedWindowDirected(90);
        else if(Tokens[2] == "south")
            SwapFocusedWindowDirected(180);
        else if(Tokens[2] == "west")
            SwapFocusedWindowDirected(270);
        else if(Tokens[2] == "prev")
            SwapFocusedWindowWithNearest(-1);
        else if(Tokens[2] == "next")
            SwapFocusedWindowWithNearest(1);
        else if(Tokens[2] == "mark")
            SwapFocusedWindowWithMarked();
    }
    else if(Tokens[1] == "-z")
    {
        if(Tokens[2] == "fullscreen")
            ToggleFocusedWindowFullscreen();
        else if(Tokens[2] == "parent")
            ToggleFocusedWindowParentContainer();
    }
    else if(Tokens[1] == "-t")
    {
        if(Tokens[2] == "focused")
            ToggleFocusedWindowFloating();
    }
    else if(Tokens[1] == "-r")
    {
        if(Tokens[2] == "focused")
            ResizeWindowToContainerSize();
    }
    else if(Tokens[1] == "-c")
    {
        if(Tokens[2] == "split-mode")
        {
            if(Tokens[3] == "toggle")
            {
                ToggleFocusedNodeSplitMode();
            }
        }
        else if(Tokens[2] == "type")
        {
            if(Tokens[3] == "monocle")
                ChangeTypeOfFocusedNode(NodeTypeLink);
            else if(Tokens[3] == "bsp")
                ChangeTypeOfFocusedNode(NodeTypeTree);
            else if(Tokens[3] == "toggle")
                ToggleTypeOfFocusedNode();
        }
        else if(Tokens[2] == "reduce" || Tokens[2] == "expand")
        {
            double Ratio = ConvertStringToDouble(Tokens[3]);
            Ratio = Tokens[2] == "reduce" ? -Ratio : Ratio;

            if(Tokens.size() == 5)
            {
                if(Tokens[4] == "north")
                    ModifyContainerSplitRatio(Ratio, 0);
                else if(Tokens[4] == "east")
                    ModifyContainerSplitRatio(Ratio, 90);
                else if(Tokens[4] == "south")
                    ModifyContainerSplitRatio(Ratio, 180);
                else if(Tokens[4] == "west")
                    ModifyContainerSplitRatio(Ratio, 270);
            }
            else
            {
                ModifyContainerSplitRatio(Ratio);
            }
        }
    }
    else if(Tokens[1] == "-m")
    {
        if(Tokens[2] == "space")
        {
            if(Tokens[3] == "previous")
                GoToPreviousSpace(true);
            else
                MoveFocusedWindowToSpace(Tokens[3]);
        }
        else if(Tokens[2] == "display")
        {
            ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
            if(!Window)
                return;

            if(Tokens[3] == "prev")
                MoveWindowToDisplay(Window, -1, true);
            else if(Tokens[3] == "next")
                MoveWindowToDisplay(Window, 1, true);
            else
                MoveWindowToDisplay(Window, ConvertStringToInt(Tokens[3]), false);
        }
        else if(Tokens[2] == "north")
        {
            ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
            if(Window)
                DetachAndReinsertWindow(Window->ID, 0);
        }
        else if(Tokens[2] == "east")
        {
            ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
            if(Window)
                DetachAndReinsertWindow(Window->ID, 90);
        }
        else if(Tokens[2] == "south")
        {
            ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
            if(Window)
                DetachAndReinsertWindow(Window->ID, 180);
        }
        else if(Tokens[2] == "west")
        {
            ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL;
            if(Window)
                DetachAndReinsertWindow(Window->ID, 270);
        }
        else if(Tokens[2] == "mark")
        {
            if(MarkedWindow)
                DetachAndReinsertWindow(MarkedWindow->ID, 0);
        }
        else
        {
            int XOff = ConvertStringToInt(Tokens[2]);
            int YOff = ConvertStringToInt(Tokens[3]);
            MoveFloatingWindow(XOff, YOff);
        }
    }
    else if(Tokens[1] == "-mk")
    {
        if(Tokens[2] == "focused")
        {
            MarkFocusedWindowContainer();
            return;
        }

        ax_window *ClosestWindow = NULL;
        std::string Output = "-1";
        int Degrees = 0;

        if(Tokens[2] == "north")
            Degrees = 0;
        else if(Tokens[2] == "east")
            Degrees = 90;
        else if(Tokens[2] == "south")
            Degrees = 180;
        else if(Tokens[2] == "west")
            Degrees = 270;

        bool Wrap = Tokens[3] == "wrap" ? true : false;
        if((FindClosestWindow(Degrees, &ClosestWindow, Wrap)) &&
           (ClosestWindow))
            MarkWindowContainer(ClosestWindow);
    }
}