Closed Bug 1844959 Opened 3 years ago Closed 7 months ago

Implement GTK Emoji Chooser

Categories

(Core :: Widget: Gtk, enhancement, P3)

Firefox 115
enhancement

Tracking

()

RESOLVED FIXED
150 Branch
Tracking Status
relnote-firefox --- 150+
firefox150 --- fixed

People

(Reporter: calestyo, Assigned: stransky)

References

(Blocks 1 open bug)

Details

(Keywords: helpwanted, webcompat:platform-bug)

User Story

user-impact-score:60

Attachments

(3 external files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0

Steps to reproduce:

GTK supports a native Emoji Chooser, which should already work with GTK 3 used by Firefox (on Linux) and is activated by pressing Ctrl-. or Ctrl-; .

Expected results:

Given that Emojis are used quite often when entering text on websites, it would be nice if Firefox could enable support for that.

The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core
Priority: -- → P3

I guess it would be similar to GtkFileDialog implementation:
https://searchfox.org/mozilla-central/source/widget/gtk/nsFilePicker.cpp

It's implemented by GtkEmojiChooser widget.

Keywords: helpwanted

On Firefox Nightly, currently 129.0a1 (2024-07-02) (64-bit), pressing control+. for the GTK emoji picker renders Firefox unusable.

It doesn't crash, but everything grinds to a complete halt until killed.

Flags: needinfo?(stransky)
Assignee: nobody → jhorak

The problem is that we create the emoji widget as a child of hidden GtkEntry and not the visible one.

Assignee: jhorak → stransky
Duplicate of this bug: 1716012
Duplicate of this bug: 1646965
Duplicate of this bug: 1576353

Explicit emoji popover is available in Gtk4. Unfortunately the widget is not exported in gtk3. We'd need to pass correct widget to it but I'm not sure how to handle the emoji position for the GtkWindow.

Looked at it and there are two issues here. First the popup is popover type and after CTRL+. is invoked but struck in waiting-to-show state. Perhaps due to hidden parent GtkEntry widget. But we may take Gtk3 widget implementation and ship that as embedded widget. But we don't have exact location where the widget may be placed - we use only one nsWindow and GtkEntry is used for key binding only.

I expected Gtk4 may help here but it can't - the main issue is popup placement which we need to solve.

There's a WIP which created keybinding entry as child of mozcontainer which tricks Gtk to show it as a child of nsWindow which makes it visible after CTRL+. But it doesn't insert the selected emoji to entry and also needs to be placed according to focused field.

Emilio, do you know if we can get position of input field (if that's active?) on widget? I guess we'd need to load it from layout or so?
Thanks.

Flags: needinfo?(emilio)

Can you add the emoji picker as a child of mShell rather than mContainer? That seems like it would work just as well and probably be simpler, right? But yeah, to your question, we have two kinds of precedent for this, I think:

  • The IME popup.
  • The context menu shortcut (Shift + F10).

I think this should work similarly to one of the two.

Right now the context menu key event goes through the whole event system, maybe this would be more similar to an IME feature, specially since we only care about this for composition?

Maybe Masayuki has thoughts on which approach might work better?

Flags: needinfo?(emilio) → needinfo?(masayuki)

(In reply to Emilio Cobos Álvarez [:emilio] from comment #14)

Can you add the emoji picker as a child of mShell rather than mContainer? That seems like it would work just as well and probably be simpler, right?

AFIAK mShell is GtkWindow and it implements GtkBin which allows to hold only one child.

But yeah, to your question, we have two kinds of precedent for this, I think:

  • The IME popup.

Do you know how the IME popup is issued?

  • The context menu shortcut (Shift + F10).

That popup looks great!

I think the picker should be around the caret. If so, you can get the position with a query content event like this:
https://searchfox.org/firefox-main/rev/133582f487ff8291ec10bd524db52db0b8ed363e/widget/gtk/IMContextWrapper.cpp#2970-3009

And you can get current caret offset in the flattened text content in the editor with:
https://searchfox.org/firefox-main/rev/133582f487ff8291ec10bd524db52db0b8ed363e/widget/gtk/IMContextWrapper.cpp#3315-3326

Flags: needinfo?(masayuki)

Thanks, the patch here works somehow but throws various Gtk related warnings due to GtkEntry put to more containers. I think we may use general GtkEntry/TextView for binding and if the emoji chooser is issues, we may create and put dedicated widgets to focused nsWindow.

That solution ensures we don't create redundant widgets.

Flags: needinfo?(stransky)
Attachment #9542296 - Attachment description: WIP: Bug 1844959 [Linux] Very ugly emoji patch → Bug 1844959 [Linux] Add emoji picker support r?emilio

The patch above works but needs to fix one last thing - when emoji picker is selected we hide cursor. The emoji picker is considered as cursor input and we hide cursor for it. Unfortunately emoji picker doesn't have a signal when emoji is not selected - only when it's picked - so I need to find a way how to restore 'hide cursor' state when emoji is not selected.

We may also add a pref to disable it as it may break some scenarios.

Summary: support GTK Emoji Chooser → Implement GTK Emoji Chooser for toplevel windows

The patch here implements emoji for toplevel windows only. We may consider to add support for popups too if that's requested.

Summary: Implement GTK Emoji Chooser for toplevel windows → Implement GTK Emoji Chooser
User Story: (updated)
Status: UNCONFIRMED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Duplicate of this bug: 1452036

:stransky, could you consider nominating this for a release note? (Process info)

Flags: needinfo?(stransky)

Release Note Request (optional, but appreciated)
[Why is this notable]: Implements Gtk Emoji picker dialog, allows to insert emoji when Gtk key binding is activated (usually CRTL+.)
[Affects Firefox for Android]: none
[Suggested wording]:
[Links (documentation, blog post, etc)]:

relnote-firefox: --- → ?
Flags: needinfo?(stransky)

Thanks, added to the Fx150 nightly release notes, please allow 30 minutes for the site to update.

QA Whiteboard: [qa-triage-done-c151/b150]

150 just hit Debian unstable,... while the chooser works in principle. I do see some weird graphic effects every time it appears and disappears, in particular, over the whole size of the chooser widget the background image "shines" through.

May of course be an issue in X, GTK, or Cinnamon's composer,... but at least no such thing would happen with other programs that do support the emoji chooser (like gedit).

Also it seems, that the first time on a window that I make the chooser pop up, it's not only the background that shows through but there's some "flickering" effect. But this is gone when I do it again on the same window (even if it's on another tab of that, as far as I can see).

Yes, that's correct - and it's due to the fuzzy implementation where custom and X11 rendering is mixed. Only 'fix' is to disable it on X11 but I think it's still worth regardless of the flickering (or we can disable the pref by default on X11 and leave users to turn it on).

Ah I see. Well please leave it, better that than nothing and X is anyway slowly on it's way out.

I'd even say don't disable it per default. Those people who use it most likely want it, those who don't aren't affected by that graphics glitches anyway.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: