Skip to content

Commit

Permalink
Fix passing alt key as cmd to webkit caused by a misunderstanding by me
Browse files Browse the repository at this point in the history
  • Loading branch information
xeco23 committed Feb 24, 2023
1 parent 7ce2894 commit 74f5e7a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ namespace wfl::ui
}
}

// This is required for keyboard shortcuts on WhatsApp Web to work. Since it is running
// on WebKit, WhatsApp Web listens for Mac's [CMD] key instead of the standard [ALT] key.
if (keyEvent->state & GDK_MOD1_MASK)
{
keyEvent->state |= GDK_META_MASK;
}

return Gtk::ApplicationWindow::on_key_press_event(keyEvent);
}

Expand Down
10 changes: 0 additions & 10 deletions src/ui/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,4 @@ namespace wfl::ui

return true;
}

bool WebView::on_key_press_event(GdkEventKey* keyEvent)
{
// This is required for keyboard shortcuts on WhatsApp Web to work. Since it is running
// on WebKit, WhatsApp Web listens for Mac's [CMD] key instead of the standard [ALT] key.
if (keyEvent->state & GDK_MOD1_MASK)
keyEvent->state += GDK_META_MASK;

return Gtk::Widget::on_key_press_event(keyEvent);
}
}
3 changes: 0 additions & 3 deletions src/ui/WebView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ namespace wfl::ui
sigc::signal<void, bool> signalNotification() const noexcept;
sigc::signal<void> signalNotificationClicked() const noexcept;

protected:
bool on_key_press_event(GdkEventKey* keyEvent) override;

private:
void onLoadStatusChanged(WebKitLoadEvent loadEvent);
bool onTimeout();
Expand Down

0 comments on commit 74f5e7a

Please sign in to comment.