[dev] [st] XIM switching problems in combination with XKB dead keys

2020-07-17 Thread Maarten van Gompel
Hi,

I identified a problem when switching input methods: XIM and XKB keymaps
with dead keys can not be used properly in the same session as that
breaks the dead keys (= composition keys for diacritics).

My situation: I use regular XKB to type in languages using a latin or
cyrillic script, but for Chinese I need of course need a proper input
method (e.g. fcitx or ibus-libpinyin). I want to change between input
methods on the fly, this currently does not work, if st is started with
a XMODIFIERS="@im=whatever" then normal dead keys don't work, regardless
whether the underlying XIM server is running or not, if it is started
with an empty XMODIFIERS="", then they do work. It means I need to
restart the terminal if I want to properly switch between chinese and my
usual dead keys. Switching in my case entails killing the XIM server if
it's running and running setxkbmap to set the desired keymap.

To reproduce:

Case 1)
 $ export XMODIFIERS=""
 $ setxbkmap es
 $ st
Type apostrophe a and output is á  , as expected, but of course no XIM now

Case 2)
 $ export XMODIFIERS="@im=fcitx"
 $ setxbkmap es  #spanish XKB keymap to illustrate the issue
 $ st
Type apostrophe a and output is 'a instead of á


I think st should behave the same way most applications do; if the xim
server is not running, it should exhibit the same behaviour as if no XIM
was configured at all. (for comparison; terminals like urxvt and
alacritty behave in this way, GTK and QT apps too)

The problem was introduced in the following commit:

787c9a55fea7131b4f1e5c7699b68b3517db8e49 Quentin Rameau x: 
fix XIM handling

Prior to this commit though, the situation was much worse as st would
simply crash if the XIM server stopped, so there's good progress but we
aren't entirely there yet :)

Regards,

--

Maarten van Gompel

proy...@anaproy.nl
https://proycon.anaproy.nl
https://github.com/proycon

GnuPG key:  0x39FE11201A31555C
XMPP:   proy...@anaproy.nl   Matrix: @proycon:matrix.anaproy.nl
Telegram:   proycon  IRC: proycon (freenode)
Mastodon:   https://social.anaproy.nl/@proycon   (@proy...@social.anaproy.nl)
Twitter:https://twitter.com/proycon



Re: [dev] [st] XIM switching problems in combination with XKB dead keys

2020-07-17 Thread Hiltjo Posthuma
On Fri, Jul 17, 2020 at 07:01:59PM +0200, Maarten van Gompel wrote:
> Hi,
> 
> I identified a problem when switching input methods: XIM and XKB keymaps
> with dead keys can not be used properly in the same session as that
> breaks the dead keys (= composition keys for diacritics).
> 
> My situation: I use regular XKB to type in languages using a latin or
> cyrillic script, but for Chinese I need of course need a proper input
> method (e.g. fcitx or ibus-libpinyin). I want to change between input
> methods on the fly, this currently does not work, if st is started with
> a XMODIFIERS="@im=whatever" then normal dead keys don't work, regardless
> whether the underlying XIM server is running or not, if it is started
> with an empty XMODIFIERS="", then they do work. It means I need to
> restart the terminal if I want to properly switch between chinese and my
> usual dead keys. Switching in my case entails killing the XIM server if
> it's running and running setxkbmap to set the desired keymap.
> 
> To reproduce:
> 
> Case 1)
>  $ export XMODIFIERS=""
>  $ setxbkmap es
>  $ st
> Type apostrophe a and output is á  , as expected, but of course no XIM now
> 
> Case 2)
>  $ export XMODIFIERS="@im=fcitx"
>  $ setxbkmap es  #spanish XKB keymap to illustrate the issue
>  $ st
> Type apostrophe a and output is 'a instead of á
> 
> 
> I think st should behave the same way most applications do; if the xim
> server is not running, it should exhibit the same behaviour as if no XIM
> was configured at all. (for comparison; terminals like urxvt and
> alacritty behave in this way, GTK and QT apps too)
> 
> The problem was introduced in the following commit:
> 
> 787c9a55fea7131b4f1e5c7699b68b3517db8e49 Quentin Rameau 
> x: fix XIM handling
> 
> Prior to this commit though, the situation was much worse as st would
> simply crash if the XIM server stopped, so there's good progress but we
> aren't entirely there yet :)
> 
> Regards,
> 
> --
> 
> Maarten van Gompel
> 
> proy...@anaproy.nl
> https://proycon.anaproy.nl
> https://github.com/proycon
> 
> GnuPG key:  0x39FE11201A31555C
> XMPP:   proy...@anaproy.nl   Matrix: @proycon:matrix.anaproy.nl
> Telegram:   proycon  IRC: proycon (freenode)
> Mastodon:   https://social.anaproy.nl/@proycon   (@proy...@social.anaproy.nl)
> Twitter:https://twitter.com/proycon
> 

Hi,

Thanks for the feedback. Is anyone willing to work on this and improve general
XIM support?

Alternatively maybe the current code should be removed and completely reworked?

-- 
Kind regards,
Hiltjo