44
55#[ cfg( window_create) ]
66use crate :: Manager ;
7- use crate :: { api:: config:: WindowConfig , endpoints:: InvokeResponse , Params , Window } ;
7+ use crate :: {
8+ api:: config:: WindowConfig ,
9+ endpoints:: InvokeResponse ,
10+ runtime:: window:: dpi:: { Position , Size } ,
11+ Params , Window ,
12+ } ;
813use serde:: Deserialize ;
914
1015use crate :: Icon ;
@@ -28,64 +33,40 @@ impl From<IconDto> for Icon {
2833
2934/// The API descriptor.
3035#[ derive( Deserialize ) ]
31- #[ serde( tag = "cmd" , rename_all = "camelCase" ) ]
36+ #[ serde( tag = "cmd" , content = "data" , rename_all = "camelCase" ) ]
3237pub enum Cmd {
3338 CreateWebview {
3439 options : WindowConfig ,
3540 } ,
36- SetResizable {
37- resizable : bool ,
38- } ,
39- SetTitle {
40- title : String ,
41- } ,
41+ // Getters
42+ ScaleFactor ,
43+ InnerPosition ,
44+ OuterPosition ,
45+ InnerSize ,
46+ OuterSize ,
47+ IsFullscreen ,
48+ IsMaximized ,
49+ CurrentMonitor ,
50+ PrimaryMonitor ,
51+ AvailableMonitors ,
52+ // Setters
53+ SetResizable ( bool ) ,
54+ SetTitle ( String ) ,
4255 Maximize ,
4356 Unmaximize ,
4457 Minimize ,
4558 Unminimize ,
4659 Show ,
4760 Hide ,
4861 Close ,
49- SetDecorations {
50- decorations : bool ,
51- } ,
52- #[ serde( rename_all = "camelCase" ) ]
53- SetAlwaysOnTop {
54- always_on_top : bool ,
55- } ,
56- SetWidth {
57- width : f64 ,
58- } ,
59- SetHeight {
60- height : f64 ,
61- } ,
62- Resize {
63- width : f64 ,
64- height : f64 ,
65- } ,
62+ SetDecorations ( bool ) ,
6663 #[ serde( rename_all = "camelCase" ) ]
67- SetMinSize {
68- min_width : f64 ,
69- min_height : f64 ,
70- } ,
71- #[ serde( rename_all = "camelCase" ) ]
72- SetMaxSize {
73- max_width : f64 ,
74- max_height : f64 ,
75- } ,
76- SetX {
77- x : f64 ,
78- } ,
79- SetY {
80- y : f64 ,
81- } ,
82- SetPosition {
83- x : f64 ,
84- y : f64 ,
85- } ,
86- SetFullscreen {
87- fullscreen : bool ,
88- } ,
64+ SetAlwaysOnTop ( bool ) ,
65+ SetSize ( Size ) ,
66+ SetMinSize ( Option < Size > ) ,
67+ SetMaxSize ( Option < Size > ) ,
68+ SetPosition ( Position ) ,
69+ SetFullscreen ( bool ) ,
8970 SetIcon {
9071 icon : IconDto ,
9172 } ,
@@ -135,33 +116,34 @@ impl Cmd {
135116 } ) ,
136117 ) ?;
137118 }
138-
139- Self :: SetResizable { resizable } => window. set_resizable ( resizable) ?,
140- Self :: SetTitle { title } => window. set_title ( & title) ?,
119+ // Getters
120+ Self :: ScaleFactor => return Ok ( window. scale_factor ( ) ?. into ( ) ) ,
121+ Self :: InnerPosition => return Ok ( window. inner_position ( ) ?. into ( ) ) ,
122+ Self :: OuterPosition => return Ok ( window. outer_position ( ) ?. into ( ) ) ,
123+ Self :: InnerSize => return Ok ( window. inner_size ( ) ?. into ( ) ) ,
124+ Self :: OuterSize => return Ok ( window. outer_size ( ) ?. into ( ) ) ,
125+ Self :: IsFullscreen => return Ok ( window. is_fullscreen ( ) ?. into ( ) ) ,
126+ Self :: IsMaximized => return Ok ( window. is_maximized ( ) ?. into ( ) ) ,
127+ Self :: CurrentMonitor => return Ok ( window. current_monitor ( ) ?. into ( ) ) ,
128+ Self :: PrimaryMonitor => return Ok ( window. primary_monitor ( ) ?. into ( ) ) ,
129+ Self :: AvailableMonitors => return Ok ( window. available_monitors ( ) ?. into ( ) ) ,
130+ // Setters
131+ Self :: SetResizable ( resizable) => window. set_resizable ( resizable) ?,
132+ Self :: SetTitle ( title) => window. set_title ( & title) ?,
141133 Self :: Maximize => window. maximize ( ) ?,
142134 Self :: Unmaximize => window. unmaximize ( ) ?,
143135 Self :: Minimize => window. minimize ( ) ?,
144136 Self :: Unminimize => window. unminimize ( ) ?,
145137 Self :: Show => window. show ( ) ?,
146138 Self :: Hide => window. hide ( ) ?,
147139 Self :: Close => window. close ( ) ?,
148- Self :: SetDecorations { decorations } => window. set_decorations ( decorations) ?,
149- Self :: SetAlwaysOnTop { always_on_top } => window. set_always_on_top ( always_on_top) ?,
150- Self :: SetWidth { width } => window. set_width ( width) ?,
151- Self :: SetHeight { height } => window. set_height ( height) ?,
152- Self :: Resize { width, height } => window. resize ( width, height) ?,
153- Self :: SetMinSize {
154- min_width,
155- min_height,
156- } => window. set_min_size ( min_width, min_height) ?,
157- Self :: SetMaxSize {
158- max_width,
159- max_height,
160- } => window. set_max_size ( max_width, max_height) ?,
161- Self :: SetX { x } => window. set_x ( x) ?,
162- Self :: SetY { y } => window. set_y ( y) ?,
163- Self :: SetPosition { x, y } => window. set_position ( x, y) ?,
164- Self :: SetFullscreen { fullscreen } => window. set_fullscreen ( fullscreen) ?,
140+ Self :: SetDecorations ( decorations) => window. set_decorations ( decorations) ?,
141+ Self :: SetAlwaysOnTop ( always_on_top) => window. set_always_on_top ( always_on_top) ?,
142+ Self :: SetSize ( size) => window. set_size ( size) ?,
143+ Self :: SetMinSize ( size) => window. set_min_size ( size) ?,
144+ Self :: SetMaxSize ( size) => window. set_max_size ( size) ?,
145+ Self :: SetPosition ( position) => window. set_position ( position) ?,
146+ Self :: SetFullscreen ( fullscreen) => window. set_fullscreen ( fullscreen) ?,
165147 Self :: SetIcon { icon } => window. set_icon ( icon. into ( ) ) ?,
166148 Self :: StartDragging => window. start_dragging ( ) ?,
167149 }
0 commit comments