@zakim24/electron-liquid-glass 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
package/src/glass_effect.mm
CHANGED
|
@@ -69,20 +69,27 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
|
|
|
69
69
|
__block int resultId = -1;
|
|
70
70
|
|
|
71
71
|
RUN_ON_MAIN(^{
|
|
72
|
-
NSView *
|
|
73
|
-
if (!
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
72
|
+
NSView *contentView = *reinterpret_cast<NSView **>(buffer);
|
|
73
|
+
if (!contentView) return;
|
|
74
|
+
|
|
75
|
+
// CRITICAL: Get the contentView's superview (the window's themeFrame)
|
|
76
|
+
// We add the glass effect there, BELOW the contentView, so it doesn't block mouse events
|
|
77
|
+
NSView *windowFrame = contentView.superview;
|
|
78
|
+
if (!windowFrame) {
|
|
79
|
+
// Fallback to contentView if no superview (shouldn't happen)
|
|
80
|
+
windowFrame = contentView;
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
// Remove previous glass and background views (if any)
|
|
79
|
-
|
|
84
|
+
// We associate with contentView for consistency
|
|
85
|
+
NSView *oldGlass = objc_getAssociatedObject(contentView, kGlassEffectKey);
|
|
80
86
|
if (oldGlass) [oldGlass removeFromSuperview];
|
|
81
87
|
|
|
82
|
-
NSView *oldBackground = objc_getAssociatedObject(
|
|
88
|
+
NSView *oldBackground = objc_getAssociatedObject(contentView, kBackgroundViewKey);
|
|
83
89
|
if (oldBackground) [oldBackground removeFromSuperview];
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
// Use contentView's frame relative to windowFrame
|
|
92
|
+
NSRect bounds = contentView.frame;
|
|
86
93
|
|
|
87
94
|
NSBox *backgroundView = nil;
|
|
88
95
|
|
|
@@ -123,29 +130,27 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
|
|
|
123
130
|
// Ensure autoresize if we created a private glass view too
|
|
124
131
|
glass.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
125
132
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// Also set on background view if present
|
|
132
|
-
if (backgroundView && [backgroundView respondsToSelector:@selector(setIgnoresMouseEvents:)]) {
|
|
133
|
-
[(id)backgroundView setIgnoresMouseEvents:YES];
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Add the glass view (positioned relative to background view if opaque, or below everything if not)
|
|
133
|
+
// Make the glass view a layer-backed view for better rendering
|
|
134
|
+
glass.wantsLayer = YES;
|
|
135
|
+
|
|
136
|
+
// Add the glass view to the windowFrame, positioned BELOW the contentView
|
|
137
|
+
// This ensures events go to contentView first, not the glass
|
|
137
138
|
if (opaque && backgroundView) {
|
|
138
|
-
|
|
139
|
+
// Background at very bottom, then glass, then contentView on top
|
|
140
|
+
backgroundView.wantsLayer = YES;
|
|
141
|
+
[windowFrame addSubview:backgroundView positioned:NSWindowBelow relativeTo:contentView];
|
|
142
|
+
[windowFrame addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
|
|
139
143
|
} else {
|
|
140
|
-
|
|
144
|
+
// Glass below contentView
|
|
145
|
+
[windowFrame addSubview:glass positioned:NSWindowBelow relativeTo:contentView];
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
// Associate views with
|
|
144
|
-
objc_setAssociatedObject(
|
|
148
|
+
// Associate views with contentView for cleanup (so we can find them later)
|
|
149
|
+
objc_setAssociatedObject(contentView, kGlassEffectKey, glass, OBJC_ASSOCIATION_RETAIN);
|
|
145
150
|
if (backgroundView) {
|
|
146
|
-
objc_setAssociatedObject(
|
|
151
|
+
objc_setAssociatedObject(contentView, kBackgroundViewKey, backgroundView, OBJC_ASSOCIATION_RETAIN);
|
|
147
152
|
} else {
|
|
148
|
-
objc_setAssociatedObject(
|
|
153
|
+
objc_setAssociatedObject(contentView, kBackgroundViewKey, nil, OBJC_ASSOCIATION_ASSIGN);
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
|