Ejemplo n.º 1
0
internal void
KwmDisplayCommand(std::vector<std::string> &Tokens)
{
    if(Tokens[1] == "-f")
    {
        if(Tokens[2] == "prev")
        {
            ax_display *Display = AXLibMainDisplay();
            if(Display)
                FocusDisplay(AXLibPreviousDisplay(Display));
        }
        else if(Tokens[2] == "next")
        {
            ax_display *Display = AXLibMainDisplay();
            if(Display)
                FocusDisplay(AXLibNextDisplay(Display));
        }
        else
        {
            int DisplayID = ConvertStringToInt(Tokens[2]);
            ax_display *Display = AXLibArrangementDisplay(DisplayID);
            if(Display)
                FocusDisplay(Display);
        }
    }
    else if(Tokens[1] == "-c")
    {
        if(Tokens[2] == "optimal")
            KWMSettings.SplitMode = SPLIT_OPTIMAL;
        else if(Tokens[2] == "vertical")
            KWMSettings.SplitMode = SPLIT_VERTICAL;
        else if(Tokens[2] == "horizontal")
            KWMSettings.SplitMode = SPLIT_HORIZONTAL;
    }
}
Ejemplo n.º 2
0
/* TODO(koekeishiya): This entire system is just stupid. Reimplement in a proper way. */
bool ApplyWindowRules(ax_window *Window)
{
    bool Skip = false;
    for(int Index = 0; Index < KWMSettings.WindowRules.size(); ++Index)
    {
        window_rule *Rule = &KWMSettings.WindowRules[Index];
        if(MatchWindowRule(Rule, Window))
        {
            if(Rule->Properties.Float == 1)
                AXLibAddFlags(Window, AXWindow_Floating);

            if(!Rule->Properties.Role.empty())
                Window->Type.CustomRole = CFStringCreateWithCString(NULL,
                                                                    Rule->Properties.Role.c_str(),
                                                                    kCFStringEncodingMacRoman);

            if(Rule->Properties.Scratchpad != -1)
            {
                AddWindowToScratchpad(Window);
                if(Rule->Properties.Scratchpad == 0)
                {
                    HideScratchpadWindow(GetScratchpadSlotOfWindow(Window));
                    Skip = true;
                }
            }

            if(Rule->Properties.Display != -1 && Rule->Properties.Space == -1)
            {
                if(!AXLibIsWindowStandard(Window) &&
                   !AXLibIsWindowCustom(Window))
                    continue;

                ax_display *Display = AXLibArrangementDisplay(Rule->Properties.Display);
                if(Display && Display != AXLibWindowDisplay(Window))
                {
                    MoveWindowToDisplay(Window, Display->ArrangementID, false);
                    Skip = true;
                }
            }

            if(Rule->Properties.Space != -1)
            {
                if(!AXLibIsWindowStandard(Window) &&
                   !AXLibIsWindowCustom(Window))
                    continue;

                int Display = Rule->Properties.Display == -1 ? 0 : Rule->Properties.Display;
                ax_display *SourceDisplay = AXLibWindowDisplay(Window);
                ax_display *DestinationDisplay = AXLibArrangementDisplay(Display);
                int TotalSpaces = AXLibDisplaySpacesCount(DestinationDisplay);
                if(Rule->Properties.Space <= TotalSpaces && Rule->Properties.Space >= 1)
                {
                    int SourceCGSSpaceID = SourceDisplay->Space->ID;
                    int DestinationCGSSpaceID = AXLibCGSSpaceIDFromDesktopID(DestinationDisplay, Rule->Properties.Space);
                    if(!AXLibSpaceHasWindow(Window, DestinationCGSSpaceID))
                    {
                        AXLibSpaceAddWindow(DestinationCGSSpaceID, Window->ID);
                        AXLibSpaceRemoveWindow(SourceCGSSpaceID, Window->ID);
                        Skip = true;
                    }
                }
            }
        }
    }

    return Skip;
}