| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | 6 #define CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Called when the engine update preedit stroing. | 36 // Called when the engine update preedit stroing. |
| 37 virtual void UpdatePreeditText(const ibus::IBusText& text, | 37 virtual void UpdatePreeditText(const ibus::IBusText& text, |
| 38 uint32 cursor_pos, | 38 uint32 cursor_pos, |
| 39 bool visible) = 0; | 39 bool visible) = 0; |
| 40 | 40 |
| 41 // Called when the engine request showing preedit string. | 41 // Called when the engine request showing preedit string. |
| 42 virtual void ShowPreeditText() = 0; | 42 virtual void ShowPreeditText() = 0; |
| 43 | 43 |
| 44 // Called when the engine request hiding preedit string. | 44 // Called when the engine request hiding preedit string. |
| 45 virtual void HidePreeditText() = 0; | 45 virtual void HidePreeditText() = 0; |
| 46 | |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 // A class to make the actual DBus calls for IBusInputContext service. | 48 // A class to make the actual DBus calls for IBusInputContext service. |
| 50 // The ibus-daemon creates object paths on demand, so the target object path is | 49 // The ibus-daemon creates object paths on demand, so the target object path is |
| 51 // not determined before calling CreateInputContext. It is good to initialize | 50 // not determined before calling CreateInputContext. It is good to initialize |
| 52 // this class at the callback from CreateInputContext in IBusClient. This class | 51 // this class at the callback from CreateInputContext in IBusClient. This class |
| 53 // is managed by DBusThreadManager as singleton instance, so we can handle only | 52 // is managed by DBusThreadManager as singleton instance, so we can handle only |
| 54 // one input context but it is enough for ChromeOS. | 53 // one input context but it is enough for ChromeOS. |
| 55 class CHROMEOS_EXPORT IBusInputContextClient { | 54 class CHROMEOS_EXPORT IBusInputContextClient { |
| 56 public: | 55 public: |
| 56 typedef base::Callback<void(const ibus::Rect& cursor_location, |
| 57 const ibus::Rect& composition_head)> |
| 58 SetCursorLocationHandler; |
| 57 typedef base::Callback<void(bool is_keyevent_used)> ProcessKeyEventCallback; | 59 typedef base::Callback<void(bool is_keyevent_used)> ProcessKeyEventCallback; |
| 58 typedef base::Callback<void()> ErrorCallback; | 60 typedef base::Callback<void()> ErrorCallback; |
| 59 | 61 |
| 60 virtual ~IBusInputContextClient(); | 62 virtual ~IBusInputContextClient(); |
| 61 | 63 |
| 62 // Creates object proxy and connects signals. | 64 // Creates object proxy and connects signals. |
| 63 virtual void Initialize(dbus::Bus* bus, | 65 virtual void Initialize(dbus::Bus* bus, |
| 64 const dbus::ObjectPath& object_path) = 0; | 66 const dbus::ObjectPath& object_path) = 0; |
| 65 | 67 |
| 66 // Sets input context handler. This function can be called multiple times and | 68 // Sets input context handler. This function can be called multiple times and |
| 67 // also can be passed |handler| as NULL. Caller must release |handler|. | 69 // also can be passed |handler| as NULL. Caller must release |handler|. |
| 68 virtual void SetInputContextHandler( | 70 virtual void SetInputContextHandler( |
| 69 IBusInputContextHandlerInterface* handler) = 0; | 71 IBusInputContextHandlerInterface* handler) = 0; |
| 70 | 72 |
| 73 // Sets SetCursorLocation handler. |
| 74 virtual void SetSetCursorLocationHandler( |
| 75 const SetCursorLocationHandler& set_cursor_location_handler) = 0; |
| 76 |
| 77 // Unset SetCursorLocation handler. |
| 78 virtual void UnsetSetCursorLocationHandler() = 0; |
| 79 |
| 71 // Resets object proxy. If you want to use InputContext again, should call | 80 // Resets object proxy. If you want to use InputContext again, should call |
| 72 // Initialize function again. | 81 // Initialize function again. |
| 73 virtual void ResetObjectProxy() = 0; | 82 virtual void ResetObjectProxy() = 0; |
| 74 | 83 |
| 75 // Returns true if the object proxy is ready to communicate with ibus-daemon, | 84 // Returns true if the object proxy is ready to communicate with ibus-daemon, |
| 76 // otherwise return false. | 85 // otherwise return false. |
| 77 virtual bool IsObjectProxyReady() const = 0; | 86 virtual bool IsObjectProxyReady() const = 0; |
| 78 | 87 |
| 79 // Invokes SetCapabilities method call. | 88 // Invokes SetCapabilities method call. |
| 80 virtual void SetCapabilities(uint32 capability) = 0; | 89 virtual void SetCapabilities(uint32 capability) = 0; |
| 81 // Invokes FocusIn method call. | 90 // Invokes FocusIn method call. |
| 82 virtual void FocusIn() = 0; | 91 virtual void FocusIn() = 0; |
| 83 // Invokes FocusOut method call. | 92 // Invokes FocusOut method call. |
| 84 virtual void FocusOut() = 0; | 93 virtual void FocusOut() = 0; |
| 85 // Invokes Reset method call. | 94 // Invokes Reset method call. |
| 86 virtual void Reset() = 0; | 95 virtual void Reset() = 0; |
| 87 // Invokes SetCursorLocation method call. | 96 // Invokes SetCursorLocation method call. |
| 88 virtual void SetCursorLocation(int32 x, int32 y, int32 width, | 97 virtual void SetCursorLocation(const ibus::Rect& cursor_location, |
| 89 int32 height) = 0; | 98 const ibus::Rect& composition_head) = 0; |
| 90 // Invokes ProcessKeyEvent method call. |callback| should not be null. | 99 // Invokes ProcessKeyEvent method call. |callback| should not be null. |
| 91 virtual void ProcessKeyEvent(uint32 keyval, | 100 virtual void ProcessKeyEvent(uint32 keyval, |
| 92 uint32 keycode, | 101 uint32 keycode, |
| 93 uint32 state, | 102 uint32 state, |
| 94 const ProcessKeyEventCallback& callback, | 103 const ProcessKeyEventCallback& callback, |
| 95 const ErrorCallback& error_callback) = 0; | 104 const ErrorCallback& error_callback) = 0; |
| 96 | 105 |
| 97 // Invokes SetSurroundingText method call. |start_index| is inclusive and | 106 // Invokes SetSurroundingText method call. |start_index| is inclusive and |
| 98 // |end_index| is exclusive. | 107 // |end_index| is exclusive. |
| 99 virtual void SetSurroundingText(const std::string& text, | 108 virtual void SetSurroundingText(const std::string& text, |
| 100 uint32 start_index, | 109 uint32 start_index, |
| 101 uint32 end_index) = 0; | 110 uint32 end_index) = 0; |
| 102 | 111 |
| 103 // Invokes PropertyActivate method call. The PROP_STATE_INCONSISTENT in | 112 // Invokes PropertyActivate method call. The PROP_STATE_INCONSISTENT in |
| 104 // original IBus spec is not supported in Chrome. | 113 // original IBus spec is not supported in Chrome. |
| 105 virtual void PropertyActivate(const std::string& key, | 114 virtual void PropertyActivate(const std::string& key, |
| 106 ibus::IBusPropertyState state) = 0; | 115 ibus::IBusPropertyState state) = 0; |
| 107 | 116 |
| 117 // Returns true if the current input method is XKB layout. |
| 118 virtual bool IsXKBLayout() = 0; |
| 119 |
| 120 // Sets current input method is XKB layout or not. |
| 121 virtual void SetIsXKBLayout(bool is_xkb_layout) = 0; |
| 122 |
| 108 // Factory function, creates a new instance and returns ownership. | 123 // Factory function, creates a new instance and returns ownership. |
| 109 // For normal usage, access the singleton via DBusThreadManager::Get(). | 124 // For normal usage, access the singleton via DBusThreadManager::Get(). |
| 110 static CHROMEOS_EXPORT IBusInputContextClient* Create( | 125 static CHROMEOS_EXPORT IBusInputContextClient* Create( |
| 111 DBusClientImplementationType type); | 126 DBusClientImplementationType type); |
| 112 | 127 |
| 113 protected: | 128 protected: |
| 114 // Create() should be used instead. | 129 // Create() should be used instead. |
| 115 IBusInputContextClient(); | 130 IBusInputContextClient(); |
| 116 | 131 |
| 117 private: | 132 private: |
| 118 DISALLOW_COPY_AND_ASSIGN(IBusInputContextClient); | 133 DISALLOW_COPY_AND_ASSIGN(IBusInputContextClient); |
| 119 }; | 134 }; |
| 120 | 135 |
| 121 } // namespace chromeos | 136 } // namespace chromeos |
| 122 | 137 |
| 123 #endif // CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | 138 #endif // CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ |
| OLD | NEW |