From 11e4fe88bb454d7317ce77fd83e456f02c683a53 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 24 Oct 2021 20:46:22 -0700 Subject: [PATCH 01/13] client.border_color: Fix a bug affecting floating clients. If client client was tiled, the `fallback` could be `theme.border_color_normal`, but if the client was tiled, this fallback was never tried. Now it tests for both "floating" and "active" fallbacks. This problem actually affects the default theme. --- lib/awful/permissions/init.lua | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/awful/permissions/init.lua b/lib/awful/permissions/init.lua index 90954429..11207b72 100644 --- a/lib/awful/permissions/init.lua +++ b/lib/awful/permissions/init.lua @@ -608,31 +608,32 @@ end, "mouse_enter") function permissions.update_border(c, context) if not pcommon.check(c, "client", "border", context) then return end - local suffix, fallback = "", "" + local suffix, fallback1, fallback2 = "", "" -- Add the sub-namespace. if c.fullscreen then - suffix, fallback = "_fullscreen", "_fullscreen" + suffix, fallback1 = "_fullscreen", "_fullscreen" elseif c.maximized then - suffix, fallback = "_maximized", "_maximized" + suffix, fallback1 = "_maximized", "_maximized" elseif c.floating then - suffix, fallback = "_floating", "_floating" + suffix, fallback1 = "_floating", "_floating" end -- Add the state suffix. if c.urgent then - suffix = suffix .. "_urgent" + suffix, fallback2 = suffix .. "_urgent", "_urgent" elseif c.active then - suffix = suffix .. "_active" + suffix, fallback2 = suffix .. "_active", "_active" elseif context == "added" then - suffix = suffix .. "_new" + suffix, fallback2 = suffix .. "_new", "_new" else - suffix = suffix .. "_normal" + suffix, fallback2 = suffix .. "_normal", "_normal" end if not c._private._user_border_width then c._border_width = beautiful["border_width"..suffix] - or beautiful["border_width"..fallback] + or beautiful["border_width"..fallback1] + or beautiful["border_width"..fallback2] or beautiful.border_width end @@ -657,8 +658,12 @@ function permissions.update_border(c, context) local tv = beautiful["border_color"..suffix] - if fallback ~= "" and not tv then - tv = beautiful["border_color"..fallback] + if (not tv) and fallback1 ~= "" then + tv = beautiful["border_color"..fallback1] + end + + if (not tv) and (fallback2 ~= "") then + tv = beautiful["border_color"..fallback2] end -- The old theme variable did not have "color" in its name. @@ -688,8 +693,12 @@ function permissions.update_border(c, context) if not c._private._user_opacity then local tv = beautiful["opacity"..suffix] - if fallback ~= "" and not tv then - tv = beautiful["opacity"..fallback] + if fallback1 ~= "" and not tv then + tv = beautiful["opacity"..fallback1] + end + + if fallback2 ~= "" and not tv then + tv = beautiful["opacity"..fallback2] end if tv then From c63a80de5c91127ff820c09b16a9d19bba4ba449 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 24 Oct 2021 21:13:54 -0700 Subject: [PATCH 02/13] layoutlist: Allow empty constructor. --- lib/awful/widget/layoutlist.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index a9c8ccac..1eaabd1f 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -400,6 +400,8 @@ local function update_common() end local function new(_, args) + args = args or {} + local ret = wibox.widget.base.make_widget(nil, nil, { enable_properties = true, }) From 2f8413acbc737b232bfb6fa897d39d50c3d7df56 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 27 Oct 2021 13:38:48 -0700 Subject: [PATCH 03/13] layoutlist: Use `layoutlist_spacing` instead of `tasklist_spacing`. Old copy/paste bug. --- lib/awful/widget/layoutlist.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 1eaabd1f..b1170823 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -245,7 +245,7 @@ local layoutlist = {} --- The space between the layouts. -- @beautiful beautiful.layoutlist_spacing --- @tparam[opt=0] number spacing The spacing between tasks. +-- @tparam[opt=0] number spacing The spacing between layouts. --- The default layoutlist elements shape. -- @beautiful beautiful.layoutlist_shape @@ -316,7 +316,7 @@ function layoutlist:set_base_layout(layout) if self._private.layout.set_spacing then self._private.layout:set_spacing( - self._private.style.spacing or beautiful.tasklist_spacing or 0 + self._private.style.spacing or beautiful.layoutlist_spacing or 0 ) end From 440d1560a32a2368214b11983786bdcf84f0f7c7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 24 Oct 2021 21:45:09 -0700 Subject: [PATCH 04/13] layoutlist: Fix the `layout` consturctor parameter. If set, it would override some important widget methods and explode. --- lib/awful/widget/layoutlist.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index b1170823..563f0fae 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -314,10 +314,10 @@ function layoutlist:set_base_layout(layout) layout or wibox.layout.fixed.horizontal ) - if self._private.layout.set_spacing then - self._private.layout:set_spacing( - self._private.style.spacing or beautiful.layoutlist_spacing or 0 - ) + local spacing = self._private.style.spacing or beautiful.tasklist_spacing + + if self._private.layout.set_spacing and spacing then + self._private.layout:set_spacing(spacing) end assert(self._private.layout.is_widget) @@ -415,11 +415,15 @@ local function new(_, args) reload_cache(ret) - -- Apply all args properties - gtable.crush(ret, args) + -- Apply all args properties. Make sure "set_layout" doesn't override + -- the widget `layout` method. + local l = args.layout + args.layout = nil + gtable.crush(ret, args, false) + args.layout = l if not ret._private.layout then - ret:set_base_layout() + ret:set_base_layout(args.layout) end assert(ret._private.layout) From c7208b4bb0ff5f2c7dce08a243bac8649b0f3cb7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 24 Oct 2021 21:46:39 -0700 Subject: [PATCH 05/13] layoutlist: Rename the constructor arg from `layout` to `base_layout`. The documentation examples already called it that way. --- lib/awful/widget/layoutlist.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 563f0fae..5fac6cd8 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -363,7 +363,7 @@ end --- Create a layout list. -- -- @tparam table args --- @tparam widget args.layout The widget layout (not to be confused with client +-- @tparam widget args.base_layout The widget layout (not to be confused with client -- layout). -- @tparam table args.buttons A table with buttons binding to set. -- @tparam[opt=awful.widget.layoutlist.source.for_screen] function args.source A From c36a869ded311bdd7c8d6fbd52e952df87cf0b93 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Oct 2021 13:31:33 -0700 Subject: [PATCH 06/13] textbox: Store the font in `_private`. So a getter can work. --- lib/wibox/widget/textbox.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/wibox/widget/textbox.lua b/lib/wibox/widget/textbox.lua index 26f6ea2f..b48bf684 100644 --- a/lib/wibox/widget/textbox.lua +++ b/lib/wibox/widget/textbox.lua @@ -338,6 +338,10 @@ end -- @propbeautiful function textbox:set_font(font) + if font == self._private.font then return end + + self._private.font = font + self._private.layout:set_font_description(beautiful.get_font(font)) self:emit_signal("widget::redraw_needed") self:emit_signal("widget::layout_changed") From 907053f31a4207dff23914c7545df57b6770d29c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 25 Oct 2021 20:22:42 -0700 Subject: [PATCH 07/13] titlebar: Implement setting the font (as documented, but unimplemented) It was documented to exist, but didn't. --- lib/awful/titlebar.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index fe16719a..9952a743 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -583,6 +583,7 @@ local function new(c, args) bars[position] = { args = args, drawable = ret, + font = args.font or beautiful.titlebar_font, update_colors = update_colors } @@ -683,6 +684,20 @@ local function update_on_signal(c, signal, widget) table.insert(widgets, widget) end +--- Honor the font. +local function draw_title(self, ctx, cr, width, height) + if ctx.position and ctx.client then + local bars = all_titlebars[ctx.client] + local data = bars and bars[ctx.position] + + if data and data.font then + self:set_font(data.font) + end + end + + textbox.draw(self, ctx, cr, width, height) +end + --- Create a new title widget. -- -- A title widget displays the name of a client. @@ -694,6 +709,9 @@ end -- @constructorfct awful.titlebar.widget.titlewidget function titlebar.widget.titlewidget(c) local ret = textbox() + + rawset(ret, "draw", draw_title) + local function update() ret:set_text(c.name or titlebar.fallback_name) end From 146a9c3166081ab513533dee6183a396154165d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 25 Oct 2021 20:23:50 -0700 Subject: [PATCH 08/13] permission: Fix hiding the border for maximized clients. When the theme variables were moved to the backend instead of `rc.lua`, some magic was added to disable them if the user set the border. However, some undocumented `awful.placement` code also set them and turned off the theme variables. So it worked *once* then stopped working. --- lib/awful/permissions/init.lua | 10 ++++++++-- lib/awful/placement.lua | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/awful/permissions/init.lua b/lib/awful/permissions/init.lua index 11207b72..64673d3f 100644 --- a/lib/awful/permissions/init.lua +++ b/lib/awful/permissions/init.lua @@ -631,10 +631,16 @@ function permissions.update_border(c, context) end if not c._private._user_border_width then - c._border_width = beautiful["border_width"..suffix] + local bw = beautiful["border_width"..suffix] or beautiful["border_width"..fallback1] or beautiful["border_width"..fallback2] - or beautiful.border_width + + -- The default `awful.permissions.geometry` handler removes the border. + if (not bw) and (c.fullscreen or c.maximized) then + bw = 0 + end + + c._border_width = bw or beautiful.border_width end if not c._private._user_border_color then diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index d57b817e..f25569a6 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -383,7 +383,7 @@ end area_common = function(d, new_geo, ignore_border_width, args) -- The C side expect no arguments, nil isn't valid if new_geo and args.zap_border_width then - d.border_width = 0 + d._border_width = 0 end local geometry = new_geo and d:geometry(new_geo) or d:geometry() local border = ignore_border_width and 0 or d.border_width or 0 @@ -1633,7 +1633,7 @@ function placement.restore(d, args) end - d.border_width = memento.border_width + d._border_width = memento.border_width -- Don't use the memento as it would be "destructive", since `x`, `y` -- and `screen` have to be modified. From cd83b64268b96946eca3b3a9d97aa8de93ac0bb2 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 25 Oct 2021 21:30:09 -0700 Subject: [PATCH 09/13] tests: Test titlebar fonts. --- tests/test-titlebar.lua | 45 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/test-titlebar.lua b/tests/test-titlebar.lua index d80f1937..4b0b8d4b 100644 --- a/tests/test-titlebar.lua +++ b/tests/test-titlebar.lua @@ -3,6 +3,7 @@ local titlebar = require("awful.titlebar") local rules = require("ruled.client") local spawn = require("awful.spawn") local gdebug = require("gears.debug") +local textbox = require("wibox.widget.textbox") local lua_executable = os.getenv("LUA") if lua_executable == nil or lua_executable == "" then @@ -17,10 +18,8 @@ window = Gtk.Window {default_width=100, default_height=100, title='title'} %s window:set_wmclass(class, class) local app = Gtk.Application {} -function app:on_activate() - window.application = self - window:show_all() -end +window:show_all() +Gtk:main{...} app:run {''} ]] local tiny_client = { lua_executable, "-e", string.format(tiny_client_code_template, "") } @@ -30,12 +29,21 @@ window.decorated = false ]]) } +local found_font = nil + -- Use the test client props local dep = gdebug.deprecate gdebug.deprecate = function() end rules.rules = {} gdebug.deprecate = dep +local function kill_client(c) + -- Make sure the process finishes. Just `c:kill()` only + -- closes the window. Adding some handlers to the GTK "app" + -- created some unwanted side effects in the CI. + awesome.kill(c.pid, 9) +end + -- Too bad there's no way to disconnect the rc.lua request::titlebars function local steps = { @@ -69,7 +77,7 @@ local steps = { titlebar.toggle(c, "top") assert(c.height == 100) - c:kill() + kill_client(c) return true end, @@ -100,7 +108,7 @@ local steps = { assert(c.width == 100 and c.height == h) - c:kill() + kill_client(c) return true end, @@ -119,7 +127,7 @@ local steps = { assert(c.width == 100 and c.height > 100) assert(c._request_titlebars_called) - c:kill() + kill_client(c) return true end, @@ -140,7 +148,7 @@ local steps = { assert(c.width == 100 and c.height > 100) assert(c._request_titlebars_called) - c:kill() + kill_client(c) return true end, @@ -161,7 +169,26 @@ local steps = { assert(not c._request_titlebars_called) assert(c.width == 100 and c.height == 100) - c:kill() + function textbox:set_font(value) + found_font = value + end + + local args = {size = 40, font = "sans 10", position = "bottom"} + titlebar(c, args).widget = titlebar.widget.titlewidget(c) + + return true + end, + function() + local c = client.get()[1] + + assert(found_font == "sans 10") + + kill_client(c) + + return true + end, + function() + if #client.get() > 0 then return end return true end, From 5069f5c2edd024e23ecf4d83feb29b308c0b088a Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Oct 2021 13:30:01 -0700 Subject: [PATCH 10/13] client.floating: Add a missing signal connection. The `fullscreen` state does affect the outcome of the state, so it needs to be connected for request::border to be sent. --- lib/awful/client.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 16085ab4..b0ab5303 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -984,6 +984,7 @@ capi.client.connect_signal("property::fullscreen", update_implicitly_floating) capi.client.connect_signal("property::maximized_vertical", update_implicitly_floating) capi.client.connect_signal("property::maximized_horizontal", update_implicitly_floating) capi.client.connect_signal("property::maximized", update_implicitly_floating) +capi.client.connect_signal("property::fullscreen", update_implicitly_floating) capi.client.connect_signal("property::size_hints", update_implicitly_floating) capi.client.connect_signal("request::manage", update_implicitly_floating) From cdd50feea7966a22321c21c42135e914835d7299 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Oct 2021 13:33:51 -0700 Subject: [PATCH 11/13] tests: Test the client border color and width. --- tests/test-client-borders.lua | 190 ++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 tests/test-client-borders.lua diff --git a/tests/test-client-borders.lua b/tests/test-client-borders.lua new file mode 100644 index 00000000..d9d044e7 --- /dev/null +++ b/tests/test-client-borders.lua @@ -0,0 +1,190 @@ +-- Brute force every possible states and see what blows up. +-- +-- The goal is to detect "other" code paths within the core +-- which have the side effect of accidentally marking the border +-- to be user-specified. When this happens, all theme variables +-- stop working. +-- +-- For example, fullscreen caused an issue because the default +-- request::geometry modified the border_width. +local beautiful = require("beautiful") +local aclient = require("awful.client") +local test_client = require("_client") + +local steps = {} +local used_colors = {} +local state_colors, state_widths = {}, {} +local state_setter = {} +local c = nil + +-- Make sure it uses `beautiful.border_width` (default) again. +local function reset() + client.focus = nil + c.urgent = false + c.maximized = false + c.fullscreen = false + + -- Use the low level API because `floating` has an implicit/explicit + -- mode just like the border. + aclient.property.set(c, "floating", nil) +end + +local function gen_random_color(state) + while true do + local str = "#" + for _=1, 3 do + local part = string.format("%x", math.ceil(math.random() * 255)) + part = #part == 1 and ("0"..part) or part + str = str .. part + end + + if not used_colors[str] then + used_colors[str] = state + return str + end + end +end + +local function check_state(state) + reset() + + if state_setter[state] then + local col = "border_color" .. state + local w = "border_width" .. state + state_setter[state](client.get()[1]) + + assert(c.border_color ~= nil) + assert(c.border_width ~= nil) + assert( + c.border_color == state_colors[col], + "Expected "..state_colors[col].." for "..state.. " but got "..c.border_color.. + " for "..(used_colors[c.border_color] or "nil") + ) + + if not state:find("full") then + assert(c.border_width == state_widths[w]) + else + assert(c.border_width == 0) + end + + assert(not c._private._user_border_width) + assert(not c._private._user_border_color) + end + + return true +end + +local function clear_theme() + for k in pairs(beautiful) do + if k:find("border_") then + beautiful[k] = nil + end + end + + return true +end + +for _, state1 in ipairs {"_fullscreen", "_maximized", "_floating" } do + local color = "border_color" .. state1 + local width = "border_width" .. state1 + + state_widths[width] = math.floor(math.random() * 10) + state_colors[color] = gen_random_color(color) + + for _, state2 in ipairs {"_urgent", "_active", "_new", "_normal" } do + color = "border_color" .. state1 .. state2 + width = "border_width" .. state1 .. state2 + + state_widths[width] = math.floor(math.random() * 10) + state_colors[color] = gen_random_color(color) + end +end + +for _, state in ipairs {"_urgent", "_active", "_new", "_normal" } do + local color = "border_color" .. state + local width = "border_width" .. state + + state_widths[width] = math.floor(math.random() * 10) + state_colors[color] = gen_random_color(color) + beautiful[width] = state_widths[width] + beautiful[color] = state_colors[color] +end + +function state_setter._urgent() + c.urgent = true +end + +function state_setter._fullscreen() + c.fullscreen = true +end + +function state_setter._floating() + c.floating = true +end + +function state_setter._active() + client.focus = c +end + +function state_setter._maximized() + c.maximized = true +end + +function state_setter._normal() + -- no-op +end + +test_client() + +table.insert(steps, function() + c = client.get()[1] + return c and true or nil +end) + +for _, state in ipairs {"_urgent", "_active", "_new", "_normal" } do + table.insert(steps, function() + return check_state(state) + end) +end + +table.insert(steps, clear_theme) + +table.insert(steps, function() + for _, state in ipairs {"_fullscreen", "_maximized", "_floating" } do + local color = "border_color" .. state + local width = "border_width" .. state + + beautiful[width] = state_widths[width] + beautiful[color] = state_colors[color] + end + + return true +end) + +for _, state in ipairs {"_fullscreen", "_maximized", "_floating" } do + table.insert(steps, function() + return check_state(state) + end) +end + +table.insert(steps, clear_theme) + +table.insert(steps, function() + -- Add everything to the theme. + for _, mode in ipairs {state_colors, state_widths} do + for key, value in pairs(mode) do + beautiful[key] = value + end + end + return true +end) + +for _, state1 in ipairs {"_fullscreen", "_maximized", "_floating" } do + for _, state2 in ipairs {"_urgent", "_active", "_new", "_normal" } do + table.insert(steps, function() + return check_state(state1 .. state2) + end) + end +end + +require("_runner").run_steps(steps) From bb65181e614899c5659da4752fa6f1086e78eb88 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 26 Oct 2021 14:27:19 -0700 Subject: [PATCH 12/13] doc: Document the textbox font. --- lib/wibox/widget/textbox.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/wibox/widget/textbox.lua b/lib/wibox/widget/textbox.lua index b48bf684..b733f434 100644 --- a/lib/wibox/widget/textbox.lua +++ b/lib/wibox/widget/textbox.lua @@ -332,6 +332,37 @@ end --- Set a textbox font. -- +-- There is multiple valid font string representation. The most precise is +-- [XFT](https://wiki.archlinux.org/title/X_Logical_Font_Description). It +-- is also possible to use the family name, followed by the face and size +-- such as `Monospace Bold 10`. This script lists the fonts present +-- on your system: +-- +-- #!/usr/bin/env lua +-- +-- local lgi = require("lgi") +-- local pangocairo = lgi.PangoCairo +-- +-- local font_map = pangocairo.font_map_get_default() +-- +-- for k, v in pairs(font_map:list_families()) do +-- print(v:get_name(), "monospace?: "..tostring(v:is_monospace())) +-- for k2, v2 in ipairs(v:list_faces()) do +-- print(" ".. v2:get_face_name()) +-- end +-- end +-- +-- Save this script somewhere on your system, `chmod +x` it and run it. It +-- will list something like: +-- +-- Sans monospace?: false +-- Regular +-- Bold +-- Italic +-- Bold Italic +-- +-- In this case, the font could be `Sans 10` or `Sans Bold Italic 10`. +-- -- @property font -- @tparam string font The font description as string. -- @propemits true false From 4f645fd07f51daffa3eb4a0e10ad9ef02b477684 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 27 Oct 2021 19:38:21 -0700 Subject: [PATCH 13/13] tests: Kill the test-selection-getter clients. This removes a confusing warning in the CI logs. --- tests/test-selection-getter.lua | 19 ++++++++++++++++--- tests/test-selection-watcher.lua | 22 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/test-selection-getter.lua b/tests/test-selection-getter.lua index 9d919355..afac4703 100644 --- a/tests/test-selection-getter.lua +++ b/tests/test-selection-getter.lua @@ -8,6 +8,8 @@ local lgi = require("lgi") local Gio = lgi.Gio local GdkPixbuf = lgi.GdkPixbuf +local pids = {} + local lua_executable = os.getenv("LUA") if lua_executable == nil or lua_executable == "" then lua_executable = "lua" @@ -53,8 +55,9 @@ runner.run_steps{ -- Clear the clipboard to get to a known state function() - spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) + table.insert(pids, pid) return true end, @@ -84,13 +87,15 @@ runner.run_steps{ -- Now set the clipboard to some text continue = false - spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_text }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_text }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) continue = true end }) + table.insert(pids, pid) + return true end, @@ -148,13 +153,15 @@ runner.run_steps{ -- Now set the clipboard to an image continue = false - spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_pixbuf }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard_pixbuf }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) continue = true end }) + table.insert(pids, pid) + return true end, @@ -194,6 +201,12 @@ runner.run_steps{ return end + -- There are now "windows", so they have no "clients", however, + -- they talk to X11 and wont exit by themselves and must be killed. + for _, pid in ipairs(pids) do + awesome.kill(pid, 9) + end + return true end, } diff --git a/tests/test-selection-watcher.lua b/tests/test-selection-watcher.lua index 3721a67f..2e9d6a64 100644 --- a/tests/test-selection-watcher.lua +++ b/tests/test-selection-watcher.lua @@ -3,6 +3,8 @@ local runner = require("_runner") local spawn = require("awful.spawn") +local pids = {} + local lua_executable = os.getenv("LUA") if lua_executable == nil or lua_executable == "" then lua_executable = "lua" @@ -67,8 +69,11 @@ runner.run_steps{ -- Clear the clipboard to get to a known state function() check_state(0, 0) - spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) + + table.insert(pids, pid) + return true end, @@ -86,13 +91,15 @@ runner.run_steps{ -- Set the clipboard continue = false - spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_clipboard }, { stdout = function(line) assert(line == "initialisation done", "Unexpected line: " .. line) continue = true end }) + table.insert(pids, pid) + return true end, @@ -105,9 +112,11 @@ runner.run_steps{ -- Now clear the clipboard again continue = false - spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, + local pid = spawn.with_line_callback({ lua_executable, "-e", acquire_and_clear_clipboard }, { exit = function() continue = true end }) + table.insert(pids, pid) + return true end, @@ -118,6 +127,13 @@ runner.run_steps{ end check_state(2, 1) + + -- There are now "windows", so they have no "clients", however, + -- they talk to X11 and wont exit by themselves and must be killed. + for _, pid in ipairs(pids) do + awesome.kill(pid, 9) + end + return true end }