mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-31 07:11:28 -04:00
get kb meesage by ipc
This commit is contained in:
parent
526d71c685
commit
8a1f3597e1
4 changed files with 40 additions and 6 deletions
12
mmsg/mmsg.c
12
mmsg/mmsg.c
|
|
@ -265,6 +265,17 @@ static void dwl_ipc_output_kb_layout(void *data,
|
||||||
printf("kb_layout %s\n", kb_layout);
|
printf("kb_layout %s\n", kb_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dwl_ipc_output_active_kb(void *data,
|
||||||
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
|
const char *active_kb) {
|
||||||
|
if (!kflag)
|
||||||
|
return;
|
||||||
|
char *output_name = data;
|
||||||
|
if (output_name)
|
||||||
|
printf("%s ", output_name);
|
||||||
|
printf("active_kb %s\n", active_kb);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dwl_ipc_output_scalefactor(void *data,
|
dwl_ipc_output_scalefactor(void *data,
|
||||||
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
|
|
@ -425,6 +436,7 @@ static const struct zdwl_ipc_output_v2_listener dwl_ipc_output_listener = {
|
||||||
.height = dwl_ipc_output_height,
|
.height = dwl_ipc_output_height,
|
||||||
.last_layer = dwl_ipc_output_last_layer,
|
.last_layer = dwl_ipc_output_last_layer,
|
||||||
.kb_layout = dwl_ipc_output_kb_layout,
|
.kb_layout = dwl_ipc_output_kb_layout,
|
||||||
|
.active_kb = dwl_ipc_output_active_kb,
|
||||||
.keymode = dwl_ipc_output_keymode,
|
.keymode = dwl_ipc_output_keymode,
|
||||||
.scalefactor = dwl_ipc_output_scalefactor,
|
.scalefactor = dwl_ipc_output_scalefactor,
|
||||||
.frame = dwl_ipc_output_frame,
|
.frame = dwl_ipc_output_frame,
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,13 @@ I would probably just submit raphi's patchset but I don't think that would be po
|
||||||
<arg name="kb_layout" type="string" summary="current keyboard layout."/>
|
<arg name="kb_layout" type="string" summary="current keyboard layout."/>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="active_kb" since="2">
|
||||||
|
<description summary="current active keyboard.">
|
||||||
|
current active keyboard.
|
||||||
|
</description>
|
||||||
|
<arg name="active_kb" type="string" summary="current active keyboard."/>
|
||||||
|
</event>
|
||||||
|
|
||||||
<event name="keymode" since="2">
|
<event name="keymode" since="2">
|
||||||
<description summary="current keybind mode.">
|
<description summary="current keybind mode.">
|
||||||
current keybind mode.
|
current keybind mode.
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,9 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
xkb_layout_index_t current;
|
xkb_layout_index_t current;
|
||||||
int32_t tagmask, state, numclients, focused_client, tag;
|
int32_t tagmask, state, numclients, focused_client, tag;
|
||||||
const char *title, *appid, *symbol;
|
const char *title, *appid, *symbol;
|
||||||
|
InputDevice *active_kb;
|
||||||
char kb_layout[32];
|
char kb_layout[32];
|
||||||
|
char active_kb_name[256];
|
||||||
focused = focustop(monitor);
|
focused = focustop(monitor);
|
||||||
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
|
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
|
||||||
|
|
||||||
|
|
@ -147,12 +149,21 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
symbol = monitor->pertag->ltidxs[monitor->pertag->curtag]->symbol;
|
symbol = monitor->pertag->ltidxs[monitor->pertag->curtag]->symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard = &kb_group->wlr_group->keyboard;
|
active_kb = get_active_keyboard_device();
|
||||||
|
if(active_kb) {
|
||||||
|
sprintf(active_kb_name, "vendor:%d,product:%d,name:%s", active_kb->vendor, active_kb->product, active_kb->name);
|
||||||
|
} else {
|
||||||
|
sprintf(active_kb_name, "-1 -1 unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
keyboard = active_kb ? (struct wlr_keyboard*)active_kb->device_data: &kb_group->wlr_group->keyboard;
|
||||||
current = xkb_state_serialize_layout(keyboard->xkb_state,
|
current = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||||
get_layout_abbr(kb_layout,
|
get_layout_abbr(kb_layout,
|
||||||
xkb_keymap_layout_get_name(keyboard->keymap, current));
|
xkb_keymap_layout_get_name(keyboard->keymap, current));
|
||||||
|
|
||||||
|
|
||||||
zdwl_ipc_output_v2_send_layout(
|
zdwl_ipc_output_v2_send_layout(
|
||||||
ipc_output->resource,
|
ipc_output->resource,
|
||||||
monitor->pertag->ltidxs[monitor->pertag->curtag] - layouts);
|
monitor->pertag->ltidxs[monitor->pertag->curtag] - layouts);
|
||||||
|
|
@ -210,6 +221,10 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
zdwl_ipc_output_v2_send_scalefactor(ipc_output->resource,
|
zdwl_ipc_output_v2_send_scalefactor(ipc_output->resource,
|
||||||
monitor->wlr_output->scale * 100);
|
monitor->wlr_output->scale * 100);
|
||||||
}
|
}
|
||||||
|
if (wl_resource_get_version(ipc_output->resource) >=
|
||||||
|
ZDWL_IPC_OUTPUT_V2_ACTIVE_KB_SINCE_VERSION) {
|
||||||
|
zdwl_ipc_output_v2_send_active_kb(ipc_output->resource, active_kb_name);
|
||||||
|
}
|
||||||
|
|
||||||
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -786,6 +786,7 @@ static Client *get_scroll_stack_head(Client *c);
|
||||||
static bool client_only_in_one_tag(Client *c);
|
static bool client_only_in_one_tag(Client *c);
|
||||||
static Client *get_focused_stack_client(Client *sc);
|
static Client *get_focused_stack_client(Client *sc);
|
||||||
static bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc);
|
static bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc);
|
||||||
|
static InputDevice * get_active_keyboard_device(void);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
|
|
@ -2577,12 +2578,11 @@ void createkeyboard(struct wlr_keyboard *keyboard) {
|
||||||
int32_t vendor = libinput_device_get_id_vendor(device);
|
int32_t vendor = libinput_device_get_id_vendor(device);
|
||||||
int32_t product = libinput_device_get_id_product(device);
|
int32_t product = libinput_device_get_id_product(device);
|
||||||
const char *name = libinput_device_get_name(device);
|
const char *name = libinput_device_get_name(device);
|
||||||
|
name = name ? name : "unknown";
|
||||||
|
|
||||||
if (name) {
|
|
||||||
input_dev->vendor = vendor;
|
input_dev->vendor = vendor;
|
||||||
input_dev->product = product;
|
input_dev->product = product;
|
||||||
input_dev->name = strdup(name);
|
input_dev->name = strdup(name);
|
||||||
}
|
|
||||||
|
|
||||||
input_dev->destroy_listener.notify = destroyinputdevice;
|
input_dev->destroy_listener.notify = destroyinputdevice;
|
||||||
wl_signal_add(&keyboard->base.events.destroy,
|
wl_signal_add(&keyboard->base.events.destroy,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue