forgot the source...




here's the source for the clock app I was talking about..

----------------------------------------------------
Jamin Philip Gray
jgray@writeme.com
http://DoLinux.org/jamin/

Love is, above all, the gift of oneself. 

--Jean Anouih
// Written by Ch. Tronche (http://tronche.lri.fr:8000/)
// Copyright by the author. This is unmaintained, no-warranty free software. 
// Please use freely. It is appreciated (but by no means mandatory) to
// acknowledge the author's contribution. Thank you.
// Started on Thu Jun 26 23:29:03 1997

//
// Xlib tutorial: 2nd program
// Make a window appear on the screen and draw a line inside.
// If you don't understand this program, go to
// http://tronche.lri.fr:8000/gui/x/xlib-tutorial/2nd-program-anatomy.html
//

#include <X11/Xlib.h> // Every Xlib program must include this
#include <X11/Xutil.h>
#include <assert.h>   // I include this to test return values the lazy way
#include <unistd.h>   // So we got the profile for 10 seconds
#include <time.h>
#include <stdlib.h>

#define NIL (0)       // A name for the void pointer

main()
{
    // Open the display

    Display *dpy = XOpenDisplay(NIL);
    assert(dpy);

    // Get some colors

    int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
    int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));

    // Create the window

    Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 
                                   200, 100, 0, blackColor, blackColor);


    // We want to get MapNotify events

    XSelectInput(dpy, w, StructureNotifyMask);


    XWMHints* hints = XAllocWMHints();

    hints->flags = StateHint;
    hints->initial_state = IconicState;

    XSetWMHints(dpy, w, hints);

    // "Map" the window (that is, make it appear on the screen)

    XMapWindow(dpy, w);

    char* title=(char*)malloc(10);
    time_t* now=new time_t();

    while(1){
        time(now);
        assert(strftime(title,9,"%l:%M:%S", localtime(now)));
        XSetIconName(dpy, w, title);
        XFlush(dpy);
        sleep(1);
    }
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]