Nice, this dog food make all a bit happier.. ;o)


Jan Stary <h...@stare.cz>:

> Dear all,
> 
> the day has come when I need to do some elementary  programming
> (open a window and draw pixels into it). I started with chapter 27
> from Stevens: Advanced UNIX Programming, being my favourite author,
> but the examples seem to be a bit outdated, at least the manpages
> of the X functions describe a slightly different interface.
> At any rate, the example below does not open a window.
> 
> I am looking at
> https://www.x.org/releases/current/doc/libX11/libX11/libX11.html
> next, but do people have a favourite X programming intro?
> 
> BTW, the manpage for XSetStandardProperties()
> doesn't seem to exist on my current/arm64.
> 
>     Jan
> 
> 
> 
> #include <unistd.h>
> #include <stdio.h>
> #include <err.h>
> 
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
> 
> int
> main(int argc, char** argv)
> {
>     Display* display;
>     XSizeHints hints;
>     Window window;
> 
>     int screen;
>     unsigned long white;
>     unsigned long black;
> 
>     if ((display = XOpenDisplay(NULL)) == NULL) {
>         /* err() is not usefull here, these are not system errors.
>          * Does X11 have any arror reporting framework? */
>         errx(1, "Error getting Display");
>     }
> 
>     screen = DefaultScreen(display);
>     white = WhitePixel(display, screen);
>     black = BlackPixel(display, screen);
> 
>     hints.x = 300;
>     hints.y = 500;
>     hints.width = 200;
>     hints.height = 100;
>     hints.flags = PPosition | PSize;
> 
>     window = XCreateSimpleWindow(display, DefaultRootWindow(display),
>         hints.x, hints.y, hints.width, hints.height, 10, white, black);
> 
>     XSetStandardProperties(display, window, "wname", "iname", None,
>         NULL, 0, &hints);
> 
>     /*XMapWindow(display, window);*/
>     XMapRaised(display, window);
> 
>     while (1) {
>         sleep(1);
>     }
> 
>     XDestroyWindow(display, window);
>     XCloseDisplay(display);
> 
>     return 0;
> }



Dan

------
Blog: http://bsd.gaoxio.com - Repo: https://code.5mode.com

Please reply to the mailing-list, leveraging technical stuff.

Reply via email to