some awesome changes, not complete

This commit is contained in:
frosty 2024-05-27 06:39:06 -04:00
parent d254a204f8
commit 66127c8b73
5 changed files with 130 additions and 30 deletions

View file

@ -145,10 +145,15 @@ local client_buttons = gears.table.join(
end),
awful.button({ "Mod4" }, 1, function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
c.floating = true
awful.mouse.client.move(c)
end),
awful.button({ "Mod4" }, 2, function(c)
c.floating = not c.floating
end),
awful.button({ "Mod4" }, 3, function(c)
c:emit_signal("request::activate", "mouse_click", { raise = true })
c.floating = true
awful.mouse.client.resize(c, config.resize_corner)
end)
)

View file

@ -1,5 +1,7 @@
local awful = require("awful")
local floating = require("floating")
local config = {}
-- Default programs
@ -15,7 +17,7 @@ config.theme_name = "default"
config.layouts = {
awful.layout.suit.tile,
awful.layout.suit.max,
awful.layout.suit.floating,
floating,
}
config.default_layout = 1 -- Index of layout (1-indexed)

View file

@ -0,0 +1,99 @@
local ipairs = ipairs
local capi = { mouse = mouse, mousegrabber = mousegrabber }
local floating = {}
function floating.mouse_resize_handler(c, corner, x, y)
local g = c:geometry()
-- Do not allow maximized clients to be resized by mouse
local fixed_x = c.maximized_horizontal
local fixed_y = c.maximized_vertical
local prev_coords = {}
local coordinates_delta = {x=0, y=0}
local corner_x, corner_y = x, y
local mouse_coords = capi.mouse.coords()
x = mouse_coords.x
y = mouse_coords.y
coordinates_delta = {x = corner_x-x,y = corner_y-y}
capi.mousegrabber.run(function(state)
if not c.valid then return false end
state.x = state.x + coordinates_delta.x
state.y = state.y + coordinates_delta.y
for _, v in ipairs(state.buttons) do
if v then
local ng
prev_coords = { x = state.x, y = state.y }
if corner == "bottom_right" then
ng = {
width = state.x - g.x,
height = state.y - g.y
}
elseif corner == "bottom_left" then
ng = {
x = state.x,
width = (g.x + g.width) - state.x,
height = state.y - g.y
}
elseif corner == "top_left" then
ng = {
x = state.x,
width = (g.x + g.width) - state.x,
y = state.y,
height = (g.y + g.height) - state.y
}
else
ng = {
width = state.x - g.x,
y = state.y,
height = (g.y + g.height) - state.y
}
end
if ng.width <= 0 then ng.width = nil end
if ng.height <= 0 then ng.height = nil end
if fixed_x then ng.width = g.width ng.x = g.x end
if fixed_y then ng.height = g.height ng.y = g.y end
c:geometry(ng)
local rg = c:geometry()
if corner == "bottom_right" then
ng = {}
elseif corner == "bottom_left" then
ng = {
x = (g.x + g.width) - rg.width
}
elseif corner == "top_left" then
ng = {
x = (g.x + g.width) - rg.width,
y = (g.y + g.height) - rg.height
}
else
ng = {
y = (g.y + g.height) - rg.height
}
end
c:geometry({ x = ng.x, y = ng.y })
return true
end
end
return prev_coords.x == state.x and prev_coords.y == state.y
end, corner .. "_corner")
end
function floating.arrange()
end
floating.name = "floating"
return floating

View file

@ -1,3 +1,4 @@
local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful")
@ -10,14 +11,20 @@ screen.connect_signal("property::geometry", function(s)
end
end)
-- Ensure client is on screen
-- Attach client to top of the slaves and ensure client is on screen
client.connect_signal("manage", function(c)
if not awesome.startup then utils.attach_top(c) end
if awesome.startup
and not c.size_hints.user_position
and not c.size_hints.program_position
then
awful.placement.no_offscreen(c)
end
if c.floating then
c.ontop = true
end
end)
-- Use sloppy focus for clients
@ -26,24 +33,7 @@ client.connect_signal("mouse::enter", function(c)
end)
-- Set border color based on focus status
client.connect_signal("focus", function(c)
if tag_only_has_floating() then
awful.client.focus.byidx(1)
else
t = 0
repeat
awful.client.focus.byidx(-1)
t = t + 1
until not client.focus.floating or t > 5
end
c.border_color = beautiful.border_focus
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
client.connect_signal("unminimize", function(c) c.unminize() end)
client.connect_signal("manage", function (c)
if c.floating then
c.ontop = true
end
end)
client.connect_signal("minimize", function(c) c.unminize() end)

View file

@ -1,12 +1,16 @@
local awful = require("awful")
function tag_only_has_floating()
local tag = awful.screen.focused().selected_tag
local clients = tag:clients()
for _, c in ipairs(clients) do
if not c.floating then
return false
end
end
return true
local utils = {}
function utils.attach_top(c)
local t = awful.tag.selected(c.screen)
local clients = t:clients()
local layout = awful.tag.getproperty(t, "layout")
local nmaster = layout.master_count or 1
local index = math.min(#clients, nmaster)
c:swap(clients[index])
end
return utils