optimize: change numlock var into server

This commit is contained in:
DreamMaoMao 2025-03-11 07:21:51 +08:00
parent aa54758e75
commit 4b7ef5287a
3 changed files with 3 additions and 5 deletions

4
cage.c
View file

@ -61,8 +61,6 @@
#include "xwayland.h"
#endif
extern bool numlock;
void
server_terminate(struct cg_server *server)
{
@ -264,7 +262,7 @@ parse_args(struct cg_server *server, int argc, char *argv[])
}
break;
case 'n':
numlock = true;
server->numlock = true;
break;
case 's':
server->allow_vt_switch = true;

3
seat.c
View file

@ -45,7 +45,6 @@
#endif
static uint32_t locked_mods = 0;
bool numlock = false;
static void drag_icon_update_position(struct cg_drag_icon *drag_icon);
@ -362,7 +361,7 @@ cg_keyboard_group_add(struct wlr_keyboard *keyboard, struct cg_seat *seat, bool
cg_group->wlr_group->data = cg_group;
wlr_keyboard_set_keymap(&cg_group->wlr_group->keyboard, keyboard->keymap);
if (numlock) {
if (seat->server->numlock) {
xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keyboard->keymap, XKB_MOD_NAME_NUM);
if (mod_index != XKB_MOD_INVALID)
locked_mods |= (uint32_t)1 << mod_index;

View file

@ -65,6 +65,7 @@ struct cg_server {
bool allow_vt_switch;
bool return_app_code;
bool terminated;
bool numlock;
enum wlr_log_importance log_level;
};