1

I started Firefox from by bash window by entering the command "firefox",
it started the Firefox browser in the user interface.

enter image description here

When I checked the Firefox process by entering "ps" command, I found Firefox process has a controlling terminal attached to it (pts12 / which is evident from above screenshot) and also the firefox process has bash as the parent process.

Now, how am I able to provide the keyboard input directly to the Firefox browser window? (I have typed "Hello world" in the browser)
Since the tty is attached to the process, the input to Firefox should be via terminal window right?

enter image description here

I know there is something called X-11 involved here, but can't get the whole picture

This question is asked keeping the following as base which doesn't provide enough information on the above queries, How do keyboard input and text output work?

2

Input to X11 applications doesn’t go through a tty device, it’s provided as X11 events. The X11 server receives the input event, determines which application currently has the focus, and translates the input event into the corresponding X11 event.

The X11 server provides an abstraction for the hardware in the system. X11 applications run as clients of the server, and receive events from it. Events can even be received remotely, i.e. you can run an X11 server on your local system and use it to interact with X11 applications running on another system.

You can see this happening by running xev, as mentioned in How do keyboard input and text output work?

6
  • You mean to say teminalEmulators, browsers, games with UI etc..all are X11 (GUI) applications? But the programs like ls, cd, cat, java -jar which doesn't have an UI are not x11 applications?
    – user446659
    Dec 16 '20 at 9:55
  • Thanks @Stephen Kitt. Also, why does teminal emulators have a pseudo tty (eg.,pts12) attached to it. So, in this case, do the terminal emulators consume input directly from x11 or tty device?
    – user446659
    Dec 16 '20 at 9:56
  • Yes, terminal emulators, browsers, games etc. are typically X11 applications (or Wayland applications now, but the considerations are similar). Programs like ls, cd, Midnight Commander etc. are not X11 applications; some of them expect to run in a terminal (Midnight Commander), others expect to be able to write to their standard output (ls, interactive shells...) and that is usually handled by a terminal or terminal emulator of some sort, but it could also be an editor buffer etc. Dec 16 '20 at 9:59
  • I’ll address your other question separately. Dec 16 '20 at 10:00
  • @ Stephen Kitt Can you suggest some docs or books which I can go in detail about this? and the architecture around
    – user446659
    Dec 16 '20 at 10:02
0

As mentioned in another answer and comment, but I try to make clearer here.

Standard in, standard out, standard error, ttys, are one concept there were in the original Unix and still very much used today: ls, cat grep, et al.

X11, keyboard focus, windows (a view on a program, not an OS from the 1980s), are another: firefox, konsole, et al.

They can both work together e.g. a virtual terminal is both an X11 program and provides a tty (pseudo tty).

Learn both separately at first.

  • What is stdin, stdout, stderr, what are pipes, file-redirection, etc.
  • What is X11, window-manager, a window, keyboard-focus, etc.
  • Then if you need it, pseudo ttys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.