*
* i3 - an improved dynamic tiling window manager
*
- * © 2009 Michael Stapelberg and contributors
+ * © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
#include "i3.h"
#include "util.h"
#include "xcb.h"
+#include "log.h"
TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts);
unsigned int xcb_numlock_mask;
/* If the window class is XCB_WINDOW_CLASS_INPUT_ONLY, depth has to be 0 */
uint16_t depth = (window_class == XCB_WINDOW_CLASS_INPUT_ONLY ? 0 : XCB_COPY_FROM_PARENT);
- /* Use the default cursor (left pointer) */
- if (cursor > -1) {
- i3Font *cursor_font = load_font(conn, "cursor");
- xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id,
- XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1,
- 0, 0, 0, 65535, 65535, 65535);
- }
-
xcb_create_window(conn,
depth,
result, /* the window id */
mask,
values);
- if (cursor > -1)
- xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id);
+ /* Set the cursor */
+ i3Font *cursor_font = load_font(conn, "cursor");
+ xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id,
+ (cursor == -1 ? XCB_CURSOR_LEFT_PTR : cursor),
+ (cursor == -1 ? XCB_CURSOR_LEFT_PTR : cursor) + 1,
+ 0, 0, 0, 65535, 65535, 65535);
+ xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id);
+ xcb_free_cursor(conn, cursor_id);
/* Map the window (= make it visible) */
if (map)
*
*/
void cached_pixmap_prepare(xcb_connection_t *conn, struct Cached_Pixmap *pixmap) {
- LOG("preparing pixmap\n");
+ DLOG("preparing pixmap\n");
/* If the Rect did not change, the pixmap does not need to be recreated */
if (memcmp(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect)) == 0)
memcpy(&(pixmap->rect), pixmap->referred_rect, sizeof(Rect));
if (pixmap->id == 0 || pixmap->gc == 0) {
- LOG("Creating new pixmap...\n");
+ DLOG("Creating new pixmap...\n");
pixmap->id = xcb_generate_id(conn);
pixmap->gc = xcb_generate_id(conn);
} else {
- LOG("Re-creating this pixmap...\n");
+ DLOG("Re-creating this pixmap...\n");
xcb_free_gc(conn, pixmap->gc);
xcb_free_pixmap(conn, pixmap->id);
}
free(reply);
return width;
}
+
+/*
+ * Configures the given window to have the size/position specified by given rect
+ *
+ */
+void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r) {
+ xcb_configure_window(conn, window,
+ XCB_CONFIG_WINDOW_X |
+ XCB_CONFIG_WINDOW_Y |
+ XCB_CONFIG_WINDOW_WIDTH |
+ XCB_CONFIG_WINDOW_HEIGHT,
+ &(r.x));
+}