From d61c6f5ae9977254101fed0812cf59edefca6242 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 13 Nov 2008 11:04:07 +0100 Subject: [PATCH] wibox: add cursor property Signed-off-by: Julien Danjou --- common/tokenize.gperf | 1 + structs.h | 2 ++ wibox.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/common/tokenize.gperf b/common/tokenize.gperf index d5ef9be98..bd6ef1288 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -19,6 +19,7 @@ Control coords conffile Ctrl +cursor east ellipsize end diff --git a/structs.h b/structs.h index 501564cbc..32c3c9d82 100644 --- a/structs.h +++ b/structs.h @@ -90,6 +90,8 @@ typedef struct widget_t *mouse_over; /** Need update */ bool need_update; + /** Cursor */ + char *cursor; } wibox_t; ARRAY_TYPE(wibox_t *, wibox) diff --git a/wibox.c b/wibox.c index eb7bde1fb..54f3790c0 100644 --- a/wibox.c +++ b/wibox.c @@ -24,6 +24,7 @@ #include "titlebar.h" #include "client.h" #include "ewmh.h" +#include "common/xcursor.h" extern awesome_t globalconf; @@ -604,6 +605,9 @@ wibox_attach(wibox_t *wibox, screen_t *s) simplewindow_border_color_set(&wibox->sw, &wibox->sw.border.color); + simplewindow_cursor_set(&wibox->sw, + xcursor_new(globalconf.connection, xcursor_font_fromstr(wibox->cursor))); + /* All the other wibox and ourselves need to be repositioned */ for(int i = 0; i < s->wiboxes.len; i++) wibox_position_update(s->wiboxes.tab[i]); @@ -687,6 +691,7 @@ luaA_wibox_new(lua_State *L) w->screen = SCREEN_UNDEF; w->isvisible = true; + w->cursor = a_strdup("left_ptr"); for(i = 0; i <= reqs_nbr; i++) xcolor_init_reply(reqs[i]); @@ -767,6 +772,7 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item) * \lfield bg Background color. * \lfield position The position. * \lfield ontop On top of other windows. + * \lfield cursor The mouse cursor. */ static int luaA_wibox_index(lua_State *L) @@ -825,6 +831,9 @@ luaA_wibox_index(lua_State *L) else lua_pushnil(L); break; + case A_TK_CURSOR: + lua_pushstring(L, (*wibox)->cursor); + break; default: return 0; } @@ -935,6 +944,19 @@ luaA_wibox_newindex(lua_State *L) titlebar_client_attach(*c, *wibox); } break; + case A_TK_CURSOR: + if((buf = luaL_checkstring(L, 3))) + { + uint16_t cursor_font = xcursor_font_fromstr(buf); + if(cursor_font) + { + xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font); + p_delete(&(*wibox)->cursor); + (*wibox)->cursor = a_strdup(buf); + simplewindow_cursor_set(&(*wibox)->sw, cursor); + } + } + break; case A_TK_SCREEN: if(lua_isnil(L, 3)) {