diff --git a/lib/wibox/widget/systray.lua.in b/lib/wibox/widget/systray.lua.in index f6cb6378..325482d9 100644 --- a/lib/wibox/widget/systray.lua.in +++ b/lib/wibox/widget/systray.lua.in @@ -10,6 +10,7 @@ local beautiful = require("beautiful") local capi = { awesome = awesome } local setmetatable = setmetatable local error = error +local abs = math.abs --- wibox.widget.systray local systray = { mt = {} } @@ -19,13 +20,18 @@ local horizontal = true local base_size = nil function systray:draw(wibox, cr, width, height) - local x, y, width, height = lbase.rect_to_device_geometry(cr, 0, 0, width, height) + local x, y, _, _ = lbase.rect_to_device_geometry(cr, 0, 0, width, height) local num_entries = capi.awesome.systray() local bg = beautiful.bg_systray or beautiful.bg_normal or "#000000" + -- Figure out if the cairo context is rotated + local dir_x, dir_y = cr:user_to_device_distance(1, 0) + local is_rotated = abs(dir_x) < abs(dir_y) + local in_dir, ortho, base if horizontal then in_dir, ortho = width, height + is_rotated = not is_rotated else ortho, in_dir = width, height end @@ -34,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, horizontal, bg) + capi.awesome.systray(wibox.drawin, x, y, base, is_rotated, bg) end function systray:fit(width, height)