Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0007778Dwarf FortressGeneralpublic2014-08-01 03:512017-07-23 01:32
Urist McKracken 
LinuxUbuntu14.04 LTS
0007778: Keyboard input stops working after fullscreen/window toggle (F11)
On Ubuntu 12.04 (SDL 1.2.15) DF sometimes no longer accepts any keyboard input after a toggle from fullscreen to window, making it impossible to save and quit the game. Mouse input (zoom) still works. For me this happens at least with versions 0.40.03, 0.40.04 and 0.40.05.
Toggle fullscreen/window (F11)
No tags attached.
related to 0005260resolved Toady One Can't play fullscreen on Mac OS X Lion (bug in outdated SDL) 
has duplicate 0008565resolved lethosor Fullscreen mode does not allow any keystrokes to go through 
Issue History
2014-08-01 03:51Urist McKrackenNew Issue
2014-08-01 05:22DwarfuRelationship addedrelated to 0005260
2014-08-01 07:23Urist McKrackenNote Added: 0028079
2014-08-01 10:57DwarfuOS Version12.04 LTS => 14.04 LTS
2014-08-01 10:58DwarfuNote Edited: 0028079bug_revision_view_page.php?bugnote_id=0028079#r10614
2014-08-26 06:39ptb_ptbNote Added: 0029640
2014-08-26 07:10lethosorNote Added: 0029645
2014-08-30 09:06Urist McKrackenNote Added: 0029801
2014-12-09 14:52bjh21Note Added: 0031302
2014-12-09 14:53bjh21Note Edited: 0031302bug_revision_view_page.php?bugnote_id=0031302#r12501
2014-12-09 20:22kicking jayNote Added: 0031309
2014-12-11 14:21lethosorRelationship addedhas duplicate 0008565
2014-12-15 16:03bjh21Note Added: 0031336
2014-12-15 16:04bjh21Issue Monitored: bjh21
2014-12-15 16:09bjh21Note Added: 0031337
2014-12-15 20:17lethosorAssigned To => lethosor
2014-12-15 20:17lethosorStatusnew => acknowledged
2014-12-16 03:24bjh21Note Edited: 0031337bug_revision_view_page.php?bugnote_id=0031337#r12520
2014-12-16 05:21bjh21Note Added: 0031340
2015-10-28 20:32chuzzumIssue Monitored: chuzzum
2017-07-23 01:32MaXMCNote Added: 0036671

Urist McKracken   
2014-08-01 07:23   
(edited on: 2014-08-01 10:58)
OS Version is Ubuntu 14.04 LTS, not 12.04. Sorry about that. Bug occurs on initial start screen too, and can be triggered by switching from fullscreen to window repeatedly.

Manager's Note: OS Version corrected.

2014-08-26 06:39   
Do all keys stop working, or just some?

I have a bug for DF in Windows where nearly all keys stop working, sometimes, after ALT+TAB.

The Space key and ESC key still work in my case.
2014-08-26 07:10   
ptb_ptb, does 0006455 explain your problem?
Urist McKracken   
2014-08-30 09:06   
In my case, all keys stop working. Doesn't look like a stuck modifier key, as no modifiers are used when the bug occurs.
2014-12-09 14:52   
(edited on: 2014-12-09 14:53)
I've encountered what I think is the same problem (similarly on Ubuntu 14.04, usually after switching out of full-screen mode). I've found a workaround, namely a way to inject keypresses into Dwarf Fortress that it actually listens to:

Install the "xdotool" package.

In a terminal, run "xwininfo" and click on the Dwarf Fortress window to get its window id (in my case, 0x4200003), the run:

xdotool key --window 0x4200003 Escape
xdotool key --window 0x4200003 Down
xdotool key --window 0x4200003 Return

replacing "0x4200003" with the window id you found. Obviously you can change the sequence of keys to suit the state the game got stuck in.

kicking jay   
2014-12-09 20:22   
Reported this in a duplicate a while back.

http://www.bay12games.com/dwarves/mantisbt/view.php?id=8565 [^]
2014-12-15 16:03   
With the help of an X protocol tracer (http://www.chiark.greenend.org.uk/~sgtatham/xtruss/ [^]), the X Input Method protocol specification (http://www.x.org/releases/X11R7.7/doc/libX11/XIM/xim.html [^]), and several mugs of tea, I think I've found the cause.

When there's an X Input Method server (IMS) present, as there usually is on Ubuntu, Dwarf Fortress (DF) sends all its keyboard events to the IMS using the XIM protocol. In normal operation, when DF receives a KeyPress event from the X server, it passes it to the IMS in an XIM_FORWARD_EVENT message. The IMS (assuming it's not interested in this event) passes it back in another XIM_FORWARD_EVENT message, this time with the "synchronous" flag set. The "synchronous" flag tells DF that it now needs to send an XIM_SYNC_REPLY message, which it duly does.

When things go wrong, DF sends the XIM_FORWARD_EVENT message as usual, but fails to read the reply message and hence never sends the XIM_SYNC_REPLY message. Instead, it just carries on sending XIM_FORWARD_EVENT messages. It looks like the IMS refuses to deal with these, presumably because it's still waiting for XIM_SYNC_REPLY. This means that the keypresses never get forwarded back to DF, and it sits there unresponsive.

I've found that I can reproduce the bug simply by pressing F11 a few times in rapid succession (about five times in a second is usually enough).

I doubt that DF deliberately interfaces with input methods itself, so presumably this bug is somewhere in the depths of SDL or whatever library is implementing the XIM protocol.

For the record, on my Ubuntu 14.04 LTS system, the version of the SDL packages is "1.2.15-8ubuntu1.1".
2014-12-15 16:09   
(edited on: 2014-12-16 03:24)
Confirming that the problem relates to XIM, if I kill the "ibus-daemon" process (which is the input method server) before starting DF, I can hammer F11 to my heart's content and DF continues to respond to the keyboard. Note that killing "ibus-daemon" while DF is running is a Very Bad Idea: it causes DF to segfault.

2014-12-16 05:21   
I've just tested on an Ubuntu 14.10 64-bit live image and after installing lots of 32-bit libraries I was able to get DF to run and it exhibited basically the same behaviour as on 32-bit 14.04: it tangled up the XIM exchange on rapid presses of F11, but could be recovered with the aid of "xdotool". I forgot to try killing ibus-daemon, but I have no reason to suspect this would behave any differently from 14.04 LTS.
2017-07-23 01:32   
I have the same problem on Ubuntu 17.04.

It seems I triggered it by pressing F11 then Alt+Tab and then F11 again.

The game answers to mouse input from DFHack though.