8000 Surrounding text does not give information on the text selection when Wayland input is used · Issue #2760 · ibus/ibus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Surrounding text does not give information on the text selection when Wayland input is used #2760
Open
@mike-fabian

Description

@mike-fabian

Distribution and Version

Fedora 42

Desktop Environment and Version

gnome-shell-48.1-1.fc42.x86_64

Session Type

Wayland

Application and Version

gedit-48.1-1.fc42.x86_64 gnome-text-editor-48.2-1.fc42.x86_64 firefox-138.0.3-1.fc42.x86_64

IBus version

ibus-1.5.32-1.fc42.x86_64

Issue Description

In a Gnome Wayland session when I select some text in gedit (Gtk3) or gnome-text-editor (Gtk4) and then call IBus.Engine.get_surrounding_text() I get always the same cursor and anchor positon, i.e. it looks as if no text was selected:

mfabian@f42:~$ tail -F .local/share/ibus-typing-booster/debug.log | grep selection
2025-05-17 19:48:08,912 hunspell_table.py line 7543 _handle_hotkeys DEBUG: matched command=show_selection_info
2025-05-17 19:48:08,913 hunspell_table.py line 6794 _command_show_selection_info DEBUG: surrounding_text = ['gedit', 5, 5]
2025-05-17 19:48:08,913 hunspell_table.py line 6799 _command_show_selection_info DEBUG: selection_text = ''
2025-05-17 19:48:08,913 hunspell_table.py line 6801 _command_show_selection_info INFO: Nothing selected.
2025-05-17 19:48:18,520 hunspell_table.py line 7543 _handle_hotkeys DEBUG: matched command=show_selection_info
2025-05-17 19:48:18,520 hunspell_table.py line 6794 _command_show_selection_info DEBUG: surrounding_text = ['gnome-text-edito
r', 17, 17]
2025-05-17 19:48:18,520 hunspell_table.py line 6799 _command_show_selection_info DEBUG: selection_text = ''
2025-05-17 19:48:18,521 hunspell_table.py line 6801 _command_show_selection_info INFO: Nothing selected.
2025-05-17 19:48:22,866 hunspell_table.py line 7543 _handle_hotkeys DEBUG: matched command=show_selection_info
2025-05-17 19:48:22,866 hunspell_table.py line 6794 _command_show_selection_info DEBUG: surrounding_text = ['firefox', 0, 0]
2025-05-17 19:48:22,866 hunspell_table.py line 6799 _command_show_selection_info DEBUG: selection_text = ''
2025-05-17 19:48:22,866 hunspell_table.py line 6801 _command_show_selection_info INFO: Nothing selected.

The code which prints the above log messages looks like this:

    def _command_show_selection_info(self) -> bool:
        '''Show info about the currently selected text'''
        if not self.client_capabilities & itb_util.Capabilite.SURROUNDING_TEXT:
            LOGGER.info('Surrounding text not supported, cannot get selection')
            return False
        surrounding_text = self.get_surrounding_text()
        if not surrounding_text:
            LOGGER.debug('Surrounding text object is None. '
                         'Should never happen.')
            return False
        text = surrounding_text[0].get_text()
        cursor_pos = surrounding_text[1]
        anchor_pos = surrounding_text[2]
        LOGGER.debug(
            'surrounding_text = [%r, %s, %s]', text, cursor_pos, anchor_pos)
        selection_start = min(cursor_pos, anchor_pos)
        selection_end = max(cursor_pos, anchor_pos)
        selection_text = text[selection_start:selection_end]
        LOGGER.debug('selection_text = %r', selection_text)
        if selection_text == '':
            LOGGER.info('Nothing selected.')
            return False
[... more stuff...]

If I do the same test in a Gnome Xorg session, I get the correct selection in gedit and gnome-text-editor, it fails only in firefox in a Gnome Xorg session.

In the Gnome Xorg session, gedit uses the Gtk3 ibus input module and gnome-text-editor but uses the Gtk4 ibus input module. In the Gnome Wayland session, both gedit and gnome-text-editor use the Wayland input (ibus passes gnome-shell on focus in).

So think there is something wrong with getting surrounding text when using Wayland/gnome-shell input.

I am not sure whether this is an ibus or a mutter problem so I report it first here.

If it is not ibus but mutter or something else, I can move the issue there.

Steps to Reproduce

- Use ibus-typing-booster >= 2.27.54
- Define a keybinding for the command `show_selection_info` in the keybindings tab of the setup tool. For example `F2` works.
- in a terminal, follow the log file and grep for the `show_selection_info` function: `tail -F .local/share/ibus-typing-booster/debug.log | grep selection`
- Start gedit, type something, select text in gedit and hit `F2` (or whatever you defined as a keybinding)
- In the terminal one sees that the cursor positon an anchor position reported by `get_surrounding_text` are always identical, no matter whether there is a selection or not.

When doing the same test on any Xorg session (Gnome, XFCE, i3, ...) the cursor position and anchor position returned by `get_surrounding_text` correctly show the selection when using gedit or gnome-text-editor (but not when using firefox, different problem maybe ...)

Can you reproduce your problem when you restart ibus-daemon? (yes / no)

Yes.

Do you see any errors when you run ibus-daemon with the verbose option?

No.

Can you reproduce your problem with a new user account instead of the

current your account? (yes / no)

Yes

Add any other context about the problem here.

Peek.2025-05-17.19-44.mp4

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0