dswayland-server: add new interface of input-method
[platform/core/uifw/libds.git] / src / DSWaylandServer / dswayland-server-input-method.cpp
1 /*LCOV_EXCL_START*/
2 /* Protocol XML file : wayland-extension/input-method.xml */
3
4 #include "dswayland-server-input-method.h"
5
6 #ifndef DS_UNLIKELY
7 #define DS_UNLIKELY(X) X
8 #endif
9 #ifndef DS_UNUSED
10 #define DS_UNUSED(X) (void)X
11 #endif
12 #ifndef DS_ASSERT
13 #define DS_ASSERT(COND) assert(COND)
14 #endif
15 #ifndef DS_ASSERT_X
16 #define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \
17     do {\
18          if (! (COND))\
19          {\
20              fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\
21              assert(COND);\
22          }\
23     } while(0)
24 #endif
25 #ifndef WRN
26 #define WRN(X...) fprintf(stderr,##X)
27 #endif
28
29 namespace DSWaylandServer {
30     wl_input_method_context::wl_input_method_context(struct ::wl_client *client, uint32_t id, int version)
31         : m_resource_map()
32         , m_resource(NULL)
33         , m_global(NULL)
34         , m_globalVersion(0)
35         , m_displayDestroyedListener()
36     {
37         init(client, id, version);
38     }
39
40     wl_input_method_context::wl_input_method_context(struct ::wl_display *display, int version)
41         : m_resource_map()
42         , m_resource(NULL)
43         , m_global(NULL)
44         , m_globalVersion(0)
45         , m_displayDestroyedListener()
46     {
47         init(display, version);
48     }
49
50     wl_input_method_context::wl_input_method_context(struct ::wl_resource *resource)
51         : m_resource_map()
52         , m_resource(NULL)
53         , m_global(NULL)
54         , m_globalVersion(0)
55         , m_displayDestroyedListener()
56     {
57         init(resource);
58     }
59
60     wl_input_method_context::wl_input_method_context()
61         : m_resource_map()
62         , m_resource(NULL)
63         , m_global(NULL)
64         , m_globalVersion(0)
65         , m_displayDestroyedListener()
66     {
67     }
68
69     wl_input_method_context::~wl_input_method_context()
70     {
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);
75         }
76
77         if (m_global) {
78             wl_global_destroy(m_global);
79             wl_list_remove(&m_displayDestroyedListener.link);
80         }
81     }
82
83     void wl_input_method_context::init(struct ::wl_client *client, uint32_t id, int version)
84     {
85         m_resource = bind(client, id, version);
86     }
87
88     void wl_input_method_context::init(struct ::wl_resource *resource)
89     {
90         m_resource = bind(resource);
91     }
92
93     wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, int version)
94     {
95         Resource *resource = bind(client, 0, version);
96         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
97         return resource;
98     }
99
100     wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, uint32_t id, int version)
101     {
102         Resource *resource = bind(client, id, version);
103         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
104         return resource;
105     }
106
107     void wl_input_method_context::init(struct ::wl_display *display, int version)
108     {
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);
114     }
115
116     const struct wl_interface *wl_input_method_context::interface()
117     {
118         return &::wl_input_method_context_interface;
119     }
120
121     wl_input_method_context::Resource *wl_input_method_context::input_method_context_allocate()
122     {
123         return new Resource;
124     }
125
126     void wl_input_method_context::input_method_context_bind_resource(Resource *)
127     {
128     }
129
130     void wl_input_method_context::input_method_context_destroy_resource(Resource *)
131     {
132     }
133
134     void wl_input_method_context::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
135     {
136         wl_input_method_context *that = static_cast<wl_input_method_context *>(data);
137         that->add(client, id, std::min(that->m_globalVersion, version));
138     }
139
140     void wl_input_method_context::display_destroy_func(struct ::wl_listener *listener, void *data)
141     {
142         DS_UNUSED(data);
143         wl_input_method_context *that = static_cast<wl_input_method_context::DisplayDestroyedListener *>(listener)->parent;
144         that->m_global = NULL;
145     }
146
147     void wl_input_method_context::destroy_func(struct ::wl_resource *client_resource)
148     {
149         Resource *resource = Resource::fromResource(client_resource);
150         DS_ASSERT(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);
154         delete resource;
155     }
156
157     wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_client *client, uint32_t id, int version)
158     {
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);
161         return bind(handle);
162     }
163
164     wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_resource *handle)
165     {
166         Resource *resource = input_method_context_allocate();
167         resource->input_method_context_object = this;
168
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);
172         return resource;
173     }
174     wl_input_method_context::Resource *wl_input_method_context::Resource::fromResource(struct ::wl_resource *resource)
175     {
176         if (DS_UNLIKELY(!resource))
177             return NULL;
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));
180         return NULL;
181     }
182
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
211     };
212
213     void wl_input_method_context::input_method_context_destroy(Resource *)
214     {
215     }
216
217     void wl_input_method_context::input_method_context_commit_string(Resource *, uint32_t , const std::string &)
218     {
219     }
220
221     void wl_input_method_context::input_method_context_preedit_string(Resource *, uint32_t , const std::string &, const std::string &)
222     {
223     }
224
225     void wl_input_method_context::input_method_context_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t )
226     {
227     }
228
229     void wl_input_method_context::input_method_context_preedit_cursor(Resource *, int32_t )
230     {
231     }
232
233     void wl_input_method_context::input_method_context_delete_surrounding_text(Resource *, int32_t , uint32_t )
234     {
235     }
236
237     void wl_input_method_context::input_method_context_cursor_position(Resource *, int32_t , int32_t )
238     {
239     }
240
241     void wl_input_method_context::input_method_context_modifiers_map(Resource *, struct ::wl_array *)
242     {
243     }
244
245     void wl_input_method_context::input_method_context_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
246     {
247     }
248
249     void wl_input_method_context::input_method_context_grab_keyboard(Resource *, uint32_t)
250     {
251     }
252
253     void wl_input_method_context::input_method_context_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t )
254     {
255     }
256
257     void wl_input_method_context::input_method_context_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
258     {
259     }
260
261     void wl_input_method_context::input_method_context_language(Resource *, uint32_t , const std::string &)
262     {
263     }
264
265     void wl_input_method_context::input_method_context_text_direction(Resource *, uint32_t , uint32_t )
266     {
267     }
268
269     void wl_input_method_context::input_method_context_selection_region(Resource *, uint32_t , int32_t , int32_t )
270     {
271     }
272
273     void wl_input_method_context::input_method_context_private_command(Resource *, uint32_t , const std::string &)
274     {
275     }
276
277     void wl_input_method_context::input_method_context_update_input_panel_data(Resource *, uint32_t , const std::string &, uint32_t )
278     {
279     }
280
281     void wl_input_method_context::input_method_context_hide_input_panel(Resource *, uint32_t )
282     {
283     }
284
285     void wl_input_method_context::input_method_context_get_selection_text(Resource *, int32_t )
286     {
287     }
288
289     void wl_input_method_context::input_method_context_get_surrounding_text(Resource *, uint32_t , uint32_t , int32_t )
290     {
291     }
292
293     void wl_input_method_context::input_method_context_filter_key_event_done(Resource *, uint32_t , uint32_t )
294     {
295     }
296
297     void wl_input_method_context::input_method_context_update_ise_geometry(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t )
298     {
299     }
300
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 &)
302     {
303     }
304
305     void wl_input_method_context::input_method_context_input_panel_event(Resource *, uint32_t , uint32_t , uint32_t )
306     {
307     }
308
309     void wl_input_method_context::input_method_context_commit_content(Resource *, uint32_t , const std::string &, const std::string &, const std::string &)
310     {
311     }
312
313     void wl_input_method_context::input_method_context_update_candidate_state(Resource *, uint32_t )
314     {
315     }
316
317     void wl_input_method_context::input_method_context_reshow_input_panel(Resource *)
318     {
319     }
320
321
322     void wl_input_method_context::handle_destroy(
323         ::wl_client *client,
324         struct wl_resource *resource)
325     {
326         DS_UNUSED(client);
327         Resource *r = Resource::fromResource(resource);
328         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_destroy(
329             r);
330     }
331
332     void wl_input_method_context::handle_commit_string(
333         ::wl_client *client,
334         struct wl_resource *resource,
335         uint32_t serial,
336         const char *text)
337     {
338         DS_UNUSED(client);
339         Resource *r = Resource::fromResource(resource);
340         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_commit_string(
341             r,
342             serial,
343             std::string(text));
344     }
345
346     void wl_input_method_context::handle_preedit_string(
347         ::wl_client *client,
348         struct wl_resource *resource,
349         uint32_t serial,
350         const char *text,
351         const char *commit)
352     {
353         DS_UNUSED(client);
354         Resource *r = Resource::fromResource(resource);
355         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_string(
356             r,
357             serial,
358             std::string(text),
359             std::string(commit));
360     }
361
362     void wl_input_method_context::handle_preedit_styling(
363         ::wl_client *client,
364         struct wl_resource *resource,
365         uint32_t index,
366         uint32_t length,
367         uint32_t style)
368     {
369         DS_UNUSED(client);
370         Resource *r = Resource::fromResource(resource);
371         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_styling(
372             r,
373             index,
374             length,
375             style);
376     }
377
378     void wl_input_method_context::handle_preedit_cursor(
379         ::wl_client *client,
380         struct wl_resource *resource,
381         int32_t index)
382     {
383         DS_UNUSED(client);
384         Resource *r = Resource::fromResource(resource);
385         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_preedit_cursor(
386             r,
387             index);
388     }
389
390     void wl_input_method_context::handle_delete_surrounding_text(
391         ::wl_client *client,
392         struct wl_resource *resource,
393         int32_t index,
394         uint32_t length)
395     {
396         DS_UNUSED(client);
397         Resource *r = Resource::fromResource(resource);
398         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_delete_surrounding_text(
399             r,
400             index,
401             length);
402     }
403
404     void wl_input_method_context::handle_cursor_position(
405         ::wl_client *client,
406         struct wl_resource *resource,
407         int32_t index,
408         int32_t anchor)
409     {
410         DS_UNUSED(client);
411         Resource *r = Resource::fromResource(resource);
412         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_cursor_position(
413             r,
414             index,
415             anchor);
416     }
417
418     void wl_input_method_context::handle_modifiers_map(
419         ::wl_client *client,
420         struct wl_resource *resource,
421         struct ::wl_array *map)
422     {
423         DS_UNUSED(client);
424         Resource *r = Resource::fromResource(resource);
425         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_modifiers_map(
426             r,
427             map);
428     }
429
430     void wl_input_method_context::handle_keysym(
431         ::wl_client *client,
432         struct wl_resource *resource,
433         uint32_t serial,
434         uint32_t time,
435         uint32_t sym,
436         uint32_t state,
437         uint32_t modifiers)
438     {
439         DS_UNUSED(client);
440         Resource *r = Resource::fromResource(resource);
441         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_keysym(
442             r,
443             serial,
444             time,
445             sym,
446             state,
447             modifiers);
448     }
449
450     void wl_input_method_context::handle_grab_keyboard(
451         ::wl_client *client,
452         struct wl_resource *resource,
453         uint32_t keyboard)
454     {
455         DS_UNUSED(client);
456         Resource *r = Resource::fromResource(resource);
457         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_grab_keyboard(
458             r,
459             keyboard);
460     }
461
462     void wl_input_method_context::handle_key(
463         ::wl_client *client,
464         struct wl_resource *resource,
465         uint32_t serial,
466         uint32_t time,
467         uint32_t key,
468         uint32_t state)
469     {
470         DS_UNUSED(client);
471         Resource *r = Resource::fromResource(resource);
472         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_key(
473             r,
474             serial,
475             time,
476             key,
477             state);
478     }
479
480     void wl_input_method_context::handle_modifiers(
481         ::wl_client *client,
482         struct wl_resource *resource,
483         uint32_t serial,
484         uint32_t mods_depressed,
485         uint32_t mods_latched,
486         uint32_t mods_locked,
487         uint32_t group)
488     {
489         DS_UNUSED(client);
490         Resource *r = Resource::fromResource(resource);
491         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_modifiers(
492             r,
493             serial,
494             mods_depressed,
495             mods_latched,
496             mods_locked,
497             group);
498     }
499
500     void wl_input_method_context::handle_language(
501         ::wl_client *client,
502         struct wl_resource *resource,
503         uint32_t serial,
504         const char *language)
505     {
506         DS_UNUSED(client);
507         Resource *r = Resource::fromResource(resource);
508         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_language(
509             r,
510             serial,
511             std::string(language));
512     }
513
514     void wl_input_method_context::handle_text_direction(
515         ::wl_client *client,
516         struct wl_resource *resource,
517         uint32_t serial,
518         uint32_t direction)
519     {
520         DS_UNUSED(client);
521         Resource *r = Resource::fromResource(resource);
522         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_text_direction(
523             r,
524             serial,
525             direction);
526     }
527
528     void wl_input_method_context::handle_selection_region(
529         ::wl_client *client,
530         struct wl_resource *resource,
531         uint32_t serial,
532         int32_t start,
533         int32_t end)
534     {
535         DS_UNUSED(client);
536         Resource *r = Resource::fromResource(resource);
537         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_selection_region(
538             r,
539             serial,
540             start,
541             end);
542     }
543
544     void wl_input_method_context::handle_private_command(
545         ::wl_client *client,
546         struct wl_resource *resource,
547         uint32_t serial,
548         const char *command)
549     {
550         DS_UNUSED(client);
551         Resource *r = Resource::fromResource(resource);
552         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_private_command(
553             r,
554             serial,
555             std::string(command));
556     }
557
558     void wl_input_method_context::handle_update_input_panel_data(
559         ::wl_client *client,
560         struct wl_resource *resource,
561         uint32_t serial,
562         const char *input_panel_data,
563         uint32_t input_panel_data_length)
564     {
565         DS_UNUSED(client);
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(
568             r,
569             serial,
570             std::string(input_panel_data),
571             input_panel_data_length);
572     }
573
574     void wl_input_method_context::handle_hide_input_panel(
575         ::wl_client *client,
576         struct wl_resource *resource,
577         uint32_t serial)
578     {
579         DS_UNUSED(client);
580         Resource *r = Resource::fromResource(resource);
581         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_hide_input_panel(
582             r,
583             serial);
584     }
585
586     void wl_input_method_context::handle_get_selection_text(
587         ::wl_client *client,
588         struct wl_resource *resource,
589         int32_t fd)
590     {
591         DS_UNUSED(client);
592         Resource *r = Resource::fromResource(resource);
593         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_get_selection_text(
594             r,
595             fd);
596     }
597
598     void wl_input_method_context::handle_get_surrounding_text(
599         ::wl_client *client,
600         struct wl_resource *resource,
601         uint32_t maxlen_before,
602         uint32_t maxlen_after,
603         int32_t fd)
604     {
605         DS_UNUSED(client);
606         Resource *r = Resource::fromResource(resource);
607         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_get_surrounding_text(
608             r,
609             maxlen_before,
610             maxlen_after,
611             fd);
612     }
613
614     void wl_input_method_context::handle_filter_key_event_done(
615         ::wl_client *client,
616         struct wl_resource *resource,
617         uint32_t serial,
618         uint32_t state)
619     {
620         DS_UNUSED(client);
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(
623             r,
624             serial,
625             state);
626     }
627
628     void wl_input_method_context::handle_update_ise_geometry(
629         ::wl_client *client,
630         struct wl_resource *resource,
631         uint32_t serial,
632         uint32_t x,
633         uint32_t y,
634         uint32_t width,
635         uint32_t height)
636     {
637         DS_UNUSED(client);
638         Resource *r = Resource::fromResource(resource);
639         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_update_ise_geometry(
640             r,
641             serial,
642             x,
643             y,
644             width,
645             height);
646     }
647
648     void wl_input_method_context::handle_recapture_string(
649         ::wl_client *client,
650         struct wl_resource *resource,
651         uint32_t serial,
652         int32_t index,
653         uint32_t length,
654         const char *preedit,
655         const char *preedit_commit,
656         const char *commit)
657     {
658         DS_UNUSED(client);
659         Resource *r = Resource::fromResource(resource);
660         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_recapture_string(
661             r,
662             serial,
663             index,
664             length,
665             std::string(preedit),
666             std::string(preedit_commit),
667             std::string(commit));
668     }
669
670     void wl_input_method_context::handle_input_panel_event(
671         ::wl_client *client,
672         struct wl_resource *resource,
673         uint32_t serial,
674         uint32_t event_type,
675         uint32_t value)
676     {
677         DS_UNUSED(client);
678         Resource *r = Resource::fromResource(resource);
679         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_input_panel_event(
680             r,
681             serial,
682             event_type,
683             value);
684     }
685
686     void wl_input_method_context::handle_commit_content(
687         ::wl_client *client,
688         struct wl_resource *resource,
689         uint32_t serial,
690         const char *content,
691         const char *description,
692         const char *mime_types)
693     {
694         DS_UNUSED(client);
695         Resource *r = Resource::fromResource(resource);
696         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_commit_content(
697             r,
698             serial,
699             std::string(content),
700             std::string(description),
701             std::string(mime_types));
702     }
703
704     void wl_input_method_context::handle_update_candidate_state(
705         ::wl_client *client,
706         struct wl_resource *resource,
707         uint32_t state)
708     {
709         DS_UNUSED(client);
710         Resource *r = Resource::fromResource(resource);
711         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_update_candidate_state(
712             r,
713             state);
714     }
715
716     void wl_input_method_context::handle_reshow_input_panel(
717         ::wl_client *client,
718         struct wl_resource *resource)
719     {
720         DS_UNUSED(client);
721         Resource *r = Resource::fromResource(resource);
722         static_cast<wl_input_method_context *>(r->input_method_context_object)->input_method_context_reshow_input_panel(
723             r);
724     }
725
726     void wl_input_method_context::send_reset()
727     {
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");
731             return;
732         }
733         send_reset(
734             m_resource->handle);
735     }
736
737     void wl_input_method_context::send_reset(struct ::wl_resource *resource)
738     {
739         wl_input_method_context_send_reset(
740             resource);
741     }
742
743
744     void wl_input_method_context::send_content_type(uint32_t hint, uint32_t purpose)
745     {
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");
749             return;
750         }
751         send_content_type(
752             m_resource->handle,
753             hint,
754             purpose);
755     }
756
757     void wl_input_method_context::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose)
758     {
759         wl_input_method_context_send_content_type(
760             resource,
761             hint,
762             purpose);
763     }
764
765
766     void wl_input_method_context::send_invoke_action(uint32_t button, uint32_t index)
767     {
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");
771             return;
772         }
773         send_invoke_action(
774             m_resource->handle,
775             button,
776             index);
777     }
778
779     void wl_input_method_context::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index)
780     {
781         wl_input_method_context_send_invoke_action(
782             resource,
783             button,
784             index);
785     }
786
787
788     void wl_input_method_context::send_commit_state(uint32_t serial)
789     {
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");
793             return;
794         }
795         send_commit_state(
796             m_resource->handle,
797             serial);
798     }
799
800     void wl_input_method_context::send_commit_state(struct ::wl_resource *resource, uint32_t serial)
801     {
802         wl_input_method_context_send_commit_state(
803             resource,
804             serial);
805     }
806
807
808     void wl_input_method_context::send_preferred_language(const std::string &language)
809     {
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");
813             return;
814         }
815         send_preferred_language(
816             m_resource->handle,
817             language);
818     }
819
820     void wl_input_method_context::send_preferred_language(struct ::wl_resource *resource, const std::string &language)
821     {
822         wl_input_method_context_send_preferred_language(
823             resource,
824             language.c_str());
825     }
826
827
828     void wl_input_method_context::send_return_key_type(uint32_t return_key_type)
829     {
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");
833             return;
834         }
835         send_return_key_type(
836             m_resource->handle,
837             return_key_type);
838     }
839
840     void wl_input_method_context::send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type)
841     {
842         wl_input_method_context_send_return_key_type(
843             resource,
844             return_key_type);
845     }
846
847
848     void wl_input_method_context::send_return_key_disabled(uint32_t return_key_disabled)
849     {
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");
853             return;
854         }
855         send_return_key_disabled(
856             m_resource->handle,
857             return_key_disabled);
858     }
859
860     void wl_input_method_context::send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled)
861     {
862         wl_input_method_context_send_return_key_disabled(
863             resource,
864             return_key_disabled);
865     }
866
867
868     void wl_input_method_context::send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length)
869     {
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");
873             return;
874         }
875         send_input_panel_data(
876             m_resource->handle,
877             input_panel_data,
878             input_panel_data_length);
879     }
880
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)
882     {
883         wl_input_method_context_send_input_panel_data(
884             resource,
885             input_panel_data.c_str(),
886             input_panel_data_length);
887     }
888
889
890     void wl_input_method_context::send_bidi_direction(uint32_t direction)
891     {
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");
895             return;
896         }
897         send_bidi_direction(
898             m_resource->handle,
899             direction);
900     }
901
902     void wl_input_method_context::send_bidi_direction(struct ::wl_resource *resource, uint32_t direction)
903     {
904         wl_input_method_context_send_bidi_direction(
905             resource,
906             direction);
907     }
908
909
910     void wl_input_method_context::send_cursor_position(uint32_t cursor_position)
911     {
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");
915             return;
916         }
917         send_cursor_position(
918             m_resource->handle,
919             cursor_position);
920     }
921
922     void wl_input_method_context::send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position)
923     {
924         wl_input_method_context_send_cursor_position(
925             resource,
926             cursor_position);
927     }
928
929
930     void wl_input_method_context::send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length)
931     {
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");
935             return;
936         }
937         send_process_input_device_event(
938             m_resource->handle,
939             event_type,
940             event_data,
941             event_length);
942     }
943
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)
945     {
946         wl_input_method_context_send_process_input_device_event(
947             resource,
948             event_type,
949             event_data.c_str(),
950             event_length);
951     }
952
953
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)
955     {
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");
959             return;
960         }
961         send_filter_key_event(
962             m_resource->handle,
963             serial,
964             time,
965             keyname,
966             state,
967             modifiers,
968             dev_name,
969             dev_class,
970             dev_subclass,
971             keycode);
972     }
973
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)
975     {
976         wl_input_method_context_send_filter_key_event(
977             resource,
978             serial,
979             time,
980             keyname.c_str(),
981             state,
982             modifiers,
983             dev_name.c_str(),
984             dev_class,
985             dev_subclass,
986             keycode);
987     }
988
989
990     void wl_input_method_context::send_capital_mode(uint32_t mode)
991     {
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");
995             return;
996         }
997         send_capital_mode(
998             m_resource->handle,
999             mode);
1000     }
1001
1002     void wl_input_method_context::send_capital_mode(struct ::wl_resource *resource, uint32_t mode)
1003     {
1004         wl_input_method_context_send_capital_mode(
1005             resource,
1006             mode);
1007     }
1008
1009
1010     void wl_input_method_context::send_prediction_hint(const std::string &text)
1011     {
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");
1015             return;
1016         }
1017         send_prediction_hint(
1018             m_resource->handle,
1019             text);
1020     }
1021
1022     void wl_input_method_context::send_prediction_hint(struct ::wl_resource *resource, const std::string &text)
1023     {
1024         wl_input_method_context_send_prediction_hint(
1025             resource,
1026             text.c_str());
1027     }
1028
1029
1030     void wl_input_method_context::send_mime_type(const std::string &type)
1031     {
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");
1035             return;
1036         }
1037         send_mime_type(
1038             m_resource->handle,
1039             type);
1040     }
1041
1042     void wl_input_method_context::send_mime_type(struct ::wl_resource *resource, const std::string &type)
1043     {
1044         wl_input_method_context_send_mime_type(
1045             resource,
1046             type.c_str());
1047     }
1048
1049
1050     void wl_input_method_context::send_finalized_content(const std::string &text, uint32_t cursor_position)
1051     {
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");
1055             return;
1056         }
1057         send_finalized_content(
1058             m_resource->handle,
1059             text,
1060             cursor_position);
1061     }
1062
1063     void wl_input_method_context::send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position)
1064     {
1065         wl_input_method_context_send_finalized_content(
1066             resource,
1067             text.c_str(),
1068             cursor_position);
1069     }
1070
1071
1072     void wl_input_method_context::send_prediction_hint_data(const std::string &key, const std::string &value)
1073     {
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");
1077             return;
1078         }
1079         send_prediction_hint_data(
1080             m_resource->handle,
1081             key,
1082             value);
1083     }
1084
1085     void wl_input_method_context::send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value)
1086     {
1087         wl_input_method_context_send_prediction_hint_data(
1088             resource,
1089             key.c_str(),
1090             value.c_str());
1091     }
1092
1093
1094     void wl_input_method_context::send_input_panel_enabled(uint32_t enabled)
1095     {
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");
1099             return;
1100         }
1101         send_input_panel_enabled(
1102             m_resource->handle,
1103             enabled);
1104     }
1105
1106     void wl_input_method_context::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled)
1107     {
1108         wl_input_method_context_send_input_panel_enabled(
1109             resource,
1110             enabled);
1111     }
1112
1113
1114     wl_input_method::wl_input_method(struct ::wl_client *client, uint32_t id, int version)
1115         : m_resource_map()
1116         , m_resource(NULL)
1117         , m_global(NULL)
1118         , m_globalVersion(0)
1119         , m_displayDestroyedListener()
1120     {
1121         init(client, id, version);
1122     }
1123
1124     wl_input_method::wl_input_method(struct ::wl_display *display, int version)
1125         : m_resource_map()
1126         , m_resource(NULL)
1127         , m_global(NULL)
1128         , m_globalVersion(0)
1129         , m_displayDestroyedListener()
1130     {
1131         init(display, version);
1132     }
1133
1134     wl_input_method::wl_input_method(struct ::wl_resource *resource)
1135         : m_resource_map()
1136         , m_resource(NULL)
1137         , m_global(NULL)
1138         , m_globalVersion(0)
1139         , m_displayDestroyedListener()
1140     {
1141         init(resource);
1142     }
1143
1144     wl_input_method::wl_input_method()
1145         : m_resource_map()
1146         , m_resource(NULL)
1147         , m_global(NULL)
1148         , m_globalVersion(0)
1149         , m_displayDestroyedListener()
1150     {
1151     }
1152
1153     wl_input_method::~wl_input_method()
1154     {
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);
1159         }
1160
1161         if (m_global) {
1162             wl_global_destroy(m_global);
1163             wl_list_remove(&m_displayDestroyedListener.link);
1164         }
1165     }
1166
1167     void wl_input_method::init(struct ::wl_client *client, uint32_t id, int version)
1168     {
1169         m_resource = bind(client, id, version);
1170     }
1171
1172     void wl_input_method::init(struct ::wl_resource *resource)
1173     {
1174         m_resource = bind(resource);
1175     }
1176
1177     wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, int version)
1178     {
1179         Resource *resource = bind(client, 0, version);
1180         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1181         return resource;
1182     }
1183
1184     wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, uint32_t id, int version)
1185     {
1186         Resource *resource = bind(client, id, version);
1187         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1188         return resource;
1189     }
1190
1191     void wl_input_method::init(struct ::wl_display *display, int version)
1192     {
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);
1198     }
1199
1200     const struct wl_interface *wl_input_method::interface()
1201     {
1202         return &::wl_input_method_interface;
1203     }
1204
1205     wl_input_method::Resource *wl_input_method::input_method_allocate()
1206     {
1207         return new Resource;
1208     }
1209
1210     void wl_input_method::input_method_bind_resource(Resource *)
1211     {
1212     }
1213
1214     void wl_input_method::input_method_destroy_resource(Resource *)
1215     {
1216     }
1217
1218     void wl_input_method::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1219     {
1220         wl_input_method *that = static_cast<wl_input_method *>(data);
1221         that->add(client, id, std::min(that->m_globalVersion, version));
1222     }
1223
1224     void wl_input_method::display_destroy_func(struct ::wl_listener *listener, void *data)
1225     {
1226         DS_UNUSED(data);
1227         wl_input_method *that = static_cast<wl_input_method::DisplayDestroyedListener *>(listener)->parent;
1228         that->m_global = NULL;
1229     }
1230
1231     void wl_input_method::destroy_func(struct ::wl_resource *client_resource)
1232     {
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);
1238         delete resource;
1239     }
1240
1241     wl_input_method::Resource *wl_input_method::bind(struct ::wl_client *client, uint32_t id, int version)
1242     {
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);
1246     }
1247
1248     wl_input_method::Resource *wl_input_method::bind(struct ::wl_resource *handle)
1249     {
1250         Resource *resource = input_method_allocate();
1251         resource->input_method_object = this;
1252
1253         wl_resource_set_implementation(handle, NULL, resource, destroy_func);
1254         resource->handle = handle;
1255         input_method_bind_resource(resource);
1256         return resource;
1257     }
1258     wl_input_method::Resource *wl_input_method::Resource::fromResource(struct ::wl_resource *resource)
1259     {
1260         if (DS_UNLIKELY(!resource))
1261             return NULL;
1262         if (wl_resource_instance_of(resource, &::wl_input_method_interface, NULL))
1263             return static_cast<Resource *>(wl_resource_get_user_data(resource));
1264         return NULL;
1265     }
1266
1267     void wl_input_method::send_activate(struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event)
1268     {
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");
1272             return;
1273         }
1274         send_activate(
1275             m_resource->handle,
1276             id,
1277             text_input_id,
1278             focus_in_event);
1279     }
1280
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)
1282     {
1283         wl_input_method_send_activate(
1284             resource,
1285             id,
1286             text_input_id,
1287             focus_in_event);
1288     }
1289
1290
1291     void wl_input_method::send_deactivate(struct ::wl_resource *context, uint32_t focus_out_event)
1292     {
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");
1296             return;
1297         }
1298         send_deactivate(
1299             m_resource->handle,
1300             context,
1301             focus_out_event);
1302     }
1303
1304     void wl_input_method::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t focus_out_event)
1305     {
1306         wl_input_method_send_deactivate(
1307             resource,
1308             context,
1309             focus_out_event);
1310     }
1311
1312
1313     void wl_input_method::send_destroy(struct ::wl_resource *context)
1314     {
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");
1318             return;
1319         }
1320         send_destroy(
1321             m_resource->handle,
1322             context);
1323     }
1324
1325     void wl_input_method::send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context)
1326     {
1327         wl_input_method_send_destroy(
1328             resource,
1329             context);
1330     }
1331
1332
1333     void wl_input_method::send_show_input_panel(struct ::wl_resource *context, uint32_t degree)
1334     {
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");
1338             return;
1339         }
1340         send_show_input_panel(
1341             m_resource->handle,
1342             context,
1343             degree);
1344     }
1345
1346     void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree)
1347     {
1348         wl_input_method_send_show_input_panel(
1349             resource,
1350             context,
1351             degree);
1352     }
1353
1354
1355     void wl_input_method::send_hide_input_panel(struct ::wl_resource *context)
1356     {
1357         DS_ASSERT_X(m_resource, "wl_input_method::hide_input_panel", "Uninitialised resource");
1358         if (DS_UNLIKELY(!m_resource)) {
1359             WRN("could not call wl_input_method::hide_input_panel as it's not initialised");
1360             return;
1361         }
1362         send_hide_input_panel(
1363             m_resource->handle,
1364             context);
1365     }
1366
1367     void wl_input_method::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context)
1368     {
1369         wl_input_method_send_hide_input_panel(
1370             resource,
1371             context);
1372     }
1373
1374
1375     wl_input_panel::wl_input_panel(struct ::wl_client *client, uint32_t id, int version)
1376         : m_resource_map()
1377         , m_resource(NULL)
1378         , m_global(NULL)
1379         , m_globalVersion(0)
1380         , m_displayDestroyedListener()
1381     {
1382         init(client, id, version);
1383     }
1384
1385     wl_input_panel::wl_input_panel(struct ::wl_display *display, int version)
1386         : m_resource_map()
1387         , m_resource(NULL)
1388         , m_global(NULL)
1389         , m_globalVersion(0)
1390         , m_displayDestroyedListener()
1391     {
1392         init(display, version);
1393     }
1394
1395     wl_input_panel::wl_input_panel(struct ::wl_resource *resource)
1396         : m_resource_map()
1397         , m_resource(NULL)
1398         , m_global(NULL)
1399         , m_globalVersion(0)
1400         , m_displayDestroyedListener()
1401     {
1402         init(resource);
1403     }
1404
1405     wl_input_panel::wl_input_panel()
1406         : m_resource_map()
1407         , m_resource(NULL)
1408         , m_global(NULL)
1409         , m_globalVersion(0)
1410         , m_displayDestroyedListener()
1411     {
1412     }
1413
1414     wl_input_panel::~wl_input_panel()
1415     {
1416         std::multimap<struct ::wl_client*, wl_input_panel::Resource*>::iterator it;
1417         for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1418             wl_input_panel::Resource *resource = (*it).second;
1419             wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1420         }
1421
1422         if (m_global) {
1423             wl_global_destroy(m_global);
1424             wl_list_remove(&m_displayDestroyedListener.link);
1425         }
1426     }
1427
1428     void wl_input_panel::init(struct ::wl_client *client, uint32_t id, int version)
1429     {
1430         m_resource = bind(client, id, version);
1431     }
1432
1433     void wl_input_panel::init(struct ::wl_resource *resource)
1434     {
1435         m_resource = bind(resource);
1436     }
1437
1438     wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, int version)
1439     {
1440         Resource *resource = bind(client, 0, version);
1441         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1442         return resource;
1443     }
1444
1445     wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, uint32_t id, int version)
1446     {
1447         Resource *resource = bind(client, id, version);
1448         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1449         return resource;
1450     }
1451
1452     void wl_input_panel::init(struct ::wl_display *display, int version)
1453     {
1454         m_global = wl_global_create(display, &::wl_input_panel_interface, version, this, bind_func);
1455         m_globalVersion = version;
1456         m_displayDestroyedListener.notify = wl_input_panel::display_destroy_func;
1457         m_displayDestroyedListener.parent = this;
1458         wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1459     }
1460
1461     const struct wl_interface *wl_input_panel::interface()
1462     {
1463         return &::wl_input_panel_interface;
1464     }
1465
1466     wl_input_panel::Resource *wl_input_panel::input_panel_allocate()
1467     {
1468         return new Resource;
1469     }
1470
1471     void wl_input_panel::input_panel_bind_resource(Resource *)
1472     {
1473     }
1474
1475     void wl_input_panel::input_panel_destroy_resource(Resource *)
1476     {
1477     }
1478
1479     void wl_input_panel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1480     {
1481         wl_input_panel *that = static_cast<wl_input_panel *>(data);
1482         that->add(client, id, std::min(that->m_globalVersion, version));
1483     }
1484
1485     void wl_input_panel::display_destroy_func(struct ::wl_listener *listener, void *data)
1486     {
1487         DS_UNUSED(data);
1488         wl_input_panel *that = static_cast<wl_input_panel::DisplayDestroyedListener *>(listener)->parent;
1489         that->m_global = NULL;
1490     }
1491
1492     void wl_input_panel::destroy_func(struct ::wl_resource *client_resource)
1493     {
1494         Resource *resource = Resource::fromResource(client_resource);
1495         DS_ASSERT(resource);
1496         wl_input_panel *that = resource->input_panel_object;
1497         that->m_resource_map.erase(resource->client());
1498         that->input_panel_destroy_resource(resource);
1499         delete resource;
1500     }
1501
1502     wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_client *client, uint32_t id, int version)
1503     {
1504         DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1505         struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_interface, version, id);
1506         return bind(handle);
1507     }
1508
1509     wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_resource *handle)
1510     {
1511         Resource *resource = input_panel_allocate();
1512         resource->input_panel_object = this;
1513
1514         wl_resource_set_implementation(handle, &m_wl_input_panel_interface, resource, destroy_func);
1515         resource->handle = handle;
1516         input_panel_bind_resource(resource);
1517         return resource;
1518     }
1519     wl_input_panel::Resource *wl_input_panel::Resource::fromResource(struct ::wl_resource *resource)
1520     {
1521         if (DS_UNLIKELY(!resource))
1522             return NULL;
1523         if (wl_resource_instance_of(resource, &::wl_input_panel_interface, &m_wl_input_panel_interface))
1524             return static_cast<Resource *>(wl_resource_get_user_data(resource));
1525         return NULL;
1526     }
1527
1528     const struct ::wl_input_panel_interface wl_input_panel::m_wl_input_panel_interface = {
1529         wl_input_panel::handle_get_input_panel_surface
1530     };
1531
1532     void wl_input_panel::input_panel_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *)
1533     {
1534     }
1535
1536
1537     void wl_input_panel::handle_get_input_panel_surface(
1538         ::wl_client *client,
1539         struct wl_resource *resource,
1540         uint32_t id,
1541         struct ::wl_resource *surface)
1542     {
1543         DS_UNUSED(client);
1544         Resource *r = Resource::fromResource(resource);
1545         static_cast<wl_input_panel *>(r->input_panel_object)->input_panel_get_input_panel_surface(
1546             r,
1547             id,
1548             surface);
1549     }
1550
1551     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_client *client, uint32_t id, int version)
1552         : m_resource_map()
1553         , m_resource(NULL)
1554         , m_global(NULL)
1555         , m_globalVersion(0)
1556         , m_displayDestroyedListener()
1557     {
1558         init(client, id, version);
1559     }
1560
1561     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_display *display, int version)
1562         : m_resource_map()
1563         , m_resource(NULL)
1564         , m_global(NULL)
1565         , m_globalVersion(0)
1566         , m_displayDestroyedListener()
1567     {
1568         init(display, version);
1569     }
1570
1571     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_resource *resource)
1572         : m_resource_map()
1573         , m_resource(NULL)
1574         , m_global(NULL)
1575         , m_globalVersion(0)
1576         , m_displayDestroyedListener()
1577     {
1578         init(resource);
1579     }
1580
1581     wl_input_panel_surface::wl_input_panel_surface()
1582         : m_resource_map()
1583         , m_resource(NULL)
1584         , m_global(NULL)
1585         , m_globalVersion(0)
1586         , m_displayDestroyedListener()
1587     {
1588     }
1589
1590     wl_input_panel_surface::~wl_input_panel_surface()
1591     {
1592         std::multimap<struct ::wl_client*, wl_input_panel_surface::Resource*>::iterator it;
1593         for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1594             wl_input_panel_surface::Resource *resource = (*it).second;
1595             wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1596         }
1597
1598         if (m_global) {
1599             wl_global_destroy(m_global);
1600             wl_list_remove(&m_displayDestroyedListener.link);
1601         }
1602     }
1603
1604     void wl_input_panel_surface::init(struct ::wl_client *client, uint32_t id, int version)
1605     {
1606         m_resource = bind(client, id, version);
1607     }
1608
1609     void wl_input_panel_surface::init(struct ::wl_resource *resource)
1610     {
1611         m_resource = bind(resource);
1612     }
1613
1614     wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, int version)
1615     {
1616         Resource *resource = bind(client, 0, version);
1617         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1618         return resource;
1619     }
1620
1621     wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, uint32_t id, int version)
1622     {
1623         Resource *resource = bind(client, id, version);
1624         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1625         return resource;
1626     }
1627
1628     void wl_input_panel_surface::init(struct ::wl_display *display, int version)
1629     {
1630         m_global = wl_global_create(display, &::wl_input_panel_surface_interface, version, this, bind_func);
1631         m_globalVersion = version;
1632         m_displayDestroyedListener.notify = wl_input_panel_surface::display_destroy_func;
1633         m_displayDestroyedListener.parent = this;
1634         wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1635     }
1636
1637     const struct wl_interface *wl_input_panel_surface::interface()
1638     {
1639         return &::wl_input_panel_surface_interface;
1640     }
1641
1642     wl_input_panel_surface::Resource *wl_input_panel_surface::input_panel_surface_allocate()
1643     {
1644         return new Resource;
1645     }
1646
1647     void wl_input_panel_surface::input_panel_surface_bind_resource(Resource *)
1648     {
1649     }
1650
1651     void wl_input_panel_surface::input_panel_surface_destroy_resource(Resource *)
1652     {
1653     }
1654
1655     void wl_input_panel_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1656     {
1657         wl_input_panel_surface *that = static_cast<wl_input_panel_surface *>(data);
1658         that->add(client, id, std::min(that->m_globalVersion, version));
1659     }
1660
1661     void wl_input_panel_surface::display_destroy_func(struct ::wl_listener *listener, void *data)
1662     {
1663         DS_UNUSED(data);
1664         wl_input_panel_surface *that = static_cast<wl_input_panel_surface::DisplayDestroyedListener *>(listener)->parent;
1665         that->m_global = NULL;
1666     }
1667
1668     void wl_input_panel_surface::destroy_func(struct ::wl_resource *client_resource)
1669     {
1670         Resource *resource = Resource::fromResource(client_resource);
1671         DS_ASSERT(resource);
1672         wl_input_panel_surface *that = resource->input_panel_surface_object;
1673         that->m_resource_map.erase(resource->client());
1674         that->input_panel_surface_destroy_resource(resource);
1675         delete resource;
1676     }
1677
1678     wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_client *client, uint32_t id, int version)
1679     {
1680         DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1681         struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_surface_interface, version, id);
1682         return bind(handle);
1683     }
1684
1685     wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_resource *handle)
1686     {
1687         Resource *resource = input_panel_surface_allocate();
1688         resource->input_panel_surface_object = this;
1689
1690         wl_resource_set_implementation(handle, &m_wl_input_panel_surface_interface, resource, destroy_func);
1691         resource->handle = handle;
1692         input_panel_surface_bind_resource(resource);
1693         return resource;
1694     }
1695     wl_input_panel_surface::Resource *wl_input_panel_surface::Resource::fromResource(struct ::wl_resource *resource)
1696     {
1697         if (DS_UNLIKELY(!resource))
1698             return NULL;
1699         if (wl_resource_instance_of(resource, &::wl_input_panel_surface_interface, &m_wl_input_panel_surface_interface))
1700             return static_cast<Resource *>(wl_resource_get_user_data(resource));
1701         return NULL;
1702     }
1703
1704     const struct ::wl_input_panel_surface_interface wl_input_panel_surface::m_wl_input_panel_surface_interface = {
1705         wl_input_panel_surface::handle_set_toplevel,
1706         wl_input_panel_surface::handle_set_overlay_panel,
1707         wl_input_panel_surface::handle_set_ready,
1708         wl_input_panel_surface::handle_set_floating_panel,
1709         wl_input_panel_surface::handle_set_floating_drag_enabled
1710     };
1711
1712     void wl_input_panel_surface::input_panel_surface_set_toplevel(Resource *, struct ::wl_resource *, uint32_t )
1713     {
1714     }
1715
1716     void wl_input_panel_surface::input_panel_surface_set_overlay_panel(Resource *)
1717     {
1718     }
1719
1720     void wl_input_panel_surface::input_panel_surface_set_ready(Resource *, uint32_t )
1721     {
1722     }
1723
1724     void wl_input_panel_surface::input_panel_surface_set_floating_panel(Resource *, uint32_t )
1725     {
1726     }
1727
1728     void wl_input_panel_surface::input_panel_surface_set_floating_drag_enabled(Resource *, uint32_t )
1729     {
1730     }
1731
1732
1733     void wl_input_panel_surface::handle_set_toplevel(
1734         ::wl_client *client,
1735         struct wl_resource *resource,
1736         struct ::wl_resource *output,
1737         uint32_t position)
1738     {
1739         DS_UNUSED(client);
1740         Resource *r = Resource::fromResource(resource);
1741         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_toplevel(
1742             r,
1743             output,
1744             position);
1745     }
1746
1747     void wl_input_panel_surface::handle_set_overlay_panel(
1748         ::wl_client *client,
1749         struct wl_resource *resource)
1750     {
1751         DS_UNUSED(client);
1752         Resource *r = Resource::fromResource(resource);
1753         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_overlay_panel(
1754             r);
1755     }
1756
1757     void wl_input_panel_surface::handle_set_ready(
1758         ::wl_client *client,
1759         struct wl_resource *resource,
1760         uint32_t state)
1761     {
1762         DS_UNUSED(client);
1763         Resource *r = Resource::fromResource(resource);
1764         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_ready(
1765             r,
1766             state);
1767     }
1768
1769     void wl_input_panel_surface::handle_set_floating_panel(
1770         ::wl_client *client,
1771         struct wl_resource *resource,
1772         uint32_t state)
1773     {
1774         DS_UNUSED(client);
1775         Resource *r = Resource::fromResource(resource);
1776         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_floating_panel(
1777             r,
1778             state);
1779     }
1780
1781     void wl_input_panel_surface::handle_set_floating_drag_enabled(
1782         ::wl_client *client,
1783         struct wl_resource *resource,
1784         uint32_t enabled)
1785     {
1786         DS_UNUSED(client);
1787         Resource *r = Resource::fromResource(resource);
1788         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_floating_drag_enabled(
1789             r,
1790             enabled);
1791     }
1792
1793     wl_input_method_manager::wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version)
1794         : m_resource_map()
1795         , m_resource(NULL)
1796         , m_global(NULL)
1797         , m_globalVersion(0)
1798         , m_displayDestroyedListener()
1799     {
1800         init(client, id, version);
1801     }
1802
1803     wl_input_method_manager::wl_input_method_manager(struct ::wl_display *display, int version)
1804         : m_resource_map()
1805         , m_resource(NULL)
1806         , m_global(NULL)
1807         , m_globalVersion(0)
1808         , m_displayDestroyedListener()
1809     {
1810         init(display, version);
1811     }
1812
1813     wl_input_method_manager::wl_input_method_manager(struct ::wl_resource *resource)
1814         : m_resource_map()
1815         , m_resource(NULL)
1816         , m_global(NULL)
1817         , m_globalVersion(0)
1818         , m_displayDestroyedListener()
1819     {
1820         init(resource);
1821     }
1822
1823     wl_input_method_manager::wl_input_method_manager()
1824         : m_resource_map()
1825         , m_resource(NULL)
1826         , m_global(NULL)
1827         , m_globalVersion(0)
1828         , m_displayDestroyedListener()
1829     {
1830     }
1831
1832     wl_input_method_manager::~wl_input_method_manager()
1833     {
1834         std::multimap<struct ::wl_client*, wl_input_method_manager::Resource*>::iterator it;
1835         for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) {
1836             wl_input_method_manager::Resource *resource = (*it).second;
1837             wl_resource_set_implementation(resource->handle, NULL, NULL, NULL);
1838         }
1839
1840         if (m_global) {
1841             wl_global_destroy(m_global);
1842             wl_list_remove(&m_displayDestroyedListener.link);
1843         }
1844     }
1845
1846     void wl_input_method_manager::init(struct ::wl_client *client, uint32_t id, int version)
1847     {
1848         m_resource = bind(client, id, version);
1849     }
1850
1851     void wl_input_method_manager::init(struct ::wl_resource *resource)
1852     {
1853         m_resource = bind(resource);
1854     }
1855
1856     wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, int version)
1857     {
1858         Resource *resource = bind(client, 0, version);
1859         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1860         return resource;
1861     }
1862
1863     wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, uint32_t id, int version)
1864     {
1865         Resource *resource = bind(client, id, version);
1866         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1867         return resource;
1868     }
1869
1870     void wl_input_method_manager::init(struct ::wl_display *display, int version)
1871     {
1872         m_global = wl_global_create(display, &::wl_input_method_manager_interface, version, this, bind_func);
1873         m_globalVersion = version;
1874         m_displayDestroyedListener.notify = wl_input_method_manager::display_destroy_func;
1875         m_displayDestroyedListener.parent = this;
1876         wl_display_add_destroy_listener(display, &m_displayDestroyedListener);
1877     }
1878
1879     const struct wl_interface *wl_input_method_manager::interface()
1880     {
1881         return &::wl_input_method_manager_interface;
1882     }
1883
1884     wl_input_method_manager::Resource *wl_input_method_manager::input_method_manager_allocate()
1885     {
1886         return new Resource;
1887     }
1888
1889     void wl_input_method_manager::input_method_manager_bind_resource(Resource *)
1890     {
1891     }
1892
1893     void wl_input_method_manager::input_method_manager_destroy_resource(Resource *)
1894     {
1895     }
1896
1897     void wl_input_method_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1898     {
1899         wl_input_method_manager *that = static_cast<wl_input_method_manager *>(data);
1900         that->add(client, id, std::min(that->m_globalVersion, version));
1901     }
1902
1903     void wl_input_method_manager::display_destroy_func(struct ::wl_listener *listener, void *data)
1904     {
1905         DS_UNUSED(data);
1906         wl_input_method_manager *that = static_cast<wl_input_method_manager::DisplayDestroyedListener *>(listener)->parent;
1907         that->m_global = NULL;
1908     }
1909
1910     void wl_input_method_manager::destroy_func(struct ::wl_resource *client_resource)
1911     {
1912         Resource *resource = Resource::fromResource(client_resource);
1913         DS_ASSERT(resource);
1914         wl_input_method_manager *that = resource->input_method_manager_object;
1915         that->m_resource_map.erase(resource->client());
1916         that->input_method_manager_destroy_resource(resource);
1917         delete resource;
1918     }
1919
1920     wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_client *client, uint32_t id, int version)
1921     {
1922         DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id);
1923         struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_manager_interface, version, id);
1924         return bind(handle);
1925     }
1926
1927     wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_resource *handle)
1928     {
1929         Resource *resource = input_method_manager_allocate();
1930         resource->input_method_manager_object = this;
1931
1932         wl_resource_set_implementation(handle, &m_wl_input_method_manager_interface, resource, destroy_func);
1933         resource->handle = handle;
1934         input_method_manager_bind_resource(resource);
1935         return resource;
1936     }
1937     wl_input_method_manager::Resource *wl_input_method_manager::Resource::fromResource(struct ::wl_resource *resource)
1938     {
1939         if (DS_UNLIKELY(!resource))
1940             return NULL;
1941         if (wl_resource_instance_of(resource, &::wl_input_method_manager_interface, &m_wl_input_method_manager_interface))
1942             return static_cast<Resource *>(wl_resource_get_user_data(resource));
1943         return NULL;
1944     }
1945
1946     const struct ::wl_input_method_manager_interface wl_input_method_manager::m_wl_input_method_manager_interface = {
1947         wl_input_method_manager::handle_set_transient_for
1948     };
1949
1950     void wl_input_method_manager::input_method_manager_set_transient_for(Resource *, uint32_t , uint32_t )
1951     {
1952     }
1953
1954
1955     void wl_input_method_manager::handle_set_transient_for(
1956         ::wl_client *client,
1957         struct wl_resource *resource,
1958         uint32_t parent_pid,
1959         uint32_t child_pid)
1960     {
1961         DS_UNUSED(client);
1962         Resource *r = Resource::fromResource(resource);
1963         static_cast<wl_input_method_manager *>(r->input_method_manager_object)->input_method_manager_set_transient_for(
1964             r,
1965             parent_pid,
1966             child_pid);
1967     }
1968 }
1969
1970 /*LCOV_EXCL_STOP*/