From 3db87c693abb4dfa35c09ea01050f8763f43fa95 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 21 Feb 2016 16:53:46 +0100 Subject: [PATCH 1/3] menubar.icon_theme: Don't require("awful") This avoids having to mock half the C API just because all of awful is loaded needlessly in this unit test and is generally a good idea. Signed-off-by: Uli Schlachter --- lib/menubar/icon_theme.lua | 20 ++++++++++---------- spec/menubar/icon_theme_spec.lua | 23 ----------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/lib/menubar/icon_theme.lua b/lib/menubar/icon_theme.lua index 768db7c78..6ffb9e518 100644 --- a/lib/menubar/icon_theme.lua +++ b/lib/menubar/icon_theme.lua @@ -12,7 +12,7 @@ -- http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-0.12.html local beautiful = require("beautiful") -local awful = require("awful") +local awful_util = require("awful.util") local GLib = require("lgi").GLib local index_theme = require("menubar.index_theme") @@ -26,18 +26,18 @@ local get_pragmatic_base_directories = function() local dirs = {} local dir = GLib.build_filenamev({GLib.get_home_dir(), ".icons"}) - if awful.util.dir_readable(dir) then + if awful_util.dir_readable(dir) then table.insert(dirs, dir) end dir = GLib.build_filenamev({GLib.get_user_data_dir(), "icons"}) - if awful.util.dir_readable(dir) then + if awful_util.dir_readable(dir) then table.insert(dirs, dir) end for _, v in ipairs(GLib.get_system_data_dirs()) do dir = GLib.build_filenamev({v, "icons"}) - if awful.util.dir_readable(dir) then + if awful_util.dir_readable(dir) then table.insert(dirs, dir) end end @@ -45,7 +45,7 @@ local get_pragmatic_base_directories = function() local need_usr_share_pixmaps = true for _, v in ipairs(GLib.get_system_data_dirs()) do dir = GLib.build_filenamev({v, "pixmaps"}) - if awful.util.dir_readable(dir) then + if awful_util.dir_readable(dir) then table.insert(dirs, dir) end if dir == "/usr/share/pixmaps" then @@ -54,7 +54,7 @@ local get_pragmatic_base_directories = function() end dir = "/usr/share/pixmaps" - if need_usr_share_pixmaps and awful.util.dir_readable(dir) then + if need_usr_share_pixmaps and awful_util.dir_readable(dir) then table.insert(dirs, dir) end @@ -66,7 +66,7 @@ local get_default_icon_theme_name = function() for _, dir in ipairs(get_pragmatic_base_directories()) do for _, icon_theme_name in ipairs(icon_theme_names) do local filename = string.format("%s/%s/index.theme", dir, icon_theme_name) - if awful.util.file_readable(filename) then + if awful_util.file_readable(filename) then return icon_theme_name end end @@ -153,7 +153,7 @@ local lookup_icon = function(self, icon_name, icon_size) local filename = string.format("%s/%s/%s/%s.%s", basedir, self.icon_theme_name, subdir, icon_name, ext) - if awful.util.file_readable(filename) then + if awful_util.file_readable(filename) then return filename else checked_already[filename] = true @@ -174,7 +174,7 @@ local lookup_icon = function(self, icon_name, icon_size) basedir, self.icon_theme_name, subdir, icon_name, ext) if not checked_already[filename] then - if awful.util.file_readable(filename) then + if awful_util.file_readable(filename) then closest_filename = filename minimal_size = dist end @@ -210,7 +210,7 @@ local lookup_fallback_icon = function(self, icon_name) local filename = string.format("%s/%s.%s", dir, icon_name, ext) - if awful.util.file_readable(filename) then + if awful_util.file_readable(filename) then return filename end end diff --git a/spec/menubar/icon_theme_spec.lua b/spec/menubar/icon_theme_spec.lua index 8588d3a27..ff937a47a 100644 --- a/spec/menubar/icon_theme_spec.lua +++ b/spec/menubar/icon_theme_spec.lua @@ -3,29 +3,6 @@ -- @copyright 2015 Kazunobu Kuriyama --------------------------------------------------------------------------- --- Hack so that beautiful can be loaded -_G.awesome = { - xrdb_get_value = function() end, - connect_signal = function() end, - register_xproperty = function() end -} --- Additional hacks to load menubar -_G.screen = { - add_signal = function() end, - count = function() return 0 end -} -_G.client = { - connect_signal = function() end, - add_signal = function() end -} -_G.tag = { - connect_signal = function() end, - add_signal = function() end -} -_G.root = { - cursor = function() end -} - local os = os local string = string local icon_theme = require("menubar.icon_theme") From f3091154f64b98b1efdbd5617293984cb62ad6e2 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 21 Feb 2016 17:08:50 +0100 Subject: [PATCH 2/3] Make beautiful work directly under unit tests Signed-off-by: Uli Schlachter --- lib/beautiful/xresources.lua | 8 +++++++- spec/awful/keyboardlayout_spec.lua | 5 ----- spec/wibox/widget/textbox_spec.lua | 9 --------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/beautiful/xresources.lua b/lib/beautiful/xresources.lua index d9b174b93..333d5aa44 100644 --- a/lib/beautiful/xresources.lua +++ b/lib/beautiful/xresources.lua @@ -74,7 +74,13 @@ function xresources.get_dpi(s) return dpi_per_screen[s] end if not xresources.dpi then - xresources.dpi = tonumber(awesome.xrdb_get_value("", "Xft.dpi") or 96) + -- Might not be present when run under unit tests + if awesome and awesome.xrdb_get_value then + xresources.dpi = tonumber(awesome.xrdb_get_value("", "Xft.dpi")) + end + if not xresources.dpi then + xresources.dpi = 96 + end end return xresources.dpi end diff --git a/spec/awful/keyboardlayout_spec.lua b/spec/awful/keyboardlayout_spec.lua index 99692a91e..ae168e9f8 100644 --- a/spec/awful/keyboardlayout_spec.lua +++ b/spec/awful/keyboardlayout_spec.lua @@ -3,11 +3,6 @@ -- @copyright 2015 Uli Schlachter and Kazunobu Kuriyama --------------------------------------------------------------------------- --- Hack so that beautiful can be loaded -_G.awesome = { - xrdb_get_value = function() end -} - local kb = require("awful.widget.keyboardlayout") describe("awful.widget.keyboardlayout get_groups_from_group_names", function() diff --git a/spec/wibox/widget/textbox_spec.lua b/spec/wibox/widget/textbox_spec.lua index 9200a6b64..10f5028a5 100644 --- a/spec/wibox/widget/textbox_spec.lua +++ b/spec/wibox/widget/textbox_spec.lua @@ -3,15 +3,6 @@ -- @copyright 2015 Uli Schlachter --------------------------------------------------------------------------- --- Grml... -_G.awesome = { - xrdb_get_value = function(a, b) - if a ~= "" then error() end - if b ~= "Xft.dpi" then error() end - return nil - end -} - local textbox = require("wibox.widget.textbox") describe("wibox.widget.textbox", function() From f6ccda84999372733ea92c29e28e550eaa3b1bfd Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 21 Feb 2016 16:44:40 +0100 Subject: [PATCH 3/3] awful.ewmh: React to workarea changes This commit makes awful.ewmh re-apply the maximized geometry to any maximized clients when the workarea of a screen changes. This happens e.g. when a wibox that is docked to the edge of the screen is hidden. Fixes: https://github.com/awesomeWM/awesome/issues/705 Signed-off-by: Uli Schlachter --- lib/awful/ewmh.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/awful/ewmh.lua b/lib/awful/ewmh.lua index e2b5ed8ee..0fffa6dd7 100644 --- a/lib/awful/ewmh.lua +++ b/lib/awful/ewmh.lua @@ -202,6 +202,11 @@ client.connect_signal("request::fullscreen", fullscreen) client.connect_signal("property::screen", screen_change) client.connect_signal("property::border_width", geometry_change) client.connect_signal("property::geometry", geometry_change) +screen.connect_signal("property::workarea", function(s) + for _, c in pairs(client.get(s)) do + geometry_change(c) + end +end) return ewmh