仅在可见窗口中更改时调用方法

时间:2013-02-26 03:10:21

标签: objective-c xcode macos cocoa

每当当前可见系统窗口发生明显变化时,我都需要调用方法。例如,我正在获得完整的可见窗口列表:

CFArrayRef openWindows =(CGWindowListCreate(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID));

这将返回一个数组,如:

{
        kCGWindowAlpha = 1;
        kCGWindowBounds =         {
            Height = 713;
            Width = 1279;
            X = 1;
            Y = 22;
        };
        kCGWindowIsOnscreen = 1;
        kCGWindowLayer = 0;
        kCGWindowMemoryUsage = 3772468;
        kCGWindowName = "Stack Overflow";
        kCGWindowNumber = 7138;
        kCGWindowOwnerName = "Google Chrome";
        kCGWindowOwnerPID = 49972;
        kCGWindowSharingState = 1;
        kCGWindowStoreType = 2;
    }

由于kCGWindowMemoryUsage值不断变化,我不能简单地将先前存储的CFArrayRef与当前存储的CFArrayRef进行比较。

0 个答案:

没有答案