internal void KwmModeCommand(std::vector<std::string> &Tokens) { if(Tokens[1] == "activate") KwmActivateBindingMode(Tokens[2]); else { std::string Mode = Tokens[1]; mode *BindingMode = GetBindingMode(Mode); if(Tokens[2] == "color") { BindingMode->Color = ConvertHexRGBAToColor(ConvertHexStringToInt(Tokens[3])); CreateColorFormat(&BindingMode->Color); } else if(Tokens[2] == "prefix") { if(Tokens[3] == "on") BindingMode->Prefix = true; else if(Tokens[3] == "off") BindingMode->Prefix = false; } else if(Tokens[2] == "timeout") { BindingMode->Timeout = ConvertStringToDouble(Tokens[3]); } else if(Tokens[2] == "restore") { BindingMode->Restore = Tokens[3]; } } }
internal bool KwmParseHotkey(std::string KeySym, std::string Command, hotkey *Hotkey, bool Passthrough, bool KeycodeInHex) { std::vector<std::string> KeyTokens = SplitString(KeySym, '-'); if(KeyTokens.size() != 2) return false; Hotkey->Mode = "default"; std::vector<std::string> Modifiers = SplitString(KeyTokens[0], '+'); for(std::size_t ModIndex = 0; ModIndex < Modifiers.size(); ++ModIndex) { if(Modifiers[ModIndex] == "cmd") Hotkey->Mod.CmdKey = true; else if(Modifiers[ModIndex] == "alt") Hotkey->Mod.AltKey = true; else if(Modifiers[ModIndex] == "ctrl") Hotkey->Mod.CtrlKey = true; else if(Modifiers[ModIndex] == "shift") Hotkey->Mod.ShiftKey = true; else Hotkey->Mode = Modifiers[ModIndex]; } DetermineHotkeyState(Hotkey, Command); Hotkey->Passthrough = Passthrough; Hotkey->Command = Command; CGKeyCode Keycode; bool Result = false; if(KeycodeInHex) { Result = true; Keycode = ConvertHexStringToInt(KeyTokens[1]); DEBUG("bindcode: " << Keycode); } else { Result = GetLayoutIndependentKeycode(KeyTokens[1], &Keycode); if(!Result) Result = KeycodeForChar(KeyTokens[1][0], &Keycode); } Hotkey->Key = Keycode; return Result; }
internal void KwmConfigCommand(std::vector<std::string> &Tokens) { if(Tokens[1] == "reload") { KwmReloadConfig(); } else if(Tokens[1] == "optimal-ratio") { KWMSettings.OptimalRatio = ConvertStringToDouble(Tokens[2]); } else if(Tokens[1] == "border") { if(Tokens[2] == "focused") { if(Tokens[3] == "on") { FocusedBorder.Enabled = true; UpdateBorder("focused"); } else if(Tokens[3] == "off") { FocusedBorder.Enabled = false; UpdateBorder("focused"); } else if(Tokens[3] == "size") { FocusedBorder.Width = ConvertStringToInt(Tokens[4]); } else if(Tokens[3] == "color") { FocusedBorder.Color = ConvertHexRGBAToColor(ConvertHexStringToInt(Tokens[4])); CreateColorFormat(&FocusedBorder.Color); mode *BindingMode = GetBindingMode("default"); BindingMode->Color = FocusedBorder.Color; } else if(Tokens[3] == "radius") { FocusedBorder.Radius = ConvertStringToDouble(Tokens[4]); } } else if(Tokens[2] == "marked") { if(Tokens[3] == "on") { MarkedBorder.Enabled = true; } else if(Tokens[3] == "off") { MarkedBorder.Enabled = false; UpdateBorder("marked"); } else if(Tokens[3] == "size") { MarkedBorder.Width = ConvertStringToInt(Tokens[4]); } else if(Tokens[3] == "color") { MarkedBorder.Color = ConvertHexRGBAToColor(ConvertHexStringToInt(Tokens[4])); CreateColorFormat(&MarkedBorder.Color); } else if(Tokens[3] == "radius") { MarkedBorder.Radius = ConvertStringToDouble(Tokens[4]); } } } else if(Tokens[1] == "float-non-resizable") { if(Tokens[2] == "off") KWMSettings.FloatNonResizable = false; else if(Tokens[2] == "on") KWMSettings.FloatNonResizable = true; } else if(Tokens[1] == "lock-to-container") { if(Tokens[2] == "off") KWMSettings.LockToContainer = false; else if(Tokens[2] == "on") KWMSettings.LockToContainer = true; } else if(Tokens[1] == "spawn") { if(Tokens[2] == "left") KWMSettings.SpawnAsLeftChild = true; else if(Tokens[2] == "right") KWMSettings.SpawnAsLeftChild = false; } else if(Tokens[1] == "tiling") { if(Tokens[2] == "bsp") KWMSettings.Space = SpaceModeBSP; else if(Tokens[2] == "monocle") KWMSettings.Space = SpaceModeMonocle; else if(Tokens[2] == "float") KWMSettings.Space = SpaceModeFloating; } else if(Tokens[1] == "space") { int ScreenID = ConvertStringToInt(Tokens[2]); int DesktopID = ConvertStringToInt(Tokens[3]); space_settings *SpaceSettings = GetSpaceSettingsForDesktopID(ScreenID, DesktopID); if(!SpaceSettings) { space_identifier Lookup = { ScreenID, DesktopID }; space_settings NULLSpaceSettings = { KWMSettings.DefaultOffset, SpaceModeDefault, "", ""}; space_settings *ScreenSettings = GetSpaceSettingsForDisplay(ScreenID); if(ScreenSettings) NULLSpaceSettings = *ScreenSettings; KWMSettings.SpaceSettings[Lookup] = NULLSpaceSettings; SpaceSettings = &KWMSettings.SpaceSettings[Lookup]; } if(Tokens[4] == "mode") { if(Tokens[5] == "bsp") SpaceSettings->Mode = SpaceModeBSP; else if(Tokens[5] == "monocle") SpaceSettings->Mode = SpaceModeMonocle; else if(Tokens[5] == "float") SpaceSettings->Mode = SpaceModeFloating; } else if(Tokens[4] == "padding") { SpaceSettings->Offset.PaddingTop = ConvertStringToDouble(Tokens[5]); SpaceSettings->Offset.PaddingBottom = ConvertStringToDouble(Tokens[6]); SpaceSettings->Offset.PaddingLeft = ConvertStringToDouble(Tokens[7]); SpaceSettings->Offset.PaddingRight = ConvertStringToDouble(Tokens[8]); } else if(Tokens[4] == "gap") { SpaceSettings->Offset.VerticalGap = ConvertStringToDouble(Tokens[5]); SpaceSettings->Offset.HorizontalGap = ConvertStringToDouble(Tokens[6]); } else if(Tokens[4] == "name") { SpaceSettings->Name = Tokens[5]; } else if(Tokens[4] == "tree") { SpaceSettings->Layout = Tokens[5]; } } else if(Tokens[1] == "display") { int ScreenID = ConvertStringToInt(Tokens[2]); space_settings *DisplaySettings = GetSpaceSettingsForDisplay(ScreenID); if(!DisplaySettings) { space_settings NULLSpaceSettings = { KWMSettings.DefaultOffset, SpaceModeDefault, "", "" }; KWMSettings.DisplaySettings[ScreenID] = NULLSpaceSettings; DisplaySettings = &KWMSettings.DisplaySettings[ScreenID]; } if(Tokens[3] == "mode") { if(Tokens[4] == "bsp") DisplaySettings->Mode = SpaceModeBSP; else if(Tokens[4] == "monocle") DisplaySettings->Mode = SpaceModeMonocle; else if(Tokens[4] == "float") DisplaySettings->Mode = SpaceModeFloating; } else if(Tokens[3] == "padding") { DisplaySettings->Offset.PaddingTop = ConvertStringToDouble(Tokens[4]); DisplaySettings->Offset.PaddingBottom = ConvertStringToDouble(Tokens[5]); DisplaySettings->Offset.PaddingLeft = ConvertStringToDouble(Tokens[6]); DisplaySettings->Offset.PaddingRight = ConvertStringToDouble(Tokens[7]); } else if(Tokens[3] == "gap") { DisplaySettings->Offset.VerticalGap = ConvertStringToDouble(Tokens[4]); DisplaySettings->Offset.HorizontalGap = ConvertStringToDouble(Tokens[5]); } } else if(Tokens[1] == "focus-follows-mouse") { if(Tokens[2] == "toggle") { if(KWMSettings.Focus == FocusModeDisabled) KWMSettings.Focus = FocusModeAutoraise; else if(KWMSettings.Focus == FocusModeAutoraise) KWMSettings.Focus = FocusModeDisabled; } else if(Tokens[2] == "on") KWMSettings.Focus = FocusModeAutoraise; else if(Tokens[2] == "off") KWMSettings.Focus = FocusModeDisabled; } else if(Tokens[1] == "mouse-follows-focus") { if(Tokens[2] == "off") KWMSettings.UseMouseFollowsFocus = false; else if(Tokens[2] == "on") KWMSettings.UseMouseFollowsFocus = true; } else if(Tokens[1] == "standby-on-float") { if(Tokens[2] == "off") KWMSettings.StandbyOnFloat = false; else if(Tokens[2] == "on") KWMSettings.StandbyOnFloat = true; } else if(Tokens[1] == "cycle-focus") { if(Tokens[2] == "on") KWMSettings.Cycle = CycleModeScreen; else if(Tokens[2] == "off") KWMSettings.Cycle = CycleModeDisabled;; } else if(Tokens[1] == "hotkeys") { if(Tokens[2] == "off") KWMSettings.UseBuiltinHotkeys = false; else if(Tokens[2] == "on") KWMSettings.UseBuiltinHotkeys = true; } else if(Tokens[1] == "padding") { container_offset Offset = { ConvertStringToDouble(Tokens[2]), ConvertStringToDouble(Tokens[3]), ConvertStringToDouble(Tokens[4]), ConvertStringToDouble(Tokens[5]), 0, 0 }; SetDefaultPaddingOfDisplay(Offset); } else if(Tokens[1] == "gap") { container_offset Offset = { 0, 0, 0, 0, ConvertStringToDouble(Tokens[2]), ConvertStringToDouble(Tokens[3]) }; SetDefaultGapOfDisplay(Offset); } else if(Tokens[1] == "split-ratio") { ChangeSplitRatio(ConvertStringToDouble(Tokens[2])); } }