XCB / X11 tutorial for beginners 1

XCB / X11 tutorial for beginners 1

Codotaku

1 год назад

3,855 Просмотров

XCB (X protocol C-language Binding) is a library implementing the client side of the X11 display server protocol. XCB is written in the C programming language and distributed under the MIT License. The project was started in 2001 by Bart Massey and aimed to replace Xlib.

XCB was designed as a smaller, modernized replacement for Xlib, previously the primary C library for communicating with the X window system, coinciding with a complete overhaul of the X implementation that took place during the early 2000s.[1] The main goals of XCB are to:
- reduce library size and complexity.
- provide direct access to the X11 protocol.
More information in Wikipedia:
https://en.wikipedia.org/wiki/XCB

Useful resources:
https://xcb.freedesktop.org/
https://tronche.com/gui/x/
https://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html
https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html

Am using:
- Language: C 17
- Libraries: xcb, xcb-icccm, xcb-util
- OS: Arch Linux (Manjaro KDE)
- Build system: CMake (Ninja)
- Compiler: GCC
- IDE: JetBrains CLion

This channel is AD-free and will always be AD-free, it's purely for educational purposes in the name of the one and only God and the name of knowledge and science.

This video is Creative Commons, you're free to use all of it or part of it for educational purposes without any permissions as long as you mention my channel's name or put a link to this video as a reference.

I'm an XCB beginner too, but my knowledge and videos are based on experience, research, trial, and error. I believe in teaching a subject while I am a beginner because a beginner won't skip details and will explain the subject more beginner-friendly way than a professional at the cost of potential loss of accuracy and rigor. the struggle of learning is still fresh on a beginner's mind. Finally am learning more by teaching and am learning better code and asking more questions because I know someone will read my code and watch my video : )
TLDR: A beginner understands beginners more than an expert and teaching is a suitable learning method.

Discord server:
https://discord.gg/mxqM4hf

GitHub repo:
https://github.com/CodesOtakuYT/XCB-Tutorial

GitHub commit:
https://github.com/CodesOtakuYT/XCB-Tutorial/commit/4aad55a2bc592d68e6a7197ce3718a8d0e42a208

GitHub commit (repo):
https://github.com/CodesOtakuYT/XCB-Tutorial/tree/4aad55a2bc592d68e6a7197ce3718a8d0e42a208

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
00:00 Intro
01:00 Project setup
02:20 Creating XCB Connection
07:30 Selecting screen
13:00 Creating window
24:20 Changing window title
33:20 Making window unresizable
42:00 Registering window events
44:50 Handling events
59:00 Clearing window background
01:13:00 Handling window close event
01:40:00 Abstract event processing into a function
01:51:20 Registering for more events like mouse and keyboard
Ссылки и html тэги не поддерживаются


Комментарии:

@joseloeza371
@joseloeza371 - 16.07.2023 03:38

Excellent video thanks. Im working and new to freebsd please how I can install library xcb on my system? Do you know a book ?

Ответить
@cs127
@cs127 - 10.05.2023 11:35

I tried to print the value of screen->black_pixel and screen->white_pixel as hex integers, and the upper byte was 00 instead of FF, meaning that the upper byte of the 32-bit integer colours is not alpha, and probably just unused.
As for how to properly use transparency, I have yet to figure that out.

Also, you are right about the "format" of atoms being 8.
According to the Linux manual page for xcb_change_property, the "format" parameter specifies the bit width of each unit of information, which in the case of ASCII characters, is 8.

Amazing video by the way! This is currently the only comprehensible xcb tutorial I've seen! Thank you!

Ответить
@thorrrik4924
@thorrrik4924 - 19.03.2023 15:56

I'm working on a professional project. An UI based application, and I wanted to use xcb. The only problem I got with it, is to manage the language input that are not latin-1. I know that I could use xcb-imdkit, but unfortunately the licence didn't fit our need. But if I will work on a free project, I will definitely use xcb. Your video is very interesting. I learn cool stuff like the use of wait events against poll events. The *_aux functions are very useful and icccm one as well. I used a lot the basic functions in xproto. But it may be clearer to use icccm function.
I'm on the same configuration except that I use clang instead of gcc and C++ 17 instead of C 17.
Thank's for the video. I will watch your other video on rust and vulkan.

Ответить
@alrshdn
@alrshdn - 13.02.2023 04:22

Hello. Thank you for this video. I subscribed.
A7sant!

Ответить
@mulad
@mulad - 02.02.2023 02:59

It's frustrating that the documentation and tutorial is so minimal for XCB, so thanks for digging into things to provide these examples. Now to just figure out how to draw some pixels on the screen in a relatively efficient way.

Ответить
@godnyx117
@godnyx117 - 31.01.2023 16:54

"I had to go through all the pain guys for you"

Well, I don't know if I'm going to seriously even use XCB (as there are other GUI libraries) but bro, you got a sub just for your work! You are awesome!!!!

Ответить
@mrdixioner
@mrdixioner - 21.01.2023 09:48

Very interesting information! The Vulkan is very difficult to understand, but you enlightened me on this issue. However, X11 also interests me a lot. Thank you very much for your videos!!!

Ответить