Hi,

On 06.10.2012 14:27, Alexander Tumin wrote:
> 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.

Urgh. :-P

> 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);

This no longer sets globalconf.default_screen to the number of the default
screen. From the top of my head, I don't know how to get that value out of Xlib,
but that should be possible.

For the argument to XOpenDisplay(): This is a pointer, so please use NULL
instead of 0.

On the error handling: XOpenDisplay() returns NULL when it fails. This would
then crash in XGetXCBConnection().

So this code:
>      if(xcb_connection_has_error(globalconf.connection))
>          fatal("cannot open display");

Should be moved up, before the call to XGetXCBConnection, and should be "if
(globalconf.display == NULL)" (Hm, and perhaps additionally checking with
xcb_connection_has_error() doesn't hurt? Dunno)


> 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];
> +    */
>  }

Come on, you don't really want me to merge that mess? Could you just remove the
now-unused code instead of commenting it out?
[...]

The rest looks good to me.

Cheers,
Uli
-- 
If you have to type the letters "A-E-S" into your source code, you're doing it
wrong.

-- 
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to