How keyboard knows which tty goes - Unix

This is a discussion on How keyboard knows which tty goes - Unix ; 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...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How keyboard knows which tty goes

  1. How keyboard knows which tty goes

    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


  2. Re: How keyboard knows which tty goes

    On Oct 18, 5:21 pm, Bin Chen 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


  3. Re: How keyboard knows which tty goes

    In article <1192699277.008021.92480@y27g2000pre.googlegroups.c om>,
    Bin Chen 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 ***

+ Reply to Thread