mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
Add client.object.immobilized_{horizontal,vertical} (#2066)
ewmh.client_geometry_requests: ignore immobilized clients Fixes https://github.com/awesomeWM/awesome/issues/1676. Fixes https://github.com/awesomeWM/awesome/issues/2036.
This commit is contained in:
parent
579159a8cc
commit
678ead2634
4 changed files with 108 additions and 0 deletions
|
@ -634,6 +634,40 @@ function client.object.is_fixed(c)
|
|||
return false
|
||||
end
|
||||
|
||||
--- Is the client immobilized horizontally?
|
||||
--
|
||||
-- Does the client have a fixed horizontal position and width, i.e. is it
|
||||
-- fullscreen, maximized, or horizontally maximized?
|
||||
--
|
||||
-- This property is read only.
|
||||
-- @property immobilized
|
||||
-- @param boolean The immobilized state
|
||||
-- @see maximized
|
||||
-- @see maximized_horizontal
|
||||
-- @see maximized_vertical
|
||||
-- @see fullscreen
|
||||
|
||||
function client.object.is_immobilized_horizontal(c)
|
||||
return c.fullscreen or c.maximized or c.maximized_horizontal
|
||||
end
|
||||
|
||||
--- Is the client immobilized vertically?
|
||||
--
|
||||
-- Does the client have a fixed vertical position and width, i.e. is it
|
||||
-- fullscreen, maximized, or vertically maximized?
|
||||
--
|
||||
-- This property is read only.
|
||||
-- @property immobilized
|
||||
-- @param boolean The immobilized state
|
||||
-- @see maximized
|
||||
-- @see maximized_horizontal
|
||||
-- @see maximized_vertical
|
||||
-- @see fullscreen
|
||||
|
||||
function client.object.is_immobilized_vertical(c)
|
||||
return c.fullscreen or c.maximized or c.maximized_vertical
|
||||
end
|
||||
|
||||
--- Get a client floating state.
|
||||
-- @client c A client.
|
||||
-- @see floating
|
||||
|
|
|
@ -374,6 +374,16 @@ end
|
|||
-- @tparam[opt={}] table hints The hints to pass to the handler
|
||||
function ewmh.client_geometry_requests(c, context, hints)
|
||||
if context == "ewmh" and hints then
|
||||
if c.immobilized_horizontal then
|
||||
hints = gtable.clone(hints)
|
||||
hints.x = nil
|
||||
hints.width = nil
|
||||
end
|
||||
if c.immobilized_vertical then
|
||||
hints = gtable.clone(hints)
|
||||
hints.y = nil
|
||||
hints.height = nil
|
||||
end
|
||||
c:geometry(hints)
|
||||
end
|
||||
end
|
||||
|
|
50
spec/awful/ewmh_spec.lua
Normal file
50
spec/awful/ewmh_spec.lua
Normal file
|
@ -0,0 +1,50 @@
|
|||
describe("awful.ewmh.client_geometry_requests", function()
|
||||
package.loaded["awful.client"] = {}
|
||||
package.loaded["awful.layout"] = {}
|
||||
package.loaded["awful.screen"] = {}
|
||||
package.loaded["awful.tag"] = {}
|
||||
package.loaded["gears.timer"] = {}
|
||||
_G.client = {
|
||||
connect_signal = function() end,
|
||||
get = function() return {} end,
|
||||
}
|
||||
_G.screen = {
|
||||
connect_signal = function() end,
|
||||
}
|
||||
|
||||
local ewmh = require("awful.ewmh")
|
||||
|
||||
it("removes x/y/width/height when immobilized", function()
|
||||
local c = {}
|
||||
local s = stub.new(c, "geometry")
|
||||
|
||||
ewmh.client_geometry_requests(c, "ewmh", {})
|
||||
assert.stub(s).was_called_with(c, {})
|
||||
|
||||
ewmh.client_geometry_requests(c, "ewmh", {x=0, width=400})
|
||||
assert.stub(s).was_called_with(c, {x=0, width=400})
|
||||
|
||||
c.immobilized_horizontal = true
|
||||
c.immobilized_vertical = false
|
||||
ewmh.client_geometry_requests(c, "ewmh", {x=0, width=400})
|
||||
assert.stub(s).was_called_with(c, {})
|
||||
|
||||
ewmh.client_geometry_requests(c, "ewmh", {x=0, width=400, y=0})
|
||||
assert.stub(s).was_called_with(c, {y=0})
|
||||
|
||||
c.immobilized_horizontal = true
|
||||
c.immobilized_vertical = true
|
||||
ewmh.client_geometry_requests(c, "ewmh", {x=0, width=400, y=0})
|
||||
assert.stub(s).was_called_with(c, {})
|
||||
|
||||
c.immobilized_horizontal = false
|
||||
c.immobilized_vertical = true
|
||||
local hints = {x=0, width=400, y=0}
|
||||
ewmh.client_geometry_requests(c, "ewmh", hints)
|
||||
assert.stub(s).was_called_with(c, {x=0, width=400})
|
||||
-- Table passed as argument should not have been modified.
|
||||
assert.is.same(hints, {x=0, width=400, y=0})
|
||||
end)
|
||||
end)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -38,8 +38,12 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
|
|||
assert(not c.maximized_vertical )
|
||||
assert(not c.maximized )
|
||||
assert(not c.fullscreen )
|
||||
assert(not c.immobilized_horizontal)
|
||||
assert(not c.immobilized_vertical)
|
||||
|
||||
c.maximized_horizontal = true
|
||||
assert(c.immobilized_horizontal)
|
||||
assert(not c.immobilized_vertical)
|
||||
return true
|
||||
end,
|
||||
function()
|
||||
|
@ -53,6 +57,7 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
|
|||
--assert(new_geo.width+2*c.border_width==sgeo.width) --FIXME off by 4px
|
||||
|
||||
c.maximized_horizontal = false
|
||||
assert(not c.immobilized_horizontal)
|
||||
return true
|
||||
end,
|
||||
|
||||
|
@ -102,6 +107,8 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
|
|||
local bw = c.border_width
|
||||
|
||||
assert(c.fullscreen)
|
||||
assert(c.immobilized_horizontal)
|
||||
assert(c.immobilized_vertical)
|
||||
|
||||
assert(new_geo.x==sgeo.x)
|
||||
assert(new_geo.y==sgeo.y)
|
||||
|
@ -140,6 +147,8 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
|
|||
assert(c.floating)
|
||||
assert(new_geo.x==sgeo.x)
|
||||
assert(new_geo.y==sgeo.y)
|
||||
assert(c.immobilized_horizontal)
|
||||
assert(c.immobilized_vertical)
|
||||
|
||||
c.maximized = false
|
||||
|
||||
|
@ -191,6 +200,8 @@ gears.table.merge(steps, {
|
|||
assert(not c.maximized_horizontal)
|
||||
assert(not c.maximized_vertical)
|
||||
assert(c.maximized)
|
||||
assert(c.immobilized_horizontal)
|
||||
assert(c.immobilized_vertical)
|
||||
|
||||
c:kill()
|
||||
|
||||
|
@ -214,6 +225,9 @@ gears.table.merge(steps, {
|
|||
-- It might happen in the second try
|
||||
if not c.maximized then return end
|
||||
|
||||
assert(c.immobilized_horizontal)
|
||||
assert(c.immobilized_vertical)
|
||||
|
||||
c:kill()
|
||||
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue