|
Home > Archive > Unix Programming > November 2007 > How keyboard knows which tty goes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How keyboard knows which tty goes
|
|
| Bin Chen 2007-10-18, 7:37 am |
| Hi,
In Linux, if I press a key in the keyboard, how the keyboard driver
knows which tty is getting the input char? What machanism it uses? Is
this way UNIX compatible?
Thanks.
Bin
| |
| hai.xu1@siemens.com 2007-11-02, 1:31 am |
| On Oct 18, 5:21 pm, Bin Chen <binary.c...@gmail.com> wrote:
> Hi,
>
> In Linux, if I press a key in the keyboard, how the keyboard driver
> knows which tty is getting the input char? What machanism it uses? Is
> this way UNIX compatible?
>
> Thanks.
> Bin
you can use command
tty
to know which tty receive the keyboard input.as I know, every process
has a controlling terminal. It is OS not the keyboard to decide which
tty will receive the keyboard input
| |
| Barry Margolin 2007-11-03, 1:37 am |
| In article <1192699277.008021.92480@y27g2000pre.googlegroups.com>,
Bin Chen <binary.chen@gmail.com> wrote:
> In Linux, if I press a key in the keyboard, how the keyboard driver
> knows which tty is getting the input char? What machanism it uses? Is
> this way UNIX compatible?
I'm guessing that your question is about when you're using X windows,
how does it know which window's tty the input should go to.
This is handles by the X server and the X client applications. The X
server has an idea of "keyboard focus", which is the window that is
associated with the keyboard at any particular time. Depending on the
window manager you use, this may be a window that you've actively
clicked on, the window that the mouse happens to be in, or perhaps some
other paradigm.
When you type something, the X server sends the input event to the
window with keyboard focus. This sends a keyboard event message to the
client application associated with the window. If the client is a
terminal application, such as xterm or gnome-terminal, it has set up a
pseudo-terminal. It converts the keyboard event to an ASCII character,
and sends it to the pseudo-terminal, which the user application then
reads from its tty device.
This is essentially how it works on all Unix and Linux OSes.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
|
|
|
|