X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=15106c87bfe2a8b4963048e09f51f3b60572b79a;hb=240269d614d12d0612cc0764589e6798378e2b8c;hp=d29cfcfcf0d2d3100aeafe8aec024f16b65279c1;hpb=1e196be4c0a2f1edf823b3a0e5a14a146317686e;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index d29cfcfc..15106c87 100644 --- a/src/events.c +++ b/src/events.c @@ -226,16 +226,44 @@ void HandleButtonEvent(XButtonEvent *event) void HandleMotionEvent(XMotionEvent *event) { + Window root, child; + int root_x, root_y; + int win_x, win_y; + unsigned int mask; + + if (!XQueryPointer(display, window, &root, &child, &root_x, &root_y, + &win_x, &win_y, &mask)) + return; + + if (!button_status && game_status != LEVELED) + return; + motion_status = TRUE; - HandleButton(event->x, event->y, button_status); + HandleButton(win_x, win_y, button_status); } void HandleKeyEvent(XKeyEvent *event) { int key_status = (event->type == KeyPress ? KEY_PRESSED : KEY_RELEASED); - unsigned int event_state = (game_status != PLAYING ? event->state : 0); - KeySym key = XLookupKeysym(event, event_state); + KeySym key; + + if (game_status == PLAYING) + { + /* use '0' instead of 'event->state' to get the key without modifiers */ + key = XLookupKeysym(event, 0); + } + else + { + /* get the key with all modifiers */ + char buffer[10]; + int buffer_size = 10; + XComposeStatus compose; + int char_count; + + char_count = XLookupString(event, buffer, buffer_size, &key, &compose); + buffer[char_count] = '\0'; + } HandleKey(key, key_status); }