diff options
author | Teddy Wing | 2023-09-29 21:19:48 +0200 |
---|---|---|
committer | Teddy Wing | 2023-09-29 21:19:48 +0200 |
commit | 67b864b6e13ad7e4746b1d4f5b5c0fa6607689e4 (patch) | |
tree | 53c1a11e5cb594556b7b46d8b4289a3dd4572427 /src | |
parent | 5a1c43d54396b9251a5181335532eca2a8f15be9 (diff) | |
download | Base-Windowed-Application-67b864b6e13ad7e4746b1d4f5b5c0fa6607689e4.tar.bz2 |
Document: Fix window cascade
Removing the pointer fixed the cascade, and now new document windows
open shifted by a full titlebar height.
Did a bit of searching on GitHub for `-cascadeTopLeftFromPoint:` and
found this code that does what I was trying to do:
https://github.com/dsa28s/android-studio-apple-m1/blob/c555e84728bfd82a0f9e705af012da37fb52291f/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m#L1399
The above code taught me about the `NSEqualPoints` function, which is
basically what I wanted to initialise the variable. But now I suppose I
don't actually need to do an initialisation of the variable.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.m | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/Document.m b/src/Document.m index eb467e3..ae0696f 100644 --- a/src/Document.m +++ b/src/Document.m @@ -1,6 +1,6 @@ #import "Document.h" -static NSPoint *cascade_offset = NULL; +static NSPoint cascade_offset; @implementation Document @@ -9,14 +9,13 @@ static NSPoint *cascade_offset = NULL; self = [super init]; if (self) { NSLog(@"Checking cascade_offset"); - if (!cascade_offset) { + if (NSEqualPoints(cascade_offset, NSZeroPoint)) { NSLog(@"Setting cascade_offset"); - NSPoint p = NSMakePoint(100, 100); - cascade_offset = &p; - NSLog(@"Has set cascade_offset x:%f y:%f", cascade_offset->x, cascade_offset->y); + cascade_offset = NSMakePoint(100, 100); + NSLog(@"Has set cascade_offset x:%f y:%f", cascade_offset.x, cascade_offset.y); } else { - NSLog(@"init has cascade_offset x:%f y:%f", cascade_offset->x, cascade_offset->y); + NSLog(@"init has cascade_offset x:%f y:%f", cascade_offset.x, cascade_offset.y); } _label = [[NSTextField alloc] @@ -75,20 +74,11 @@ static NSPoint *cascade_offset = NULL; | NSViewMinYMargin | NSViewMaxYMargin]; - // TODO: Cascade, store previous top-left position. - // Figure out why the cascade isn't cascading by enough. Try logging origin values. - if (cascade_offset) { - // cascade_offset = NSMakePoint(100, 100); - NSLog(@"Yes"); - // default 21:03:08.812158+0200 Base Windowed Application makeWindowControllers cascade_offset x:-0.000000 y:-0.000000 - NSPoint o = *cascade_offset; - NSLog(@"makeWindowControllers cascade_offset x:%f y:%f", o.x, o.y); - } - - *cascade_offset = [window cascadeTopLeftFromPoint:*cascade_offset]; + // *cascade_offset = [window cascadeTopLeftFromPoint:*cascade_offset]; // NSPoint o = [window cascadeTopLeftFromPoint:*cascade_offset]; // cascade_offset = &o; - NSLog(@"after setting cascade_offset x:%f y:%f", cascade_offset->x, cascade_offset->y); + cascade_offset = [window cascadeTopLeftFromPoint:cascade_offset]; + NSLog(@"after setting cascade_offset x:%f y:%f", cascade_offset.x, cascade_offset.y); // cascade_offset = [window frame].origin; |