@@ -124,3 +124,45 @@ fn macos_is_in_app_bundle(canonicalized_exec_dir: impl AsRef<Path>) -> bool {
124124 }
125125 } )
126126}
127+
128+ #[ cfg( target_os = "windows" ) ]
129+ /// Workaround for windows for shadow that intercept mouse events outside of the
130+ /// actual window. See https://github.com/flxzt/rnote/issues/1372
131+ ///
132+ /// Taken from gaphor
133+ /// See commment from https://github.com/gaphor/gaphor/blob/a7b35712b166a38b78933a79613eab330f7bd885/gaphor/ui/styling-windows.css
134+ /// and https://gitlab.gnome.org/GNOME/gtk/-/issues/6255#note_1952796
135+ pub fn window_styling_workaround ( ) -> anyhow:: Result < ( ) > {
136+ use gtk4:: { gdk, style_context_add_provider_for_display} ;
137+
138+ // gtk needs to be initialized for the style provider to work
139+ gtk4:: init ( ) ?;
140+
141+ let default_display = gdk:: Display :: default ( ) ;
142+ let style_provider = gtk4:: CssProvider :: new ( ) ;
143+ style_provider. load_from_string (
144+ "
145+ .csd {
146+ box-shadow: 0 3px 9px 1px alpha(black, 0.35),
147+ 0 0 0 1px alpha(black, 0.18);
148+ }
149+
150+ .csd:backdrop {
151+ box-shadow: 0 3px 9px 1px transparent,
152+ 0 2px 6px 2px alpha(black, 1),
153+ 0 0 0 1px alpha(black, 0.06);
154+ }" ,
155+ ) ;
156+
157+ match default_display {
158+ Some ( display) => {
159+ style_context_add_provider_for_display (
160+ & display,
161+ & style_provider,
162+ gtk4:: STYLE_PROVIDER_PRIORITY_APPLICATION ,
163+ ) ;
164+ Ok ( ( ) )
165+ }
166+ None => Err ( anyhow:: anyhow!( "Could not find a default display" ) ) ,
167+ }
168+ }
0 commit comments