Override */
| 140 | } |
| 141 | |
| 142 | /* Override */ xcb_void_cookie_t |
| 143 | xcb_warp_pointer (xcb_connection_t *c, |
| 144 | xcb_window_t src_window, |
| 145 | xcb_window_t dst_window, |
| 146 | int16_t src_x, |
| 147 | int16_t src_y, |
| 148 | uint16_t src_width, |
| 149 | uint16_t src_height, |
| 150 | int16_t dst_x, |
| 151 | int16_t dst_y) |
| 152 | { |
| 153 | RETURN_IF_NATIVE(xcb_warp_pointer, (c, src_window, dst_window, src_x, src_y, src_width, src_height, dst_x, dst_y), nullptr); |
| 154 | |
| 155 | LOG(LL_TRACE, LCF_MOUSE, "%s called with dest_w %d and dest_x %d and dest_y %d", __func__, dst_window, dst_x, dst_y); |
| 156 | |
| 157 | /* Does this generate a XCB_MOTION_NOTIFY event? */ |
| 158 | if (XlibGameWindow::get()) { |
| 159 | xcb_motion_notify_event_t event; |
| 160 | event.response_type = XCB_MOTION_NOTIFY; |
| 161 | event.state = SingleInput::toXlibPointerMask(Inputs::game_ai.pointer.mask); |
| 162 | |
| 163 | if (dst_window == XCB_NONE) { |
| 164 | /* Relative warp */ |
| 165 | event.event_x = Inputs::game_ai.pointer.x + dst_x; |
| 166 | event.event_y = Inputs::game_ai.pointer.y + dst_y; |
| 167 | } |
| 168 | else { |
| 169 | /* Absolute warp */ |
| 170 | event.event_x = dst_x; |
| 171 | event.event_y = dst_y; |
| 172 | } |
| 173 | event.root_x = event.event_x; |
| 174 | event.root_y = event.event_y; |
| 175 | event.event = XlibGameWindow::get(); |
| 176 | |
| 177 | struct timespec time = DeterministicTimer::get().getTicks(); |
| 178 | event.time = time.tv_sec * 1000 + time.tv_nsec / 1000000; |
| 179 | |
| 180 | xcbEventQueueList.insert(reinterpret_cast<xcb_generic_event_t*>(&event), false); |
| 181 | LOG(LL_DEBUG, LCF_EVENTS | LCF_MOUSE, "Generate xcb event XCB_MOTION_NOTIFY with new position (%d,%d)", Inputs::game_ai.pointer.x, Inputs::game_ai.pointer.y); |
| 182 | } |
| 183 | |
| 184 | /* Update the pointer coordinates */ |
| 185 | if (dst_window == XCB_NONE) { |
| 186 | /* Relative warp */ |
| 187 | Inputs::game_ai.pointer.x += dst_x; |
| 188 | Inputs::game_ai.pointer.y += dst_y; |
| 189 | } |
| 190 | else { |
| 191 | /* Absolute warp */ |
| 192 | Inputs::game_ai.pointer.x = dst_x; |
| 193 | Inputs::game_ai.pointer.y = dst_y; |
| 194 | } |
| 195 | |
| 196 | if (Global::shared_config.mouse_prevent_warp) { |
| 197 | xcb_void_cookie_t cookie{0}; |
| 198 | return cookie; |
| 199 | } |
no test coverage detected