Skip to content

Commit

Permalink
app: use logo key on macos instead of ctrl/alt for the shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfi committed Jan 28, 2025
1 parent 2639ba2 commit d9a819b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion bin/app/src/app/schema/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ pub async fn make(
let node = create_shortcut("back_shortcut");
#[cfg(target_os = "android")]
node.set_property_str(atom, Role::App, "key", "back").unwrap();
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
node.set_property_str(atom, Role::App, "key", "logo+left").unwrap();
#[cfg(all(not(target_os = "android"), not(target_os = "macos")))]
node.set_property_str(atom, Role::App, "key", "alt+left").unwrap();
// Not sure what was eating my keys. This is a workaround.
node.set_property_u32(atom, Role::App, "priority", 10).unwrap();
Expand Down
3 changes: 3 additions & 0 deletions bin/app/src/app/schema/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ pub async fn make(app: &App, window: SceneNodePtr) {
// Create shortcut
let channel_id = i + 1;
let node = create_shortcut(&format!("channel_shortcut_{channel_id}"));
#[cfg(not(target_os = "macos"))]
let key = format!("alt+{channel_id}");
#[cfg(target_os = "macos")]
let key = format!("logo+{channel_id}");
node.set_property_str(atom, Role::App, "key", key).unwrap();
node.set_property_u32(atom, Role::App, "priority", 1).unwrap();

Expand Down
16 changes: 11 additions & 5 deletions bin/app/src/ui/chatedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ use super::{
// Avoid updating too much makes scrolling smoother.
const VERT_SCROLL_UPDATE_INC: f32 = 1.;

macro_rules! d { ($($arg:tt)*) => { debug!(target: "ui::chatview", $($arg)*); } }
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::chatview", $($arg)*); } }
macro_rules! d { ($($arg:tt)*) => { debug!(target: "ui::chatedit", $($arg)*); } }
macro_rules! t { ($($arg:tt)*) => { trace!(target: "ui::chatedit", $($arg)*); } }

fn is_all_whitespace(glyphs: &[Glyph]) -> bool {
for glyph in glyphs {
Expand Down Expand Up @@ -1131,9 +1131,15 @@ impl ChatEdit {
) -> bool {
t!("handle_shortcut({:?}, {:?})", key, mods);

#[cfg(not(target_os = "macos"))]
let modkey_pressed = mods.ctrl;

#[cfg(target_os = "macos")]
let modkey_pressed = mods.logo;

match key {
'a' => {
if mods.ctrl {
if modkey_pressed {
{
let mut text_wrap = self.text_wrap.lock();
let rendered = text_wrap.get_render();
Expand All @@ -1157,7 +1163,7 @@ impl ChatEdit {
}
}
'v' => {
if mods.ctrl {
if modkey_pressed {
let mut clip = Clipboard::new();
if let Some(text) = clip.get() {
self.insert_text(&text, atom).await;
Expand Down Expand Up @@ -1997,7 +2003,7 @@ impl UIObject for ChatEdit {

let atom = &mut PropertyAtomicGuard::new();

if mods.ctrl || mods.alt {
if mods.ctrl || mods.alt || mods.logo {
if repeat {
return false
}
Expand Down

0 comments on commit d9a819b

Please sign in to comment.