From 6f803cf3b3b975c0a26b1ce62b04fa4f80c78bd1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 6 Mar 2017 17:11:05 +0100 Subject: [PATCH] Fix code using awful.util.round This gets rid of lots of deprecation warnings Signed-off-by: Uli Schlachter --- lib/awful/titlebar.lua | 3 ++- lib/menubar/init.lua | 3 ++- lib/wibox/layout/flex.lua | 5 +++-- lib/wibox/layout/ratio.lua | 9 +++++---- tests/test-awful-rules.lua | 3 ++- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index 81a5ba415..a25ad7a62 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -8,6 +8,7 @@ local error = error local type = type +local gmath = require("gears.math") local util = require("awful.util") local abutton = require("awful.button") local aclient = require("awful.client") @@ -464,7 +465,7 @@ end local function new(c, args) args = args or {} local position = args.position or "top" - local size = args.size or util.round(beautiful.get_font_height(args.font) * 1.5) + local size = args.size or gmath.round(beautiful.get_font_height(args.font) * 1.5) local d = get_titlebar_function(c, position)(c, size) -- Make sure that there is never more than one titlebar for any given client diff --git a/lib/menubar/init.lua b/lib/menubar/init.lua index eb9f06656..5b538f5a6 100644 --- a/lib/menubar/init.lua +++ b/lib/menubar/init.lua @@ -25,6 +25,7 @@ local capi = { mouse = mouse, screen = screen } +local gmath = require("gears.math") local awful = require("awful") local common = require("awful.widget.common") local theme = require("beautiful") @@ -417,7 +418,7 @@ function menubar.show(scr) local geometry = menubar.geometry instance.geometry = {x = geometry.x or scrgeom.x, y = geometry.y or scrgeom.y, - height = geometry.height or awful.util.round(theme.get_font_height() * 1.5), + height = geometry.height or gmath.round(theme.get_font_height() * 1.5), width = geometry.width or scrgeom.width} instance.wibox:geometry(instance.geometry) diff --git a/lib/wibox/layout/flex.lua b/lib/wibox/layout/flex.lua index 51f773dbc..4318a9f4f 100644 --- a/lib/wibox/layout/flex.lua +++ b/lib/wibox/layout/flex.lua @@ -11,6 +11,7 @@ local fixed = require("wibox.layout.fixed") local table = table local pairs = pairs local floor = math.floor +local gmath = require("gears.math") local util = require("awful.util") local flex = {} @@ -69,10 +70,10 @@ function flex:layout(_, width, height) for _, v in pairs(self._private.widgets) do local x, y, w, h if self._private.dir == "y" then - x, y = 0, util.round(pos) + x, y = 0, gmath.round(pos) w, h = width, floor(space_per_item) else - x, y = util.round(pos), 0 + x, y = gmath.round(pos), 0 w, h = floor(space_per_item), height end diff --git a/lib/wibox/layout/ratio.lua b/lib/wibox/layout/ratio.lua index 2750467ba..f2817b542 100644 --- a/lib/wibox/layout/ratio.lua +++ b/lib/wibox/layout/ratio.lua @@ -14,6 +14,7 @@ local flex = require("wibox.layout.flex" ) local table = table local pairs = pairs local floor = math.floor +local gmath = require("gears.math") local util = require("awful.util") local ratio = {} @@ -87,11 +88,11 @@ function ratio:layout(_, width, height) if self._private.dir == "y" then space = height * self._private.ratios[k] - x, y = 0, util.round(pos) + x, y = 0, gmath.round(pos) w, h = width, floor(space) else space = width * self._private.ratios[k] - x, y = util.round(pos), 0 + x, y = gmath.round(pos), 0 w, h = floor(space), height end @@ -101,8 +102,8 @@ function ratio:layout(_, width, height) -- Make sure all widgets fit in the layout, if they aren't, something -- went wrong - if (self._private.dir == "y" and util.round(pos) >= height) or - (self._private.dir ~= "y" and util.round(pos) >= width) then + if (self._private.dir == "y" and gmath.round(pos) >= height) or + (self._private.dir ~= "y" and gmath.round(pos) >= width) then break end end diff --git a/tests/test-awful-rules.lua b/tests/test-awful-rules.lua index 6391dc6ed..be258fc10 100644 --- a/tests/test-awful-rules.lua +++ b/tests/test-awful-rules.lua @@ -1,4 +1,5 @@ local awful = require("awful") +local gears = require("gears") local beautiful = require("beautiful") local test_client = require("_client") local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1) @@ -8,7 +9,7 @@ local callback_called = false -- Magic table to store tests local tests = {} -local tb_height = awful.util.round(beautiful.get_font_height() * 1.5) +local tb_height = gears.math.round(beautiful.get_font_height() * 1.5) -- local border_width = beautiful.border_width -- Detect "manage" race conditions