@@ -570,6 +570,10 @@ bool Window::get_flag(Flags p_flag) const {
570
570
return flags[p_flag];
571
571
}
572
572
573
+ bool Window::is_popup () const {
574
+ return get_flag (Window::FLAG_POPUP) || get_flag (Window::FLAG_NO_FOCUS);
575
+ }
576
+
573
577
bool Window::is_maximize_allowed () const {
574
578
ERR_READ_THREAD_GUARD_V (false );
575
579
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
@@ -680,11 +684,6 @@ void Window::_make_window() {
680
684
}
681
685
}
682
686
683
- if (get_tree () && get_tree ()->is_accessibility_supported ()) {
684
- get_tree ()->_accessibility_force_update ();
685
- _accessibility_notify_enter (this );
686
- }
687
-
688
687
_update_window_callbacks ();
689
688
690
689
RS::get_singleton ()->viewport_set_update_mode (get_viewport_rid (), RS::VIEWPORT_UPDATE_WHEN_VISIBLE);
@@ -716,10 +715,6 @@ void Window::_clear_window() {
716
715
717
716
_update_from_window ();
718
717
719
- if (get_tree () && get_tree ()->is_accessibility_supported ()) {
720
- _accessibility_notify_exit (this );
721
- }
722
-
723
718
DisplayServer::get_singleton ()->delete_sub_window (window_id);
724
719
window_id = DisplayServer::INVALID_WINDOW_ID;
725
720
@@ -886,7 +881,7 @@ void Window::_accessibility_notify_enter(Node *p_node) {
886
881
887
882
if (p_node != this ) {
888
883
const Window *window = Object::cast_to<Window>(p_node);
889
- if (window && !window-> is_embedded () ) {
884
+ if (window) {
890
885
return ;
891
886
}
892
887
}
@@ -901,7 +896,7 @@ void Window::_accessibility_notify_exit(Node *p_node) {
901
896
902
897
if (p_node != this ) {
903
898
const Window *window = Object::cast_to<Window>(p_node);
904
- if (window && !window-> is_embedded () ) {
899
+ if (window) {
905
900
return ;
906
901
}
907
902
}
@@ -950,23 +945,35 @@ void Window::set_visible(bool p_visible) {
950
945
}
951
946
}
952
947
embedder->_sub_window_register (this );
953
- embedder->queue_accessibility_update ();
954
948
RS::get_singleton ()->viewport_set_update_mode (get_viewport_rid (), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE);
955
949
} else {
956
950
embedder->_sub_window_remove (this );
957
- embedder->queue_accessibility_update ();
958
951
embedder = nullptr ;
959
952
RS::get_singleton ()->viewport_set_update_mode (get_viewport_rid (), RS::VIEWPORT_UPDATE_DISABLED);
960
953
}
961
954
_update_window_size ();
962
955
}
963
956
964
- if (!visible) {
957
+ if (visible) {
958
+ if (get_tree () && get_tree ()->is_accessibility_supported ()) {
959
+ get_tree ()->_accessibility_force_update ();
960
+ _accessibility_notify_enter (this );
961
+ }
962
+ } else {
963
+ if (get_tree () && get_tree ()->is_accessibility_supported ()) {
964
+ _accessibility_notify_exit (this );
965
+ }
965
966
focused = false ;
966
967
if (focused_window == this ) {
967
968
focused_window = nullptr ;
968
969
}
969
970
}
971
+ if (get_parent ()) {
972
+ get_parent ()->queue_accessibility_update ();
973
+ }
974
+ if (embedder) {
975
+ embedder->queue_accessibility_update ();
976
+ }
970
977
971
978
notification (NOTIFICATION_VISIBILITY_CHANGED);
972
979
emit_signal (SceneStringName (visibility_changed));
@@ -1371,10 +1378,10 @@ Viewport *Window::get_embedder() const {
1371
1378
}
1372
1379
1373
1380
RID Window::get_accessibility_element () const {
1374
- if (is_part_of_edited_scene ()) {
1381
+ if (!visible || is_part_of_edited_scene ()) {
1375
1382
return RID ();
1376
1383
}
1377
- if (get_embedder ()) {
1384
+ if (get_embedder () || is_popup () ) {
1378
1385
return Node::get_accessibility_element ();
1379
1386
} else if (window_id != DisplayServer::INVALID_WINDOW_ID) {
1380
1387
return DisplayServer::get_singleton ()->accessibility_get_window_root (window_id);
@@ -1415,11 +1422,18 @@ void Window::_notification(int p_what) {
1415
1422
DisplayServer::get_singleton ()->accessibility_update_add_action (ae, DisplayServer::AccessibilityAction::ACTION_FOCUS, callable_mp (this , &Window::_accessibility_action_grab_focus));
1416
1423
DisplayServer::get_singleton ()->accessibility_update_set_flag (ae, DisplayServer::AccessibilityFlags::FLAG_HIDDEN, !visible);
1417
1424
1418
- if (get_embedder ()) {
1425
+ if (get_embedder () || is_popup () ) {
1419
1426
Control *parent_ctrl = Object::cast_to<Control>(get_parent ());
1420
1427
Transform2D parent_tr = parent_ctrl ? parent_ctrl->get_global_transform () : Transform2D ();
1421
1428
Transform2D tr;
1422
- tr.set_origin (position);
1429
+ if (window_id == DisplayServer::INVALID_WINDOW_ID) {
1430
+ tr.set_origin (position);
1431
+ } else {
1432
+ Window *np = get_non_popup_window ();
1433
+ if (np) {
1434
+ tr.set_origin (get_position () - np->get_position ());
1435
+ }
1436
+ }
1423
1437
DisplayServer::get_singleton ()->accessibility_update_set_transform (ae, parent_tr.affine_inverse () * tr);
1424
1438
DisplayServer::get_singleton ()->accessibility_update_set_bounds (ae, Rect2 (Point2 (), size));
1425
1439
@@ -1540,9 +1554,19 @@ void Window::_notification(int p_what) {
1540
1554
_make_transient ();
1541
1555
}
1542
1556
if (visible) {
1557
+ if (window_id != DisplayServer::MAIN_WINDOW_ID && get_tree () && get_tree ()->is_accessibility_supported ()) {
1558
+ get_tree ()->_accessibility_force_update ();
1559
+ _accessibility_notify_enter (this );
1560
+ }
1543
1561
notification (NOTIFICATION_VISIBILITY_CHANGED);
1544
1562
emit_signal (SceneStringName (visibility_changed));
1545
1563
RS::get_singleton ()->viewport_set_active (get_viewport_rid (), true );
1564
+ if (get_parent ()) {
1565
+ get_parent ()->queue_accessibility_update ();
1566
+ }
1567
+ if (embedder) {
1568
+ embedder->queue_accessibility_update ();
1569
+ }
1546
1570
}
1547
1571
1548
1572
// Emits NOTIFICATION_THEME_CHANGED internally.
@@ -1584,6 +1608,18 @@ void Window::_notification(int p_what) {
1584
1608
1585
1609
set_theme_context (nullptr , false );
1586
1610
1611
+ if (visible && window_id != DisplayServer::MAIN_WINDOW_ID) {
1612
+ if (get_tree () && get_tree ()->is_accessibility_supported ()) {
1613
+ _accessibility_notify_exit (this );
1614
+ if (get_parent ()) {
1615
+ get_parent ()->queue_accessibility_update ();
1616
+ }
1617
+ if (embedder) {
1618
+ embedder->queue_accessibility_update ();
1619
+ }
1620
+ }
1621
+ }
1622
+
1587
1623
accessibility_title_element = RID ();
1588
1624
accessibility_announcement_element = RID ();
1589
1625
@@ -1816,6 +1852,14 @@ Viewport *Window::get_parent_viewport() const {
1816
1852
}
1817
1853
}
1818
1854
1855
+ Window *Window::get_non_popup_window () const {
1856
+ Window *w = const_cast <Window *>(this );
1857
+ while (w && w->is_popup ()) {
1858
+ w = w->get_parent_visible_window ();
1859
+ }
1860
+ return w;
1861
+ }
1862
+
1819
1863
Window *Window::get_parent_visible_window () const {
1820
1864
ERR_READ_THREAD_GUARD_V (nullptr );
1821
1865
Viewport *vp = get_parent_viewport ();
0 commit comments