ecore_imf: just use the styles that are supported!
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 18 Jun 2012 23:38:23 +0000 (23:38 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 18 Jun 2012 23:38:23 +0000 (23:38 +0000)
If we want a fancy XIM style that is unsupported, do not use it... but
the fallback (no preedit, no status).

This allows poor's man XIM to work for those without SCIM and similar.

Elementary is now working properly with ' + a = รก

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@72426 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/immodules/xim/ecore_imf_xim.c

index 093f99b..107a3ac 100644 (file)
@@ -1226,7 +1226,48 @@ get_ic(Ecore_IMF_Context *ctx)
              im_style |= XIMStatusNothing;
           }
 
-        if (im_info->im)
+        if (!im_info->xim_styles)
+          {
+             EINA_LOG_WARN("No XIM styles supported! Wanted %#llx",
+                           (unsigned long long)im_style);
+             im_style = 0;
+          }
+        else
+          {
+             XIMStyle fallback = 0;
+             int i;
+
+             for (i = 0; i < im_info->xim_styles->count_styles; i++)
+               {
+                  XIMStyle cur = im_info->xim_styles->supported_styles[i];
+                  if (cur == im_style)
+                    break;
+                  else if (cur == (XIMPreeditNothing | XIMStatusNothing))
+                    /* TODO: fallback is just that or the anyone? */
+                    fallback = cur;
+               }
+
+             if (i == im_info->xim_styles->count_styles)
+               {
+                  if (fallback)
+                    {
+                       EINA_LOG_WARN("Wanted XIM style %#llx not found, "
+                                     "using fallback %#llx instead.",
+                                     (unsigned long long)im_style,
+                                     (unsigned long long)fallback);
+                       im_style = fallback;
+                    }
+                  else
+                    {
+                       EINA_LOG_WARN("Wanted XIM style %#llx not found, "
+                                     "no fallback supported.",
+                                     (unsigned long long)im_style);
+                       im_style = 0;
+                    }
+               }
+          }
+
+        if ((im_info->im) && (im_style))
           {
              ic = XCreateIC(im_info->im,
                             XNInputStyle, im_style,