Cursor goes missing on breakpoint

Currently using SDL_SetRelativeMouseMode and SDL_SetWindowGrab to lock the cursor within the window, however on a breakpoint the cursor doesn’t reappear and is locked within the window area.

SDL Version: 2.0.3
Platform: Ubuntu 14.04

This is “normal”, as far as I can tell, but annoying.
I’m not sure if SDL can really avoid this (I’d love to hear the opinion
of someone familiar with Linux/X11 on this!), though, especially when
using real relative mouse mode and not just warping the cursor back to
the middle of the window each frame (which wouldn’t happen while paused
in the debugger).
And AFAIK there is no way to execute more code on the program-site when
breaking to the debugger - most probably not if the debugger breaks
because a breakpoint, but even when the debugger just reacts to a signal
(assertion, segfault, …) it’s probably not possible to have your own
signal handler called before the debugger kicks in. Again, I’d love a
comment on this from someone with more experience.

Some possible workarounds:

  • Do the warping yourself (i.e. don’t use relative mousemode and
    windowgrab, but SDL_WarpoMouseInWindow()) - works, but kinda sucks
    (additional work you shouldn’t have to worry about and you don’t get
    unaccelerated “raw” mouse input like you would in relative mode)

  • Bind X86Ungrab to some key-combination and press that when a
    breakpoint is hit. See
    http://unix.stackexchange.com/questions/40458/command-for-forcing-a-pointer-ungrab-captured-mouse-release
    for details. Note that someone could use the same key-combination to
    disable your screensaver, so this is a possible security-risk.

  • gdb allows you to call functions. Create a global function to ungrab
    the mouse (so you don’t have to call SDL_SetWindowGrab with the pointer
    to the window in gdb), e.g. “void DEBUG_UngrabInput() { … }” and call
    it from gdb (“call DEBUG_UngrabInput()”). For this you at least need to
    be able to navigate to the gdb console without a mouse (with Alt-Tab or
    something).
    It might be possible to do this automatically, i.e. configure gdb to
    execute “call DEBUG_UngrabInput()” on a breakpoint.
    https://sourceware.org/gdb/onlinedocs/gdb/Break-Commands.html#Break-Commands
    might be a first step, maybe there’s a better way to always execute it
    (all breakpoints and also on signals like SIGINT or segfaults).

Cheers,
DanielAm 09.10.2014 22:49, schrieb AlexRou:

Currently using SDL_SetRelativeMouseMode and SDL_SetWindowGrab to lock
the cursor within the window, however on a breakpoint the cursor doesn’t
reappear and is locked within the window area.

SDL Version: 2.0.3
Platform: Ubuntu 14.04