4
4
5
5
#[ cfg( window_create) ]
6
6
use 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
+ } ;
8
13
use serde:: Deserialize ;
9
14
10
15
use crate :: Icon ;
@@ -28,64 +33,40 @@ impl From<IconDto> for Icon {
28
33
29
34
/// The API descriptor.
30
35
#[ derive( Deserialize ) ]
31
- #[ serde( tag = "cmd" , rename_all = "camelCase" ) ]
36
+ #[ serde( tag = "cmd" , content = "data" , rename_all = "camelCase" ) ]
32
37
pub enum Cmd {
33
38
CreateWebview {
34
39
options : WindowConfig ,
35
40
} ,
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 ) ,
42
55
Maximize ,
43
56
Unmaximize ,
44
57
Minimize ,
45
58
Unminimize ,
46
59
Show ,
47
60
Hide ,
48
61
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 ) ,
66
63
#[ 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 ) ,
89
70
SetIcon {
90
71
icon : IconDto ,
91
72
} ,
@@ -135,33 +116,34 @@ impl Cmd {
135
116
} ) ,
136
117
) ?;
137
118
}
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) ?,
141
133
Self :: Maximize => window. maximize ( ) ?,
142
134
Self :: Unmaximize => window. unmaximize ( ) ?,
143
135
Self :: Minimize => window. minimize ( ) ?,
144
136
Self :: Unminimize => window. unminimize ( ) ?,
145
137
Self :: Show => window. show ( ) ?,
146
138
Self :: Hide => window. hide ( ) ?,
147
139
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) ?,
165
147
Self :: SetIcon { icon } => window. set_icon ( icon. into ( ) ) ?,
166
148
Self :: StartDragging => window. start_dragging ( ) ?,
167
149
}
0 commit comments