[squeak-dev] International text input on X11

Yoshiki Ohshima Yoshiki.Ohshima at acm.org
Sun May 15 20:29:50 UTC 2016

(if you see this twice but with a difference, I'm sorry.)

Hi, David,

At Sun, 15 May 2016 00:58:34 -0400,
David T. Lewis wrote:
> On Sat, May 14, 2016 at 07:44:29AM -0700, Eliot Miranda wrote:
> > Hi Yoshiki,
> > 
> > > On May 13, 2016, at 9:04 PM, Yoshiki Ohshima <Yoshiki.Ohshima at acm.org> wrote:
> > > 
> > > Thanks!  I don't have the environment right now, but I'll follow this.
> > > But adding ImmX11Plugin (back again) seems to be right thing to do.
> > > If I'm not mistaken, this does not actually involve the VMMaker?
> > 
> > Hopefully :-). The Cog build tree is designed to put control on the set of plugins to compile into the hands of a particular build.  Plugins are generated to src/plugins, and the idea is for VMMaker to generate as many of them as can be generated.  Then to specify what set of plugins to compile into a VM simply edit the plugins.int & plugins.ext in buildOSNNProc/flavour, eg build.linuxARM/squeak.cog.spur/{plugins.int,plugins.ext}.
> > 
> > So provided src/plugins/ImmX11Plugin/ImmX11Plugin.c exists (on my phone right now, will check soon) all you need to do is edit the relevant plugins.int & plugins.ext.
> > 
> Yoshiki,
> I have done some additional testing, and I think that on Linux the ImmX11Plugin
> will work without any code changes at all :-)
> I was expecting that some code changes would be needed to enable the
> primSetCompositionWindowPosition() function in ImmX11Plugin to call 
> setCompositionWindowPosition() in the vm-display-X11 VM module. But I
> tried compiling ImmX11Plugin as an external module, and running under
> a gdb debugger. I can confirm that the ImmX11Plugin is calling the external
> setCompositionWindowPosition() function successfully.
> I cannot test this with Cog due to issues with gcc/autotools on the Ubuntu
> system I am using now, but there should be no differences in doing this
> on Cog. So I think that if you add ImmX11Plugin to plugins.ext as Eliot
> describes, then the plugin probably will work for Raspbian without any
> other changes.

It indeed was to my surprise to find out that ImmX11Plugin was in the
distribution!  It even has more than two primitives I wrote while ago.

I can confirm that many things are working; but it still does require
some code change in the VM and in the image.

Mr Hachisuka worked on a similar change and mentioned this:


Effectively, his change to recordPendingKeys() takes UTF8 string but
cook them into UTF32 in there.  Without this change, the image
receives those octets separately, and the way things are set up
currently, they are interpreted as individual characters.

We used to have a theory that this might be a job on
the image side, but I'd be willing to go along with the idea that the
VM does it in recordPendingKeys().  (Attached patch for now has an
ifdef, but once it is accepted as a main stream patch, it'd not have
to be there.)

Then on the image side, we need to fix ImmX11>>keyboardFocusForMorph:
to support non-TextMorphs.  My feeble attempt involves to test whether
the given morph understand #paragraph and make it read:

keyboardFocusForAMorph: aMorph

	aMorph ifNil: [^ self].
		| left bottom pos height |
		pos := aMorph preferredKeyboardPosition.
		left := (pos x min: Display width max: 0) asInteger.
		(aMorph respondsTo: #paragraph) ifTrue: [
			height := (aMorph paragraph
				characterBlockForIndex: aMorph editor selectionInterval first) height
		] ifFalse: [
			height := 0].
		bottom := (pos y min: Display height max: 0) asInteger
			 + height.
		self setCompositionWindowPositionX: left y: bottom asInteger
	] on: Error
	do: [:ex |].

(#asInteger is sent so that the primitive does not get floats.)

and then to use it StringFieldMorph (and possible a few other classes)
need its #keyboardFocusChange: to read:

keyboardFocusChange: t1 
			and: [isKeyboardFocus not])
		ifTrue: [lastContents := stringMorph contents].
			and: [t1 not])
		ifTrue: [lastContents := nil.
				ifTrue: [self contents: stringMorph contents asNumberNoError printStringNoExponent].
				ifTrue: [self acceptEdits]].
	isKeyboardFocus := t1.
		ifTrue: [selectionStart := 0.
			selectionEnd := stringMorph contents size].
        "This line below"
	isKeyboardFocus ifTrue: [ActiveHand compositionWindowManager keyboardFocusForAMorph: self].
	self changed

The result is that when the input method is enabled, and the user
tries to type into a field, the preedit window shows up right there
where you are typing in.

The prerequite for this is to have all the right environment variables
for the X Server and Squeak VM and then the good old -vm-display-X11
-compositioninput is passed in to invoke the VM.

Thank you everybody for all the help!  We'll need to fold these
changes and I'll test a few more configurations so that a novice user
invoking Scratch on Raspbian sees everything al right, but it is
getting there!

-- Yoshiki

-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff.diff
Type: application/octet-stream
Size: 3172 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160515/2cc033e7/diff.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: preedit.png
Type: image/png
Size: 53503 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160515/2cc033e7/preedit.png

More information about the Squeak-dev mailing list