/// <summary> /// Create an input context and setup callback handlers. This method should be /// called only once, and then after KeyboardController.CombinedKeyboardHandling /// has been set properly. /// </summary> /// <remarks> /// For IBus 1.5, we must use the current InputContext because there is no /// way to enable one we create ourselves. (InputContext.Enable() has turned /// into a no-op.) For IBus 1.4, we must create one ourselves because /// m_ibus.CurrentInputContext() throws an exception. /// </remarks> public void CreateInputContext() { System.Diagnostics.Debug.Assert(!m_contextCreated); if (m_ibus == null) { // This seems to be needed for tests on TeamCity. // It also seems that it shouldn't be necessary to run IBus to use Linux keyboarding! return; } if (KeyboardController.CombinedKeyboardHandling) { var path = m_ibus.CurrentInputContext(); m_inputContext = new InputContext(m_connection, path); } else { m_inputContext = m_ibus.CreateInputContext("IbusCommunicator"); } AttachContextMethods(m_inputContext); m_contextCreated = true; }
/// <summary> /// Return the DBUS 'path' name for the currently focused InputContext /// </summary> /// <exception cref="System.Exception">Throws: System.Exception with message /// 'org.freedesktop.DBus.Error.Failed: No input context focused' if nothing is currently /// focused.</exception> public string GetFocusedInputContext() { return(m_ibus.CurrentInputContext()); }