From feb17d77bbe1121f743b2ca5ea5306ca72a18aec Mon Sep 17 00:00:00 2001 From: Luca CPZ Date: Fri, 20 Jul 2018 12:52:00 +0200 Subject: [PATCH] centerwork: mouse_resize_handler added; #395 --- icons/cal/black/17.png | Bin 1506 -> 1504 bytes layout/centerwork.lua | 61 +++++++++++++++++++++++++++++++++++++++- widget/contrib/task.lua | 1 - wiki | 2 +- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/icons/cal/black/17.png b/icons/cal/black/17.png index 08dc21b316d7b9dc02aa89aa1c0b40b0b9f988ea..f3fa0a997e607ce485c4d5a9cfce4a799f965f32 100644 GIT binary patch delta 659 zcmV;E0&M-_3*ZZ|@B)8%NklPeHWQd2Bo%GAI)vUd3MX|`w2=|utRX27ue;X5;J0S!d}X3Y)_;{xW)9WjgvXq-37 zFdkt3f>DRD0QCzahLHe^B8T|^((Zt!SOLxMfWAq910KNshr$Mg3V1{ZJcj*GgbjF#1w5kzp2PkZ!Ulv2cu5Dmg8i?B4G0xb zLkGNp{coi-fOo+qb#UuF06vrm@bS~3*rl~@B)8(Nkl#5G$Iykv3FxdL6oA#E|%B@ zu|ZT2#ol{oezFgdFneGY_ufo)vX*B*&B|oX`LZ998<9XJc=^O6+8EDOfCBzMKrE1n z|K2z$7Hz`jidW_+KmiI+fC3btfXV?(=AMY+3Q&LoDi=VC0u+Cs00k((7Lb@SwUBAP z*Q=(_FiLf?fSI#==g69o*JqoaJ?9h!NX~^}wIg@tnF8vH0L)(y7{&!GTr_GJ6Hvc+ zjA1;$lBHt~V*zTHg$yGBmWK{=0i^5!D$k?v^WClJ+HMbe`yK80@|HVLw9o+^060SjU;$@^4mf`Yfb(=f7WQ8dI-m&v7wG^j z;F8b*mjQ5v4!{Dg3LS6_0N3e&7TDh@bU+sXZqNZ(K)28VHvw>q4!{C#3mtF=0C(wt z9@yWTqXX^%;J&Z{SU_VH9gqS*hp+(;@E>%R4yc3uDPaQw1!U-ecG%x1Y(SuZemdYG z>>m&|AcKDeJfZ_0!~Q{G0|Es+p#z@6{%67lJjViF&;c)D|0`hw0tLLL1Kz;?x55Sl z3aF+7-ogI&QX0Sq|B@u!`UrqeB?5f@^0km}ak%xp^G6}wKXb#07$CnAafv5>kNe4T v>C!Y1c@&@k1t>rP3aCK9pCN8W0m>BxC_n*a2mA>IwLE59d$$eClX3-aXU7+1 diff --git a/layout/centerwork.lua b/layout/centerwork.lua index cb83709..bf0c0ca 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -1,6 +1,7 @@ --[[ Licensed under GNU General Public License v2 + * (c) 2018, Eugene Pakhomov * (c) 2016, Henrik Antonsson * (c) 2015, Joerg Jaspert * (c) 2014, projektile @@ -9,7 +10,7 @@ --]] -local floor, max, screen = math.floor, math.max, screen +local capi, floor, max, screen = capi, math.floor, math.max, screen local centerwork = { name = "centerwork", @@ -124,6 +125,56 @@ local function arrange(p, layout) end end +local function mouse_resize_handler(c, corner, x, y, orientation) + local wa = c.screen.workarea + local mwfact = c.screen.selected_tag.master_width_factor + local g = c:geometry() + local offset = 0 + local cursor = "cross" + + local corner_coords + + if orientation == 'vertical' then + if g.height + 15 >= wa.height then + offset = g.height * .5 + cursor = "sb_h_double_arrow" + elseif not (g.y + g.height + 15 > wa.y + wa.height) then + offset = g.height + end + corner_coords = { x = wa.x + wa.width * (1 - mwfact) / 2, y = g.y + offset } + else + if g.width + 15 >= wa.width then + offset = g.width * .5 + cursor = "sb_v_double_arrow" + elseif not (g.x + g.width + 15 > wa.x + wa.width) then + offset = g.width + end + corner_coords = { y = wa.y + wa.height * (1 - mwfact) / 2, x = g.x + offset } + end + + capi.mouse.coords(corner_coords) + + local prev_coords = {} + + capi.mousegrabber.run(function(_mouse) + if not c.valid then return false end + for _, v in ipairs(_mouse.buttons) do + if v then + prev_coords = { x = _mouse.x, y = _mouse.y } + local new_mwfact + if orientation == 'vertical' then + new_mwfact = 1 - (_mouse.x - wa.x) / wa.width * 2 + else + new_mwfact = 1 - (_mouse.y - wa.y) / wa.height * 2 + end + c.screen.selected_tag.master_width_factor = math.min(math.max(new_mwfact, 0.01), 0.99) + return true + end + end + return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y + end, cursor) +end + function centerwork.arrange(p) return arrange(p, centerwork) end @@ -132,4 +183,12 @@ function centerwork.horizontal.arrange(p) return arrange(p, centerwork.horizontal) end +function centerwork.mouse_resize_handler(c, corner, x, y) + return mouse_resize_handler(c, corner, x, y, 'vertical') +end + +function centerwork.horizontal.mouse_resize_handler(c, corner, x, y) + return mouse_resize_handler(c, corner, x, y, 'horizontal') +end + return centerwork diff --git a/widget/contrib/task.lua b/widget/contrib/task.lua index 7de1967..6c32751 100644 --- a/widget/contrib/task.lua +++ b/widget/contrib/task.lua @@ -23,7 +23,6 @@ function task.hide() end function task.show(scr) - if task.followtag then task.notification_preset.screen = awful.screen.focused() elseif scr then diff --git a/wiki b/wiki index 278c3c6..abaf929 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 278c3c6c5b670640742e4a72ea571b4d656aa9dd +Subproject commit abaf929d0f77d7a268c6390a24ad9258049e5623 -- 2.39.2