void FloatFocusedSpace() { if(KWMScreen.Current && IsSpaceInitializedForScreen(KWMScreen.Current) && KWMToggles.EnableTilingMode && !IsSpaceTransitionInProgress() && !IsSpaceSystemOrFullscreen() && FilterWindowList(KWMScreen.Current)) { space_info *Space = &KWMScreen.Current->Space[KWMScreen.Current->ActiveSpace]; DestroyNodeTree(Space->RootNode, Space->Mode); Space->RootNode = NULL; Space->Mode = SpaceModeFloating; ClearFocusedWindow(); } }
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); } }
void * KwmWindowMonitor(void*) { while(1) { if(KWMTiling.MonitorWindows) { pthread_mutex_lock(&KWMThread.Lock); CheckPrefixTimeout(); if(!IsSpaceTransitionInProgress() && IsActiveSpaceManaged()) { if(KWMScreen.Transitioning) KWMScreen.Transitioning = false; else UpdateWindowTree(); } pthread_mutex_unlock(&KWMThread.Lock); } usleep(200000); } }
CGEventRef CGEventCallback(CGEventTapProxy Proxy, CGEventType Type, CGEventRef Event, void *Refcon) { switch(Type) { case kCGEventTapDisabledByTimeout: case kCGEventTapDisabledByUserInput: { if(!KWMMach.DisableEventTapInternal) { DEBUG("Restarting Event Tap"); CGEventTapEnable(KWMMach.EventTap, true); } } break; case kCGEventKeyDown: { if(KWMToggles.UseBuiltinHotkeys) { hotkey Eventkey = {}, Hotkey = {}; CreateHotkeyFromCGEvent(Event, &Eventkey); if(HotkeyExists(Eventkey.Mod, Eventkey.Key, &Hotkey, KWMHotkeys.ActiveMode->Name)) { KWMHotkeys.Queue.push(Hotkey); if(!Hotkey.Passthrough) return NULL; } } if(KWMMode.Focus == FocusModeAutofocus && !IsActiveSpaceFloating()) { CGEventSetIntegerValueField(Event, kCGKeyboardEventAutorepeat, 0); CGEventPostToPSN(&KWMFocus.PSN, Event); return NULL; } } break; case kCGEventKeyUp: { if(KWMMode.Focus == FocusModeAutofocus && !IsActiveSpaceFloating()) { CGEventSetIntegerValueField(Event, kCGKeyboardEventAutorepeat, 0); CGEventPostToPSN(&KWMFocus.PSN, Event); return NULL; } } break; case kCGEventMouseMoved: { pthread_mutex_lock(&KWMThread.Lock); if(!IsSpaceTransitionInProgress()) { UpdateActiveScreen(); if(KWMMode.Focus != FocusModeDisabled && KWMMode.Focus != FocusModeStandby && !IsActiveSpaceFloating()) FocusWindowBelowCursor(); } pthread_mutex_unlock(&KWMThread.Lock); } break; default: {} break; } return Event; }