]> git.sur5r.net Git - i3/i3/blobdiff - docs/NoName-2009-03-12/i3.tex
More example code
[i3/i3] / docs / NoName-2009-03-12 / i3.tex
index 370cfe0dc04b894663196ea738664311da7c410d..85c64423055e1c1e287ca00d087a815c34481542 100644 (file)
 \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