gardesk/ers / e209766

Browse files

Fix border thickness; orderOut before close in Drop

CAShapeLayer strokes are centered on the path, so to render a visible
border_width-thick ring inside the layer bounds we want
line_width = border_width and path inset = border_width/2 (not the
doubled values I had — those produced 2x-thick borders user reported).
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
e20976629aa7f8845db2e67b3160404df9af1e08
Parents
fa8412b
Tree
e77edf1

1 changed file

StatusFile+-
M src/nswindow_overlay.rs 11 4
src/nswindow_overlay.rsmodified
@@ -135,7 +135,7 @@ impl OverlayWindow {
135135
             let stroke_ref: *mut AnyObject =
136136
                 objc2_core_foundation::CFRetained::as_ptr(&stroke).as_ptr() as *mut AnyObject;
137137
             let _: () = msg_send![&*border_layer, setStrokeColor: stroke_ref];
138
-            border_layer.setLineWidth(border_width * 2.0);
138
+            border_layer.setLineWidth(border_width);
139139
             border_layer.setFrame(CGRect::new(
140140
                 CGPoint::new(0.0, 0.0),
141141
                 CGSize::new(outer_cg.size.width, outer_cg.size.height),
@@ -217,14 +217,21 @@ impl OverlayWindow {
217217
 
218218
 impl Drop for OverlayWindow {
219219
     fn drop(&mut self) {
220
+        // orderOut first so the visual disappears synchronously;
221
+        // close() afterward releases the window. Without orderOut a
222
+        // closed-but-still-onscreen window can briefly linger on
223
+        // Tahoe before Retained drops the last ref.
224
+        self.window.orderOut(None);
220225
         self.window.close();
221226
     }
222227
 }
223228
 
224229
 fn inset_for_stroke(size: CGSize, border_width: f64) -> CGRect {
225
-    // CAShapeLayer strokes centered on the path. To get the stroke
226
-    // exactly inside the layer bounds we inset by half the line width.
227
-    let half = border_width;
230
+    // CAShapeLayer strokes centered on the path. To get an exactly
231
+    // border_width-thick visible ring sitting inside the layer bounds,
232
+    // inset the path by half the line width and stroke at line_width
233
+    // = border_width.
234
+    let half = border_width / 2.0;
228235
     CGRect::new(
229236
         CGPoint::new(half, half),
230237
         CGSize::new(