summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm
blob: 19c5c0d714224f1100c23630d94eebd2979ef68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

// some versions of CALayer.h use 'slots' as an identifier
#define QT_NO_KEYWORDS

#include "tst_qwidget_mac_helpers.h"
#include <QApplication>
#include <qpa/qplatformnativeinterface.h>
#include <private/qcore_mac_p.h>

#include <AppKit/AppKit.h>

QString nativeWindowTitle(QWidget *window, Qt::WindowState state)
{
    QWindow *qwindow = window->windowHandle();
    NSWindow *nswindow = (NSWindow *) qApp->platformNativeInterface()->nativeResourceForWindow("nswindow", qwindow);
    QCFString macTitle;
    if (state == Qt::WindowMinimized) {
        macTitle = reinterpret_cast<CFStringRef>([[nswindow miniwindowTitle] retain]);
    } else {
        macTitle = reinterpret_cast<CFStringRef>([[nswindow title] retain]);
    }
    return macTitle;
}

bool nativeWindowModified(QWidget *widget)
{
    QWindow *qwindow = widget->windowHandle();
    NSWindow *nswindow = (NSWindow *) qApp->platformNativeInterface()->nativeResourceForWindow("nswindow", qwindow);
    return [nswindow isDocumentEdited];
}