mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-04-21 06:47:07 -04:00
feat: support numlock on
This commit is contained in:
parent
360e259ca5
commit
aa54758e75
3 changed files with 24 additions and 1 deletions
|
|
@ -33,6 +33,9 @@ activities outside the scope of the running application are prevented.
|
||||||
*-s*
|
*-s*
|
||||||
Allow VT switching
|
Allow VT switching
|
||||||
|
|
||||||
|
*-n*
|
||||||
|
Enable numlock
|
||||||
|
|
||||||
*-v*
|
*-v*
|
||||||
Show the version number and exit.
|
Show the version number and exit.
|
||||||
|
|
||||||
|
|
|
||||||
8
cage.c
8
cage.c
|
|
@ -61,6 +61,8 @@
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern bool numlock;
|
||||||
|
|
||||||
void
|
void
|
||||||
server_terminate(struct cg_server *server)
|
server_terminate(struct cg_server *server)
|
||||||
{
|
{
|
||||||
|
|
@ -232,6 +234,7 @@ usage(FILE *file, const char *cage)
|
||||||
" -m extend Extend the display across all connected outputs (default)\n"
|
" -m extend Extend the display across all connected outputs (default)\n"
|
||||||
" -m last Use only the last connected output\n"
|
" -m last Use only the last connected output\n"
|
||||||
" -s\t Allow VT switching\n"
|
" -s\t Allow VT switching\n"
|
||||||
|
" -n\t Enable numlock\n"
|
||||||
" -v\t Show the version number and exit\n"
|
" -v\t Show the version number and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Use -- when you want to pass arguments to APPLICATION\n",
|
" Use -- when you want to pass arguments to APPLICATION\n",
|
||||||
|
|
@ -242,7 +245,7 @@ static bool
|
||||||
parse_args(struct cg_server *server, int argc, char *argv[])
|
parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "dDhm:sv")) != -1) {
|
while ((c = getopt(argc, argv, "dDhm:snv")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
server->xdg_decoration = true;
|
server->xdg_decoration = true;
|
||||||
|
|
@ -260,6 +263,9 @@ parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
server->output_mode = CAGE_MULTI_OUTPUT_MODE_EXTEND;
|
server->output_mode = CAGE_MULTI_OUTPUT_MODE_EXTEND;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
numlock = true;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
server->allow_vt_switch = true;
|
server->allow_vt_switch = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
14
seat.c
14
seat.c
|
|
@ -22,6 +22,7 @@
|
||||||
#include <wlr/types/wlr_data_device.h>
|
#include <wlr/types/wlr_data_device.h>
|
||||||
#include <wlr/types/wlr_idle_notify_v1.h>
|
#include <wlr/types/wlr_idle_notify_v1.h>
|
||||||
#include <wlr/types/wlr_keyboard_group.h>
|
#include <wlr/types/wlr_keyboard_group.h>
|
||||||
|
#include <wlr/interfaces/wlr_keyboard.h>
|
||||||
#include <wlr/types/wlr_primary_selection.h>
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_scene.h>
|
#include <wlr/types/wlr_scene.h>
|
||||||
|
|
@ -43,6 +44,9 @@
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static uint32_t locked_mods = 0;
|
||||||
|
bool numlock = false;
|
||||||
|
|
||||||
static void drag_icon_update_position(struct cg_drag_icon *drag_icon);
|
static void drag_icon_update_position(struct cg_drag_icon *drag_icon);
|
||||||
|
|
||||||
/* XDG toplevels may have nested surfaces, such as popup windows for context
|
/* XDG toplevels may have nested surfaces, such as popup windows for context
|
||||||
|
|
@ -358,6 +362,15 @@ cg_keyboard_group_add(struct wlr_keyboard *keyboard, struct cg_seat *seat, bool
|
||||||
cg_group->wlr_group->data = cg_group;
|
cg_group->wlr_group->data = cg_group;
|
||||||
wlr_keyboard_set_keymap(&cg_group->wlr_group->keyboard, keyboard->keymap);
|
wlr_keyboard_set_keymap(&cg_group->wlr_group->keyboard, keyboard->keymap);
|
||||||
|
|
||||||
|
if (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locked_mods)
|
||||||
|
wlr_keyboard_notify_modifiers(&cg_group->wlr_group->keyboard, 0, 0, locked_mods, 0);
|
||||||
|
|
||||||
wlr_keyboard_set_repeat_info(&cg_group->wlr_group->keyboard, keyboard->repeat_info.rate,
|
wlr_keyboard_set_repeat_info(&cg_group->wlr_group->keyboard, keyboard->repeat_info.rate,
|
||||||
keyboard->repeat_info.delay);
|
keyboard->repeat_info.delay);
|
||||||
|
|
||||||
|
|
@ -397,6 +410,7 @@ handle_new_keyboard(struct cg_seat *seat, struct wlr_keyboard *keyboard, bool vi
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_keyboard_set_keymap(keyboard, keymap);
|
wlr_keyboard_set_keymap(keyboard, keymap);
|
||||||
|
wlr_keyboard_notify_modifiers(keyboard, 0, 0, locked_mods, 0);
|
||||||
|
|
||||||
xkb_keymap_unref(keymap);
|
xkb_keymap_unref(keymap);
|
||||||
xkb_context_unref(context);
|
xkb_context_unref(context);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue