tdf#163792 gtk3: Don't always focus combobox when its popup closes
Since commit405cf00e48
Author: Michael Weghorn <m.weghorn@posteo.de> Date: Tue May 28 11:50:12 2024 +0200 related tdf#160971 gtk3 a11y: Keep new combobox value , closing an (editable) combobox like the font size one in the Writer formatting toolbar resulted in the combobox's entry having focus, while the focus was set to the document before that commit. Make this work as expected (again), by making grabbing the focus conditional in 2 places: 1) In GtkInstanceComboBox::signal_popup_toggled, only set the focus to the GtkEntry of the custom combobox implementation if the child focus is already inside of the combobox. As I understand it, the intended logic is "move focus from the combo box's button to its entry", not "unconditionally grab the focus". This also matches what the gtk4 implementation does. Sync the comment from the gtk4 implementation, which explicitly mentions the case of the font combobox in the toolbar (which behaves the same as the font size one in that regard) where focus should not be grabbed. 2) In GtkComboBox::menu_toggled, only explicitly set focus to the toggle button if the combo box is located inside of a popup. This is the same condition used to grab all keyboard events. The code to do both was introduced in commit131c1c7da8
Date: Sun Nov 21 19:53:47 2021 +0000 Related: tdf#145786 cooperate between our own grabs whose commit message only explicitly mentions grabs for popups. The scenarios described in the commit message still work as expected with GDK_BACKEND=x11. With this in place, focus now moves to the document as expected when clicking on a combobox entry in the popup for the font size combobox in Writer's formatting toolbar, while clicking an entry in any of the comboboxes in e.g. Writer's "Format" -> "Character" dialog's "Font" tab still results in the entry of the combobox getting focus. Change-Id: Ib07b034f8327dab19a2264ae3ed8e20ea918dd89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176713 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
parent
b223a06401
commit
4e770803c6
1 changed files with 15 additions and 6 deletions
|
@ -21395,8 +21395,10 @@ private:
|
|||
GdkSurface* pParentSurface = pParent ? widget_get_surface(pParent) : nullptr;
|
||||
void* pParentIsPopover = pParentSurface ? g_object_get_data(G_OBJECT(pParentSurface), "g-lo-InstancePopup") : nullptr;
|
||||
if (pParentIsPopover)
|
||||
{
|
||||
do_grab(m_pToggleButton);
|
||||
gtk_widget_grab_focus(m_pToggleButton);
|
||||
gtk_widget_grab_focus(m_pToggleButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -21442,11 +21444,18 @@ private:
|
|||
ComboBox::signal_popup_toggled();
|
||||
if (!m_bPopupActive && m_pEntry)
|
||||
{
|
||||
disable_notify_events();
|
||||
//restore focus to the GtkEntry when the popup is gone, which
|
||||
//is what the vcl case does, to ease the transition a little
|
||||
gtk_widget_grab_focus(m_pEntry);
|
||||
enable_notify_events();
|
||||
if (has_child_focus())
|
||||
{
|
||||
// restore focus to the GtkEntry when the popup is gone, which
|
||||
// is what the vcl case does, to ease the transition a little,
|
||||
// but don't do it if the focus was moved out of togglebutton
|
||||
// by something else already (e.g. font combobox in toolbar
|
||||
// on a "direct pick" from the menu which moves focus into
|
||||
// the main document
|
||||
disable_notify_events();
|
||||
gtk_widget_grab_focus(m_pEntry);
|
||||
enable_notify_events();
|
||||
}
|
||||
|
||||
// tdf#160971: For some reason, the tree view in the no longer visible
|
||||
// popup still incorrectly assumes it has focus in addition to the now
|
||||
|
|
Loading…
Reference in a new issue