Merge pull request #1084 from Elv13/use_screen_props

Use screen props
This commit is contained in:
Emmanuel Lepage Vallée 2016-09-11 04:40:35 -04:00 committed by GitHub
commit 39aace50e9
9 changed files with 27 additions and 15 deletions

View File

@ -27,7 +27,7 @@ local function screen_change(window)
if data[window][reqtype] then if data[window][reqtype] then
if data[window][reqtype].width then if data[window][reqtype].width then
data[window][reqtype].width = math.min(data[window][reqtype].width, data[window][reqtype].width = math.min(data[window][reqtype].width,
screen[window.screen].workarea.width) window.screen.workarea.width)
if reqtype == "maximized_horizontal" then if reqtype == "maximized_horizontal" then
local bw = window.border_width or 0 local bw = window.border_width or 0
data[window][reqtype].width = data[window][reqtype].width - 2*bw data[window][reqtype].width = data[window][reqtype].width - 2*bw
@ -35,7 +35,7 @@ local function screen_change(window)
end end
if data[window][reqtype].height then if data[window][reqtype].height then
data[window][reqtype].height = math.min(data[window][reqtype].height, data[window][reqtype].height = math.min(data[window][reqtype].height,
screen[window.screen].workarea.height) window.screen.workarea.height)
if reqtype == "maximized_vertical" then if reqtype == "maximized_vertical" then
local bw = window.border_width or 0 local bw = window.border_width or 0
data[window][reqtype].height = data[window][reqtype].height - 2*bw data[window][reqtype].height = data[window][reqtype].height - 2*bw
@ -43,7 +43,7 @@ local function screen_change(window)
end end
if data[window][reqtype].screen then if data[window][reqtype].screen then
local from = screen[data[window][reqtype].screen].workarea local from = screen[data[window][reqtype].screen].workarea
local to = screen[window.screen].workarea local to = window.screen.workarea
local new_x, new_y local new_x, new_y
if data[window][reqtype].x then if data[window][reqtype].x then
new_x = to.x + data[window][reqtype].x - from.x new_x = to.x + data[window][reqtype].x - from.x
@ -80,7 +80,7 @@ local function geometry_change(window)
-- Fix up the geometry in case this window needs to cover the whole screen. -- Fix up the geometry in case this window needs to cover the whole screen.
local bw = window.border_width or 0 local bw = window.border_width or 0
local g = screen[window.screen].workarea local g = window.screen.workarea
if window.maximized_vertical then if window.maximized_vertical then
window:geometry { height = g.height - 2*bw, y = g.y } window:geometry { height = g.height - 2*bw, y = g.y }
end end
@ -89,7 +89,7 @@ local function geometry_change(window)
end end
if window.fullscreen then if window.fullscreen then
window.border_width = 0 window.border_width = 0
window:geometry(screen[window.screen].geometry) window:geometry(window.screen.geometry)
end end
geometry_change_lock = false geometry_change_lock = false
@ -128,7 +128,7 @@ local function get_valid_tags(c, s)
local tags, new_tags = c:tags(), {} local tags, new_tags = c:tags(), {}
for _, t in ipairs(tags) do for _, t in ipairs(tags) do
if screen[s] == t.screen then if s == t.screen then
table.insert(new_tags, t) table.insert(new_tags, t)
end end
end end

View File

@ -201,8 +201,14 @@ local function group_label(group, color)
return margin return margin
end end
local function get_screen(s)
return s and capi.screen[s]
end
local function create_wibox(s, available_groups) local function create_wibox(s, available_groups)
local wa = capi.screen[s].workarea s = get_screen(s)
local wa = s.workarea
local height = (widget.height < wa.height) and widget.height or local height = (widget.height < wa.height) and widget.height or
(wa.height - widget.border_width * 2) (wa.height - widget.border_width * 2)
local width = (widget.width < wa.width) and widget.width or local width = (widget.width < wa.width) and widget.width or

View File

@ -23,7 +23,7 @@ local magnifier = {}
function magnifier.mouse_resize_handler(c, corner, x, y) function magnifier.mouse_resize_handler(c, corner, x, y)
capi.mouse.coords({ x = x, y = y }) capi.mouse.coords({ x = x, y = y })
local wa = capi.screen[c.screen].workarea local wa = c.screen.workarea
local center_x = wa.x + wa.width / 2 local center_x = wa.x + wa.width / 2
local center_y = wa.y + wa.height / 2 local center_y = wa.y + wa.height / 2
local maxdist_pow = (wa.width^2 + wa.height^2) / 4 local maxdist_pow = (wa.width^2 + wa.height^2) / 4

View File

@ -28,7 +28,7 @@ tile.resize_jump_to_corner = true
local function mouse_resize_handler(c, _, _, _, orientation) local function mouse_resize_handler(c, _, _, _, orientation)
orientation = orientation or "tile" orientation = orientation or "tile"
local wa = capi.screen[c.screen].workarea local wa = c.screen.workarea
local mwfact = c.screen.selected_tag.master_width_factor local mwfact = c.screen.selected_tag.master_width_factor
local cursor local cursor
local g = c:geometry() local g = c:geometry()

View File

@ -22,7 +22,7 @@ function module.drag_to_tag(c)
local dir = nil local dir = nil
local wa = capi.screen[c.screen].workarea local wa = c.screen.workarea
if coords.x >= wa.x + wa.width - 1 then if coords.x >= wa.x + wa.width - 1 then
capi.mouse.coords({ x = wa.x + 2 }, true) capi.mouse.coords({ x = wa.x + 2 }, true)

View File

@ -203,8 +203,8 @@ function module.snap(c, snap, x, y, fixed_x, fixed_y)
geom.x = x or geom.x geom.x = x or geom.x
geom.y = y or geom.y geom.y = y or geom.y
geom, edge = snap_inside(geom, capi.screen[c.screen].geometry, snap) geom, edge = snap_inside(geom, c.screen.geometry, snap)
geom = snap_inside(geom, capi.screen[c.screen].workarea, snap) geom = snap_inside(geom, c.screen.workarea, snap)
-- Allow certain windows to snap to the edge of the workarea. -- Allow certain windows to snap to the edge of the workarea.
-- Only allow docking to workarea for consistency/to avoid problems. -- Only allow docking to workarea for consistency/to avoid problems.

View File

@ -135,7 +135,7 @@ function screen.focus_bydirection(dir, _screen)
if sel then if sel then
local geomtbl = {} local geomtbl = {}
for s in capi.screen do for s in capi.screen do
geomtbl[s] = capi.screen[s].geometry geomtbl[s] = s.geometry
end end
local target = grect.get_in_direction(dir, geomtbl, sel.geometry) local target = grect.get_in_direction(dir, geomtbl, sel.geometry)
if target then if target then

View File

@ -21,6 +21,10 @@ end
-- Information about a pending wallpaper change, see prepare_context() -- Information about a pending wallpaper change, see prepare_context()
local pending_wallpaper = nil local pending_wallpaper = nil
local function get_screen(s)
return s and screen[s]
end
--- Prepare the needed state for setting a wallpaper. --- Prepare the needed state for setting a wallpaper.
-- This function returns a cairo context through which a wallpaper can be drawn. -- This function returns a cairo context through which a wallpaper can be drawn.
-- The context is only valid for a short time and should not be saved in a -- The context is only valid for a short time and should not be saved in a
@ -29,8 +33,10 @@ local pending_wallpaper = nil
-- @return[1] The available geometry (table with entries width and height) -- @return[1] The available geometry (table with entries width and height)
-- @return[1] A cairo context that the wallpaper should be drawn to -- @return[1] A cairo context that the wallpaper should be drawn to
function wallpaper.prepare_context(s) function wallpaper.prepare_context(s)
s = get_screen(s)
local root_width, root_height = root.size() local root_width, root_height = root.size()
local geom = s and screen[s].geometry or root_geometry() local geom = s and s.geometry or root_geometry()
local source, target, cr local source, target, cr
if not pending_wallpaper then if not pending_wallpaper then

View File

@ -415,7 +415,7 @@ function menubar.show(scr)
-- Set position and size -- Set position and size
scr = scr or awful.screen.focused() or 1 scr = scr or awful.screen.focused() or 1
scr = get_screen(scr) scr = get_screen(scr)
local scrgeom = capi.screen[scr].workarea local scrgeom = scr.workarea
local geometry = menubar.geometry local geometry = menubar.geometry
instance.geometry = {x = geometry.x or scrgeom.x, instance.geometry = {x = geometry.x or scrgeom.x,
y = geometry.y or scrgeom.y, y = geometry.y or scrgeom.y,