Skip to content

Commit

Permalink
Merge pull request monero-project#4333
Browse files Browse the repository at this point in the history
8118355 macOS: remove deprecated screenshot function (tobtoht)
  • Loading branch information
luigi1111 committed Aug 13, 2024
2 parents 6889ab5 + 8118355 commit af92ca6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
4 changes: 0 additions & 4 deletions src/main/oshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ namespace

QPixmap screenshot()
{
#ifdef Q_OS_MAC
return MacOSHelper::screenshot();
#else
std::unordered_set<QWindow *> hidden;
const QWindowList windows = QGuiApplication::allWindows();
for (QWindow *window : windows)
Expand All @@ -91,7 +88,6 @@ QPixmap screenshot()
});

return QGuiApplication::primaryScreen()->grabWindow(0);
#endif
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion src/qt/macoshelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class MacOSHelper
public:
static bool isCapsLock();
static bool openFolderAndSelectItem(const QUrl &path);
static QPixmap screenshot();
static QString bundlePath();
static void disableWindowTabbing();
};
Expand Down
35 changes: 0 additions & 35 deletions src/qt/macoshelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,6 @@
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()
{
NSBundle *main = [NSBundle mainBundle];
Expand Down

0 comments on commit af92ca6

Please sign in to comment.