DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2230
Version: 2.0-feature
Link: http://www.fltk.org/str.php?L2230
Version: 2.0-feature
/*
Simple Xlib application drawing a box in a window.
gcc hello_xlib.c -o hello_xlib -lX11
*/
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
Display *d;
Window w, w2;
XEvent e;
const char *msg = "Hello, World!";
int s;
XSetWindowAttributes attr;
/* open connection with the server */
d = XOpenDisplay(NULL);
if (d == NULL) {
fprintf(stderr, "Cannot open display\n");
exit(1);
}
s = DefaultScreen(d);
/* create window */
w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 200, 1,
BlackPixel(d, s), WhitePixel(d, s));
w2 = XCreateSimpleWindow(d, RootWindow(d, s), 110, 110, 300, 300, 1,
BlackPixel(d, s), WhitePixel(d, s));
attr.save_under = True;
attr.override_redirect = True;
XChangeWindowAttributes(d, w2, CWSaveUnder | CWOverrideRedirect, &attr);
/* select kind of events we are interested in */
XSelectInput(d, w, ExposureMask | KeyPressMask);
/* map (show) the window */
XMapWindow(d, w);
/* event loop */
while (1) {
XNextEvent(d, &e);
/* draw or redraw the window */
if (e.type == Expose) {
XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
XDrawString(d, w, DefaultGC(d, s), 50, 50, msg, strlen(msg));
}
/* exit on key press */
if (e.type == KeyPress)
XMapWindow(d, w2);
//break;
}
/* close connection to server */
XCloseDisplay(d);
return 0;
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs