Skip to content

Commit

Permalink
Maximize windows correctly with the new Awesome layout
Browse files Browse the repository at this point in the history
  • Loading branch information
demostanis committed Dec 14, 2024
1 parent 1173cce commit 82db5ca
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
5 changes: 1 addition & 4 deletions airootfs/etc/skel/.config/awesome/clientkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ return gears.table.join(
awful.key({ modkey }, "q", function(c) c:kill() end),
awful.key({ modkey }, "o", function(c) c:move_to_screen() end),
awful.key({ modkey }, "m", function(c) c.minimized = true end),
awful.key({ modkey }, "w", function(c)
c.maximized = not c.maximized
c:raise()
end)
awful.key({ modkey }, "w", function(c) layout.maximize(c) end)
)

-- vim:set et sw=4 ts=4:
1 change: 0 additions & 1 deletion airootfs/etc/skel/.config/awesome/globalkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ local globalkeys = gears.table.join(
awful.key({ modkey }, "k", require"screenlock", nil),
awful.key({ modkey }, "o", require"overview", nil),
awful.key({ modkey }, "space", require"applauncher", nil),
awful.key({ modkey }, "u", function() awful.spawn("nemo /home/demostanis/programming/subjects") end, nil),
-- God, why is it trying to call some on_release when I don't specify nil??
awful.key({ modkey }, "e", require"emojipicker", nil),

Expand Down
17 changes: 16 additions & 1 deletion airootfs/etc/skel/.config/awesome/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,30 @@ function scroll.move_handler(c, context, hints)
end
end

local function maximize(c)
if c.kinda_maximized then
c.width = c.oldwidth
else
c.oldwidth = c.width
c.width = c.screen.geometry.width-100
end
c.kinda_maximized = not c.kinda_maximized
end

-- replace default client move handler
client.disconnect_signal("request::geometry", awful.layout.move_handler)
client.connect_signal("request::geometry", scroll.move_handler)

client.connect_signal("property::maximized", function(c)
-- disable since it fucks up the layout
c.maximized = false
end)

return {
move_left = move_left,
move_right = move_right,
move_left_window = move_left_window,
move_right_window = move_right_window,
cycle_window_focus = cycle_window_focus,
scroll = scroll,
scroll = scroll, maximize = maximize,
}
12 changes: 11 additions & 1 deletion airootfs/etc/skel/.config/awesome/titlebar.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
local function maximizedbutton(c)
local widget = awful.titlebar.widget.button(c, "maximized", function(cl)
return cl.kinda_maximized or false
end, function(cl, state)
layout.maximize(cl)
end)
c:connect_signal("property::kinda_maximized", widget.update)
return widget
end

return function(c)
local buttons = gears.table.join(
awful.button({ }, 1, function()
Expand Down Expand Up @@ -65,7 +75,7 @@ return function(c)
right = 2
}),
titlebar_button_with_hover_effect(wibox.widget{
awful.titlebar.widget.maximizedbutton(c),
maximizedbutton(c),
widget = wibox.container.margin,
left = 2,
right = 2
Expand Down

0 comments on commit 82db5ca

Please sign in to comment.