Skip to content

Commit

Permalink
fix(positioner): handleIconState missing permission and wrong impl (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Oct 9, 2024
1 parent 51ddf6a commit 3c1f387
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-handleIconState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"positioner": patch
"positioner-js": patch
---

Added missing permission for `handleIconState` and fixed its event processing logic.
2 changes: 1 addition & 1 deletion plugins/positioner/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/positioner/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

const COMMANDS: &[&str] = &["move_window"];
const COMMANDS: &[&str] = &["move_window", "set_tray_icon_state"];

fn main() {
tauri_plugin::Builder::new(COMMANDS)
Expand Down
16 changes: 2 additions & 14 deletions plugins/positioner/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,8 @@ export async function moveWindow(to: Position): Promise<void> {
}

export async function handleIconState(event: TrayIconEvent): Promise<void> {
const size = {} as Record<string, unknown>
size[`${event.rect.size.type}`] = {
width: event.rect.size.width,
height: event.rect.size.height
}

const position = {} as Record<string, unknown>
position[`${event.rect.position.type}`] = {
x: event.rect.position.x,
y: event.rect.position.y
}

await invoke('plugin:positioner|set_tray_icon_state', {
position,
size
position: event.rect.position,
size: event.rect.size
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

[[permission]]
identifier = "allow-set-tray-icon-state"
description = "Enables the set_tray_icon_state to handle events and set the TrayIcon state."
description = "Enables the set_tray_icon_state command without any pre-configured scope."
commands.allow = ["set_tray_icon_state"]

[[permission]]
identifier = "deny-set-tray-icon-state"
description = "Denies the set_tray_icon_state command without any pre-configured scope."
commands.deny = ["set_tray_icon_state"]
17 changes: 15 additions & 2 deletions plugins/positioner/permissions/autogenerated/reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Default Permission

Allows the move_window command
Allows the moveWindow and handleIconState APIs

- `allow-move-window`
- `set-tray-icon-state`
Expand Down Expand Up @@ -48,7 +48,20 @@ Denies the move_window command without any pre-configured scope.
</td>
<td>

Enables the set_tray_icon_state to handle events and set the TrayIcon state.
Enables the set_tray_icon_state command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`positioner:deny-set-tray-icon-state`

</td>
<td>

Denies the set_tray_icon_state command without any pre-configured scope.

</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion plugins/positioner/permissions/default.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"$schema" = "schemas/schema.json"
[default]
description = "Allows the move_window command"
description = "Allows the moveWindow and handleIconState APIs"
permissions = ["allow-move-window", "set-tray-icon-state"]
9 changes: 7 additions & 2 deletions plugins/positioner/permissions/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,17 @@
"const": "deny-move-window"
},
{
"description": "Enables the set_tray_icon_state to handle events and set the TrayIcon state.",
"description": "Enables the set_tray_icon_state command without any pre-configured scope.",
"type": "string",
"const": "allow-set-tray-icon-state"
},
{
"description": "Allows the move_window command",
"description": "Denies the set_tray_icon_state command without any pre-configured scope.",
"type": "string",
"const": "deny-set-tray-icon-state"
},
{
"description": "Allows the moveWindow and handleIconState APIs",
"type": "string",
"const": "default"
}
Expand Down

0 comments on commit 3c1f387

Please sign in to comment.