working on fixes for wurrkspaces in sway

This commit is contained in:
Paul Wilde 2022-07-20 10:00:23 +01:00
parent 848a48e1e5
commit 72f27e56db

View file

@ -76,21 +76,6 @@ proc switchWorkspace(workspace: string) =
discard execCmd(cmd)
showWorkspaces()
# proc getApplications(node: JsonNode): (seq[string],bool) =
# var apps: seq[string] = @[]
# var focused = false
# for item in node["nodes"].getElems():
# var name = ""
# if item["focused"].getBool():
# focused = true
# if item{"window_properties"} != nil :
# let prop = item["window_properties"]
# name = prop["class"].getStr()
# name &= " " & prop["title"].getStr()
# echo "Adding application : " & name
# apps.add(name)
# return (apps, focused)
#
proc getApplication(node: JsonNode, ws: Workspace = Workspace()): Application =
var app = Application()
let window = node["window_properties"]
@ -102,30 +87,6 @@ proc getApplication(node: JsonNode, ws: Workspace = Workspace()): Application =
#echo app.title & " " & app.class
return app
# proc findWorkspaces(node: JsonNode) =
# for channel in node["nodes"].getElems():
# case channel["type"].getStr():
# of "workspace":
# if channel["output"].getStr() == "__i3":
# continue
# let w = channel
# let apps = getApplications(channel)
# var space = Workspace(
# num: w["num"].getInt(),
# name: w["name"].getStr(),
# focused: apps[1],
# #visible: w["visible"].getBool(),
# urgent: w["urgent"].getBool(),
# output: w["output"].getStr(),
# apps: apps[0]
# )
# space.display_string = buildString(space)
# my_workspaces.add(space)
# else:
# echo "finding workspaces..."
# findWorkspaces(channel)
# return
proc newWorkspace(node: JsonNode): Workspace =
return Workspace(
num: node["num"].getInt(),
@ -146,9 +107,13 @@ proc findWorkspacesTree(node: JsonNode, parent: Workspace = Workspace()) =
if node["output"].getStr() == "__i3":
return
ws = newWorkspace(node)
echo ws
###
echo channel
if channel{"window_properties"} != nil:
#or (wayland and `something that is the same as window_properties'):
let app = getApplication(channel,ws)
echo app
if ws.name != "":
#if app.focused:
# ws.focused = true