awful: Move the backward compatibility code into its own file.

The reason for this is that as more of CAPI is brought in line with the
current API guidelines, it is more and more likely the tests will hit
APIs shims (either to test them or because the prototype remains the
same and only the implementation moved to Lua).
This commit is contained in:
Emmanuel Lepage Vallee 2018-12-26 22:26:05 -05:00
parent 4cab9f8c38
commit 0cb22fd203
3 changed files with 30 additions and 29 deletions

View File

@ -133,6 +133,7 @@ file = {
-- documentation
'../lib/awful/autofocus.lua',
'../lib/awful/dbus.lua',
'../lib/awful/_compat.lua',
'../lib/awful/init.lua',
'../lib/awful/remote.lua',
'../lib/awful/screen/dpi.lua',

27
lib/awful/_compat.lua Normal file
View File

@ -0,0 +1,27 @@
-- This file contains all global backward compatibility workarounds for the
-- Core API changes.
local gtimer = require("gears.timer")
local util = require("awful.util" )
local spawn = require("awful.spawn")
local gdebug = require("gears.debug")
function timer(...) -- luacheck: ignore
gdebug.deprecate("gears.timer", {deprecated_in=4})
return gtimer(...)
end
util.spawn = function(...)
gdebug.deprecate("awful.spawn", {deprecated_in=4})
return spawn.spawn(...)
end
util.spawn_with_shell = function(...)
gdebug.deprecate("awful.spawn.with_shell", {deprecated_in=4})
return spawn.with_shell(...)
end
util.pread = function()
gdebug.deprecate("Use io.popen() directly or look at awful.spawn.easy_async() "
.. "for an asynchronous alternative", {deprecated_in=4})
return ""
end

View File

@ -6,34 +6,7 @@
-- @module awful
---------------------------------------------------------------------------
-- TODO: This is a hack for backwards-compatibility with 3.5, remove!
local util = require("awful.util")
local gtimer = require("gears.timer")
local gdebug = require("gears.debug")
function timer(...) -- luacheck: ignore
gdebug.deprecate("gears.timer", {deprecated_in=4})
return gtimer(...)
end
--TODO: This is a hack for backwards-compatibility with 3.5, remove!
-- Set awful.util.spawn* and awful.util.pread.
local spawn = require("awful.spawn")
util.spawn = function(...)
gdebug.deprecate("awful.spawn", {deprecated_in=4})
return spawn.spawn(...)
end
util.spawn_with_shell = function(...)
gdebug.deprecate("awful.spawn.with_shell", {deprecated_in=4})
return spawn.with_shell(...)
end
util.pread = function()
gdebug.deprecate("Use awful.spawn.easy_async() "
.. "for an asynchronous alternative", {deprecated_in=4})
return ""
end
require("awful._compat")
return
{
@ -60,7 +33,7 @@ return
titlebar = require("awful.titlebar");
rules = require("awful.rules");
popup = require("awful.popup");
spawn = spawn;
spawn = require("awful.spawn");
}
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80