File tree 7 files changed +44
-12
lines changed
7 files changed +44
-12
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ - On Wayland, windows will use server-side decorations when available.
3
4
- Added support for F16-F24 keys.
4
5
- Fixed graphical glitches when resizing on Wayland.
5
6
- On Windows, fix freezes when performing certain actions after a window resize has been triggered. Reintroduces some visual artifacts when resizing.
6
7
- Updated window manager hints under X11 to v1.5 of [ Extended Window Manager Hints] ( https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm140200472629520 ) .
8
+ - Added ` WindowBuilderExt::with_gtk_theme_variant ` to X11-specific ` WindowBuilder ` functions.
9
+ - Fixed UTF8 handling bug in X11 ` set_title ` function.
10
+ - On Windows, ` Window::set_cursor ` now applies immediately instead of requiring specific events to occur first.
7
11
- Add optional ` serde ` feature with implementations of ` Serialize ` /` Deserialize ` for DPI types, various event types, and ` WindowAttributes ` .
8
12
- Add ` PartialEq ` , ` Eq ` , and ` Hash ` implementations on public types that could have them but were missing them.
9
13
Original file line number Diff line number Diff line change @@ -219,6 +219,8 @@ pub trait WindowBuilderExt {
219
219
fn with_override_redirect ( self , override_redirect : bool ) -> WindowBuilder ;
220
220
/// Build window with `_NET_WM_WINDOW_TYPE` hint; defaults to `Normal`. Only relevant on X11.
221
221
fn with_x11_window_type ( self , x11_window_type : XWindowType ) -> WindowBuilder ;
222
+ /// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11.
223
+ fn with_gtk_theme_variant ( self , variant : String ) -> WindowBuilder ;
222
224
/// Build window with resize increment hint. Only implemented on X11.
223
225
fn with_resize_increments ( self , increments : LogicalSize ) -> WindowBuilder ;
224
226
/// Build window with base size hint. Only implemented on X11.
@@ -269,6 +271,12 @@ impl WindowBuilderExt for WindowBuilder {
269
271
self . platform_specific . base_size = Some ( base_size. into ( ) ) ;
270
272
self
271
273
}
274
+
275
+ #[ inline]
276
+ fn with_gtk_theme_variant ( mut self , variant : String ) -> WindowBuilder {
277
+ self . platform_specific . gtk_theme_variant = Some ( variant) ;
278
+ self
279
+ }
272
280
}
273
281
274
282
/// Additional methods on `MonitorId` that are specific to Linux.
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
45
45
pub class : Option < ( String , String ) > ,
46
46
pub override_redirect : bool ,
47
47
pub x11_window_type : x11:: util:: WindowType ,
48
+ pub gtk_theme_variant : Option < String > ,
48
49
}
49
50
50
51
lazy_static ! (
Original file line number Diff line number Diff line change @@ -69,13 +69,10 @@ impl Window {
69
69
70
70
let window_store = evlp. store . clone ( ) ;
71
71
let my_surface = surface. clone ( ) ;
72
- let mut frame = SWindow :: < BasicFrame > :: init (
72
+ let mut frame = SWindow :: < BasicFrame > :: init_from_env (
73
+ & evlp. env ,
73
74
surface. clone ( ) ,
74
75
( width, height) ,
75
- & evlp. env . compositor ,
76
- & evlp. env . subcompositor ,
77
- & evlp. env . shm ,
78
- & evlp. env . shell ,
79
76
move |event, ( ) | match event {
80
77
WEvent :: Configure { new_size, .. } => {
81
78
let mut store = window_store. lock ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -272,6 +272,10 @@ impl UnownedWindow {
272
272
window. set_window_type ( pl_attribs. x11_window_type ) . queue ( ) ;
273
273
}
274
274
275
+ if let Some ( variant) = pl_attribs. gtk_theme_variant {
276
+ window. set_gtk_theme_variant ( variant) . queue ( ) ;
277
+ }
278
+
275
279
// set size hints
276
280
{
277
281
let mut min_dimensions = window_attrs. min_dimensions ;
@@ -457,6 +461,19 @@ impl UnownedWindow {
457
461
)
458
462
}
459
463
464
+ fn set_gtk_theme_variant ( & self , variant : String ) -> util:: Flusher {
465
+ let hint_atom = unsafe { self . xconn . get_atom_unchecked ( b"_GTK_THEME_VARIANT\0 " ) } ;
466
+ let utf8_atom = unsafe { self . xconn . get_atom_unchecked ( b"UTF8_STRING\0 " ) } ;
467
+ let variant = CString :: new ( variant) . expect ( "`_GTK_THEME_VARIANT` contained null byte" ) ;
468
+ self . xconn . change_property (
469
+ self . xwindow ,
470
+ hint_atom,
471
+ utf8_atom,
472
+ util:: PropMode :: Replace ,
473
+ variant. as_bytes ( ) ,
474
+ )
475
+ }
476
+
460
477
#[ inline]
461
478
pub fn set_urgent ( & self , is_urgent : bool ) {
462
479
let mut wm_hints = self . xconn . get_wm_hints ( self . xwindow ) . expect ( "`XGetWMHints` failed" ) ;
@@ -583,7 +600,7 @@ impl UnownedWindow {
583
600
wm_name_atom,
584
601
utf8_atom,
585
602
util:: PropMode :: Replace ,
586
- title. as_bytes_with_nul ( ) ,
603
+ title. as_bytes ( ) ,
587
604
)
588
605
}
589
606
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ unsafe impl Send for PlatformSpecificWindowBuilderAttributes {}
18
18
unsafe impl Sync for PlatformSpecificWindowBuilderAttributes { }
19
19
20
20
// Cursor name in UTF-16. Used to set cursor in `WM_SETCURSOR`.
21
- #[ derive( Debug , Clone ) ]
21
+ #[ derive( Debug , Clone , Copy ) ]
22
22
pub struct Cursor ( pub * const winapi:: ctypes:: wchar_t ) ;
23
23
unsafe impl Send for Cursor { }
24
24
unsafe impl Sync for Cursor { }
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ impl Window {
301
301
302
302
#[ inline]
303
303
pub fn set_cursor ( & self , cursor : MouseCursor ) {
304
- let cursor_id = match cursor {
304
+ let cursor_id = Cursor ( match cursor {
305
305
MouseCursor :: Arrow | MouseCursor :: Default => winuser:: IDC_ARROW ,
306
306
MouseCursor :: Hand => winuser:: IDC_HAND ,
307
307
MouseCursor :: Crosshair => winuser:: IDC_CROSS ,
@@ -321,10 +321,15 @@ impl Window {
321
321
MouseCursor :: Progress => winuser:: IDC_APPSTARTING ,
322
322
MouseCursor :: Help => winuser:: IDC_HELP ,
323
323
_ => winuser:: IDC_ARROW , // use arrow for the missing cases.
324
- } ;
325
-
326
- let mut cur = self . window_state . lock ( ) . unwrap ( ) ;
327
- cur. cursor = Cursor ( cursor_id) ;
324
+ } ) ;
325
+ self . window_state . lock ( ) . unwrap ( ) . cursor = cursor_id;
326
+ self . events_loop_proxy . execute_in_thread ( move |_| unsafe {
327
+ let cursor = winuser:: LoadCursorW (
328
+ ptr:: null_mut ( ) ,
329
+ cursor_id. 0 ,
330
+ ) ;
331
+ winuser:: SetCursor ( cursor) ;
332
+ } ) ;
328
333
}
329
334
330
335
unsafe fn cursor_is_grabbed ( & self ) -> Result < bool , String > {
You can’t perform that action at this time.
0 commit comments