/// <summary> /// Sends a key Event to the ibus current input context. This method will be called by /// the IbusKeyboardAdapter on some KeyDown and all KeyPress events. /// </summary> /// <param name="keySym">The X11 key symbol (for special keys) or the key code</param> /// <param name="scanCode">The X11 scan code</param> /// <param name="state">The modifier state, i.e. shift key etc.</param> /// <returns><c>true</c> if the key event is handled by ibus.</returns> /// <seealso cref="IBusKeyboardAdaptor.HandleKeyPress"/> public bool ProcessKeyEvent(int keySym, int scanCode, Keys state) { if (m_inputContext == null) { return(false); } try { // m_inputContext.IsEnabled() throws an exception for IBus 1.5. if (!KeyboardController.CombinedKeyboardHandling && !m_inputContext.IsEnabled()) { return(false); } var modifiers = ConvertToIbusModifiers(state, (char)keySym); return(m_inputContext.ProcessKeyEvent(keySym, scanCode, modifiers)); } catch (NDesk.DBus.DBusConectionErrorException e) { Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught DBusConectionErrorException: {3}", keySym, scanCode, state, e); m_ibus = null; m_inputContext = null; NotifyUserOfIBusConnectionDropped(); } catch (System.NullReferenceException e) { Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught NullReferenceException: {3}", keySym, scanCode, state, e); } return(false); }
/// <summary> /// Sends a key Event to the ibus current input context. This method will be called by /// the IbusKeyboardAdapter on some KeyDown and all KeyPress events. /// </summary> /// <param name="keySym">The X11 key symbol (for special keys) or the key code</param> /// <param name="scanCode">The X11 scan code</param> /// <param name="state">The modifier state, i.e. shift key etc.</param> /// <returns><c>true</c> if the key event is handled by ibus.</returns> /// <seealso cref="IbusKeyboardSwitchingAdaptor.HandleKeyPress"/> public bool ProcessKeyEvent(int keySym, int scanCode, Keys state) { if (m_inputContext == null) { return(false); } try { // m_inputContext.IsEnabled() is no longer contained in IBus 1.5. However, // ibusdotnet >= 1.9.1 deals with that and always returns true so that we still // can use this method. if (!m_inputContext.IsEnabled()) { return(false); } var modifiers = ConvertToIbusModifiers(state, (char)keySym); return(m_inputContext.ProcessKeyEvent(keySym, scanCode, modifiers)); } catch (NDesk.DBus.DBusConectionErrorException e) { Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught DBusConectionErrorException: {3}", keySym, scanCode, state, e); m_ibus = null; m_inputContext = null; NotifyUserOfIBusConnectionDropped(); } catch (System.NullReferenceException e) { Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught NullReferenceException: {3}", keySym, scanCode, state, e); } return(false); }