]> git.sur5r.net Git - i3/i3/commitdiff
Merge font.c into xcb.c
authorMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 4 Mar 2009 13:52:04 +0000 (14:52 +0100)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 4 Mar 2009 13:52:04 +0000 (14:52 +0100)
Makefile
include/font.h [deleted file]
include/xcb.h
src/font.c [deleted file]
src/handlers.c
src/layout.c
src/mainx.c
src/xcb.c
src/xinerama.c

index 1993a481d4876cb30d769cb37a371bd64863c97b..eb806d961088fb31fe70a115f1b137410133d513 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ INSTALL=install
 CFLAGS += -std=c99
 CFLAGS += -pipe
 CFLAGS += -Wall
+CFLAGS += -Wunused
 CFLAGS += -Iinclude
 CFLAGS += -I/usr/local/include
 
diff --git a/include/font.h b/include/font.h
deleted file mode 100644 (file)
index 3e9d0a1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * vim:ts=8:expandtab
- *
- * i3 - an improved dynamic tiling window manager
- *
- * (c) 2009 Michael Stapelberg and contributors
- *
- * See file LICENSE for license information.
- *
- */
-#include <xcb/xcb.h>
-
-#include "data.h"
-
-#ifndef _FONT_H
-#define _FONT_H
-
-i3Font *load_font(xcb_connection_t *c, const char *pattern);
-
-#endif
index cf2863aeb23912c37b2515d40cdda3aad2f5e091..1e8a932183b30209fef4427765cb26cb24d236f0 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef _XCB_H
 #define _XCB_H
 
+#include "data.h"
+
 #define _NET_WM_STATE_REMOVE 0
 #define _NET_WM_STATE_ADD 1
 #define _NET_WM_STATE_TOGGLE 2
@@ -27,6 +29,7 @@ enum { _NET_SUPPORTED = 0,
         UTF8_STRING
 };
 
+i3Font *load_font(xcb_connection_t *connection, const char *pattern);
 uint32_t get_colorpixel(xcb_connection_t *conn, Client *client, xcb_window_t window, char *hex);
 xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t window_class, uint32_t mask, uint32_t *values);
 void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value);
diff --git a/src/font.c b/src/font.c
deleted file mode 100644 (file)
index 624c20a..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * vim:ts=8:expandtab
- *
- * i3 - an improved dynamic tiling window manager
- *
- * © 2009 Michael Stapelberg and contributors
- *
- * See file LICENSE for license information.
- *
- * font.c: Handles font loading (with caching, with height information)
- *
- */
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <xcb/xcb.h>
-
-#include "data.h"
-#include "util.h"
-
-TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts);
-
-/*
- * Loads a font for usage, getting its height. This function is used very often, so it
- * maintains a cache.
- *
- */
-i3Font *load_font(xcb_connection_t *connection, const char *pattern) {
-        /* Check if we got the font cached */
-        i3Font *font;
-        TAILQ_FOREACH(font, &cached_fonts, fonts)
-                if (strcmp(font->pattern, pattern) == 0)
-                        return font;
-
-        i3Font *new = smalloc(sizeof(i3Font));
-        xcb_void_cookie_t font_cookie;
-        xcb_list_fonts_with_info_cookie_t info_cookie;
-
-        /* Send all our requests first */
-        new->id = xcb_generate_id(connection);
-        font_cookie = xcb_open_font_checked(connection, new->id, strlen(pattern), pattern);
-        info_cookie = xcb_list_fonts_with_info(connection, 1, strlen(pattern), pattern);
-
-        check_error(connection, font_cookie, "Could not open font");
-
-        /* Get information (height/name) for this font */
-        xcb_list_fonts_with_info_reply_t *reply = xcb_list_fonts_with_info_reply(connection, info_cookie, NULL);
-        exit_if_null(reply, "Could not load font \"%s\"\n", pattern);
-
-        if (asprintf(&(new->name), "%.*s", xcb_list_fonts_with_info_name_length(reply),
-                                           xcb_list_fonts_with_info_name(reply)) == -1)
-                die("asprintf() failed\n");
-        new->pattern = sstrdup(pattern);
-        new->height = reply->font_ascent + reply->font_descent;
-
-        /* Insert into cache */
-        TAILQ_INSERT_TAIL(&cached_fonts, new, fonts);
-
-        return new;
-}
index 2c1861be43816280fb6153398591e5dffb8f3174..1c1d9a9a785716382305ee66c984818998b0ff72 100644 (file)
@@ -23,7 +23,6 @@
 #include "layout.h"
 #include "commands.h"
 #include "data.h"
-#include "font.h"
 #include "xcb.h"
 #include "util.h"
 #include "xinerama.h"
index c122f313951d963361651d245c2460d4ac2186d0..6fd767e7f1207210c30ef7dbcd131f2b9dd22d5f 100644 (file)
@@ -17,7 +17,6 @@
 #include <assert.h>
 
 #include "config.h"
-#include "font.h"
 #include "i3.h"
 #include "xcb.h"
 #include "table.h"
index 4dbe7794547454bb0594e049f524d82184eba223..4e98ab55595e1fc5532599612a8df35e333cc95f 100644 (file)
@@ -35,7 +35,6 @@
 #include "config.h"
 #include "queue.h"
 #include "table.h"
-#include "font.h"
 #include "layout.h"
 #include "debug.h"
 #include "handlers.h"
index 2f60ba7080ac630d309873561405ed16e5d204e1..bcef608617dd4afc36ad9feb52e7c44131f5c655 100644 (file)
--- a/src/xcb.c
+++ b/src/xcb.c
 
 #include "util.h"
 
+TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts);
+
+/*
+ * Loads a font for usage, getting its height. This function is used very often, so it
+ * maintains a cache.
+ *
+ */
+i3Font *load_font(xcb_connection_t *connection, const char *pattern) {
+        /* Check if we got the font cached */
+        i3Font *font;
+        TAILQ_FOREACH(font, &cached_fonts, fonts)
+                if (strcmp(font->pattern, pattern) == 0)
+                        return font;
+
+        i3Font *new = smalloc(sizeof(i3Font));
+        xcb_void_cookie_t font_cookie;
+        xcb_list_fonts_with_info_cookie_t info_cookie;
+
+        /* Send all our requests first */
+        new->id = xcb_generate_id(connection);
+        font_cookie = xcb_open_font_checked(connection, new->id, strlen(pattern), pattern);
+        info_cookie = xcb_list_fonts_with_info(connection, 1, strlen(pattern), pattern);
+
+        check_error(connection, font_cookie, "Could not open font");
+
+        /* Get information (height/name) for this font */
+        xcb_list_fonts_with_info_reply_t *reply = xcb_list_fonts_with_info_reply(connection, info_cookie, NULL);
+        exit_if_null(reply, "Could not load font \"%s\"\n", pattern);
+
+        if (asprintf(&(new->name), "%.*s", xcb_list_fonts_with_info_name_length(reply),
+                                           xcb_list_fonts_with_info_name(reply)) == -1)
+                die("asprintf() failed\n");
+        new->pattern = sstrdup(pattern);
+        new->height = reply->font_ascent + reply->font_descent;
+
+        /* Insert into cache */
+        TAILQ_INSERT_TAIL(&cached_fonts, new, fonts);
+
+        return new;
+}
+
 /*
  * Returns the colorpixel to use for the given hex color (think of HTML).
  *
index 1d16eb9bfdb026185bf640cd41f753c4846d1d7b..823926924dca3dc231ebd59ca80ffa54365528cc 100644 (file)
@@ -24,7 +24,6 @@
 #include "xinerama.h"
 #include "layout.h"
 #include "xcb.h"
-#include "font.h"
 #include "config.h"
 
 /* This TAILQ of i3Screens stores the virtual screens, used for handling overlapping screens