Skip to content

Commit 3f0a566

Browse files
committed
fix: Expose dialogs in the platform adapters
1 parent ffc1c69 commit 3f0a566

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

platforms/atspi-common/src/node.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ impl NodeWrapper<'_> {
284284
let state = self.0;
285285
let atspi_role = self.role();
286286
let mut atspi_state = StateSet::empty();
287-
if state.parent_id().is_none() && state.role() == Role::Window && is_window_focused {
287+
if is_window_focused
288+
&& ((state.parent_id().is_none() && state.role() == Role::Window)
289+
|| (state.is_dialog()
290+
&& state.tree_state.active_dialog().map(|d| d.id()) == Some(state.id())))
291+
{
288292
atspi_state.insert(State::Active);
289293
}
290294
if state.is_text_input() && !state.is_read_only() {
@@ -314,6 +318,9 @@ impl NodeWrapper<'_> {
314318
if atspi_role != AtspiRole::ToggleButton && state.toggled().is_some() {
315319
atspi_state.insert(State::Checkable);
316320
}
321+
if state.is_modal() {
322+
atspi_state.insert(State::Modal);
323+
}
317324
if let Some(selected) = state.is_selected() {
318325
if !state.is_disabled() {
319326
atspi_state.insert(State::Selectable);

platforms/windows/src/node.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,18 @@ impl NodeWrapper<'_> {
443443
self.0.role() == Role::PasswordInput
444444
}
445445

446+
fn is_dialog(&self) -> bool {
447+
self.0.is_dialog()
448+
}
449+
450+
fn is_window_pattern_supported(&self) -> bool {
451+
self.0.is_modal()
452+
}
453+
454+
fn is_modal(&self) -> bool {
455+
self.0.is_modal()
456+
}
457+
446458
pub(crate) fn enqueue_property_changes(
447459
&self,
448460
queue: &mut Vec<QueuedEvent>,
@@ -500,7 +512,8 @@ impl NodeWrapper<'_> {
500512
IRangeValueProvider,
501513
ISelectionItemProvider,
502514
ISelectionProvider,
503-
ITextProvider
515+
ITextProvider,
516+
IWindowProvider
504517
)]
505518
pub(crate) struct PlatformNode {
506519
pub(crate) context: Weak<Context>,
@@ -925,7 +938,8 @@ properties! {
925938
(UIA_IsRequiredForFormPropertyId, is_required),
926939
(UIA_IsPasswordPropertyId, is_password),
927940
(UIA_PositionInSetPropertyId, position_in_set),
928-
(UIA_SizeOfSetPropertyId, size_of_set)
941+
(UIA_SizeOfSetPropertyId, size_of_set),
942+
(UIA_IsDialogPropertyId, is_dialog)
929943
}
930944

931945
patterns! {
@@ -1065,6 +1079,41 @@ patterns! {
10651079
}
10661080
})
10671081
}
1082+
)),
1083+
(UIA_WindowPatternId, IWindowProvider, IWindowProvider_Impl, is_window_pattern_supported, (
1084+
(UIA_WindowIsModalPropertyId, IsModal, is_modal, BOOL)
1085+
), (
1086+
fn SetVisualState(&self, _: WindowVisualState) -> Result<()> {
1087+
Err(not_supported())
1088+
},
1089+
1090+
fn Close(&self) -> Result<()> {
1091+
Err(not_supported())
1092+
},
1093+
1094+
fn WaitForInputIdle(&self, _: i32) -> Result<BOOL> {
1095+
Err(not_supported())
1096+
},
1097+
1098+
fn CanMaximize(&self) -> Result<BOOL> {
1099+
Err(not_supported())
1100+
},
1101+
1102+
fn CanMinimize(&self) -> Result<BOOL> {
1103+
Err(not_supported())
1104+
},
1105+
1106+
fn WindowVisualState(&self) -> Result<WindowVisualState> {
1107+
Err(not_supported())
1108+
},
1109+
1110+
fn WindowInteractionState(&self) -> Result<WindowInteractionState> {
1111+
Err(not_supported())
1112+
},
1113+
1114+
fn IsTopmost(&self) -> Result<BOOL> {
1115+
Err(not_supported())
1116+
}
10681117
))
10691118
}
10701119

platforms/windows/src/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ pub(crate) fn invalid_operation() -> Error {
215215
HRESULT(UIA_E_INVALIDOPERATION as _).into()
216216
}
217217

218+
pub(crate) fn not_supported() -> Error {
219+
HRESULT(UIA_E_NOTSUPPORTED as _).into()
220+
}
221+
218222
pub(crate) fn client_top_left(hwnd: WindowHandle) -> Point {
219223
let mut result = POINT::default();
220224
// If ClientToScreen fails, that means the window is gone.

0 commit comments

Comments
 (0)