views:

66

answers:

1

Here is my .mm file

#include "windowmanagerutils.h"

#ifdef Q_OS_MAC
#import </System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Headers/CGWindow.h>

QRect WindowManagerUtils::getWindowRect(WId windowId)
{
    CFArrayRef windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
    return QRect();
}

QRect WindowManagerUtils::getClientRect(WId windowId)
{
    return QRect();
}

QString WindowManagerUtils::getWindowText(WId windowId)
{
    return QString();
}

WId WindowManagerUtils::rootWindow()
{
    QApplication::desktop()->winId();
}

WId WindowManagerUtils::windowFromPoint(const QPoint &p, WId parent, bool(*filterFunction)(WId))
{
    return NULL;
}

void WindowManagerUtils::setTopMostCarbon(const QWidget *const window, bool topMost)
{
    if (!window)
    {
        return;
    }

    // Find a Cocoa equivalent for this Carbon function
    // [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
    // OSStatus ret = HIViewSetZOrder(this->winId(), kHIViewZOrderAbove, NULL);
}
#endif

The linker is telling me "_CGWindowListCreate" is undefined. What libraries must I link to? Apple's documentation is not very helpful on telling what to include or link to, like MSDN is. Also I couldn't just do #import <CGWindow.h>, I had to specify the absolute path to it... any way around that?

+1  A: 

The CGWindowListCreate function is part of the Quartz Window Services. The corresponding framework is ApplicationServices which is located under /System/Library/Frameworks/.

So, you can just include <ApplicationServices/ApplicationServices.h> at the top of the file and link with the -framework ApplicationServicesoption.

Laurent Etiemble
I fixed the typo. Thanks for spotting it.
Laurent Etiemble
Thanks for all your help, I was able to link to ApplicationServices by placing: `mac:LIBS += -framework ApplicationServices` in my .pro file and `#import <ApplicationServices/ApplicationServices.h>` in my .mm file.
Jake Petroules