Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64e084ddee | ||
|
|
93bd528430 | ||
|
|
e45e6eaf91 |
+115
-49
@@ -75,6 +75,23 @@ pub fn format_hashrate_ths(ths: f64) -> Option<String> {
|
||||
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
||||
}
|
||||
|
||||
/// A hashrate number (no unit) for a given mining algorithm (round 18 #7). asic-rs
|
||||
/// stores every hashrate normalised to "TH/s", but for Equihash the underlying
|
||||
/// count is Sol/s that it reinterprets through the base H unit, so `ths * 1e12`
|
||||
/// recovers the real Sol/s count. SHA256/Scrypt show the TH/s value directly
|
||||
/// ("33.5"); Equihash shows the Sol/s count with an SI prefix ("167.8K"). Pair
|
||||
/// with [`MinerRow::hashrate_unit`]. `None` for a non-positive reading.
|
||||
pub fn hashrate_num_for(algo: &str, ths: f64) -> Option<String> {
|
||||
if ths <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
if algo.eq_ignore_ascii_case("equihash") {
|
||||
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
||||
} else {
|
||||
Some(format!("{ths:.1}"))
|
||||
}
|
||||
}
|
||||
|
||||
/// The actual/expected ratio, or `None` when the expected value is unknown
|
||||
/// (<= 0.0) so a ratio-based color/warning never divides by zero or treats an
|
||||
/// unknown expectation as a 0% shortfall.
|
||||
@@ -420,6 +437,10 @@ pub struct MinerRow {
|
||||
/// = board 1). Drives the per-board Health tooltip (round 17 R2). Empty when
|
||||
/// the firmware reports no per-board hashrate.
|
||||
pub board_hashrates: Vec<f64>,
|
||||
/// Per-hashboard EXPECTED hashrate in TH/s, index-aligned with the hashboards.
|
||||
/// The per-board tooltip shows actual / expected (round 18 #3). Empty when the
|
||||
/// firmware reports no per-board expected hashrate.
|
||||
pub board_expected_hashrates: Vec<f64>,
|
||||
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
||||
pub efficiency: f64,
|
||||
pub power_w: f64,
|
||||
@@ -516,12 +537,17 @@ impl MinerRow {
|
||||
/// live); grey (unknown) otherwise -- asic-rs has no direct PSU-fault flag, so
|
||||
/// a missing wattage reading is treated as unknown, never a false "down".
|
||||
pub fn power_health(&self) -> CompHealth {
|
||||
// A reported power-supply fault (round 16 #2) is authoritative: red, even
|
||||
// if a residual wattage is still being read.
|
||||
// A miner drawing power / spinning its PSU fan / actively mining has a live
|
||||
// PSU regardless of any warning flag.
|
||||
let delivering = self.power_w > 0.0 || self.psu_fan_rpm > 0.0 || self.is_mining;
|
||||
// A reported PSU fault while the miner is actually mining is a warning, not
|
||||
// a failure -- yellow, not red (round 18 #2: some WhatsMiners flag a PSU
|
||||
// error while running fine). A fault on a miner that is not mining is a real
|
||||
// failure (red).
|
||||
if self.faults_for(FaultComponent::Power).next().is_some() {
|
||||
return CompHealth::Down;
|
||||
return if self.is_mining { CompHealth::Degraded } else { CompHealth::Down };
|
||||
}
|
||||
if self.power_w > 0.0 || self.psu_fan_rpm > 0.0 || self.is_mining {
|
||||
if delivering {
|
||||
CompHealth::Ok
|
||||
} else {
|
||||
CompHealth::Unreachable
|
||||
@@ -557,12 +583,6 @@ impl MinerRow {
|
||||
.filter(|f| f.is_error && matches!(f.component, FaultComponent::Other))
|
||||
}
|
||||
|
||||
/// True when the miner reports a power-supply fault, which means the
|
||||
/// hashboards cannot be powered or evaluated (round 16 #2).
|
||||
fn power_supply_faulted(&self) -> bool {
|
||||
self.faults_for(FaultComponent::Power).next().is_some()
|
||||
}
|
||||
|
||||
/// Per-fan health (round 13 #3), front-to-back / top-to-bottom in the order
|
||||
/// the miner reports its fans. A spinning fan is green, unless it is running
|
||||
/// well below its fastest sibling (< 50% of the max reported RPM), which is a
|
||||
@@ -621,16 +641,22 @@ impl MinerRow {
|
||||
if base.is_empty() {
|
||||
return base;
|
||||
}
|
||||
// 3. A PSU fault means no board can be powered/tested -> all grey.
|
||||
if self.power_supply_faulted() {
|
||||
return vec![CompHealth::Unreachable; base.len()];
|
||||
}
|
||||
// 2. Board-specific faults are authoritative: red only the named boards,
|
||||
// green the rest (overriding a stall-induced all-red).
|
||||
// 2. Board-specific faults are authoritative: red the named boards. A board
|
||||
// is grey ONLY when it is genuinely not detected (base Missing); a board
|
||||
// that is running stays green and a faulted board is red, even when the
|
||||
// PSU also reports a fault (round 18 #4b -- WhatsMiner codes 540/560 must
|
||||
// show red, not grey, and boards still hashing during a PSU fault stay
|
||||
// green). A whole-miner stall reds every board's base, so exonerate the
|
||||
// boards the fault codes did NOT name back to healthy.
|
||||
let board_faulted = |i: usize| self.faults_for(FaultComponent::Board(i)).next().is_some();
|
||||
if (0..base.len()).any(board_faulted) {
|
||||
for (i, h) in base.iter_mut().enumerate() {
|
||||
*h = if board_faulted(i) { CompHealth::Down } else { ok };
|
||||
if board_faulted(i) {
|
||||
*h = CompHealth::Down;
|
||||
} else if *h == CompHealth::Down {
|
||||
*h = ok; // stall-reddened but not named by the fault codes
|
||||
}
|
||||
// else keep the base (green Ok / grey Missing).
|
||||
}
|
||||
}
|
||||
base
|
||||
@@ -736,22 +762,28 @@ impl MinerRow {
|
||||
tips.push(t);
|
||||
}
|
||||
// Hashboards -- an operating board shows its number (counting DOWN, n-1..0,
|
||||
// left to right) and hashrate; a faulted board shows its error+code; a
|
||||
// board the failed PSU left untested shows "unpowered" (round 17 R2,
|
||||
// round 16 #2/#3). No generic "Hashboard N: faulted" prose.
|
||||
// left to right) and actual/expected hashrate; a faulted board shows its
|
||||
// error+code; a board that is genuinely not detected shows "not detected"
|
||||
// (round 17 R2, round 18 #3 actual/expected + #4b). No generic
|
||||
// "Hashboard N: faulted" prose.
|
||||
let boards = self.board_healths();
|
||||
let psu_down = self.power_supply_faulted();
|
||||
let n = self.hashboards.map(|v| v as usize).unwrap_or(boards.len());
|
||||
let unit = self.hashrate_unit();
|
||||
for i in 0..max_boards {
|
||||
let fault = self.fault_texts_for(FaultComponent::Board(i));
|
||||
let t = if !fault.is_empty() {
|
||||
fault.join("\n")
|
||||
} else if matches!(boards.get(i), Some(CompHealth::Unreachable)) && psu_down {
|
||||
"unpowered (PSU fault)".to_string()
|
||||
} else if matches!(boards.get(i), Some(CompHealth::Unreachable)) {
|
||||
"not detected".to_string()
|
||||
} else if i < n {
|
||||
let num = n - 1 - i; // count down, left to right
|
||||
match self.board_hashrates.get(i).copied() {
|
||||
Some(hr) if hr > 0.0 => format!("{num} \u{00b7} {hr:.1} TH/s"),
|
||||
let actual = self.board_hashrates.get(i).copied().unwrap_or(0.0);
|
||||
let expected = self.board_expected_hashrates.get(i).copied().unwrap_or(0.0);
|
||||
let a = hashrate_num_for(&self.algorithm, actual);
|
||||
let e = hashrate_num_for(&self.algorithm, expected);
|
||||
match (a, e) {
|
||||
(Some(a), Some(e)) => format!("{num} \u{00b7} {a} / {e} {unit}"),
|
||||
(Some(a), None) => format!("{num} \u{00b7} {a} {unit}"),
|
||||
_ => num.to_string(),
|
||||
}
|
||||
} else {
|
||||
@@ -773,6 +805,17 @@ impl MinerRow {
|
||||
}
|
||||
}
|
||||
|
||||
/// The display unit for this miner's hashrate, by mining algorithm (round 18
|
||||
/// #7). SHA256/Scrypt miners report TH/s; Equihash miners (Antminer Z15 /
|
||||
/// Zcash) report in Sol/s and must not be labelled TH/s.
|
||||
pub fn hashrate_unit(&self) -> &'static str {
|
||||
if self.algorithm.eq_ignore_ascii_case("equihash") {
|
||||
"Sol/s"
|
||||
} else {
|
||||
"TH/s"
|
||||
}
|
||||
}
|
||||
|
||||
/// Compact plain-text summary of component health (round 13 #3), used as the
|
||||
/// Health column's filter/sort-fallback text and the base of its hover
|
||||
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
||||
@@ -1290,20 +1333,14 @@ impl Column {
|
||||
Column::Cpu => r.cpu.clone(),
|
||||
Column::BoardCode => r.board_code.clone(),
|
||||
Column::Algorithm => r.algorithm.clone(),
|
||||
Column::Pic => {
|
||||
// A per-board PIC MCU is an Antminer hashboard property; it has no
|
||||
// meaning for WhatsMiner or any other make, which show nothing
|
||||
// rather than a "?" that implies an unanswered Antminer question.
|
||||
if !r.brand.eq_ignore_ascii_case("antminer") {
|
||||
String::new()
|
||||
} else {
|
||||
match r.pic_present {
|
||||
Some(true) => "PIC".to_string(),
|
||||
Some(false) => "noPIC".to_string(),
|
||||
None => "?".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Column::Pic => match r.pic_present {
|
||||
// A per-board PIC MCU is a known Antminer-hashboard property. Show
|
||||
// it only when known; anything unknown (non-Antminer makes, or an
|
||||
// Antminer model we can't classify) is blank, never "?" (round 18 #11).
|
||||
Some(true) => "PIC".to_string(),
|
||||
Some(false) => "noPIC".to_string(),
|
||||
None => String::new(),
|
||||
},
|
||||
Column::Locked => match r.write_locked {
|
||||
Some(true) => "locked".to_string(),
|
||||
Some(false) => "unlocked".to_string(),
|
||||
@@ -1749,22 +1786,51 @@ mod tests {
|
||||
assert!(board_tips[0].contains("Slot 0 error reading chip id."));
|
||||
assert!(!board_tips[2].contains("Slot"), "board 3 has no fault text");
|
||||
|
||||
// Round 16 #2: a power-supply fault greys every board (they can't be
|
||||
// powered/tested), turns the bolt red, and the PSU message shows on the
|
||||
// power tooltip.
|
||||
// Round 18 #2/#4b: a PSU fault while the miner is NOT mining is a real
|
||||
// failure (red bolt), and boards keep their own reported state -- a PSU
|
||||
// fault no longer greys them. Faulted boards stay red.
|
||||
let psu = MinerRow {
|
||||
power_w: 40.0,
|
||||
board_status: vec![BoardHealth::Fault, BoardHealth::Fault, BoardHealth::Fault],
|
||||
expected_fans: Some(2),
|
||||
fan_rpms: vec![6000.0, 6000.0],
|
||||
faults: vec![fault(FaultComponent::Power, "Power current error.")],
|
||||
..Default::default()
|
||||
..Default::default() // is_mining = false
|
||||
};
|
||||
assert_eq!(psu.power_health(), CompHealth::Down);
|
||||
assert!(psu.board_healths().iter().all(|h| *h == CompHealth::Unreachable));
|
||||
assert_eq!(psu.power_health(), CompHealth::Down); // fault + not mining -> red
|
||||
assert!(psu.board_healths().iter().all(|h| *h == CompHealth::Down)); // faulted -> red, not grey
|
||||
let ptips = psu.health_tooltips(2, 3);
|
||||
assert!(ptips[0].contains("Power current error."));
|
||||
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
||||
|
||||
// Round 18 #2: the SAME PSU fault while the miner IS mining is a warning
|
||||
// (yellow bolt), and running boards stay GREEN (not grey). Round 18 #4b:
|
||||
// grey is reserved for genuinely-undetected boards.
|
||||
let psu_running = MinerRow {
|
||||
is_mining: true,
|
||||
power_w: 3000.0,
|
||||
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Missing],
|
||||
faults: vec![fault(FaultComponent::Power, "Power vout warning.")],
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(psu_running.power_health(), CompHealth::Degraded); // yellow, not red
|
||||
let rb = psu_running.board_healths();
|
||||
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
||||
assert_eq!(rb[1], CompHealth::Ok);
|
||||
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn equihash_hashrate_units_round18() {
|
||||
// SHA256 shows the TH/s value directly; Equihash shows the Sol/s count
|
||||
// (ths * 1e12) with an SI prefix (round 18 #7).
|
||||
assert_eq!(hashrate_num_for("SHA256", 80.5).as_deref(), Some("80.5"));
|
||||
// 167,764 Sol/s -> SI mantissa+prefix ("168k"); paired with the "Sol/s" unit.
|
||||
assert_eq!(hashrate_num_for("Equihash", 167_764.0 / 1e12).as_deref(), Some("168k"));
|
||||
assert_eq!(hashrate_num_for("Equihash", 0.0), None);
|
||||
let sha = MinerRow { algorithm: "SHA256".into(), ..Default::default() };
|
||||
let equi = MinerRow { algorithm: "Equihash".into(), ..Default::default() };
|
||||
assert_eq!(sha.hashrate_unit(), "TH/s");
|
||||
assert_eq!(equi.hashrate_unit(), "Sol/s");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2099,12 +2165,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn pic_locked_error_columns_render() {
|
||||
// PIC (best-effort): Antminer known -> PIC/noPIC, unknown Antminer -> "?".
|
||||
// PIC: known -> PIC/noPIC; anything unknown -> blank, never "?" (round 18 #11).
|
||||
let am = |pic| MinerRow { brand: "Antminer".into(), pic_present: pic, ..Default::default() };
|
||||
assert_eq!(Column::Pic.cell(&am(Some(true))), "PIC");
|
||||
assert_eq!(Column::Pic.cell(&am(Some(false))), "noPIC");
|
||||
assert_eq!(Column::Pic.cell(&am(None)), "?");
|
||||
// Non-Antminer makes: PIC has no meaning -> blank, never "?".
|
||||
assert_eq!(Column::Pic.cell(&am(None)), ""); // unknown Antminer model -> blank
|
||||
// Non-Antminer makes: PIC has no meaning -> blank.
|
||||
let wm = MinerRow { brand: "WhatsMiner".into(), pic_present: None, ..Default::default() };
|
||||
assert_eq!(Column::Pic.cell(&wm), "");
|
||||
|
||||
|
||||
@@ -287,6 +287,22 @@ fn is_aml_140mm(clean_model: &str) -> bool {
|
||||
m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21")
|
||||
}
|
||||
|
||||
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
||||
/// the firmware itself does not report an expected hashrate (round 18 #6). Plain
|
||||
/// Antminer Z15 firmware omits the cgminer `total_rateideal` field (the Z15j does
|
||||
/// report it), so its actual-vs-expected column and colour would otherwise be
|
||||
/// blank. The Z15 nameplate is 420 KSol/s. Returns `None` for models with no known
|
||||
/// nameplate (the caller then leaves expected unknown).
|
||||
pub fn equihash_expected_sols(clean_model: &str) -> Option<f64> {
|
||||
let m = clean_model.to_ascii_lowercase();
|
||||
// Match the Z15 family (z15, z15j); both share the 420 KSol/s nameplate.
|
||||
if m.contains("z15") {
|
||||
Some(420_000.0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -572,7 +572,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
.as_ref()
|
||||
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||
.unwrap_or(0.0);
|
||||
let expected_ths = data
|
||||
let mut expected_ths = data
|
||||
.expected_hashrate
|
||||
.as_ref()
|
||||
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||
@@ -614,6 +614,18 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
.unwrap_or(0.0)
|
||||
})
|
||||
.collect();
|
||||
// Per-board expected hashrate (TH/s), index-aligned, for the actual/expected
|
||||
// per-board tooltip (round 18 #3).
|
||||
let board_expected_hashrates: Vec<f64> = data
|
||||
.hashboards
|
||||
.iter()
|
||||
.map(|b| {
|
||||
b.expected_hashrate
|
||||
.as_ref()
|
||||
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||
.unwrap_or(0.0)
|
||||
})
|
||||
.collect();
|
||||
let fan_rpms: Vec<f64> = data
|
||||
.fans
|
||||
.iter()
|
||||
@@ -699,6 +711,14 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
.filter_map(|f| f.rpm.as_ref().map(|r| r.as_rpm()))
|
||||
.fold(0.0f64, f64::max);
|
||||
let algorithm = data.hashrate.as_ref().map(|h| h.algo.to_string()).unwrap_or_default();
|
||||
// Equihash (Z15) fallback: plain Z15 firmware omits the expected hashrate, so
|
||||
// fill it from the model nameplate (Sol/s -> the ths-normalised value) so the
|
||||
// actual/expected column + colour work like every other miner (round 18 #6).
|
||||
if expected_ths <= 0.0 && algorithm.eq_ignore_ascii_case("equihash") {
|
||||
if let Some(sols) = crate::naming::equihash_expected_sols(&model) {
|
||||
expected_ths = sols / 1e12;
|
||||
}
|
||||
}
|
||||
let is_mining = data.is_mining;
|
||||
let slow = crate::model::is_slow(is_mining, hashrate_ths, expected_ths);
|
||||
let operating_state = data.operating_state.as_ref().map(|s| s.to_string()).unwrap_or_default();
|
||||
@@ -843,6 +863,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
hashrate_ths,
|
||||
expected_ths,
|
||||
board_hashrates,
|
||||
board_expected_hashrates,
|
||||
efficiency: data.efficiency.unwrap_or(0.0),
|
||||
power_w,
|
||||
// PSU info (round 17 R5/G15; ePIC exposes it today). A reported-but-zero
|
||||
|
||||
@@ -1311,14 +1311,16 @@ impl App {
|
||||
// With a single algorithm running (the common case) the card shows that
|
||||
// algorithm's total under a "<Algo> Hashrate" caption; when several are
|
||||
// running, clicking the card cycles `hashrate_algo_idx` through them.
|
||||
let (algo_label, algo_ths) = if k.hashrate_by_algo.is_empty() {
|
||||
("SHA-256".to_string(), 0.0)
|
||||
let (algo_label, algo_ths, algo_unit) = if k.hashrate_by_algo.is_empty() {
|
||||
("SHA-256".to_string(), 0.0, "H")
|
||||
} else {
|
||||
let i = self.hashrate_algo_idx % k.hashrate_by_algo.len();
|
||||
let (a, t) = &k.hashrate_by_algo[i];
|
||||
(pretty_algo(a), *t)
|
||||
// Equihash miners (Z15/Zcash) are counted in Sol/s, not H/s (round 18 #7).
|
||||
let unit = if a.eq_ignore_ascii_case("equihash") { "Sol" } else { "H" };
|
||||
(pretty_algo(a), *t, unit)
|
||||
};
|
||||
self.kpi_hashrate.set_label(&format_si(algo_ths * 1e12, "H"));
|
||||
self.kpi_hashrate.set_label(&format_si(algo_ths * 1e12, algo_unit));
|
||||
self.kpi_hashrate_lbl.set_label(&format!("{algo_label} Hashrate"));
|
||||
self.kpi_power.set_label(&format_si(k.total_power_w, "W"));
|
||||
// set_label resizes the static text; re-run each card's sizer so the
|
||||
@@ -1472,8 +1474,14 @@ impl App {
|
||||
if !caps.is_empty() {
|
||||
let sfx = if n == 1 { String::new() } else { format!(" ({n})") };
|
||||
if caps.fault_light {
|
||||
menu.menu_append(ID_CTX_LIGHT_ON, &format!("Flash lights on{sfx}"));
|
||||
menu.menu_append(ID_CTX_LIGHT_OFF, &format!("Flash lights off{sfx}"));
|
||||
// A single state-based toggle (round 18 #9): if any selected miner's
|
||||
// locate light is on, offer to stop; otherwise offer to flash.
|
||||
let any_on = selected.iter().any(|r| r.light_flashing == Some(true));
|
||||
if any_on {
|
||||
menu.menu_append(ID_CTX_LIGHT_OFF, &format!("Stop flashing lights{sfx}"));
|
||||
} else {
|
||||
menu.menu_append(ID_CTX_LIGHT_ON, &format!("Flash lights{sfx}"));
|
||||
}
|
||||
}
|
||||
if caps.pause {
|
||||
menu.menu_append(ID_CTX_PAUSE, &format!("Pause mining{sfx}"));
|
||||
|
||||
@@ -335,14 +335,15 @@ int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
|
||||
if (h < 8) h = 8;
|
||||
int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
||||
if (w < 1) w = 1;
|
||||
// The Font Awesome fan glyph fills its square box more than the other health
|
||||
// icons (brain/chip/bolt), so at the shared size it reads as oversized. Draw
|
||||
// it a bit smaller, centred in its full-size slot, so the slot advance and the
|
||||
// per-icon tooltip hit-test (both keyed to the full width) are unchanged
|
||||
// (round 17 R1).
|
||||
// The Font Awesome fan and brain glyphs fill their square box more than the
|
||||
// other health icons (chip/bolt), so at the shared size they read as oversized.
|
||||
// Draw them a bit smaller, centred in their full-size slot, so the slot advance
|
||||
// and the per-icon tooltip hit-test (both keyed to the full width) are
|
||||
// unchanged (round 17 R1; round 18 #1 brain).
|
||||
int dw = w, dh = h;
|
||||
if (shape == SHAPE_FAN) {
|
||||
dh = (int)(h * 0.80 + 0.5);
|
||||
double glyph_scale = (shape == SHAPE_FAN) ? 0.80 : (shape == SHAPE_BRAIN) ? 0.82 : 1.0;
|
||||
if (glyph_scale < 1.0) {
|
||||
dh = (int)(h * glyph_scale + 0.5);
|
||||
if (dh < 8) dh = 8;
|
||||
dw = (sv->vbh > 0) ? (int)((double)dh * sv->vbw / sv->vbh + 0.5) : dh;
|
||||
if (dw < 1) dw = 1;
|
||||
@@ -982,6 +983,17 @@ static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keybo
|
||||
if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
|
||||
const wxString& tip = iit->second[(size_t)slot];
|
||||
if (tip.IsEmpty()) return FALSE;
|
||||
// Scope the tooltip's "tip area" to just this icon's slot (round 18 #4a).
|
||||
// Without a tip area GTK defaults it to the whole widget, so it never re-queries
|
||||
// or moves the tooltip as the pointer crosses from one icon to the next -- the
|
||||
// old tooltip just stays put with stale text. Setting a per-slot area makes GTK
|
||||
// hide + re-show + reposition the tooltip for each icon.
|
||||
GdkRectangle area;
|
||||
area.x = crect.x + slot * adv;
|
||||
area.y = crect.y;
|
||||
area.width = adv;
|
||||
area.height = crect.height;
|
||||
gtk_tooltip_set_tip_area(tooltip, &area);
|
||||
gtk_tooltip_set_text(tooltip, tip.utf8_str());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user