MappingNotify Events
Steven J Abner
pheonix.sja at att.net
Wed Jun 18 15:17:49 UTC 2025
On Tue, Jun 17 2025 at 11:22:30 PM +0000, Steven J Abner
<pheonix.sja at att.net> wrote:
> Or is it obvious that prior to run loop I create a XMappingEvent to
> send with XRefreshKeyboardMapping(), with flush?
This is definitely not the solution! It solves the MappingNotify only
to replace with a need for one to handle XCB_ALLOC_NAMED_COLOR event.
Looking at xcb_refresh_keyboard_mapping() the correct way to handle is
to update my cached values. No messaging back to the server required.
I could not find the source code in libxcb for
xcb_get_keyboard_mapping(). I am guessing that may be the server
response it was looking for?
Here was my last attempt causing the event XCB_ALLOC_NAMED_COLOR:
/* session to hold global values */
void
_xcb_keysym_alloc(xcb_connection_t *connection) {
const struct xcb_setup_t *setup = xcb_get_setup(connection);
xcb_keycode_t min_keycode = setup->min_keycode;
xcb_keycode_t max_keycode = setup->max_keycode;
xcb_get_keyboard_mapping_reply_t *sym_table;
xcb_get_keyboard_mapping_cookie_t cookie;
cookie = xcb_get_keyboard_mapping(connection,
min_keycode,
max_keycode - min_keycode + 1);
/* AFAICT owned by server */
sym_table
= xcb_get_keyboard_mapping_reply(connection, cookie, NULL);
/* owned by server */
session->keysyms = xcb_get_keyboard_mapping_keysyms(sym_table);
session->sym_stride = sym_table->keysyms_per_keycode;
session->sym_min = min_keycode;
/* Added for test purpose only. */
{
XMappingEvent event_map;
event_map.type = MappingNotify;
event_map.serial = 0;
event_map.send_event = false;
event_map.display = display;
event_map.window = 0;
event_map.request = MappingModifier;
event_map.first_keycode = 0;
event_map.count = 0;
XRefreshKeyboardMapping(&event_map);
event_map.request = MappingKeyboard;
event_map.first_keycode = min_keycode;
event_map.count = (max_keycode + 1) - min_keycode;
XRefreshKeyboardMapping(&event_map);
}
xcb_flush(connection);
}
So solution as to what to do with a MappingNotify is just update values:
case XCB_MAPPING_NOTIFY: { /* response_type 34 */
xcb_mapping_notify_event_t *keymap
= (xcb_mapping_notify_event_t*)nvt;
if (keymap->request == XCB_MAPPING_KEYBOARD)
_xcb_keysym_alloc(session->connection);
break;
}
That should even address when someone does actually call one of the
trip functions to cause MappingNotify.
Thanks for listening, and if I'm wrong, please tell me :)
Steve
More information about the xorg
mailing list