Skip to content

Commit a9b54aa

Browse files
committed
fix: f10 keydown events not working in linux
1 parent e6cab28 commit a9b54aa

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src-tauri/Cargo.lock

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

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace
2525
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
2626

2727
[target.'cfg(target_os = "linux")'.dependencies]
28+
gtk = "0.15"
2829
webkit2gtk = "0.18" # if tauri build fails, make sure to match this version to what we have in tauri
2930

3031
[target.'cfg(target_os = "macos")'.dependencies]

src-tauri/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ windows_subsystem = "windows"
77
use std::fs::metadata;
88
#[cfg(target_os = "linux")]
99
use std::path::PathBuf;
10+
#[cfg(target_os = "linux")]
11+
use gtk::{glib::ObjectExt, prelude::WidgetExt};
1012

1113
use std::process::Command;
1214
#[cfg(target_os = "linux")]
@@ -16,6 +18,7 @@ extern crate webkit2gtk;
1618
#[macro_use]
1719
extern crate objc;
1820

21+
use tauri::Manager;
1922
use regex::Regex;
2023
extern crate percent_encoding;
2124
use tauri::http::ResponseBuilder;
@@ -203,6 +206,16 @@ fn main() {
203206
_get_windows_drives, _rename_path, show_in_folder, zoom_window])
204207
.setup(|app| {
205208
init::init_app(app);
209+
#[cfg(target_os = "linux")]
210+
{
211+
// In linux, f10 key press events are reserved for gtk-menu-bar-accel and not passed.
212+
// So we assing f25 key to it to free f10 and make it available to app
213+
// https://discord.com/channels/616186924390023171/1192844593557950474
214+
let win = app.get_window("main").unwrap();
215+
let gtk_win = win.gtk_window().unwrap();
216+
let gtk_settings = gtk_win.settings().unwrap();
217+
gtk_settings.set_property("gtk-menu-bar-accel", "F25");
218+
}
206219
Ok(())
207220
})
208221
.run(tauri::generate_context!())

0 commit comments

Comments
 (0)