init
This commit is contained in:
commit
d2743fe41d
22 changed files with 2290 additions and 0 deletions
61
lib/ewmh.lua
Normal file
61
lib/ewmh.lua
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
-- This source code form is subject to the terms of the MPL-v2 https://mozilla.org/MPL/2.0/ --
|
||||
--* Handles Extended Window Manager Hint (https://specifications.freedesktop.org/wm-spec/latest/) stuff that doesn't really fit in Tree
|
||||
local Tree
|
||||
local X = require("x")
|
||||
local EWMH = {}
|
||||
|
||||
local pid = tonumber(io.open("/proc/self/stat"):read(8):match("%d+"))
|
||||
|
||||
--* init(str name) Sets up properties to the root and support check windows
|
||||
function EWMH.init(name)
|
||||
Tree = require("tree")
|
||||
local supported = {
|
||||
X.getAtoms(
|
||||
"_NET_SUPPORTED", "_NET_SUPPORTING_WM_CHECK", "_NET_WM_NAME", "_NET_WM_PID", "_NET_WM_WINDOW_TYPE",
|
||||
"_NET_WM_WINDOW_TYPE_DESKTOP", "_NET_WM_WINDOW_TYPE_DOCK", "_NET_WM_WINDOW_TYPE_TOOLBAR", "_NET_WM_WINDOW_TYPE_MENU",
|
||||
"_NET_WM_WINDOW_TYPE_UTILITY", "_NET_WM_WINDOW_TYPE_SPLASH", "_NET_WM_WINDOW_TYPE_DIALOG", "_NET_WM_WINDOW_TYPE_NORMAL"
|
||||
)
|
||||
}
|
||||
local supportWin = X.createWindow()
|
||||
X.setProperty(supportWin, X.getAtoms("WM_CLASS"), X.getAtoms("STRING"), 8, X.PropModeReplace, { name, name })
|
||||
X.setProperty(supportWin, X.getAtoms("_NET_WM_NAME"), X.getAtoms("UTF8_STRING"), 8, X.PropModeReplace, name)
|
||||
X.setProperty(supportWin, X.getAtoms("_NET_SUPPORTING_WM_CHECK"), X.getAtoms("WINDOW"), 32, X.PropModeReplace, supportWin)
|
||||
X.setProperty(supportWin, X.getAtoms("_NET_WM_PID"), X.getAtoms("CARDINAL"), 32, X.PropModeReplace, pid)
|
||||
X.setProperty(X.root, X.getAtoms("_NET_SUPPORTING_WM_CHECK"), X.getAtoms("WINDOW"), 32, X.PropModeReplace, supportWin)
|
||||
X.setProperty(X.root, X.getAtoms("_NET_SUPPORTED"), X.getAtoms("ATOM"), 32, X.PropModeReplace, supported)
|
||||
end
|
||||
|
||||
--* bool should shouldManage(table win) Returns a boolean on whether the WM should manage the window
|
||||
function EWMH.shouldManage(win)
|
||||
local winTypeAtom = X.getProperty(win.id, X.getAtoms("_NET_WM_WINDOW_TYPE"), 0, X.getAtoms("ATOM"))
|
||||
if not winTypeAtom then return true end
|
||||
local winType = X.getAtomNames(winTypeAtom)
|
||||
if winType == "_NET_WM_WINDOW_TYPE_DOCK" then
|
||||
local attrs = X.getWindowAttributes(win.id)
|
||||
win.winType = "dock"
|
||||
if attrs.y == 0 then
|
||||
-- print(inspect(Tree))
|
||||
local m = Tree.focusedMonitor.margins
|
||||
-- print("HHIHIHII", inspect(m))
|
||||
-- print("m", inspect(attrs))
|
||||
Tree.focusedMonitor.dockMargins = { top = attrs.height, bottom = 0, left = 0, right = 0 }
|
||||
Tree.focusedMonitor:setMargins(Tree.focusedMonitor.margins)
|
||||
end
|
||||
return false
|
||||
elseif winType == "_NET_WM_WINDOW_TYPE_SPLASH" then
|
||||
return false
|
||||
else
|
||||
win.winType = winType or "normal"
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--* bool should shouldTile(table win) Returns a boolean on whether the WM should tile the window by default
|
||||
function EWMH.shouldTile(win)
|
||||
if win.winType == "_NET_WM_WINDOW_TYPE_DIALOG" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return EWMH
|
||||
Loading…
Add table
Add a link
Reference in a new issue