Hi, i wish to share a simple patch enabling Xcursor themes support in awesome wm (3.4.13).

Yes, not without Xlib, but unlike xcb it _is working_ instead of managing elitist purity of library calls.

Here it is, in mail attachment.

And in case it won't be allowed by MTA, here are [breakable] urls to it:

ftp://eientei.org/soft/awesome/x11-wm/awesome/files/awesome-3.4.11-mouse-xcursors.patch -- the patch itself ftp://eientei.org/soft/awesome/x11-wm/awesome/awesome-3.4.13-r1.ebuild -- ebuild for your gentoo/funtoo/whatever emerge-driven package system.
diff -ru a/awesome.c b/awesome.c
--- a/awesome.c	2011-11-23 18:08:50.000000000 +0400
+++ b/awesome.c	2012-10-06 15:11:57.642625979 +0400
@@ -33,6 +33,8 @@
 #include <xcb/xinerama.h>
 #include <xcb/xtest.h>
 
+#include <X11/Xlib-xcb.h>
+
 #include "awesome.h"
 #include "spawn.h"
 #include "client.h"
@@ -373,7 +375,9 @@
     sigaction(SIGSEGV, &sa, 0);
 
     /* X stuff */
-    globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
+    globalconf.display = XOpenDisplay(0);
+    globalconf.connection = XGetXCBConnection(globalconf.display);
+
     if(xcb_connection_has_error(globalconf.connection))
         fatal("cannot open display");
 
diff -ru a/awesomeConfig.cmake b/awesomeConfig.cmake
--- a/awesomeConfig.cmake	2012-10-06 15:40:03.926559594 +0400
+++ b/awesomeConfig.cmake	2012-10-06 15:28:09.210587072 +0400
@@ -133,6 +133,7 @@
     glib-2.0
     cairo
     x11
+    xcursor
     pango>=1.19.3
     pangocairo>=1.19.3
     xcb-randr
diff -ru a/common/xcursor.c b/common/xcursor.c
--- a/common/xcursor.c	2011-11-23 18:08:50.000000000 +0400
+++ b/common/xcursor.c	2012-10-06 15:21:43.288604110 +0400
@@ -137,12 +137,19 @@
  * \return Allocated cursor font.
  */
 xcb_cursor_t
-xcursor_new(xcb_connection_t *conn, uint16_t cursor_font)
+xcursor_new(Display *conn, uint16_t cursor_font)
 {
-    static xcb_font_t font = XCB_NONE;
+    //static xcb_font_t font = XCB_NONE;
     static xcb_cursor_t xcursor[countof(xcursor_font)];
+    if (!xcursor[cursor_font]) {
+        xcursor[cursor_font] = XcursorLibraryLoadCursor(conn, xcursor_font_tostr(cursor_font));
+    }
+    return xcursor[cursor_font];
+    /*
 
+    */
     /* Get the font for the cursor */
+    /*
     if(!font)
     {
         font = xcb_generate_id(conn);
@@ -159,6 +166,7 @@
     }
 
     return xcursor[cursor_font];
+    */
 }
 
 
diff -ru a/common/xcursor.h b/common/xcursor.h
--- a/common/xcursor.h	2011-11-23 18:08:50.000000000 +0400
+++ b/common/xcursor.h	2012-10-06 15:17:12.300613568 +0400
@@ -24,10 +24,11 @@
 
 #include <X11/cursorfont.h>
 #include <xcb/xcb.h>
+#include <X11/Xlib.h>
 
 uint16_t xcursor_font_fromstr(const char *);
 const char * xcursor_font_tostr(uint16_t);
-xcb_cursor_t xcursor_new(xcb_connection_t *, uint16_t);
+xcb_cursor_t xcursor_new(Display *, uint16_t);
 
 #endif
 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
diff -ru a/globalconf.h b/globalconf.h
--- a/globalconf.h	2011-11-23 18:08:50.000000000 +0400
+++ b/globalconf.h	2012-10-06 15:11:55.208626150 +0400
@@ -52,6 +52,8 @@
 /** Main configuration structure */
 typedef struct
 {
+    /** Display ref */
+    Display * display;
     /** Connection ref */
     xcb_connection_t *connection;
     /** Default screen number */
diff -ru a/mousegrabber.c b/mousegrabber.c
--- a/mousegrabber.c	2011-11-23 18:08:50.000000000 +0400
+++ b/mousegrabber.c	2012-10-06 15:13:20.580622709 +0400
@@ -106,7 +106,7 @@
 
     if(cfont)
     {
-        xcb_cursor_t cursor = xcursor_new(globalconf.connection, cfont);
+        xcb_cursor_t cursor = xcursor_new(globalconf.display, cfont);
 
         luaA_registerfct(L, 1, &globalconf.mousegrabber);
 
diff -ru a/root.c b/root.c
--- a/root.c	2011-11-23 18:08:50.000000000 +0400
+++ b/root.c	2012-10-06 15:13:34.149622182 +0400
@@ -202,7 +202,7 @@
 
     if(cursor_font)
     {
-        uint32_t change_win_vals[] = { xcursor_new(globalconf.connection, cursor_font) };
+        uint32_t change_win_vals[] = { xcursor_new(globalconf.display, cursor_font) };
 
         for(int screen_nbr = 0;
             screen_nbr < xcb_setup_roots_length(xcb_get_setup(globalconf.connection));
diff -ru a/wibox.c b/wibox.c
--- a/wibox.c	2011-11-23 18:08:50.000000000 +0400
+++ b/wibox.c	2012-10-06 15:13:52.453621460 +0400
@@ -799,7 +799,7 @@
     wibox_init(wibox, phys_screen);
 
     window_set_cursor(wibox->window,
-                      xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor)));
+                      xcursor_new(globalconf.display, xcursor_font_fromstr(wibox->cursor)));
 
     if(wibox->opacity != -1)
         window_opacity_set(wibox->window, wibox->opacity);
@@ -1316,7 +1316,7 @@
         uint16_t cursor_font = xcursor_font_fromstr(buf);
         if(cursor_font)
         {
-            xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
+            xcb_cursor_t cursor = xcursor_new(globalconf.display, cursor_font);
             p_delete(&wibox->cursor);
             wibox->cursor = a_strdup(buf);
             window_set_cursor(wibox->window, cursor);

Reply via email to