diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-05-06 11:57:21 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-05-07 06:05:50 +0200 |
commit | 1b9041a7c97c31a12afe7b69f0e1e4005a819509 (patch) | |
tree | 6e2cae20f5104ae16d4f1c69862828f036c5fb44 /vcl/unx/gtk3 | |
parent | c1a7de292c3f1d1ec52dbda4c027dc91a9718777 (diff) |
tdf#160806 tdf#160837 gtk3 a11y: Port from deprecated atk_focus_tracker_notify
`atk_focus_tracker_notify` takes care of sending an
"AtkObject:focus-event" event for the given object.
However, both, `atk_focus_tracker_notify` and the "AtkObject:focus-event"
ATK event (which triggers a "focus" AT-SPI event) are
deprecated, quoting [1]:
> Focus tracking has been dropped as a feature to be implemented by ATK
> itself. As AtkObject::focus-event was deprecated in favor of a
> AtkObject::state-change signal, in order to notify a focus change on
> your implementation, you can use atk_object_notify_state_change()
> instead.
Move the existing call to `atk_object_notify_state_change` up and
use instead of the deprecated function.
For the example of the "Print" button in
Writer's standard toolbar, it can now be
seen that a "object:state-changed:focused"
instead of a "focus" event is received with
a corresponding listener when tabbing to
the button and then further:
Before:
88.7 focus:(0, 0, 0)
source: [push button | Print]
application: [application | soffice]
88.7 object:state-changed:focused(1, 0, 0)
source: [push button | Print]
application: [application | soffice]
89.4 object:state-changed:focused(0, 0, 0)
source: [push button | Print]
application: [application | soffice]
After:
80.0 object:state-changed:focused(1, 0, 0)
source: [push button | Print]
application: [application | soffice]
80.0 object:state-changed:focused(1, 0, 0)
source: [push button | Print]
application: [application | soffice]
80.8 object:state-changed:focused(0, 0, 0)
source: [push button | Print]
application: [application | soffice]
The first event is the one emitted fromt this place,
the others are from elsewhere.
This also already shows that duplicate events are
sent. Eliminating those which also cause
other problems is planned in upcoming steps.
[1] https://docs.gtk.org/atk/func.focus_tracker_notify.html
Change-Id: Ieb9d25445b620681b01b887c0c120c80a43379ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167207
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r-- | vcl/unx/gtk3/a11y/atkutil.cxx | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/vcl/unx/gtk3/a11y/atkutil.cxx b/vcl/unx/gtk3/a11y/atkutil.cxx index 88ebe460a7d4..9936bc350b0f 100644 --- a/vcl/unx/gtk3/a11y/atkutil.cxx +++ b/vcl/unx/gtk3/a11y/atkutil.cxx @@ -42,19 +42,16 @@ using namespace ::com::sun::star; static void -atk_wrapper_focus_tracker_notify(const uno::Reference<accessibility::XAccessible>& xAccessible) +atk_wrapper_notify_focus_change(const uno::Reference<accessibility::XAccessible>& xAccessible) { AtkObject *atk_obj = xAccessible.is() ? atk_object_wrapper_ref( xAccessible ) : nullptr; // Gail does not notify focus changes to NULL, so do we .. if( atk_obj ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - atk_focus_tracker_notify(atk_obj); - SAL_WNODEPRECATED_DECLARATIONS_POP + atk_object_notify_state_change(atk_obj, ATK_STATE_FOCUSED, true); // #i93269# // emit text_caret_moved event for <XAccessibleText> object, // if cursor is inside the <XAccessibleText> object. - // also emit state-changed:focused event under the same condition. { AtkObjectWrapper* wrapper_obj = ATK_OBJECT_WRAPPER (atk_obj); if( wrapper_obj && !wrapper_obj->mpText.is() ) @@ -73,7 +70,6 @@ atk_wrapper_focus_tracker_notify(const uno::Reference<accessibility::XAccessible if ( caretPos != -1 ) { - atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, true ); g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos ); } } @@ -106,7 +102,7 @@ void DocumentFocusListener::notifyEvent( const accessibility::AccessibleEventObj aEvent.NewValue >>= nState; if( accessibility::AccessibleStateType::FOCUSED == nState ) - atk_wrapper_focus_tracker_notify(getAccessible(aEvent)); + atk_wrapper_notify_focus_change(getAccessible(aEvent)); break; } @@ -200,7 +196,7 @@ void DocumentFocusListener::attachRecursive( ) { if( nStateSet & accessibility::AccessibleStateType::FOCUSED ) - atk_wrapper_focus_tracker_notify(xAccessible); + atk_wrapper_notify_focus_change(xAccessible); uno::Reference< accessibility::XAccessibleEventBroadcaster > xBroadcaster(xContext, uno::UNO_QUERY); @@ -296,7 +292,7 @@ static void handle_tabpage_activated(vcl::Window *pWindow) xAccessible->getAccessibleContext(), uno::UNO_QUERY); if( xSelection.is() ) - atk_wrapper_focus_tracker_notify(xSelection->getSelectedAccessibleChild(0)); + atk_wrapper_notify_focus_change(xSelection->getSelectedAccessibleChild(0)); } /*****************************************************************************/ @@ -321,7 +317,7 @@ static void notify_toolbox_item_focus(ToolBox *pToolBox) ToolBox::ImplToolItems::size_type nPos = pToolBox->GetItemPos( pToolBox->GetHighlightItemId() ); if( nPos != ToolBox::ITEM_NOTFOUND ) - atk_wrapper_focus_tracker_notify(xContext->getAccessibleChild(nPos)); + atk_wrapper_notify_focus_change(xContext->getAccessibleChild(nPos)); } static void handle_toolbox_highlight(vcl::Window *pWindow) @@ -452,7 +448,7 @@ static void handle_get_focus(::VclWindowEvent const * pEvent) if( (nStateSet & accessibility::AccessibleStateType::FOCUSED) && ( pWindow->GetType() != WindowType::TREELISTBOX ) ) { - atk_wrapper_focus_tracker_notify(xAccessible); + atk_wrapper_notify_focus_change(xAccessible); } else { @@ -488,7 +484,7 @@ static void handle_menu_highlighted(::VclMenuEvent const * pEvent) uno::Reference< accessibility::XAccessibleContext > xContext ( xAccessible->getAccessibleContext() ); if( xContext.is() ) - atk_wrapper_focus_tracker_notify(xContext->getAccessibleChild(nPos)); + atk_wrapper_notify_focus_change(xContext->getAccessibleChild(nPos)); } } } |