use group(?)-agnostic keyval for paste shortcut (fixes #228)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "chatinput.hpp"
|
#include "chatinput.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
|
#include "misc/events.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
ChatInputText::ChatInputText() {
|
ChatInputText::ChatInputText() {
|
||||||
@@ -41,12 +42,14 @@ bool ChatInputText::ProcessKeyPress(GdkEventKey *event) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto shortcut = EventsUtil::shortcut_key(event);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if ((event->state & GDK_MOD2_MASK) && event->keyval == GDK_KEY_v) {
|
if ((event->state & GDK_MOD2_MASK) && shortcut == GDK_KEY_v) {
|
||||||
return CheckHandleClipboardPaste();
|
return CheckHandleClipboardPaste();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((event->state & GDK_CONTROL_MASK) && event->keyval == GDK_KEY_v) {
|
if ((event->state & GDK_CONTROL_MASK) && shortcut == GDK_KEY_v) {
|
||||||
return CheckHandleClipboardPaste();
|
return CheckHandleClipboardPaste();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
15
src/misc/events.cpp
Normal file
15
src/misc/events.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "events.hpp"
|
||||||
|
|
||||||
|
namespace EventsUtil {
|
||||||
|
unsigned shortcut_key(GdkEventKey *event) {
|
||||||
|
// thanks inkscape
|
||||||
|
unsigned shortcut_key = 0;
|
||||||
|
gdk_keymap_translate_keyboard_state(
|
||||||
|
gdk_keymap_get_for_display(gdk_display_get_default()),
|
||||||
|
event->hardware_keycode,
|
||||||
|
static_cast<GdkModifierType>(event->state),
|
||||||
|
0,
|
||||||
|
&shortcut_key, nullptr, nullptr, nullptr);
|
||||||
|
return shortcut_key;
|
||||||
|
}
|
||||||
|
} // namespace EventsUtil
|
7
src/misc/events.hpp
Normal file
7
src/misc/events.hpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <gdk/gdkkeys.h>
|
||||||
|
// idk it wont let me forward declare
|
||||||
|
|
||||||
|
namespace EventsUtil {
|
||||||
|
unsigned shortcut_key(GdkEventKey *event);
|
||||||
|
}
|
Reference in New Issue
Block a user