Combine windows of one program into a counted icon, auto-hide, links open in default browser
This commit is contained in:
@@ -306,6 +306,9 @@ type appWin struct {
|
||||
title string
|
||||
icon uintptr
|
||||
exe string // full path of the program, "" when unknown
|
||||
|
||||
count int // windows combined into this icon (1 when alone)
|
||||
members []uintptr // every window behind this icon
|
||||
}
|
||||
|
||||
type alphaLevel struct {
|
||||
@@ -538,6 +541,10 @@ func activateApp(idx int) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if apps[idx].count > 1 {
|
||||
activateGroup(apps[idx])
|
||||
return
|
||||
}
|
||||
fg, _, _ := pGetForegroundWindow.Call()
|
||||
iconic, _, _ := pIsIconic.Call(h)
|
||||
switch {
|
||||
@@ -574,7 +581,7 @@ func barGap() int32 { return px(6) }
|
||||
|
||||
func positionBar(hwnd uintptr) {
|
||||
pw, ph := pillSize()
|
||||
if !customPos {
|
||||
if !customPos && !autoHide {
|
||||
sw, sh := screenSize()
|
||||
edge := uintptr(abeBottom)
|
||||
if vertical {
|
||||
@@ -590,6 +597,14 @@ func positionBar(hwnd uintptr) {
|
||||
appBar(abmSetPos, &abd)
|
||||
}
|
||||
x, y := pillPos(pw, ph)
|
||||
if autoHide && ahHidden {
|
||||
sw, sh := screenSize()
|
||||
if vertical {
|
||||
x = sw // just past the right edge
|
||||
} else {
|
||||
y = sh // just below the bottom edge
|
||||
}
|
||||
}
|
||||
pMoveWindow.Call(hwnd, uintptr(x), uintptr(y), uintptr(pw), uintptr(ph), 1)
|
||||
redraw(hwnd)
|
||||
}
|
||||
@@ -729,6 +744,9 @@ func drawAppGlyph(hdc uintptr, r rect, a appWin) {
|
||||
if a.icon != 0 {
|
||||
cx, cy := center(r)
|
||||
pDrawIconEx.Call(hdc, uintptr(cx-isz/2), uintptr(cy-isz/2), styledIcon(a.icon), uintptr(isz), uintptr(isz), 0, 0, diNormal)
|
||||
if a.count > 1 {
|
||||
drawCountBadge(hdc, cx, cy, isz, a.count)
|
||||
}
|
||||
} else if rs := []rune(a.title); len(rs) > 0 {
|
||||
pSetBkMode.Call(hdc, transparent)
|
||||
pSetTextColor.Call(hdc, rgb(245, 245, 245))
|
||||
@@ -806,7 +824,7 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
|
||||
var target uintptr
|
||||
var exe string
|
||||
if appIdx >= 0 && appIdx < len(apps) {
|
||||
target = apps[appIdx].hwnd
|
||||
target = memberHwnd(apps[appIdx])
|
||||
|
||||
title := []rune(apps[appIdx].title)
|
||||
text := string(title)
|
||||
@@ -905,8 +923,11 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
|
||||
var pt point
|
||||
pGetCursorPos.Call(uintptr(unsafe.Pointer(&pt)))
|
||||
pSetForegroundWindow.Call(hwnd)
|
||||
menuOpen = true
|
||||
cmd, _, _ := pTrackPopupMenu.Call(menu, tpmRightButton|tpmBottomAlign|tpmReturnCmd,
|
||||
uintptr(pt.X), uintptr(pt.Y), 0, hwnd, 0)
|
||||
menuOpen = false
|
||||
ahLeftAt = time.Now()
|
||||
pDestroyMenu.Call(menu)
|
||||
|
||||
sysCommands := map[uintptr]uintptr{
|
||||
@@ -989,6 +1010,10 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
|
||||
gmPoll()
|
||||
return 0
|
||||
}
|
||||
if wparam == ahTimerID {
|
||||
ahTick(hwnd)
|
||||
return 0
|
||||
}
|
||||
if wparam == previewTimerID {
|
||||
previewTick()
|
||||
return 0
|
||||
@@ -1344,7 +1369,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Register as an app bar so maximized windows stop above us.
|
||||
if customPos {
|
||||
if customPos || autoHide {
|
||||
appbarOn = false
|
||||
} else {
|
||||
abd := appBarData{Hwnd: hwnd, CallbackMsg: callbackMsg}
|
||||
@@ -1356,6 +1381,9 @@ func main() {
|
||||
refreshApps(true)
|
||||
positionBar(hwnd)
|
||||
pSetTimer.Call(hwnd, timerID, 250, 0)
|
||||
if autoHide {
|
||||
ahStart()
|
||||
}
|
||||
weatherRefresh(false) // have the forecast ready before the cloud is first clicked
|
||||
newsRefresh(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user