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
Printable View
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
On Oct 18, 5:21 pm, Bin Chen <binary.c...@gmail.com> wrote:[color=blue]
> 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[/color]
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
In article <1192699277.008021.92480@y27g2000pre.googlegroups.com>,
Bin Chen <binary.chen@gmail.com> wrote:
[color=blue]
> 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?[/color]
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, [email]barmar@alum.mit.edu[/email]
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 ***