SIGWINCH works on background and libnotify widgets

This commit is contained in:
Jeff Carr 2025-03-03 22:56:05 -06:00
parent b373eab346
commit 54bbe72aa8
4 changed files with 51 additions and 22 deletions

View File

@ -46,15 +46,27 @@ func doMouseClick(w int, h int) {
log.Log(INFO, "click() check if", w, h, "is the libnotify menu")
if me.notify.menu.tk != nil && me.notify.menu.tk.gocuiSize.inRect(w, h) {
log.Log(GOCUI, "click() is libnotify menu!")
if me.notify.menu.active {
log.Info("show notify menu here")
setNotifyMenuText("[X]")
me.notify.menu.active = false
} else {
log.Info("hide notify menu here")
setNotifyMenuText("[ ]")
me.notify.menu.active = true
}
return
}
if me.notify.clock.tk != nil && me.notify.clock.tk.gocuiSize.inRect(w, h) {
log.Log(GOCUI, "click() is the clock!")
if me.showHelp {
log.Info("show help")
showHelp()
setNotifyMenuText("[X]")
} else {
log.Info("hide help")
hideHelp()
setNotifyMenuText("[ ]")
}
return
}
return
}

View File

@ -191,7 +191,8 @@ func initPlugin() {
me.notify.clock.offsetH = 1
me.notify.menu.wId = -6
me.notify.menu.offsetH = 0
me.notify.menu.offsetW = 4
me.notify.menu.offsetH = 1
me.notify.help.wId = -7
me.notify.help.offsetH = 3

View File

@ -105,12 +105,15 @@ func libNotifyUpdate() {
// check for SIGWINCH. If so, move the libnotify clock
w, h := me.baseGui.Size()
if me.winchW != w || me.winchH != h {
me.winchW = w
me.winchH = h
log.Info("handle SIGWINCH!", w, h)
me.notify.clock.tk.MoveToOffset(w-me.notify.clock.offsetW, me.notify.clock.offsetH)
me.notify.clock.tk.Hide()
me.notify.clock.tk.Show()
me.winchW = w
me.winchH = h
sigWinchBG()
sigWinchMenu()
}
// update the time
@ -237,15 +240,15 @@ func hardDrawAtgocuiSize(tk *guiWidget) {
log.Verbose("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name())
}
// find the "BG" widget and set it to the background on the very very bottom
func setBottomBG() {
if me.BG.tk == nil {
log.Info("background tk widget not initialized")
return
func sigWinchMenu() {
w, _ := me.baseGui.Size()
me.notify.menu.tk.MoveToOffset(w-me.notify.menu.offsetW, me.notify.menu.offsetH)
me.notify.menu.tk.Hide()
me.notify.menu.tk.Show()
}
func sigWinchBG() {
tk := me.BG.tk
// log.Info("found BG. setting to bottom", tk.cuiName)
if tk.v == nil {
w, h := me.baseGui.Size()
a := -1
b := -1
@ -258,7 +261,19 @@ func setBottomBG() {
log.Log(ERROR, "drawView() internal plugin error err = nil")
return
}
log.Info("background tk View not initialized")
log.Info("background resized to", a, b, c, d)
}
// find the "BG" widget and set it to the background on the very very bottom
func setBottomBG() {
if me.BG.tk == nil {
log.Info("background tk widget not initialized")
return
}
tk := me.BG.tk
// log.Info("found BG. setting to bottom", tk.cuiName)
if tk.v == nil {
sigWinchBG()
return
}
if me.dark {

View File

@ -150,6 +150,7 @@ type internalTK struct {
type libnotify struct {
clock internalTK // widget for the clock
menu internalTK // libnotify menu icon
menuWindow internalTK // libnotify menu window
window internalTK // the libnotify menu
help internalTK // the help menu
}