After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705779 - The text in the search-entry isn't aligned to right in RTL text
The text in the search-entry isn't aligned to right in RTL text
Status: RESOLVED FIXED
Product: clutter
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: clutter-maint
clutter-maint
Depends on:
Blocks:
 
 
Reported: 2013-08-11 00:21 UTC by Yosef Or Boczko
Modified: 2014-03-04 12:18 UTC
See Also:
GNOME target: ---
GNOME version: 3.11/3.12


Attachments
Screenshot - English ('Type to search...') (770.53 KB, image/png)
2013-08-11 00:21 UTC, Yosef Or Boczko
  Details
Screenshot - Hebrew (768.28 KB, image/png)
2013-08-11 00:23 UTC, Yosef Or Boczko
  Details
Make the search entry behave better in RTL locales (4.41 KB, patch)
2013-08-26 22:27 UTC, Matthias Clasen
needs-work Details | Review
Screencast - GNOME Shell with the patch (992.18 KB, video/ogg)
2013-09-08 17:16 UTC, Yosef Or Boczko
  Details
Make the search entry behave better in RTL locales (4.39 KB, patch)
2013-09-10 20:05 UTC, Florian Müllner
committed Details | Review
st: Fix spacing on right icon in entry (857 bytes, patch)
2013-09-10 20:05 UTC, Florian Müllner
committed Details | Review
text: Consider text direction when computing layout offsets (1.93 KB, patch)
2013-09-10 20:08 UTC, Florian Müllner
committed Details | Review
Screenshot - it very good (960.66 KB, image/png)
2013-09-11 17:55 UTC, Yosef Or Boczko
  Details
Screenshot - RTL character (981.00 KB, image/png)
2013-09-11 18:51 UTC, Yosef Or Boczko
  Details
Screenshot - LTR character (964.34 KB, image/png)
2013-09-11 18:51 UTC, Yosef Or Boczko
  Details
text: Consider text direction according to the content of the text (1002 bytes, patch)
2013-11-17 15:29 UTC, Yosef Or Boczko
needs-work Details | Review
text: Discover the direction of the contents (1.72 KB, patch)
2014-03-03 18:07 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
text: Use the resolved text direction (1.48 KB, patch)
2014-03-03 19:18 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
test-text-field with CLUTTER_TEXT_DIRECTION=rtl (79.71 KB, image/png)
2014-03-03 19:20 UTC, Emmanuele Bassi (:ebassi)
  Details
backend: Add private accessor for the keymap direction (2.16 KB, patch)
2014-03-03 23:26 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
x11: Add keymap direction query (8.36 KB, patch)
2014-03-03 23:27 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
text: Use the keymap direction when focused (1.88 KB, patch)
2014-03-03 23:27 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Yosef Or Boczko 2013-08-11 00:21:08 UTC
Created attachment 251280 [details]
Screenshot - English ('Type to search...')

The text in the search-entry isn't aligned to right in RTL text:
Text LTR should to aligned to Left,
and text RTL (e.g. Hebrew string) should to aligned to Right.

Text RTL * isn't * aligned to right in RTL text.

See screenshots.
Comment 1 Yosef Or Boczko 2013-08-11 00:23:45 UTC
Created attachment 251281 [details]
Screenshot - Hebrew

'Type to search...' in Hebrew is 'יש להקליד כדי לחפש...', and this need
to be alignment to right
Comment 2 Matthias Clasen 2013-08-17 15:50:24 UTC
I guess the icon should go to the other side as well ?
Comment 3 Yosef Or Boczko 2013-08-17 18:35:14 UTC
(In reply to comment #2)
> I guess the icon should go to the other side as well ?

Yes, similar to GtkSearchEntry.
Comment 4 Matthias Clasen 2013-08-26 22:27:07 UTC
Created attachment 253194 [details] [review]
Make the search entry behave better in RTL locales

It is expected that the primary and secondary icons in entries
change places in RTL locales. When doing so, the edit-clear
icon must be replaced by an rtl variant too.

http://bugzilla.gnome.org/show_bug.cgi?id=705779
Comment 5 Matthias Clasen 2013-08-26 22:29:26 UTC
This is not quite sufficient - it looks to me as if ClutterText is not setting the base direction of the PangoLayout properly. Ie the equivalent of this code snipplet:

      if (gtk_entry_get_display_mode (entry) == DISPLAY_NORMAL)
        pango_dir = pango_find_base_dir (display, n_bytes);
      else
        pango_dir = PANGO_DIRECTION_NEUTRAL;

      if (pango_dir == PANGO_DIRECTION_NEUTRAL)
        {
          if (gtk_widget_has_focus (widget))
            {
              GdkDisplay *display = gtk_widget_get_display (widget);
              GdkKeymap *keymap = gdk_keymap_get_for_display (display);
              if (gdk_keymap_get_direction (keymap) == PANGO_DIRECTION_RTL)
                pango_dir = PANGO_DIRECTION_RTL;
              else
                pango_dir = PANGO_DIRECTION_LTR;
            }
          else
            {
              if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
                pango_dir = PANGO_DIRECTION_RTL;
              else
                pango_dir = PANGO_DIRECTION_LTR;
            }
        }

      pango_context_set_base_dir (gtk_widget_get_pango_context (widget),
                                  pango_dir);
Comment 6 Matthias Clasen 2013-09-08 17:07:30 UTC
ping ? some review or reaction would be nice here.
Comment 7 Yosef Or Boczko 2013-09-08 17:16:13 UTC
Created attachment 254424 [details]
Screencast - GNOME Shell with the patch
Comment 8 Florian Müllner 2013-09-08 18:10:59 UTC
Review of attachment 253194 [details] [review]:

::: js/ui/viewSelector.js
@@ +86,3 @@
         this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
                                                    icon_name: 'edit-find-symbolic' }));
+        if (this._entry.get_text_direction() == ClutterTextDirection.RTL) {

Style nit: no braces

::: src/st/st-entry.c
@@ +442,3 @@
     {
+      clutter_actor_get_preferred_width (left_icon, -1, NULL, &icon_w);
+      clutter_actor_get_preferred_height (left_icon, -1, NULL, &icon_h);

As you are touching this anyway, maybe use clutter_actor_get_preferred_size() now?
Comment 9 Yosef Or Boczko 2013-09-09 08:00:16 UTC
(In reply to comment #7)
> Created an attachment (id=254424) [details]
> Screencast - GNOME Shell with the patch

Note: gnome-shell freez in the end of the video.
I recorded from other tty...
Comment 10 Florian Müllner 2013-09-09 10:06:14 UTC
Review of attachment 253194 [details] [review]:

Sorry I didn't catch this before.

Also the text itself should be right-aligned as well (priv->entry in allocate)

::: js/ui/viewSelector.js
@@ +86,3 @@
         this._entry.set_primary_icon(new St.Icon({ style_class: 'search-entry-icon',
                                                    icon_name: 'edit-find-symbolic' }));
+        if (this._entry.get_text_direction() == ClutterTextDirection.RTL) {

It's Clutter.TextDirection, not ClutterTextDirection
Comment 11 Matthias Clasen 2013-09-09 13:56:06 UTC
> Also the text itself should be right-aligned as well (priv->entry in allocate)

That is what I was talking about in comment 5: set the base direction of the PangoLayout. I fear that has to be done inside clutter.

I would appreciate if you could try to finish this up, I'm not that much of shell / clutter developer, I merely wanted to push this along...
Comment 12 Florian Müllner 2013-09-10 20:05:18 UTC
Created attachment 254624 [details] [review]
Make the search entry behave better in RTL locales

It is expected that the primary and secondary icons in entries
change places in RTL locales. When doing so, the edit-clear
icon must be replaced by an rtl variant too.

http://bugzilla.gnome.org/show_bug.cgi?id=705779
Comment 13 Florian Müllner 2013-09-10 20:05:29 UTC
Created attachment 254625 [details] [review]
st: Fix spacing on right icon in entry
Comment 14 Florian Müllner 2013-09-10 20:08:01 UTC
Created attachment 254626 [details] [review]
text: Consider text direction when computing layout offsets

Currently this is only the case when the actor's x-expand/x-align
flags have been set and clutter_text_compute_layout_offsets() is
used.
Comment 15 Matthias Clasen 2013-09-11 01:21:05 UTC
Yosef, could you give these patches a try ?
Comment 16 Yosef Or Boczko 2013-09-11 17:55:34 UTC
Created attachment 254725 [details]
Screenshot - it very good
Comment 17 Jasper St. Pierre (not reading bugmail) 2013-09-11 18:12:33 UTC
Review of attachment 254625 [details] [review]:

OK.
Comment 18 Jasper St. Pierre (not reading bugmail) 2013-09-11 18:12:56 UTC
Review of attachment 254624 [details] [review]:

OK.
Comment 19 Florian Müllner 2013-09-11 18:49:07 UTC
Comment on attachment 254624 [details] [review]
Make the search entry behave better in RTL locales

Attachment 254624 [details] pushed as 1b6090f - Make the search entry behave better in RTL locales
Comment 20 Florian Müllner 2013-09-11 18:49:21 UTC
Comment on attachment 254625 [details] [review]
st: Fix spacing on right icon in entry

Attachment 254625 [details] pushed as 954d262 - st: Fix spacing on right icon in entry
Comment 21 Yosef Or Boczko 2013-09-11 18:49:59 UTC
I see now more problem, in the search entry with the patches.

Just string which start in RTL character should to be align to right (e.g.
string
start with word in Hebrew), string which start with LTR character (e.g. string
start with word in English), should to be align to left.

Now also string start with LTR character is align to right, and is wrong.
Comment 22 Yosef Or Boczko 2013-09-11 18:51:17 UTC
Created attachment 254729 [details]
Screenshot - RTL character
Comment 23 Yosef Or Boczko 2013-09-11 18:51:49 UTC
Created attachment 254730 [details]
Screenshot - LTR character
Comment 24 Florian Müllner 2013-09-11 19:21:36 UTC
(In reply to comment #21)
> Now also string start with LTR character is align to right, and is wrong.

Yes, it's based on the base direction, not the direction of the content. I don't see any API in Pango to change this in a non-intrusive way, so this is likely out of scope for 3.10; in any case, the remaining problem is a Clutter issue, so reassigning.
Comment 25 Emmanuele Bassi (:ebassi) 2013-09-11 19:25:08 UTC
Review of attachment 254626 [details] [review]:

looks okay to me.
Comment 26 Florian Müllner 2013-09-11 19:38:11 UTC
It doesn't address comment #21 in any way though ...
Comment 27 Emmanuele Bassi (:ebassi) 2013-09-11 19:46:16 UTC
(In reply to comment #26)
> It doesn't address comment #21 in any way though ...

I know, but half-right is better than wholly wrong.
Comment 28 Yosef Or Boczko 2013-09-11 19:52:36 UTC
(In reply to comment #27)
> (In reply to comment #26)
> > It doesn't address comment #21 in any way though ...
> 
> I know, but half-right is better than wholly wrong.

I agree.

Now, for example, in 'Type command' (Alt+F2) the command is
always align to right, and it very bad.

I think need to look how it implemented in GtkEntry or in GtkTextView.
Comment 29 Florian Müllner 2013-09-11 19:54:07 UTC
Comment on attachment 254626 [details] [review]
text: Consider text direction when computing layout offsets

Attachment 254626 [details] pushed as 986e46d - text: Consider text direction when computi
ng layout offsets
 
Yeah. Leaving bug open for the missing bits ...
Comment 30 Yosef Or Boczko 2013-09-11 20:05:21 UTC
Note: before the patches (exactly - the patch in clutter),
the text is was always align to left, so I think not need
to reverse him :-)
Comment 31 Matthias Clasen 2013-09-19 13:29:24 UTC
moving off the blocker list
Comment 32 Yosef Or Boczko 2013-11-17 15:29:08 UTC
Created attachment 260039 [details] [review]
text: Consider text direction according to the content of the text
Comment 33 Emmanuele Bassi (:ebassi) 2014-02-07 10:31:59 UTC
Review of attachment 260039 [details] [review]:

I don't think this is enough.

GtkEntry checks the mode of the entry, i.e. whether the entry is in password or in normal mode, to check if the PangoDirection should be neutral.

in case the direction is neutral, it also uses whether the entry has focus, and the direction of the keymap.

all of this is done when creating the PangoLayout, not when drawing it.
Comment 34 Yosef Or Boczko 2014-02-20 21:37:14 UTC
I try to set the direction in clutter_text_create_layout_no_cache()
like you sad in IRC (some times ago), and this look like there isn't
any affect on the real direction of the text.

This look like just what I do in clutter_text_paint() is affect on the
direction of the text.

Any idea?
I really want to see this fix for the next stable version, and also
if this not complete, like my patch, but if it better than what we
have now.
Comment 35 Emmanuele Bassi (:ebassi) 2014-02-20 22:38:27 UTC
(In reply to comment #34)
> I try to set the direction in clutter_text_create_layout_no_cache()
> like you sad in IRC (some times ago), and this look like there isn't
> any affect on the real direction of the text.
>
> This look like just what I do in clutter_text_paint() is affect on the
> direction of the text.

do you have a patch that I can test or review? otherwise I'll have to write my own.
 
> Any idea?
> I really want to see this fix for the next stable version, and also
> if this not complete, like my patch, but if it better than what we
> have now.

I'd rather have a working and complete approach. we still have plenty of time before the stable release.
Comment 36 Yosef Or Boczko 2014-02-20 22:42:16 UTC
(In reply to comment #35)
> (In reply to comment #34)
> > I try to set the direction in clutter_text_create_layout_no_cache()
> > like you sad in IRC (some times ago), and this look like there isn't
> > any affect on the real direction of the text.
> >
> > This look like just what I do in clutter_text_paint() is affect on the
> > direction of the text.
> 
> do you have a patch that I can test or review? otherwise I'll have to write my
> own.

Now already not, what I had deleted after updated clutter from git (I never
remember to hack in a different folder than the one I build for my system,
this not the first code I lose :-().
> 
> > Any idea?
> > I really want to see this fix for the next stable version, and also
> > if this not complete, like my patch, but if it better than what we
> > have now.
> 
> I'd rather have a working and complete approach. we still have plenty of time
> before the stable release.

Me too.
What I tried myself to solve all the cases I think.
Comment 37 Emmanuele Bassi (:ebassi) 2014-03-03 18:07:32 UTC
Created attachment 270826 [details] [review]
text: Discover the direction of the contents

We should set the direction on the PangoContext when creating a
PangoLayout based on a best effort between the contents of the text
itself and the text direction of the widget, in case that fails.
Comment 38 Emmanuele Bassi (:ebassi) 2014-03-03 19:18:17 UTC
Created attachment 270838 [details] [review]
text: Use the resolved text direction

Now that we compute the effective text direction when creating the Pango
layout, we should also use it when painting it.
Comment 39 Emmanuele Bassi (:ebassi) 2014-03-03 19:20:59 UTC
Created attachment 270839 [details]
test-text-field with CLUTTER_TEXT_DIRECTION=rtl

result after applying both attachment 270826 [details] [review] and attachment 270838 [details] [review]
Comment 40 Emmanuele Bassi (:ebassi) 2014-03-03 23:26:50 UTC
Created attachment 270852 [details] [review]
backend: Add private accessor for the keymap direction

We need to ask the backend (wherever possible) for the direction of the
current keymap.
Comment 41 Emmanuele Bassi (:ebassi) 2014-03-03 23:27:02 UTC
Created attachment 270853 [details] [review]
x11: Add keymap direction query

We should use the Xkb API to query the direction of the key map,
depending on the group. To get a valid result we need to go over
the Unicode equivalents of the key symbols for each group, so we
should cache the result.

The code used to query and cache the key map direction is taken
from GDK.
Comment 42 Emmanuele Bassi (:ebassi) 2014-03-03 23:27:12 UTC
Created attachment 270854 [details] [review]
text: Use the keymap direction when focused

If the ClutterText actor has key focus then we should ask for the
direction of the key map, instead of the direction of the actor.
Comment 43 Emmanuele Bassi (:ebassi) 2014-03-04 01:39:34 UTC
pushed and released as part of Clutter 1.17.6; feel free to re-open if there are further issues.

before 1.18 I'll make the same changes to the GDK and evdev/libinput backends.
Comment 44 Yosef Or Boczko 2014-03-04 11:48:08 UTC
Thanks Emmanuele!

I see just more one thing:
When there isn't text and the entry is focused,
the position of the cursor is always on the left size,
also if the keyword layout is Hebrew (which need to
show the cursor on the right side).

But generally it amazing, thanks!
Comment 45 Emmanuele Bassi (:ebassi) 2014-03-04 12:12:26 UTC
we do bail out early if there's no text; it'll need another fix so we align the cursor with the right text direction. I'll open a new bug, this one has become fairly unwieldy.
Comment 46 Emmanuele Bassi (:ebassi) 2014-03-04 12:18:40 UTC
filed bug 725650 - will work on it ASAP.