示例#1
0
文件: space.cpp 项目: Karunamon/kwm
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();
    }
}
示例#2
0
文件: space.cpp 项目: Karunamon/kwm
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);
    }
}
示例#3
0
文件: kwm.cpp 项目: shijingyu/kwm
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);
    }
}
示例#4
0
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;
}