Cloudef / monsterwm-xcb

Port of monsterwm to xcb
Other
35 stars 10 forks source link

Question about interpreting xcb_key_press events #6

Open funrep opened 9 years ago

funrep commented 9 years ago

I'm very sorry I ask this question here, but didn't find any email or irc nick on your website and the email in the LICENSE uses your old domain. I wonder if you could explain how https://github.com/Cloudef/monsterwm-xcb/blob/master/monsterwm.c#L590 (´void keypress(xcb_generic_event_t *e)´), works? I'm writing a simple WM as an exercise to learn C, but I can't understand how to intepret which key is pressed when a key press event occurs. I tried to use awesomewm's solution, but I wasen't able to integrate their code into my project so I searched for other reference implementations and found this.

Cloudef commented 9 years ago

That function is callback for X11 keypress event. The detail member under the casted X11 event structure contains the raw keycode. You get layout independent key symbol with the xkb_get_keysym function and go through list of key handlers that may handle the key. The CLEANMASK macro ignores numlock and scroll lock when comparing the mod bitmasks.

funrep commented 9 years ago

I understand, thanks!