Remove num/caps locks from modifier processing in mouse events
This commit is contained in:
parent
a4db27a807
commit
db719eafac
1
glfw/glfw3.h
vendored
1
glfw/glfw3.h
vendored
@ -512,6 +512,7 @@ typedef enum {
|
|||||||
* GLFW_LOCK_KEY_MODS input mode is set.
|
* GLFW_LOCK_KEY_MODS input mode is set.
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_NUM_LOCK 0x0080
|
#define GLFW_MOD_NUM_LOCK 0x0080
|
||||||
|
#define GLFW_LOCK_MASK (GLFW_MOD_NUM_LOCK | GLFW_MOD_CAPS_LOCK)
|
||||||
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
|||||||
2
kitty/glfw-wrapper.h
generated
2
kitty/glfw-wrapper.h
generated
@ -248,9 +248,9 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
* If this bit is set the Num Lock key is enabled and the @ref
|
* If this bit is set the Num Lock key is enabled and the @ref
|
||||||
* GLFW_LOCK_KEY_MODS input mode is set.
|
* GLFW_LOCK_KEY_MODS input mode is set.
|
||||||
* @note Ravi: Num lock is not supported in this branch
|
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_NUM_LOCK 0x0080
|
#define GLFW_MOD_NUM_LOCK 0x0080
|
||||||
|
#define GLFW_LOCK_MASK (GLFW_MOD_NUM_LOCK | GLFW_MOD_CAPS_LOCK)
|
||||||
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "charsets.h"
|
#include "charsets.h"
|
||||||
|
|
||||||
static const unsigned LOCK_MASK = GLFW_MOD_NUM_LOCK | GLFW_MOD_CAPS_LOCK;
|
|
||||||
typedef enum { SHIFT=1, ALT=2, CTRL=4, SUPER=8, HYPER=16, META=32, CAPS_LOCK=64, NUM_LOCK=128} ModifierMasks;
|
typedef enum { SHIFT=1, ALT=2, CTRL=4, SUPER=8, HYPER=16, META=32, CAPS_LOCK=64, NUM_LOCK=128} ModifierMasks;
|
||||||
typedef enum { PRESS = 0, REPEAT = 1, RELEASE = 2} KeyAction;
|
typedef enum { PRESS = 0, REPEAT = 1, RELEASE = 2} KeyAction;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -49,7 +48,7 @@ is_modifier_key(const uint32_t key) {
|
|||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
convert_glfw_mods(int mods, KeyEvent *ev, const unsigned key_encoding_flags) {
|
convert_glfw_mods(int mods, KeyEvent *ev, const unsigned key_encoding_flags) {
|
||||||
if (!key_encoding_flags) mods &= ~LOCK_MASK;
|
if (!key_encoding_flags) mods &= ~GLFW_LOCK_MASK;
|
||||||
ev->mods.alt = (mods & GLFW_MOD_ALT) > 0, ev->mods.ctrl = (mods & GLFW_MOD_CONTROL) > 0, ev->mods.shift = (mods & GLFW_MOD_SHIFT) > 0, ev->mods.super = (mods & GLFW_MOD_SUPER) > 0, ev->mods.hyper = (mods & GLFW_MOD_HYPER) > 0, ev->mods.meta = (mods & GLFW_MOD_META) > 0;
|
ev->mods.alt = (mods & GLFW_MOD_ALT) > 0, ev->mods.ctrl = (mods & GLFW_MOD_CONTROL) > 0, ev->mods.shift = (mods & GLFW_MOD_SHIFT) > 0, ev->mods.super = (mods & GLFW_MOD_SUPER) > 0, ev->mods.hyper = (mods & GLFW_MOD_HYPER) > 0, ev->mods.meta = (mods & GLFW_MOD_META) > 0;
|
||||||
ev->mods.numlock = (mods & GLFW_MOD_NUM_LOCK) > 0, ev->mods.capslock = (mods & GLFW_MOD_CAPS_LOCK) > 0;
|
ev->mods.numlock = (mods & GLFW_MOD_NUM_LOCK) > 0, ev->mods.capslock = (mods & GLFW_MOD_CAPS_LOCK) > 0;
|
||||||
ev->mods.value = ev->mods.shift ? SHIFT : 0;
|
ev->mods.value = ev->mods.shift ? SHIFT : 0;
|
||||||
|
|||||||
@ -358,6 +358,7 @@ handle_mouse_movement_in_kitty(Window *w, int button, bool mouse_cell_changed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLER(handle_move_event) {
|
HANDLER(handle_move_event) {
|
||||||
|
modifiers &= ~GLFW_LOCK_MASK;
|
||||||
unsigned int x = 0, y = 0;
|
unsigned int x = 0, y = 0;
|
||||||
if (OPT(focus_follows_mouse)) {
|
if (OPT(focus_follows_mouse)) {
|
||||||
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
||||||
@ -421,6 +422,7 @@ clear_click_queue(Window *w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLER(add_click) {
|
HANDLER(add_click) {
|
||||||
|
modifiers &= ~GLFW_LOCK_MASK;
|
||||||
ClickQueue *q = &w->click_queue;
|
ClickQueue *q = &w->click_queue;
|
||||||
if (q->length == CLICK_QUEUE_SZ) { memmove(q->clicks, q->clicks + 1, sizeof(Click) * (CLICK_QUEUE_SZ - 1)); q->length--; }
|
if (q->length == CLICK_QUEUE_SZ) { memmove(q->clicks, q->clicks + 1, sizeof(Click) * (CLICK_QUEUE_SZ - 1)); q->length--; }
|
||||||
monotonic_t now = monotonic();
|
monotonic_t now = monotonic();
|
||||||
@ -477,6 +479,7 @@ handle_button_event_in_kitty(Window *w, int button, int modifiers, bool is_relea
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLER(handle_button_event) {
|
HANDLER(handle_button_event) {
|
||||||
|
modifiers &= ~GLFW_LOCK_MASK;
|
||||||
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
||||||
bool is_release = !global_state.callback_os_window->mouse_button_pressed[button];
|
bool is_release = !global_state.callback_os_window->mouse_button_pressed[button];
|
||||||
if (window_idx != t->active_window && !is_release) {
|
if (window_idx != t->active_window && !is_release) {
|
||||||
@ -506,6 +509,7 @@ currently_pressed_button(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLER(handle_event) {
|
HANDLER(handle_event) {
|
||||||
|
modifiers &= ~GLFW_LOCK_MASK;
|
||||||
if (button == -1) {
|
if (button == -1) {
|
||||||
button = currently_pressed_button();
|
button = currently_pressed_button();
|
||||||
handle_move_event(w, button, modifiers, window_idx);
|
handle_move_event(w, button, modifiers, window_idx);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user