awful.client: Deprecate .floating.get/set

Begin to formalize the getter/setter syntax into a coherent one
This commit is contained in:
Emmanuel Lepage Vallee 2016-03-14 02:21:29 -04:00
parent 828543c838
commit 82342f055c
7 changed files with 55 additions and 25 deletions

View File

@ -41,7 +41,7 @@ do
__newindex = error -- Just to be sure in case anything ever does this __newindex = error -- Just to be sure in case anything ever does this
}) })
end end
local client = {} local client = {object={}}
-- Private data -- Private data
client.data = {} client.data = {}
@ -264,7 +264,7 @@ function client.tiled(s, stacked)
local tclients = {} local tclients = {}
-- Remove floating clients -- Remove floating clients
for _, c in pairs(clients) do for _, c in pairs(clients) do
if not client.floating.get(c) if not client.object.get_floating(c)
and not c.fullscreen and not c.fullscreen
and not c.maximized_vertical and not c.maximized_vertical
and not c.maximized_horizontal then and not c.maximized_horizontal then
@ -599,6 +599,8 @@ function client.mark(c)
end end
end end
--- Unmark a client and then call 'unmarked' hook. --- Unmark a client and then call 'unmarked' hook.
-- @client c The client to unmark, or the focused one if not specified. -- @client c The client to unmark, or the focused one if not specified.
-- @return True if the client has been unmarked. False if the client was not marked. -- @return True if the client has been unmarked. False if the client was not marked.
@ -653,9 +655,19 @@ end
--- Set a client floating state, overriding auto-detection. --- Set a client floating state, overriding auto-detection.
-- Floating client are not handled by tiling layouts. -- Floating client are not handled by tiling layouts.
-- @deprecated awful.client.floating.set
-- @client c A client. -- @client c A client.
-- @param s True or false. -- @param s True or false.
function client.floating.set(c, s) function client.floating.set(c, s)
util.deprecate "Use c.floating = true instead of awful.client.floating.set"
client.object.set_floating(c, s)
end
-- Set a client floating state, overriding auto-detection.
-- Floating client are not handled by tiling layouts.
-- @client c A client.
-- @param s True or false.
function client.object.set_floating(c, s)
c = c or capi.client.focus c = c or capi.client.focus
if c and client.property.get(c, "floating") ~= s then if c and client.property.get(c, "floating") ~= s then
client.property.set(c, "floating", s) client.property.set(c, "floating", s)
@ -668,7 +680,7 @@ function client.floating.set(c, s)
end end
local function store_floating_geometry(c) local function store_floating_geometry(c)
if client.floating.get(c) then if client.object.get_floating(c) then
client.property.set(c, "floating_geometry", c:geometry()) client.property.set(c, "floating_geometry", c:geometry())
end end
end end
@ -703,10 +715,31 @@ end
--- Get a client floating state. --- Get a client floating state.
-- @client c A client. -- @client c A client.
-- @see floating
-- @deprecated awful.client.floating.get
-- @return True or false. Note that some windows might be floating even if you -- @return True or false. Note that some windows might be floating even if you
-- did not set them manually. For example, windows with a type different than -- did not set them manually. For example, windows with a type different than
-- normal. -- normal.
function client.floating.get(c) function client.floating.get(c)
util.deprecate "Use c.floating instead of awful.client.floating.get"
return client.object.get_floating(c)
end
--- The client floating state.
-- If the client is part of the tiled layout or free floating.
--
-- Note that some windows might be floating even if you
-- did not set them manually. For example, windows with a type different than
-- normal.
--
-- **Signal:**
--
-- * *property::floating*
--
-- @property floating
-- @param boolean The floating state
function client.object.get_floating(c)
c = c or capi.client.focus c = c or capi.client.focus
if c then if c then
local value = client.property.get(c, "floating") local value = client.property.get(c, "floating")
@ -725,21 +758,20 @@ function client.floating.get(c)
end end
--- Toggle the floating state of a client between 'auto' and 'true'. --- Toggle the floating state of a client between 'auto' and 'true'.
-- Use `c.floating = not c.floating`
-- @deprecated awful.client.floating.toggle
-- @client c A client. -- @client c A client.
-- @see floating
function client.floating.toggle(c) function client.floating.toggle(c)
c = c or capi.client.focus c = c or capi.client.focus
-- If it has been set to floating -- If it has been set to floating
if client.floating.get(c) then client.object.set_floating(c, not client.object.get_floating(c))
client.floating.set(c, false)
else
client.floating.set(c, true)
end
end end
--- Remove the floating information on a client. -- Remove the floating information on a client.
-- @client c The client. -- @client c The client.
function client.floating.delete(c) function client.floating.delete(c)
client.floating.set(c, nil) client.object.set_floating(c, nil)
end end
--- Restore (=unminimize) a random client. --- Restore (=unminimize) a random client.
@ -1127,8 +1159,8 @@ client.property.persist("floating", "boolean")
-- Extend the luaobject -- Extend the luaobject
object.properties(capi.client, { object.properties(capi.client, {
getter_class = client, getter_class = client.object,
setter_class = client, setter_class = client.object,
getter_fallback = client.property.get, getter_fallback = client.property.get,
setter_fallback = client.property.set, setter_fallback = client.property.set,
}) })

View File

@ -18,7 +18,6 @@ local capi =
mouse = mouse, mouse = mouse,
mousegrabber = mousegrabber mousegrabber = mousegrabber
} }
local client = require("awful.client")
local magnifier = {} local magnifier = {}
@ -67,7 +66,7 @@ function magnifier.arrange(p)
end end
-- If focused window is not tiled, take the first one which is tiled. -- If focused window is not tiled, take the first one which is tiled.
if client.floating.get(focus) then if focus.floating then
focus = cls[1] focus = cls[1]
fidx = 1 fidx = 1
end end

View File

@ -117,7 +117,7 @@ function mouse.client.snap(c, snap, x, y, fixed_x, fixed_y)
struts['right'] = 0 struts['right'] = 0
struts['top'] = 0 struts['top'] = 0
struts['bottom'] = 0 struts['bottom'] = 0
if edge ~= "none" and aclient.floating.get(c) then if edge ~= "none" and c.floating then
if edge == "left" or edge == "right" then if edge == "left" or edge == "right" then
struts[edge] = cur_geom.width struts[edge] = cur_geom.width
elseif edge == "top" or edge == "bottom" then elseif edge == "top" or edge == "bottom" then
@ -177,7 +177,7 @@ function mouse.client.move(c, snap, finished_cb)
for _, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then if v then
local lay = layout.get(c.screen) local lay = layout.get(c.screen)
if lay == layout.suit.floating or aclient.floating.get(c) then if lay == layout.suit.floating or c.floating then
local x = _mouse.x - dist_x local x = _mouse.x - dist_x
local y = _mouse.y - dist_y local y = _mouse.y - dist_y
c:geometry(mouse.client.snap(c, snap, x, y, fixed_x, fixed_y)) c:geometry(mouse.client.snap(c, snap, x, y, fixed_x, fixed_y))
@ -195,7 +195,7 @@ function mouse.client.move(c, snap, finished_cb)
end end
if layout.get(c.screen) ~= layout.suit.floating then if layout.get(c.screen) ~= layout.suit.floating then
local c_u_m = mouse.client_under_pointer() local c_u_m = mouse.client_under_pointer()
if c_u_m and not aclient.floating.get(c_u_m) then if c_u_m and not c_u_m.floating then
if c_u_m ~= c then if c_u_m ~= c then
c:swap(c_u_m) c:swap(c_u_m)
end end
@ -356,7 +356,7 @@ function mouse.client.resize(c, corner)
local lay = layout.get(c.screen) local lay = layout.get(c.screen)
local corner2, x, y = mouse.client.corner(c, corner) local corner2, x, y = mouse.client.corner(c, corner)
if lay == layout.suit.floating or aclient.floating.get(c) then if lay == layout.suit.floating or c.floating then
return layout.suit.floating.mouse_resize_handler(c, corner2, x, y) return layout.suit.floating.mouse_resize_handler(c, corner2, x, y)
elseif lay.mouse_resize_handler then elseif lay.mouse_resize_handler then
return lay.mouse_resize_handler(c, corner2, x, y) return lay.mouse_resize_handler(c, corner2, x, y)

View File

@ -453,7 +453,7 @@ function placement.no_overlap(c)
local curlay = layout.get() local curlay = layout.get()
local areas = { screen.workarea } local areas = { screen.workarea }
for _, cl in pairs(cls) do for _, cl in pairs(cls) do
if cl ~= c and cl.type ~= "desktop" and (client.floating.get(cl) or curlay == layout.suit.floating) then if cl ~= c and cl.type ~= "desktop" and (cl.floating or curlay == layout.suit.floating) then
areas = area_remove(areas, area_common(cl)) areas = area_remove(areas, area_common(cl))
end end
end end

View File

@ -13,7 +13,6 @@ local table = table
local type = type local type = type
local ipairs = ipairs local ipairs = ipairs
local pairs = pairs local pairs = pairs
local aclient = require("awful.client")
local atag = require("awful.tag") local atag = require("awful.tag")
local rules = {} local rules = {}
@ -199,9 +198,7 @@ function rules.execute(c, props, callbacks)
if property ~= "focus" and type(value) == "function" then if property ~= "focus" and type(value) == "function" then
value = value(c) value = value(c)
end end
if property == "floating" then if property == "tag" then
aclient.floating.set(c, value)
elseif property == "tag" then
c.screen = atag.getscreen(value) c.screen = atag.getscreen(value)
c:tags({ value }) c:tags({ value })
elseif property == "switchtotag" and value and props.tag then elseif property == "switchtotag" and value and props.tag then

View File

@ -256,7 +256,7 @@ end
--- Create a new float button for a client. --- Create a new float button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.floatingbutton(c) function titlebar.widget.floatingbutton(c)
local widget = titlebar.widget.button(c, "floating", aclient.floating.get, aclient.floating.toggle) local widget = titlebar.widget.button(c, "floating", aclient.object.get_floating, aclient.floating.toggle)
c:connect_signal("property::floating", widget.update) c:connect_signal("property::floating", widget.update)
return widget return widget
end end

View File

@ -79,7 +79,7 @@ local function tasklist_label(c, args, tb)
else else
if c.maximized_horizontal then name = name .. maximized_horizontal end if c.maximized_horizontal then name = name .. maximized_horizontal end
if c.maximized_vertical then name = name .. maximized_vertical end if c.maximized_vertical then name = name .. maximized_vertical end
if client.floating.get(c) then name = name .. floating end if c.floating then name = name .. floating end
end end
end end
@ -88,6 +88,7 @@ local function tasklist_label(c, args, tb)
else else
name = name .. (util.escape(c.name) or util.escape("<untitled>")) name = name .. (util.escape(c.name) or util.escape("<untitled>"))
end end
local focused = capi.client.focus == c local focused = capi.client.focus == c
-- Handle transient_for: the first parent that does not skip the taskbar -- Handle transient_for: the first parent that does not skip the taskbar
-- is considered to be focused, if the real client has skip_taskbar. -- is considered to be focused, if the real client has skip_taskbar.
@ -98,6 +99,7 @@ local function tasklist_label(c, args, tb)
end) == c then end) == c then
focused = true focused = true
end end
if focused then if focused then
bg = bg_focus bg = bg_focus
text = text .. "<span color='"..fg_focus.."'>"..name.."</span>" text = text .. "<span color='"..fg_focus.."'>"..name.."</span>"