Esempio n. 1
0
void DisplayReconfigurationCallBack(CGDirectDisplayID Display, CGDisplayChangeSummaryFlags Flags, void *UserInfo)
{
    pthread_mutex_lock(&KWMThread.Lock);

    if (Flags & kCGDisplayAddFlag)
    {
        // Display has been added
        DEBUG("New display detected! DisplayID: " << Display << " Index: " << KWMScreen.ActiveCount)
        RefreshActiveDisplays();
    }
    else if (Flags & kCGDisplayRemoveFlag)
    {
        // Display has been removed
        if(CGDisplayIsAsleep(Display))
        {
            DEBUG("Display " << Display << " is asleep!")
        }
        else
        {
            DEBUG("Display has been removed! DisplayID: " << Display)
            std::map<int, space_info>::iterator It;
            for(It = KWMTiling.DisplayMap[Display].Space.begin(); It != KWMTiling.DisplayMap[Display].Space.end(); ++It)
                DestroyNodeTree(It->second.RootNode);

            if(KWMTiling.DisplayMap[Display].Identifier)
                CFRelease(KWMTiling.DisplayMap[Display].Identifier);

            KWMTiling.DisplayMap.erase(Display);
        }

        RefreshActiveDisplays();
    }
Esempio n. 2
0
void DisplayReconfigurationCallBack(CGDirectDisplayID Display, CGDisplayChangeSummaryFlags Flags, void *UserInfo)
{
    pthread_mutex_lock(&BackgroundLock);

    if (Flags & kCGDisplayAddFlag)
    {
        // Display has been added
        DEBUG("New display detected! DisplayID: " << Display << " Index: " << ActiveDisplaysCount)
        RefreshActiveDisplays();
    }
    else if (Flags & kCGDisplayRemoveFlag)
    {
        // Display has been removed
        DEBUG("Display has been removed! DisplayID: " << Display)
        std::map<int, space_info>::iterator It;
        for(It = DisplayMap[Display].Space.begin(); It != DisplayMap[Display].Space.end(); ++It)
            DestroyNodeTree(It->second.RootNode, It->second.Mode);

        DisplayMap.erase(Display);
        RefreshActiveDisplays();
    }

    pthread_mutex_unlock(&BackgroundLock);
}
Esempio n. 3
0
void DisplayReconfigurationCallBack(CGDirectDisplayID Display, CGDisplayChangeSummaryFlags Flags, void *UserInfo)
{
    pthread_mutex_lock(&KWMThread.Lock);
    static int idx = 0;
    DEBUG("\n[" << idx << "] BEGIN DISPLAY CONFIGURATION CALLBACK");

    if (Flags & kCGDisplayAddFlag)
    {
        CFStringRef displayIdentifier = GetDisplayIdentifier(Display);
        int savedDisplayID = 0;
        if(displayIdentifier)
            savedDisplayID = GetDisplayIDFromIdentifier(displayIdentifier);
        if (!savedDisplayID) {
            DEBUG("New display detected! DisplayID: " << Display << " Index: " << KWMScreen.ActiveCount);
        }
        else if (savedDisplayID != Display) {
            DEBUG("This display being added had saved ID: " << savedDisplayID);
            UpdateDisplayIDForDisplay(savedDisplayID, Display);
        }
        else {
            DEBUG("The display that is being added is already there!");
        }
        // Display has been added
        RefreshActiveDisplays(true);
    }
    if (Flags & kCGDisplayRemoveFlag)
    {
        CFStringRef displayIdentifier = GetDisplayIdentifier(Display);
        int savedDisplayID = 0;
        if(displayIdentifier)
            savedDisplayID = GetDisplayIDFromIdentifier(displayIdentifier);
        if ((!savedDisplayID) || (savedDisplayID == Display)) {
            // Display has been removed
            if(CGDisplayIsAsleep(Display))
            {
                DEBUG("Display " << Display << " is asleep!");
                RefreshActiveDisplays(false);
            }
            else
            {
                DEBUG("Display has been removed! DisplayID: " << Display);
                std::map<int, space_info>::iterator It;
                for(It = KWMTiling.DisplayMap[Display].Space.begin(); It != KWMTiling.DisplayMap[Display].Space.end(); ++It)
                    DestroyNodeTree(It->second.RootNode);

                if(KWMTiling.DisplayMap[Display].Identifier)
                    CFRelease(KWMTiling.DisplayMap[Display].Identifier);

                KWMTiling.DisplayMap.erase(Display);
                RefreshActiveDisplays(true);
            }
        }
        else if (savedDisplayID != Display) {
            DEBUG("This display being removed had saved ID: " << savedDisplayID);
            RefreshActiveDisplays(true);
        }
    }
    if ((Flags & kCGDisplayDesktopShapeChangedFlag) || (Flags & kCGDisplayMovedFlag))
    {
        if(!CGDisplayIsAsleep(Display))
        {
            if (Flags & kCGDisplayDesktopShapeChangedFlag) {
                DEBUG("Display " << Display << " changed resolution");
            }
            else {
                DEBUG("Display " << Display << " moved");
            }
            screen_info *Screen = &KWMTiling.DisplayMap[Display];
            UpdateExistingScreenInfo(Screen, Display, Screen->ID);
            std::map<int, space_info>::iterator It;
            for(It = Screen->Space.begin(); It != Screen->Space.end(); ++It)
            {
                if(It->second.Managed || It->second.Settings.Mode == SpaceModeFloating)
                {
                    if(It->first == Screen->ActiveSpace)
                        UpdateSpaceOfScreen(&It->second, Screen);
                    else
                        It->second.NeedsUpdate = true;
                }
            }
        }
    }
    if (Flags & kCGDisplaySetMainFlag)
    {
        DEBUG("Display " << Display << " became main");
    }
    if (Flags & kCGDisplaySetModeFlag)
    {
        DEBUG("Display " << Display << " changed mode");
    }
    if (Flags & kCGDisplayEnabledFlag)
    {
        DEBUG("Display " << Display << " enabled");
    }
    if (Flags & kCGDisplayDisabledFlag)
    {
        DEBUG("Display " << Display << " disabled");
    }

    DEBUG("[" << idx << "] END DISPLAY CONFIGURATION CALLBACK\n");
    idx++;
    pthread_mutex_unlock(&KWMThread.Lock);
}