From 89db5f7217ade35d8a844279b9a4a9c3e4df8a14 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 12 Mar 2009 17:56:03 +0100 Subject: [PATCH] More example code --- docs/NoName-2009-03-12/i3.tex | 46 +++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) 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 -- 2.39.5