client: merge class hints into index
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
fc38d32052
commit
e4db1a3b86
30
client.c
30
client.c
|
@ -1148,24 +1148,6 @@ luaA_client_tostring(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the client name.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \luastack
|
|
||||||
* \lvalue A client.
|
|
||||||
* \lreturn A string with the client class.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_client_class_get(lua_State *L)
|
|
||||||
{
|
|
||||||
client_t **c = luaA_checkudata(L, 1, "client");
|
|
||||||
class_hint_t *hint=xutil_get_class_hint(globalconf.connection, (*c)->win);
|
|
||||||
if (hint)
|
|
||||||
lua_pushstring(L, hint->res_class);
|
|
||||||
else
|
|
||||||
luaL_error(L, "Unable to get the class property for client");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the client's titlebar.
|
/** Set the client's titlebar.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \luastack
|
* \luastack
|
||||||
|
@ -1329,6 +1311,7 @@ luaA_client_index(lua_State *L)
|
||||||
size_t len;
|
size_t len;
|
||||||
client_t **c = luaA_checkudata(L, 1, "client");
|
client_t **c = luaA_checkudata(L, 1, "client");
|
||||||
const char *buf = luaL_checklstring(L, 2, &len);
|
const char *buf = luaL_checklstring(L, 2, &len);
|
||||||
|
xutil_class_hint_t hint;
|
||||||
|
|
||||||
if(luaA_usemetatable(L, 1, 2))
|
if(luaA_usemetatable(L, 1, 2))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1338,6 +1321,16 @@ luaA_client_index(lua_State *L)
|
||||||
case A_TK_NAME:
|
case A_TK_NAME:
|
||||||
lua_pushstring(L, (*c)->name);
|
lua_pushstring(L, (*c)->name);
|
||||||
break;
|
break;
|
||||||
|
case A_TK_CLASS:
|
||||||
|
if(xutil_get_class_hint(globalconf.connection, (*c)->win, &hint))
|
||||||
|
{
|
||||||
|
lua_pushstring(L, hint.res_name);
|
||||||
|
lua_pushstring(L, hint.res_class);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
case A_TK_FLOATING_PLACEMENT:
|
case A_TK_FLOATING_PLACEMENT:
|
||||||
lua_pushstring(L, name_func_rlookup((*c)->floating_placement,
|
lua_pushstring(L, name_func_rlookup((*c)->floating_placement,
|
||||||
FloatingPlacementList));
|
FloatingPlacementList));
|
||||||
|
@ -1389,7 +1382,6 @@ const struct luaL_reg awesome_client_meta[] =
|
||||||
{ "focus_set", luaA_client_focus_set },
|
{ "focus_set", luaA_client_focus_set },
|
||||||
{ "raise", luaA_client_raise },
|
{ "raise", luaA_client_raise },
|
||||||
{ "redraw", luaA_client_redraw },
|
{ "redraw", luaA_client_redraw },
|
||||||
{ "class_get", luaA_client_class_get },
|
|
||||||
{ "mouse_resize", luaA_client_mouse_resize },
|
{ "mouse_resize", luaA_client_mouse_resize },
|
||||||
{ "mouse_move", luaA_client_mouse_move },
|
{ "mouse_move", luaA_client_mouse_move },
|
||||||
{ "unmanage", luaA_client_unmanage },
|
{ "unmanage", luaA_client_unmanage },
|
||||||
|
|
|
@ -12,6 +12,7 @@ bottom
|
||||||
bottomleft
|
bottomleft
|
||||||
bottomright
|
bottomright
|
||||||
center
|
center
|
||||||
|
class
|
||||||
color
|
color
|
||||||
fg
|
fg
|
||||||
flex
|
flex
|
||||||
|
|
|
@ -153,18 +153,16 @@ xutil_get_transient_for_hint(xcb_connection_t *c, xcb_window_t win,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class_hint_t *
|
bool
|
||||||
xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
|
xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win, xutil_class_hint_t *ch)
|
||||||
{
|
{
|
||||||
xcb_get_property_reply_t *class_hint_r;
|
xcb_get_property_reply_t *class_hint_r;
|
||||||
xcb_get_property_cookie_t class_hint_c;
|
xcb_get_property_cookie_t class_hint_c;
|
||||||
char *data;
|
char *data;
|
||||||
int len_name, len_class;
|
int len_name, len_class;
|
||||||
class_hint_t *ch;
|
|
||||||
|
|
||||||
class_hint_c = xcb_get_property_unchecked(conn, false, win, WM_CLASS,
|
class_hint_c = xcb_get_property_unchecked(conn, false, win, WM_CLASS,
|
||||||
STRING, 0L, 2048L);
|
STRING, 0L, 2048L);
|
||||||
ch = p_new(class_hint_t, 1);
|
|
||||||
|
|
||||||
class_hint_r = xcb_get_property_reply(conn, class_hint_c, NULL);
|
class_hint_r = xcb_get_property_reply(conn, class_hint_c, NULL);
|
||||||
|
|
||||||
|
@ -173,7 +171,7 @@ xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
|
||||||
|| class_hint_r->format != 8)
|
|| class_hint_r->format != 8)
|
||||||
{
|
{
|
||||||
p_delete(&class_hint_r);
|
p_delete(&class_hint_r);
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = xcb_get_property_value(class_hint_r);
|
data = xcb_get_property_value(class_hint_r);
|
||||||
|
@ -186,7 +184,7 @@ xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
|
||||||
|
|
||||||
p_delete(&class_hint_r);
|
p_delete(&class_hint_r);
|
||||||
|
|
||||||
return ch;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Number of different errors */
|
/* Number of different errors */
|
||||||
|
|
|
@ -92,9 +92,9 @@ typedef struct
|
||||||
{
|
{
|
||||||
char *res_name;
|
char *res_name;
|
||||||
char *res_class;
|
char *res_class;
|
||||||
} class_hint_t;
|
} xutil_class_hint_t;
|
||||||
|
|
||||||
class_hint_t *xutil_get_class_hint(xcb_connection_t *, xcb_window_t);
|
bool xutil_get_class_hint(xcb_connection_t *, xcb_window_t, xutil_class_hint_t *);
|
||||||
|
|
||||||
bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **, ssize_t *);
|
bool xutil_gettextprop(xcb_connection_t *, xcb_window_t, xcb_atom_t, char **, ssize_t *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue