2 /* Protocol XML file : wayland-extension/input-method.xml */
4 #include "dswayland-server-input-method.h"
7 #define DS_UNLIKELY(X) X
10 #define DS_UNUSED(X) (void)X
13 #define DS_ASSERT(COND) assert(COND)
16 #define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \
20 fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\
26 #define WRN(X...) fprintf(stderr,##X)
29 namespace DSWaylandServer {
30 wl_input_method_context::wl_input_method_context(struct ::wl_client *client, uint32_t id, int version)
35 , m_displayDestroyedListener()
37 init(client, id, version);
40 wl_input_method_context::wl_input_method_context(struct ::wl_display *display, int version)
45 , m_displayDestroyedListener()
47 init(display, version);
50 wl_input_method_context::wl_input_method_context(struct ::wl_resource *resource)
55 , m_displayDestroyedListener()
60 wl_input_method_context::wl_input_method_context()
65 , m_displayDestroyedListener()
69 wl_input_method_context::~wl_input_method_context()
71 std::multimap<struct ::wl_client*, wl_input_method_context::Resource*>::iterator it;
72 for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
73 wl_input_method_context::Resource *resource = (*it).second;
74 wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
78 wl_global_destroy(m_global);
79 wl_list_remove(&m_displayDestroyedListener.link);
83 void wl_input_method_context::init(struct ::wl_client *client, uint32_t id, int version)
85 m_resource = bind(client, id, version);
88 void wl_input_method_context::init(struct ::wl_resource *resource)
90 m_resource = bind(resource);
93 wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, int version)
95 Resource *resource = bind(client, 0, version);
96 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
100 wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, uint32_t id, int version)
102 Resource *resource = bind(client, id, version);
103 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
107 void wl_input_method_context::init(struct ::wl_display *display, int version)
109 m_global = wl_global_create(display, &::wl_input_method_context_interface, version, this, bind_func);
110 m_globalVersion = version;
111 m_displayDestroyedListener.notify = wl_input_method_context::display_destroy_func;
112 m_displayDestroyedListener.parent = this;
113 wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
116 const struct wl_interface *wl_input_method_context::interface()
118 return &::wl_input_method_context_interface;
121 wl_input_method_context::Resource *wl_input_method_context::input_method_context_allocate()
126 void wl_input_method_context::input_method_context_bind_resource(Resource *)
130 void wl_input_method_context::input_method_context_destroy_resource(Resource *)
134 void wl_input_method_context::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
136 wl_input_method_context *that = static_cast<wl_input_method_context *>(data);
137 that->add(client, id, std::min(that->m_globalVersion, version));
140 void wl_input_method_context::display_destroy_func(struct ::wl_listener *listener, void *data)
143 wl_input_method_context *that = static_cast<wl_input_method_context::DisplayDestroyedListener *>(listener)->parent;
144 that->m_global = NULL;
147 void wl_input_method_context::destroy_func(struct ::wl_resource *client_resource)
149 Resource *resource = Resource::fromResource(client_resource);
151 wl_input_method_context *that = resource->input_method_context_object;
152 that->m_resource_map.erase(resource->client());
153 that->input_method_context_destroy_resource(resource);
157 wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_client *client, uint32_t id, int version)
159 DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
160 struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_context_interface, version, id);
164 wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_resource *handle)
166 Resource *resource = input_method_context_allocate();
167 resource->input_method_context_object = this;
169 wl_resource_set_implementation(handle, &m_wl_input_method_context_interface, resource, destroy_func);
170 resource->handle = handle;
171 input_method_context_bind_resource(resource);
174 wl_input_method_context::Resource *wl_input_method_context::Resource::fromResource(struct ::wl_resource *resource)
176 if (DS_UNLIKELY(!resource))
178 if (wl_resource_instance_of(resource, &::wl_input_method_context_interface, &m_wl_input_method_context_interface))
179 return static_cast<Resource *>(wl_resource_get_user_data(resource));
183 const struct ::wl_input_method_context_interface wl_input_method_context::m_wl_input_method_context_interface = {
184 wl_input_method_context::handle_destroy,
185 wl_input_method_context::handle_commit_string,
186 wl_input_method_context::handle_preedit_string,
187 wl_input_method_context::handle_preedit_styling,
188 wl_input_method_context::handle_preedit_cursor,
189 wl_input_method_context::handle_delete_surrounding_text,
190 wl_input_method_context::handle_cursor_position,
191 wl_input_method_context::handle_modifiers_map,
192 wl_input_method_context::handle_keysym,
193 wl_input_method_context::handle_grab_keyboard,
194 wl_input_method_context::handle_key,
195 wl_input_method_context::handle_modifiers,
196 wl_input_method_context::handle_language,
197 wl_input_method_context::handle_text_direction,
198 wl_input_method_context::handle_selection_region,
199 wl_input_method_context::handle_private_command,
200 wl_input_method_context::handle_update_input_panel_data,
201 wl_input_method_context::handle_hide_input_panel,
202 wl_input_method_context::handle_get_selection_text,
203 wl_input_method_context::handle_get_surrounding_text,
204 wl_input_method_context::handle_filter_key_event_done,
205 wl_input_method_context::handle_update_ise_geometry,
206 wl_input_method_context::handle_recapture_string,
207 wl_input_method_context::handle_input_panel_event,
208 wl_input_method_context::handle_commit_content,
209 wl_input_method_context::handle_update_candidate_state,
210 wl_input_method_context::handle_reshow_input_panel
213 void wl_input_method_context::input_method_context_destroy(Resource *)
217 void wl_input_method_context::input_method_context_commit_string(Resource *, uint32_t , const std::string &)
221 void wl_input_method_context::input_method_context_preedit_string(Resource *, uint32_t , const std::string &, const std::string &)
225 void wl_input_method_context::input_method_context_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t )
229 void wl_input_method_context::input_method_context_preedit_cursor(Resource *, int32_t )
233 void wl_input_method_context::input_method_context_delete_surrounding_text(Resource *, int32_t , uint32_t )
237 void wl_input_method_context::input_method_context_cursor_position(Resource *, int32_t , int32_t )
241 void wl_input_method_context::input_method_context_modifiers_map(Resource *, struct ::wl_array *)
245 void wl_input_method_context::input_method_context_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
249 void wl_input_method_context::input_method_context_grab_keyboard(Resource *, uint32_t)
253 void wl_input_method_context::input_method_context_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t )
257 void wl_input_method_context::input_method_context_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
261 void wl_input_method_context::input_method_context_language(Resource *, uint32_t , const std::string &)
265 void wl_input_method_context::input_method_context_text_direction(Resource *, uint32_t , uint32_t )
269 void wl_input_method_context::input_method_context_selection_region(Resource *, uint32_t , int32_t , int32_t )
273 void wl_input_method_context::input_method_context_private_command(Resource *, uint32_t , const std::string &)
277 void wl_input_method_context::input_method_context_update_input_panel_data(Resource *, uint32_t , const std::string &, uint32_t )
281 void wl_input_method_context::input_method_context_hide_input_panel(Resource *, uint32_t )
285 void wl_input_method_context::input_method_context_get_selection_text(Resource *, int32_t )
289 void wl_input_method_context::input_method_context_get_surrounding_text(Resource *, uint32_t , uint32_t , int32_t )
293 void wl_input_method_context::input_method_context_filter_key_event_done(Resource *, uint32_t , uint32_t )
297 void wl_input_method_context::input_method_context_update_ise_geometry(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
301 void wl_input_method_context::input_method_context_recapture_string(Resource *, uint32_t , int32_t , uint32_t , const std::string &, const std::string &, const std::string &)
305 void wl_input_method_context::input_method_context_input_panel_event(Resource *, uint32_t , uint32_t , uint32_t )
309 void wl_input_method_context::input_method_context_commit_content(Resource *, uint32_t , const std::string &, const std::string &, const std::string &)
313 void wl_input_method_context::input_method_context_update_candidate_state(Resource *, uint32_t )
317 void wl_input_method_context::input_method_context_reshow_input_panel(Resource *)
322 void wl_input_method_context::handle_destroy(
324 struct wl_resource *resource)
327 Resource *r = Resource::fromResource(resource);
328 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_destroy(
332 void wl_input_method_context::handle_commit_string(
334 struct wl_resource *resource,
339 Resource *r = Resource::fromResource(resource);
340 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_commit_string(
346 void wl_input_method_context::handle_preedit_string(
348 struct wl_resource *resource,
354 Resource *r = Resource::fromResource(resource);
355 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_string(
359 std::string(commit));
362 void wl_input_method_context::handle_preedit_styling(
364 struct wl_resource *resource,
370 Resource *r = Resource::fromResource(resource);
371 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_styling(
378 void wl_input_method_context::handle_preedit_cursor(
380 struct wl_resource *resource,
384 Resource *r = Resource::fromResource(resource);
385 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_cursor(
390 void wl_input_method_context::handle_delete_surrounding_text(
392 struct wl_resource *resource,
397 Resource *r = Resource::fromResource(resource);
398 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_delete_surrounding_text(
404 void wl_input_method_context::handle_cursor_position(
406 struct wl_resource *resource,
411 Resource *r = Resource::fromResource(resource);
412 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_cursor_position(
418 void wl_input_method_context::handle_modifiers_map(
420 struct wl_resource *resource,
421 struct ::wl_array *map)
424 Resource *r = Resource::fromResource(resource);
425 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_modifiers_map(
430 void wl_input_method_context::handle_keysym(
432 struct wl_resource *resource,
440 Resource *r = Resource::fromResource(resource);
441 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_keysym(
450 void wl_input_method_context::handle_grab_keyboard(
452 struct wl_resource *resource,
456 Resource *r = Resource::fromResource(resource);
457 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_grab_keyboard(
462 void wl_input_method_context::handle_key(
464 struct wl_resource *resource,
471 Resource *r = Resource::fromResource(resource);
472 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_key(
480 void wl_input_method_context::handle_modifiers(
482 struct wl_resource *resource,
484 uint32_t mods_depressed,
485 uint32_t mods_latched,
486 uint32_t mods_locked,
490 Resource *r = Resource::fromResource(resource);
491 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_modifiers(
500 void wl_input_method_context::handle_language(
502 struct wl_resource *resource,
504 const char *language)
507 Resource *r = Resource::fromResource(resource);
508 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_language(
511 std::string(language));
514 void wl_input_method_context::handle_text_direction(
516 struct wl_resource *resource,
521 Resource *r = Resource::fromResource(resource);
522 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_text_direction(
528 void wl_input_method_context::handle_selection_region(
530 struct wl_resource *resource,
536 Resource *r = Resource::fromResource(resource);
537 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_selection_region(
544 void wl_input_method_context::handle_private_command(
546 struct wl_resource *resource,
551 Resource *r = Resource::fromResource(resource);
552 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_private_command(
555 std::string(command));
558 void wl_input_method_context::handle_update_input_panel_data(
560 struct wl_resource *resource,
562 const char *input_panel_data,
563 uint32_t input_panel_data_length)
566 Resource *r = Resource::fromResource(resource);
567 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_update_input_panel_data(
570 std::string(input_panel_data),
571 input_panel_data_length);
574 void wl_input_method_context::handle_hide_input_panel(
576 struct wl_resource *resource,
580 Resource *r = Resource::fromResource(resource);
581 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_hide_input_panel(
586 void wl_input_method_context::handle_get_selection_text(
588 struct wl_resource *resource,
592 Resource *r = Resource::fromResource(resource);
593 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_get_selection_text(
598 void wl_input_method_context::handle_get_surrounding_text(
600 struct wl_resource *resource,
601 uint32_t maxlen_before,
602 uint32_t maxlen_after,
606 Resource *r = Resource::fromResource(resource);
607 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_get_surrounding_text(
614 void wl_input_method_context::handle_filter_key_event_done(
616 struct wl_resource *resource,
621 Resource *r = Resource::fromResource(resource);
622 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_filter_key_event_done(
628 void wl_input_method_context::handle_update_ise_geometry(
630 struct wl_resource *resource,
638 Resource *r = Resource::fromResource(resource);
639 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_update_ise_geometry(
648 void wl_input_method_context::handle_recapture_string(
650 struct wl_resource *resource,
655 const char *preedit_commit,
659 Resource *r = Resource::fromResource(resource);
660 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_recapture_string(
665 std::string(preedit),
666 std::string(preedit_commit),
667 std::string(commit));
670 void wl_input_method_context::handle_input_panel_event(
672 struct wl_resource *resource,
678 Resource *r = Resource::fromResource(resource);
679 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_input_panel_event(
686 void wl_input_method_context::handle_commit_content(
688 struct wl_resource *resource,
691 const char *description,
692 const char *mime_types)
695 Resource *r = Resource::fromResource(resource);
696 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_commit_content(
699 std::string(content),
700 std::string(description),
701 std::string(mime_types));
704 void wl_input_method_context::handle_update_candidate_state(
706 struct wl_resource *resource,
710 Resource *r = Resource::fromResource(resource);
711 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_update_candidate_state(
716 void wl_input_method_context::handle_reshow_input_panel(
718 struct wl_resource *resource)
721 Resource *r = Resource::fromResource(resource);
722 static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_reshow_input_panel(
726 void wl_input_method_context::send_reset()
728 DS_ASSERT_X(m_resource, "wl_input_method_context::reset", "Uninitialised resource");
729 if (DS_UNLIKELY(!m_resource)) {
730 WRN("could not call wl_input_method_context::reset as it's not initialised");
737 void wl_input_method_context::send_reset(struct ::wl_resource *resource)
739 wl_input_method_context_send_reset(
744 void wl_input_method_context::send_content_type(uint32_t hint, uint32_t purpose)
746 DS_ASSERT_X(m_resource, "wl_input_method_context::content_type", "Uninitialised resource");
747 if (DS_UNLIKELY(!m_resource)) {
748 WRN("could not call wl_input_method_context::content_type as it's not initialised");
757 void wl_input_method_context::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose)
759 wl_input_method_context_send_content_type(
766 void wl_input_method_context::send_invoke_action(uint32_t button, uint32_t index)
768 DS_ASSERT_X(m_resource, "wl_input_method_context::invoke_action", "Uninitialised resource");
769 if (DS_UNLIKELY(!m_resource)) {
770 WRN("could not call wl_input_method_context::invoke_action as it's not initialised");
779 void wl_input_method_context::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index)
781 wl_input_method_context_send_invoke_action(
788 void wl_input_method_context::send_commit_state(uint32_t serial)
790 DS_ASSERT_X(m_resource, "wl_input_method_context::commit_state", "Uninitialised resource");
791 if (DS_UNLIKELY(!m_resource)) {
792 WRN("could not call wl_input_method_context::commit_state as it's not initialised");
800 void wl_input_method_context::send_commit_state(struct ::wl_resource *resource, uint32_t serial)
802 wl_input_method_context_send_commit_state(
808 void wl_input_method_context::send_preferred_language(const std::string &language)
810 DS_ASSERT_X(m_resource, "wl_input_method_context::preferred_language", "Uninitialised resource");
811 if (DS_UNLIKELY(!m_resource)) {
812 WRN("could not call wl_input_method_context::preferred_language as it's not initialised");
815 send_preferred_language(
820 void wl_input_method_context::send_preferred_language(struct ::wl_resource *resource, const std::string &language)
822 wl_input_method_context_send_preferred_language(
828 void wl_input_method_context::send_return_key_type(uint32_t return_key_type)
830 DS_ASSERT_X(m_resource, "wl_input_method_context::return_key_type", "Uninitialised resource");
831 if (DS_UNLIKELY(!m_resource)) {
832 WRN("could not call wl_input_method_context::return_key_type as it's not initialised");
835 send_return_key_type(
840 void wl_input_method_context::send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type)
842 wl_input_method_context_send_return_key_type(
848 void wl_input_method_context::send_return_key_disabled(uint32_t return_key_disabled)
850 DS_ASSERT_X(m_resource, "wl_input_method_context::return_key_disabled", "Uninitialised resource");
851 if (DS_UNLIKELY(!m_resource)) {
852 WRN("could not call wl_input_method_context::return_key_disabled as it's not initialised");
855 send_return_key_disabled(
857 return_key_disabled);
860 void wl_input_method_context::send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled)
862 wl_input_method_context_send_return_key_disabled(
864 return_key_disabled);
868 void wl_input_method_context::send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length)
870 DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_data", "Uninitialised resource");
871 if (DS_UNLIKELY(!m_resource)) {
872 WRN("could not call wl_input_method_context::input_panel_data as it's not initialised");
875 send_input_panel_data(
878 input_panel_data_length);
881 void wl_input_method_context::send_input_panel_data(struct ::wl_resource *resource, const std::string &input_panel_data, uint32_t input_panel_data_length)
883 wl_input_method_context_send_input_panel_data(
885 input_panel_data.c_str(),
886 input_panel_data_length);
890 void wl_input_method_context::send_bidi_direction(uint32_t direction)
892 DS_ASSERT_X(m_resource, "wl_input_method_context::bidi_direction", "Uninitialised resource");
893 if (DS_UNLIKELY(!m_resource)) {
894 WRN("could not call wl_input_method_context::bidi_direction as it's not initialised");
902 void wl_input_method_context::send_bidi_direction(struct ::wl_resource *resource, uint32_t direction)
904 wl_input_method_context_send_bidi_direction(
910 void wl_input_method_context::send_cursor_position(uint32_t cursor_position)
912 DS_ASSERT_X(m_resource, "wl_input_method_context::cursor_position", "Uninitialised resource");
913 if (DS_UNLIKELY(!m_resource)) {
914 WRN("could not call wl_input_method_context::cursor_position as it's not initialised");
917 send_cursor_position(
922 void wl_input_method_context::send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position)
924 wl_input_method_context_send_cursor_position(
930 void wl_input_method_context::send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length)
932 DS_ASSERT_X(m_resource, "wl_input_method_context::process_input_device_event", "Uninitialised resource");
933 if (DS_UNLIKELY(!m_resource)) {
934 WRN("could not call wl_input_method_context::process_input_device_event as it's not initialised");
937 send_process_input_device_event(
944 void wl_input_method_context::send_process_input_device_event(struct ::wl_resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length)
946 wl_input_method_context_send_process_input_device_event(
954 void wl_input_method_context::send_filter_key_event(uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode)
956 DS_ASSERT_X(m_resource, "wl_input_method_context::filter_key_event", "Uninitialised resource");
957 if (DS_UNLIKELY(!m_resource)) {
958 WRN("could not call wl_input_method_context::filter_key_event as it's not initialised");
961 send_filter_key_event(
974 void wl_input_method_context::send_filter_key_event(struct ::wl_resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode)
976 wl_input_method_context_send_filter_key_event(
990 void wl_input_method_context::send_capital_mode(uint32_t mode)
992 DS_ASSERT_X(m_resource, "wl_input_method_context::capital_mode", "Uninitialised resource");
993 if (DS_UNLIKELY(!m_resource)) {
994 WRN("could not call wl_input_method_context::capital_mode as it's not initialised");
1002 void wl_input_method_context::send_capital_mode(struct ::wl_resource *resource, uint32_t mode)
1004 wl_input_method_context_send_capital_mode(
1010 void wl_input_method_context::send_prediction_hint(const std::string &text)
1012 DS_ASSERT_X(m_resource, "wl_input_method_context::prediction_hint", "Uninitialised resource");
1013 if (DS_UNLIKELY(!m_resource)) {
1014 WRN("could not call wl_input_method_context::prediction_hint as it's not initialised");
1017 send_prediction_hint(
1022 void wl_input_method_context::send_prediction_hint(struct ::wl_resource *resource, const std::string &text)
1024 wl_input_method_context_send_prediction_hint(
1030 void wl_input_method_context::send_mime_type(const std::string &type)
1032 DS_ASSERT_X(m_resource, "wl_input_method_context::mime_type", "Uninitialised resource");
1033 if (DS_UNLIKELY(!m_resource)) {
1034 WRN("could not call wl_input_method_context::mime_type as it's not initialised");
1042 void wl_input_method_context::send_mime_type(struct ::wl_resource *resource, const std::string &type)
1044 wl_input_method_context_send_mime_type(
1050 void wl_input_method_context::send_finalized_content(const std::string &text, uint32_t cursor_position)
1052 DS_ASSERT_X(m_resource, "wl_input_method_context::finalized_content", "Uninitialised resource");
1053 if (DS_UNLIKELY(!m_resource)) {
1054 WRN("could not call wl_input_method_context::finalized_content as it's not initialised");
1057 send_finalized_content(
1063 void wl_input_method_context::send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position)
1065 wl_input_method_context_send_finalized_content(
1072 void wl_input_method_context::send_prediction_hint_data(const std::string &key, const std::string &value)
1074 DS_ASSERT_X(m_resource, "wl_input_method_context::prediction_hint_data", "Uninitialised resource");
1075 if (DS_UNLIKELY(!m_resource)) {
1076 WRN("could not call wl_input_method_context::prediction_hint_data as it's not initialised");
1079 send_prediction_hint_data(
1085 void wl_input_method_context::send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value)
1087 wl_input_method_context_send_prediction_hint_data(
1094 void wl_input_method_context::send_input_panel_enabled(uint32_t enabled)
1096 DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_enabled", "Uninitialised resource");
1097 if (DS_UNLIKELY(!m_resource)) {
1098 WRN("could not call wl_input_method_context::input_panel_enabled as it's not initialised");
1101 send_input_panel_enabled(
1106 void wl_input_method_context::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled)
1108 wl_input_method_context_send_input_panel_enabled(
1114 wl_input_method::wl_input_method(struct ::wl_client *client, uint32_t id, int version)
1118 , m_globalVersion(0)
1119 , m_displayDestroyedListener()
1121 init(client, id, version);
1124 wl_input_method::wl_input_method(struct ::wl_display *display, int version)
1128 , m_globalVersion(0)
1129 , m_displayDestroyedListener()
1131 init(display, version);
1134 wl_input_method::wl_input_method(struct ::wl_resource *resource)
1138 , m_globalVersion(0)
1139 , m_displayDestroyedListener()
1144 wl_input_method::wl_input_method()
1148 , m_globalVersion(0)
1149 , m_displayDestroyedListener()
1153 wl_input_method::~wl_input_method()
1155 std::multimap<struct ::wl_client*, wl_input_method::Resource*>::iterator it;
1156 for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1157 wl_input_method::Resource *resource = (*it).second;
1158 wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1162 wl_global_destroy(m_global);
1163 wl_list_remove(&m_displayDestroyedListener.link);
1167 void wl_input_method::init(struct ::wl_client *client, uint32_t id, int version)
1169 m_resource = bind(client, id, version);
1172 void wl_input_method::init(struct ::wl_resource *resource)
1174 m_resource = bind(resource);
1177 wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, int version)
1179 Resource *resource = bind(client, 0, version);
1180 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1184 wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, uint32_t id, int version)
1186 Resource *resource = bind(client, id, version);
1187 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1191 void wl_input_method::init(struct ::wl_display *display, int version)
1193 m_global = wl_global_create(display, &::wl_input_method_interface, version, this, bind_func);
1194 m_globalVersion = version;
1195 m_displayDestroyedListener.notify = wl_input_method::display_destroy_func;
1196 m_displayDestroyedListener.parent = this;
1197 wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1200 const struct wl_interface *wl_input_method::interface()
1202 return &::wl_input_method_interface;
1205 wl_input_method::Resource *wl_input_method::input_method_allocate()
1207 return new Resource;
1210 void wl_input_method::input_method_bind_resource(Resource *)
1214 void wl_input_method::input_method_destroy_resource(Resource *)
1218 void wl_input_method::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1220 wl_input_method *that = static_cast<wl_input_method *>(data);
1221 that->add(client, id, std::min(that->m_globalVersion, version));
1224 void wl_input_method::display_destroy_func(struct ::wl_listener *listener, void *data)
1227 wl_input_method *that = static_cast<wl_input_method::DisplayDestroyedListener *>(listener)->parent;
1228 that->m_global = NULL;
1231 void wl_input_method::destroy_func(struct ::wl_resource *client_resource)
1233 Resource *resource = Resource::fromResource(client_resource);
1234 DS_ASSERT(resource);
1235 wl_input_method *that = resource->input_method_object;
1236 that->m_resource_map.erase(resource->client());
1237 that->input_method_destroy_resource(resource);
1241 wl_input_method::Resource *wl_input_method::bind(struct ::wl_client *client, uint32_t id, int version)
1243 DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1244 struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_interface, version, id);
1245 return bind(handle);
1248 wl_input_method::Resource *wl_input_method::bind(struct ::wl_resource *handle)
1250 Resource *resource = input_method_allocate();
1251 resource->input_method_object = this;
1253 wl_resource_set_implementation(handle, NULL, resource, destroy_func);
1254 resource->handle = handle;
1255 input_method_bind_resource(resource);
1258 wl_input_method::Resource *wl_input_method::Resource::fromResource(struct ::wl_resource *resource)
1260 if (DS_UNLIKELY(!resource))
1262 if (wl_resource_instance_of(resource, &::wl_input_method_interface, NULL))
1263 return static_cast<Resource *>(wl_resource_get_user_data(resource));
1267 void wl_input_method::send_activate(struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event)
1269 DS_ASSERT_X(m_resource, "wl_input_method::activate", "Uninitialised resource");
1270 if (DS_UNLIKELY(!m_resource)) {
1271 WRN("could not call wl_input_method::activate as it's not initialised");
1281 void wl_input_method::send_activate(struct ::wl_resource *resource, struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event)
1283 wl_input_method_send_activate(
1291 void wl_input_method::send_deactivate(struct ::wl_resource *context, uint32_t focus_out_event)
1293 DS_ASSERT_X(m_resource, "wl_input_method::deactivate", "Uninitialised resource");
1294 if (DS_UNLIKELY(!m_resource)) {
1295 WRN("could not call wl_input_method::deactivate as it's not initialised");
1304 void wl_input_method::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t focus_out_event)
1306 wl_input_method_send_deactivate(
1313 void wl_input_method::send_destroy(struct ::wl_resource *context)
1315 DS_ASSERT_X(m_resource, "wl_input_method::destroy", "Uninitialised resource");
1316 if (DS_UNLIKELY(!m_resource)) {
1317 WRN("could not call wl_input_method::destroy as it's not initialised");
1325 void wl_input_method::send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context)
1327 wl_input_method_send_destroy(
1333 void wl_input_method::send_show_input_panel(struct ::wl_resource *context)
1335 DS_ASSERT_X(m_resource, "wl_input_method::show_input_panel", "Uninitialised resource");
1336 if (DS_UNLIKELY(!m_resource)) {
1337 WRN("could not call wl_input_method::show_input_panel as it's not initialised");
1340 send_show_input_panel(
1345 void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context)
1347 wl_input_method_send_show_input_panel(
1353 void wl_input_method::send_hide_input_panel(struct ::wl_resource *context)
1355 DS_ASSERT_X(m_resource, "wl_input_method::hide_input_panel", "Uninitialised resource");
1356 if (DS_UNLIKELY(!m_resource)) {
1357 WRN("could not call wl_input_method::hide_input_panel as it's not initialised");
1360 send_hide_input_panel(
1365 void wl_input_method::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context)
1367 wl_input_method_send_hide_input_panel(
1373 wl_input_panel::wl_input_panel(struct ::wl_client *client, uint32_t id, int version)
1377 , m_globalVersion(0)
1378 , m_displayDestroyedListener()
1380 init(client, id, version);
1383 wl_input_panel::wl_input_panel(struct ::wl_display *display, int version)
1387 , m_globalVersion(0)
1388 , m_displayDestroyedListener()
1390 init(display, version);
1393 wl_input_panel::wl_input_panel(struct ::wl_resource *resource)
1397 , m_globalVersion(0)
1398 , m_displayDestroyedListener()
1403 wl_input_panel::wl_input_panel()
1407 , m_globalVersion(0)
1408 , m_displayDestroyedListener()
1412 wl_input_panel::~wl_input_panel()
1414 std::multimap<struct ::wl_client*, wl_input_panel::Resource*>::iterator it;
1415 for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1416 wl_input_panel::Resource *resource = (*it).second;
1417 wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1421 wl_global_destroy(m_global);
1422 wl_list_remove(&m_displayDestroyedListener.link);
1426 void wl_input_panel::init(struct ::wl_client *client, uint32_t id, int version)
1428 m_resource = bind(client, id, version);
1431 void wl_input_panel::init(struct ::wl_resource *resource)
1433 m_resource = bind(resource);
1436 wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, int version)
1438 Resource *resource = bind(client, 0, version);
1439 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1443 wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, uint32_t id, int version)
1445 Resource *resource = bind(client, id, version);
1446 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1450 void wl_input_panel::init(struct ::wl_display *display, int version)
1452 m_global = wl_global_create(display, &::wl_input_panel_interface, version, this, bind_func);
1453 m_globalVersion = version;
1454 m_displayDestroyedListener.notify = wl_input_panel::display_destroy_func;
1455 m_displayDestroyedListener.parent = this;
1456 wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1459 const struct wl_interface *wl_input_panel::interface()
1461 return &::wl_input_panel_interface;
1464 wl_input_panel::Resource *wl_input_panel::input_panel_allocate()
1466 return new Resource;
1469 void wl_input_panel::input_panel_bind_resource(Resource *)
1473 void wl_input_panel::input_panel_destroy_resource(Resource *)
1477 void wl_input_panel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1479 wl_input_panel *that = static_cast<wl_input_panel *>(data);
1480 that->add(client, id, std::min(that->m_globalVersion, version));
1483 void wl_input_panel::display_destroy_func(struct ::wl_listener *listener, void *data)
1486 wl_input_panel *that = static_cast<wl_input_panel::DisplayDestroyedListener *>(listener)->parent;
1487 that->m_global = NULL;
1490 void wl_input_panel::destroy_func(struct ::wl_resource *client_resource)
1492 Resource *resource = Resource::fromResource(client_resource);
1493 DS_ASSERT(resource);
1494 wl_input_panel *that = resource->input_panel_object;
1495 that->m_resource_map.erase(resource->client());
1496 that->input_panel_destroy_resource(resource);
1500 wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_client *client, uint32_t id, int version)
1502 DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1503 struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_interface, version, id);
1504 return bind(handle);
1507 wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_resource *handle)
1509 Resource *resource = input_panel_allocate();
1510 resource->input_panel_object = this;
1512 wl_resource_set_implementation(handle, &m_wl_input_panel_interface, resource, destroy_func);
1513 resource->handle = handle;
1514 input_panel_bind_resource(resource);
1517 wl_input_panel::Resource *wl_input_panel::Resource::fromResource(struct ::wl_resource *resource)
1519 if (DS_UNLIKELY(!resource))
1521 if (wl_resource_instance_of(resource, &::wl_input_panel_interface, &m_wl_input_panel_interface))
1522 return static_cast<Resource *>(wl_resource_get_user_data(resource));
1526 const struct ::wl_input_panel_interface wl_input_panel::m_wl_input_panel_interface = {
1527 wl_input_panel::handle_get_input_panel_surface
1530 void wl_input_panel::input_panel_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *)
1535 void wl_input_panel::handle_get_input_panel_surface(
1536 ::wl_client *client,
1537 struct wl_resource *resource,
1539 struct ::wl_resource *surface)
1542 Resource *r = Resource::fromResource(resource);
1543 static_cast<wl_input_panel *>(r->input_panel_object)->input_panel_get_input_panel_surface(
1549 wl_input_panel_surface::wl_input_panel_surface(struct ::wl_client *client, uint32_t id, int version)
1553 , m_globalVersion(0)
1554 , m_displayDestroyedListener()
1556 init(client, id, version);
1559 wl_input_panel_surface::wl_input_panel_surface(struct ::wl_display *display, int version)
1563 , m_globalVersion(0)
1564 , m_displayDestroyedListener()
1566 init(display, version);
1569 wl_input_panel_surface::wl_input_panel_surface(struct ::wl_resource *resource)
1573 , m_globalVersion(0)
1574 , m_displayDestroyedListener()
1579 wl_input_panel_surface::wl_input_panel_surface()
1583 , m_globalVersion(0)
1584 , m_displayDestroyedListener()
1588 wl_input_panel_surface::~wl_input_panel_surface()
1590 std::multimap<struct ::wl_client*, wl_input_panel_surface::Resource*>::iterator it;
1591 for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1592 wl_input_panel_surface::Resource *resource = (*it).second;
1593 wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1597 wl_global_destroy(m_global);
1598 wl_list_remove(&m_displayDestroyedListener.link);
1602 void wl_input_panel_surface::init(struct ::wl_client *client, uint32_t id, int version)
1604 m_resource = bind(client, id, version);
1607 void wl_input_panel_surface::init(struct ::wl_resource *resource)
1609 m_resource = bind(resource);
1612 wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, int version)
1614 Resource *resource = bind(client, 0, version);
1615 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1619 wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, uint32_t id, int version)
1621 Resource *resource = bind(client, id, version);
1622 m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1626 void wl_input_panel_surface::init(struct ::wl_display *display, int version)
1628 m_global = wl_global_create(display, &::wl_input_panel_surface_interface, version, this, bind_func);
1629 m_globalVersion = version;
1630 m_displayDestroyedListener.notify = wl_input_panel_surface::display_destroy_func;
1631 m_displayDestroyedListener.parent = this;
1632 wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1635 const struct wl_interface *wl_input_panel_surface::interface()
1637 return &::wl_input_panel_surface_interface;
1640 wl_input_panel_surface::Resource *wl_input_panel_surface::input_panel_surface_allocate()
1642 return new Resource;
1645 void wl_input_panel_surface::input_panel_surface_bind_resource(Resource *)
1649 void wl_input_panel_surface::input_panel_surface_destroy_resource(Resource *)
1653 void wl_input_panel_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1655 wl_input_panel_surface *that = static_cast<wl_input_panel_surface *>(data);
1656 that->add(client, id, std::min(that->m_globalVersion, version));
1659 void wl_input_panel_surface::display_destroy_func(struct ::wl_listener *listener, void *data)
1662 wl_input_panel_surface *that = static_cast<wl_input_panel_surface::DisplayDestroyedListener *>(listener)->parent;
1663 that->m_global = NULL;
1666 void wl_input_panel_surface::destroy_func(struct ::wl_resource *client_resource)
1668 Resource *resource = Resource::fromResource(client_resource);
1669 DS_ASSERT(resource);
1670 wl_input_panel_surface *that = resource->input_panel_surface_object;
1671 that->m_resource_map.erase(resource->client());
1672 that->input_panel_surface_destroy_resource(resource);
1676 wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_client *client, uint32_t id, int version)
1678 DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1679 struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_surface_interface, version, id);
1680 return bind(handle);
1683 wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_resource *handle)
1685 Resource *resource = input_panel_surface_allocate();
1686 resource->input_panel_surface_object = this;
1688 wl_resource_set_implementation(handle, &m_wl_input_panel_surface_interface, resource, destroy_func);
1689 resource->handle = handle;
1690 input_panel_surface_bind_resource(resource);
1693 wl_input_panel_surface::Resource *wl_input_panel_surface::Resource::fromResource(struct ::wl_resource *resource)
1695 if (DS_UNLIKELY(!resource))
1697 if (wl_resource_instance_of(resource, &::wl_input_panel_surface_interface, &m_wl_input_panel_surface_interface))
1698 return static_cast<Resource *>(wl_resource_get_user_data(resource));
1702 const struct ::wl_input_panel_surface_interface wl_input_panel_surface::m_wl_input_panel_surface_interface = {
1703 wl_input_panel_surface::handle_set_toplevel,
1704 wl_input_panel_surface::handle_set_overlay_panel,
1705 wl_input_panel_surface::handle_set_ready,
1706 wl_input_panel_surface::handle_set_floating_panel,
1707 wl_input_panel_surface::handle_set_floating_drag_enabled
1710 void wl_input_panel_surface::input_panel_surface_set_toplevel(Resource *, struct ::wl_resource *, uint32_t )
1714 void wl_input_panel_surface::input_panel_surface_set_overlay_panel(Resource *)
1718 void wl_input_panel_surface::input_panel_surface_set_ready(Resource *, uint32_t )
1722 void wl_input_panel_surface::input_panel_surface_set_floating_panel(Resource *, uint32_t )
1726 void wl_input_panel_surface::input_panel_surface_set_floating_drag_enabled(Resource *, uint32_t )
1731 void wl_input_panel_surface::handle_set_toplevel(
1732 ::wl_client *client,
1733 struct wl_resource *resource,
1734 struct ::wl_resource *output,
1738 Resource *r = Resource::fromResource(resource);
1739 static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_toplevel(
1745 void wl_input_panel_surface::handle_set_overlay_panel(
1746 ::wl_client *client,
1747 struct wl_resource *resource)
1750 Resource *r = Resource::fromResource(resource);
1751 static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_overlay_panel(
1755 void wl_input_panel_surface::handle_set_ready(
1756 ::wl_client *client,
1757 struct wl_resource *resource,
1761 Resource *r = Resource::fromResource(resource);
1762 static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_ready(
1767 void wl_input_panel_surface::handle_set_floating_panel(
1768 ::wl_client *client,
1769 struct wl_resource *resource,
1773 Resource *r = Resource::fromResource(resource);
1774 static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_floating_panel(
1779 void wl_input_panel_surface::handle_set_floating_drag_enabled(
1780 ::wl_client *client,
1781 struct wl_resource *resource,
1785 Resource *r = Resource::fromResource(resource);
1786 static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_floating_drag_enabled(