| 85 | } |
| 86 | |
| 87 | int32_t Window::ProcessedEvent() |
| 88 | { |
| 89 | if (!XPending(mDisplay)) |
| 90 | { |
| 91 | return EVT_NONE_PENDING; |
| 92 | } |
| 93 | |
| 94 | XEvent evt; |
| 95 | XNextEvent(mDisplay, &evt); |
| 96 | |
| 97 | if (evt.type == ButtonPress || evt.type == ButtonRelease) |
| 98 | { |
| 99 | if (evt.xbutton.button == Button4) |
| 100 | { |
| 101 | OnMouseWheel(1, evt.xbutton.x, evt.xbutton.y, |
| 102 | evt.xbutton.state); |
| 103 | } |
| 104 | else if (evt.xbutton.button == Button5) |
| 105 | { |
| 106 | OnMouseWheel(-1, evt.xbutton.x, evt.xbutton.y, |
| 107 | evt.xbutton.state); |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | OnMouseClick(evt.xbutton.button, evt.xbutton.type, |
| 112 | evt.xbutton.x, evt.xbutton.y, evt.xbutton.state); |
| 113 | |
| 114 | mButtonDown[evt.xbutton.button] = (evt.type == ButtonPress); |
| 115 | } |
| 116 | return EVT_PROCESSED; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | if (evt.type == MotionNotify) |
| 121 | { |
| 122 | int32_t button = MOUSE_NONE; |
| 123 | for (int32_t i = MOUSE_LEFT; i <= MOUSE_RIGHT; ++i) |
| 124 | { |
| 125 | if (mButtonDown[i]) |
| 126 | { |
| 127 | button = i; |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | OnMouseMotion(button, evt.xmotion.x, evt.xmotion.y, evt.xmotion.state); |
| 132 | return EVT_PROCESSED; |
| 133 | } |
| 134 | |
| 135 | if (evt.type == KeyPress || evt.type == KeyRelease) |
| 136 | { |
| 137 | int32_t keysyms_per_keycode_return; |
| 138 | KeySym* pKeySym = XGetKeyboardMapping(mDisplay, |
| 139 | evt.xkey.keycode, 1, &keysyms_per_keycode_return); |
| 140 | KeySym& keySym = *pKeySym; |
| 141 | int32_t key = (keySym & 0x00FF); |
| 142 | |
| 143 | // Quit application if the KEY_ESCAPE key is pressed. |
| 144 | if (key == KEY_ESCAPE) |