summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eventMouseClick.go16
-rw-r--r--init.go3
-rw-r--r--libnotify.go45
-rw-r--r--structs.go9
4 files changed, 51 insertions, 22 deletions
diff --git a/eventMouseClick.go b/eventMouseClick.go
index 4229964..03e7180 100644
--- a/eventMouseClick.go
+++ b/eventMouseClick.go
@@ -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
}
diff --git a/init.go b/init.go
index 5153c12..3580116 100644
--- a/init.go
+++ b/init.go
@@ -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
diff --git a/libnotify.go b/libnotify.go
index 9658ad2..487c429 100644
--- a/libnotify.go
+++ b/libnotify.go
@@ -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,6 +240,30 @@ func hardDrawAtgocuiSize(tk *guiWidget) {
log.Verbose("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name())
}
+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
+ w, h := me.baseGui.Size()
+ a := -1
+ b := -1
+ c := w + 1
+ d := h + 1
+ var err error
+ tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
+ if err == nil {
+ tk.dumpWidget("drawView() err")
+ log.Log(ERROR, "drawView() internal plugin error err = nil")
+ return
+ }
+ 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 {
@@ -246,19 +273,7 @@ func setBottomBG() {
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
- c := w + 1
- d := h + 1
- var err error
- tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
- if err == nil {
- tk.dumpWidget("drawView() err")
- log.Log(ERROR, "drawView() internal plugin error err = nil")
- return
- }
- log.Info("background tk View not initialized")
+ sigWinchBG()
return
}
if me.dark {
diff --git a/structs.go b/structs.go
index d3fce8e..dd9ed14 100644
--- a/structs.go
+++ b/structs.go
@@ -148,10 +148,11 @@ type internalTK struct {
// the desktop libnotify menu
type libnotify struct {
- clock internalTK // widget for the clock
- menu internalTK // libnotify menu icon
- window internalTK // the libnotify menu
- help internalTK // the help menu
+ 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
}
// this is the gocui way