fix visual offset in switcher and editor

This commit is contained in:
Xinhao Yuan 2019-07-17 23:26:09 -04:00
parent 2c1d8dc59c
commit 1942d63421
2 changed files with 16 additions and 16 deletions

View File

@ -485,8 +485,8 @@ local function create(data)
local cmd_index = #data.cmds + 1
data.cmds[cmd_index] = ""
local screen_x = screen.geometry.x
local screen_y = screen.geometry.y
local start_x = screen.workarea.x
local start_y = screen.workarea.y
local kg
local infobox = api.wibox({
@ -514,13 +514,13 @@ local function create(data)
for i, a in ipairs(closed_areas) do
local sa = shrink_area_with_gap(a, inner_gap, outer_gap)
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:clip()
cr:set_source(closed_color)
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:fill()
cr:set_source(border_color)
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:set_line_width(10.0)
cr:stroke()
cr:reset_clip()
@ -528,18 +528,18 @@ local function create(data)
for i, a in ipairs(open_areas) do
local sa = shrink_area_with_gap(a, inner_gap, outer_gap)
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:clip()
if i == #open_areas then
cr:set_source(api.gears.color(active_color))
else
cr:set_source(api.gears.color(open_color))
end
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:fill()
cr:set_source(border_color)
cr:rectangle(sa.x - screen_x, sa.y - screen_y, sa.width, sa.height)
cr:rectangle(sa.x - start_x, sa.y - start_y, sa.width, sa.height)
cr:set_line_width(10.0)
if i ~= #open_areas then
cr:set_dash({5, 5}, 0)

View File

@ -54,8 +54,8 @@ local function start(c)
local traverse_radius = api.dpi(5)
local screen = c.screen
local screen_x = screen.geometry.x
local screen_y = screen.geometry.y
local start_x = screen.workarea.x
local start_y = screen.workarea.y
local layout = api.layout.get(screen)
if c.floating or layout.machi_get_regions == nil then return end
@ -106,7 +106,7 @@ local function start(c)
local msg, ext
for i, a in ipairs(regions) do
cr:rectangle(a.x - screen_x, a.y - screen_y, a.width, a.height)
cr:rectangle(a.x - start_x, a.y - start_y, a.width, a.height)
cr:clip()
if i == c.machi_region then
@ -130,10 +130,10 @@ local function start(c)
height = height + ext.height + vpadding
end
local x_offset = a.x + a.width / 2 - screen_x
local y_offset = a.y + a.height / 2 - height / 2 + vpadding - screen_y
local x_offset = a.x + a.width / 2 - start_x
local y_offset = a.y + a.height / 2 - height / 2 + vpadding - start_y
cr:rectangle(a.x - screen_x, y_offset - vpadding - screen_y, a.width, height)
cr:rectangle(a.x - start_x, y_offset - vpadding - start_y, a.width, height)
cr:set_source(fill_color)
cr:fill()
@ -163,14 +163,14 @@ local function start(c)
-- cr:rectangle(a.x, a.y, a.width, a.height)
-- cr:fill()
cr:set_source(border_color)
cr:rectangle(a.x - screen_x, a.y - screen_y, a.width, a.height)
cr:rectangle(a.x - start_x, a.y - start_y, a.width, a.height)
cr:set_line_width(10.0)
cr:stroke()
cr:reset_clip()
end
-- show the traverse point
cr:rectangle(traverse_x - screen_x - traverse_radius, traverse_y - screen_y - traverse_radius, traverse_radius * 2, traverse_radius * 2)
cr:rectangle(traverse_x - start_x - traverse_radius, traverse_y - start_y - traverse_radius, traverse_radius * 2, traverse_radius * 2)
cr:set_source_rgba(1, 1, 1, 1)
cr:fill()
end