<type>documentation</type>
<domain>debug</domain>
<id>debug-x-grab</id>
<title>Debugging Code with XGrab* Calls</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>per+</product>

Under X11, Wing does not attempt to break ``XGrabPointer`` or ``XGrabKey`` and similar
resource grabs when your debug process pauses. This means that X may be unresponsive to
the keyboard or mouse or both in some debugging cases.

Here are some tips for working around this problem:

``(1)`` Most Linux systems offer some way to break through X11 pointer and
keyboard grabs. 

For example, ``X.org`` installations define a key symbol that releases all pointer and
keyboard grabs. You can map a key sequence to it with `xdotool
<https://www.semicomplete.com/projects/xdotool/>`__ as in the following example::

  xdotool ctrl+alt+n XF86Ungrab

``(2)`` Some toolkits have an option to disable resource grabs specifically to avoid this
problem during debugging. For example, PyQt has a command line option ``-nograb`` that
prevents it from ever grabbing the keyboard or pointer. Adding this to the debug process
command line solves the problem.

When this option is not available, another option is to move processing into a timer or
idle task so it occurs after the grab has been released.

``(3)`` If all else fails, you can log in remotely, use ``ps`` to find the debug process,
and kill it with ``kill`` or ``kill -9`` . This will unlock your X display.

``(4)`` Setting DISPLAY to send your debug process window to another X display avoids
tying up Wing in this way. The remote display will release its grabs once you kill the
debug process from the IDE.
