Add IsOverlapped implementation for macOS.
This commit is contained in:
parent
98e3ba2c58
commit
eb768c8c4b
1 changed files with 49 additions and 1 deletions
|
|
@ -103,7 +103,55 @@ void IgnoreAllActivation(not_null<QWidget*> widget) {
|
||||||
std::optional<bool> IsOverlapped(
|
std::optional<bool> IsOverlapped(
|
||||||
not_null<QWidget*> widget,
|
not_null<QWidget*> widget,
|
||||||
const QRect &rect) {
|
const QRect &rect) {
|
||||||
return std::nullopt;
|
NSWindow *window = [reinterpret_cast<NSView*>(widget->window()->winId()) window];
|
||||||
|
Assert(window != nullptr);
|
||||||
|
|
||||||
|
if (![window isOnActiveSpace]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto nativeRect = CGRectMake(
|
||||||
|
rect.x(),
|
||||||
|
rect.y(),
|
||||||
|
rect.width(),
|
||||||
|
rect.height());
|
||||||
|
|
||||||
|
CGWindowID windowId = (CGWindowID)[window windowNumber];
|
||||||
|
const CGWindowListOption options = kCGWindowListExcludeDesktopElements
|
||||||
|
| kCGWindowListOptionOnScreenAboveWindow;
|
||||||
|
CFArrayRef windows = CGWindowListCopyWindowInfo(options, windowId);
|
||||||
|
if (!windows) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
CFRelease(windows);
|
||||||
|
});
|
||||||
|
NSMutableArray *list = (__bridge NSMutableArray*)windows;
|
||||||
|
for (NSDictionary *window in list) {
|
||||||
|
NSNumber *alphaValue = [window objectForKey:@"kCGWindowAlpha"];
|
||||||
|
const auto alpha = alphaValue ? [alphaValue doubleValue] : 1.;
|
||||||
|
if (alpha == 0.) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
NSString *owner = [window objectForKey:@"kCGWindowOwnerName"];
|
||||||
|
NSNumber *layerValue = [window objectForKey:@"kCGWindowLayer"];
|
||||||
|
const auto layer = layerValue ? [layerValue intValue] : 0;
|
||||||
|
if (owner && [owner isEqualToString:@"Dock"] && layer == 20) {
|
||||||
|
// It is always full screen.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CFDictionaryRef bounds = (__bridge CFDictionaryRef)[window objectForKey:@"kCGWindowBounds"];
|
||||||
|
if (!bounds) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CGRect rect;
|
||||||
|
if (!CGRectMakeWithDictionaryRepresentation(bounds, &rect)) {
|
||||||
|
continue;
|
||||||
|
} else if (CGRectIntersectsRect(rect, nativeRect)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleControls::Layout TitleControlsLayout() {
|
TitleControls::Layout TitleControlsLayout() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue