aboutsummaryrefslogtreecommitdiff
path: root/i3-nagbar
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2016-01-04 09:26:45 +0100
committerMichael Stapelberg <michael@stapelberg.de>2016-01-04 09:26:45 +0100
commita9f31b9dc98f4f9cada46c48b5caa97de8bef34b (patch)
tree46353082028c35c0fe5c1fd612413e27d34857ff /i3-nagbar
parentebda8dc3723d1be2947d28655183ed0841ac81b8 (diff)
downloadi3-a9f31b9dc98f4f9cada46c48b5caa97de8bef34b.tar.gz
i3-a9f31b9dc98f4f9cada46c48b5caa97de8bef34b.zip
i3-nagbar: explicitly set cursor using libxcursor if available
See commit b1f1da432 for context. fixes #2114
Diffstat (limited to 'i3-nagbar')
-rw-r--r--i3-nagbar/i3-nagbar.mk4
-rw-r--r--i3-nagbar/main.c29
2 files changed, 29 insertions, 4 deletions
diff --git a/i3-nagbar/i3-nagbar.mk b/i3-nagbar/i3-nagbar.mk
index aba3c09a..b10e389e 100644
--- a/i3-nagbar/i3-nagbar.mk
+++ b/i3-nagbar/i3-nagbar.mk
@@ -4,8 +4,8 @@ CLEAN_TARGETS += clean-i3-nagbar
i3_nagbar_SOURCES := $(wildcard i3-nagbar/*.c)
i3_nagbar_HEADERS := $(wildcard i3-nagbar/*.h)
-i3_nagbar_CFLAGS = $(XCB_CFLAGS) $(XCB_WM_CFLAGS) $(PANGO_CFLAGS)
-i3_nagbar_LIBS = $(XCB_LIBS) $(XCB_WM_LIBS) $(PANGO_LIBS)
+i3_nagbar_CFLAGS = $(XCB_CFLAGS) $(XCB_CURSOR_CFLAGS) $(XCB_WM_CFLAGS) $(PANGO_CFLAGS)
+i3_nagbar_LIBS = $(XCB_LIBS) $(XCB_CURSOR_LIBS) $(XCB_WM_LIBS) $(PANGO_LIBS)
i3_nagbar_OBJECTS := $(i3_nagbar_SOURCES:.c=.o)
diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c
index cbbe9ef8..38740774 100644
--- a/i3-nagbar/main.c
+++ b/i3-nagbar/main.c
@@ -28,10 +28,15 @@
#include <xcb/xcb_aux.h>
#include <xcb/xcb_event.h>
#include <xcb/randr.h>
+#include <xcb/xcb_cursor.h>
#include "libi3.h"
#include "i3-nagbar.h"
+/** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
+ * constant for that. */
+#define XCB_CURSOR_LEFT_PTR 68
+
static char *argv0 = NULL;
typedef struct {
@@ -467,6 +472,25 @@ int main(int argc, char *argv[]) {
xcb_rectangle_t win_pos = get_window_position();
+ xcb_cursor_t cursor;
+ xcb_cursor_context_t *cursor_ctx;
+ if (xcb_cursor_context_new(conn, root_screen, &cursor_ctx) == 0) {
+ cursor = xcb_cursor_load_cursor(cursor_ctx, "left_ptr");
+ xcb_cursor_context_free(cursor_ctx);
+ } else {
+ cursor = xcb_generate_id(conn);
+ i3Font cursor_font = load_font("cursor", false);
+ xcb_create_glyph_cursor(
+ conn,
+ cursor,
+ cursor_font.specific.xcb.id,
+ cursor_font.specific.xcb.id,
+ XCB_CURSOR_LEFT_PTR,
+ XCB_CURSOR_LEFT_PTR + 1,
+ 0, 0, 0,
+ 65535, 65535, 65535);
+ }
+
/* Open an input window */
win = xcb_generate_id(conn);
@@ -479,13 +503,14 @@ int main(int argc, char *argv[]) {
0, /* x11 border = 0, we draw our own */
XCB_WINDOW_CLASS_INPUT_OUTPUT,
XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */
- XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
+ XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_CURSOR,
(uint32_t[]){
0, /* back pixel: black */
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_BUTTON_PRESS |
- XCB_EVENT_MASK_BUTTON_RELEASE});
+ XCB_EVENT_MASK_BUTTON_RELEASE,
+ cursor});
/* Map the window (make it visible) */
xcb_map_window(conn, win);