Respect FxRemoteWindow geometry and follow host content bounds in LUT browser

这个提交包含在:
mac 于 2026-11-02 21:42:20 +08:00 提交
1 父节点 e62d5532f2
当前提交 f9dea76a45
11 个文件已更改
+261 -14

没有与搜索条件相匹配的文件

+1 -1
查看文件
@@ -32,7 +32,7 @@ int main(int argc,const char **argv){@autoreleasepool{
NSSplitView *split=[browser valueForKey:@"splitView"];[split setPosition:240 ofDividerAtIndex:0];[browser layoutBrowser];NSScrollView *folders=[browser valueForKey:@"folderScroll"],*grid=[browser valueForKey:@"gridScroll"];require(fabs(folders.frame.size.width-240)<2&&NSMaxX(folders.frame)<=NSMinX(grid.frame),@"sidebar divider changes folder width without overlapping previews");
[browser close];[browser release];browser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:nil palette:@{} selection:nil];pump(^{return [browser valueForKey:@"libraryTask"]==nil;});require([(NSPopUpButton*)[browser valueForKey:@"layoutMenu"]indexOfSelectedItem]==1&&fabs([[browser valueForKey:@"sidebarWidth"]doubleValue]-240)<2,@"layout and sidebar width survive reopening");
NSPanel *host=[[[NSPanel alloc]initWithContentRect:NSMakeRect(120,160,900,620) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];__block int closes=0;[browser showInRemoteParent:host.contentView close:^{closes++;}];pump(^{return [browser valueForKey:@"presentationWindow"]==host;});require(!host.visible&&browser.visible,@"remote-parent checks never display a test window");
NSRect desired=NSMakeRect(190,210,1000,680);[host setFrame:desired display:NO];NSString *frameKey=[@"com.dayu.color.lookLUTPreview.windowFrame|" stringByAppendingString:library.rootURL.path];require(NSEqualRects(NSRectFromString([NSUserDefaults.standardUserDefaults stringForKey:frameKey]),host.frame),@"window position and size are remembered");[browser close];[browser close];require(closes==1,@"remote close callback runs once");[browser release];[ack release];ack=nil;
NSRect desired=NSMakeRect(190,210,1000,680);[host setFrame:desired display:NO];NSString *frameKey=[@"com.dayu.color.lookLUTPreview.windowFrame|" stringByAppendingString:library.rootURL.path];require([NSUserDefaults.standardUserDefaults stringForKey:frameKey]==nil,@"remote window geometry is owned and remembered by the host");[browser close];[browser close];require(closes==1,@"remote close callback runs once");[browser release];[ack release];ack=nil;
for(int i=0;i<50;i++)[library recordUsedPath:[root.path stringByAppendingPathComponent:[NSString stringWithFormat:@"History-%d.cube",i]]];require(library.recentPaths.count==40&&[library.recentPaths[0]hasSuffix:@"History-49.cube"],@"recent history stays bounded at 40 newest paths");
NSArray *keys=NSUserDefaults.standardUserDefaults.dictionaryRepresentation.allKeys;for(NSString *key in keys)if([key containsString:library.rootURL.path])[NSUserDefaults.standardUserDefaults removeObjectForKey:key];require([fm removeItemAtURL:root error:nil],@"isolated fixtures and preferences cleaned");
NSDictionary *report=@{@"pass":@YES,@"checks":checks,@"scope":@"Real AppKit browser objects, hidden host-owned window fixture, asynchronous acknowledgement and root-scoped history; no visible test app or user LUT changes."};[[NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted error:nil]writeToFile:[NSString stringWithUTF8String:argv[1]] atomically:YES];printf("PASS %lu browser checks\n",(unsigned long)checks.count);[checks release];return 0;
+62
查看文件
@@ -0,0 +1,62 @@
#import <AppKit/AppKit.h>
#import "../大鱼调色/Plugin/DYLUTBrowser.h"
#import "../大鱼调色/Plugin/DYLUTLibrary.h"
#include <cmath>
@interface DYLUTBrowser (GeometryProbe)
- (void)configurePresentationWindow;
@end
static NSMutableArray *checks;
static void check(BOOL pass,NSString *name){[checks addObject:@{@"name":name,@"pass":@(pass)}];if(!pass)fprintf(stderr,"FAIL %s\n",name.UTF8String);}
static void pump(void){double until=NSProcessInfo.processInfo.systemUptime+.08;while(NSProcessInfo.processInfo.systemUptime<until)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];}
int main(int argc,const char **argv){@autoreleasepool{
if(argc!=2)return 2;checks=[NSMutableArray new];[NSApplication sharedApplication];[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
NSURL *directory=[NSURL fileURLWithPath:[NSTemporaryDirectory()stringByAppendingPathComponent:[@"dayu-remote-geometry-" stringByAppendingString:NSUUID.UUID.UUIDString]]];
[NSFileManager.defaultManager createDirectoryAtURL:directory withIntermediateDirectories:YES attributes:nil error:nil];
DYLUTLibrary *library=[[[DYLUTLibrary alloc]initWithRootURL:directory]autorelease];
NSString *key=[@"com.dayu.color.lookLUTPreview.windowFrame|" stringByAppendingString:library.rootURL.path];
NSString *stale=NSStringFromRect(NSMakeRect(-9000,8000,1800,1228));[NSUserDefaults.standardUserDefaults setObject:stale forKey:key];
NSPanel *host=[[[NSPanel alloc]initWithContentRect:NSMakeRect(80,100,900,620) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];
// A remote bridge can publish its content bounds separately from its local
// service-side window. Never resize that window to restore plug-in history.
NSView *parent=[[[NSView alloc]initWithFrame:host.contentView.bounds]autorelease];parent.autoresizesSubviews=NO;[host.contentView addSubview:parent];
NSRect initial=host.frame;NSSize minimum=host.contentMinSize,maximum=host.contentMaxSize;NSString *title=[host.title copy];
__block NSUInteger closes=0;DYLUTBrowser *browser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:nil palette:@{} selection:nil];
[browser showInRemoteParent:parent close:^{closes++;}];pump();
NSView *root=[browser valueForKey:@"root"];
check(NSEqualRects(host.frame,initial),@"remote attach never restores a stale frame onto the host window");
check(NSEqualSizes(host.contentMinSize,minimum)&&NSEqualSizes(host.contentMaxSize,maximum),@"remote attach preserves host minimum and maximum sizes");
check([host.title isEqual:title],@"remote attach preserves host-owned window metadata");
check(!parent.autoresizesSubviews,@"remote attach preserves the bridge's autoresizing policy");
check(NSEqualRects(root.frame,parent.bounds),@"root initially covers exactly the supplied remote bounds");
check(!host.visible&&browser.visible,@"native geometry fixtures remain invisible");
for(NSValue *value in @[[NSValue valueWithSize:NSMakeSize(576,336)],[NSValue valueWithSize:NSMakeSize(720,420)],[NSValue valueWithSize:NSMakeSize(1280,800)],[NSValue valueWithSize:NSMakeSize(900,620)]]){
parent.autoresizesSubviews=NO;[parent setFrameSize:value.sizeValue];pump();
check(NSEqualRects(root.frame,parent.bounds),@"root follows bridge resize even when autoresizing is disabled");
NSView *done=[browser valueForKey:@"done"],*search=[browser valueForKey:@"search"],*split=[browser valueForKey:@"splitView"];
check(NSContainsRect(root.bounds,done.frame)&&NSContainsRect(root.bounds,search.frame)&&NSContainsRect(root.bounds,split.frame),@"footer, search and browser panes remain within host-capped content");
}
[parent setBoundsOrigin:NSMakePoint(17,23)];pump();check(NSEqualRects(root.frame,parent.bounds),@"root tracks nonzero remote bounds origins");
[host setFrame:NSMakeRect(140,160,1000,700) display:NO];pump();check([[NSUserDefaults.standardUserDefaults stringForKey:key]isEqual:stale],@"remote window events never overwrite local window history");
[browser close];[browser close];check(closes==1,@"remote dismissal is delivered once");[browser release];[title release];
// Late SDK attachment: a zero-sized placeholder gets real bounds later.
NSView *late=[[[NSView alloc]initWithFrame:NSZeroRect]autorelease];late.autoresizesSubviews=NO;[host.contentView addSubview:late];
browser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:nil palette:@{} selection:nil];[browser showInRemoteParent:late close:nil];
[late setFrame:NSMakeRect(0,0,720,420)];pump();root=[browser valueForKey:@"root"];
check(NSEqualRects(root.frame,late.bounds),@"zero-size SDK placeholder expands after late host attachment");[browser close];[browser release];
// Detached popovers are local windows and retain their geometry behavior.
NSPanel *local=[[[NSPanel alloc]initWithContentRect:NSMakeRect(120,140,900,620) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];
browser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:nil palette:@{} selection:nil];[browser showInRemoteParent:local.contentView close:nil];
[browser setValue:@NO forKey:@"remoteMode"];[browser setValue:@YES forKey:@"detached"];pump();
BOOL onScreen=NO;for(NSScreen *screen in NSScreen.screens)onScreen|=NSContainsRect(screen.visibleFrame,local.frame);
check(onScreen,@"local detached window constrains disconnected-display history to a visible screen");
NSRect chosen=[local frameRectForContentRect:NSMakeRect(180,200,900,620)];[local setFrame:chosen display:NO];pump();
check(NSEqualRects(NSRectFromString([NSUserDefaults.standardUserDefaults stringForKey:key]),local.frame),@"local detached window still remembers user position and size");
check(!local.visible,@"local fallback geometry checks also remain invisible");[browser close];[browser release];
for(NSString *item in NSUserDefaults.standardUserDefaults.dictionaryRepresentation.allKeys)if([item containsString:library.rootURL.path])[NSUserDefaults.standardUserDefaults removeObjectForKey:item];
[NSFileManager.defaultManager removeItemAtURL:directory error:nil];
BOOL pass=YES;for(NSDictionary *item in checks)pass&=[item[@"pass"]boolValue];
NSDictionary *report=@{@"pass":@(pass),@"checks":checks,@"scope":@"Hidden native AppKit remote-bridge fixtures: stale off-screen history, host-owned geometry, disabled autoresizing, capped content sizes, nonzero bounds and late attachment. No visible test app or user settings modified."};
[[NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted error:nil]writeToFile:[NSString stringWithUTF8String:argv[1]] atomically:YES];
printf("%s %lu checks\n",pass?"PASS":"FAIL",(unsigned long)checks.count);return pass?0:1;
}}