int main(int argc, char **argv) { if(ParseArguments(argc, argv)) return 0; NSApplicationLoad(); if(!AXLibDisplayHasSeparateSpaces()) Fatal("Error: 'Displays have separate spaces' must be enabled!"); AXLibInit(&AXState); AXLibStartEventLoop(); if(!KwmStartDaemon()) Fatal("Error: Could not start daemon!"); OverlayLibInitialize(); DEBUG("OverlayLib initialized!"); ax_display *MainDisplay = AXLibMainDisplay(); ax_display *Display = MainDisplay; do { ax_space *PrevSpace = Display->Space; Display->Space = AXLibGetActiveSpace(Display); Display->PrevSpace = PrevSpace; Display = AXLibNextDisplay(Display); } while(Display != MainDisplay); FocusedDisplay = MainDisplay; FocusedApplication = AXLibGetFocusedApplication(); KwmInit(); KwmParseConfig(KWMPath.Config); KwmExecuteInitScript(); CreateWindowNodeTree(MainDisplay); /* TODO(koekeishiya): Probably want to defer this to run at some point where we know that * the focused application is set. This is usually the case as 'Finder' is always reported * as the active application when nothing is running. The following behaviour requries * refinement, because we will (sometimes ?) get NULL when started by launchd at login */ if(FocusedApplication && FocusedApplication->Focus) UpdateBorder(&FocusedBorder, FocusedApplication->Focus); ConfigureRunLoop(); CFRunLoopRun(); return 0; }
void TileFocusedSpace(space_tiling_option Mode) { if(KWMScreen.Current && IsSpaceInitializedForScreen(KWMScreen.Current) && KWMToggles.EnableTilingMode && !IsSpaceTransitionInProgress() && !IsSpaceSystemOrFullscreen() && FilterWindowList(KWMScreen.Current)) { space_info *Space = &KWMScreen.Current->Space[KWMScreen.Current->ActiveSpace]; if(Space->Mode == Mode) return; DestroyNodeTree(Space->RootNode, Space->Mode); Space->RootNode = NULL; Space->Mode = Mode; std::vector<window_info*> WindowsOnDisplay = GetAllWindowsOnDisplay(KWMScreen.Current->ID); CreateWindowNodeTree(KWMScreen.Current, &WindowsOnDisplay); } }