rubywm/floating.rb

29 lines
671 B
Ruby
Raw Permalink Normal View History

2024-01-23 18:56:53 +01:00
#
# Apart from the very limited "place" the main purpose of this
# class is to ensure there *always* is a layout
require_relative 'layout'
class FloatingLayout < Layout
2024-01-23 18:56:53 +01:00
def initialize(rootgeom)
@rootgeom = rootgeom
end
def find(w) = nil
def place(w, focus)
attr = w.get_geometry
return if attr.is_a?(X11::Form::Error)
x = attr.x
y = attr.y
width = attr.width
height = attr.height
width = @rootgeom.width / 2 if width < 10
height = @rootgeom.height - 100 if height < 10
x = (@rootgeom.width - width) /2 if x == 0
y = (@rootgeom.height - height)/2 if y == 0
w.configure(x:, y:, width:, height:)
end
end