mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
Fix X11 decorations for client-drawn Cocoa windows
Synchronize Motif decoration hints on style and titlebar-property changes, including native-window recreation and restoring ordinary WM decorations. Add a ten-case standalone Cocoa/X11 regression probe and document validation on KWin/Xwayland.
This commit is contained in:
1 parent
337aa79c27
commit
41da6d9e0a
4 files changed
+179
-35
No files matched your search
@@ -119,6 +119,33 @@ 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.
|
||||
|
||||
### 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.
|
||||
|
||||
### 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.
|
||||
|
||||
+55
-34
@@ -1946,7 +1946,7 @@ index d545120a..79760f47 100644
|
||||
|
||||
- (BOOL) inLiveResize {
|
||||
return _isInLiveResize;
|
||||
@@ -1561,6 +1766,117 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -1561,6 +1766,123 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
return point;
|
||||
}
|
||||
|
||||
@@ -1976,7 +1976,10 @@ index d545120a..79760f47 100644
|
||||
+}
|
||||
+
|
||||
+- (void) setTitlebarAppearsTransparent: (BOOL) value {
|
||||
+ if (_titlebarAppearsTransparent == value)
|
||||
+ return;
|
||||
+ _titlebarAppearsTransparent = value;
|
||||
+ [_platformWindow setStyleMask: _styleMask];
|
||||
+}
|
||||
+
|
||||
+- (NSInteger) titleVisibility {
|
||||
@@ -1984,7 +1987,10 @@ index d545120a..79760f47 100644
|
||||
+}
|
||||
+
|
||||
+- (void) setTitleVisibility: (NSInteger) value {
|
||||
+ if (_titleVisibility == value)
|
||||
+ return;
|
||||
+ _titleVisibility = value;
|
||||
+ [_platformWindow setStyleMask: _styleMask];
|
||||
+}
|
||||
+
|
||||
+- (BOOL) movableByWindowBackground {
|
||||
@@ -2064,7 +2070,7 @@ index d545120a..79760f47 100644
|
||||
- (NSRect) frameRectForContentRect: (NSRect) contentRect {
|
||||
// hasMainMenu is an instance method so we can't just use the class method
|
||||
// frameRectForContentRect:styleMask:
|
||||
@@ -1580,6 +1896,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -1580,6 +1902,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
}
|
||||
|
||||
- (NSRect) contentRectForFrameRect: (NSRect) frameRect {
|
||||
@@ -2075,7 +2081,7 @@ index d545120a..79760f47 100644
|
||||
NSRect result = [[NSDisplay currentDisplay] insetRect: frameRect
|
||||
forNativeWindowBorderWithStyle: [self styleMask]];
|
||||
|
||||
@@ -2155,6 +2475,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2155,6 +2481,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
- (void) orderWindow: (NSWindowOrderingMode) place
|
||||
relativeTo: (NSInteger) relativeTo
|
||||
{
|
||||
@@ -2083,7 +2089,7 @@ index d545120a..79760f47 100644
|
||||
// The move notifications are sent under unknown conditions around
|
||||
// orderFront: in the Apple AppKit, we do them all the time here until it's
|
||||
// figured out. I suspect it is a side effect of off-screen windows being at
|
||||
@@ -2208,6 +2529,8 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2208,6 +2535,8 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2092,7 +2098,7 @@ index d545120a..79760f47 100644
|
||||
[self postNotificationName: NSWindowDidMoveNotification];
|
||||
}
|
||||
|
||||
@@ -2257,6 +2580,12 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2257,6 +2586,12 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
}
|
||||
|
||||
- (void) sendEvent: (NSEvent *) event {
|
||||
@@ -2105,7 +2111,7 @@ index d545120a..79760f47 100644
|
||||
// Some events can cause our window to be destroyed
|
||||
// So make sure self lives at least through this current run loop...
|
||||
[[self retain] autorelease];
|
||||
@@ -2300,6 +2629,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2300,6 +2635,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
|
||||
case NSLeftMouseDown: {
|
||||
NSView *view = [_backgroundView hitTest: [event locationInWindow]];
|
||||
@@ -2116,7 +2122,7 @@ index d545120a..79760f47 100644
|
||||
|
||||
if ([view acceptsFirstResponder]) {
|
||||
if ([view needsPanelToBecomeKey]) {
|
||||
@@ -2307,6 +2640,27 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2307,6 +2646,27 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2144,7 +2150,7 @@ index d545120a..79760f47 100644
|
||||
// Event goes to view, not first responder.
|
||||
[view mouseDown: event];
|
||||
_mouseDownLocationInWindow = [event locationInWindow];
|
||||
@@ -2330,6 +2684,31 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2330,6 +2690,31 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
_mouseDownLocationInWindow = NSMakePoint(NAN, NAN);
|
||||
break;
|
||||
|
||||
@@ -2176,7 +2182,7 @@ index d545120a..79760f47 100644
|
||||
case NSMouseMoved: {
|
||||
NSView *hit = [_backgroundView hitTest: [event locationInWindow]];
|
||||
|
||||
@@ -2478,6 +2857,197 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2478,6 +2863,197 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
_draggedTypes = nil;
|
||||
}
|
||||
|
||||
@@ -2374,7 +2380,7 @@ index d545120a..79760f47 100644
|
||||
- (void) dragImage: (NSImage *) image
|
||||
at: (NSPoint) location
|
||||
offset: (NSSize) offset
|
||||
@@ -2486,6 +3056,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2486,6 +3062,10 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
source: (id) source
|
||||
slideBack: (BOOL) slideBack
|
||||
{
|
||||
@@ -2385,7 +2391,7 @@ index d545120a..79760f47 100644
|
||||
[[NSDraggingManager draggingManager] dragImage: image
|
||||
at: location
|
||||
offset: offset
|
||||
@@ -2536,6 +3110,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -2536,6 +3116,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
} else {
|
||||
[[self platformWindow] hideWindow];
|
||||
}
|
||||
@@ -2393,7 +2399,7 @@ index d545120a..79760f47 100644
|
||||
}
|
||||
|
||||
- (void) orderFront: (id) sender {
|
||||
@@ -3064,6 +3639,13 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -3064,6 +3645,13 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
if (didSize) {
|
||||
// Don't redraw everything unless we really have to.
|
||||
[_backgroundView setFrameSize: _frame.size];
|
||||
@@ -2407,7 +2413,7 @@ index d545120a..79760f47 100644
|
||||
[_backgroundView setNeedsDisplay: YES];
|
||||
[self resetCursorRects];
|
||||
[self saveFrameUsingName: _autosaveFrameName];
|
||||
@@ -3260,8 +3842,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -3260,8 +3848,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
mouseWasInside && !mouseIsInside) {
|
||||
[exited addObject: area];
|
||||
}
|
||||
@@ -2417,7 +2423,7 @@ index d545120a..79760f47 100644
|
||||
[moved addObject: area];
|
||||
}
|
||||
if (options & NSTrackingCursorUpdate && !mouseWasInside &&
|
||||
@@ -3459,7 +4040,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
@@ -3459,7 +4046,7 @@ static BOOL _allowsAutomaticWindowTabbing;
|
||||
}
|
||||
|
||||
- (CGSubWindow *) _createSubWindowWithFrame: (CGRect) frame {
|
||||
@@ -5191,7 +5197,7 @@ index f4925b66..730d4692 100644
|
||||
|
||||
_isModal = [delegate isSheet] || [NSApp modalWindow] == delegate;
|
||||
// FIXME: There should be no need for this.
|
||||
@@ -254,7 +396,8 @@ static NSData *makeWindowIcon() {
|
||||
@@ -254,19 +396,96 @@ static NSData *makeWindowIcon() {
|
||||
XNFocusWindow, _window,
|
||||
NULL);
|
||||
|
||||
@@ -5201,7 +5207,10 @@ index f4925b66..730d4692 100644
|
||||
|
||||
[(X11Display *) [NSDisplay currentDisplay] setWindow: self forID: _window];
|
||||
|
||||
@@ -265,8 +408,88 @@ static NSData *makeWindowIcon() {
|
||||
- // FIXME: Move this call into setStyleMaskInternal below!
|
||||
- if (_styleMask == NSBorderlessWindowMask) {
|
||||
- [[self class] removeDecorationForWindow: _window onDisplay: _display];
|
||||
- }
|
||||
[self setStyleMaskInternal: _styleMask force: YES];
|
||||
|
||||
[self setWindowIcon];
|
||||
@@ -5291,7 +5300,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
|
||||
- (void) dealloc {
|
||||
@@ -279,24 +502,30 @@ static NSData *makeWindowIcon() {
|
||||
@@ -279,24 +498,30 @@ static NSData *makeWindowIcon() {
|
||||
return _styleMask;
|
||||
}
|
||||
|
||||
@@ -5338,7 +5347,7 @@ index f4925b66..730d4692 100644
|
||||
if (!_mapped) {
|
||||
long states[2];
|
||||
int states_cnt = 0;
|
||||
@@ -304,7 +533,7 @@ static NSData *makeWindowIcon() {
|
||||
@@ -304,7 +529,7 @@ static NSData *makeWindowIcon() {
|
||||
states[states_cnt++] =
|
||||
(long) XInternAtom(_display, "_NET_WM_STATE_MODAL", False);
|
||||
}
|
||||
@@ -5347,7 +5356,7 @@ index f4925b66..730d4692 100644
|
||||
states[states_cnt++] = (long) XInternAtom(
|
||||
_display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
}
|
||||
@@ -312,14 +541,13 @@ static NSData *makeWindowIcon() {
|
||||
@@ -312,14 +537,13 @@ static NSData *makeWindowIcon() {
|
||||
XInternAtom(_display, "_NET_WM_STATE", False), XA_ATOM,
|
||||
32, PropModeReplace, (const unsigned char *) states,
|
||||
states_cnt);
|
||||
@@ -5364,7 +5373,7 @@ index f4925b66..730d4692 100644
|
||||
event.data.l[1] =
|
||||
(long) XInternAtom(_display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
event.data.l[3] = 1;
|
||||
@@ -327,6 +555,35 @@ static NSData *makeWindowIcon() {
|
||||
@@ -327,6 +551,47 @@ static NSData *makeWindowIcon() {
|
||||
SubstructureNotifyMask | SubstructureRedirectMask,
|
||||
(XEvent *) &event);
|
||||
}
|
||||
@@ -5373,6 +5382,18 @@ index f4925b66..730d4692 100644
|
||||
+}
|
||||
+
|
||||
+- (void) setStyleMaskInternal: (NSUInteger) mask force: (BOOL) force {
|
||||
+ // Cocoa chrome may change after the native window already exists. A hidden,
|
||||
+ // transparent titlebar is client-drawn chrome, even with the titled bit set.
|
||||
+ // NSWindowTitleHidden is 1; this SDK exposes titleVisibility as NSInteger.
|
||||
+ BOOL clientChrome = [_delegate titlebarAppearsTransparent] &&
|
||||
+ [_delegate titleVisibility] == 1;
|
||||
+ if (!(mask & NSTitledWindowMask) || clientChrome) {
|
||||
+ [[self class] removeDecorationForWindow: _window onDisplay: _display];
|
||||
+ } else {
|
||||
+ // Return decoration ownership to the WM on the reverse transition.
|
||||
+ XDeleteProperty(_display, _window,
|
||||
+ XInternAtom(_display, "_MOTIF_WM_HINTS", False));
|
||||
+ }
|
||||
+ if (force || (mask & NSWindowStyleMaskResizable) !=
|
||||
+ (_styleMask & NSWindowStyleMaskResizable)) {
|
||||
+ XSizeHints *sh = XAllocSizeHints();
|
||||
@@ -5400,7 +5421,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
|
||||
- (void) setStyleMask: (NSUInteger) mask {
|
||||
@@ -338,7 +595,6 @@ static NSData *makeWindowIcon() {
|
||||
@@ -338,7 +603,6 @@ static NSData *makeWindowIcon() {
|
||||
}
|
||||
|
||||
+ (void) removeDecorationForWindow: (Window) w onDisplay: (Display *) dpy {
|
||||
@@ -5408,7 +5429,7 @@ index f4925b66..730d4692 100644
|
||||
struct {
|
||||
unsigned long flags;
|
||||
unsigned long functions;
|
||||
@@ -356,8 +612,14 @@ static NSData *makeWindowIcon() {
|
||||
@@ -356,8 +620,14 @@ static NSData *makeWindowIcon() {
|
||||
|
||||
- (void) ensureMapped {
|
||||
if (!_mapped) {
|
||||
@@ -5423,7 +5444,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,15 +639,27 @@ static NSData *makeWindowIcon() {
|
||||
@@ -377,15 +647,27 @@ static NSData *makeWindowIcon() {
|
||||
- (void) syncDelegateProperties {
|
||||
long mask = KeyPressMask | KeyReleaseMask | ExposureMask |
|
||||
StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
|
||||
@@ -5456,7 +5477,7 @@ index f4925b66..730d4692 100644
|
||||
// TODO: background color
|
||||
}
|
||||
|
||||
@@ -393,6 +667,28 @@ static NSData *makeWindowIcon() {
|
||||
@@ -393,6 +675,28 @@ static NSData *makeWindowIcon() {
|
||||
// This is essentially dealloc; we release our contexts
|
||||
// and windows, but unlike dealloc, this method can be called
|
||||
// several times, so set everything to nil/NULL/0.
|
||||
@@ -5485,7 +5506,7 @@ index f4925b66..730d4692 100644
|
||||
[_context release];
|
||||
_context = nil;
|
||||
|
||||
@@ -421,6 +717,392 @@ static NSData *makeWindowIcon() {
|
||||
@@ -421,6 +725,392 @@ static NSData *makeWindowIcon() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5878,7 +5899,7 @@ index f4925b66..730d4692 100644
|
||||
- (Window) windowHandle {
|
||||
return _window;
|
||||
}
|
||||
@@ -470,14 +1152,32 @@ static NSData *makeWindowIcon() {
|
||||
@@ -470,14 +1160,32 @@ static NSData *makeWindowIcon() {
|
||||
const char *text = [title cString];
|
||||
XStringListToTextProperty((char **) &text, 1, &prop);
|
||||
XSetWMName(_display, _window, &prop);
|
||||
@@ -5912,7 +5933,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
|
||||
- (void) setHasShadow: (BOOL) value {
|
||||
@@ -488,6 +1188,25 @@ static NSData *makeWindowIcon() {
|
||||
@@ -488,6 +1196,25 @@ static NSData *makeWindowIcon() {
|
||||
_level = value;
|
||||
}
|
||||
|
||||
@@ -5938,7 +5959,7 @@ index f4925b66..730d4692 100644
|
||||
- (void) setOpaque: (BOOL) value {
|
||||
_isOpaque = value;
|
||||
}
|
||||
@@ -543,6 +1262,21 @@ static NSData *makeWindowIcon() {
|
||||
@@ -543,6 +1270,21 @@ static NSData *makeWindowIcon() {
|
||||
- (void) makeKey {
|
||||
[self ensureMapped];
|
||||
XRaiseWindow(_display, _window);
|
||||
@@ -5960,7 +5981,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
|
||||
- (void) makeMain {
|
||||
@@ -559,7 +1293,29 @@ static NSData *makeWindowIcon() {
|
||||
@@ -559,7 +1301,29 @@ static NSData *makeWindowIcon() {
|
||||
XRaiseWindow(_display, _window);
|
||||
}
|
||||
|
||||
@@ -5990,7 +6011,7 @@ index f4925b66..730d4692 100644
|
||||
Atom wmState = XInternAtom(_display, "_NET_WM_STATE", FALSE);
|
||||
Atom hiddenState = XInternAtom(_display, "_NET_WM_STATE_HIDDEN", FALSE);
|
||||
|
||||
@@ -593,8 +1349,10 @@ static NSData *makeWindowIcon() {
|
||||
@@ -593,8 +1357,10 @@ static NSData *makeWindowIcon() {
|
||||
if (_cglContext == NULL) {
|
||||
CGLError error;
|
||||
|
||||
@@ -6003,7 +6024,7 @@ index f4925b66..730d4692 100644
|
||||
NSLog(@"CGLCreateContext failed at %s %d with error %d", __FILE__,
|
||||
__LINE__, error);
|
||||
|
||||
@@ -615,6 +1373,12 @@ static NSData *makeWindowIcon() {
|
||||
@@ -615,6 +1381,12 @@ static NSData *makeWindowIcon() {
|
||||
}
|
||||
|
||||
- (void) openGLFlushBuffer {
|
||||
@@ -6016,7 +6037,7 @@ index f4925b66..730d4692 100644
|
||||
CGLError error;
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
@@ -652,7 +1416,7 @@ static NSData *makeWindowIcon() {
|
||||
@@ -652,7 +1424,7 @@ static NSData *makeWindowIcon() {
|
||||
}
|
||||
|
||||
- (O2Rect) frame {
|
||||
@@ -6025,7 +6046,7 @@ index f4925b66..730d4692 100644
|
||||
}
|
||||
|
||||
static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) {
|
||||
@@ -666,6 +1430,7 @@ static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) {
|
||||
@@ -666,6 +1438,7 @@ static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) {
|
||||
}
|
||||
|
||||
- (void) frameChanged {
|
||||
@@ -6033,7 +6054,7 @@ index f4925b66..730d4692 100644
|
||||
XErrorHandler previousHandler = XSetErrorHandler(ignoreBadWindow);
|
||||
@try {
|
||||
Window root, parent;
|
||||
@@ -710,19 +1475,13 @@ static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) {
|
||||
@@ -710,19 +1483,13 @@ static int ignoreBadWindow(Display *display, XErrorEvent *errorEvent) {
|
||||
[_deviceDictionary addEntriesFromDictionary: entries];
|
||||
}
|
||||
|
||||
|
||||
@@ -48,4 +48,14 @@ 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)
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user