2008-11-25 17:01:06 +01:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 12:44:21 +02:00
|
|
|
--- Dummy function for floating layout
|
|
|
|
--
|
2008-11-25 17:01:06 +01:00
|
|
|
-- @author Gregor Best
|
|
|
|
-- @copyright 2008 Gregor Best
|
2016-12-10 02:24:22 +01:00
|
|
|
-- @module awful.layout
|
2008-11-25 17:01:06 +01:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2014-10-23 01:30:19 +02:00
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
|
|
|
local capi =
|
|
|
|
{
|
|
|
|
mouse = mouse,
|
|
|
|
mousegrabber = mousegrabber
|
|
|
|
}
|
|
|
|
|
2016-08-14 07:34:43 +02:00
|
|
|
--- The floating layout layoutbox icon.
|
|
|
|
-- @beautiful beautiful.layout_floating
|
|
|
|
-- @param surface
|
|
|
|
-- @see gears.surface
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
local floating = {}
|
2008-11-25 17:01:06 +01:00
|
|
|
|
2015-08-07 18:50:08 +02:00
|
|
|
--- Jump mouse cursor to the client's corner when resizing it.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @field awful.layout.suit.floating.resize_jump_to_corner
|
2015-08-07 18:50:08 +02:00
|
|
|
floating.resize_jump_to_corner = true
|
|
|
|
|
2014-10-23 01:30:19 +02:00
|
|
|
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
|
|
|
|
|
2015-07-13 20:52:16 +02:00
|
|
|
local prev_coords = {}
|
2022-07-03 08:10:31 +02:00
|
|
|
local coordinates_delta = {x=0, y=0}
|
|
|
|
|
2015-08-07 18:50:08 +02:00
|
|
|
if floating.resize_jump_to_corner then
|
|
|
|
-- Warp mouse pointer
|
|
|
|
capi.mouse.coords({ x = x, y = y })
|
|
|
|
else
|
|
|
|
local corner_x, corner_y = x, y
|
|
|
|
local mouse_coords = capi.mouse.coords()
|
2022-07-03 08:10:31 +02:00
|
|
|
|
2015-08-07 18:50:08 +02:00
|
|
|
x = mouse_coords.x
|
|
|
|
y = mouse_coords.y
|
2022-07-03 08:10:31 +02:00
|
|
|
coordinates_delta = {x = corner_x-x,y = corner_y-y}
|
2015-08-07 18:50:08 +02:00
|
|
|
end
|
|
|
|
|
2022-07-03 08:10:31 +02:00
|
|
|
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)
|
|
|
|
-- Get real geometry that has been applied
|
|
|
|
-- in case we honor size hints
|
|
|
|
-- XXX: This should be rewritten when size
|
|
|
|
-- hints are available from Lua.
|
|
|
|
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")
|
2014-10-23 01:30:19 +02:00
|
|
|
end
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
function floating.arrange()
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
2016-12-10 02:24:22 +01:00
|
|
|
--- The floating layout.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @clientlayout awful.layout.suit.floating
|
2021-12-21 06:54:15 +01:00
|
|
|
-- @usebeautiful beautiful.layout_floating
|
2016-12-10 02:24:22 +01:00
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
floating.name = "floating"
|
|
|
|
|
|
|
|
return floating
|
2015-12-12 17:42:33 +01:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|