From e8649d0a296a8a014fbd9e98182c78bfae2b9ed3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 15 Sep 2016 16:50:10 -0400 Subject: [PATCH 1/2] screen: Add a function to get the client preferred screen --- lib/awful/screen.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 6a7a496d..48efa13c 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -12,7 +12,8 @@ local capi = { mouse = mouse, screen = screen, - client = client + client = client, + awesome = awesome, } local util = require("awful.util") local object = require("gears.object") @@ -213,6 +214,15 @@ function screen.object.set_padding(self, padding) end end +--- Return the currently screen for new clients. +-- This is exactly the same as `awful.screen.focused` exept it avoids clients +-- being moved when Awesome is restarted. This is used by the default `rc.lua`. +-- @tparam client c A client +-- @treturn screen The preferred screen. +function screen.preferred(c) + return capi.awesome.startup and c.screen or screen.focused() +end + --- The defaults arguments for `awful.screen.focused` -- @tfield[opt=nil] table awful.screen.default_focused_args From 1c177cabce1557f6eacf517dee0e8ff0f4cb02fe Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 15 Sep 2016 16:50:28 -0400 Subject: [PATCH 2/2] 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 --- awesomerc.lua | 1 + lib/awful/screen.lua | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 0029e197..11dcc93e 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -428,6 +428,7 @@ awful.rules.rules = { raise = true, keys = clientkeys, buttons = clientbuttons, + screen = awful.screen.preferred, placement = awful.placement.no_overlap+awful.placement.no_offscreen } }, diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 48efa13c..f477d6a0 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -214,10 +214,12 @@ function screen.object.set_padding(self, padding) end end ---- Return the currently screen for new clients. --- This is exactly the same as `awful.screen.focused` exept it avoids clients --- being moved when Awesome is restarted. This is used by the default `rc.lua`. --- @tparam client c A client +--- Get the preferred screen in the context of a client. +-- This is exactly the same as `awful.screen.focused` except that it avoids +-- clients being moved when Awesome is restarted. +-- 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. function screen.preferred(c) return capi.awesome.startup and c.screen or screen.focused()