Page 1 of 1

X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 9:23 am
by Cyborg Girl
As a programming exercise, I decided to resurrect and modernize a dead X11 window manager (and maybe bloat it up with features at some point).

Step 1: make it actually compile. (Done.)

Step 2: turn on -Werror and fix all the warnings. (Still working on that...)

Step 3: start adding the features I want. Make sure it compiles without errors or warnings. Make sure it actually runs, and does what I want. Rinse and repeat...

Unfortunately that second part is is a bit like wrestling with a boa constrictor, if you know what I mean.

Case in point, the very first one:

Code: Select all
  char **missing, *def = "-";
  int nmissing;

  // load the fontset                                                           
  fs = XCreateFontSet(_display.XDisplay(), fontsetname.c_str(),
                      &missing, &nmissing, &def);


That first line generates a warning in C++. def is initialized from a constant string literal, but is itself mutable, which may not be what you expect; and it gets modified by XCreateFontSet(), whose documentation doesn't actually specify the length of the string it will stuff into that buffer. def is probably going to be initialized to 2 bytes ('-' and the null terminator). XCreateFontSet might then try to force, I dunno, 16 bytes into it. Oops. Not sure how I'll deal with that.

(Also this is the first time I've seen a pointer to a pointer to a pointer... Anywhere, I think. Not sure if that's just because I'm a newbie.)

Anyway I guess I'll sleep on it.

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 7:02 pm
by Rommie
My favorite thing about the new update (as in, that sarcastic least favorite sort of way) is they got rid of underlines and made them spaces, so this_file.py now shows up as this file.py.

No idea why the crap you would do that!

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 7:36 pm
by Cyborg Girl
Wha... What software? Spaces in filenames can be a hazard on almost every platform.

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 7:52 pm
by Sigma_Orionis
Yeah, what update, on WHAT software?

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 8:14 pm
by Cyborg Girl
Okay, re the OP, XCreateFontSet apparently makes a copy of the buffer... That's why it's passed as a pointer to a pointer, not just a pointer. Or something. I'm confused.

Edit: okay, it makes a copy of the buffer, and doesn't change the original at all. So why the hell does it specifically require a mutable buffer, when it never actually puts anything in it? *tears hair out*

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 8:32 pm
by Cyborg Girl
Yeah okay this is just libX11 being total shit. RAARGH.

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 10:30 pm
by Cyborg Girl
Apparently the deal is that const declarations were only added to C in 1999, and X for the most part has not started making use of them in the past ~15 years. :(

Re: X11 is making me lose my sanity

PostPosted: Sun Jan 12, 2014 11:47 pm
by Sigma_Orionis
I never needed to see the code of X11 to determine it was crap...........

Re: X11 is making me lose my sanity

PostPosted: Mon Jan 13, 2014 12:00 am
by Cyborg Girl
Update: the program now compiles with -Werror -Wall, and runs without any issues.

Boo ya.

Now to actually do something useful with it. :?