Merge pull request #2910 from xinhaoyuan/pr-ewmh-merge_maximization

fix ewmh.merge_maximization
This commit is contained in:
mergify[bot] 2019-10-18 16:41:18 +00:00 committed by GitHub
commit f6f5b461e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 9 deletions

View File

@ -38,6 +38,7 @@ addons:
- dbus-x11
- xterm
- xdotool
- wmctrl
- xterm
- xvfb
- zsh

View File

@ -106,6 +106,8 @@ Additionally, the following optional dependencies exist:
pretty-printing of X11 errors
- [libRSVG](https://wiki.gnome.org/action/show/Projects/LibRsvg) for displaying
SVG files without scaling artifacts
- [wmctrl](http://tripie.sweb.cz/utils/wmctrl) for testing WM interactions
with external actions.
## Running Awesome

View File

@ -353,14 +353,37 @@ function ewmh.merge_maximization(c, context, hints)
if not c._delay_maximization then
c._delay_maximization = function()
-- This ignores unlikely corner cases like mismatching toggles.
-- That's likely to be an accident anyway.
if c._delayed_max_h and c._delayed_max_v then
c.maximized = c._delayed_max_h or c._delayed_max_v
elseif c._delayed_max_h then
c.maximized_horizontal = c._delayed_max_h
elseif c._delayed_max_v then
c.maximized_vertical = c._delayed_max_v
-- Computes the actual X11 atoms before/after
local before_max_h = c.maximized or c.maximized_horizontal
local before_max_v = c.maximized or c.maximized_vertical
local after_max_h, after_max_v
if c._delayed_max_h ~= nil then
after_max_h = c._delayed_max_h
else
after_max_h = before_max_h
end
if c._delayed_max_v ~= nil then
after_max_v = c._delayed_max_v
else
after_max_v = before_max_v
end
-- Interprets the client's intention based on the client's view
if after_max_h and after_max_v then
c.maximized = true
elseif before_max_h and before_max_v then
-- At this point, c.maximized must be true, and the client is
-- trying to unmaximize the window, and potentially partial
-- maximized the window
c.maximized = false
if after_max_h ~= after_max_v then
c.maximized_horizontal = after_max_h
c.maximized_vertical = after_max_v
end
else
-- At this point, c.maximized must be false, and the client is
-- not trying to fully maximize the window
c.maximized_horizontal = after_max_h
c.maximized_vertical = after_max_v
end
end
@ -383,7 +406,7 @@ function ewmh.merge_maximization(c, context, hints)
if hints.toggle and c["_delayed_max_"..suffix] ~= nil then
return not c["_delayed_max_"..suffix]
elseif hints.toggle then
return not c["maximized_"..long_suffix]
return not (c["maximized"] or c["maximized_"..long_suffix])
else
return hints.status
end

View File

@ -40,6 +40,8 @@ local function open_window(class, title, options)
window:show_all()
if options.maximize_after then
window:maximize()
elseif options.unmaximize_after then
window:unmaximize()
end
if options.resize_after_width and options.resize_after_height then
window:resize(
@ -142,6 +144,9 @@ return function(class, title, sn_rules, callback, resize_increment, args)
if args.maximize_after then
options = options .. "maximize_after,"
end
if args.unmaximize_after then
options = options .. "unmaximize_after,"
end
if args.size then
options = table.concat {
options,

View File

@ -95,6 +95,11 @@ export GDK_SCALE=1
# No idea what this does, but it silences a warning that GTK init might print
export NO_AT_BRIDGE=1
# Enable partial maximization tests if wmctrl is found.
if command -v wmctrl >/dev/null 2>&1; then
export HAS_WMCTRL=1
fi
if [ $HEADLESS = 1 ]; then
"$XVFB" $D -noreset -screen 0 "${SIZE}x24" &
xserver_pid=$!

View File

@ -172,6 +172,82 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
})
end
-- Partial maximization tests, which depend on wmctrl as a portable way to generate external requests.
if os.getenv('HAS_WMCTRL') == '1' then
print("Added tests for partial maximization.")
gears.table.merge(steps, {
function()
if #client.get() > 0 then return end
test_client(nil,nil,nil,nil,nil,{})
return true
end,
-- Makes the window partially maximized
function()
local c = client.get()[1]
if not c then return end
c.maximized_vertical = true
return true
end,
-- Maximizes the window externally
function()
local c = client.get()[1]
assert(c.maximized_vertical)
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b add,maximized_vert,maximized_horz")
return true
end,
-- Partially unmaximizes the window externally
function()
local c = client.get()[1]
if not c.maximized then return end
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b remove,maximized_vert")
return true
end,
-- Checks if the window is properly partially maximized, then fully maximizes it back externally
function()
local c = client.get()[1]
if c.maximized then return end
assert(c.maximized_horizontal)
assert(not c.maximized_vertical)
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b add,maximized_vert")
return true
end,
-- Unmaximizes the window externally
function()
local c = client.get()[1]
if not c.maximized then return end
awful.spawn.with_shell(
"wmctrl -i -r " .. tostring(c.window) .. " -b toggle,maximized_vert,maximized_horz", false)
return true
end,
-- Checks that partial maximization is restored, then kills the client.
function()
local c = client.get()[1]
if c.maximized then return end
assert(c.maximized_horizontal)
assert(not c.maximized_vertical)
c:kill()
return true
end
})
else
print("Ignored partial maximization tests because wmctrl is not found.")
end
local counter = 0
local function geometry_handler(c, context, hints)
@ -232,6 +308,30 @@ gears.table.merge(steps, {
return true
end,
-- Maximize then unmaximize. The window state should be restored.
function()
if #client.get() > 0 then return end
test_client(nil,nil,nil,nil,nil,{maximize_before=true,unmaximize_after=true})
return true
end,
function()
local c = client.get()[1]
if not c then return end
assert(not c.maximized_horizontal)
assert(not c.maximized_vertical)
-- May need to retry
if c.maximized then return end
assert(not c.immobilized_horizontal)
assert(not c.immobilized_vertical)
c:kill()
return true
end,
function()
if #client.get() > 0 then return end