Rouvrir la fenêtre sans focus à l’entrée en sélection Arena #64

Merged
nessar merged 1 commits from feat/63-reveal-on-champ-select into main 2026-11-20 10:57:56 +01:00
4 changed files with 86 additions and 12 deletions

No files matched your search

+8 -1
View File
@@ -90,7 +90,14 @@ impl RootView {
let champ_select = cx.subscribe_in(
&page,
window,
|this, _, _: &stats_page::ChampSelectTransition, window, cx| {
|this, _, transition: &stats_page::ChampSelectTransition, window, cx| {
// Only on entry: the window stays open after the champ select.
if transition.entered
&& let Some(hwnd) = tray::window_hwnd(window)
{
// Outside this update: the native calls resize the window through GPUI.
cx.spawn(async move |_, _| tray::reveal(hwnd)).detach();
}
if this.screen == Screen::Settings {
// Champ select takes the window away: do not bring back half-typed edits.
this.show_page(window, cx);
+39 -3
View File
@@ -83,7 +83,10 @@ impl SelectItem for AccountItem {
}
}
pub struct ChampSelectTransition;
/// The page entered or left an Arena champ select.
pub struct ChampSelectTransition {
pub entered: bool,
}
impl EventEmitter<ChampSelectTransition> for StatsPage {}
pub struct StatsPage {
@@ -388,7 +391,9 @@ impl StatsPage {
self.reload_in_background(window, cx);
}
if changed_page {
cx.emit(ChampSelectTransition);
cx.emit(ChampSelectTransition {
entered: self.in_champ_select(),
});
}
self.update_picks();
if pool_changed || switch {
@@ -1221,7 +1226,7 @@ impl Render for StatsPage {
#[cfg(test)]
mod tests {
use std::cell::Cell;
use std::cell::{Cell, RefCell};
use std::path::Path;
use std::rc::Rc;
use std::sync::Arc;
@@ -1421,6 +1426,37 @@ mod tests {
});
}
#[gpui::test]
fn only_entering_a_champ_select_is_reported_as_an_entry(cx: &mut TestAppContext) {
use crate::worker::Msg;
use arena_tracker_core::ChampSelect;
let tracker = Tracker::open(Path::new(":memory:"), Box::new(RefreshHistory)).unwrap();
let (page, mut window) = open_page_with_tracker(cx, tracker);
let entered = Rc::new(RefCell::new(Vec::new()));
let _events = window.update(|_, cx| {
let entered = entered.clone();
cx.subscribe(
&page,
move |_, transition: &super::ChampSelectTransition, _| {
entered.borrow_mut().push(transition.entered)
},
)
});
let hovered = |current| ChampSelect::new(current, [39].into(), vec![39]);
for champ_select in [
None,
Some(("Alice#EUW".into(), hovered(Some(39)))),
Some(("Alice#EUW".into(), hovered(None))),
None,
None,
] {
window.update(|w, cx| {
page.update(cx, |p, cx| p.apply(Msg::ChampSelect(champ_select), w, cx))
});
}
assert_eq!(*entered.borrow(), [true, false]);
}
#[gpui::test]
fn typing_in_the_search_field_filters_the_table(cx: &mut TestAppContext) {
let (page, cx) = open_page(cx);
+38 -7
View File
@@ -253,15 +253,46 @@ fn fill(field: &mut [u16], text: &str) {
}
}
pub fn reopen(hwnd: HWND) {
/// The window's tray, while it is installed.
fn installed_tray(hwnd: HWND) -> Option<Rc<Tray>> {
let mut data = 0;
if unsafe { GetWindowSubclass(hwnd, Some(window_proc), TRAY_SUBCLASS, Some(&mut data)) }
unsafe { GetWindowSubclass(hwnd, Some(window_proc), TRAY_SUBCLASS, Some(&mut data)) }
.as_bool()
{
let data = data as *const Tray;
unsafe { retain(data) }.open();
} else {
foreground(hwnd);
.then(|| unsafe { retain(data as *const Tray) })
}
pub fn reopen(hwnd: HWND) {
match installed_tray(hwnd) {
Some(tray) => tray.open(),
None => foreground(hwnd),
}
}
/// Brings a minimized window, or one hidden in the notification area, back above the other
/// windows while the foreground app keeps the keyboard. A window already shown is left alone.
pub fn reveal(hwnd: HWND) {
unsafe {
let iconic = IsIconic(hwnd).as_bool();
if IsWindowVisible(hwnd).as_bool() && !iconic {
return;
}
if let Some(tray) = installed_tray(hwnd) {
tray.remove_icon();
}
if iconic {
// shortcut: a window minimized from maximized may come back at its normal size, as no
// show command maximizes without activating; revisit if the Windows check shows it.
let _ = ShowWindow(hwnd, SW_SHOWNOACTIVATE);
}
let _ = SetWindowPos(
hwnd,
Some(HWND_TOP),
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW,
);
}
}
+1 -1
View File
@@ -31,7 +31,7 @@ Au survol ou au focus clavier, la fiche du champion affiche ses Parties, ses Vic
### Pendant la sélection Arena
1. La détection d’une sélection Arena affiche automatiquement la rangée de cartes dans la fenêtre existante, sous la progression de saison. Le joueur garde le focus dans League et une fenêtre réduite reste réduite.
1. La détection d’une sélection Arena affiche automatiquement la rangée de cartes dans la fenêtre existante, sous la progression de saison. Le joueur garde le focus dans League : une fenêtre réduite ou cachée dans la zone de notification se rouvre à l’entrée en sélection, sans prendre le focus, et reste ouverte à la fin de la sélection. Ce comportement n’a pas de réglage.
2. La rangée « Champions de l’Enclume » contient **tous** les champions marqués d’une enclume dans la sélection en cours, dans le tri choisi. Au-dessous, « Autres champions » est replié par défaut. L’ouvrir affiche tous les champions sans enclume, avec le même tri et les mêmes cartes. Sa recherche par nom filtre uniquement cette section.
3. Dans les deux sections, les cartes gardent leur place lorsqu’un champion est validé, banni ou pris par un allié. Son portrait est grisé et la carte indique les raisons applicables : « Validé », « Banni », « Pris par un allié ». Un champion validé et banni porte les deux indications.
4. Une présélection alliée laisse la carte dans son état courant. « Pris par un allié » apparaît à la confirmation du choix. Les bans et les choix alliés expirent avec la sélection : ils n’affectent ni les coches personnelles, ni le compteur du Défi, ni la sélection suivante.