From e8649d0a296a8a014fbd9e98182c78bfae2b9ed3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 15 Sep 2016 16:50:10 -0400 Subject: [PATCH] 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