From 08ca70c00d06c64466af511c14eba68c5db4b452 Mon Sep 17 00:00:00 2001 From: Tumin Alexander Date: Sun, 7 Oct 2012 02:06:58 +0400 Subject: [PATCH] Added initial support for Xlib cursor themes -- for branch 3.4 The same patch, only for branch 3.4 (there is a bunch of differences from master) Signed-off-by: Tumin Alexander Signed-off-by: Uli Schlachter --- awesome.c | 12 +++++++++++- awesomeConfig.cmake | 1 + common/xcursor.c | 19 +++---------------- common/xcursor.h | 3 ++- globalconf.h | 2 ++ mousegrabber.c | 2 +- root.c | 2 +- wibox.c | 4 ++-- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/awesome.c b/awesome.c index f8cf6757..3f8c81a6 100644 --- a/awesome.c +++ b/awesome.c @@ -33,6 +33,8 @@ #include #include +#include + #include "awesome.h" #include "spawn.h" #include "client.h" @@ -373,7 +375,15 @@ main(int argc, char **argv) sigaction(SIGSEGV, &sa, 0); /* X stuff */ - globalconf.connection = xcb_connect(NULL, &globalconf.default_screen); + globalconf.display = XOpenDisplay(NULL); + if (globalconf.display == NULL) + fatal("cannot open display"); + + globalconf.default_screen = XDefaultScreen(globalconf.display); + + globalconf.connection = XGetXCBConnection(globalconf.display); + + /* Double checking then everything is OK. */ if(xcb_connection_has_error(globalconf.connection)) fatal("cannot open display"); diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 8f102817..7e4fc5b2 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -133,6 +133,7 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED glib-2.0 cairo x11 + xcursor pango>=1.19.3 pangocairo>=1.19.3 xcb-randr diff --git a/common/xcursor.c b/common/xcursor.c index 2f8824e8..8cb50716 100644 --- a/common/xcursor.c +++ b/common/xcursor.c @@ -137,25 +137,12 @@ xcursor_font_tostr(uint16_t c) * \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_cursor_t xcursor[countof(xcursor_font)]; - /* Get the font for the cursor */ - if(!font) - { - font = xcb_generate_id(conn); - xcb_open_font(conn, font, sizeof(CURSORFONT) - 1, CURSORFONT); - } - - if(!xcursor[cursor_font]) - { - xcursor[cursor_font] = xcb_generate_id(conn); - xcb_create_glyph_cursor(conn, xcursor[cursor_font], font, font, - cursor_font, cursor_font + 1, - 0, 0, 0, - 65535, 65535, 65535); + if (!xcursor[cursor_font]) { + xcursor[cursor_font] = XcursorLibraryLoadCursor(conn, xcursor_font_tostr(cursor_font)); } return xcursor[cursor_font]; diff --git a/common/xcursor.h b/common/xcursor.h index 4536c721..64a1144f 100644 --- a/common/xcursor.h +++ b/common/xcursor.h @@ -23,11 +23,12 @@ #define AWESOME_COMMON_XCURSORS_H #include +#include #include 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:textwidth=80 diff --git a/globalconf.h b/globalconf.h index dd0f8124..5cf98dc9 100644 --- a/globalconf.h +++ b/globalconf.h @@ -52,6 +52,8 @@ ARRAY_TYPE(wibox_t *, wibox) /** Main configuration structure */ typedef struct { + /** Xlib Display ref [for Xcursors] */ + Display * display; /** Connection ref */ xcb_connection_t *connection; /** Default screen number */ diff --git a/mousegrabber.c b/mousegrabber.c index 0b4059cb..b88b98b6 100644 --- a/mousegrabber.c +++ b/mousegrabber.c @@ -106,7 +106,7 @@ luaA_mousegrabber_run(lua_State *L) 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 --git a/root.c b/root.c index e33eb706..ee50d7e0 100644 --- a/root.c +++ b/root.c @@ -229,7 +229,7 @@ luaA_root_cursor(lua_State *L) 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 --git a/wibox.c b/wibox.c index 0ab73635..8070222d 100644 --- a/wibox.c +++ b/wibox.c @@ -799,7 +799,7 @@ wibox_attach(lua_State *L, int udx, screen_t *s) 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 @@ luaA_wibox_set_cursor(lua_State *L, wibox_t *wibox) 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);