mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Merge current main into the tested VSync and VRR fixes
This commit is contained in:
commit
ff8a985057
11 files changed
+1272
-184
No files matched your search
@@ -119,6 +119,96 @@ Expected: `CORETEXT_FONT_LIST pass=1` with nonzero family/face counts (306/1124
|
||||
|
||||
The font probe reproduces Chromium's installed-family enumeration, mandatory family matching and localized-name lookup with a null language output. It checks ownership of the single-match result and that a nonexistent mandatory family produces no substitute. The resize probe checks backing-layer bounds immediately after frame/bounds changes, including a scaled view and a child layer, without relying on input or coordinate conversion to refresh them. It also verifies that native parent size is current during child layout, and that adding an overlay sibling after the content view does not redirect subsequent content resizing into that overlay. The old sibling selection left content at 1600×900 while stretching the 30×20 overlay to 1280×720; the corrected layout resizes the content and preserves the overlay. Before the fixes, these checks report a stale 1280×720 layer and native parent after a 1600×900 resize. The `FRAME_SIZE_HOOK` check uses a subclass whose `setFrameSize:` publishes its viewport size. It checks growth and shrinkage through parent autoresizing, direct `setFrame:`, and direct `setFrameSize:`. Before component-setter dispatch was corrected only the final direct size setter reached the subclass (one callback); afterward all four updates do, with current geometry visible inside the callback. No probe launches or contacts Riot/League. The user confirmed that the language dropdown and League window resizing work after the final X11 correction (2026-10-15). The practice-tool crash remains unresolved.
|
||||
|
||||
### Local event monitors and client dragging
|
||||
|
||||
`python3 tools/build-riot-x11-runtime.py` builds
|
||||
`build/riot-event-monitors-check`. With patched AppKit installed and clients
|
||||
closed, run:
|
||||
|
||||
```sh
|
||||
darling shell env DYLD_LIBRARY_PATH=/Users/me/RuntimeLibraries \
|
||||
DYLD_FRAMEWORK_PATH=/Users/me/RuntimeFrameworks \
|
||||
/Volumes/SystemRoot/path/to/darling-lol/build/riot-event-monitors-check
|
||||
```
|
||||
|
||||
Expected: nine `PASS` lines and exit status 0. This independent probe tests
|
||||
multiple monitors, mask filtering, removal, consumption, event replacement,
|
||||
self-removal, and the in-flight snapshot when another monitor is removed.
|
||||
Monitor order is unspecified and is deliberately not asserted. It dispatches
|
||||
only synthetic events to its own unmapped window.
|
||||
The same source runs against native macOS AppKit:
|
||||
|
||||
```sh
|
||||
clang -fblocks -framework AppKit tools/riot-event-monitors-check.m \
|
||||
-o /tmp/riot-event-monitors-check
|
||||
/tmp/riot-event-monitors-check
|
||||
```
|
||||
|
||||
Native reference: macOS 26.6.2. LeagueClientUx uses local
|
||||
monitors for custom window movement; intercepting a fixed titlebar strip instead
|
||||
would bypass its own drag policy and risk stealing its window-control clicks.
|
||||
For a live regression check, drag its header, drag ordinary content (which must
|
||||
not move the window), minimize and restore it, and check Riot Client header
|
||||
dragging separately. No match is required.
|
||||
|
||||
### X11 window decorations
|
||||
|
||||
`python3 tools/build-riot-x11-runtime.py` also builds
|
||||
`build/riot-window-decorations-check`. Install and activate both the patched
|
||||
AppKit and X11 backend before running it, with clients and the game closed:
|
||||
|
||||
```sh
|
||||
darling shell env DYLD_LIBRARY_PATH=/Users/me/RuntimeLibraries \
|
||||
DYLD_FRAMEWORK_PATH=/Users/me/RuntimeFrameworks \
|
||||
/Volumes/SystemRoot/path/to/darling-lol/build/riot-window-decorations-check
|
||||
```
|
||||
|
||||
Expected: `WINDOW_DECORATIONS_CHECK cases=10 pass=1`. The independent Cocoa
|
||||
probe reads `_MOTIF_WM_HINTS` on its own unmapped native windows. It covers a
|
||||
normal titled window, hidden title alone, hidden plus transparent titlebar,
|
||||
both reverse transitions, untitled masks with additional flags, switching to
|
||||
borderless after creation, native-window recreation, and properties set before
|
||||
the native window exists. It sends no input, maps no windows and does not
|
||||
launch or contact Riot/League. Check the success marker, not only the launcher
|
||||
exit status: some Darling versions do not propagate a guest assertion failure.
|
||||
|
||||
Before the fix the hidden/transparent case fails. With the corrected overlays,
|
||||
the ten cases passed on KDE Wayland/Xwayland. Passive inspection of the reopened
|
||||
Riot Client also confirmed the no-decoration hint and identical compositor frame
|
||||
and client dimensions (1536×864), instead of the previous 28-pixel titlebar.
|
||||
This validates the Riot Client window, not every LeagueClientUx or game mode.
|
||||
|
||||
### NSOpenPanel Open/Cancel (issue #85)
|
||||
|
||||
`python3 tools/build-riot-openpanel-check.py` builds
|
||||
`build/riot-openpanel-check`. Install the patched AppKit first, with clients and
|
||||
the game closed. The probe opens its own directory chooser in a fresh `/tmp`
|
||||
folder containing one subfolder and needs no Riot/League client:
|
||||
|
||||
```sh
|
||||
P=/Volumes/SystemRoot/path/to/darling-lol/build/riot-openpanel-check
|
||||
E="env DYLD_LIBRARY_PATH=/Users/me/RuntimeLibraries DYLD_FRAMEWORK_PATH=/Users/me/RuntimeFrameworks"
|
||||
for m in cancel open-selected open-none; do darling shell $E $P --auto $m; done
|
||||
darling shell $E $P --interactive
|
||||
```
|
||||
|
||||
Each `--auto` mode waits 1.5 s, then clicks the panel's own Cancel or Open
|
||||
button (selecting the subfolder first for `open-selected`), and checks that
|
||||
`runModal` returned, the result code and URL, and that the panel is gone. A
|
||||
15 s watchdog on a separate thread reports a hang. Expected, one line per mode:
|
||||
|
||||
```
|
||||
OPENPANEL_CHECK mode=cancel result=PASS code=0 ...
|
||||
OPENPANEL_CHECK mode=open-selected result=PASS code=1 url=/tmp/openpanel-check.XXXXXX/subfolder ...
|
||||
OPENPANEL_CHECK mode=open-none result=PASS code=1 url=/tmp/openpanel-check.XXXXXX ...
|
||||
```
|
||||
|
||||
A failure prints `result=FAIL ... problems=...` (`HANG` when `runModal` never
|
||||
returned) and exits non-zero. `--interactive` shows the panel for manual clicks
|
||||
and prints `OPENPANEL_CHECK mode=interactive result=RETURNED code=... url=...`
|
||||
once it closes. As with the other probes, check the printed line rather than
|
||||
only the launcher exit status.
|
||||
|
||||
### Presentation publisher handoff
|
||||
|
||||
With clients closed, run `build/riot-client-resize-check --handoff` through Darling with the normal runtime overrides. This creates an owned window and two fixture frame slots. The live software owner first supplies a 1280×720 main frame, then switches to a 262×131 popup; another slot supplies the resized main frame without the software flag. The test samples its own window beyond the original frame extent and checks generation colors across growth and shrinkage. The old selector reports black at the 1600×900 sample; the correction passes all four sizes. Repeat with `RCLOL_XSHM=0` and with `DARLING_XSHM_LIBRARY` pointing to the normal transport to cover both paths. The fixtures remove their own frame slots on exit; they do not read client pixels or send input.
|
||||
|
||||
+669
-181
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,46 @@
|
||||
"""Check that the patched Cocotron file panels always end their modal session and never throw on Open."""
|
||||
import unittest
|
||||
import test_runtime_compatibility as sources
|
||||
|
||||
|
||||
def body(source, signature):
|
||||
return source.split(signature + ' {', 1)[1].split('\n}', 1)[0]
|
||||
|
||||
|
||||
class FilePanelCloseChecks(unittest.TestCase):
|
||||
patched = sources.CompatibilityChecks.patched
|
||||
|
||||
def save_panel(self):
|
||||
return self.patched('cocotron', 'AppKit/NSSavePanel.subproj/NSSavePanel.m')
|
||||
|
||||
def open_panel(self):
|
||||
return self.patched('cocotron', 'AppKit/NSSavePanel.subproj/NSOpenPanel.m')
|
||||
|
||||
def test_both_buttons_dismiss_through_one_helper(self):
|
||||
source = self.save_panel()
|
||||
dismiss = body(source, '- (void) _dismissWithCode: (NSModalResponse) code')
|
||||
self.assertIn('[NSApp modalWindow] == self', dismiss)
|
||||
self.assertIn('stopModalWithCode: code', dismiss)
|
||||
self.assertIn('orderOut', dismiss)
|
||||
self.assertIn('_dismissWithCode: NSCancelButton', body(source, '- (IBAction) _cancel: (id) sender'))
|
||||
self.assertIn('_dismissWithCode: NSOKButton', body(source, '- (IBAction) _selectFile: (id) sender'))
|
||||
|
||||
def test_open_without_a_selection_cannot_throw(self):
|
||||
# Nothing selected used to hand nil to -_setFilename:, and NSOpenPanel boxed it in @[ ... ].
|
||||
self.assertNotIn('@[ filename ]];', self.open_panel().replace('[filename length] > 0 ? @[ filename ] : @[]', ''))
|
||||
select = body(self.save_panel(), '- (IBAction) _selectFile: (id) sender')
|
||||
self.assertNotIn('itemAtRow: [_outlineView selectedRow]', select)
|
||||
self.assertIn('@catch', select)
|
||||
self.assertIn('NSCancelButton', select.split('@catch', 1)[1])
|
||||
|
||||
def test_open_panel_honours_what_it_may_choose(self):
|
||||
accept = body(self.open_panel(), '- (NSArray *) _acceptablePaths')
|
||||
self.assertIn('_canChooseDirectories', accept)
|
||||
self.assertIn('_canChooseFiles', accept)
|
||||
|
||||
def test_escape_cancels(self):
|
||||
self.assertIn('[self _cancel: sender]', body(self.save_panel(), '- (void) cancelOperation: (id) sender'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,36 @@
|
||||
"""Check that the patched X11 backend cannot re-map a window AppKit has hidden."""
|
||||
import unittest
|
||||
import test_runtime_compatibility as sources
|
||||
|
||||
|
||||
def body(source, signature):
|
||||
return source.split(signature + ' {', 1)[1].split('\n}', 1)[0]
|
||||
|
||||
|
||||
class HiddenWindowChecks(unittest.TestCase):
|
||||
patched = sources.CompatibilityChecks.patched
|
||||
|
||||
def test_restack_and_make_key_map_only_visible_windows(self):
|
||||
source = self.patched('cocotron', 'AppKit/X11.backend/X11Window.m')
|
||||
self.assertIn('[_delegate isVisible]', body(source, '- (void) ensureMappedIfVisible'))
|
||||
for signature in ('- (void) placeAboveWindow: (NSInteger) otherNumber',
|
||||
'- (void) placeBelowWindow: (NSInteger) otherNumber', '- (void) makeKey'):
|
||||
method = body(source, signature)
|
||||
self.assertIn('[self ensureMappedIfVisible]', method, signature)
|
||||
self.assertNotIn('[self ensureMapped]', method, signature)
|
||||
|
||||
def test_ordering_marks_window_visible_before_placing_it(self):
|
||||
source = self.patched('cocotron', 'AppKit/NSWindow.m')
|
||||
ordering = source.split('relativeTo: (NSInteger) relativeTo\n{', 1)[1].split('\n}', 1)[0]
|
||||
for call in ('placeAboveWindow', 'placeBelowWindow'):
|
||||
self.assertLess(ordering.index('_isVisible = YES'), ordering.index(call))
|
||||
|
||||
def test_hiding_reaches_the_platform_window_when_already_not_visible(self):
|
||||
source = self.patched('cocotron', 'AppKit/NSWindow.m')
|
||||
method = body(source, '- (void) setIsVisible: (BOOL) visible')
|
||||
self.assertIn('_isVisible == visible && visible', method)
|
||||
self.assertIn('hideWindow', method)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -12,7 +12,7 @@ for line in (framework / 'CMakeFiles/AppKit.dir/flags.make').read_text().splitli
|
||||
name, value = line.split(' = ', 1)
|
||||
flags[name] = shlex.split(value)
|
||||
link = shlex.split((framework / 'CMakeFiles/AppKit.dir/link.txt').read_text())
|
||||
for name in ['NSResponder', 'NSApplication', 'NSWindow', 'NSDisplay', 'NSView', 'NSThemeFrame', 'NSTextInput', 'NSBitmapImageRep', 'NSEvent.subproj/NSEvent_mouse']:
|
||||
for name in ['NSResponder', 'NSApplication', 'NSWindow', 'NSDisplay', 'NSView', 'NSThemeFrame', 'NSTextInput', 'NSBitmapImageRep', 'NSEvent.subproj/NSEvent', 'NSEvent.subproj/NSEvent_mouse']:
|
||||
obj = project / f'build/riot-{Path(name).name}.o'
|
||||
subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FLAGS'],
|
||||
'-O3', '-march=native', '-mtune=generic', '-Wno-macro-redefined', '-c',
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the owned NSOpenPanel modal-session check (issue #85)."""
|
||||
from pathlib import Path
|
||||
import json
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
folder = root / 'build/darling-src/build/src/external/cocotron/AppKit'
|
||||
config = root / 'build/config.json'
|
||||
sdk = json.loads(config.read_text())['sdk'] if config.exists() else '/usr/local/libexec/darling'
|
||||
flags = {}
|
||||
for line in (folder / 'CMakeFiles/X11_backend.dir/flags.make').read_text().splitlines():
|
||||
if line.startswith('C_') and ' = ' in line:
|
||||
key, value = line.split(' = ', 1)
|
||||
flags[key] = shlex.split(value)
|
||||
obj = root / 'build/riot-openpanel-check.o'
|
||||
subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FLAGS'],
|
||||
'-O2', '-fblocks', '-UNDEBUG', '-Wno-macro-redefined', '-c', str(root / 'tools/riot-openpanel-check.m'),
|
||||
'-o', str(obj)], check=True)
|
||||
subprocess.run(['clang', '-target', 'x86_64-apple-macosx11.0', '-fuse-ld=lld', '-nostdlib',
|
||||
'-isysroot', sdk, str(obj), '-lSystem', '-lobjc',
|
||||
'-framework', 'AppKit', '-framework', 'CoreFoundation', '-framework', 'Foundation',
|
||||
'-o', str(root / 'build/riot-openpanel-check')], check=True)
|
||||
@@ -48,4 +48,23 @@ subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FL
|
||||
str(project / 'tools/riot-fullscreen-geometry-check.m'), '-o', str(probe)], check=True)
|
||||
subprocess.run(['clang', '-target', 'x86_64-apple-macosx11.0', '-fuse-ld=lld',
|
||||
'-nostdlib', '-isysroot', sdk, str(probe), '-lSystem', '-lobjc', '-framework', 'Foundation',
|
||||
'-o', str(project / 'build/riot-fullscreen-geometry-check')], check=True)
|
||||
'-o', str(project / 'build/riot-fullscreen-geometry-check')], check=True)
|
||||
|
||||
# Query the actual native hints after Cocoa title/style changes, without mapping windows.
|
||||
probe = project / 'build/riot-window-decorations-check.o'
|
||||
subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FLAGS'],
|
||||
'-O3', '-march=native', '-mtune=generic', '-UNDEBUG', '-Wno-macro-redefined', '-c',
|
||||
str(project / 'tools/riot-window-decorations-check.m'), '-o', str(probe)], check=True)
|
||||
subprocess.run(['clang', '-target', 'x86_64-apple-macosx11.0', '-fuse-ld=lld',
|
||||
'-nostdlib', '-isysroot', sdk, str(probe), '-lSystem', '-lobjc', '-framework', 'AppKit',
|
||||
'-framework', 'Foundation', '-framework', 'CoreGraphics',
|
||||
'-o', str(project / 'build/riot-window-decorations-check')], check=True)
|
||||
|
||||
# Match native AppKit's local event monitor dispatch semantics.
|
||||
probe = project / 'build/riot-event-monitors-check.o'
|
||||
subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FLAGS'],
|
||||
'-O3', '-march=native', '-mtune=generic', '-Wno-macro-redefined', '-c',
|
||||
str(project / 'tools/riot-event-monitors-check.m'), '-o', str(probe)], check=True)
|
||||
subprocess.run(['clang', '-target', 'x86_64-apple-macosx11.0', '-fuse-ld=lld',
|
||||
'-nostdlib', '-isysroot', sdk, str(probe), '-lSystem', '-lobjc', '-framework', 'AppKit',
|
||||
'-framework', 'Foundation', '-o', str(project / 'build/riot-event-monitors-check')], check=True)
|
||||
@@ -0,0 +1,98 @@
|
||||
/* Local event dispatch regression; also runs unchanged against native AppKit.
|
||||
* No global input, client hooks, account access, or mapped windows. */
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
static NSMutableString *calls;
|
||||
static int failures;
|
||||
|
||||
@interface MonitorTestWindow : NSWindow
|
||||
@end
|
||||
@implementation MonitorTestWindow
|
||||
- (void) sendEvent: (NSEvent *) event {
|
||||
[calls appendFormat: @"W%ld", (long)[event type]];
|
||||
}
|
||||
@end
|
||||
|
||||
static void expectCalls(NSString *name, NSString *expected) {
|
||||
BOOL ok = [calls isEqual: expected];
|
||||
printf("%s %s got=%s expected=%s\n", ok ? "PASS" : "FAIL",
|
||||
[name UTF8String], [calls UTF8String], [expected UTF8String]);
|
||||
failures += !ok;
|
||||
[calls setString: @""];
|
||||
}
|
||||
|
||||
/* AppKit does not promise an order between independent registrations. Native
|
||||
* ordering can change with block addresses, even on the same OS build. */
|
||||
static void expectBoth(NSString *name) {
|
||||
NSString *expected = [calls isEqual: @"ABW1"] ? @"ABW1" : @"BAW1";
|
||||
expectCalls(name, expected);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@autoreleasepool {
|
||||
[NSApplication sharedApplication];
|
||||
calls = [NSMutableString new];
|
||||
NSWindow *window = [[MonitorTestWindow alloc]
|
||||
initWithContentRect: NSMakeRect(100, 100, 300, 200)
|
||||
styleMask: 0 backing: NSBackingStoreBuffered defer: NO];
|
||||
NSEvent *down = [NSEvent mouseEventWithType: NSLeftMouseDown
|
||||
location: NSMakePoint(10, 10) modifierFlags: 0 timestamp: 0
|
||||
windowNumber: [window windowNumber] context: nil
|
||||
eventNumber: 1 clickCount: 1 pressure: 1];
|
||||
NSEvent *up = [NSEvent mouseEventWithType: NSLeftMouseUp
|
||||
location: NSMakePoint(10, 10) modifierFlags: 0 timestamp: 0
|
||||
windowNumber: [window windowNumber] context: nil
|
||||
eventNumber: 2 clickCount: 1 pressure: 0];
|
||||
id a = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"A"]; return event;
|
||||
}];
|
||||
id b = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"B"]; return event;
|
||||
}];
|
||||
[NSApp sendEvent: down]; expectBoth(@"multiple-monitors");
|
||||
[NSApp sendEvent: up]; expectCalls(@"mask-filter", @"W2");
|
||||
[NSEvent removeMonitor: b];
|
||||
[NSApp sendEvent: down]; expectCalls(@"remove", @"AW1");
|
||||
[NSEvent removeMonitor: a];
|
||||
|
||||
b = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"B"]; return nil;
|
||||
}];
|
||||
[NSApp sendEvent: down]; expectCalls(@"consume", @"B");
|
||||
[NSEvent removeMonitor: b];
|
||||
b = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"B"]; return up;
|
||||
}];
|
||||
[NSApp sendEvent: down]; expectCalls(@"replace-event", @"BW2");
|
||||
[NSEvent removeMonitor: b];
|
||||
|
||||
__block id selfRemoving;
|
||||
selfRemoving = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"S"];
|
||||
[NSEvent removeMonitor: selfRemoving]; return event;
|
||||
}];
|
||||
[NSApp sendEvent: down]; expectCalls(@"self-remove", @"SW1");
|
||||
[NSApp sendEvent: down]; expectCalls(@"self-remove-next", @"W1");
|
||||
__block id pendingA, pendingB;
|
||||
pendingA = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"A"];
|
||||
[NSEvent removeMonitor: pendingB]; return event;
|
||||
}];
|
||||
pendingB = [NSEvent addLocalMonitorForEventsMatchingMask: NSLeftMouseDownMask
|
||||
handler: ^NSEvent *(NSEvent *event) {
|
||||
[calls appendString: @"B"];
|
||||
[NSEvent removeMonitor: pendingA]; return event;
|
||||
}];
|
||||
[NSApp sendEvent: down]; expectBoth(@"remove-pending-snapshot");
|
||||
[NSApp sendEvent: down]; expectCalls(@"remove-pending-next", @"W1");
|
||||
[window release];
|
||||
[calls release];
|
||||
}
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/* Standalone AppKit regression for issue #85: the panel's own Open/Cancel
|
||||
* buttons must end runModal. Drives only its own NSOpenPanel; no Riot/League
|
||||
* client is launched or contacted and no external input is generated.
|
||||
*
|
||||
* riot-openpanel-check --auto cancel|open-selected|open-none
|
||||
* riot-openpanel-check --interactive
|
||||
*/
|
||||
#import <AppKit/AppKit.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
#include <objc/runtime.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static NSOpenPanel *panel;
|
||||
static NSString *tempDir, *subDir;
|
||||
static const char *mode;
|
||||
static BOOL interactive;
|
||||
static BOOL panelVisibleAtTrigger;
|
||||
/* Plain C storage: an autoreleased NSString kept here would be freed by the
|
||||
* modal loop's pools before the result is reported (and the watchdog thread
|
||||
* reads it too). */
|
||||
static char triggerNote[160] = "";
|
||||
static const double kTriggerDelay = 1.5, kWatchdog = 15.0;
|
||||
|
||||
static NSButton *findButton(NSView *view, SEL action) {
|
||||
if ([view isKindOfClass:[NSButton class]] && [(NSButton *)view action] == action)
|
||||
return (NSButton *)view;
|
||||
for (NSView *sub in [view subviews]) {
|
||||
NSButton *found = findButton(sub, action);
|
||||
if (found) return found;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
static NSOutlineView *findOutline(NSView *view) {
|
||||
if ([view isKindOfClass:[NSOutlineView class]]) return (NSOutlineView *)view;
|
||||
for (NSView *sub in [view subviews]) {
|
||||
NSOutlineView *found = findOutline(sub);
|
||||
if (found) return found;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
static void press(SEL action, const char *name) {
|
||||
NSButton *button = findButton([panel contentView], action);
|
||||
if (button) {
|
||||
snprintf(triggerNote, sizeof triggerNote, "%s via button", name);
|
||||
[button performClick:nil];
|
||||
} else {
|
||||
snprintf(triggerNote, sizeof triggerNote, "%s via direct action (button not found)", name);
|
||||
[panel performSelector:action withObject:nil];
|
||||
}
|
||||
}
|
||||
|
||||
static char selectNote[320] = "";
|
||||
static BOOL selectionOK = YES;
|
||||
|
||||
static NSString *urlPath(id item) {
|
||||
NSString *path = [item isKindOfClass:[NSURL class]] ? [item path] : nil;
|
||||
while ([path length] > 1 && [path hasSuffix:@"/"])
|
||||
path = [path substringToIndex:[path length] - 1];
|
||||
return path;
|
||||
}
|
||||
|
||||
/* The panel's tree is rooted at "/" and is not navigated to the directory
|
||||
* being shown, so expand each component of subDir from the root, then select
|
||||
* its row. Records diagnostics in selectNote. */
|
||||
static BOOL selectSubfolder(void) {
|
||||
NSOutlineView *outline = findOutline([panel contentView]);
|
||||
if (!outline) { snprintf(selectNote, sizeof selectNote, "no_outline_view"); return NO; }
|
||||
[outline reloadData];
|
||||
NSString *prefix = @"";
|
||||
NSInteger found = -1;
|
||||
for (NSString *part in [subDir pathComponents]) {
|
||||
if ([part isEqualToString:@"/"]) continue;
|
||||
prefix = [prefix stringByAppendingFormat:@"/%@", part];
|
||||
found = -1;
|
||||
for (NSInteger row = 0; row < [outline numberOfRows]; row++) {
|
||||
if ([urlPath([outline itemAtRow:row]) isEqualToString:prefix]) { found = row; break; }
|
||||
}
|
||||
if (found < 0) {
|
||||
snprintf(selectNote, sizeof selectNote, "row_not_found at=%s rows=%ld",
|
||||
[prefix UTF8String], (long)[outline numberOfRows]);
|
||||
return NO;
|
||||
}
|
||||
if (![prefix isEqualToString:subDir]) [outline expandItem:[outline itemAtRow:found]];
|
||||
}
|
||||
[outline selectRowIndexes:[NSIndexSet indexSetWithIndex:found] byExtendingSelection:NO];
|
||||
NSIndexSet *sel = [outline selectedRowIndexes];
|
||||
NSInteger selRow = [sel firstIndex] == NSNotFound ? -1 : (NSInteger)[sel firstIndex];
|
||||
id item = selRow >= 0 ? [outline itemAtRow:selRow] : nil;
|
||||
NSString *itemPath = urlPath(item);
|
||||
snprintf(selectNote, sizeof selectNote,
|
||||
"target_row=%ld selected_count=%lu selected_row=%ld item_class=%s item_path=%s",
|
||||
(long)found, (unsigned long)[sel count], (long)selRow,
|
||||
item ? class_getName([item class]) : "nil", itemPath ? [itemPath UTF8String] : "(nil)");
|
||||
return selRow == found;
|
||||
}
|
||||
|
||||
@interface Trigger : NSObject
|
||||
- (void)fire:(NSTimer *)timer;
|
||||
@end
|
||||
@implementation Trigger
|
||||
- (void)fire:(NSTimer *)timer {
|
||||
static BOOL done;
|
||||
if (done) return;
|
||||
done = YES;
|
||||
panelVisibleAtTrigger = [panel isVisible];
|
||||
if (!strcmp(mode, "cancel")) {
|
||||
press(@selector(_cancel:), "cancel");
|
||||
} else {
|
||||
if (!strcmp(mode, "open-selected")) selectionOK = selectSubfolder();
|
||||
press(@selector(_selectFile:), "open");
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
setbuf(stdout, NULL);
|
||||
if (argc == 2 && !strcmp(argv[1], "--interactive")) {
|
||||
interactive = YES;
|
||||
mode = "interactive";
|
||||
} else if (argc == 3 && !strcmp(argv[1], "--auto") &&
|
||||
(!strcmp(argv[2], "cancel") || !strcmp(argv[2], "open-selected") ||
|
||||
!strcmp(argv[2], "open-none"))) {
|
||||
mode = argv[2];
|
||||
} else {
|
||||
fprintf(stderr, "usage: %s --auto cancel|open-selected|open-none | --interactive\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
@autoreleasepool {
|
||||
[NSApplication sharedApplication];
|
||||
char templ[] = "/tmp/openpanel-check.XXXXXX";
|
||||
tempDir = [[NSString stringWithUTF8String:mkdtemp(templ)] retain];
|
||||
subDir = [[tempDir stringByAppendingPathComponent:@"subfolder"] retain];
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:subDir
|
||||
withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
|
||||
panel = [[NSOpenPanel openPanel] retain];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
[panel setCanChooseFiles:NO];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setDirectory:tempDir];
|
||||
|
||||
if (!interactive) {
|
||||
/* Independent of the run loop: a hung runModal still reports. */
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kWatchdog * NSEC_PER_SEC)),
|
||||
dispatch_get_global_queue(0, 0), ^{
|
||||
printf("OPENPANEL_CHECK mode=%s result=FAIL problems=HANG "
|
||||
"trigger=\"%s\" visible_at_trigger=%d\n",
|
||||
mode, triggerNote, panelVisibleAtTrigger);
|
||||
fflush(stdout);
|
||||
_exit(3);
|
||||
});
|
||||
Trigger *trigger = [[Trigger alloc] init];
|
||||
NSTimer *timer = [NSTimer timerWithTimeInterval:kTriggerDelay target:trigger
|
||||
selector:@selector(fire:) userInfo:nil repeats:NO];
|
||||
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
|
||||
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSModalPanelRunLoopMode];
|
||||
} else {
|
||||
printf("Interactive: pick the folder, or press Open/Cancel on the panel.\n");
|
||||
}
|
||||
|
||||
NSInteger code = [panel runModal];
|
||||
NSString *path = [[panel URL] path];
|
||||
NSArray *urls = [panel URLs];
|
||||
BOOL visible = [panel isVisible];
|
||||
NSString *shown = path ? path : @"(none)";
|
||||
|
||||
if (interactive) {
|
||||
printf("OPENPANEL_CHECK mode=interactive result=RETURNED code=%ld url=%s urls=%lu visible=%d\n",
|
||||
(long)code, [shown UTF8String], (unsigned long)[urls count], visible);
|
||||
return 0;
|
||||
}
|
||||
|
||||
NSMutableArray *problems = [NSMutableArray array];
|
||||
BOOL wantOpen = strcmp(mode, "cancel") != 0;
|
||||
NSString *wantPath = !strcmp(mode, "open-selected") ? subDir : tempDir;
|
||||
if (!panelVisibleAtTrigger) [problems addObject:@"panel_not_visible_at_trigger"];
|
||||
if (wantOpen) {
|
||||
if (code != NSOKButton) [problems addObject:@"code_not_ok"];
|
||||
if (![path isEqualToString:wantPath]) [problems addObject:@"wrong_url"];
|
||||
if ([urls count] != 1) [problems addObject:@"wrong_url_count"];
|
||||
} else if (code != NSCancelButton) {
|
||||
[problems addObject:@"code_not_cancel"];
|
||||
}
|
||||
if (visible) [problems addObject:@"still_visible"];
|
||||
if (!selectionOK) [problems addObject:@"selection_failed"];
|
||||
BOOL pass = [problems count] == 0;
|
||||
printf("OPENPANEL_CHECK mode=%s result=%s code=%ld url=%s expected_url=%s visible=%d trigger=\"%s\"%s%s%s%s%s\n",
|
||||
mode, pass ? "PASS" : "FAIL", (long)code, [shown UTF8String],
|
||||
wantOpen ? [wantPath UTF8String] : "-", visible, triggerNote,
|
||||
selectNote[0] ? " selection=\"" : "", selectNote, selectNote[0] ? "\"" : "",
|
||||
pass ? "" : " problems=",
|
||||
pass ? "" : [[problems componentsJoinedByString:@","] UTF8String]);
|
||||
fflush(stdout);
|
||||
return pass ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/* Standalone Cocoa/X11 regression: no client windows, hooks or input. */
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <AppKit/NSDisplay.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@protocol DecorationProbeDisplay
|
||||
- (void *)display;
|
||||
@end
|
||||
|
||||
@interface NSObject (DecorationProbe)
|
||||
- (unsigned long)windowHandle;
|
||||
- (void)recreateXWindowWithAlpha:(BOOL)alpha;
|
||||
@end
|
||||
|
||||
static BOOL undecorated(NSWindow *window) {
|
||||
void *xlib = dlopen("/usr/lib/native/libX11.dylib", RTLD_LAZY);
|
||||
assert(xlib);
|
||||
Atom (*intern)(Display *, const char *, Bool) = dlsym(xlib, "XInternAtom");
|
||||
int (*sync)(Display *, Bool) = dlsym(xlib, "XSync");
|
||||
int (*get)(Display *, Window, Atom, long, long, Bool, Atom,
|
||||
Atom *, int *, unsigned long *, unsigned long *, unsigned char **) =
|
||||
dlsym(xlib, "XGetWindowProperty");
|
||||
int (*freeData)(void *) = dlsym(xlib, "XFree");
|
||||
assert(intern && sync && get && freeData);
|
||||
id native = [window platformWindow];
|
||||
Display *display = (Display *)[(id<DecorationProbeDisplay>)[NSDisplay currentDisplay] display];
|
||||
sync(display, False);
|
||||
Atom type = None;
|
||||
int format = 0;
|
||||
unsigned long count = 0, remaining = 0;
|
||||
unsigned char *data = NULL;
|
||||
int status = get(display, [native windowHandle], intern(display, "_MOTIF_WM_HINTS", False),
|
||||
0, 5, False, AnyPropertyType, &type, &format, &count, &remaining, &data);
|
||||
assert(status == Success);
|
||||
BOOL result = format == 32 && count >= 3 && data &&
|
||||
(((unsigned long *)data)[0] & 2) && ((unsigned long *)data)[2] == 0;
|
||||
if (data) freeData(data);
|
||||
dlclose(xlib);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void assertDecoration(NSWindow *window, BOOL expected, const char *name) {
|
||||
BOOL actual = undecorated(window);
|
||||
printf("WINDOW_DECORATION case=%s undecorated=%d expected=%d\n", name, actual, expected);
|
||||
assert(actual == expected);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
setbuf(stdout, NULL);
|
||||
@autoreleasepool {
|
||||
[NSApplication sharedApplication];
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(20, 20, 320, 180)
|
||||
styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
|
||||
assertDecoration(window, NO, "ordinary titled window");
|
||||
[window setTitleVisibility:1];
|
||||
assertDecoration(window, NO, "hidden title alone preserves frame");
|
||||
[window setTitlebarAppearsTransparent:YES];
|
||||
assertDecoration(window, YES, "hidden and transparent title removes frame");
|
||||
[window setTitleVisibility:0];
|
||||
assertDecoration(window, NO, "visible title restores frame");
|
||||
[window setTitleVisibility:1];
|
||||
[window setTitlebarAppearsTransparent:NO];
|
||||
assertDecoration(window, NO, "opaque title restores frame");
|
||||
[window setStyleMask:NSTexturedBackgroundWindowMask];
|
||||
assertDecoration(window, YES, "untitled with extra flags");
|
||||
[window setStyleMask:NSTitledWindowMask];
|
||||
assertDecoration(window, NO, "titled style restored");
|
||||
[window setStyleMask:NSBorderlessWindowMask];
|
||||
assertDecoration(window, YES, "borderless after creation");
|
||||
[window setStyleMask:NSTitledWindowMask];
|
||||
[window setTitlebarAppearsTransparent:YES];
|
||||
[(id)[window platformWindow] recreateXWindowWithAlpha:NO];
|
||||
assertDecoration(window, YES, "recreated native window retains client chrome");
|
||||
NSWindow *deferred = [[NSWindow alloc] initWithContentRect:NSMakeRect(20, 20, 320, 180)
|
||||
styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES];
|
||||
[deferred setTitleVisibility:1];
|
||||
[deferred setTitlebarAppearsTransparent:YES];
|
||||
assertDecoration(deferred, YES, "properties set before native creation");
|
||||
puts("WINDOW_DECORATIONS_CHECK cases=10 pass=1");
|
||||
// Windows stay unmapped: the probe never changes compositor focus.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -57,7 +57,7 @@
|
||||
"revision": "c8d38d16a9f613d300157bebbab2b9501bc0c274",
|
||||
"repository": "https://github.com/darlinghq/darling-cocotron.git",
|
||||
"patch": "patches/cocotron.patch",
|
||||
"modified_files": 114,
|
||||
"modified_files": 115,
|
||||
"new_files": [
|
||||
"QuartzCore/include/QuartzCore/CATransformLayer.h",
|
||||
"AppKit/NSGeometryTrace.h"
|
||||
|
||||
Reference in new issue
Block a user