Skip to content

Commit

Permalink
fix: f10 keydown events not working in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Jan 7, 2024
1 parent e6cab28 commit a9b54aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

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

[target.'cfg(target_os = "macos")'.dependencies]
Expand Down
13 changes: 13 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ windows_subsystem = "windows"
use std::fs::metadata;
#[cfg(target_os = "linux")]
use std::path::PathBuf;
#[cfg(target_os = "linux")]
use gtk::{glib::ObjectExt, prelude::WidgetExt};

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

use tauri::Manager;
use regex::Regex;
extern crate percent_encoding;
use tauri::http::ResponseBuilder;
Expand Down Expand Up @@ -203,6 +206,16 @@ fn main() {
_get_windows_drives, _rename_path, show_in_folder, zoom_window])
.setup(|app| {
init::init_app(app);
#[cfg(target_os = "linux")]
{
// In linux, f10 key press events are reserved for gtk-menu-bar-accel and not passed.
// So we assing f25 key to it to free f10 and make it available to app
// https://discord.com/channels/616186924390023171/1192844593557950474
let win = app.get_window("main").unwrap();
let gtk_win = win.gtk_window().unwrap();
let gtk_settings = gtk_win.settings().unwrap();
gtk_settings.set_property("gtk-menu-bar-accel", "F25");
}
Ok(())
})
.run(tauri::generate_context!())
Expand Down

0 comments on commit a9b54aa

Please sign in to comment.