Advertisement
Guest User

Untitled

a guest
May 28th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. commit 7895f091aab89dfa794b86d229850b930ed0bd2e
  2. Author: Emmanuel Lepage Vallee <elv1313@gmail.com>
  3. Date: Wed May 28 00:46:17 2014 -0400
  4.  
  5. Fix flawed tag deletion logic (FS#1268)
  6.  
  7. The sticky use case was dubious as if there is no fallback tag,
  8. the process abort early. Then, the new selected tag doesn't have
  9. to be random, as the fallback is always a better choice.
  10.  
  11. Finally, this fix an issue where clients with multiple tags were
  12. simply not supported. It is a very useful feature if used with
  13. some implementation of tag forking. The current implementation
  14. caused the client to be untagged from all other tags. As the
  15. fallback tag is designed to avoid a client having no tags, it is
  16. not needed (nor wanted) in that case.
  17.  
  18. diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
  19. index 58b0a34..40a5bc0 100644
  20. --- a/lib/awful/tag.lua.in
  21. +++ b/lib/awful/tag.lua.in
  22. @@ -139,14 +139,19 @@ function tag.delete(target_tag, fallback_tag)
  23. local clients = target_tag:clients()
  24. if ( #clients > 0 and ntags <= 1 ) or fallback_tag == nil then return end
  25.  
  26. + -- Keep a possible candidate in case no selected tag is available
  27. + -- it is very rare, but possible if a client have been automatically tagged
  28. + local candidate = fallback_tag
  29. +
  30. -- Move the clients we can off of this tag.
  31. for _, c in pairs(clients) do
  32. + local current_tags = c:tags()
  33.  
  34. - -- If a client has only this tag, or stickied clients with
  35. - -- nowhere to go, abort.
  36. - if (not c.sticky and #c:tags() == 1) or
  37. - (c.sticky and fallback_tag == nil) then
  38. - return
  39. + -- Do not use a "random" tags as fallback if the client already have some
  40. + if #current_tags > 1 then
  41. + current_tags[util.table.hasitem(current_tags,target_tag)] = nil
  42. + c:tags(current_tags)
  43. + candidate = current_tags[1]
  44. else
  45. c:tags({fallback_tag})
  46. end
  47. @@ -160,7 +165,8 @@ function tag.delete(target_tag, fallback_tag)
  48. if tag.selected(target_scr) == nil and ntags > 0 then
  49. tag.history.restore(nil, 1)
  50. if tag.selected(target_scr) == nil then
  51. - tag.gettags(target_scr)[1].selected = true
  52. + local next_tag = candidate or tag.gettags(target_scr)[1]
  53. + next_tag.selected = true
  54. end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement