| | @@ -5,6 +5,9 @@ struct WorkChild { |
| 5 | 5 | events: Vec<egui::Event>, |
| 6 | 6 | labels: Vec<(String, egui::Pos2)>, |
| 7 | 7 | rendered: usize, |
| 8 | +추가: cursor: Option<egui::CursorIcon>, |
| 9 | +추가: rects: Vec<(egui::Rect, egui::Color32)>, |
| 10 | +추가: commands: Vec<egui::ViewportCommand>, |
| 8 | 11 | } |
| 9 | 12 | |
| 10 | 13 | std::thread_local! { |
| | @@ -43,6 +46,21 @@ fn install_work_child_renderer() { |
| 43 | 46 | let mut child = child.borrow_mut(); |
| 44 | 47 | child.labels = labels(&output.shapes); |
| 45 | 48 | child.rendered += 1; |
| 49 | +추가: child.cursor = Some(output.platform_output.cursor_icon); |
| 50 | +추가: child.rects.clear(); |
| 51 | +추가: fn walk(shape: &egui::epaint::Shape, out: &mut Vec<(egui::Rect, egui::Color32)>) { |
| 52 | +추가: match shape { |
| 53 | +추가: egui::epaint::Shape::Rect(rect) => out.push((rect.rect, rect.fill)), |
| 54 | +추가: egui::epaint::Shape::Vec(shapes) => shapes.iter().for_each(|s| walk(s, out)), |
| 55 | +추가: _ => {} |
| 56 | +추가: } |
| 57 | +추가: } |
| 58 | +추가: for shape in &output.shapes { |
| 59 | +추가: walk(&shape.shape, &mut child.rects); |
| 60 | +추가: } |
| 61 | +추가: for viewport in output.viewport_output.values() { |
| 62 | +추가: child.commands.extend(viewport.commands.iter().cloned()); |
| 63 | +추가: } |
| 46 | 64 | }); |
| 47 | 65 | }); |
| 48 | 66 | } |
| | @@ -219,3 +237,75 @@ fn password_prompt_is_not_covered_by_separate_work_window() { |
| 219 | 237 | "암호 입력 뒤 진행 창이 다시 나타나야 함" |
| 220 | 238 | ); |
| 221 | 239 | } |
| 240 | +추가: |
| 241 | +추가: #[test] |
| 242 | +추가: fn child_window_buttons_hover_again_after_title_bar_drag() { |
| 243 | +추가: let scratch = Folder::new(); |
| 244 | +추가: let factory = FakeFactory::default(); |
| 245 | +추가: let mut app = loaded(&scratch, &factory); |
| 246 | +추가: factory.state.borrow_mut().manual = true; |
| 247 | +추가: assert!(app.begin_extract()); |
| 248 | +추가: { |
| 249 | +추가: let mut worker = factory.state.borrow_mut(); |
| 250 | +추가: worker.frame(Event::Accepted { encryption: false }); |
| 251 | +추가: worker.finish(Outcome::Failed, Publication::None); |
| 252 | +추가: } |
| 253 | +추가: app.set_custom_frame(true); |
| 254 | +추가: let ctx = egui::Context::default(); |
| 255 | +추가: ctx.set_embed_viewports(false); |
| 256 | +추가: install_work_child_renderer(); |
| 257 | +추가: for _ in 0..10 { |
| 258 | +추가: policy_render(&ctx, &mut app, vec![]); |
| 259 | +추가: } |
| 260 | +추가: let mut commands = Vec::new(); |
| 261 | +추가: fn child_frame( |
| 262 | +추가: ctx: &egui::Context, |
| 263 | +추가: app: &mut ArchiveApp, |
| 264 | +추가: events: Vec<egui::Event>, |
| 265 | +추가: commands: &mut Vec<egui::ViewportCommand>, |
| 266 | +추가: ) { |
| 267 | +추가: WORK_CHILD.with(|child| child.borrow_mut().events = events); |
| 268 | +추가: // 자식 창 명령은 부모 출력에 실려 올 수도 있어 둘 다 모음. |
| 269 | +추가: let output = frame_output(ctx, app, vec![]); |
| 270 | +추가: for viewport in output.viewport_output.values() { |
| 271 | +추가: commands.extend(viewport.commands.iter().cloned()); |
| 272 | +추가: } |
| 273 | +추가: } |
| 274 | +추가: // 자식 창 제목 표시줄을 누른 채 끌어 창 이동을 운영체제에 넘김. |
| 275 | +추가: let start = egui::pos2(120.0, 19.0); |
| 276 | +추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(start)], &mut commands); |
| 277 | +추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerButton { |
| 278 | +추가: pos: start, |
| 279 | +추가: button: egui::PointerButton::Primary, |
| 280 | +추가: pressed: true, |
| 281 | +추가: modifiers: egui::Modifiers::NONE, |
| 282 | +추가: }], &mut commands); |
| 283 | +추가: for step in 1..=3 { |
| 284 | +추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(start + egui::vec2(6.0 * step as f32, 0.0))], &mut commands); |
| 285 | +추가: } |
| 286 | +추가: let started = commands.contains(&egui::ViewportCommand::StartDrag) |
| 287 | +추가: || WORK_CHILD.with(|child| { |
| 288 | +추가: child |
| 289 | +추가: .borrow() |
| 290 | +추가: .commands |
| 291 | +추가: .contains(&egui::ViewportCommand::StartDrag) |
| 292 | +추가: }); |
| 293 | +추가: assert!(started, "자식 창 이동이 시작돼야 함"); |
| 294 | +추가: // GNOME은 이동이 끝나도 버튼 놓기를 보내지 않음. 그대로 닫기 버튼에 마우스를 올림. |
| 295 | +추가: let close = egui::pos2(480.0 - 6.0 - 17.0, 19.0); |
| 296 | +추가: for _ in 0..3 { |
| 297 | +추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(close)], &mut commands); |
| 298 | +추가: } |
| 299 | +추가: let (cursor, hovered_red) = WORK_CHILD.with(|child| { |
| 300 | +추가: let child = child.borrow(); |
| 301 | +추가: ( |
| 302 | +추가: child.cursor, |
| 303 | +추가: child |
| 304 | +추가: .rects |
| 305 | +추가: .iter() |
| 306 | +추가: .any(|(rect, fill)| rect.contains(close) && *fill == egui::Color32::from_rgb(232, 17, 35)), |
| 307 | +추가: ) |
| 308 | +추가: }); |
| 309 | +추가: assert!(hovered_red, "닫기 버튼에 마우스를 올린 배경이 없음"); |
| 310 | +추가: assert_eq!(cursor, Some(egui::CursorIcon::PointingHand)); |
| 311 | +추가: } |