Output ClientMessage to help debug

In my environment, detected unexpected event is only ClientMessage.

```
% journalctl | grep 'unexpected event detected' | cut -d! -f2 | sort | uniq
 (33)
```
This commit is contained in:
Seiei Miyagi 2017-06-17 02:22:56 +09:00
parent 64eef405a6
commit f1ece680c2
No known key found for this signature in database
GPG Key ID: CECD34C119139FA8

View File

@ -1,10 +1,26 @@
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <inttypes.h>
#include <mruby.h>
#include <X11/Xlib.h>
#include "xremap.h"
void
print_client_message_event(XClientMessageEvent *event)
{
fprintf(stderr,
"received ClientMesssage(message_type=%" PRIu32 " format=%d data=%#lx, %#lx, %#lx, %#lx, %#lx)",
(uint32_t)event->message_type,
event->format,
(unsigned long)event->data.l[0],
(unsigned long)event->data.l[1],
(unsigned long)event->data.l[2],
(unsigned long)event->data.l[3],
(unsigned long)event->data.l[4]);
}
int
error_handler(Display *display, XErrorEvent *event)
{
@ -32,6 +48,8 @@ event_loop(Display *display, mrb_state *mrb, mrb_value event_handler)
case MappingNotify:
handle_mapping_notify(mrb, event_handler);
break;
case ClientMessage:
print_client_message_event((XClientMessageEvent*)&event);
default:
fprintf(stderr, "unexpected event detected! (%d)\n", event.type);
break;