wibox: add cursor property

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-13 11:04:07 +01:00
parent 5a4784b646
commit d61c6f5ae9
3 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Control
coords coords
conffile conffile
Ctrl Ctrl
cursor
east east
ellipsize ellipsize
end end

View File

@ -90,6 +90,8 @@ typedef struct
widget_t *mouse_over; widget_t *mouse_over;
/** Need update */ /** Need update */
bool need_update; bool need_update;
/** Cursor */
char *cursor;
} wibox_t; } wibox_t;
ARRAY_TYPE(wibox_t *, wibox) ARRAY_TYPE(wibox_t *, wibox)

22
wibox.c
View File

@ -24,6 +24,7 @@
#include "titlebar.h" #include "titlebar.h"
#include "client.h" #include "client.h"
#include "ewmh.h" #include "ewmh.h"
#include "common/xcursor.h"
extern awesome_t globalconf; 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_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 */ /* All the other wibox and ourselves need to be repositioned */
for(int i = 0; i < s->wiboxes.len; i++) for(int i = 0; i < s->wiboxes.len; i++)
wibox_position_update(s->wiboxes.tab[i]); wibox_position_update(s->wiboxes.tab[i]);
@ -687,6 +691,7 @@ luaA_wibox_new(lua_State *L)
w->screen = SCREEN_UNDEF; w->screen = SCREEN_UNDEF;
w->isvisible = true; w->isvisible = true;
w->cursor = a_strdup("left_ptr");
for(i = 0; i <= reqs_nbr; i++) for(i = 0; i <= reqs_nbr; i++)
xcolor_init_reply(reqs[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 bg Background color.
* \lfield position The position. * \lfield position The position.
* \lfield ontop On top of other windows. * \lfield ontop On top of other windows.
* \lfield cursor The mouse cursor.
*/ */
static int static int
luaA_wibox_index(lua_State *L) luaA_wibox_index(lua_State *L)
@ -825,6 +831,9 @@ luaA_wibox_index(lua_State *L)
else else
lua_pushnil(L); lua_pushnil(L);
break; break;
case A_TK_CURSOR:
lua_pushstring(L, (*wibox)->cursor);
break;
default: default:
return 0; return 0;
} }
@ -935,6 +944,19 @@ luaA_wibox_newindex(lua_State *L)
titlebar_client_attach(*c, *wibox); titlebar_client_attach(*c, *wibox);
} }
break; 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: case A_TK_SCREEN:
if(lua_isnil(L, 3)) if(lua_isnil(L, 3))
{ {