awful.client: Convert all remaining functions to methods.
This commit is contained in:
parent
e15fea6a46
commit
43f1561f26
|
@ -142,9 +142,17 @@ mylayoutbox = {}
|
||||||
mytaglist = {}
|
mytaglist = {}
|
||||||
mytaglist.buttons = awful.util.table.join(
|
mytaglist.buttons = awful.util.table.join(
|
||||||
awful.button({ }, 1, awful.tag.viewonly),
|
awful.button({ }, 1, awful.tag.viewonly),
|
||||||
awful.button({ modkey }, 1, awful.client.movetotag),
|
awful.button({ modkey }, 1, function(t)
|
||||||
|
if client.focus then
|
||||||
|
client.focus:move_to_tag(t)
|
||||||
|
end
|
||||||
|
end),
|
||||||
awful.button({ }, 3, awful.tag.viewtoggle),
|
awful.button({ }, 3, awful.tag.viewtoggle),
|
||||||
awful.button({ modkey }, 3, awful.client.toggletag),
|
awful.button({ modkey }, 3, function(t)
|
||||||
|
if client.focus then
|
||||||
|
client.focus:toggle_tag(t)
|
||||||
|
end
|
||||||
|
end),
|
||||||
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
|
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
|
||||||
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
|
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
|
||||||
)
|
)
|
||||||
|
@ -335,7 +343,7 @@ clientkeys = awful.util.table.join(
|
||||||
{description = "toggle floating", group = "client"}),
|
{description = "toggle floating", group = "client"}),
|
||||||
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
|
||||||
{description = "move to master", group = "client"}),
|
{description = "move to master", group = "client"}),
|
||||||
awful.key({ modkey, }, "o", awful.client.movetoscreen ,
|
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
|
||||||
{description = "move to screen", group = "client"}),
|
{description = "move to screen", group = "client"}),
|
||||||
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
|
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
|
||||||
{description = "toggle keep on top", group = "client"}),
|
{description = "toggle keep on top", group = "client"}),
|
||||||
|
@ -385,7 +393,7 @@ for i = 1, 9 do
|
||||||
if client.focus then
|
if client.focus then
|
||||||
local tag = awful.tag.gettags(client.focus.screen)[i]
|
local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||||
if tag then
|
if tag then
|
||||||
awful.client.movetotag(tag)
|
client.focus:move_to_tag(tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -396,7 +404,7 @@ for i = 1, 9 do
|
||||||
if client.focus then
|
if client.focus then
|
||||||
local tag = awful.tag.gettags(client.focus.screen)[i]
|
local tag = awful.tag.gettags(client.focus.screen)[i]
|
||||||
if tag then
|
if tag then
|
||||||
awful.client.toggletag(tag)
|
client.focus:toggle_tag(tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -62,26 +62,42 @@ client.focus = require("awful.client.focus")
|
||||||
--- Jump to the given client.
|
--- Jump to the given client.
|
||||||
-- Takes care of focussing the screen, the right tag, etc.
|
-- Takes care of focussing the screen, the right tag, etc.
|
||||||
--
|
--
|
||||||
|
-- @deprecated awful.client.jumpto
|
||||||
|
-- @see client.jump_to
|
||||||
-- @client c the client to jump to
|
-- @client c the client to jump to
|
||||||
-- @tparam bool|function merge If true then merge tags (select the client's
|
-- @tparam bool|function merge If true then merge tags (select the client's
|
||||||
-- first tag additionally) when the client is not visible.
|
-- first tag additionally) when the client is not visible.
|
||||||
-- If it is a function, it will be called with the client and its first
|
-- If it is a function, it will be called with the client and its first
|
||||||
-- tag as arguments.
|
-- tag as arguments.
|
||||||
function client.jumpto(c, merge)
|
function client.jumpto(c, merge)
|
||||||
local s = get_screen(screen.focused())
|
util.deprecate "Use c:jump_to(merge) instead of awful.client.jumpto"
|
||||||
-- focus the screen
|
|
||||||
if s ~= get_screen(c.screen) then
|
client.object.jump_to(c, merge)
|
||||||
screen.focus(c.screen)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
c.minimized = false
|
--- Jump to the given client.
|
||||||
|
-- Takes care of focussing the screen, the right tag, etc.
|
||||||
|
--
|
||||||
|
-- @function client.jump_to
|
||||||
|
-- @tparam bool|function merge If true then merge tags (select the client's
|
||||||
|
-- first tag additionally) when the client is not visible.
|
||||||
|
-- If it is a function, it will be called with the client and its first
|
||||||
|
-- tag as arguments.
|
||||||
|
function client.object.jump_to(self, merge)
|
||||||
|
local s = get_screen(screen.focused())
|
||||||
|
-- focus the screen
|
||||||
|
if s ~= get_screen(self.screen) then
|
||||||
|
screen.focus(self.screen)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.minimized = false
|
||||||
|
|
||||||
-- Try to make client visible, this also covers e.g. sticky.
|
-- Try to make client visible, this also covers e.g. sticky.
|
||||||
if not c:isvisible() then
|
if not self:isvisible() then
|
||||||
local t = c.first_tag
|
local t = self.first_tag
|
||||||
if merge then
|
if merge then
|
||||||
if type(merge) == "function" then
|
if type(merge) == "function" then
|
||||||
merge(c, t)
|
merge(self, t)
|
||||||
elseif t then
|
elseif t then
|
||||||
t.selected = true
|
t.selected = true
|
||||||
end
|
end
|
||||||
|
@ -90,7 +106,7 @@ function client.jumpto(c, merge)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
c:emit_signal("request::activate", "client.jumpto", {raise=true})
|
self:emit_signal("request::activate", "client.jumpto", {raise=true})
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO move this to `awful.screen`
|
--TODO move this to `awful.screen`
|
||||||
|
@ -213,12 +229,12 @@ function client.swap.global_bydirection(dir, sel)
|
||||||
|
|
||||||
-- swapping to an empty screen
|
-- swapping to an empty screen
|
||||||
elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel == c then
|
elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel == c then
|
||||||
client.movetoscreen(sel, screen.focused())
|
sel:move_to_screen(screen.focused())
|
||||||
|
|
||||||
-- swapping to a nonempty screen
|
-- swapping to a nonempty screen
|
||||||
elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel ~= c then
|
elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel ~= c then
|
||||||
client.movetoscreen(sel, c.screen)
|
sel:move_to_screen(c.screen)
|
||||||
client.movetoscreen(c, scr)
|
sel:move_to_screen(scr)
|
||||||
end
|
end
|
||||||
|
|
||||||
screen.focus(sel.screen)
|
screen.focus(sel.screen)
|
||||||
|
@ -295,45 +311,76 @@ function client.setslave(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Move/resize a client relative to current coordinates.
|
--- Move/resize a client relative to current coordinates.
|
||||||
|
-- @deprecated awful.client.moveresize
|
||||||
-- @param x The relative x coordinate.
|
-- @param x The relative x coordinate.
|
||||||
-- @param y The relative y coordinate.
|
-- @param y The relative y coordinate.
|
||||||
-- @param w The relative width.
|
-- @param w The relative width.
|
||||||
-- @param h The relative height.
|
-- @param h The relative height.
|
||||||
-- @client[opt] c The client, otherwise focused one is used.
|
-- @client[opt] c The client, otherwise focused one is used.
|
||||||
|
-- @see client.move_resize
|
||||||
function client.moveresize(x, y, w, h, c)
|
function client.moveresize(x, y, w, h, c)
|
||||||
local sel = c or capi.client.focus
|
util.deprecate "Use c:move_resize(x, y, w, h) instead of awful.client.moveresize"
|
||||||
local geometry = sel:geometry()
|
client.object.move_resize(c or capi.client.focus, x, y, w, h)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Move/resize a client relative to current coordinates.
|
||||||
|
-- @function client.move_resize
|
||||||
|
-- @see geometry
|
||||||
|
-- @tparam[opt=c.x] number x The relative x coordinate.
|
||||||
|
-- @tparam[opt=c.y] number y The relative y coordinate.
|
||||||
|
-- @tparam[opt=c.width] number w The relative width.
|
||||||
|
-- @tparam[opt=c.height] number h The relative height.
|
||||||
|
function client.object.move_resize(self, x, y, w, h)
|
||||||
|
local geometry = self:geometry()
|
||||||
geometry['x'] = geometry['x'] + x
|
geometry['x'] = geometry['x'] + x
|
||||||
geometry['y'] = geometry['y'] + y
|
geometry['y'] = geometry['y'] + y
|
||||||
geometry['width'] = geometry['width'] + w
|
geometry['width'] = geometry['width'] + w
|
||||||
geometry['height'] = geometry['height'] + h
|
geometry['height'] = geometry['height'] + h
|
||||||
sel:geometry(geometry)
|
self:geometry(geometry)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Move a client to a tag.
|
--- Move a client to a tag.
|
||||||
|
-- @deprecated awful.client.movetotag
|
||||||
-- @param target The tag to move the client to.
|
-- @param target The tag to move the client to.
|
||||||
-- @client[opt] c The client to move, otherwise the focused one is used.
|
-- @client[opt] c The client to move, otherwise the focused one is used.
|
||||||
|
-- @see client.move_to_tag
|
||||||
function client.movetotag(target, c)
|
function client.movetotag(target, c)
|
||||||
local sel = c or capi.client.focus
|
util.deprecate "Use c:move_to_tag(target) instead of awful.client.movetotag"
|
||||||
|
client.object.move_to_tag(c or capi.client.focus, target)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Move a client to a tag.
|
||||||
|
-- @function client.move_to_tag
|
||||||
|
-- @tparam tag target The tag to move the client to.
|
||||||
|
function client.object.move_to_tag(self, target)
|
||||||
local s = tag.getscreen(target)
|
local s = tag.getscreen(target)
|
||||||
if sel and s then
|
if self and s then
|
||||||
if sel == capi.client.focus then
|
if self == capi.client.focus then
|
||||||
sel:emit_signal("request::activate", "client.movetotag", {raise=true})
|
self:emit_signal("request::activate", "client.movetotag", {raise=true})
|
||||||
end
|
end
|
||||||
-- Set client on the same screen as the tag.
|
-- Set client on the same screen as the tag.
|
||||||
sel.screen = s
|
self.screen = s
|
||||||
sel:tags({ target })
|
self:tags({ target })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggle a tag on a client.
|
--- Toggle a tag on a client.
|
||||||
|
-- @deprecated awful.client.toggletag
|
||||||
-- @param target The tag to toggle.
|
-- @param target The tag to toggle.
|
||||||
-- @client[opt] c The client to toggle, otherwise the focused one is used.
|
-- @client[opt] c The client to toggle, otherwise the focused one is used.
|
||||||
|
-- @see client.toggle_tag
|
||||||
function client.toggletag(target, c)
|
function client.toggletag(target, c)
|
||||||
local sel = c or capi.client.focus
|
util.deprecate "Use c:toggle_tag(target) instead of awful.client.toggletag"
|
||||||
|
client.object.toggle_tag(c or capi.client.focus, target)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Toggle a tag on a client.
|
||||||
|
-- @function client.toggle_tag
|
||||||
|
-- @tparam tag target The tag to move the client to.
|
||||||
|
function client.object.toggle_tag(self, target)
|
||||||
-- Check that tag and client screen are identical
|
-- Check that tag and client screen are identical
|
||||||
if sel and get_screen(sel.screen) == get_screen(tag.getscreen(target)) then
|
if self and get_screen(self.screen) == get_screen(tag.getscreen(target)) then
|
||||||
local tags = sel:tags()
|
local tags = self:tags()
|
||||||
local index = nil;
|
local index = nil;
|
||||||
for i, v in ipairs(tags) do
|
for i, v in ipairs(tags) do
|
||||||
if v == target then
|
if v == target then
|
||||||
|
@ -348,32 +395,44 @@ function client.toggletag(target, c)
|
||||||
else
|
else
|
||||||
tags[#tags + 1] = target
|
tags[#tags + 1] = target
|
||||||
end
|
end
|
||||||
sel:tags(tags)
|
self:tags(tags)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Move a client to a screen. Default is next screen, cycling.
|
--- Move a client to a screen. Default is next screen, cycling.
|
||||||
|
-- @deprecated awful.client.movetoscreen
|
||||||
-- @client c The client to move.
|
-- @client c The client to move.
|
||||||
-- @param s The screen, default to current + 1.
|
-- @param s The screen, default to current + 1.
|
||||||
-- @see screen
|
-- @see screen
|
||||||
|
-- @see client.move_to_screen
|
||||||
function client.movetoscreen(c, s)
|
function client.movetoscreen(c, s)
|
||||||
local sel = c or capi.client.focus
|
util.deprecate "Use c:move_to_screen(s) instead of awful.client.movetoscreen"
|
||||||
if sel then
|
|
||||||
|
client.object.move_to_screen(c or capi.client.focus, s)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Move a client to a screen. Default is next screen, cycling.
|
||||||
|
-- @function client.move_to_screen
|
||||||
|
-- @tparam[opt=c.screen.index+1] screen s The screen, default to current + 1.
|
||||||
|
-- @see screen
|
||||||
|
-- @see request::activate
|
||||||
|
function client.object.move_to_screen(self, s)
|
||||||
|
if self then
|
||||||
local sc = capi.screen.count()
|
local sc = capi.screen.count()
|
||||||
if not s then
|
if not s then
|
||||||
s = sel.screen.index + 1
|
s = self.screen.index + 1
|
||||||
end
|
end
|
||||||
if type(s) == "number" then
|
if type(s) == "number" then
|
||||||
if s > sc then s = 1 elseif s < 1 then s = sc end
|
if s > sc then s = 1 elseif s < 1 then s = sc end
|
||||||
end
|
end
|
||||||
s = get_screen(s)
|
s = get_screen(s)
|
||||||
if get_screen(sel.screen) ~= s then
|
if get_screen(self.screen) ~= s then
|
||||||
local sel_is_focused = sel == capi.client.focus
|
local sel_is_focused = self == capi.client.focus
|
||||||
sel.screen = s
|
self.screen = s
|
||||||
screen.focus(s)
|
screen.focus(s)
|
||||||
|
|
||||||
if sel_is_focused then
|
if sel_is_focused then
|
||||||
sel:emit_signal("request::activate", "client.movetoscreen",
|
self:emit_signal("request::activate", "client.movetoscreen",
|
||||||
{raise=true})
|
{raise=true})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -951,12 +1010,26 @@ function client.run_or_raise(cmd, matcher, merge)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a matching transient_for client (if any).
|
--- Get a matching transient_for client (if any).
|
||||||
|
-- @deprecated awful.client.get_transient_for_matching
|
||||||
|
-- @see client.get_transient_for_matching
|
||||||
-- @client c The client.
|
-- @client c The client.
|
||||||
-- @tparam function matcher A function that should return true, if
|
-- @tparam function matcher A function that should return true, if
|
||||||
-- a matching parent client is found.
|
-- a matching parent client is found.
|
||||||
-- @treturn client.client|nil The matching parent client or nil.
|
-- @treturn client.client|nil The matching parent client or nil.
|
||||||
function client.get_transient_for_matching(c, matcher)
|
function client.get_transient_for_matching(c, matcher)
|
||||||
local tc = c.transient_for
|
util.deprecate ("Use c:get_transient_for_matching(matcher) instead of"..
|
||||||
|
"awful.client.get_transient_for_matching")
|
||||||
|
|
||||||
|
return client.object.get_transient_for_matching(c, matcher)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a matching transient_for client (if any).
|
||||||
|
-- @function client.get_transient_for_matching
|
||||||
|
-- @tparam function matcher A function that should return true, if
|
||||||
|
-- a matching parent client is found.
|
||||||
|
-- @treturn client.client|nil The matching parent client or nil.
|
||||||
|
function client.object.get_transient_for_matching(self, matcher)
|
||||||
|
local tc = self.transient_for
|
||||||
while tc do
|
while tc do
|
||||||
if matcher(tc) then
|
if matcher(tc) then
|
||||||
return tc
|
return tc
|
||||||
|
@ -967,11 +1040,24 @@ function client.get_transient_for_matching(c, matcher)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Is a client transient for another one?
|
--- Is a client transient for another one?
|
||||||
|
-- @deprecated awful.client.is_transient_for
|
||||||
|
-- @see client.is_transient_for
|
||||||
-- @client c The child client (having transient_for).
|
-- @client c The child client (having transient_for).
|
||||||
-- @client c2 The parent client to check.
|
-- @client c2 The parent client to check.
|
||||||
-- @treturn client.client|nil The parent client or nil.
|
-- @treturn client.client|nil The parent client or nil.
|
||||||
function client.is_transient_for(c, c2)
|
function client.is_transient_for(c, c2)
|
||||||
local tc = c
|
util.deprecate ("Use c:is_transient_for(c2) instead of"..
|
||||||
|
"awful.client.is_transient_for")
|
||||||
|
|
||||||
|
return client.object.is_transient_for(c, c2)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Is a client transient for another one?
|
||||||
|
-- @function client.is_transient_for
|
||||||
|
-- @client c2 The parent client to check.
|
||||||
|
-- @treturn client.client|nil The parent client or nil.
|
||||||
|
function client.object.is_transient_for(self, c2)
|
||||||
|
local tc = self
|
||||||
while tc.transient_for do
|
while tc.transient_for do
|
||||||
if tc.transient_for == c2 then
|
if tc.transient_for == c2 then
|
||||||
return tc
|
return tc
|
||||||
|
|
|
@ -239,11 +239,11 @@ function mouse.client.dragtotag.border(c)
|
||||||
end
|
end
|
||||||
if _mouse.x > wa.x + wa.width - 10 then
|
if _mouse.x > wa.x + wa.width - 10 then
|
||||||
local newtag = tags[util.cycle(#tags, idx + 1)]
|
local newtag = tags[util.cycle(#tags, idx + 1)]
|
||||||
aclient.movetotag(newtag, c)
|
c:move_to_tag(newtag)
|
||||||
tag.viewnext()
|
tag.viewnext()
|
||||||
elseif _mouse.x < wa.x + 10 then
|
elseif _mouse.x < wa.x + 10 then
|
||||||
local newtag = tags[util.cycle(#tags, idx - 1)]
|
local newtag = tags[util.cycle(#tags, idx - 1)]
|
||||||
aclient.movetotag(newtag, c)
|
c:move_to_tag(newtag)
|
||||||
tag.viewprev()
|
tag.viewprev()
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue