mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-22 19:49:34 +00:00
macOS: remove deprecated screenshot function
This commit is contained in:
parent
f0b1b8cd08
commit
8118355f39
3 changed files with 0 additions and 40 deletions
|
@ -70,9 +70,6 @@ namespace
|
||||||
|
|
||||||
QPixmap screenshot()
|
QPixmap screenshot()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
return MacOSHelper::screenshot();
|
|
||||||
#else
|
|
||||||
std::unordered_set<QWindow *> hidden;
|
std::unordered_set<QWindow *> hidden;
|
||||||
const QWindowList windows = QGuiApplication::allWindows();
|
const QWindowList windows = QGuiApplication::allWindows();
|
||||||
for (QWindow *window : windows)
|
for (QWindow *window : windows)
|
||||||
|
@ -91,7 +88,6 @@ QPixmap screenshot()
|
||||||
});
|
});
|
||||||
|
|
||||||
return QGuiApplication::primaryScreen()->grabWindow(0);
|
return QGuiApplication::primaryScreen()->grabWindow(0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -38,7 +38,6 @@ class MacOSHelper
|
||||||
public:
|
public:
|
||||||
static bool isCapsLock();
|
static bool isCapsLock();
|
||||||
static bool openFolderAndSelectItem(const QUrl &path);
|
static bool openFolderAndSelectItem(const QUrl &path);
|
||||||
static QPixmap screenshot();
|
|
||||||
static QString bundlePath();
|
static QString bundlePath();
|
||||||
static void disableWindowTabbing();
|
static void disableWindowTabbing();
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,41 +68,6 @@ bool MacOSHelper::openFolderAndSelectItem(const QUrl &path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap MacOSHelper::screenshot()
|
|
||||||
{
|
|
||||||
std::unordered_set<uintptr_t> appWindowIds;
|
|
||||||
for (NSWindow *window in [NSApp windows])
|
|
||||||
{
|
|
||||||
appWindowIds.insert((uintptr_t)[window windowNumber]);
|
|
||||||
}
|
|
||||||
|
|
||||||
CFArrayRef onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
|
||||||
const auto onScreenWindowsClenaup = sg::make_scope_guard([&onScreenWindows]() {
|
|
||||||
CFRelease(onScreenWindows);
|
|
||||||
});
|
|
||||||
|
|
||||||
CFMutableArrayRef foreignWindows = CFArrayCreateMutable(NULL, CFArrayGetCount(onScreenWindows), NULL);
|
|
||||||
const auto foreignWindowsClenaup = sg::make_scope_guard([&foreignWindows]() {
|
|
||||||
CFRelease(foreignWindows);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (CFIndex index = 0, count = CFArrayGetCount(onScreenWindows); index < count; ++index)
|
|
||||||
{
|
|
||||||
const uintptr_t windowId = reinterpret_cast<const uintptr_t>(CFArrayGetValueAtIndex(onScreenWindows, index));
|
|
||||||
if (appWindowIds.find(windowId) == appWindowIds.end())
|
|
||||||
{
|
|
||||||
CFArrayAppendValue(foreignWindows, reinterpret_cast<const void *>(windowId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CGImageRef image = CGWindowListCreateImageFromArray(CGRectInfinite, foreignWindows, kCGWindowListOptionAll);
|
|
||||||
const auto imageClenaup = sg::make_scope_guard([&image]() {
|
|
||||||
CFRelease(image);
|
|
||||||
});
|
|
||||||
|
|
||||||
return QtMac::fromCGImageRef(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MacOSHelper::bundlePath()
|
QString MacOSHelper::bundlePath()
|
||||||
{
|
{
|
||||||
NSBundle *main = [NSBundle mainBundle];
|
NSBundle *main = [NSBundle mainBundle];
|
||||||
|
|
Loading…
Reference in a new issue