From 0cb22fd20395fd6c586fda6117177a2d7b2ed8e1 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 26 Dec 2018 22:26:05 -0500 Subject: [PATCH] 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). --- docs/config.ld | 1 + lib/awful/_compat.lua | 27 +++++++++++++++++++++++++++ lib/awful/init.lua | 31 ++----------------------------- 3 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 lib/awful/_compat.lua diff --git a/docs/config.ld b/docs/config.ld index 3a264f90..120ba85c 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -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', diff --git a/lib/awful/_compat.lua b/lib/awful/_compat.lua new file mode 100644 index 00000000..07016b14 --- /dev/null +++ b/lib/awful/_compat.lua @@ -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 diff --git a/lib/awful/init.lua b/lib/awful/init.lua index da63275c..cf576427 100644 --- a/lib/awful/init.lua +++ b/lib/awful/init.lua @@ -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