From: Michael Stapelberg Date: Thu, 12 Mar 2009 16:56:03 +0000 (+0100) Subject: More example code X-Git-Tag: 3.a~23 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=89db5f7217ade35d8a844279b9a4a9c3e4df8a14;p=i3%2Fi3 More example code --- diff --git a/docs/NoName-2009-03-12/i3.tex b/docs/NoName-2009-03-12/i3.tex index 370cfe0d..85c64423 100644 --- a/docs/NoName-2009-03-12/i3.tex +++ b/docs/NoName-2009-03-12/i3.tex @@ -23,9 +23,11 @@ \lstnewenvironment{code}{% \lstset{frame=single, basicstyle=\footnotesize\ttfamily, language=C, showstringspaces=false,% style=colors, numbers=left, morekeywords={xcb_get_window_attributes_cookie_t, xcb_map_request_event_t,% - xcb_connection_t, xcb_get_window_attributes_reply_t, window_attributes_t},% + xcb_connection_t, xcb_get_window_attributes_reply_t, window_attributes_t, xcb_intern_atom_cookie_t,% + xcb_intern_atom_reply_t, xcb_atom_t},% moreemph={xcb_get_window_attributes_reply, xcb_get_window_attributes_unchecked, manage_window,% - add_ignore_event}} + add_ignore_event, xcb_intern_atom, xcb_intern_atom_reply, fprintf, printf, free, load_configuration,% + XInternAtom, exit, strlen}} }{} \title{i3 - an improved dynamic tiling window manager} \author{sECuRE beim NoName e.V.\\ @@ -140,6 +142,46 @@ int handle_map_request(void *prophs, xcb_connection_t *conn, \end{list} \end{slide} +\begin{slide}[method=direct]{Xlib-Beispielcode} +\begin{code} + char *names[10] = {"_NET_SUPPORTED", "_NET_WM_STATE", + "_NET_WM_STATE_FULLSCREEN", "_NET_WM_NAME" /* ... */}; + Atom atoms[10]; + + /* Get atoms */ + for (int i = 0; i < 10; i++) { + atoms[i] = XInternAtom(display, names[i], 0); + } +\end{code} +\end{slide} + +\begin{slide}[method=direct]{XCB-Beispielcode} +\begin{code} +char *names[10] = {"_NET_SUPPORTED", "_NET_WM_STATE", + "_NET_WM_STATE_FULLSCREEN", "_NET_WM_NAME" /* ... */}; +xcb_intern_atom_cookie_t cookies[10]; + +/* Place requests for atoms as soon as possible */ +for (int c = 0; c < 10; c++) + xcb_intern_atom(connection, 0, strlen(names[c]), names[c]); + +/* Do other stuff here */ +load_configuration(); + +/* Get atoms */ +for (int c = 0; c < 10; c++) { + xcb_intern_atom_reply_t *reply = + xcb_intern_atom_reply(connection, cookies[c], NULL); + if (!reply) { + fprintf(stderr, "Could not get atom\n"); + exit(-1); + } + printf("atom has ID %d\n", reply->atom); + free(reply); +} +\end{code} +\end{slide} + \begin{slide}{Xft} \begin{list}{$\bullet$}{\itemsep=1em} \item<1-> „X FreeType”, library um antialiased fonts zu benutzen