You are not logged in.

#1 2013-04-18 21:37:25

fawkes5
Member
From: Canada
Registered: 2012-12-23
Posts: 84

A Noobs Quest to Understanding dwm [and window managers in general]

Hello,

I've just switched to dwm. I would like to begin patching and contribute patches to it.
To do this i need to understand dwm, that is... read the source code.

I know a bit of C, will be learning more in the coming days. Looking at the dwm.c, i find it really overwhleming. I feel as though there are lots of fundamental concepts [to windowmanagers, to linux in general] that i don't know enough about, or don't know about at all that gets in the way of my understanding. I've only been with linux/arch for 4 months now.

So i'm looking for some tips!

What concepts do i need to understand in order to understand dwm.c?
Any advice on actually reading dwm.c (general advice also welcome)
Any helpfull resources that helped you?

Thank you for your time!

Offline

#2 2013-04-19 05:16:19

TheCrownedFox
Member
Registered: 2013-04-19
Posts: 1

Re: A Noobs Quest to Understanding dwm [and window managers in general]

I too have undertaken the same quest and run into the same roadblocks you have.

Offline

#3 2013-04-19 07:04:11

msthev
Member
Registered: 2012-04-05
Posts: 177

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Don't try to solve non-existing problems. Start using plain dwm (only editing config.h), familiarize yourself with it → with time you'll get to know it and therefore digging into the code will be a lot easier.
If you just read the code without understanding the program at all, you'll only see a mess. You need to "feel" the program you want to hack — to know what it's doing, so that when you see some part of its code you'll be like "this code does <bla>".
Use it, and when you are comfortable with it, then start asking such question — they'll be a lot easier to answer, and a lot more to the point.

Offline

#4 2013-04-19 07:22:23

fawkes5
Member
From: Canada
Registered: 2012-12-23
Posts: 84

Re: A Noobs Quest to Understanding dwm [and window managers in general]

TheCrownedFox wrote:

I too have undertaken the same quest and run into the same roadblocks you have.

Isn't it nice to know your not alone big_smile

Don't try to solve non-existing problems. Start using plain dwm (only editing config.h), familiarize yourself with it → with time you'll get to know it and therefore digging into the code will be a lot easier.
If you just read the code without understanding the program at all, you'll only see a mess. You need to "feel" the program you want to hack — to know what it's doing, so that when you see some part of its code you'll be like "this code does <bla>".
Use it, and when you are comfortable with it, then start asking such question — they'll be a lot easier to answer, and a lot more to the point.

I know what you mean! Thanks for putting it into words!

I know my question is general and vague, I just don't know
what else to do when I feel this way. Are these types of questions
welcome on the arch forums?

Last edited by fawkes5 (2013-04-19 07:30:48)

Offline

#5 2013-04-19 08:08:39

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Read xlib documentation to understand some of the functions. "bit of C" doesn't work here . If you plan on contributing code to upstream or make patches, you need to give yourself some time. Have some patience and familiarize yourself to dwm.c and see what is going on there. See dwm hackers unite thread. Read what others did there. Learn about XEvents, EWMH atoms etc. In general just use DWM as your primary window manager and hand patch dwm.c if you ever need to. I learned a lot this way. Google is your best friend. If you don't understand what any specific function does, just google it.


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#6 2013-04-19 09:53:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,556
Website

Re: A Noobs Quest to Understanding dwm [and window managers in general]

For learning about Xlib, this is a great reference.

But I'd suggest that you not start by studying dwm.  Use it by all means, but start studying wm code with TinyWM.  In under 40 lines of easy to read C code, you have a functional window manager.  If you get what those 40 lines of code do, all the nice additions dwm makes to those core elements will be more clear.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2013-04-19 12:24:31

whilealive
Member
Registered: 2012-09-04
Posts: 17

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Didn't know about TinyWM. That seems to be really a good starting point, though. Thanks.

Offline

#8 2013-04-19 18:35:16

fawkes5
Member
From: Canada
Registered: 2012-12-23
Posts: 84

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Trilby wrote:

For learning about Xlib, this is a great reference.

But I'd suggest that you not start by studying dwm.  Use it by all means, but start studying wm code with TinyWM.  In under 40 lines of easy to read C code, you have a functional window manager.  If you get what those 40 lines of code do, all the nice additions dwm makes to those core elements will be more clear.

Wow, thats awesome! That's exactly what i should do!!! thanks!

Offline

#9 2013-04-20 17:28:11

jgreen1tc
Member
From: St. Louis
Registered: 2011-05-16
Posts: 251

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Trilby wrote:

For learning about Xlib, this is a great reference.

But I'd suggest that you not start by studying dwm.  Use it by all means, but start studying wm code with TinyWM.  In under 40 lines of easy to read C code, you have a functional window manager.  If you get what those 40 lines of code do, all the nice additions dwm makes to those core elements will be more clear.

This advice is really useful to me as well. What programming language should I teach myself in order to best understand Xlib?

Offline

#10 2013-04-21 00:41:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,556
Website

Re: A Noobs Quest to Understanding dwm [and window managers in general]

Xlib is just a library, and has bindings for *many* languages.  One nice thing about tinywm is that it has been ported to many languages - so take your pick.

If you want to learn about dwm, though, learn C.  EDIT: C and Python would be my top two recommended languages to learn.  C is the most powerful, but python is extremely flexible and allows you to do lots of cool stuff quickly and easily.  I've never really done much with python - as I feel so "fluent" or comfortable in C, I see no advantage in a scripting language to make some things "easy": C is easy for me.

Also, as a caveat, while I love Xlib, if you are starting from scratch you may want to consider xcb instead which many argue is replacing / will replace xlib.  The documentation for xlib is far better, though, so it may be easier to learn.  Also some argue that X itself is nearing its end and will be completely replaced by wayland.  I highly doubt that - but that's a separate topic.

Last edited by Trilby (2013-04-21 00:44:40)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB