Merge pull request #2910 from xinhaoyuan/pr-ewmh-merge_maximization
fix ewmh.merge_maximization
This commit is contained in:
commit
f6f5b461e3
|
@ -38,6 +38,7 @@ addons:
|
||||||
- dbus-x11
|
- dbus-x11
|
||||||
- xterm
|
- xterm
|
||||||
- xdotool
|
- xdotool
|
||||||
|
- wmctrl
|
||||||
- xterm
|
- xterm
|
||||||
- xvfb
|
- xvfb
|
||||||
- zsh
|
- zsh
|
||||||
|
|
|
@ -106,6 +106,8 @@ Additionally, the following optional dependencies exist:
|
||||||
pretty-printing of X11 errors
|
pretty-printing of X11 errors
|
||||||
- [libRSVG](https://wiki.gnome.org/action/show/Projects/LibRsvg) for displaying
|
- [libRSVG](https://wiki.gnome.org/action/show/Projects/LibRsvg) for displaying
|
||||||
SVG files without scaling artifacts
|
SVG files without scaling artifacts
|
||||||
|
- [wmctrl](http://tripie.sweb.cz/utils/wmctrl) for testing WM interactions
|
||||||
|
with external actions.
|
||||||
|
|
||||||
## Running Awesome
|
## Running Awesome
|
||||||
|
|
||||||
|
|
|
@ -353,14 +353,37 @@ function ewmh.merge_maximization(c, context, hints)
|
||||||
|
|
||||||
if not c._delay_maximization then
|
if not c._delay_maximization then
|
||||||
c._delay_maximization = function()
|
c._delay_maximization = function()
|
||||||
-- This ignores unlikely corner cases like mismatching toggles.
|
-- Computes the actual X11 atoms before/after
|
||||||
-- That's likely to be an accident anyway.
|
local before_max_h = c.maximized or c.maximized_horizontal
|
||||||
if c._delayed_max_h and c._delayed_max_v then
|
local before_max_v = c.maximized or c.maximized_vertical
|
||||||
c.maximized = c._delayed_max_h or c._delayed_max_v
|
local after_max_h, after_max_v
|
||||||
elseif c._delayed_max_h then
|
if c._delayed_max_h ~= nil then
|
||||||
c.maximized_horizontal = c._delayed_max_h
|
after_max_h = c._delayed_max_h
|
||||||
elseif c._delayed_max_v then
|
else
|
||||||
c.maximized_vertical = c._delayed_max_v
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -383,7 +406,7 @@ function ewmh.merge_maximization(c, context, hints)
|
||||||
if hints.toggle and c["_delayed_max_"..suffix] ~= nil then
|
if hints.toggle and c["_delayed_max_"..suffix] ~= nil then
|
||||||
return not c["_delayed_max_"..suffix]
|
return not c["_delayed_max_"..suffix]
|
||||||
elseif hints.toggle then
|
elseif hints.toggle then
|
||||||
return not c["maximized_"..long_suffix]
|
return not (c["maximized"] or c["maximized_"..long_suffix])
|
||||||
else
|
else
|
||||||
return hints.status
|
return hints.status
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,8 @@ local function open_window(class, title, options)
|
||||||
window:show_all()
|
window:show_all()
|
||||||
if options.maximize_after then
|
if options.maximize_after then
|
||||||
window:maximize()
|
window:maximize()
|
||||||
|
elseif options.unmaximize_after then
|
||||||
|
window:unmaximize()
|
||||||
end
|
end
|
||||||
if options.resize_after_width and options.resize_after_height then
|
if options.resize_after_width and options.resize_after_height then
|
||||||
window:resize(
|
window:resize(
|
||||||
|
@ -142,6 +144,9 @@ return function(class, title, sn_rules, callback, resize_increment, args)
|
||||||
if args.maximize_after then
|
if args.maximize_after then
|
||||||
options = options .. "maximize_after,"
|
options = options .. "maximize_after,"
|
||||||
end
|
end
|
||||||
|
if args.unmaximize_after then
|
||||||
|
options = options .. "unmaximize_after,"
|
||||||
|
end
|
||||||
if args.size then
|
if args.size then
|
||||||
options = table.concat {
|
options = table.concat {
|
||||||
options,
|
options,
|
||||||
|
|
|
@ -95,6 +95,11 @@ export GDK_SCALE=1
|
||||||
# No idea what this does, but it silences a warning that GTK init might print
|
# No idea what this does, but it silences a warning that GTK init might print
|
||||||
export NO_AT_BRIDGE=1
|
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
|
if [ $HEADLESS = 1 ]; then
|
||||||
"$XVFB" $D -noreset -screen 0 "${SIZE}x24" &
|
"$XVFB" $D -noreset -screen 0 "${SIZE}x24" &
|
||||||
xserver_pid=$!
|
xserver_pid=$!
|
||||||
|
|
|
@ -172,6 +172,82 @@ for _, gravity in ipairs { "NORTH_WEST", "NORTH", "NORTH_EAST", "WEST",
|
||||||
})
|
})
|
||||||
end
|
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 counter = 0
|
||||||
|
|
||||||
local function geometry_handler(c, context, hints)
|
local function geometry_handler(c, context, hints)
|
||||||
|
@ -232,6 +308,30 @@ gears.table.merge(steps, {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end,
|
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()
|
function()
|
||||||
if #client.get() > 0 then return end
|
if #client.get() > 0 then return end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue