Skip to content

Commit 3c1f387

Browse files
authored
fix(positioner): handleIconState missing permission and wrong impl (#1911)
1 parent 51ddf6a commit 3c1f387

File tree

8 files changed

+39
-22
lines changed

8 files changed

+39
-22
lines changed

.changes/fix-handleIconState.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"positioner": patch
3+
"positioner-js": patch
4+
---
5+
6+
Added missing permission for `handleIconState` and fixed its event processing logic.

plugins/positioner/api-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/positioner/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
// SPDX-License-Identifier: MIT
44

5-
const COMMANDS: &[&str] = &["move_window"];
5+
const COMMANDS: &[&str] = &["move_window", "set_tray_icon_state"];
66

77
fn main() {
88
tauri_plugin::Builder::new(COMMANDS)

plugins/positioner/guest-js/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,8 @@ export async function moveWindow(to: Position): Promise<void> {
4040
}
4141

4242
export async function handleIconState(event: TrayIconEvent): Promise<void> {
43-
const size = {} as Record<string, unknown>
44-
size[`${event.rect.size.type}`] = {
45-
width: event.rect.size.width,
46-
height: event.rect.size.height
47-
}
48-
49-
const position = {} as Record<string, unknown>
50-
position[`${event.rect.position.type}`] = {
51-
x: event.rect.position.x,
52-
y: event.rect.position.y
53-
}
54-
5543
await invoke('plugin:positioner|set_tray_icon_state', {
56-
position,
57-
size
44+
position: event.rect.position,
45+
size: event.rect.size
5846
})
5947
}

plugins/positioner/permissions/autogenerated/commands/set_tray_icon_state.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44

55
[[permission]]
66
identifier = "allow-set-tray-icon-state"
7-
description = "Enables the set_tray_icon_state to handle events and set the TrayIcon state."
7+
description = "Enables the set_tray_icon_state command without any pre-configured scope."
88
commands.allow = ["set_tray_icon_state"]
9+
10+
[[permission]]
11+
identifier = "deny-set-tray-icon-state"
12+
description = "Denies the set_tray_icon_state command without any pre-configured scope."
13+
commands.deny = ["set_tray_icon_state"]

plugins/positioner/permissions/autogenerated/reference.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Default Permission
22

3-
Allows the move_window command
3+
Allows the moveWindow and handleIconState APIs
44

55
- `allow-move-window`
66
- `set-tray-icon-state`
@@ -48,7 +48,20 @@ Denies the move_window command without any pre-configured scope.
4848
</td>
4949
<td>
5050

51-
Enables the set_tray_icon_state to handle events and set the TrayIcon state.
51+
Enables the set_tray_icon_state command without any pre-configured scope.
52+
53+
</td>
54+
</tr>
55+
56+
<tr>
57+
<td>
58+
59+
`positioner:deny-set-tray-icon-state`
60+
61+
</td>
62+
<td>
63+
64+
Denies the set_tray_icon_state command without any pre-configured scope.
5265

5366
</td>
5467
</tr>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"$schema" = "schemas/schema.json"
22
[default]
3-
description = "Allows the move_window command"
3+
description = "Allows the moveWindow and handleIconState APIs"
44
permissions = ["allow-move-window", "set-tray-icon-state"]

plugins/positioner/permissions/schemas/schema.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,17 @@
305305
"const": "deny-move-window"
306306
},
307307
{
308-
"description": "Enables the set_tray_icon_state to handle events and set the TrayIcon state.",
308+
"description": "Enables the set_tray_icon_state command without any pre-configured scope.",
309309
"type": "string",
310310
"const": "allow-set-tray-icon-state"
311311
},
312312
{
313-
"description": "Allows the move_window command",
313+
"description": "Denies the set_tray_icon_state command without any pre-configured scope.",
314+
"type": "string",
315+
"const": "deny-set-tray-icon-state"
316+
},
317+
{
318+
"description": "Allows the moveWindow and handleIconState APIs",
314319
"type": "string",
315320
"const": "default"
316321
}

0 commit comments

Comments
 (0)