From 82db5ca4bcb8936d3f53335f9ee9b47c6032ef81 Mon Sep 17 00:00:00 2001 From: demostanis Date: Sat, 14 Dec 2024 23:16:11 +0100 Subject: [PATCH] Maximize windows correctly with the new Awesome layout --- .../etc/skel/.config/awesome/clientkeys.lua | 5 +---- .../etc/skel/.config/awesome/globalkeys.lua | 1 - airootfs/etc/skel/.config/awesome/layout.lua | 17 ++++++++++++++++- airootfs/etc/skel/.config/awesome/titlebar.lua | 12 +++++++++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/airootfs/etc/skel/.config/awesome/clientkeys.lua b/airootfs/etc/skel/.config/awesome/clientkeys.lua index 4d8d30c..f18edb1 100644 --- a/airootfs/etc/skel/.config/awesome/clientkeys.lua +++ b/airootfs/etc/skel/.config/awesome/clientkeys.lua @@ -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: diff --git a/airootfs/etc/skel/.config/awesome/globalkeys.lua b/airootfs/etc/skel/.config/awesome/globalkeys.lua index f4d1778..87b3533 100644 --- a/airootfs/etc/skel/.config/awesome/globalkeys.lua +++ b/airootfs/etc/skel/.config/awesome/globalkeys.lua @@ -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), diff --git a/airootfs/etc/skel/.config/awesome/layout.lua b/airootfs/etc/skel/.config/awesome/layout.lua index 84b2d4b..f215d6f 100644 --- a/airootfs/etc/skel/.config/awesome/layout.lua +++ b/airootfs/etc/skel/.config/awesome/layout.lua @@ -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, } diff --git a/airootfs/etc/skel/.config/awesome/titlebar.lua b/airootfs/etc/skel/.config/awesome/titlebar.lua index aa7dd3b..7cd6216 100644 --- a/airootfs/etc/skel/.config/awesome/titlebar.lua +++ b/airootfs/etc/skel/.config/awesome/titlebar.lua @@ -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() @@ -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