From 74f5e7a7fc638bbe99f42d10f7f9321b387aa4cf Mon Sep 17 00:00:00 2001 From: Enes Hecan Date: Fri, 24 Feb 2023 17:06:14 +0100 Subject: [PATCH] Fix passing alt key as cmd to webkit caused by a misunderstanding by me --- src/ui/MainWindow.cpp | 7 +++++++ src/ui/WebView.cpp | 10 ---------- src/ui/WebView.hpp | 3 --- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index dc6a706..6479077 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -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); } diff --git a/src/ui/WebView.cpp b/src/ui/WebView.cpp index d056aaf..f008e4f 100644 --- a/src/ui/WebView.cpp +++ b/src/ui/WebView.cpp @@ -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); - } } diff --git a/src/ui/WebView.hpp b/src/ui/WebView.hpp index 684939c..92a834d 100644 --- a/src/ui/WebView.hpp +++ b/src/ui/WebView.hpp @@ -35,9 +35,6 @@ namespace wfl::ui sigc::signal signalNotification() const noexcept; sigc::signal signalNotificationClicked() const noexcept; - protected: - bool on_key_press_event(GdkEventKey* keyEvent) override; - private: void onLoadStatusChanged(WebKitLoadEvent loadEvent); bool onTimeout();