From 9cbc8a18c04c89f40aa208ed5596163e7aeac47a Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 2 Feb 2020 21:03:15 -0500 Subject: [PATCH] rc.lua: Revert moving the sloppy focus to awful.permissions. This caused a behavior change it wasn't clear how to use the permission API to change the focus mode. The change will only take effect if the user override the API level. --- awesomerc.lua | 5 +++++ lib/awful/autofocus.lua | 13 ++++++++----- lib/awful/permissions/init.lua | 11 ++++++++--- spec/awful/permissions_spec.lua | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 00d4134a..c9124395 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -538,3 +538,8 @@ client.connect_signal("request::titlebars", function(c) } end) -- }}} + +-- Enable sloppy focus, so that focus follows mouse. +client.connect_signal("mouse::enter", function(c) + c:activate { context = "mouse_enter", raise = false } +end) diff --git a/lib/awful/autofocus.lua b/lib/awful/autofocus.lua index c11d4831..a765ea6b 100644 --- a/lib/awful/autofocus.lua +++ b/lib/awful/autofocus.lua @@ -8,8 +8,11 @@ --------------------------------------------------------------------------- require("awful.permissions._common")._deprecated_autofocus_in_use() ---require("gears.debug").deprecate( --- "The `awful.autofocus` module is deprecated, remove the require() and ".. --- "look at the new `rc.lua` granted permission section in the client rules", --- {deprecated_in=5} ---) +if awesome.api_level > 4 then + --TODO v5: Remove `require("awful.autofocus")` from `rc.lua`. + require("gears.debug").deprecate( + "The `awful.autofocus` module is deprecated, remove the require() and ".. + "look at the new `rc.lua` granted permission section in the client rules", + {deprecated_in=5} + ) +end diff --git a/lib/awful/permissions/init.lua b/lib/awful/permissions/init.lua index c1baa0c5..d0c82d1e 100644 --- a/lib/awful/permissions/init.lua +++ b/lib/awful/permissions/init.lua @@ -740,9 +740,14 @@ screen.connect_signal("property::workarea", function(s) end) -- Enable sloppy focus, so that focus follows mouse. -client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::autoactivate", "mouse_enter", {raise=false}) -end) +if awesome.api_level > 4 then + --TODO v5: Remove the code from `rc.lua`. It cannot be done yet because we + -- cannot know if the user removed it to disable sloppy focus or because + -- they want to use the permissions to manage it. + client.connect_signal("mouse::enter", function(c) + c:emit_signal("request::autoactivate", "mouse_enter", {raise=false}) + end) +end return permissions diff --git a/spec/awful/permissions_spec.lua b/spec/awful/permissions_spec.lua index ce13aabc..f02fde36 100644 --- a/spec/awful/permissions_spec.lua +++ b/spec/awful/permissions_spec.lua @@ -15,6 +15,7 @@ describe("awful.permissions.client_geometry_requests", function() connect_signal = function() end, } _G.awesome = { + api_level = 4, connect_signal = function() end, } _G.drawin = {