X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=b5d3c18c4473bfdee23c1b4bbf70b19512eafa42;hb=a6e8cf77120ad2601b878278bc750fd695c6fbbd;hp=3870ed81ea871f01269abdc7553c60a2b9072644;hpb=df4588617a9478bdb512aab7432ef2d3777eb529;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 3870ed81..b5d3c18c 100644 --- a/src/events.c +++ b/src/events.c @@ -216,7 +216,7 @@ void HandleButtonEvent(XButtonEvent *event) { motion_status = FALSE; - if (event->type==ButtonPress) + if (event->type == ButtonPress) button_status = event->button; else button_status = MB_RELEASED; @@ -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); } @@ -284,9 +312,11 @@ void HandleButton(int mx, int my, int button) old_mx = mx; old_my = my; + /* HandleVideoButtons(mx,my, button); HandleSoundButtons(mx,my, button); HandleGameButtons(mx,my, button); + */ } HandleGadgets(mx, my, button); @@ -310,7 +340,6 @@ void HandleButton(int mx, int my, int button) break; case LEVELED: - LevelEd(mx,my, button); break; case HELPSCREEN: @@ -337,7 +366,12 @@ void HandleButton(int mx, int my, int button) int x = LEVELX(sx); int y = LEVELY(sy); - printf("INFO: Feld[%d][%d] == %d\n", x,y, Feld[x][y]); + printf("INFO: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y); + + if (!IN_LEV_FIELD(x, y)) + break; + + printf(" Feld[%d][%d] == %d\n", x,y, Feld[x][y]); printf(" Store[%d][%d] == %d\n", x,y, Store[x][y]); printf(" Store2[%d][%d] == %d\n", x,y, Store2[x][y]); printf(" StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]); @@ -461,6 +495,8 @@ void HandleKey(KeySym key, int key_status) + HandleGadgetsKeyInput(key); + switch(game_status) { case TYPENAME: @@ -509,7 +545,6 @@ void HandleKey(KeySym key, int key_status) case LEVELED: HandleLevelEditorKeyInput(key); - LevelNameTyping(key); break; case PLAYING: @@ -552,6 +587,22 @@ void HandleKey(KeySym key, int key_status) break; #endif +#if 1 + case XK_m: + if (MoveSpeed == 8) + { + MoveSpeed = 4; + ScrollStepSize = TILEX/4; + } + else + { + MoveSpeed = 8; + ScrollStepSize = TILEX/8; + } + printf("MoveSpeed == %d\n", MoveSpeed); + break; +#endif + case XK_f: ScrollStepSize = TILEX/8; printf("ScrollStepSize == %d (1/8)\n", ScrollStepSize);