34fb3e6aa72c5ef04190b55d0d1a038074f0cabb
[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)
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     }
1344
1345     void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context)
1346     {
1347         wl_input_method_send_show_input_panel(
1348             resource,
1349             context);
1350     }
1351
1352
1353     void wl_input_method::send_hide_input_panel(struct ::wl_resource *context)
1354     {
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");
1358             return;
1359         }
1360         send_hide_input_panel(
1361             m_resource->handle,
1362             context);
1363     }
1364
1365     void wl_input_method::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context)
1366     {
1367         wl_input_method_send_hide_input_panel(
1368             resource,
1369             context);
1370     }
1371
1372
1373     wl_input_panel::wl_input_panel(struct ::wl_client *client, uint32_t id, int version)
1374         : m_resource_map()
1375         , m_resource(NULL)
1376         , m_global(NULL)
1377         , m_globalVersion(0)
1378         , m_displayDestroyedListener()
1379     {
1380         init(client, id, version);
1381     }
1382
1383     wl_input_panel::wl_input_panel(struct ::wl_display *display, int version)
1384         : m_resource_map()
1385         , m_resource(NULL)
1386         , m_global(NULL)
1387         , m_globalVersion(0)
1388         , m_displayDestroyedListener()
1389     {
1390         init(display, version);
1391     }
1392
1393     wl_input_panel::wl_input_panel(struct ::wl_resource *resource)
1394         : m_resource_map()
1395         , m_resource(NULL)
1396         , m_global(NULL)
1397         , m_globalVersion(0)
1398         , m_displayDestroyedListener()
1399     {
1400         init(resource);
1401     }
1402
1403     wl_input_panel::wl_input_panel()
1404         : m_resource_map()
1405         , m_resource(NULL)
1406         , m_global(NULL)
1407         , m_globalVersion(0)
1408         , m_displayDestroyedListener()
1409     {
1410     }
1411
1412     wl_input_panel::~wl_input_panel()
1413     {
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);
1418         }
1419
1420         if (m_global) {
1421             wl_global_destroy(m_global);
1422             wl_list_remove(&m_displayDestroyedListener.link);
1423         }
1424     }
1425
1426     void wl_input_panel::init(struct ::wl_client *client, uint32_t id, int version)
1427     {
1428         m_resource = bind(client, id, version);
1429     }
1430
1431     void wl_input_panel::init(struct ::wl_resource *resource)
1432     {
1433         m_resource = bind(resource);
1434     }
1435
1436     wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, int version)
1437     {
1438         Resource *resource = bind(client, 0, version);
1439         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1440         return resource;
1441     }
1442
1443     wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, uint32_t id, int version)
1444     {
1445         Resource *resource = bind(client, id, version);
1446         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1447         return resource;
1448     }
1449
1450     void wl_input_panel::init(struct ::wl_display *display, int version)
1451     {
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);
1457     }
1458
1459     const struct wl_interface *wl_input_panel::interface()
1460     {
1461         return &::wl_input_panel_interface;
1462     }
1463
1464     wl_input_panel::Resource *wl_input_panel::input_panel_allocate()
1465     {
1466         return new Resource;
1467     }
1468
1469     void wl_input_panel::input_panel_bind_resource(Resource *)
1470     {
1471     }
1472
1473     void wl_input_panel::input_panel_destroy_resource(Resource *)
1474     {
1475     }
1476
1477     void wl_input_panel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1478     {
1479         wl_input_panel *that = static_cast<wl_input_panel *>(data);
1480         that->add(client, id, std::min(that->m_globalVersion, version));
1481     }
1482
1483     void wl_input_panel::display_destroy_func(struct ::wl_listener *listener, void *data)
1484     {
1485         DS_UNUSED(data);
1486         wl_input_panel *that = static_cast<wl_input_panel::DisplayDestroyedListener *>(listener)->parent;
1487         that->m_global = NULL;
1488     }
1489
1490     void wl_input_panel::destroy_func(struct ::wl_resource *client_resource)
1491     {
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);
1497         delete resource;
1498     }
1499
1500     wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_client *client, uint32_t id, int version)
1501     {
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);
1505     }
1506
1507     wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_resource *handle)
1508     {
1509         Resource *resource = input_panel_allocate();
1510         resource->input_panel_object = this;
1511
1512         wl_resource_set_implementation(handle, &m_wl_input_panel_interface, resource, destroy_func);
1513         resource->handle = handle;
1514         input_panel_bind_resource(resource);
1515         return resource;
1516     }
1517     wl_input_panel::Resource *wl_input_panel::Resource::fromResource(struct ::wl_resource *resource)
1518     {
1519         if (DS_UNLIKELY(!resource))
1520             return NULL;
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));
1523         return NULL;
1524     }
1525
1526     const struct ::wl_input_panel_interface wl_input_panel::m_wl_input_panel_interface = {
1527         wl_input_panel::handle_get_input_panel_surface
1528     };
1529
1530     void wl_input_panel::input_panel_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *)
1531     {
1532     }
1533
1534
1535     void wl_input_panel::handle_get_input_panel_surface(
1536         ::wl_client *client,
1537         struct wl_resource *resource,
1538         uint32_t id,
1539         struct ::wl_resource *surface)
1540     {
1541         DS_UNUSED(client);
1542         Resource *r = Resource::fromResource(resource);
1543         static_cast<wl_input_panel *>(r->input_panel_object)->input_panel_get_input_panel_surface(
1544             r,
1545             id,
1546             surface);
1547     }
1548
1549     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_client *client, uint32_t id, int version)
1550         : m_resource_map()
1551         , m_resource(NULL)
1552         , m_global(NULL)
1553         , m_globalVersion(0)
1554         , m_displayDestroyedListener()
1555     {
1556         init(client, id, version);
1557     }
1558
1559     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_display *display, int version)
1560         : m_resource_map()
1561         , m_resource(NULL)
1562         , m_global(NULL)
1563         , m_globalVersion(0)
1564         , m_displayDestroyedListener()
1565     {
1566         init(display, version);
1567     }
1568
1569     wl_input_panel_surface::wl_input_panel_surface(struct ::wl_resource *resource)
1570         : m_resource_map()
1571         , m_resource(NULL)
1572         , m_global(NULL)
1573         , m_globalVersion(0)
1574         , m_displayDestroyedListener()
1575     {
1576         init(resource);
1577     }
1578
1579     wl_input_panel_surface::wl_input_panel_surface()
1580         : m_resource_map()
1581         , m_resource(NULL)
1582         , m_global(NULL)
1583         , m_globalVersion(0)
1584         , m_displayDestroyedListener()
1585     {
1586     }
1587
1588     wl_input_panel_surface::~wl_input_panel_surface()
1589     {
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);
1594         }
1595
1596         if (m_global) {
1597             wl_global_destroy(m_global);
1598             wl_list_remove(&m_displayDestroyedListener.link);
1599         }
1600     }
1601
1602     void wl_input_panel_surface::init(struct ::wl_client *client, uint32_t id, int version)
1603     {
1604         m_resource = bind(client, id, version);
1605     }
1606
1607     void wl_input_panel_surface::init(struct ::wl_resource *resource)
1608     {
1609         m_resource = bind(resource);
1610     }
1611
1612     wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, int version)
1613     {
1614         Resource *resource = bind(client, 0, version);
1615         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1616         return resource;
1617     }
1618
1619     wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, uint32_t id, int version)
1620     {
1621         Resource *resource = bind(client, id, version);
1622         m_resource_map.insert(std::pair<struct ::wl_client*, Resource*>(client, resource));
1623         return resource;
1624     }
1625
1626     void wl_input_panel_surface::init(struct ::wl_display *display, int version)
1627     {
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);
1633     }
1634
1635     const struct wl_interface *wl_input_panel_surface::interface()
1636     {
1637         return &::wl_input_panel_surface_interface;
1638     }
1639
1640     wl_input_panel_surface::Resource *wl_input_panel_surface::input_panel_surface_allocate()
1641     {
1642         return new Resource;
1643     }
1644
1645     void wl_input_panel_surface::input_panel_surface_bind_resource(Resource *)
1646     {
1647     }
1648
1649     void wl_input_panel_surface::input_panel_surface_destroy_resource(Resource *)
1650     {
1651     }
1652
1653     void wl_input_panel_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id)
1654     {
1655         wl_input_panel_surface *that = static_cast<wl_input_panel_surface *>(data);
1656         that->add(client, id, std::min(that->m_globalVersion, version));
1657     }
1658
1659     void wl_input_panel_surface::display_destroy_func(struct ::wl_listener *listener, void *data)
1660     {
1661         DS_UNUSED(data);
1662         wl_input_panel_surface *that = static_cast<wl_input_panel_surface::DisplayDestroyedListener *>(listener)->parent;
1663         that->m_global = NULL;
1664     }
1665
1666     void wl_input_panel_surface::destroy_func(struct ::wl_resource *client_resource)
1667     {
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);
1673         delete resource;
1674     }
1675
1676     wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_client *client, uint32_t id, int version)
1677     {
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);
1681     }
1682
1683     wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_resource *handle)
1684     {
1685         Resource *resource = input_panel_surface_allocate();
1686         resource->input_panel_surface_object = this;
1687
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);
1691         return resource;
1692     }
1693     wl_input_panel_surface::Resource *wl_input_panel_surface::Resource::fromResource(struct ::wl_resource *resource)
1694     {
1695         if (DS_UNLIKELY(!resource))
1696             return NULL;
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));
1699         return NULL;
1700     }
1701
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
1708     };
1709
1710     void wl_input_panel_surface::input_panel_surface_set_toplevel(Resource *, struct ::wl_resource *, uint32_t )
1711     {
1712     }
1713
1714     void wl_input_panel_surface::input_panel_surface_set_overlay_panel(Resource *)
1715     {
1716     }
1717
1718     void wl_input_panel_surface::input_panel_surface_set_ready(Resource *, uint32_t )
1719     {
1720     }
1721
1722     void wl_input_panel_surface::input_panel_surface_set_floating_panel(Resource *, uint32_t )
1723     {
1724     }
1725
1726     void wl_input_panel_surface::input_panel_surface_set_floating_drag_enabled(Resource *, uint32_t )
1727     {
1728     }
1729
1730
1731     void wl_input_panel_surface::handle_set_toplevel(
1732         ::wl_client *client,
1733         struct wl_resource *resource,
1734         struct ::wl_resource *output,
1735         uint32_t position)
1736     {
1737         DS_UNUSED(client);
1738         Resource *r = Resource::fromResource(resource);
1739         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_toplevel(
1740             r,
1741             output,
1742             position);
1743     }
1744
1745     void wl_input_panel_surface::handle_set_overlay_panel(
1746         ::wl_client *client,
1747         struct wl_resource *resource)
1748     {
1749         DS_UNUSED(client);
1750         Resource *r = Resource::fromResource(resource);
1751         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_overlay_panel(
1752             r);
1753     }
1754
1755     void wl_input_panel_surface::handle_set_ready(
1756         ::wl_client *client,
1757         struct wl_resource *resource,
1758         uint32_t state)
1759     {
1760         DS_UNUSED(client);
1761         Resource *r = Resource::fromResource(resource);
1762         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_ready(
1763             r,
1764             state);
1765     }
1766
1767     void wl_input_panel_surface::handle_set_floating_panel(
1768         ::wl_client *client,
1769         struct wl_resource *resource,
1770         uint32_t state)
1771     {
1772         DS_UNUSED(client);
1773         Resource *r = Resource::fromResource(resource);
1774         static_cast<wl_input_panel_surface *>(r->input_panel_surface_object)->input_panel_surface_set_floating_panel(
1775             r,
1776             state);
1777     }
1778
1779     void wl_input_panel_surface::handle_set_floating_drag_enabled(
1780         ::wl_client *client,
1781         struct wl_resource *resource,
1782         uint32_t enabled)
1783     {
1784         DS_UNUSED(client);
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(
1787             r,
1788             enabled);
1789     }
1790 }
1791
1792 /*LCOV_EXCL_STOP*/