4 Commits
11 changed files with 2919 additions and 2507 deletions
+6 -2
View File
@@ -11,7 +11,11 @@ The real taskbar is hidden and a see-through pill takes its place. The pill is a
- Pull the far left end of the pill (the cursor turns into a double arrow) to shrink the empty space on the left. The center line stays put, and the left side stretches back out as you open more apps. Right-click and choose "Reset bar width" to go back to the mirrored look. - Pull the far left end of the pill (the cursor turns into a double arrow) to shrink the empty space on the left. The center line stays put, and the left side stretches back out as you open more apps. Right-click and choose "Reset bar width" to go back to the mirrored look.
- Right-click and choose "Switch to vertical" to stand it up and down against the right edge of the screen. - Right-click and choose "Switch to vertical" to stand it up and down against the right edge of the screen.
- Right-click an app icon for the normal window options (Restore, Move, Size, Minimize, Maximize, Close) plus Open new window and Open file location. - Right-click an app icon for the normal window options (Restore, Move, Size, Minimize, Maximize, Close) plus Open new window and Open file location.
- Drag the app icons and the Windows logo along the left row to reorder them. MirrorBar remembers the order of your apps and the logo's spot. - Windows of the same program share one icon. Four Brave windows show one Brave icon with a small red 4 in its top right corner. Click it to bring up the window you used last; click again while one of them is in front to step to the next. Hover shows a preview of the window you used last, and dragging the icon moves all of its windows together. Untick "Combine windows of the same program into one icon" in the settings window to get one icon per window again.
Tick "Hide the bar until the mouse touches the screen edge" in the settings window and the bar slides out of sight when the mouse is away from it (and stops reserving screen space, so maximized windows use the whole screen). Push the mouse against the screen edge where the bar lives (the bottom, or the right edge in vertical mode) and it comes back. It stays up while a panel, menu or preview is open.
Drag the app icons and the Windows logo along the left row to reorder them. MirrorBar remembers the order of your apps and the logo's spot.
- Drag the clock, battery, volume, wifi and hidden-icons arrow along the right row to reorder them. That order is remembered. - Drag the clock, battery, volume, wifi and hidden-icons arrow along the right row to reorder them. That order is remembered.
- Rest the mouse on an app icon for a moment and a live preview of that window pops up beside the bar (minimized windows show their icon instead). Click the preview to switch to that window. - Rest the mouse on an app icon for a moment and a live preview of that window pops up beside the bar (minimized windows show their icon instead). Click the preview to switch to that window.
- Right-click an app icon and choose "Pin to MirrorBar" to keep it on the bar. A pinned app that isn't running shows as a launcher: click it to start the program, and when its window opens it takes that spot. Pinning works for normal programs; Store apps can't be pinned. - Right-click an app icon and choose "Pin to MirrorBar" to keep it on the bar. A pinned app that isn't running shows as a launcher: click it to start the program, and when its window opens it takes that spot. Pinning works for normal programs; Store apps can't be pinned.
@@ -23,7 +27,7 @@ The real taskbar is hidden and a see-through pill takes its place. The pill is a
- Click the newspaper and a panel of local headlines opens above the bar, newest first, with the outlet and how long ago each ran. Click a headline and it opens in your default browser. It uses the same ZIP code as the weather: the ZIP code is turned into a town name and the headlines are Google News' feed for that town, so someone in 43220 gets Columbus stations and papers and someone in 46750 gets Fort Wayne and Huntington ones. The headlines are only downloaded when a ZIP code is set. Small towns have fewer stories than cities. - Click the newspaper and a panel of local headlines opens above the bar, newest first, with the outlet and how long ago each ran. Click a headline and it opens in your default browser. It uses the same ZIP code as the weather: the ZIP code is turned into a town name and the headlines are Google News' feed for that town, so someone in 43220 gets Columbus stations and papers and someone in 46750 gets Fort Wayne and Huntington ones. The headlines are only downloaded when a ZIP code is set. Small towns have fewer stories than cities.
- Click the little speech bubble and Google Messages for web opens in a small window above the bar, so you can read and answer texts without opening a browser tab. The first time, scan the QR code from the Messages app on your phone (Settings, Device pairing) and tick "Remember this computer"; after that it stays signed in. It runs Microsoft Edge in app mode (no tabs, no address bar) with its own private profile folder in `%LOCALAPPDATA%\MirrorBar\messages`, separate from your normal Edge, and goes only to messages.google.com. Once you have paired, MirrorBar quietly starts it in the background about 20 seconds after it launches, keeps the window just off the edge of the screen, and shows the unread count from the window title as a red number on the bubble. Click anywhere else and the window slides away again. Right-click the bubble and choose "Close Messages" to stop the background window and give the memory back. Messages for web only works while your phone is on and connected; that is how Google built it. `messages-titles.txt` in the MirrorBar data folder keeps the first 25 different window titles it has seen, only so the unread badge can be tuned; delete it any time. - Click the little speech bubble and Google Messages for web opens in a small window above the bar, so you can read and answer texts without opening a browser tab. The first time, scan the QR code from the Messages app on your phone (Settings, Device pairing) and tick "Remember this computer"; after that it stays signed in. It runs Microsoft Edge in app mode (no tabs, no address bar) with its own private profile folder in `%LOCALAPPDATA%\MirrorBar\messages`, separate from your normal Edge, and goes only to messages.google.com. Once you have paired, MirrorBar quietly starts it in the background about 20 seconds after it launches, keeps the window just off the edge of the screen, and shows the unread count from the window title as a red number on the bubble. Click anywhere else and the window slides away again. Right-click the bubble and choose "Close Messages" to stop the background window and give the memory back. Messages for web only works while your phone is on and connected; that is how Google built it. A link someone texts you opens in your normal default browser, not in Edge: the Messages window is started with a debugging port that only listens on this PC (127.0.0.1), and MirrorBar hands any page that is not Messages or a Google sign-in page to the default browser and closes it. `messages-titles.txt` in the MirrorBar data folder keeps the first 25 different window titles it has seen, only so the unread badge can be tuned; delete it any time.
- "Show weather on the bar", "Show local news on the bar", "Show system stats on the bar" and "Show Google Messages on the bar" in the settings window turn each feature off. The icon leaves the bar and nothing is downloaded for it; tick the box again and it comes back. - "Show weather on the bar", "Show local news on the bar", "Show system stats on the bar" and "Show Google Messages on the bar" in the settings window turn each feature off. The icon leaves the bar and nothing is downloaded for it; tick the box again and it comes back.
+102
View File
@@ -0,0 +1,102 @@
package main
// Auto-hide: the bar slides out of sight when the mouse is away from it and
// comes back when the mouse touches the screen edge where it lives.
import (
"time"
"unsafe"
)
const (
ahTimerID = 9
ahDelay = 700 * time.Millisecond
ahEdgeSlack = 24 // device-independent pixels of leeway along the edge
)
var (
autoHide bool
ahHidden bool
ahLeftAt = time.Now()
menuOpen bool // a right-click menu of the bar is showing
)
// ahStart / ahStop run the quick mouse check only while auto-hide is on.
func ahStart() { pSetTimer.Call(hwndMain, ahTimerID, 60, 0) }
func ahStop() { pKillTimer.Call(hwndMain, ahTimerID) }
// ahBusy is true while something on screen depends on the bar staying put.
func ahBusy() bool {
if wxShown || newsShown || sysShown || gmShown || dragging || dragActive || menuOpen {
return true
}
if pvHwnd != 0 {
if v, _, _ := pIsWindowVisible.Call(pvHwnd); v != 0 {
return true
}
}
return false
}
func ahTick(hwnd uintptr) {
if !autoHide {
return
}
var cp point
pGetCursorPos.Call(uintptr(unsafe.Pointer(&cp)))
sw, sh := screenSize()
pw, ph := pillSize()
x, y := pillPos(pw, ph)
slack := px(ahEdgeSlack)
if ahHidden {
var hot bool
if vertical {
hot = cp.X >= sw-2 && cp.Y >= y-slack && cp.Y <= y+ph+slack
} else {
hot = cp.Y >= sh-2 && cp.X >= x-slack && cp.X <= x+pw+slack
}
if hot {
ahHidden = false
ahLeftAt = time.Now()
positionBar(hwnd)
}
return
}
near := cp.X >= x-px(6) && cp.X <= x+pw+px(6) && cp.Y >= y-px(6) && cp.Y <= y+ph+px(6)
if near || ahBusy() {
ahLeftAt = time.Now()
return
}
if time.Since(ahLeftAt) > ahDelay {
ahHidden = true
positionBar(hwnd)
}
}
// setAutoHide is called by the settings window.
func setAutoHide(on bool) {
if autoHide == on {
return
}
autoHide = on
saveFeatures()
ahHidden = false
ahLeftAt = time.Now()
if on {
if appbarOn { // a bar that hides must not keep screen space reserved
abd := appBarData{Hwnd: hwndMain}
appBar(abmRemove, &abd)
appbarOn = false
}
ahStart()
} else {
ahStop()
if !customPos && !appbarOn {
abd := appBarData{Hwnd: hwndMain, CallbackMsg: callbackMsg}
appBar(abmNew, &abd)
appbarOn = true
}
}
positionBar(hwndMain)
}
+18 -1
View File
@@ -41,12 +41,16 @@ func loadFeatures() {
showGM = on showGM = on
case "panelfade": case "panelfade":
flyMatchBar = on flyMatchBar = on
case "group":
groupWins = on
case "autohide":
autoHide = on
} }
} }
} }
func saveFeatures() { func saveFeatures() {
s := "weather=" + b01(showWeather) + "\nnews=" + b01(showNews) + "\nsys=" + b01(showSys) + "\nmessages=" + b01(showGM) + "\npanelfade=" + b01(flyMatchBar) + "\n" s := "weather=" + b01(showWeather) + "\nnews=" + b01(showNews) + "\nsys=" + b01(showSys) + "\nmessages=" + b01(showGM) + "\npanelfade=" + b01(flyMatchBar) + "\ngroup=" + b01(groupWins) + "\nautohide=" + b01(autoHide) + "\n"
_ = os.MkdirAll(dataDir(), 0o755) _ = os.MkdirAll(dataDir(), 0o755)
_ = os.WriteFile(featuresFile(), []byte(s), 0o644) _ = os.WriteFile(featuresFile(), []byte(s), 0o644)
} }
@@ -144,3 +148,16 @@ func zipStatusText() string {
} }
return newsStatusText() return newsStatusText()
} }
// setGroupWins is called by the settings window: one icon per program, with a
// count, or one icon per window.
func setGroupWins(on bool) {
if groupWins == on {
return
}
groupWins = on
saveFeatures()
styleCacheClear()
apps = groupApps(allApps)
positionBar(hwndMain)
}
+5
View File
@@ -167,6 +167,9 @@ func gmLaunch(visible bool) bool {
exe, exe,
"--app=" + gmURL, "--app=" + gmURL,
"--user-data-dir=" + prof, "--user-data-dir=" + prof,
// lets MirrorBar send clicked links to the default browser (this PC only)
"--remote-debugging-port=" + gmDebugPort,
"--remote-debugging-address=127.0.0.1",
"--no-first-run", "--no-first-run",
"--no-default-browser-check", "--no-default-browser-check",
// keep the page awake while its window is parked off the screen // keep the page awake while its window is parked off the screen
@@ -191,6 +194,7 @@ func gmLaunch(visible bool) bool {
return false return false
} }
gmPid = pi.ProcessId gmPid = pi.ProcessId
gmStartLinkWatch()
syscall.CloseHandle(pi.Process) syscall.CloseHandle(pi.Process)
syscall.CloseHandle(pi.Thread) syscall.CloseHandle(pi.Thread)
gmLaunching = true gmLaunching = true
@@ -269,6 +273,7 @@ func gmAdopt(h uintptr) {
pSetWindowPos.Call(h, 0, 0, 0, 0, 0, gmSwpNoMove|gmSwpNoSize|gmSwpNoZOrder|swpNoActivate|gmSwpFrameChanged) pSetWindowPos.Call(h, 0, 0, 0, 0, 0, gmSwpNoMove|gmSwpNoSize|gmSwpNoZOrder|swpNoActivate|gmSwpFrameChanged)
} }
gmLaunching = false gmLaunching = false
gmStartLinkWatch()
if gmWantOpen { if gmWantOpen {
gmWantOpen = false gmWantOpen = false
gmShow() gmShow()
+88
View File
@@ -0,0 +1,88 @@
package main
// Links clicked inside Google Messages open in the Windows default browser.
//
// Edge opens a clicked link in a new Edge window of the Messages profile. To
// hand those to the default browser, the Messages window is started with a
// debugging port that listens on this PC only (127.0.0.1). A small background
// loop looks at the list of open pages, and any page that is not Messages or
// a Google sign-in page is opened with the default browser and then closed.
import (
"encoding/json"
"net/http"
"net/url"
"runtime"
"strings"
"time"
"unsafe"
)
const gmDebugPort = "9341"
var gmLinkOnce bool
type gmTarget struct {
ID string `json:"id"`
Type string `json:"type"`
URL string `json:"url"`
}
// gmOwnHost reports whether a page belongs to Messages itself (including the
// Google sign-in pages used while pairing), which must stay where they are.
func gmOwnHost(host string) bool {
host = strings.ToLower(host)
for _, ok := range []string{"messages.google.com", "accounts.google.com", "gstatic.com", "googleusercontent.com"} {
if host == ok || strings.HasSuffix(host, "."+ok) {
return true
}
}
return false
}
func gmStartLinkWatch() {
if gmLinkOnce {
return
}
gmLinkOnce = true
go func() {
defer func() { recover() }()
runtime.LockOSThread()
pCoInitializeEx.Call(0, 2)
client := &http.Client{Timeout: 1500 * time.Millisecond, Transport: &http.Transport{DisableKeepAlives: true}}
base := "http://127.0.0.1:" + gmDebugPort
for {
time.Sleep(80 * time.Millisecond)
if gmHwnd == 0 {
continue
}
resp, err := client.Get(base + "/json/list")
if err != nil {
continue
}
var ts []gmTarget
err = json.NewDecoder(resp.Body).Decode(&ts)
resp.Body.Close()
if err != nil {
continue
}
for _, t := range ts {
if t.Type != "page" {
continue
}
u, err := url.Parse(t.URL)
if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
continue
}
if gmOwnHost(u.Hostname()) {
continue
}
// close the Edge window first so it is on screen as briefly as possible
if r, err := client.Get(base + "/json/close/" + url.PathEscape(t.ID)); err == nil {
r.Body.Close()
}
pShellExecute.Call(0, uintptr(unsafe.Pointer(u16("open"))), uintptr(unsafe.Pointer(u16(t.URL))), 0, 0, 1)
}
}
}()
}
+134
View File
@@ -0,0 +1,134 @@
package main
// Combining windows: when "Combine windows of the same program" is on, all the
// open windows of one program (four Brave windows, say) share a single icon on
// the bar with a small red count in its top right corner. `allApps` is the full
// list of windows and launchers in bar order; `apps` is what the bar shows.
import (
"strconv"
"strings"
"time"
"unsafe"
)
var (
groupWins = true
allApps []appWin
winActiveAt = map[uintptr]time.Time{} // when each window was last the front one
)
// noteForeground remembers which window is in front, so a combined icon knows
// which of its windows you were using last.
func noteForeground(present map[uintptr]appWin) {
fg, _, _ := pGetForegroundWindow.Call()
if _, ok := present[fg]; ok {
winActiveAt[fg] = time.Now()
}
for h := range winActiveAt {
if _, ok := present[h]; !ok {
delete(winActiveAt, h)
}
}
}
// groupApps turns the full window list into the icons the bar shows.
func groupApps(list []appWin) []appWin {
out := make([]appWin, 0, len(list))
idx := map[string]int{}
for _, a := range list {
a.count, a.members = 1, nil
if a.hwnd == 0 {
out = append(out, a)
continue
}
a.members = []uintptr{a.hwnd}
if groupWins && a.exe != "" {
k := strings.ToLower(a.exe)
if i, ok := idx[k]; ok {
out[i].members = append(out[i].members, a.hwnd)
out[i].count++
continue
}
idx[k] = len(out)
}
out = append(out, a)
}
return out
}
// memberHwnd is the window a combined icon acts on: the one used most recently.
func memberHwnd(a appWin) uintptr {
if len(a.members) <= 1 {
return a.hwnd
}
best := a.members[0]
for _, m := range a.members[1:] {
if winActiveAt[m].After(winActiveAt[best]) {
best = m
}
}
return best
}
// syncAllFromGrouped puts allApps back in step after the icons were dragged
// into a new order: each icon brings all of its windows along.
func syncAllFromGrouped() {
byHwnd := map[uintptr]appWin{}
for _, a := range allApps {
if a.hwnd != 0 {
byHwnd[a.hwnd] = a
}
}
out := make([]appWin, 0, len(allApps))
for _, g := range apps {
if g.hwnd == 0 {
g.count, g.members = 0, nil
out = append(out, g)
continue
}
for _, m := range g.members {
if w, ok := byHwnd[m]; ok {
out = append(out, w)
}
}
}
allApps = out
}
// activateGroup handles a click on a combined icon: bring up the window used
// most recently, or, if one of them is already in front, step to the next.
func activateGroup(a appWin) {
fg, _, _ := pGetForegroundWindow.Call()
target := memberHwnd(a)
for i, m := range a.members {
if m == fg {
target = a.members[(i+1)%len(a.members)]
break
}
}
if iconic, _, _ := pIsIconic.Call(target); iconic != 0 {
pShowWindow.Call(target, swRestore)
}
pSetForegroundWindow.Call(target)
}
// drawCountBadge draws the little red number in the top right corner of an icon.
func drawCountBadge(hdc uintptr, cx, cy, isz int32, n int) {
br, bg, bb := styleColor(235, 70, 70)
bx, by, rad := cx+isz/2, cy-isz/2, px(5)
circleRaw(hdc, bx, by, rad, rgb(br, bg, bb))
txt := strconv.Itoa(n)
if n > 9 {
txt = "9+"
}
f := makeFont(px(8), 700)
old, _, _ := pSelectObject.Call(hdc, f)
pSetBkMode.Call(hdc, transparent)
pSetTextColor.Call(hdc, rgb(255, 255, 255))
drawText(hdc, txt, rect{bx - rad, by - rad, bx + rad + 1, by + rad + 1})
pSelectObject.Call(hdc, old)
pDeleteObject.Call(f)
}
var _ = unsafe.Pointer(nil)
+43 -3
View File
@@ -306,6 +306,9 @@ type appWin struct {
title string title string
icon uintptr icon uintptr
exe string // full path of the program, "" when unknown 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 { type alphaLevel struct {
@@ -437,6 +440,17 @@ func setTaskbarState(owner uintptr, state uintptr) {
appBar(abmSetState, &abd) appBar(abmSetState, &abd)
} }
// keepOnTop puts the bar back in the topmost band if Windows or another program
// has knocked it out of it, which otherwise sinks it under every other window.
func keepOnTop(hwnd uintptr) {
ex, _, _ := pGetWindowLongPtr.Call(hwnd, neg(-20))
if ex&wsExTopmost != 0 {
return
}
const swpNoSize, swpNoMove = 0x0001, 0x0002
pSetWindowPos.Call(hwnd, hwndTopmost, 0, 0, 0, 0, swpNoSize|swpNoMove|swpNoActivate)
}
func hideTaskbar() { func hideTaskbar() {
tb := findTaskbar() tb := findTaskbar()
if tb == 0 { if tb == 0 {
@@ -527,6 +541,10 @@ func activateApp(idx int) {
} }
return return
} }
if apps[idx].count > 1 {
activateGroup(apps[idx])
return
}
fg, _, _ := pGetForegroundWindow.Call() fg, _, _ := pGetForegroundWindow.Call()
iconic, _, _ := pIsIconic.Call(h) iconic, _, _ := pIsIconic.Call(h)
switch { switch {
@@ -563,7 +581,7 @@ func barGap() int32 { return px(6) }
func positionBar(hwnd uintptr) { func positionBar(hwnd uintptr) {
pw, ph := pillSize() pw, ph := pillSize()
if !customPos { if !customPos && !autoHide {
sw, sh := screenSize() sw, sh := screenSize()
edge := uintptr(abeBottom) edge := uintptr(abeBottom)
if vertical { if vertical {
@@ -579,6 +597,14 @@ func positionBar(hwnd uintptr) {
appBar(abmSetPos, &abd) appBar(abmSetPos, &abd)
} }
x, y := pillPos(pw, ph) 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) pMoveWindow.Call(hwnd, uintptr(x), uintptr(y), uintptr(pw), uintptr(ph), 1)
redraw(hwnd) redraw(hwnd)
} }
@@ -718,6 +744,9 @@ func drawAppGlyph(hdc uintptr, r rect, a appWin) {
if a.icon != 0 { if a.icon != 0 {
cx, cy := center(r) 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) 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 { } else if rs := []rune(a.title); len(rs) > 0 {
pSetBkMode.Call(hdc, transparent) pSetBkMode.Call(hdc, transparent)
pSetTextColor.Call(hdc, rgb(245, 245, 245)) pSetTextColor.Call(hdc, rgb(245, 245, 245))
@@ -795,7 +824,7 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
var target uintptr var target uintptr
var exe string var exe string
if appIdx >= 0 && appIdx < len(apps) { if appIdx >= 0 && appIdx < len(apps) {
target = apps[appIdx].hwnd target = memberHwnd(apps[appIdx])
title := []rune(apps[appIdx].title) title := []rune(apps[appIdx].title)
text := string(title) text := string(title)
@@ -894,8 +923,11 @@ func showMenu(hwnd uintptr, appIdx int, trayKind int) {
var pt point var pt point
pGetCursorPos.Call(uintptr(unsafe.Pointer(&pt))) pGetCursorPos.Call(uintptr(unsafe.Pointer(&pt)))
pSetForegroundWindow.Call(hwnd) pSetForegroundWindow.Call(hwnd)
menuOpen = true
cmd, _, _ := pTrackPopupMenu.Call(menu, tpmRightButton|tpmBottomAlign|tpmReturnCmd, cmd, _, _ := pTrackPopupMenu.Call(menu, tpmRightButton|tpmBottomAlign|tpmReturnCmd,
uintptr(pt.X), uintptr(pt.Y), 0, hwnd, 0) uintptr(pt.X), uintptr(pt.Y), 0, hwnd, 0)
menuOpen = false
ahLeftAt = time.Now()
pDestroyMenu.Call(menu) pDestroyMenu.Call(menu)
sysCommands := map[uintptr]uintptr{ sysCommands := map[uintptr]uintptr{
@@ -978,11 +1010,16 @@ func wndProc(hwnd, m, wparam, lparam uintptr) (result uintptr) {
gmPoll() gmPoll()
return 0 return 0
} }
if wparam == ahTimerID {
ahTick(hwnd)
return 0
}
if wparam == previewTimerID { if wparam == previewTimerID {
previewTick() previewTick()
return 0 return 0
} }
hideTaskbar() hideTaskbar()
keepOnTop(hwnd)
tick++ tick++
changed := refreshApps(tick%16 == 0) changed := refreshApps(tick%16 == 0)
if gmTick(tick) { if gmTick(tick) {
@@ -1332,7 +1369,7 @@ func main() {
} }
// Register as an app bar so maximized windows stop above us. // Register as an app bar so maximized windows stop above us.
if customPos { if customPos || autoHide {
appbarOn = false appbarOn = false
} else { } else {
abd := appBarData{Hwnd: hwnd, CallbackMsg: callbackMsg} abd := appBarData{Hwnd: hwnd, CallbackMsg: callbackMsg}
@@ -1344,6 +1381,9 @@ func main() {
refreshApps(true) refreshApps(true)
positionBar(hwnd) positionBar(hwnd)
pSetTimer.Call(hwnd, timerID, 250, 0) pSetTimer.Call(hwnd, timerID, 250, 0)
if autoHide {
ahStart()
}
weatherRefresh(false) // have the forecast ready before the cloud is first clicked weatherRefresh(false) // have the forecast ready before the cloud is first clicked
newsRefresh(false) newsRefresh(false)
+15 -7
View File
@@ -257,8 +257,12 @@ func refreshApps(refreshIcons bool) bool {
} }
} }
present0 := make(map[uintptr]appWin, len(present))
for h, w := range present {
present0[h] = w
}
var next []appWin var next []appWin
for _, a := range apps { for _, a := range allApps {
if a.hwnd == 0 { if a.hwnd == 0 {
next = append(next, a) // a waiting launcher; sorted out below next = append(next, a) // a waiting launcher; sorted out below
continue continue
@@ -321,13 +325,17 @@ func refreshApps(refreshIcons bool) bool {
} }
} }
noteForeground(present0)
allApps = next
grouped := groupApps(next)
// Titles change constantly (browser tabs, documents) but nothing on the // Titles change constantly (browser tabs, documents) but nothing on the
// bar shows them, so only a change in which buttons exist, or their icons, // bar shows them, so only a change in which buttons exist, their icons, or
// counts as a change. // how many windows an icon stands for counts as a change.
changed := len(next) != len(apps) changed := len(grouped) != len(apps)
if !changed { if !changed {
for i := range next { for i := range grouped {
if next[i].hwnd != apps[i].hwnd || next[i].icon != apps[i].icon { if grouped[i].hwnd != apps[i].hwnd || grouped[i].icon != apps[i].icon || grouped[i].count != apps[i].count {
changed = true changed = true
break break
} }
@@ -336,7 +344,7 @@ func refreshApps(refreshIcons bool) bool {
if changed { if changed {
styleCacheClear() // icon handles can be reused by other icons styleCacheClear() // icon handles can be reused by other icons
} }
apps = next apps = grouped
return changed return changed
} }
+1
View File
@@ -330,4 +330,5 @@ func moveSeq(from, to int) {
} }
} }
apps = next apps = next
syncAllFromGrouped()
} }
+2 -1
View File
@@ -175,6 +175,7 @@ func previewShow(idx int) {
return return
} }
a := apps[idx] a := apps[idx]
a.hwnd = memberHwnd(a)
previewDropThumb() previewDropThumb()
iconic, _, _ := pIsIconic.Call(a.hwnd) iconic, _, _ := pIsIconic.Call(a.hwnd)
@@ -297,7 +298,7 @@ func previewTick() {
} }
idx = appIndexAt(hwndMain, x) idx = appIndexAt(hwndMain, x)
if idx >= 0 && idx < len(apps) { if idx >= 0 && idx < len(apps) {
raw = apps[idx].hwnd raw = memberHwnd(apps[idx])
} }
} }
target := raw target := raw
+16 -4
View File
@@ -73,6 +73,8 @@ const (
idShowSys = 215 idShowSys = 215
idPanelFade = 216 idPanelFade = 216
idShowGM = 217 idShowGM = 217
idGroup = 218
idAutoHide = 219
) )
var ( var (
@@ -84,6 +86,7 @@ var (
ctlVertical, ctlAutostart uintptr ctlVertical, ctlAutostart uintptr
ctlZip, ctlZipStatus uintptr ctlZip, ctlZipStatus uintptr
ctlShowWeather, ctlShowNews, ctlShowSys, ctlShowGM, ctlPanelFade uintptr ctlShowWeather, ctlShowNews, ctlShowSys, ctlShowGM, ctlPanelFade uintptr
ctlGroup, ctlAutoHide uintptr
zipSyncing bool // true while the program itself is filling in the ZIP box zipSyncing bool // true while the program itself is filling in the ZIP box
) )
@@ -135,7 +138,7 @@ func openSettings() {
settingsFont = makeFont(px(13), 400) settingsFont = makeFont(px(13), 400)
} }
r := rect{0, 0, px(400), px(516)} r := rect{0, 0, px(400), px(572)}
pAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(&r)), wsWindowFrame, 0, 0) pAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(&r)), wsWindowFrame, 0, 0)
ow, oh := r.Right-r.Left, r.Bottom-r.Top ow, oh := r.Right-r.Left, r.Bottom-r.Top
sw, sh := screenSize() sw, sh := screenSize()
@@ -190,9 +193,12 @@ func openSettings() {
ctlVertical = makeControl(hw, inst, "BUTTON", "Stand the bar up at the right edge (vertical)", bsAutoCheckBox|wsTabStop, 16, 402, 368, 22, idVertical) ctlVertical = makeControl(hw, inst, "BUTTON", "Stand the bar up at the right edge (vertical)", bsAutoCheckBox|wsTabStop, 16, 402, 368, 22, idVertical)
ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 430, 368, 22, idAutostart) ctlAutostart = makeControl(hw, inst, "BUTTON", "Start MirrorBar when I sign in", bsAutoCheckBox|wsTabStop, 16, 430, 368, 22, idAutostart)
makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 470, 116, 28, idResetPos) ctlGroup = makeControl(hw, inst, "BUTTON", "Combine windows of the same program into one icon", bsAutoCheckBox|wsTabStop, 16, 458, 368, 22, idGroup)
makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 470, 116, 28, idResetWidth) ctlAutoHide = makeControl(hw, inst, "BUTTON", "Hide the bar until the mouse touches the screen edge", bsAutoCheckBox|wsTabStop, 16, 486, 368, 22, idAutoHide)
makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 470, 92, 28, idClose)
makeControl(hw, inst, "BUTTON", "Reset position", bsPushButton|wsTabStop, 16, 526, 116, 28, idResetPos)
makeControl(hw, inst, "BUTTON", "Reset bar width", bsPushButton|wsTabStop, 140, 526, 116, 28, idResetWidth)
makeControl(hw, inst, "BUTTON", "Close", bsDefPushButton|wsTabStop, 292, 526, 92, 28, idClose)
hwndSettings = hw hwndSettings = hw
settingsSync() settingsSync()
@@ -218,6 +224,8 @@ func settingsSync() {
pSendMessage.Call(ctlPanelFade, bmSetCheck, boolWP(flyMatchBar), 0) pSendMessage.Call(ctlPanelFade, bmSetCheck, boolWP(flyMatchBar), 0)
pSendMessage.Call(ctlVertical, bmSetCheck, boolWP(vertical), 0) pSendMessage.Call(ctlVertical, bmSetCheck, boolWP(vertical), 0)
pSendMessage.Call(ctlAutostart, bmSetCheck, boolWP(autostartEnabled()), 0) pSendMessage.Call(ctlAutostart, bmSetCheck, boolWP(autostartEnabled()), 0)
pSendMessage.Call(ctlGroup, bmSetCheck, boolWP(groupWins), 0)
pSendMessage.Call(ctlAutoHide, bmSetCheck, boolWP(autoHide), 0)
// Leave the ZIP box alone while the person is typing in it. // Leave the ZIP box alone while the person is typing in it.
if f, _, _ := pGetFocus.Call(); f != ctlZip && zipText() != wxZip { if f, _, _ := pGetFocus.Call(); f != ctlZip && zipText() != wxZip {
@@ -324,6 +332,10 @@ func settingsCommand(id, note uintptr) {
vertical = checked(ctlVertical) vertical = checked(ctlVertical)
saveOrient() saveOrient()
resetPos(hwndMain) resetPos(hwndMain)
case idGroup:
setGroupWins(checked(ctlGroup))
case idAutoHide:
setAutoHide(checked(ctlAutoHide))
case idAutostart: case idAutostart:
setAutostart(checked(ctlAutostart)) setAutostart(checked(ctlAutostart))
settingsSync() settingsSync()