[Discuss] keyboard focus

bctill bctill at ece.uvic.ca
Sun Apr 2 20:17:22 PDT 2023


Hi all --

In windows, there are very clear visual cues letting me know which 
window my keystrokes will be sent to.  This window is said to "have the 
focus".  The keyboard is a producer of events (mostly KeyDown and KeyUp 
events) and these events are routed to the window that has the focus.  
This window is a consumer of events, so we have a textbook case of 
producer/consumer concurrency.

In Ubuntu with the default Gnome desktop, visual cues are few and far 
between.  Windows don't even have borders, so I have to squint to 
distinguish between the text in my editor and the text in my terminal, 
and I certainly can't tell by looking at the screen which window will 
receive the next key I type.

How is keyboard input handled in Linux?  How are keystrokes routed to 
windows?  Do these questions apply to Linux, or perhaps X11?  Or do the 
answers differ between GTK and Qt, or even from desktop to desktop?

Is there a way to get better visual cues from the desktop?  Can I make 
window borders or title bars change color to indicate where my 
keystrokes will go?  Can I separate the processing of KeyDown and KeyUp 
events?  Can I detect when several keys are down at the same time?  And, 
again, if "it depends", then what does it depend on?

Regards,
-- Bernie.



More information about the Discuss mailing list