Sign in Join
Wiki copytemporary

X11: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: X11

OldNewLine
1+The X11 package contains some units which contain the translations of the X header files.
2+
3+## List of units
4+
5+The most basic units are:
6+
7+- **X** basic X routines.
8+- **xcms** Some color management.
9+- **xlib** Xlib toolkit.
10+- **xrender** X Render extension.
11+- **xresource** X resource management.
12+- **xshm** X shared memory extension.
13+- **xutil** X util lib.
14+
15+Newer units:
16+
17+- cursorfont
18+- xinerama
19+- xrandr
20+- keysym
21+- xf86dga.pp
22+- xkb
23+- xv
24+- xf86vmode
25+- xkblib
26+- xvlib
27+- xatom
28+- xi
29+
30+All these units link to the various X libraries. These units interface to the documented client libraries, and are thus largely immune to the X11\<-\>Xorg changes.
31+
32+## Examples
33+
34+### A window with a message
35+
36+This is a very simple application which shows a window with a written message.
37+
38+``` pascal
39+program xshowwindow;
40+
41+{$mode objfpc}{$H+}
42+
43+uses
44+ xlib,
45+ x,
46+ ctypes;
47+
48+procedure ModalShowX11Window(AMsg: string);
49+var
50+ d: PDisplay;
51+ w: TWindow;
52+ e: TXEvent;
53+ msg: PChar;
54+ s: cint;
55+begin
56+ msg := PChar(AMsg);
57+
58+ { open connection with the server }
59+ d := XOpenDisplay(nil);
60+ if (d = nil) then
61+ begin
62+ WriteLn('[ModalShowX11Window] Cannot open display');
63+ exit;
64+ end;
65+
66+ s := DefaultScreen(d);
67+
68+ { create window }
69+ w := XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 200, 1,
70+ BlackPixel(d, s), WhitePixel(d, s));
71+
72+ { select kind of events we are interested in }
73+ XSelectInput(d, w, ExposureMask or KeyPressMask);
74+
75+ { map (show) the window }
76+ XMapWindow(d, w);
77+
78+ { event loop }
79+ while (True) do
80+ begin
81+ XNextEvent(d, @e);
82+ { draw or redraw the window }
83+ if (e._type = Expose) then
84+ begin
85+ XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
86+ XDrawString(d, w, DefaultGC(d, s), 50, 50, msg, strlen(msg));
87+ end;
88+ { exit on key press }
89+ if (e._type = KeyPress) then Break;
90+ end;
91+
92+ { close connection to server }
93+ XCloseDisplay(d);
94+end;
95+
96+begin
97+ ModalShowX11Window('My message');
98+end.
99+```
100+
101+## See Also
102+
103+- <http://en.wikipedia.org/wiki/Xlib>
104+
105+---
106+*From the Free Pascal wiki, page "X11", as it stood on 2019-12-21 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history