Talk:X Window Programming

Merging GTK+ Book
Merging the GTK+ book into this book would allow people to contribute to one effort rather then dividing the community as well as allows readers to learn GTK+ along with other aspects of X Windows Programming. --darklama 17:33, 5 November 2006 (UTC)


 * Excellent idea. --Swift 08:18, 10 December 2006 (UTC)


 * Bad idea. Remember that GTK is cross-platform. It does not have to run under X. - Anonymous 16:05, 18 May 2007 (UTC)


 * Please don't do this. You don't need to know anything about X to program using Gtk, and you don't need to know anything about Gtk to program X Windows. --Tony Sidaway 23:04, 20 December 2007 (UTC)


 * Another vote for not doing this. As already pointed out Gtk and X programming are not related. If you still think they are consider, why we should not merge this with Qt programming, or FLTK programming or someother toolkit programming. --Balbir Thomas 15:12, 21 January 2008 (UTC)

While GTK+ is cross-platform and doesn't need to run under X, GTK+ is most commonly used under X, was originally made for use with X, and still relies on X concepts that need to be understood to write programs that use GTK+. Most of the topics covered in this book will be dealing with libraries and toolkits which happen to be cross-platform, because there more frequently used. Other toolkits or libraries, like Xlib or XCB, are less frequently used directly. This book will be covering GTK+ and Qt, along with other toolkits, regardless of whether or not the merger happens, as most programmers today use them to create programs for X. So why not keep things simple and easy, by letting any contributions to be concentrated in a single work, rather then having work and effort split among different books? --dark lama  01:35, 23 January 2008 (UTC)


 * I'd take it the other way round: merge the X Window Programming relevant chapters to existing books, the Guide to X11 for instance. Looking at the X Window Programming content, I've noticed that most of the chapters (beyond XLib and XCB) present only general information, that is, they haven't developed into real book chapters yet. Moreover, the four last topics (SDL, OpenGL, Qt and GTK+) are not part of the X Window system: SDL, GTK+ and Qt use some X Window libraries when built on X11, but they're cross-platform toolkits and use different libraries on other systems; OpenGL is in no way bound to X Window. As a consequence, I'd move the XLib and XCB chapters to the Guide to X11 book, and the Motif information to Wikipedia (Motif is the only toolkit that depends only on X, so it could stay in an X book, but as a framework it can have its own book). Move the other chapters either to Wikipedia or the existing independant books (OpenGL, Gtk, Qt). I'd add that most of the GTK+ or Qt programmers have never learnt about the X Window concepts, there's no need to learn X to use frameworks built on top of it. Though Qt and Gtk+ were historically based on X libraries, they're now real cross-platform toolkits (especially Qt); many application authors probably choose one of them with that cross-platform idea in mind, whichever the system they choose (or are used to) for main developments. No work will be duplicated when splitting the X Window Programming book because there's no direct relationship between any of them (excepted beetween the first two ones). Moreover, once you've choosed a framework, you don't need to learn (or even know) about the other ones. Some of them allow making direct calls to the X libraries (in which case you'll refer the the X specific book), but they're primarily meant as X abstraction frameworks. --User:Romainbehar


 * I disagree with splitting this book up. Guide to X11 is for installing and using X11, not for programming under X11. Most of the general information in this book is based on already existing Wikipedia articles. Gtk hasn't had much development yet either, which is why I suggested a merger with this book, while not suggesting any other mergers. While GTK+ or Qt programmers may never touch X, this book isn't for those type of programmers. This book is for programmers wanting to write programs or games that run under X11, whether only one toolkit or library is being used or a mix of toolkits/libraries are going to be used together. This book is intended to be useful in introductory classes that introduce all these libraries, and useful in advance classes in which students are expected to learn how to make window managers, new interface elements, and use libraries/toolkits together. --dark lama  17:43, 15 March 2008 (UTC)


 * I agree. The two have different scope. Gtk and X Window Programming/GTK+, however, share a scope and should be merged. Whether that's under this book or the other (used as a reference here) doesn't really matter. --Swift (talk) 09:48, 6 February 2009 (UTC)

Splash pages
Would anyone object to moving the upper half of the main page to /Cover and merge the /Contents with the lower half (the introduction)? I've done this with abandoned books as per the splash page discussion on WB:MOS. --Swift (talk) 10:08, 6 February 2009 (UTC)


 * There is already a short table of contents listed on the main page that lists each major section of the book. The intent is for /Contents to be a more complete table of contents. The order in which each major section is read should more or less not matter, while chapters in each major section should be read in the order presented. I think this is similar to how Muggles' Guide to Harry Potter is organized. --dark lama  18:14, 7 February 2009 (UTC)

Unix programming
Hi. In polish wikibooks is a small page about Unix programming. Can it be treated as a polish version of this book ? --Adam majewski (discuss • contribs) 20:10, 26 February 2011 (UTC)


 * X Window has many implementations and is available for other systems besides UNIX. I think English Wikibooks may not have a Unix Programming book yet. Unix Programming is a broader topic in some ways, and in other ways might cover things which may not be compatible across the systems in which X Window is implemented. A person should hopefully be able to write graphic programs using any number of graphic libraries and X Window, whether they are in a UNIX environment or not. How about starting a Unix Programming book instead? --dark lama  20:47, 26 February 2011 (UTC)

Xview
What about old Xview library ? --Adam majewski (discuss • contribs) 07:08, 27 February 2011 (UTC)


 * I am open to the idea of covering other libraries too. Are their people using Xview to develop programs? I think a criteria for inclusion should be that their be an active community of developers using it. The link you provided mentions some problems that have been known since 1993, suggesting there might be no incentive for people to develop programs using Xview any more. Maybe some kind of migration guide could be useful for people that come across programs still using Xview? --dark lama  14:29, 28 February 2011 (UTC)

Key concepts and their examples
I suggest add some key concepts in the book with examples of each one.

display is the X hardware abstration for hardware input/output set. Example: computer jonh's keyboard, mouse and two LCD screens connected thru X Server are viewed (this is the abstraction) for the X client like one "Display".

widget is the X software abstraction for window (not, x window) derivatives like menus, forms, lists, checkboxes, etc. Example: label window saying "hello world".

resources is the set of resource itens that a widget owns.

resource is one atributte of a widget. Example: width of a window.

Tranparent programming
The X programming consist in make X clients. One can programming a client to run in one OS (not necessary a UNIX one) and use another like user interface. Example: John create an "hello X World" application that was compiled in your computer running FreeBSD OS. Paul interact with John's "Hello X World" program running in their computer thru a network system using your computer running a GNU/linux system. The Paul's computer have an X Server installed, that communicates with John's computer running X client.

Example : Make this example in C code.

From Alan tutorial (Maybe this program could be considered a "Hello X World", cause it shows an "X" formed by two lines)

/* first include the standard headers that we're likely to need */
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 6) include 

int main(int argc, char ** argv){ int screen_num, width, height; unsigned long background, border; Window win; XEvent ev; Display *dpy; GC pen; XGCValues values;

/* First connect to the display server */ dpy = XOpenDisplay(NULL); if (!dpy) {fprintf(stderr, "unable to connect to display\n");return 7;}

/* these are macros that pull useful data out of the display object */ /* we use these bits of info enough to want them in their own variables */ screen_num = DefaultScreen(dpy); background = BlackPixel(dpy, screen_num); border = WhitePixel(dpy, screen_num);

width = 40; /* start with a small window */ height = 40;

win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), /* display, parent */		0,0, /* x, y: the window manager will place the window elsewhere */		width, height, /* width, height */		2, border, /* border width & colour, unless you have a window manager */		background); /* background colour */

/* create the pen to draw lines with */ values.foreground = WhitePixel(dpy, screen_num); values.line_width = 1; values.line_style = LineSolid; pen = XCreateGC(dpy, win, GCForeground|GCLineWidth|GCLineStyle,&values);

/* tell the display server what kind of events we would like to see */ XSelectInput(dpy, win, ButtonPressMask|StructureNotifyMask|ExposureMask );

/* okay, put the window on the screen, please */ XMapWindow(dpy, win);

/* as each event that we asked about occurs, we respond. In this * case we note if the window's shape changed, and exit if a button * is pressed inside the window. We also draw lines whenever a part * of a window becomes viewable. */	while(1){ XNextEvent(dpy, &ev); switch(ev.type){ case Expose: XDrawLine(dpy, win, pen, 0, 0, width, height); XDrawLine(dpy, win, pen, width, 0, 0, height); break; case ConfigureNotify: if (width != ev.xconfigure.width					|| height != ev.xconfigure.height) { width = ev.xconfigure.width; height = ev.xconfigure.height; XClearWindow(dpy, ev.xany.window); printf("Size changed to: %d by %d\n", width, height); }			break; case ButtonPress: XCloseDisplay(dpy); return 0; }	} }

Basic Xlib programming
Unix has a strong link with the C programming language, so Xlib was created as a C language library. Remebering that UNIX was created mostly in C language. Despite X could be programmed in another languages, the better choice is to start from the beginning.