When two windows are close together you can snap them (window manager autocorrects windows position/sizes and snaps them together, see image attached)
NSWindows have levels:
[Window setLevel:kCGBaseWindowLevelKey]
I want window to be always on top and snap-able. I can achieve "on top" functionality by doing:
[Window setLevel:kCGScreenSaverWindowLevelKey];
However, now window is not snap-able. How can i have both, snap-able and "on top". I have tried every possible window level, only one level is snapable, that is kCGBaseWindowLevelKey
CodePudding user response:
Found an answer. Two windows at the same place with different levels.
It's possible to create an invisible window with window level kCGBaseWindowLevelKey and put it right below the window with kCGScreenSaverWindowLevelKey level. Two windows at the same place with different levels.
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
if (self = [super initWithContentRect:contentRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO])
{
[self setBackgroundColor:[NSColor clearColor]];
}
return self;
}