Skip to content

Commit

Permalink
Merge pull request #31 from c2r0b/dev
Browse files Browse the repository at this point in the history
Fix #29
  • Loading branch information
c2r0b authored Oct 6, 2024
2 parents 1cdd3b5 + 020002c commit 8d5854f
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .changes/0.4.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "major"
"tauri-plugin-context-menu": "minor"
---

- Add icon support on Windows
Expand Down
2 changes: 1 addition & 1 deletion .changes/0.6.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "major"
"tauri-plugin-context-menu": "minor"
---

- Add linux support
2 changes: 1 addition & 1 deletion .changes/0.6.1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "minor"
"tauri-plugin-context-menu": "patch"
---

- Fix #16
2 changes: 1 addition & 1 deletion .changes/0.6.2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "minor"
"tauri-plugin-context-menu": "patch"
---

- Fix event warning on linux
2 changes: 1 addition & 1 deletion .changes/0.7.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "major"
"tauri-plugin-context-menu": "minor"
---

- Add checked items support #10
Expand Down
2 changes: 1 addition & 1 deletion .changes/0.7.1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "minor"
"tauri-plugin-context-menu": "patch"
---

- Fix #21
2 changes: 1 addition & 1 deletion .changes/0.8.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"tauri-plugin-context-menu": "major"
"tauri-plugin-context-menu": "minor"
---

- Add support for `theme` option
Expand Down
2 changes: 1 addition & 1 deletion .changes/0.8.1.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
"tauri-plugin-context-menu": "minor"
"tauri-plugin-context-menu": "patch"
---
- Fix support for external display on MacOS #25
4 changes: 4 additions & 0 deletions .changes/0.8.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"tauri-plugin-context-menu": "patch"
---
- Fix window crashing on Windows when unfocused #29
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tauri-plugin-context-menu"
version = "0.8.1"
version = "0.8.2"
authors = [ "c2r0b" ]
description = "Handle native Context Menu in Tauri"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multi-example",
"version": "0.8.1",
"version": "0.8.2",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
2 changes: 1 addition & 1 deletion examples/ts-utility/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-utility-example",
"version": "0.8.1",
"version": "0.8.2",
"main": "index.js",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanilla-example",
"version": "0.8.1",
"version": "0.8.2",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.8.1"
"version": "0.8.2"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tauri-plugin-context-menu",
"version": "0.8.1",
"version": "0.8.2",
"author": "c2r0b",
"description": "",
"homepage": "https://github.com/c2r0b/tauri-plugin-context-menu",
Expand Down
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tauri-plugin-context-menu",
"version": "0.8.1",
"version": "0.8.2",
"author": "c2r0b",
"type": "module",
"description": "",
Expand Down
8 changes: 7 additions & 1 deletion src/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use winapi::{
AppendMenuW, ClientToScreen, CreatePopupMenu, DestroyMenu, DispatchMessageW, GetCursorPos,
GetMessageW, PostQuitMessage, SetMenuItemBitmaps, TrackPopupMenu, TranslateMessage,
MF_BYCOMMAND, MF_CHECKED, MF_DISABLED, MF_ENABLED, MF_POPUP, MF_SEPARATOR, MF_STRING, MSG,
TPM_LEFTALIGN, TPM_RIGHTBUTTON, TPM_TOPALIGN, WM_COMMAND,
TPM_LEFTALIGN, TPM_RIGHTBUTTON, TPM_TOPALIGN, WM_ACTIVATE, WM_COMMAND,
},
};

Expand All @@ -20,6 +20,7 @@ use crate::win_image_handler::{convert_to_hbitmap, load_bitmap_from_file};
use crate::{MenuItem, Position};

const ID_MENU_ITEM_BASE: u32 = 1000;
const WA_INACTIVE: u16 = 0;

// We use a lazy_static Mutex to ensure thread safety.
// This will store a map from menu item IDs to events.
Expand Down Expand Up @@ -216,6 +217,11 @@ pub fn show_context_menu<R: Runtime>(
let menu_item_id = LOWORD(msg.wParam as u32);
handle_menu_item_click(menu_item_id.into(), window.clone());
}
WM_ACTIVATE => {
if LOWORD(msg.wParam as u32) == WA_INACTIVE {
unsafe { DestroyMenu(menu) };
}
}
_ => unsafe {
TranslateMessage(&msg);
DispatchMessageW(&msg);
Expand Down

0 comments on commit 8d5854f

Please sign in to comment.