Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clicked button as script argument for statusbar #226

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ modifiers = [ "super" ]

# Example: Start process when region is clicked, see github wiki for what constitutes a region
# [[startProcess]]
# command = "notify-send \"Id: %1, rx: %2, cx: %4, w: %6\""
# command = "notify-send \"Id: %1, rx: %2, cx: %4, cy: %5, w: %6, b: %7\""
# clickRegion = 0

[autostart]
Expand Down
7 changes: 4 additions & 3 deletions src/nimdowpkg/config/configloader.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ proc findConfigPath*(): string =
type
KeyCombo* = tuple[keycode: int, modifiers: int]
Action* = proc(keyCombo: KeyCombo): void
RegionClickAction* = proc(idx: int, width: int, regionCord: Point[int], clickCord: Point[int]): void
RegionClickAction* = proc(idx: int, width: int, regionCord: Point[int], clickCord: Point[int], button: int): void

WindowSettings* = object
tagCount*: uint
Expand Down Expand Up @@ -308,15 +308,16 @@ proc populateExternalProcessSettings(this: Config, configTable: TomlTable, displ
closureScope:
let command = command
this.regionClickActionTable[clickRegion] =
proc(idx: int, width: int, regionCord: Point[int], clickCord: Point[int]) =
proc(idx: int, width: int, regionCord: Point[int], clickCord: Point[int], button: int) =
this.runCommandWithArgs(
command,
$idx,
$regionCord.x,
$regionCord.y,
$clickCord.x,
$clickCord.y,
$width
$width,
$button
)
else:
this.configureExternalProcess(command)
Expand Down
1 change: 1 addition & 0 deletions src/nimdowpkg/statusbar.nim
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ proc renderStringRightAligned(
while i < sgr.len:
if sgr[i] == resetCode:
color = -1
bgColor = -1
selectedFont = -1
fontErrorLogged = false
elif sgr[i] >= fontStart and sgr[i] <= fontStop:
Expand Down
3 changes: 2 additions & 1 deletion src/nimdowpkg/windowmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,8 @@ proc handleButtonPressed(this: WindowManager, e: XButtonEvent) =
clickedInfo.index,
clickedInfo.width,
clickedInfo.regionCord,
clickedInfo.clickCord
clickedInfo.clickCord,
e.button.int
)
return

Expand Down