awesomerc: Explicitly select a default screen

A client is supposed to go to a screen when:

 * It has been started using `awful.spawn` with explicit instructions [1]
 * An `awful.rules` rule **or any of its callbacks** set the screen [2]
 * When something handle `request::screen` and/or `request::tag` in some
   custom ways. [3]
 * Some clients can request a screen and mean it (like MythTV/Kodi/XBMC and
   some multi-window DAW) [4]

A client is supposed to go to the focused screen when none of the above are
true [5].

Other constraints:

 * The screen need to be set only once, anything will will emit
   `property::screen` many time and cause side effects.
 * There has to be a single entry point to the algorithm, no multiple
   "manage" handler.
 * Awesome internals must use the `request::` signal API and not force
   their decision outside of request handlers.
 * Restarting Awesome must not change the client screen

Commit 2178744 fix use case number [1] and [2]. It actually fix [4] too, but
it is an accident and I am not sure we care about [4] anyway. Use case [1]
and [2], however, are very important.

Fix #1091
This commit is contained in:
Emmanuel Lepage Vallee 2016-09-15 16:50:28 -04:00 committed by Daniel Hahler
parent e8649d0a29
commit 1c177cabce
2 changed files with 7 additions and 4 deletions

View File

@ -428,6 +428,7 @@ awful.rules.rules = {
raise = true, raise = true,
keys = clientkeys, keys = clientkeys,
buttons = clientbuttons, buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen placement = awful.placement.no_overlap+awful.placement.no_offscreen
} }
}, },

View File

@ -214,10 +214,12 @@ function screen.object.set_padding(self, padding)
end end
end end
--- Return the currently screen for new clients. --- Get the preferred screen in the context of a client.
-- This is exactly the same as `awful.screen.focused` exept it avoids clients -- This is exactly the same as `awful.screen.focused` except that it avoids
-- being moved when Awesome is restarted. This is used by the default `rc.lua`. -- clients being moved when Awesome is restarted.
-- @tparam client c A client -- This is used in the default `rc.lua` to ensure clients get assigned to the
-- focused screen by default.
-- @tparam client c A client.
-- @treturn screen The preferred screen. -- @treturn screen The preferred screen.
function screen.preferred(c) function screen.preferred(c)
return capi.awesome.startup and c.screen or screen.focused() return capi.awesome.startup and c.screen or screen.focused()