CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
    • 1.The Structure and Evolution of the X Window System
    • 2.Libraries and the Toolkit Layers
    • 3.Window Manager · Display Manager · Desktop Environment
    • 4.Running X and Remote Displays
    • 5.Week 8 Comprehensive Review: The X Window Name Tag Sheet
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 8/Day 2

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 8 · Day 2~21 min read

Day 2 - Libraries and the Toolkit Layers

📌 Key Takeaways

  • An X client talks to the X server through two layers — low-level libraries and the toolkits above them.
  • There are two low-level libraries: Xlib and XCB. XCB is the lower level, closer to the X server.
  • The representative toolkits are GTK+ · Qt · FLTK · Motif · Tk.
  • GTK+ is written in C and used by GNOME, and Qt is written in C++ and used by KDE.
  • They form pairs — Xlib ↔ XCB (low-level libraries), GTK+ ↔ Qt (toolkits).

The Four Layers

X Window layer structure leading from application, toolkit, and low-level library to the X server

  • The further down you go, the closer to the X server and the lower the level. This up-down relationship is asked as is.
  • You can build a program with Xlib alone without a toolkit, but even drawing a single button means drawing each line yourself.

Until One "OK" Button Appears on the Screen

LayerWhat is said at this layerJob
Application"Put an 'OK' button here"Decides what to show
Toolkit (GTK+ · Qt)"A button is a rounded rectangle with text, and the color changes when pressed"Builds the look and behavior of widgets
Low-level library (Xlib · XCB)"A rectangle at coordinates (10,20), with text inside"Converts drawing instructions into X protocol messages and sends them
X server(Draws on the screen as received)Handles the actual screen output and input devices
  • The three layers above (application, toolkit, low-level library) are all on the X client side. That is why Xlib and XCB are called "X client libraries", and they must not be mistaken for part of the X server.
  • When you press the button with the mouse, it goes up in the opposite direction — the X server sends an event, the low-level library receives it, and the toolkit interprets it as "the button was pressed" and tells the program.
  • Thanks to the layering, even if what is below changes, what is above can be used as is. GTK+ and Qt also work on Wayland, so programs built with toolkits run on both X and Wayland. Old programs that call Xlib directly need the XWayland we saw yesterday.

Low-Level Libraries — Xlib and XCB

ItemXlibXCB
Full nameX LibraryX protocol C-language Binding
AppearedTraditional, oldA later replacement
LayerA library wrapping the X protocolThinner — closer to the X server
CommunicationMainly synchronousAsynchronous
SizeHeavyLight

The answer to the question "Which is the low-level X client library closest to the X server?" is XCB. Qt, GTK+, and FLTK are toolkits in a layer above that, so they cannot be the answer.

  • XCB was made to replace Xlib. It is closer to the protocol and has less latency.
  • Today even Xlib's internals have been reimplemented to run on top of XCB.

What Is the Difference Between Synchronous and Asynchronous

   Xlib (synchronous)                   XCB (asynchronous)
   sends request 1                       sends request 1
     … waits until the reply arrives     sends request 2
   receives reply 1                      sends request 3
   sends request 2                         … does other work
     … waits                             receives replies 1 · 2 · 3 when needed
   receives reply 2
  • The picture above is the difference when sending requests that need a reply, such as asking a window's size.
  • If the X server is on the other side of a network, each reply takes time. The wait-one-at-a-time approach gets slower the more requests there are, while the send-them-all-at-once approach overlaps the waiting times. That is the underlying meaning of XCB having "less latency".
  • "Lower level" means "less convenient but closer to the X protocol". XCB transposes the protocol's messages into functions almost as they are, and Xlib adds more conveniences on top of that. It does not mean lower performance.
Confusing phrasingCorrect answer
The library closest to the X server, the lowest-level oneXCB
The traditional, oldest low-level libraryXlib
"Made to replace Xlib"XCB
The asynchronous oneXCB
The one that provides widgetsA toolkit (GTK+ · Qt …) — neither of the two
  • Some old X programs put a layer called Xt (X Toolkit Intrinsics) between Xlib and the toolkit. It is a layer that only supplies the framework for building widgets, and Motif and the Athena widgets (Xaw) used by the basic X programs (xterm, xclock) were built on top of it.

Toolkits

These are libraries that build widgets such as buttons, menus, and checkboxes.

ToolkitFull name · originLanguageUsed by
GTK+GIMP ToolkitCGNOME, GIMP, Xfce
Qt(pronounced "cute")C++KDE, VLC
FLTKFast Light ToolkitC++Lightweight programs
Motif—CCDE, traditional commercial Unix
TkThe graphical part of Tcl/TkTclFor scripts
XForms—CAn old toolkit

Pairs to Memorize

PairWhat they share
Xlib ↔ XCBBoth are low-level libraries
GTK+ ↔ QtBoth are representative toolkits
GNOME ↔ XfceBoth are desktop environments that use GTK+
KDE ↔ QtKDE is built with Qt

It is asked in the form "the one of a different kind from the rest". For example, among Xlib · XCB · GTK+, GTK+ is a toolkit so it is different, and among GTK+ · Qt · FLTK · XCB, XCB is a low-level library so it is different.

GTK+ and Qt

ItemGTK+Qt
LanguageCC++
OriginDeveloped to build GIMPNorway's Trolltech
Representative desktopsGNOME, Xfce, LXDEKDE, LXQt
Representative programsGIMP, FirefoxVLC, Krita
  • There are questions on the origin that GTK+ = GIMP Toolkit. What was developed to build the image editor GIMP became an independent toolkit.
  • It also asks whether the language is C or C++. GTK+ is C, Qt is C++.

Why the Camps Split in Two

   1996  KDE starts      chose Qt — but at the time Qt was not under a free software license
     │
   1997  GNOME starts    raised the banner of "a completely free desktop" and chose GTK+
     │
   after  Qt was also released under GPL · LGPL — the license problem was resolved but the two camps remained
  • The direct trigger for GNOME's creation was Qt's license. So "GNOME ↔ GTK+" and "KDE ↔ Qt" are not coincidental combinations but pairs bound from the start.
  • This background connects to the fact that GTK+ is part of the GNU project and that its license is the LGPL.
ItemGTK+Qt
LicenseLGPLOffered under GPL · LGPL together with a commercial license
Changes of its makerGIMP developers → GNOME projectTrolltech → Nokia → today's The Qt Company
Where it runsLinux-centered, also supports Windows and macOSBroadly across Linux, Windows, macOS, even mobile
Name notationFrom recent versions, the + is dropped and it is written GTK—
  • On exam choices it still appears as GTK+. It is the same as GTK.
  • It is a "toolkit made in C", not "a toolkit usable only from C". Both GTK+ and Qt can be called from other languages such as Python. What the question asks is the language in which the toolkit itself is written.

Guessing the Toolkit from the Program

ProgramKindToolkit
GIMPImage editorGTK+ (the starting point of this toolkit)
gedit · NautilusGNOME's editor · file managerGTK+
Firefox (Linux version)Web browserGTK+
Dolphin · Konsole · KateKDE's file manager · terminal · editorQt
VLC · KritaVideo player · drawing toolQt
xterm · xclock · xeyesBasic X programsNo toolkit; Xlib · Xt · Athena widgets
  • Remember it grouped as programs that come with GNOME are GTK+, and programs that come with KDE are Qt. Many KDE programs have a K in the name.
  • Even with different toolkits, they appear together on the same screen. You may run VLC, a Qt program, on GNOME. In the end both ask the same X server to draw for them. The buttons and menus just look different from each other.

Motif

  • It was a commercial toolkit of the late 1980s and the standard of traditional Unix workstations.
  • CDE (Common Desktop Environment) was built with Motif.
  • It was later released as open source and became OpenMotif, and LessTif existed as a compatible implementation.
  • It is hardly used now, but the name appears on the exam.

Layer Summary

   application
        │
   ┌────┴──────────────────────────┐
   │  toolkit                       │   GTK+(C) · Qt(C++) · FLTK · Motif · Tk
   └────┬──────────────────────────┘
        │
   ┌────┴──────────────────────────┐
   │  low-level library             │   Xlib · XCB   ← XCB is further down
   └────┬──────────────────────────┘
        │  X protocol
        ▼
     X server

The Remaining Toolkits, One Line Each

ToolkitOne thing to rememberNames that come with it
FLTKAims to be small and fast. Read as "full tick"Fast Light Toolkit
MotifThe standard of the commercial Unix era. Built on top of XtCDE, OpenMotif, LessTif
TkPaired with the scripting language Tcl. Python's tkinter uses this tooTcl/Tk
XFormsAn old lightweight toolkit. Xfce was originally built with this—

Slotting Names into Layers

NameLayerWhy it is easy to get wrong
XCBLow-level libraryAn unfamiliar name, mistaken for a toolkit
XlibLow-level libraryMistaken for part of the X server — it is on the client side
GTK+ToolkitConfused with GNOME (a desktop environment)
QtToolkitConfused with KDE (a desktop environment)
FLTK · Motif · TkToolkitThe names are unfamiliar
GIMPApplicationMistaken for a toolkit because of "GIMP Toolkit"
GNOME · KDEDesktop environmentLayers get mixed up when memorized as a bundle with toolkits
X11Protocol versionMistaken for a library name
X.org ServerX server—
  • A single set of choices deliberately mixes names from different layers. If it asks for "what is not a toolkit", Xlib and XCB (lower layer) or GNOME and KDE (upper layer) are the answer, and if it asks for "what is not a low-level library", one of the toolkits is the answer.
  • It also asks about order. The order closest to the X server is XCB → Xlib → toolkit (GTK+, Qt) → application.
Memory hookContent
A name starting with X is a lower layerXlib and XCB are low-level libraries (but XForms is a toolkit)
A name ending in tk/TK is a toolkitGTK+, FLTK, Tk — short for toolkit
C is G, C++ is QGTK+ = C = GNOME, Qt = C++ = KDE
CB is C BindingXCB = X protocol C-language Binding

Tomorrow we cover the distinctions among the window manager · display manager · desktop environment that sit on top of this.

📖 Glossary

  • Xlib: The traditional low-level library that wraps the X protocol in functions.
  • XCB: X protocol C-language Binding. A low-level library thinner than Xlib and closer to the X server.
  • Toolkit: A higher-level library that provides widgets such as buttons and menus.
  • GTK+: GIMP Toolkit. Written in C and used by GNOME.
  • Qt: A toolkit written in C++. Used by KDE.
  • FLTK: Fast Light Toolkit. A C++ toolkit that aims to be light and fast.
  • Motif: A toolkit used on traditional commercial Unix. CDE was built with it.
  • Widget: An individual element that makes up the screen, such as a button, menu, or scrollbar.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which is the low-level X client library closest to the X server?

Question 2

Which programming language was used to write the GTK+ toolkit?

Question 3

Which toolkit is the foundation of the KDE desktop environment?

Question 4

Which of the following is in a different layer from the other three?

Question 5

Which program gave its name to the GTK+ toolkit?

PreviousThe Structure and Evolution of the X Window SystemWeek 8 · Day 1Next Window Manager · Display Manager · Desktop EnvironmentWeek 8 · Day 3

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • The Four Layers
  • Until One "OK" Button Appears on the Screen
  • Low-Level Libraries — Xlib and XCB
  • What Is the Difference Between Synchronous and Asynchronous
  • Toolkits
  • Pairs to Memorize
  • GTK+ and Qt
  • Why the Camps Split in Two
  • Guessing the Toolkit from the Program
  • Motif
  • Layer Summary
  • The Remaining Toolkits, One Line Each
  • Slotting Names into Layers
  • Glossary
  • Practice Questions