There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

[solved] How to unfocus a frozen application that grabbed the pointer/keyboard in Xorg?

I’m posting here, because i have no idea how to search for this.

When exploring GTK programming, I ran into a very specific problem:

I created an application that crashes when i open a GtkDropDown, so to debug the crash I ran my app inside GDB. When GDB notices an application crashing, it freezes it, so i can analyze the state in which it crashed. The GtkDropDown grabs the pointer, like rofi or i3lock grab the pointer to prevent the window manager from exercising any keyboard shortcuts. Problem is now, the application gets frozen while the pointer is grabbed, so I’m basically locked out of my window manager.

To close the application, I can just log into a TTY and kill the GDB process, but I would like to have a simpler solution, that possibly doesn’t kill the application.

Is there a way with Xorg to get out of such a situation without switching to the TTY? If not, why can a single user application completely prevent you from using anything in your graphical environment?

Because Xorg bad? Should I switch to Wayland?

Solution (thanks to @trachemys):

  • switch to TTY and log in
  • export DISPLAY=':0’
  • setxkbmap -option grab:break_actions
  • xdotool key XF86Ungrab
CarlosCheddar ,

I recently enabled SysRq to kill processes that hang and it’s been working nicely. Haven’t had to restart in a while. en.m.wikipedia.org/wiki/Magic_SysRq_key

d_k_bo ,

Xorg bad?

It’s not bad. It’s just old, broken and unmaintained.

wallmenis ,

That is another word for “bad”… But I guess that was the joke 😅

vector_zero ,

old

Old doesn’t mean bad

broken

Is it?

unmaintained

Is it?

I use Wayland personally, but I’ve had almost zero issues with X in the last decade, maybe with the exception of minor screen tearing several years back.

d_k_bo ,

My comment above should be taken with a grain of salt.

broken

It works in many cases. From a privacy/security standpoint, it is a nightmare since any program can just access all other windows. Multiple monitor setups with different scaling don’t work at all. …

unmaintained

While the git repo receives some commits, most of them are fixes for xwayland. Most X11 contributors that are still active are working on wayland now. See gitlab.freedesktop.org/xorg/xserver/-/…/master and (not so serious) floss.social/

vector_zero ,

Ah, I’ve almost always used a single monitor setup, so my use case wasn’t weird enough to break X11. That said. Even Wayland is wonky on my multi monitor setup at work, though that’s probably more a GNOME thing than a Wayland thing.

I do still think the approach they took with Wayland is a tad odd, in that everyone has to implement it themselves. But hey, if it works, it works.

bjoern_tantau ,
@bjoern_tantau@swg-empire.de avatar

Does CTRL+ALT+ESC and click work? I think it’s Xorg’s way of killing a window.

quantenzitrone OP ,

nope, that is probably window manager specific, i’m using i3, but any keyboard shortcuts get disabled when a window grabs the pointer anyway, i found a solution and updated my post

trachemys ,

The key word to be searching for is “ungrab” mouse. here is a stackexchange on this.. On some systems ctrl-alt-/(on keypad) might work, but that is often disabled for security.

quantenzitrone OP ,

This is exactly what I needed, thanks!

anon5621 ,

Recommend u to learn xorg documentation www.x.org/wiki/guide/

quantenzitrone OP ,

Maybe once I am a bit more used to reading and understanding documentation for large existing libraries and programs.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines