@zakim24/electron-liquid-glass 1.1.3 → 1.1.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakim24/electron-liquid-glass",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "macOS glass / vibrancy wrapper for Electron BrowserWindow",
5
5
  "repository": {
6
6
  "type": "git",
Binary file
@@ -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 *rootView = *reinterpret_cast<NSView **>(buffer);
73
- if (!rootView) return;
74
-
75
- // Find the proper container - avoid NSThemeFrame
76
- NSView *container = rootView;
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
- NSView *oldGlass = objc_getAssociatedObject(container, kGlassEffectKey);
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(container, kBackgroundViewKey);
88
+ NSView *oldBackground = objc_getAssociatedObject(contentView, kBackgroundViewKey);
83
89
  if (oldBackground) [oldBackground removeFromSuperview];
84
90
 
85
- NSRect bounds = container.bounds;
91
+ // Use contentView's frame relative to windowFrame
92
+ NSRect bounds = contentView.frame;
86
93
 
87
94
  NSBox *backgroundView = nil;
88
95
 
@@ -104,9 +111,7 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
104
111
  backgroundView.fillColor = [NSColor windowBackgroundColor];
105
112
  backgroundView.wantsLayer = YES;
106
113
 
107
-
108
- // Add the background view first (bottom layer)
109
- [container addSubview:backgroundView positioned:NSWindowBelow relativeTo:nil];
114
+ // Note: backgroundView will be added to windowFrame later, below contentView
110
115
  }
111
116
  } else {
112
117
  /**
@@ -123,38 +128,27 @@ extern "C" int AddGlassEffectView(unsigned char *buffer, bool opaque) {
123
128
  // Ensure autoresize if we created a private glass view too
124
129
  glass.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
125
130
 
126
- // Make the glass view click-through by setting it to not accept any mouse events
127
- // NSView doesn't have setIgnoresMouseEvents, so we use layer properties
131
+ // Make the glass view a layer-backed view for better rendering
128
132
  glass.wantsLayer = YES;
129
133
 
130
- // Get the first existing subview to position our glass behind it
131
- NSView *firstSubview = container.subviews.firstObject;
132
-
133
- // Add the glass view (positioned BELOW all existing content to not block events)
134
+ // Add the glass view to the windowFrame, positioned BELOW the contentView
135
+ // This ensures events go to contentView first, not the glass
134
136
  if (opaque && backgroundView) {
135
- // Background at very bottom, glass above it, content on top
136
- if (firstSubview) {
137
- [container addSubview:backgroundView positioned:NSWindowBelow relativeTo:firstSubview];
138
- [container addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
139
- } else {
140
- [container addSubview:backgroundView positioned:NSWindowBelow relativeTo:nil];
141
- [container addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
142
- }
137
+ // Background at very bottom, then glass, then contentView on top
138
+ backgroundView.wantsLayer = YES;
139
+ [windowFrame addSubview:backgroundView positioned:NSWindowBelow relativeTo:contentView];
140
+ [windowFrame addSubview:glass positioned:NSWindowAbove relativeTo:backgroundView];
143
141
  } else {
144
- // Glass at very bottom, content on top
145
- if (firstSubview) {
146
- [container addSubview:glass positioned:NSWindowBelow relativeTo:firstSubview];
147
- } else {
148
- [container addSubview:glass positioned:NSWindowBelow relativeTo:nil];
149
- }
142
+ // Glass below contentView
143
+ [windowFrame addSubview:glass positioned:NSWindowBelow relativeTo:contentView];
150
144
  }
151
145
 
152
- // Associate views with the container for cleanup
153
- objc_setAssociatedObject(container, kGlassEffectKey, glass, OBJC_ASSOCIATION_RETAIN);
146
+ // Associate views with contentView for cleanup (so we can find them later)
147
+ objc_setAssociatedObject(contentView, kGlassEffectKey, glass, OBJC_ASSOCIATION_RETAIN);
154
148
  if (backgroundView) {
155
- objc_setAssociatedObject(container, kBackgroundViewKey, backgroundView, OBJC_ASSOCIATION_RETAIN);
149
+ objc_setAssociatedObject(contentView, kBackgroundViewKey, backgroundView, OBJC_ASSOCIATION_RETAIN);
156
150
  } else {
157
- objc_setAssociatedObject(container, kBackgroundViewKey, nil, OBJC_ASSOCIATION_ASSIGN);
151
+ objc_setAssociatedObject(contentView, kBackgroundViewKey, nil, OBJC_ASSOCIATION_ASSIGN);
158
152
  }
159
153
 
160
154