• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: VWR-2261
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Tofu Linden
Reporter: Tofu Linden
Votes: 6
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
1. Second Life Viewer - VWR

Use GTK for Linux Viewer input handling, especially unicode input

Created: 29/Aug/07 10:28 AM   Updated: 10/Sep/09 10:16 AM
Component/s: Internationalization
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File GTK-20071111.tar.bz2 (35 kB)
2. Text File gtk-20071201.patch (145 kB)
3. Text File gtk-20080113.patch (174 kB)
4. Text File gtk-20080301.patch (167 kB)
5. Text File gtk-20081221.diff (140 kB)
6. Text File gtk-20081228.diff (4 kB)
7. Text File VWR-2261-2008-03-04.patch (168 kB)

Issue Links:
Relates

Last Triaged: 10/Sep/09 09:09 AM
Source Version: 1.19.0.4
Linden Lab Issue ID: DEV-2171
Patch attached: Patch attached


 Description  « Hide
GTK's support for Unicode input, particularly composition, is a lot better than SDL's. It may be possible to convince GTK to manage the main window's keyboard in preference to SDL, where GTK is available.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Alissa Sabre added a comment - 08/Sep/07 05:42 AM
Hmm.

I agree that GTK's immodule is far better than SDL's. The problem is that immodule API seems heavily depends on implementation details of GTK windowing mechanisms, and it is no trivial to make it run on LLUI components. We could port entire GTK on top of OpenGL surface (GTK can run on bare frame buffer hardware, so it is not impossible to do so, if you don't count the performance.) This approach is a good news for Linux users. However, for Windows and MacOS users, I don't think use of GTK is a fortune, because immodule can't fully support the modern features of Windows and MacOS input methods.

Another approach to improve the Linux users's Japanese input experiences is to drive SCIM directly. SCIM is yet another beast, but it is designed for more platform/environment neutral in mind.

It will be fun to play with it, anyway.


Alissa Sabre added a comment - 10/Oct/07 10:12 AM
I wrote a set of patches that demonstrates what we can do with good old XIM. I had to change both SDL and SL viewer (mostly LLwindowSDL class). It is available here ( http://alissa-sabre.cocolog-nifty.com/files/ots-20071008.tar.bz2 ) if you are interested.

Based on this experience, I concluded that this (i.e., SDL + XIM) is not the way to go. I agree we somehow switch to a modern input method interface. Although I'm still not 100% confortable with GTK immodule API, I have to agree that it is certainly a good candidate, especially provided that there are no better alternative available on Linux...


Alissa Sabre added a comment - 11/Nov/07 02:49 PM
I made some progress on this issue and produced a patch kit.

The file GTK-20071111.tar.bz2 contains the work in progess as a form of a patch against SL viewer 1.18.4.3. It replaces SDL with GtkGLExt to support GTK immodules. Detailed build information is included in the archive.

I think the patch kit is not suitable for merge into SL viewer's development branch yet, so I don't mark "Patch Attached" at this moment.


Alissa Sabre added a comment - 01/Dec/07 05:09 AM
I'm attaching my latest work on this issue as a patch: gtk-20071201.patch

This patch is against 1.18.5.3 source files. You first need to apply the patch ime-20071201.patch attached to VWR-250, then apply this gtk-20071201.patch.

See README contained in the gtk-20071111.tar.bz2 patch kit for other build details. (The patch files included in the gtk-20071111.tar.bz2 should not be applied when using gtk-20071201.patch.)

If you just want to try the patched viewer without compiling, you can download the binary from my site. It is available as:

http://alissa-sabre.cocolog-nifty.com/files/gtk-20071201-Linux.tar.bz2

Have fun.


Alissa Sabre added a comment - 13/Jan/08 06:06 AM
Well, I'm uploading another monthly_update of GTK immodule project. This patch, gtk-20080113.patch is against the 1.19.0 beta (76838) source. It now supports fullscreen resolution changes and adjustment of gamma correction value. No big changes on immodule handling. It still doesn't wok under a locale whose decimal point is not a period.

Have fun.


Rob Linden added a comment - 15/Feb/08 06:02 PM
Has anyone taken a look at Clutter? http://www.clutter-project.org/

It appears to be a close relative of Gtk+, and might be a more suitable solution.


Alissa Sabre added a comment - 01/Mar/08 03:17 AM
Rob, against what do you think Clutter is a "more suitalbe solution"? Correct me if I'm wrong, but I believe the current clutter lacks support for input method handling. Adapting it doesn't solve the problem that Japanese or Chinese speaker's problems.

Alissa Sabre added a comment - 01/Mar/08 03:18 AM
I updated the patch of the series. It is against 1.19.0.4. No big changes. Only small changes other than adapting to the latest viewer source. I believe I did all I can do. It have no further plan on this issue. It is up to LL's decision to take this patch or just trash it...

In this version (20080301), added an alternative workaround for locale issue (known as SL-13243) in wrapper.sh (the "secondlife" shell script), so that a user can start the viewer under a locale whose decimal digit is different from C locale. (We need to run GTK event loop under the user's prefered locale so that input methods work.) This is the biggest development in this version of the patch.

As always, it is not easy to produce an executable with this patch. You need more recent GTK than that contained in LL library bundle. It means you need to update other dependencies, too. It will be easier to follow STANDALONE build procedure described on the SL wiki than to replace files under linden/libraries directory. You will need slviewer-1.18.5.1-standalone_expat_includes.patch for VWR-2488 to do so. You also need to adjust linden/indra/newview/viewer_manifest.py apropriately.

I used Fedora 8 x86 and g++ 3.4 for development.

Have fun.


Alissa Sabre added a comment - 01/Mar/08 04:23 AM
I checked "Patch attached" since I believe the 20080301 version of the patch is stable enough for integration.

Tofu Linden added a comment - 04/Mar/08 04:51 AM
Thanks, Alissa.
I'm attaching a version of the same patch (minus SConstruct changes) with the conflicts resolved against the current release (~1.19.1RC).

Kazunori Takakura added a comment - 21/May/08 09:11 PM
Verified in 1.20.7 (87883) running Ubuntu Hardy Heron (8.04) that I am able to input Japanese (including Kanji) using XIM / Anthy. I am able to access the input field which pastes to the chat line in the viewer.

Yukinoroh Kamachi added a comment - 26/May/08 09:52 PM - edited
Kazunori, the japanese input DOES work but it is messy. In other software and OSes, it is done directly in the software window, "inline", and you can access the IME options. But the client as it is right now doesn't do that, the input is done in an external window then it is pasted to the client. That's what this feature request is about.

As a side effect here I'm experiencing bug VWR-6212 .


Tofu Linden added a comment - 27/May/08 01:42 PM
Hi Alissa,
Would you mind turning this into a LLWindowGTK which co-exists in the code with LLWindowSDL? Keeping both options around in the code for a while will really help to make the transition gentle. (And, I suspect, the final iteration may turn out to be a hybrid.)

I wonder, how would you feel about maintaining this in a sandbox in the public svn tree?


Soft Linden added a comment - 02/Oct/08 09:01 AM
@Alissa - pinging on the above, in case the last was missed

Alissa Sabre added a comment - 21/Dec/08 04:45 AM
I updated my GTK patch. The new one is gtk-20081221.diff. It includes necessary changes to cmake files, too.

Major changes from 20080301/20080304 version are:

  • It is now against 1.22 series of the viewer source code. (It is against 1.22.4 for the moment.)
  • The compiled binary has both SDL and GtkGL support. It uses GtkGL as default. Setting the environment variable LL_USE_SDL=1 switches to SDL based operation, which should be identical to the normal Linux viewer behaviour.
  • Handling of (no input method) keyboard input has been improved.

To compile the patched viewer, you need GtkGLExt header files under linde/libraries. (Or, you could do standalone build.) Please make sure you GTK header file versions are compatible with GtkGLExt's. When I build it, I copy distro supplied GTK related header files in /usr/include to appropriate directories under linde/libraries, overwriting LL supplied develop.py downloaded ones. Yes, there should be a better way. I'm too lazy to seek for one.

Have fun.


Tofu Linden added a comment - 22/Dec/08 10:30 AM
Thanks, Alissa, interesting reading.
A few comments:
  • Some methods are identical or very similar between LLWindowSDL vs GTK - probably these belong either in a common superclass or (easiest) common helper-code.
  • Runtime selection of SDL vs GTK is interesting but compile-time selection is still more desirable - that would make this mergeable sooner so, pragmatically, the distro-specific SL builds can start enabling GTK-only and we can get wider testing feedback before this gets enabled at all in Linden builds.
  • Please base patches on maint-viewer if you can - this is where Linux-specific changes (mostly) happen first. So, this is where this is most likely to land and it's the branch with the most GTK/SDL changes to sync/conflict against (for example, current maint-viewer has some copy-and-paste changes to support PRIMARY clipboard).

Feel free to clean up the poor semantics, uncertain comments and hackery of LLWindowSDL in your own LLWindowGTK instead of cloning it all over; LLWindowSDL has had many authors over time and grown organically - it's a stinking mess of coding styles, hackery and fuzzy semantics but it works (apart from good i18n support of course) which is why it doesn't get much cleanup.


Alissa Sabre added a comment - 27/Dec/08 11:41 PM
Tofu,

> Some methods are identical or very similar between LLWindowSDL vs GTK - probably these belong either in a common superclass or (easiest) common helper-code.

Yes, if we keep both forever. However, I expect that LLWindowSDL to disappear really soon. I'm relactant to make such changes for the moment.

> Runtime selection of SDL vs GTK is interesting but compile-time selection is still more desirable - that would make this mergeable sooner so, pragmatically, the distro-specific SL builds can start enabling GTK-only and we can get wider testing feedback before this gets enabled at all in Linden builds.

It is straight forward to make SDL-GtkGL switching a compile option, because LLWindow class uses the factory pattern (It's a Linden's feat, of course), and my LLWindowGTK is yet another subclass implementation of LLWindow. A patch, gtk-20081228.diff, is attached. It is against my gtk-20081221. The macro LL_SDL is for LLWindowSDL, and LL_GTKGL is for LLWindowGTK. (I didn't use LL_GTK for the purpose, because it is essentially for "SDL with GTK dialog boxes.") If you define both LL_SDL and LL_GTKGL, the runtime swithing is compiled. Selection of LL_SDL only, LL_GTKGL only, and both LL_SDL and LL_GTKGL is currently by manual editing of cmake/LLWindow.cmake. I have a feeling the selection should be through develop.py, although I have no idea how I can do so.

> Please base patches on maint-viewer if you can - this is where Linux-specific changes (mostly) happen first. So, this is where this is most likely to land and it's the branch with the most GTK/SDL changes to sync/conflict against (for example, current maint-viewer has some copy-and-paste changes to support PRIMARY clipboard).

I'm considering that.


Rob Linden added a comment - 29/Jan/09 01:52 PM
Pinged folks at Linden Lab

Tofu Linden added a comment - 12/Mar/09 03:55 PM
Hi - This should still be rebased against maint-viewer (or actually trunk at this point is fine). The requirement for a recent GTK and the uncommon GTKGLEXT is still a sticking-point - some users are definitely happily using distros without these - can you think of a workaround? One possibility is, we're probably going to be shipping a version of Qt 4.5 with future viewers, and Qt natively supports setting up GL contexts and probably everything else we need (right?), though that's a comparable amount of work again.

Yukinoroh Kamachi added a comment - 12/Mar/09 07:01 PM - edited
Tofu, if you want a good advice, stay away from Qt. Ever since I started using Linux, every time I try a Qt-based application, I have problems with its internationalization support: Japanese text displayed as ????????, keyboard dead keys (for French accentuated letters) not working, etc, etc. As someone who uses both Japanese and French in SL, those two are very important for me. GTK is the way to go for internationalization. I never have any trouble with GTK-based applications.

Yukinoroh Kamachi added a comment - 19/Mar/09 12:31 PM
Today as QAvimator, which uses the Qt libray to run, crashed when I tried to open a file from a folder containing non-latin characters, I remembered about my March 12th comment... It's as I said. Problems, problems, problems.

Tofu Linden added a comment - 24/Mar/09 11:42 AM
Do these problems still apply to Qt 4.5? Thanks.

Yukinoroh Kamachi added a comment - 24/Mar/09 06:22 PM
I don't have that version of Qt. I have 4.2.3. I can tell you however that I have given Qt applications a chance more than once since 4~5 years, every time with a different version, and every time I ran into internationalization problems. GTK has never given me any trouble. So I would think the newest version of GTK is still ahead of Qt for that. I think it's because it was built to support UTF-8 from the start.

My locale is ja_JP.UTF-8, by the way.


Alissa Sabre added a comment - 25/Mar/09 07:07 AM
Tofu,

I found that Qt 4.5 is very new and no major Linux distro supports it. 4.2, 4.3, or 4.4 are the Qt versions available in the latest versions of the major distributions.

Why are you so aggressive to use very new version of Qt, while you are very conservative to stay on the very old version of GTK?


Tofu Linden added a comment - 25/Mar/09 10:42 AM
Because (for another project) we'll be shipping the viewer with Qt 4.5 on all platforms anyway, so the system version will be irrelevant.

Alissa Sabre added a comment - 28/Mar/09 05:55 PM
Why you don't bundle GTK while you do Qt? What's the difference?

Tofu Linden added a comment - 30/Mar/09 10:44 AM
GTK has an incredibly longer ad-hoc dependancy chain.

Alissa Sabre added a comment - 04/Apr/09 07:24 PM
Hmm.

Then, how about making use of dynamic load (i.e., dlopen() et. al.) to access to modern GTK functions and/or GtkGLExt functions?

  • Keep both SDL based LLWindow code and GtkGLExt based LLWindow code. ALso keep dynamic switching code between two.
  • Remove all static references to GtkGLExt functions and modern GTK functions. Instead, use dynamic load mechanism to access to those functions.
  • When GtkGLExt based code is requested, the swithing code first makes sure the GTK versions and availability of GtkGLExt, and if the system lacks the required libraries, falls back to SDL based code.
  • The switching can be through an environment variable, or we could add a checkbox in Preferences... dialog box.

Is this acceptable to LL?


Tofu Linden added a comment - 06/Apr/09 12:11 PM
That does address the deployment concerns AFAICT - I like it.
I don't know if it will work out well in reality (I'm guessing that GTK is a bit dlopen-hostile like GStreamer is, needing some dirty hacks) but I'm interested in seeing.

So, one important question I think - do you have a feeling for how ABI-stable GtkGLExt is? (I was pleased to see that it is now maintained again.) GTK itself is fairly ABI-backwards-compatible. For the dlopen'ing of GtkGLExt, GtkGLExt has to be similarly stable or we need to rethink.


Dzonatas Sol added a comment - 10/Apr/09 07:25 PM
Gnome settled for GtkGLArea for the GL context, now named GdkGL:
http://bugzilla.gnome.org/show_bug.cgi?id=119189#c54

The support is official for the context, but they still leave the makers of GtkGLArea and what's left of GtkGLExt authors to work together for the higher end functions.

The gl context (from gtk) is only what is needed. They provide the source files (gdkgl.c/.h) to get the context.
http://svn.gnome.org/svn/gtkglarea/trunk/gtkgl/gdkgl.c
http://svn.gnome.org/svn/gtkglarea/trunk/gtkgl/gdkgl.h

Keyboard input could be routed through an eventbox instead of the default event handler. Gtk already has functions that take care of propagation when rerouted.

MainWindow->EventBox->GdkGL

Make the EventBox AppPaintable. Use the GL context created by GdkGL to draw into instead of the one now created by llwindow.

This way you don't need to worry about the rest of the functions gtkglext provides, and no redesign of the *draw() methods need to be done. You'll just need to redesign the keyboard input routines to queue from Gtk.EventBox instead of SDL.


Dzonatas Sol added a comment - 17/Apr/09 11:29 AM
In review of Alissa's patches (20081221, 20081228), it seems apparent there is question of how immodule is affected between grabs & event pumps. Under the implementation now with the embedded browsers, it seems like that question is if, for example, a hotkey would corrupt immodule sequences under pumped events.

Looks like Alissa already commented, in the patch, about the current design.

Instead of the EventBox I noted above (which can't force grabs, but the window can), it seems like a possible interim solution is to pass a new GtkWindow(popup) to gecko and use that for the embedded renders, which could either be copied back to the main gl context as the window stays hidden or shown as-is ontop of gl (maybe transient). This solution probably would require more design changes then LL would be willing to handle, I bet. I'm not an expert on immodule to test all options, but this is one way to separate keyboard contexts with built-in features of gtk. The main window can forward events to the subwindow if needed, which is kind-of how the other suggested solutions above work.

Right now I have a GTK/GLArea (Gdkgl), which provides the render surface for gl context instead of SDL. Allissa's llkeyboardgtk code is helpful here to glue the rest of the code together. I can't use the design of llwindowgtk since it grabs everything. I have other focus points in my window besides just a single gl area. Hence, my suggestion above.