@zakim24/electron-liquid-glass 1.1.5 → 1.1.6
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,27 +69,20 @@ 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
|
-
|
|
77
|
-
NSView *windowFrame = contentView.superview;
|
|
78
|
-
if (!windowFrame) {
|
|
79
|
-
// Fallback to contentView if no superview (shouldn't happen)
|
|
80
|
-
windowFrame = contentView;
|
|
81
|
-
}
|
|
72
|
+
NSView *rootView = *reinterpret_cast<NSView **>(buffer);
|
|
73
|
+
if (!rootView) return;
|
|
74
|
+
|
|
75
|
+
// Find the proper container - avoid NSThemeFrame
|
|
76
|
+
NSView *container = rootView;
|
|
82
77
|
|
|
83
78
|
// Remove previous glass and background views (if any)
|
|
84
|
-
|
|
85
|
-
NSView *oldGlass = objc_getAssociatedObject(contentView, kGlassEffectKey);
|
|
79
|
+
NSView *oldGlass = objc_getAssociatedObject(container, kGlassEffectKey);
|
|
86
80
|
if (oldGlass) [oldGlass removeFromSuperview];
|
|
87
81
|
|
|
88
|
-
NSView *oldBackground = objc_getAssociatedObject(
|
|
82
|
+
NSView *oldBackground = objc_getAssociatedObject(container, kBackgroundViewKey);
|
|
89
83
|
if (oldBackground) [oldBackground removeFromSuperview];
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
NSRect bounds = contentView.frame;
|
|
85
|
+
NSRect bounds = container.bounds;
|
|
93
86
|
|
|
94
87
|
NSBox *backgroundView = nil;
|
|
95
88
|
|
|
@@ -111,7 +104,9 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
|
|
|
111
104
|
backgroundView.fillColor = [NSColor windowBackgroundColor];
|
|
112
105
|
backgroundView.wantsLayer = YES;
|
|
113
106
|
|
|
114
|
-
|
|
107
|
+
|
|
108
|
+
// Add the background view first (bottom layer)
|
|
109
|
+
[container addSubview:backgroundView positioned:NSWindowBelow relativeTo:nil];
|
|
115
110
|
}
|
|
116
111
|
} else {
|
|
117
112
|
/**
|
|
@@ -127,28 +122,20 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
|
|
|
127
122
|
|
|
128
123
|
// Ensure autoresize if we created a private glass view too
|
|
129
124
|
glass.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
glass.wantsLayer = YES;
|
|
133
|
-
|
|
134
|
-
// Add the glass view to the windowFrame, positioned BELOW the contentView
|
|
135
|
-
// This ensures events go to contentView first, not the glass
|
|
125
|
+
|
|
126
|
+
// Add the glass view (positioned relative to background view if opaque, or below everything if not)
|
|
136
127
|
if (opaque && backgroundView) {
|
|
137
|
-
|
|
138
|
-
backgroundView.wantsLayer = YES;
|
|
139
|
-
[windowFrame addSubview:backgroundView positioned:NSWindowBelow relativeTo:contentView];
|
|
140
|
-
[windowFrame addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
|
|
128
|
+
[container addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
|
|
141
129
|
} else {
|
|
142
|
-
|
|
143
|
-
[windowFrame addSubview:glass positioned:NSWindowBelow relativeTo:contentView];
|
|
130
|
+
[container addSubview:glass positioned:NSWindowBelow relativeTo:nil];
|
|
144
131
|
}
|
|
145
132
|
|
|
146
|
-
// Associate views with
|
|
147
|
-
objc_setAssociatedObject(
|
|
133
|
+
// Associate views with the container for cleanup
|
|
134
|
+
objc_setAssociatedObject(container, kGlassEffectKey, glass, OBJC_ASSOCIATION_RETAIN);
|
|
148
135
|
if (backgroundView) {
|
|
149
|
-
objc_setAssociatedObject(
|
|
136
|
+
objc_setAssociatedObject(container, kBackgroundViewKey, backgroundView, OBJC_ASSOCIATION_RETAIN);
|
|
150
137
|
} else {
|
|
151
|
-
objc_setAssociatedObject(
|
|
138
|
+
objc_setAssociatedObject(container, kBackgroundViewKey, nil, OBJC_ASSOCIATION_ASSIGN);
|
|
152
139
|
}
|
|
153
140
|
|
|
154
141
|
|