| 123 | #endif |
| 124 | |
| 125 | void inputgrab(bool on, bool delay = false) |
| 126 | { |
| 127 | #ifdef SDL_VIDEO_DRIVER_X11 |
| 128 | bool wasrelativemouse = relativemouse; |
| 129 | #endif |
| 130 | if (on) |
| 131 | { |
| 132 | SDL_ShowCursor(SDL_FALSE); |
| 133 | if (canrelativemouse && userelativemouse) |
| 134 | { |
| 135 | if (SDL_SetRelativeMouseMode(SDL_TRUE) >= 0) |
| 136 | { |
| 137 | SDL_SetWindowGrab(screen, SDL_TRUE); |
| 138 | relativemouse = true; |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | SDL_SetWindowGrab(screen, SDL_FALSE); |
| 143 | canrelativemouse = false; |
| 144 | relativemouse = false; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | SDL_ShowCursor(SDL_TRUE); |
| 151 | if (relativemouse) |
| 152 | { |
| 153 | SDL_SetWindowGrab(screen, SDL_FALSE); |
| 154 | SDL_SetRelativeMouseMode(SDL_FALSE); |
| 155 | relativemouse = false; |
| 156 | } |
| 157 | } |
| 158 | shouldgrab = delay; |
| 159 | |
| 160 | #ifdef SDL_VIDEO_DRIVER_X11 |
| 161 | if ((relativemouse || wasrelativemouse) && sdl_xgrab_bug) |
| 162 | { |
| 163 | // Workaround for buggy SDL X11 pointer grabbing |
| 164 | union { SDL_SysWMinfo info; uchar buf[sizeof(SDL_SysWMinfo) + 128]; }; |
| 165 | SDL_GetVersion(&info.version); |
| 166 | if (SDL_GetWindowWMInfo(screen, &info) && info.subsystem == SDL_SYSWM_X11) |
| 167 | { |
| 168 | if (relativemouse) |
| 169 | { |
| 170 | uint mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask; |
| 171 | XGrabPointer(info.info.x11.display, info.info.x11.window, True, mask, GrabModeAsync, GrabModeAsync, info.info.x11.window, None, CurrentTime); |
| 172 | } |
| 173 | else XUngrabPointer(info.info.x11.display, CurrentTime); |
| 174 | } |
| 175 | } |
| 176 | #endif |
| 177 | } |
| 178 | |
| 179 | |
| 180 | void setfullscreen(bool enable) |
no outgoing calls
no test coverage detected