Allow reversing the icon order in systray

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Tin Benjamin Matuka 2014-04-02 15:25:03 +02:00 committed by Uli Schlachter
parent ed6d5e0246
commit d441030ba9
2 changed files with 20 additions and 5 deletions

View File

@ -17,6 +17,7 @@ local systray = { mt = {} }
local horizontal = true
local base_size = nil
local reverse = false
function systray:draw(wibox, cr, width, height)
local x, y, _, _ = lbase.rect_to_device_geometry(cr, 0, 0, width, height)
@ -39,7 +40,7 @@ function systray:draw(wibox, cr, width, height)
else
base = in_dir / num_entries
end
capi.awesome.systray(wibox.drawin, x, y, base, is_rotated, bg)
capi.awesome.systray(wibox.drawin, x, y, base, is_rotated, bg, reverse)
end
function systray:fit(width, height)
@ -58,13 +59,18 @@ function systray:fit(width, height)
return base, base * num_entries
end
local function new()
local function new(revers)
local ret = wbase.make_widget()
ret.fit = systray.fit
ret.draw = systray.draw
ret.set_base_size = function(_, size) base_size = size end
ret.set_horizontal = function(_, horiz) horizontal = horiz end
ret.set_reverse = function(revers) reverse = revers end
if revers then
ret:set_reverse(true)
end
capi.awesome.connect_signal("systray::update", function()
ret:emit_signal("widget::updated")

View File

@ -268,7 +268,7 @@ luaA_systray_invalidate(void)
}
static void
systray_update(int base_size, bool horizontal)
systray_update(int base_size, bool horizontal, bool reverse)
{
if(base_size <= 0)
return;
@ -289,7 +289,13 @@ systray_update(int base_size, bool horizontal)
config_vals[2] = config_vals[3] = base_size;
for(int i = 0; i < globalconf.embedded.len; i++)
{
xembed_window_t *em = &globalconf.embedded.tab[i];
xembed_window_t *em;
if(reverse)
em = &globalconf.embedded.tab[(globalconf.embedded.len - i - 1)];
else
em = &globalconf.embedded.tab[i];
xcb_configure_window(globalconf.connection, em->win,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
config_vals);
@ -310,6 +316,8 @@ systray_update(int base_size, bool horizontal)
* \lparam y Y position for the systray.
* \lparam base_size The size (width and height) each systray item gets.
* \lparam horiz If true, the systray is horizontal, else vertical
* \lparam bg Color of the systray background
* \lparam revers If true, the systray icon order will be reversed, else default
*/
int
luaA_systray(lua_State *L)
@ -323,6 +331,7 @@ luaA_systray(lua_State *L)
int base_size = luaL_checknumber(L, 4);
bool horiz = lua_toboolean(L, 5);
const char *bg = luaL_checklstring(L, 6, &bg_len);
bool revers = lua_toboolean(L, 7);
color_t bg_color;
if(color_init_reply(color_init_unchecked(&bg_color, bg, bg_len)))
@ -354,7 +363,7 @@ luaA_systray(lua_State *L)
if(globalconf.embedded.len != 0)
{
systray_update(base_size, horiz);
systray_update(base_size, horiz, revers);
xcb_map_window(globalconf.connection,
globalconf.systray.window);
}