1 #include "tinyds-tdm.h"
5 struct tinyds_server *server;
6 struct ds_output *ds_output;
7 struct ds_allocator *allocator;
8 #ifdef USE_TDM_BUFFER_QUEUE
9 struct tinyds_renderer renderer;
10 struct ds_tdm_buffer_queue *buffer_queue;
11 struct wl_listener buffer_queue_acquirable;
13 struct ds_swapchain *swapchain;
15 struct ds_buffer *front_buffer;
17 struct wl_listener output_destroy;
18 struct wl_listener output_frame;
22 struct wl_event_source *idle_commit;
27 struct ds_tdm_output_hwc *hwc;
28 struct ds_tdm_output_hwc_window *bg_hwc_window;
32 struct ds_tdm_output_hwc_window *cursor_hwc_window;
38 struct ds_tizen_dpms *ds_dpms;
39 struct tinyds_server *server;
41 struct wl_listener destroy;
42 struct wl_listener set_dpms;
43 struct wl_listener get_dpms;
48 struct tinyds_server *server;
50 struct tinyds_texture *texture;
51 struct ds_xdg_surface *xdg_surface;
53 struct wl_listener xdg_surface_map;
54 struct wl_listener xdg_surface_unmap;
55 struct wl_listener xdg_surface_destroy;
56 struct wl_listener surface_commit;
57 struct wl_list link; // tinyds_server::views
59 struct ds_tdm_output_hwc_window *hwc_window;
70 struct ds_input_device *dev;
71 struct tinyds_server *server;
73 struct tinyds_view *focused_view;
75 struct wl_listener destroy;
76 struct wl_listener motion; //relative
77 struct wl_listener button;
78 struct wl_listener frame;
79 struct wl_list link; //tinyds_server::pointers
82 struct tinyds_keyboard
84 struct ds_input_device *dev;
85 struct tinyds_server *server;
87 struct wl_listener destroy;
88 struct wl_listener key;
89 struct wl_list link; //tinyds_server::keyboards
94 struct ds_input_device *dev;
95 struct tinyds_server *server;
97 struct wl_listener destroy;
98 struct wl_listener down;
99 struct wl_listener up;
100 struct wl_listener motion;
103 struct tinyds_text_input {
104 struct ds_tizen_text_input *input;
105 struct ds_tizen_text_input_manager *text_input_mgr;
107 struct tinyds_server *server;
108 struct ds_surface *surface;
110 struct wl_list input_methods;
112 struct wl_listener mgr_destroy;
113 struct wl_listener new_text_input;
115 struct wl_listener destroy;
116 struct wl_listener text_input_activate;
117 struct wl_listener text_input_deactivate;
118 struct wl_listener text_input_reset;
119 struct wl_listener text_input_set_content_type;
120 struct wl_listener text_input_invoke_action;
121 struct wl_listener text_input_commit_state;
122 struct wl_listener text_input_set_preferred_language;
125 struct tinyds_input_method {
126 struct ds_tizen_input_method *input_method;
127 struct ds_tizen_input_method_manager *input_method_mgr;
129 struct tinyds_server *server;
130 struct tinyds_text_input *input;
131 struct tinyds_input_method_context *context;
135 struct wl_listener destroy;
136 struct wl_listener mgr_destroy;
139 struct tinyds_input_method_context {
140 struct ds_tizen_input_method_context *context;
142 struct tinyds_server *server;
143 struct tinyds_text_input *input;
144 struct tinyds_input_method *input_method;
146 struct wl_listener destroy;
148 struct wl_listener im_context_commit_string;
149 struct wl_listener im_context_preedit_string;
150 struct wl_listener im_context_preedit_styling;
151 struct wl_listener im_context_preedit_cursor;
152 struct wl_listener im_context_delete_surrounding_text;
153 struct wl_listener im_context_cursor_position;
154 struct wl_listener im_context_modifiers_map;
155 struct wl_listener im_context_keysym;
156 struct wl_listener im_context_grab_keyboard;
157 struct wl_listener im_context_key;
158 struct wl_listener im_context_modifiers;
159 struct wl_listener im_context_language;
160 struct wl_listener im_context_text_direction;
163 struct tinyds_server tinyds;
165 static bool init_server(struct tinyds_server *server, struct wl_display *display);
166 static int server_dispatch_stdin(int fd, uint32_t mask, void *data);
167 static void output_handle_destroy(struct wl_listener *listener, void *data);
168 static void output_handle_frame(struct wl_listener *listener, void *data);
169 static void draw_server_with_damage(struct tinyds_server *server);
170 static void draw_output(struct tinyds_output *output);
171 static void output_swap_buffer(struct tinyds_output *output,
172 struct ds_buffer *buffer);
173 static void view_send_frame_done(struct tinyds_view *view);
174 static void output_hwc_init(struct tinyds_output *output);
175 static void output_schedule_commit(struct tinyds_output *output);
176 static void output_commit(struct tinyds_output *output);
177 #ifdef USE_TDM_BUFFER_QUEUE
178 static void output_buffer_queue_init(struct tinyds_output *output);
179 static void output_renderer_init(struct tinyds_output *output);
180 static void output_draw_with_renderer(struct tinyds_output *output);
182 static void output_swapchain_init(struct tinyds_output *output,
183 int width, int height, uint32_t format);
184 static void output_draw_with_swapchain(struct tinyds_output *output);
185 static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image);
187 static void dpms_handle_destroy(struct wl_listener *listener, void *data);
188 static void dpms_handle_set_dpms(struct wl_listener *listener, void *data);
189 static void dpms_handle_get_dpms(struct wl_listener *listener, void *data);
190 static void server_add_keyboard(struct tinyds_server *server,
191 struct ds_input_device *dev);
192 static void server_add_pointer(struct tinyds_server *server,
193 struct ds_input_device *dev);
194 static void server_add_touch(struct tinyds_server *server,
195 struct ds_input_device *dev);
196 static struct tinyds_view *
197 server_view_at(struct tinyds_server *server, double lx, double ly,
198 double *sx, double *sy);
200 static bool add_new_text_input(struct tinyds_server *server);
201 static bool add_new_input_method(struct tinyds_server *server);
202 static bool add_new_input_method_context(
203 struct tinyds_input_method *input_method,
204 struct tinyds_text_input *text_input);
206 static void text_input_mgr_handle_destroy(struct wl_listener *listener,
207 void *data TINYDS_UNUSED);
208 static void text_input_mgr_handle_new_text_input(struct wl_listener *listener,
209 void *data TINYDS_UNUSED);
211 static void input_method_mgr_handle_destroy(struct wl_listener *listener,
212 void *data TINYDS_UNUSED);
214 static void input_method_handle_destroy(struct wl_listener *listener,
215 void *data TINYDS_UNUSED);
220 struct tinyds_server *server = &tinyds;
221 struct wl_display *display;
222 struct wl_event_loop *loop;
226 ds_log_init(DS_INF, NULL);
228 display = wl_display_create();
231 res = init_server(server, display);
234 socket = wl_display_add_socket_auto(display);
237 ds_backend_start(server->backend);
238 ds_backend_start(server->input_backend);
240 setenv("WAYLAND_DISPLAY", socket, true);
242 ds_inf("Running Wayland compositor on WAYLAND_DISPLAY=%s", socket);
244 loop = wl_display_get_event_loop(display);
245 server->stdin_source = wl_event_loop_add_fd(loop, STDIN_FILENO,
246 WL_EVENT_READABLE, server_dispatch_stdin, server);
248 wl_display_run(display);
250 protocol_trace_enable(false);
251 protocol_trace_fini();
253 wl_display_destroy_clients(display);
254 wl_display_destroy(display);
260 view_populate_pid(struct tinyds_view *view)
263 struct wl_client *client = NULL;
264 struct ds_surface *surface;
266 surface = ds_xdg_surface_get_surface(view->xdg_surface);
270 client = wl_resource_get_client(ds_surface_get_wl_resource(surface));
274 wl_client_get_credentials(client, &pid, NULL, NULL);
276 ds_inf("view pid(%u)", pid);
279 view->effect_type = ds_tizen_launch_effect_get_effect_type(view->server->effect, pid);
280 ds_tizen_launch_effect_unset_effect_type(view->server->effect, pid);
281 ds_inf("view effect_type(%d)", view->effect_type);
285 view_handle_xdg_surface_map(struct wl_listener *listener,
286 void *data TINYDS_UNUSED)
288 struct tinyds_view *view;
289 struct ds_keyboard *keyboard;
290 struct tinyds_keyboard *kbd;
292 view = wl_container_of(listener, view, xdg_surface_map);
295 view_populate_pid(view);
297 wl_list_for_each(kbd, &view->server->keyboards, link) {
298 keyboard = ds_input_device_get_keyboard(kbd->dev);
299 if (keyboard != NULL) {
300 ds_seat_keyboard_notify_enter(view->server->seat,
301 ds_xdg_surface_get_surface(view->xdg_surface),
302 keyboard->keycodes, keyboard->num_keycodes,
303 &keyboard->modifiers);
310 view_handle_xdg_surface_unmap(struct wl_listener *listener,
311 void *data TINYDS_UNUSED)
313 struct tinyds_view *view;
315 view = wl_container_of(listener, view, xdg_surface_unmap);
316 view->mapped = false;
320 view_handle_xdg_surface_destroy(struct wl_listener *listener,
321 void *data TINYDS_UNUSED)
323 struct tinyds_view *view;
325 view = wl_container_of(listener, view, xdg_surface_destroy);
327 draw_server_with_damage(view->server);
329 ds_tdm_output_hwc_window_destroy(view->hwc_window);
331 wl_list_remove(&view->xdg_surface_destroy.link);
332 wl_list_remove(&view->xdg_surface_map.link);
333 wl_list_remove(&view->xdg_surface_unmap.link);
334 wl_list_remove(&view->surface_commit.link);
335 wl_list_remove(&view->link);
340 view_handle_surface_commit(struct wl_listener *listener,
341 void *data TINYDS_UNUSED)
343 struct tinyds_view *view;
345 view = wl_container_of(listener, view, surface_commit);
346 draw_server_with_damage(view->server);
350 server_new_xdg_surface(struct wl_listener *listener, void *data)
352 static unsigned int seedx = 1;
353 static unsigned int seedy = 43210;
354 struct tinyds_server *server;
355 struct tinyds_view *view;
356 struct ds_xdg_surface *xdg_surface;
358 server = wl_container_of(listener, server, new_xdg_surface);
361 ds_inf("New xdg_surface(%p)", (void *)xdg_surface);
363 view = calloc(1, sizeof *view);
366 view->server = server;
367 view->xdg_surface = xdg_surface;
369 view->xdg_surface_map.notify = view_handle_xdg_surface_map;
370 ds_xdg_surface_add_map_listener(xdg_surface,
371 &view->xdg_surface_map);
373 view->xdg_surface_unmap.notify = view_handle_xdg_surface_unmap;
374 ds_xdg_surface_add_unmap_listener(xdg_surface,
375 &view->xdg_surface_unmap);
377 view->xdg_surface_destroy.notify = view_handle_xdg_surface_destroy;
378 ds_xdg_surface_add_destroy_listener(xdg_surface,
379 &view->xdg_surface_destroy);
381 view->surface_commit.notify = view_handle_surface_commit;
382 ds_surface_add_commit_listener(
383 ds_xdg_surface_get_surface(xdg_surface),
384 &view->surface_commit);
386 view->x = rand_r(&seedx) % 1000;
387 view->y = rand_r(&seedy) % 500;
389 view->hwc_window = ds_tdm_output_hwc_window_create(server->output->hwc);
390 assert(view->hwc_window);
392 wl_list_insert(server->views.prev, &view->link);
395 view->effect_type = -1;
397 ds_inf("view at (%d, %d)", view->x, view->y);
401 backend_handle_new_output(struct wl_listener *listener, void *data)
403 struct tinyds_server *server;
404 struct tinyds_output *output;
405 struct ds_output *ds_output;
406 const struct ds_output_mode *mode;
407 struct ds_tdm_box src_box;
409 server = wl_container_of(listener, server, new_output);
412 ds_inf("New output(%p)", ds_output);
417 mode = ds_output_get_preferred_mode(ds_output);
418 ds_output_set_mode(ds_output, mode);
420 output = calloc(1, sizeof *output);
424 output->server = server;
425 output->ds_output = ds_output;
426 output->width = mode->width;
427 output->height = mode->height;
428 output->damaged = true;
429 output->committable = true;
431 output_hwc_init(output);
433 #ifdef USE_TDM_BUFFER_QUEUE
434 output_buffer_queue_init(output);
435 output_renderer_init(output);
437 output_swapchain_init(output, mode->width, mode->height,
438 DRM_FORMAT_XRGB8888);
441 output->bg_hwc_window = ds_tdm_output_hwc_window_create(output->hwc);
442 assert(output->bg_hwc_window);
446 src_box.width = output->width;
447 src_box.height = output->height;
449 ds_tdm_output_hwc_window_set_src_box(output->bg_hwc_window, &src_box);
450 ds_tdm_output_hwc_window_set_position(output->bg_hwc_window, 0, 0);
451 ds_tdm_output_hwc_window_set_dest_size(output->bg_hwc_window, output->width, output->height);
452 ds_tdm_output_hwc_window_set_transform(output->bg_hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
455 output->cursor_enabled = false;
458 output->output_destroy.notify = output_handle_destroy;
459 ds_output_add_destroy_listener(ds_output, &output->output_destroy);
461 output->output_frame.notify = output_handle_frame;
462 ds_output_add_frame_listener(ds_output, &output->output_frame);
464 ds_tizen_input_devicemgr_set_output_width_height(server->devicemgr, (uint32_t)output->width, (uint32_t)output->height);
466 server->output = output;
467 server->output_x = (double)(output->width) / 2;
468 server->output_y = (double)(output->height) / 2;
470 output_schedule_commit(output);
474 add_new_dpms(struct tinyds_server *server)
476 struct tinyds_dpms *dpms;
478 dpms = calloc(1, sizeof *dpms);
482 dpms->ds_dpms = ds_tizen_dpms_create(server->display);
483 if (!dpms->ds_dpms) {
485 ds_err("Could not create ds_tizen_dpms");
489 dpms->destroy.notify = dpms_handle_destroy;
490 ds_tizen_dpms_add_destroy_listener(dpms->ds_dpms, &dpms->destroy);
492 dpms->set_dpms.notify = dpms_handle_set_dpms;
493 ds_tizen_dpms_add_set_dpms_listener(dpms->ds_dpms, &dpms->set_dpms);
495 dpms->get_dpms.notify = dpms_handle_get_dpms;
496 ds_tizen_dpms_add_get_dpms_listener(dpms->ds_dpms, &dpms->get_dpms);
500 ds_inf("Dpms (%p) added", dpms);
506 backend_handle_new_input(struct wl_listener *listener, void *data)
508 struct tinyds_server *server;
509 struct ds_input_device *dev = data;
510 enum ds_input_device_type dev_type;
512 server = wl_container_of(listener, server, new_input);
514 dev_type = ds_input_device_get_type(dev);
517 case DS_INPUT_DEVICE_KEYBOARD:
518 server_add_keyboard(server, dev);
519 server->seat_caps |= WL_SEAT_CAPABILITY_KEYBOARD;
521 case DS_INPUT_DEVICE_TOUCH:
522 server_add_touch(server, dev);
523 server->seat_caps |= WL_SEAT_CAPABILITY_TOUCH;
525 case DS_INPUT_DEVICE_POINTER:
526 server_add_pointer(server, dev);
527 server->seat_caps |= WL_SEAT_CAPABILITY_POINTER;
530 ds_err("Unknown type(%d) of ds_input_device", dev_type);
534 ds_seat_set_capabilities(server->seat, server->seat_caps);
538 devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode)
540 struct ds_tizen_input_devicemgr_keymap_data *data;
542 data = calloc(1, sizeof *data);
544 ds_err("Failed to alloc memory");
548 data->name = strdup(name);
549 data->keycode = keycode;
551 wl_list_insert(list, &data->link);
555 devicemgr_cleanup_keymap_list(struct wl_list *list)
557 struct ds_tizen_input_devicemgr_keymap_data *data, *tmp;
559 wl_list_for_each_safe(data, tmp, list, link) {
560 wl_list_remove(&data->link);
567 devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr)
569 struct wl_list keymap_list;
572 wl_list_init(&keymap_list);
574 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeRaise", 455);
575 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeLower", 456);
576 devicemgr_add_keymap_data(&keymap_list, "XF86LightOn", 457);
577 devicemgr_add_keymap_data(&keymap_list, "XF86LightOff", 458);
579 res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list);
581 ds_inf("Failed to set keymap");
583 devicemgr_cleanup_keymap_list(&keymap_list);
587 devicemgr_handle_pointer_warp(struct wl_listener *listener, void *data)
589 struct tinyds_server *server;
590 struct tinyds_pointer *pointer;
591 struct ds_tizen_input_devicemgr_event_pointer_warp *event = data;
592 double sx = 0.f, sy = 0.f;
593 struct tinyds_view *view = NULL;
595 server = wl_container_of(listener, server, pointer_warp);
597 ds_inf("Pointer warp: surface(%p) x(%.2f) y(%.2f)", event->surface,
600 wl_list_for_each(pointer, &server->pointers, link){
601 if (!pointer->focused_view) continue;
602 view = pointer->focused_view;
606 if (event->surface != ds_xdg_surface_get_surface(view->xdg_surface)) {
607 ds_inf("Pointer is not on the requested surface");
611 server->output_x = view->x + (event->x * server->output->width);
612 server->output_y = view->y + (event->y * server->output->height);
614 server_view_at(server, server->output_x, server->output_y, &sx, &sy);
616 ds_inf("notify motion: sx:%.2f sy:%.2f, output_x:%.1f, output_y:%.1f",
617 sx, sy, server->output_x, server->output_y);
619 ds_seat_pointer_notify_motion(server->seat,
620 event->time_msec, sx, sy);
624 devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
626 struct tinyds_server *server =
627 wl_container_of(listener, server, devicemgr_destroy);
629 wl_list_remove(&server->devicemgr_destroy.link);
630 wl_list_remove(&server->pointer_warp.link);
632 server->devicemgr = NULL;
636 launch_effect_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
638 struct tinyds_server *server =
639 wl_container_of(listener, server, effect_destroy);
641 wl_list_remove(&server->effect_destroy.link);
642 wl_list_remove(&server->effect_type_set.link);
643 wl_list_remove(&server->effect_type_unset.link);
644 wl_list_remove(&server->new_splash.link);
646 server->effect = NULL;
650 launch_effect_handle_type_set(struct wl_listener *listener, void *data)
652 struct tinyds_server *server;
653 struct ds_tizen_launch_effect_event_type_set *event = data;
654 struct tinyds_view *view = NULL;
655 bool existing = false;
657 server = wl_container_of(listener, server, effect_type_set);
659 ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch");
661 wl_list_for_each(view, &server->views, link) {
662 if (view->pid == event->pid) {
663 view->effect_type = event->effect_type;
664 ds_inf("Launch effect. existing pid");
669 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
671 ds_tizen_launch_effect_set_effect_type(server->effect, event->pid, event->effect_type);
676 launch_effect_handle_type_unset(struct wl_listener *listener, void *data)
678 struct tinyds_server *server;
679 struct ds_tizen_launch_effect_event_type_unset *event = data;
680 struct tinyds_view *view = NULL;
682 server = wl_container_of(listener, server, effect_type_unset);
684 ds_inf("Launch effect. type_unset: pid(%u)", event->pid);
686 wl_list_for_each(view, &server->views, link) {
687 if (view->pid == event->pid) {
688 view->effect_type = -1;
689 ds_inf("Launch effect. pid found");
692 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
696 launch_splash_handle_owner(struct wl_listener *listener, void *data)
698 struct tinyds_server *server;
699 struct ds_tizen_launch_splash_event_owner *event = data;
700 struct tinyds_view *view = NULL;
702 server = wl_container_of(listener, server, splash_owner);
704 ds_inf("Splash owner. pid(%u)", event->pid);
706 wl_list_for_each(view, &server->views, link) {
707 if (view->pid == event->pid) {
708 if (event->pid == ds_tizen_launch_splash_get_pid(server->splash))
711 ds_tizen_launch_splash_set_pid(server->splash, event->pid);
718 launch_effect_handle_new_splash(struct wl_listener *listener, void *data)
720 struct tinyds_server *server;
721 struct ds_tizen_launch_splash *splash = data;
722 struct tinyds_view *view = NULL;
724 server = wl_container_of(listener, server, new_splash);
726 ds_inf("Launch new splash. splash(%p)", splash);
729 server->splash = splash;
731 // new view for "Launchscreen"
732 view = calloc(1, sizeof *view);
734 wl_list_insert(server->views.prev, &view->link);
735 view->pid = ds_tizen_launch_splash_get_pid(splash);
737 server->splash_owner.notify = launch_splash_handle_owner;
738 ds_tizen_launch_splash_add_owner_listener(server->splash,
739 &server->splash_owner);
743 policy_free_func(void *data)
745 struct tinyds_server *server = (struct tinyds_server *)data;
747 server->policy = NULL;
751 init_server(struct tinyds_server *server, struct wl_display *display)
753 server->display = display;
755 wl_list_init(&server->views);
757 if (wl_display_init_shm(display) != 0)
760 server->backend = ds_tdm_backend_create(display);
761 if (!server->backend)
764 server->input_backend = ds_libinput_backend_create(display);
765 if (!server->input_backend) {
766 ds_backend_destroy(server->backend);
770 server->new_output.notify = backend_handle_new_output;
771 ds_backend_add_new_output_listener(server->backend,
772 &server->new_output);
774 wl_list_init(&server->keyboards);
775 wl_list_init(&server->pointers);
776 server->new_input.notify = backend_handle_new_input;
777 ds_backend_add_new_input_listener(server->input_backend, &server->new_input);
779 server->compositor = ds_compositor_create(display);
780 if (!server->compositor)
783 server->tbm_server = ds_tbm_server_create(display);
784 if (!server->tbm_server)
787 server->xdg_shell = ds_xdg_shell_create(display);
788 if (!server->xdg_shell)
791 server->new_xdg_surface.notify = server_new_xdg_surface;
792 ds_xdg_shell_add_new_surface_listener(server->xdg_shell,
793 &server->new_xdg_surface);
795 if (!add_new_dpms(server))
798 server->policy = tinyds_policy_init(server->display, policy_free_func, (void *)server);
802 server->seat = ds_seat_create(display, "seat0" /* arbitrary name */);
805 server->seat_caps = 0;
807 server->devicemgr = ds_tizen_input_devicemgr_create(
808 server->input_backend, server->seat);
809 if (!server->devicemgr) {
810 ds_err("Could not create ds_tizen_input_devicemgr");
814 devicemgr_set_keymap(server->devicemgr);
816 server->devicemgr_destroy.notify = devicemgr_handle_destroy;
817 ds_tizen_input_devicemgr_add_destroy_listener(server->devicemgr,
818 &server->devicemgr_destroy);
820 server->pointer_warp.notify = devicemgr_handle_pointer_warp;
821 ds_tizen_input_devicemgr_add_pointer_warp_listener(server->devicemgr,
822 &server->pointer_warp);
824 server->effect = ds_tizen_launch_effect_create(display);
825 if (!server->effect) {
829 server->effect_destroy.notify = launch_effect_handle_destroy;
830 ds_tizen_launch_effect_add_destroy_listener(server->effect,
831 &server->effect_destroy);
833 server->effect_type_set.notify = launch_effect_handle_type_set;
834 ds_tizen_launch_effect_add_type_set_listener(server->effect,
835 &server->effect_type_set);
837 server->effect_type_unset.notify = launch_effect_handle_type_unset;
838 ds_tizen_launch_effect_add_type_unset_listener(server->effect,
839 &server->effect_type_unset);
841 server->new_splash.notify = launch_effect_handle_new_splash;
842 ds_tizen_launch_effect_add_new_splash_listener(server->effect,
843 &server->new_splash);
845 if (!add_new_text_input(server))
848 if (!add_new_input_method(server))
851 if (protocol_trace_init(display))
852 protocol_trace_enable(true);
857 ds_backend_destroy(server->backend);
858 ds_backend_destroy(server->input_backend);
864 output_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
866 struct tinyds_output *output =
867 wl_container_of(listener, output, output_destroy);
869 if (output->bg_hwc_window)
870 ds_tdm_output_hwc_window_destroy(output->bg_hwc_window);
872 wl_list_remove(&output->output_destroy.link);
873 wl_list_remove(&output->output_frame.link);
875 if (output->front_buffer)
876 ds_buffer_unlock(output->front_buffer);
878 #ifdef USE_TDM_BUFFER_QUEUE
879 fini_renderer(&output->renderer);
881 if (output->swapchain)
882 ds_swapchain_destroy(output->swapchain);
884 if (output->allocator)
885 ds_allocator_destroy(output->allocator);
888 wl_display_terminate(output->server->display);
890 output->server->output = NULL;
896 output_commit(struct tinyds_output *output)
898 uint32_t num_changed = 0;
899 uint32_t num_windows = 0, current_num_windows = 0;
900 struct ds_tdm_output_hwc_window **composited_hwc_windows = NULL;
901 struct ds_tdm_output_hwc_window **changed_hwc_windows = NULL;
902 enum ds_tdm_output_hwc_window_composition composition;
903 struct tinyds_view *view;
905 bool need_target = false;
906 bool fully_obscured = false;
907 struct ds_buffer *ds_buffer;
908 struct ds_tdm_box src_box;
911 if (!output->committable)
914 if (!output->damaged && !output->target_updated)
917 wl_list_for_each_reverse(view, &output->server->views, link) {
918 if (!view->hwc_window)
921 ds_buffer = ds_surface_get_buffer(
922 ds_xdg_surface_get_surface(view->xdg_surface));
931 ds_buffer_get_size(ds_buffer, &w, &h);
933 if ((output->width <= w) && (output->height <= h))
934 fully_obscured = true;
937 if (fully_obscured) {
938 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
939 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
941 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
942 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT);
948 if (output->cursor_hwc_window) {
951 src_box.width = CURSOR_W;
952 src_box.height = CURSOR_H;
954 ds_tdm_output_hwc_window_set_src_box(output->cursor_hwc_window, &src_box);
955 ds_tdm_output_hwc_window_set_position(output->cursor_hwc_window, output->server->output_x, output->server->output_y);
956 ds_tdm_output_hwc_window_set_dest_size(output->cursor_hwc_window, CURSOR_W, CURSOR_H);
957 ds_tdm_output_hwc_window_set_transform(output->cursor_hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
959 ds_tdm_output_hwc_window_set_composition(output->cursor_hwc_window,
960 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT);
967 composited_hwc_windows = calloc(num_windows, sizeof *composited_hwc_windows);
968 if (!composited_hwc_windows)
971 wl_list_for_each_reverse(view, &output->server->views, link) {
972 if (!view->hwc_window)
975 ds_buffer = ds_surface_get_buffer(
976 ds_xdg_surface_get_surface(view->xdg_surface));
980 ds_tdm_output_hwc_window_set_buffer(view->hwc_window, ds_buffer);
982 ds_buffer_get_size(ds_buffer, &w, &h);
989 ds_tdm_output_hwc_window_set_src_box(view->hwc_window, &src_box);
990 ds_tdm_output_hwc_window_set_position(view->hwc_window, view->x, view->y);
991 ds_tdm_output_hwc_window_set_dest_size(view->hwc_window, w, h);
992 ds_tdm_output_hwc_window_set_transform(view->hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
996 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
997 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT);
999 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1000 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE);
1002 composited_hwc_windows[current_num_windows] = view->hwc_window;
1003 current_num_windows++;
1005 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1006 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
1010 if (!fully_obscured) {
1011 composited_hwc_windows[current_num_windows] = output->bg_hwc_window;
1012 current_num_windows++;
1016 if (output->cursor_hwc_window) {
1017 composited_hwc_windows[current_num_windows] = output->cursor_hwc_window;
1018 current_num_windows++;
1023 if (!ds_tdm_output_hwc_validate(output->hwc, composited_hwc_windows,
1024 num_windows, &num_changed)) {
1025 free(composited_hwc_windows);
1026 ds_err("Could not hwc validate");
1030 if (composited_hwc_windows)
1031 free(composited_hwc_windows);
1033 if (num_changed > 0) {
1034 changed_hwc_windows = calloc(num_windows, sizeof *changed_hwc_windows);
1035 if (!changed_hwc_windows)
1038 if (!ds_tdm_output_hwc_get_changed_composition(output->hwc, &num_changed,
1039 changed_hwc_windows)) {
1040 free(changed_hwc_windows);
1041 ds_err("Could not get chaged composition");
1045 for (i = 0; i < num_changed; i++) {
1046 composition = ds_tdm_output_hwc_window_get_composition(changed_hwc_windows[i]);
1047 if (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT) {
1054 if (changed_hwc_windows)
1055 free(changed_hwc_windows);
1057 if (need_target && output->damaged)
1058 draw_output(output);
1060 #ifdef USE_TDM_BUFFER_QUEUE
1061 struct ds_buffer *buffer;
1063 buffer = ds_tdm_buffer_queue_acquire(output->buffer_queue);
1065 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, buffer)) {
1066 ds_err("Could not set hwc client target buffer");
1070 output_swap_buffer(output, buffer);
1074 if (!ds_tdm_output_hwc_accept_validation(output->hwc)) {
1075 ds_err("Could not hwc accept validateion");
1079 ds_output_commit(output->ds_output);
1081 output->committable = false;
1082 output->damaged = false;
1083 output->target_updated = false;
1085 wl_list_for_each(view, &output->server->views, link) {
1086 enum ds_tdm_output_hwc_window_composition composition;
1091 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1092 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1093 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1094 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1095 view_send_frame_done(view);
1098 ds_dbg("output:%p commit", output);
1102 output_handle_frame(struct wl_listener *listener, void *data TINYDS_UNUSED)
1104 struct tinyds_output *output =
1105 wl_container_of(listener, output, output_frame);
1107 ds_dbg("output:%p handle frame", output);
1109 output->committable = true;
1111 output_commit(output);
1115 draw_server_with_damage(struct tinyds_server *server)
1117 server->output->damaged = true;
1118 output_schedule_commit(server->output);
1122 output_hwc_init(struct tinyds_output *output)
1124 struct ds_tdm_output *tdm_output;
1126 tdm_output = ds_tdm_output_from_output(output->ds_output);
1129 output->hwc = ds_tdm_output_get_hwc(tdm_output);
1130 assert(output->hwc);
1132 ds_tdm_output_hwc_set_enabled(output->hwc, true);
1135 #ifdef USE_TDM_BUFFER_QUEUE
1137 output_handle_buffer_queue_acquirable(struct wl_listener *listener,
1138 void *data TINYDS_UNUSED)
1140 struct tinyds_output *output;
1142 output = wl_container_of(listener, output, buffer_queue_acquirable);
1144 output->target_updated = true;
1145 output_schedule_commit(output);
1149 output_buffer_queue_init(struct tinyds_output *output)
1151 struct ds_tdm_output *tdm_output;
1153 tdm_output = ds_tdm_output_from_output(output->ds_output);
1156 output->buffer_queue = ds_tdm_output_get_buffer_queue(tdm_output);
1157 assert(output->buffer_queue);
1159 output->buffer_queue_acquirable.notify =
1160 output_handle_buffer_queue_acquirable;
1161 ds_tdm_buffer_queue_add_acquirable_listener(output->buffer_queue,
1162 &output->buffer_queue_acquirable);
1166 output_renderer_init(struct tinyds_output *output)
1168 init_renderer(&output->renderer);
1170 renderer_set_surface_queue(&output->renderer,
1171 ds_tdm_buffer_queue_get_native_queue(output->buffer_queue));
1173 renderer_set_bg_color(&output->renderer, 80, 80, 80);
1177 output_draw_with_renderer(struct tinyds_output *output)
1179 struct tinyds_view *view;
1181 ds_dbg(">> BEGIN UPDATE TEXTURES");
1183 wl_list_for_each(view, &output->server->views, link) {
1184 struct ds_buffer *ds_buffer;
1185 struct ds_tbm_client_buffer *tbm_buffer;
1186 tbm_surface_h surface;
1187 enum ds_tdm_output_hwc_window_composition composition;
1192 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1193 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1194 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1195 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1198 ds_buffer = ds_surface_get_buffer(
1199 ds_xdg_surface_get_surface(view->xdg_surface));
1203 tbm_buffer = ds_tbm_client_buffer_from_buffer(ds_buffer);
1207 surface = ds_tbm_client_buffer_get_tbm_surface(tbm_buffer);
1211 renderer_add_texture(&output->renderer, surface, view->x, view->y);
1213 view_send_frame_done(view);
1216 ds_dbg("<< END UPDATE TEXTURES");
1218 renderer_draw(&output->renderer);
1222 output_swapchain_init(struct tinyds_output *output,
1223 int width, int height, uint32_t format)
1226 output->allocator = ds_tbm_allocator_create();
1227 assert(output->allocator);
1229 output->swapchain = ds_swapchain_create(output->allocator,
1230 width, height, format);
1231 assert(output->swapchain);
1235 output_draw_with_swapchain(struct tinyds_output *output)
1237 struct tinyds_view *view;
1238 struct ds_buffer *output_buffer;
1239 pixman_image_t *output_image;
1240 enum ds_tdm_output_hwc_window_composition composition;
1242 output_buffer = ds_swapchain_acquire(output->swapchain, NULL);
1246 output_image = pixman_image_from_buffer(output_buffer,
1247 DS_BUFFER_DATA_PTR_ACCESS_WRITE);
1248 if (!output_image) {
1249 ds_buffer_unlock(output_buffer);
1253 pixman_image_fill_color(output_image, 80, 80, 80);
1255 wl_list_for_each(view, &output->server->views, link) {
1259 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1260 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1261 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1262 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1265 draw_view(view, output_image);
1267 pixman_image_unref(output_image);
1269 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, output_buffer)) {
1270 ds_err("Could not set hwc client target buffer");
1271 ds_buffer_unlock(output_buffer);
1275 output_swap_buffer(output, output_buffer);
1279 draw_view(struct tinyds_view *view, pixman_image_t *dst_image)
1281 struct ds_buffer *buffer;
1282 pixman_image_t *src_image;
1284 buffer = ds_surface_get_buffer(
1285 ds_xdg_surface_get_surface(view->xdg_surface));
1289 src_image = pixman_image_from_buffer(buffer,
1290 DS_BUFFER_DATA_PTR_ACCESS_READ);
1291 pixman_image_composite32(PIXMAN_OP_OVER,
1297 pixman_image_get_width(src_image),
1298 pixman_image_get_height(src_image));
1299 pixman_image_unref(src_image);
1301 view_send_frame_done(view);
1306 draw_output(struct tinyds_output *output)
1308 #ifdef USE_TDM_BUFFER_QUEUE
1309 output_draw_with_renderer(output);
1311 output_draw_with_swapchain(output);
1314 ds_dbg("output:%p draw", output);
1318 output_swap_buffer(struct tinyds_output *output, struct ds_buffer *buffer)
1320 ds_output_attach_buffer(output->ds_output, buffer);
1322 if (output->front_buffer)
1323 ds_buffer_unlock(output->front_buffer);
1324 output->front_buffer = buffer;
1328 view_send_frame_done(struct tinyds_view *view)
1330 struct timespec now;
1331 clock_gettime(CLOCK_MONOTONIC, &now);
1332 ds_surface_send_frame_done(ds_xdg_surface_get_surface(view->xdg_surface),
1337 server_dispatch_stdin(int fd, uint32_t mask, void *data)
1339 struct tinyds_server *server = data;
1341 wl_display_terminate(server->display);
1347 dpms_handle_destroy(struct wl_listener *listener, void *data)
1349 struct tinyds_dpms *dpms;
1351 dpms = wl_container_of(listener, dpms, destroy);
1353 ds_inf("Dpms(%p) destroyed", dpms);
1355 wl_list_remove(&dpms->destroy.link);
1356 wl_list_remove(&dpms->set_dpms.link);
1357 wl_list_remove(&dpms->get_dpms.link);
1363 dpms_handle_set_dpms(struct wl_listener *listener, void *data)
1365 struct tinyds_dpms *dpms;
1366 struct ds_tizen_dpms_event *event = data;
1368 dpms = wl_container_of(listener, dpms, set_dpms);
1370 ds_inf("Dpms(%p) set dpms : %d", dpms, event->mode);
1373 //set dpms mode to output
1374 ds_tizen_dpms_send_set_result(dpms->ds_dpms, event->mode,
1375 DS_TIZEN_DPMS_ERROR_NONE);
1379 dpms_handle_get_dpms(struct wl_listener *listener, void *data)
1381 struct tinyds_dpms *dpms;
1383 dpms = wl_container_of(listener, dpms, get_dpms);
1385 ds_inf("Dpms(%p) get dpms", dpms);
1388 //get dpms mode from output
1389 ds_tizen_dpms_send_get_result(dpms->ds_dpms, DS_TIZEN_DPMS_MODE_ON,
1390 DS_TIZEN_DPMS_ERROR_NONE);
1394 keyboard_handle_device_destroy(struct wl_listener *listener, void *data)
1396 struct tinyds_keyboard *kbd;
1398 kbd = wl_container_of(listener, kbd, destroy);
1400 ds_inf("Keyboard(%p) destroyed", kbd);
1402 wl_list_remove(&kbd->destroy.link);
1403 wl_list_remove(&kbd->key.link);
1404 wl_list_remove(&kbd->link);
1410 server_handle_keybinding(struct tinyds_server *server, xkb_keysym_t sym)
1413 case XKB_KEY_BackSpace:
1414 wl_display_terminate(server->display);
1424 keyboard_handle_key(struct wl_listener *listener, void *data)
1426 struct tinyds_keyboard *kbd;
1427 struct ds_event_keyboard_key *event = data;
1428 struct ds_keyboard *ds_keyboard;
1429 struct xkb_state *xkb_state;
1430 const xkb_keysym_t *syms;
1432 bool handled = false;
1434 kbd = wl_container_of(listener, kbd, key);
1436 ds_inf("Keyboard(%p) event key: keycode(%d), state(%d), time_msec(%d), "
1437 "update_state(%d)", kbd->dev,
1438 event->keycode, event->state, event->time_msec,
1439 event->update_state);
1441 ds_keyboard = ds_input_device_get_keyboard(kbd->dev);
1443 if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
1444 xkb_state = ds_keyboard_get_xkb_state(ds_keyboard);
1446 nsyms = xkb_state_key_get_syms(xkb_state, event->keycode + 8,
1448 for (int i = 0; i < nsyms; i++) {
1449 handled = server_handle_keybinding(kbd->server, syms[i]);
1455 ds_seat_keyboard_notify_key(kbd->server->seat, event->time_msec,
1456 event->keycode, event->state);
1461 server_add_keyboard(struct tinyds_server *server, struct ds_input_device *dev)
1463 struct tinyds_keyboard *kbd;
1464 struct xkb_context *context;
1465 struct xkb_keymap *keymap;
1467 kbd = calloc(1, sizeof *kbd);
1471 kbd->server = server;
1473 context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
1477 keymap = xkb_keymap_new_from_names(context, NULL,
1478 XKB_KEYMAP_COMPILE_NO_FLAGS);
1481 ds_err("Failed to compile keymap");
1482 xkb_context_unref(context);
1486 ds_keyboard_set_keymap(ds_input_device_get_keyboard(dev), keymap);
1488 xkb_keymap_unref(keymap);
1489 xkb_context_unref(context);
1491 kbd->destroy.notify = keyboard_handle_device_destroy;
1492 ds_input_device_add_destroy_listener(dev, &kbd->destroy);
1494 kbd->key.notify = keyboard_handle_key;
1495 ds_keyboard_add_key_listener(ds_input_device_get_keyboard(dev), &kbd->key);
1497 wl_list_insert(&server->keyboards, &kbd->link);
1499 ds_inf("Keyboard(%p) added", kbd);
1507 static struct tinyds_view *
1508 server_view_at(struct tinyds_server *server, double lx, double ly,
1509 double *sx, double *sy)
1511 struct tinyds_view *view;
1512 struct ds_surface *surface;
1513 struct ds_buffer *buffer;
1514 int x, y, w = 0, h = 0;
1516 wl_list_for_each(view, &server->views, link) {
1517 surface = ds_xdg_surface_get_surface(view->xdg_surface);
1518 buffer = ds_surface_get_buffer(surface);
1519 ds_buffer_get_size(buffer, &w, &h);
1524 if (lx >= x && lx <= x + w && ly >= y && ly <= y + h) {
1536 touch_handle_device_destroy(struct wl_listener *listener, void *data)
1538 struct tinyds_touch *touch;
1540 touch = wl_container_of(listener, touch, destroy);
1542 ds_inf("Touch(%p) destroyed", touch);
1544 wl_list_remove(&touch->destroy.link);
1545 wl_list_remove(&touch->down.link);
1546 wl_list_remove(&touch->up.link);
1547 wl_list_remove(&touch->motion.link);
1553 touch_handle_down(struct wl_listener *listener, void *data)
1555 struct ds_event_touch_down *event = data;
1556 struct tinyds_touch *touch;
1557 struct tinyds_view *view;
1558 struct tinyds_server *server;
1559 double sx = 0.f, sy = 0.f;
1561 touch = wl_container_of(listener, touch, down);
1563 server = touch->server;
1564 server->output_x = event->x * server->output->width;
1565 server->output_y = event->y * server->output->height;
1567 ds_inf("Touch(%p) event down: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1568 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1570 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1573 ds_seat_touch_notify_down(touch->server->seat, ds_xdg_surface_get_surface(view->xdg_surface),
1574 event->time_msec, event->id, sx, sy);
1578 if (server->output && server->output->cursor_enabled) {
1579 renderer_cursor_update(&server->output->renderer, server->output_x, server->output_y);
1580 draw_server_with_damage(server);
1586 touch_handle_up(struct wl_listener *listener, void *data)
1588 struct ds_event_touch_up *event = data;
1589 struct tinyds_touch *touch;
1591 touch = wl_container_of(listener, touch, up);
1593 ds_inf("Touch(%p) event up: id(%d) time_msec(%d)",
1594 touch->dev, event->id, event->time_msec);
1596 ds_seat_touch_notify_up(touch->server->seat, event->time_msec, event->id);
1600 touch_handle_motion(struct wl_listener *listener, void *data)
1602 struct ds_event_touch_motion *event = data;
1603 struct tinyds_touch *touch;
1604 struct tinyds_view *view;
1605 struct tinyds_server *server;
1606 double sx = 0.f, sy = 0.f;
1608 touch = wl_container_of(listener, touch, motion);
1610 server = touch->server;
1611 server->output_x = event->x * server->output->width;
1612 server->output_y = event->y * server->output->height;
1614 ds_inf("Touch(%p) event motion: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1615 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1617 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1620 ds_seat_touch_notify_motion(server->seat, event->time_msec,
1625 if (server->output && server->output->cursor_enabled) {
1626 renderer_cursor_update(&server->output->renderer, server->output_x, server->output_y);
1627 draw_server_with_damage(server);
1633 server_add_touch(struct tinyds_server *server, struct ds_input_device *dev)
1635 struct tinyds_touch *touch;
1637 touch = calloc(1, sizeof *touch);
1641 touch->server = server;
1643 touch->destroy.notify = touch_handle_device_destroy;
1644 ds_input_device_add_destroy_listener(dev, &touch->destroy);
1646 touch->down.notify = touch_handle_down;
1647 ds_touch_add_down_listener(ds_input_device_get_touch(dev), &touch->down);
1649 touch->up.notify = touch_handle_up;
1650 ds_touch_add_up_listener(ds_input_device_get_touch(dev), &touch->up);
1652 touch->motion.notify = touch_handle_motion;
1653 ds_touch_add_motion_listener(ds_input_device_get_touch(dev), &touch->motion);
1655 ds_inf("Touch(%p) added", touch);
1659 pointer_handle_device_destroy(struct wl_listener *listener, void *data)
1661 struct tinyds_pointer *pointer;
1662 struct tinyds_server *server;
1664 pointer = wl_container_of(listener, pointer, destroy);
1666 ds_inf("Pointer(%p) destroyed", pointer);
1668 wl_list_remove(&pointer->destroy.link);
1669 wl_list_remove(&pointer->motion.link);
1670 wl_list_remove(&pointer->button.link);
1671 wl_list_remove(&pointer->frame.link);
1672 wl_list_remove(&pointer->link);
1675 server = pointer->server;
1676 if (server->output && wl_list_empty(&server->pointers))
1678 server->output->cursor_enabled = false;
1679 renderer_cursor_destroy(&server->output->renderer);
1681 if (server->output->cursor_hwc_window)
1683 ds_tdm_output_hwc_window_destroy(server->output->cursor_hwc_window);
1684 server->output->cursor_hwc_window = NULL;
1686 draw_server_with_damage(server);
1694 pointer_handle_motion(struct wl_listener *listener, void *data)
1696 struct tinyds_pointer *pointer;
1697 struct ds_event_pointer_motion *event = data;
1698 struct tinyds_view *view;
1699 struct tinyds_server *server;
1703 pointer = wl_container_of(listener, pointer, motion);
1705 server = pointer->server;
1706 if (server->output) {
1707 ow = server->output->width;
1708 oh = server->output->height;
1711 if (server->output_x + event->delta_x >= ow)
1712 server->output_x = ow;
1713 else if(server->output_x + event->delta_x <= 0.f)
1714 server->output_x = 0.f;
1716 server->output_x = server->output_x + event->delta_x ;
1717 if (server->output_y + event->delta_y >= oh)
1718 server->output_y = oh;
1719 else if(server->output_y + event->delta_y <= 0.f)
1720 server->output_y = 0.f;
1722 server->output_y = server->output_y + event->delta_y ;
1724 ds_inf("Pointer(%p) motion: (delta_x %.1f delta_y %.1f) output_x %.1f output_y %.1f",
1725 pointer, event->delta_x, event->delta_y, server->output_x, server->output_y);
1727 view = server_view_at(pointer->server, server->output_x, server->output_y, &sx, &sy);
1729 if (pointer->focused_view != view) {
1730 if (pointer->focused_view) {
1731 ds_inf("Clear pointer focus from view(%p)", pointer->focused_view);
1732 ds_seat_pointer_notify_clear_focus(pointer->server->seat);
1733 pointer->focused_view = NULL;
1737 ds_inf("Set pointer focus to view(%p)", view);
1738 ds_seat_pointer_notify_enter(pointer->server->seat,
1739 ds_xdg_surface_get_surface(view->xdg_surface), sx, sy);
1740 pointer->focused_view = view;
1745 ds_seat_pointer_notify_motion(pointer->server->seat,
1746 event->time_msec, sx, sy);
1750 if (server->output && server->output->cursor_enabled) {
1751 renderer_cursor_update(&server->output->renderer, server->output_x, server->output_y);
1752 draw_server_with_damage(server);
1758 pointer_handle_button(struct wl_listener *listener, void *data)
1760 struct tinyds_pointer *pointer;
1761 struct ds_event_pointer_button *event = data;
1763 pointer = wl_container_of(listener, pointer, button);
1765 ds_inf("Pointer(%p) button(%d): state(%s) time(%d)",
1766 pointer, event->button,
1767 (event->state == DS_BUTTON_PRESSED) ? "Pressed" : "Released",
1770 ds_seat_pointer_notify_button(pointer->server->seat, event->time_msec, event->button, event->state);
1774 pointer_handle_frame(struct wl_listener *listener, void *data)
1776 struct tinyds_pointer *pointer;
1778 pointer = wl_container_of(listener, pointer, frame);
1780 ds_inf("Pointer(%p) frame", pointer);
1781 ds_seat_pointer_notify_frame(pointer->server->seat);
1785 server_add_pointer(struct tinyds_server *server, struct ds_input_device *dev)
1787 struct tinyds_pointer *pointer;
1789 pointer = calloc(1, sizeof *pointer);
1793 pointer->server = server;
1795 pointer->destroy.notify = pointer_handle_device_destroy;
1796 ds_input_device_add_destroy_listener(dev, &pointer->destroy);
1798 pointer->motion.notify = pointer_handle_motion;
1799 ds_pointer_add_motion_listener(ds_input_device_get_pointer(dev),
1802 pointer->button.notify = pointer_handle_button;
1803 ds_pointer_add_button_listener(ds_input_device_get_pointer(dev),
1806 pointer->frame.notify = pointer_handle_frame;
1807 ds_pointer_add_frame_listener(ds_input_device_get_pointer(dev),
1810 pointer->focused_view = NULL;
1813 if (server->output && wl_list_empty(&server->pointers)) {
1814 server->output_x = (double)(server->output->width) / 2;
1815 server->output_y = (double)(server->output->height) / 2;
1817 server->output->cursor_enabled = true;
1818 renderer_cursor_create(&server->output->renderer, 255, 0, 0, CURSOR_W, CURSOR_H);
1819 renderer_cursor_update(&server->output->renderer, server->output_x, server->output_y);
1821 server->output->cursor_hwc_window = ds_tdm_output_hwc_window_create(server->output->hwc);
1822 assert(server->output->cursor_hwc_window);
1823 draw_server_with_damage(server);
1827 wl_list_insert(&server->pointers, &pointer->link);
1829 ds_inf("Pointer(%p) added", pointer);
1833 output_schedule_commit_handle_idle_timer(void *data)
1835 struct tinyds_output *output = data;
1836 output->idle_commit = NULL;
1838 output_commit(output);
1842 output_schedule_commit(struct tinyds_output *output)
1844 if (output->idle_commit)
1847 struct wl_event_loop *ev = wl_display_get_event_loop(output->server->display);
1848 output->idle_commit =
1849 wl_event_loop_add_idle(ev, output_schedule_commit_handle_idle_timer, output);
1853 text_input_mgr_handle_destroy(struct wl_listener *listener, void *data)
1855 struct tinyds_text_input *text_input;
1856 struct tinyds_server *server;
1858 ds_inf("text_input_mgr_handle_destroy");
1859 text_input = wl_container_of(listener, text_input, mgr_destroy);
1861 wl_list_remove(&text_input->mgr_destroy.link);
1862 wl_list_remove(&text_input->new_text_input.link);
1864 server = text_input->server;
1865 server->text_input = NULL;
1869 text_input_handle_destroy(struct wl_listener *listener, void *data)
1871 struct tinyds_text_input *text_input;
1873 ds_inf("text_input_handle_destroy");
1875 text_input = wl_container_of(listener, text_input, destroy);
1877 wl_list_remove(&text_input->destroy.link);
1878 wl_list_remove(&text_input->text_input_activate.link);
1879 wl_list_remove(&text_input->text_input_deactivate.link);
1880 wl_list_remove(&text_input->text_input_reset.link);
1881 wl_list_remove(&text_input->text_input_set_content_type.link);
1882 wl_list_remove(&text_input->text_input_invoke_action.link);
1883 wl_list_remove(&text_input->text_input_commit_state.link);
1884 wl_list_remove(&text_input->text_input_set_preferred_language.link);
1890 text_input_handle_activate(struct wl_listener *listener, void *data)
1892 struct tinyds_text_input *text_input;
1893 struct tinyds_input_method *input_method;
1894 struct ds_tizen_text_input_event_activate *event = data;
1896 text_input = wl_container_of(listener, text_input, text_input_activate);
1898 input_method = text_input->server->input_method;
1900 ds_inf("text_input_handle_activate. text_input(%p) seat(%p) surface(%p) text_input(%p)",
1901 text_input, event->seat, event->surface, event->text_input);
1903 if (input_method->input == text_input)
1905 if (input_method->input)
1906 ;//deactivate_input_method(server->input_method);
1907 input_method->input = text_input;
1908 wl_list_insert(&text_input->input_methods, &input_method->link);
1910 text_input->surface = event->surface;
1912 if (!add_new_input_method_context(input_method, text_input))
1915 // ds_tizen_input_method_send_set_text_input_id();
1919 text_input_handle_deactivate(struct wl_listener *listener, void *data)
1921 struct tinyds_text_input *text_input;
1922 struct tinyds_input_method *input_method, *tmp;
1923 struct ds_tizen_text_input_event_deactivate *event = data;
1925 text_input = wl_container_of(listener, text_input, text_input_deactivate);
1926 ds_inf("text_input_handle_deactivate. text_input(%p) seat(%p) text_input(%p)",
1927 text_input, event->seat, event->text_input);
1929 wl_list_for_each_safe(input_method, tmp, &text_input->input_methods, link) {
1930 if (!input_method->input_method || !input_method->context->context) continue;
1931 ds_tizen_input_method_send_deactivate(input_method->input_method, input_method->context->context);
1932 input_method->input = NULL;
1933 input_method->context = NULL;
1934 wl_list_remove(&input_method->link);
1937 text_input->surface = NULL;
1938 // ds_tizen_input_method_send_close_connection();
1942 text_input_handle_reset(struct wl_listener *listener, void *data)
1944 struct tinyds_text_input *text_input;
1945 struct tinyds_input_method *input_method;
1947 text_input = wl_container_of(listener, text_input, text_input_reset);
1949 ds_inf("text_input_handle_reset. text_input(%p)", text_input);
1951 wl_list_for_each(input_method, &text_input->input_methods, link) {
1952 if (!input_method->context || !input_method->context->context) continue;
1953 ds_tizen_input_method_context_send_reset(input_method->context->context);
1958 text_input_handle_set_content_type(struct wl_listener *listener, void *data)
1960 struct tinyds_text_input *text_input;
1961 struct ds_tizen_text_input_event_set_content_type *event = data;
1962 struct tinyds_input_method *input_method;
1964 text_input = wl_container_of(listener, text_input, text_input_set_content_type);
1966 ds_inf("text_input_handle_content_type. text_input(%p) hint(%u) purpose(%u)",
1967 text_input, event->hint, event->purpose);
1969 wl_list_for_each(input_method, &text_input->input_methods, link) {
1970 if (!input_method->context || !input_method->context->context) continue;
1971 ds_tizen_input_method_context_send_content_type(input_method->context->context,
1972 event->hint, event->purpose);
1977 text_input_handle_invoke_action(struct wl_listener *listener, void *data)
1979 struct tinyds_text_input *text_input;
1980 struct ds_tizen_text_input_event_invoke_action *event = data;
1981 struct tinyds_input_method *input_method;
1983 text_input = wl_container_of(listener, text_input, text_input_invoke_action);
1985 ds_inf("text_input_handle_invoke_action. text_input(%p) button(%u) index(%u)",
1986 text_input, event->button, event->index);
1988 wl_list_for_each(input_method, &text_input->input_methods, link) {
1989 if (!input_method->context || !input_method->context->context) continue;
1990 ds_tizen_input_method_context_send_invoke_action(input_method->context->context,
1991 event->button, event->index);
1996 text_input_handle_commit_state(struct wl_listener *listener, void *data)
1998 struct tinyds_text_input *text_input;
1999 struct ds_tizen_text_input_event_commit_state *event = data;
2000 struct tinyds_input_method *input_method;
2002 text_input = wl_container_of(listener, text_input, text_input_commit_state);
2004 ds_inf("text_input_handle_commit_state. text_input(%p) serial(%u)",
2005 text_input, event->serial);
2007 wl_list_for_each(input_method, &text_input->input_methods, link) {
2008 if (!input_method->context || !input_method->context->context) continue;
2009 ds_tizen_input_method_context_send_commit_state(input_method->context->context,
2015 text_input_handle_set_preferred_language(struct wl_listener *listener, void *data)
2017 struct tinyds_text_input *text_input;
2018 struct ds_tizen_text_input_event_set_preferred_language *event = data;
2019 struct tinyds_input_method *input_method;
2021 text_input = wl_container_of(listener, text_input, text_input_set_preferred_language);
2023 ds_inf("text_input_handle_set_preferred_language. text_input(%p) language(%s)",
2024 text_input, event->language);
2026 wl_list_for_each(input_method, &text_input->input_methods, link) {
2027 if (!input_method->context || !input_method->context->context) continue;
2028 ds_tizen_input_method_context_send_preferred_language(input_method->context->context,
2034 text_input_mgr_handle_new_text_input(struct wl_listener *listener, void *data)
2036 struct tinyds_text_input *text_input;
2037 struct ds_tizen_text_input *input = data;
2039 text_input = wl_container_of(listener, text_input, new_text_input);
2041 ds_inf("text_input_mgr_handle_new_text_input");
2043 text_input->input = input;
2045 text_input->destroy.notify = text_input_handle_destroy;
2046 ds_tizen_text_input_add_destroy_listener(text_input->input,
2047 &text_input->destroy);
2049 text_input->text_input_activate.notify = text_input_handle_activate;
2050 ds_tizen_text_input_add_activate_listener(text_input->input,
2051 &text_input->text_input_activate);
2053 text_input->text_input_deactivate.notify = text_input_handle_deactivate;
2054 ds_tizen_text_input_add_deactivate_listener(text_input->input,
2055 &text_input->text_input_deactivate);
2057 text_input->text_input_reset.notify = text_input_handle_reset;
2058 ds_tizen_text_input_add_reset_listener(text_input->input,
2059 &text_input->text_input_reset);
2061 text_input->text_input_set_content_type.notify = text_input_handle_set_content_type;
2062 ds_tizen_text_input_add_set_content_type_listener(text_input->input,
2063 &text_input->text_input_set_content_type);
2065 text_input->text_input_invoke_action.notify = text_input_handle_invoke_action;
2066 ds_tizen_text_input_add_invoke_action_listener(text_input->input,
2067 &text_input->text_input_invoke_action);
2069 text_input->text_input_commit_state.notify = text_input_handle_commit_state;
2070 ds_tizen_text_input_add_commit_state_listener(text_input->input,
2071 &text_input->text_input_commit_state);
2073 text_input->text_input_set_preferred_language.notify = text_input_handle_set_preferred_language;
2074 ds_tizen_text_input_add_set_preferred_language_listener(text_input->input,
2075 &text_input->text_input_set_preferred_language);
2079 input_method_mgr_handle_destroy(struct wl_listener *listener, void *data)
2081 struct tinyds_input_method *input_method;
2083 ds_inf("input_method_mgr_handle_destroy");
2085 input_method = wl_container_of(listener, input_method, mgr_destroy);
2087 wl_list_remove(&input_method->mgr_destroy.link);
2091 input_method_handle_destroy(struct wl_listener *listener, void *data)
2093 struct tinyds_input_method *input_method;
2094 struct tinyds_server *server;
2096 ds_inf("input_method_handle_destroy");
2098 input_method = wl_container_of(listener, input_method, destroy);
2100 wl_list_remove(&input_method->destroy.link);
2102 server = input_method->server;
2103 server->input_method = NULL;
2109 context_handle_destroy(struct wl_listener *listener, void *data)
2111 struct tinyds_input_method_context *context;
2112 struct tinyds_server *server;
2114 ds_inf("context_handle_destroy");
2116 context = wl_container_of(listener, context, destroy);
2118 wl_list_remove(&context->destroy.link);
2120 wl_list_remove(&context->im_context_commit_string.link);
2121 wl_list_remove(&context->im_context_preedit_string.link);
2122 wl_list_remove(&context->im_context_preedit_styling.link);
2123 wl_list_remove(&context->im_context_preedit_cursor.link);
2124 wl_list_remove(&context->im_context_delete_surrounding_text.link);
2125 wl_list_remove(&context->im_context_cursor_position.link);
2126 wl_list_remove(&context->im_context_modifiers_map.link);
2127 wl_list_remove(&context->im_context_keysym.link);
2128 wl_list_remove(&context->im_context_grab_keyboard.link);
2129 wl_list_remove(&context->im_context_key.link);
2130 wl_list_remove(&context->im_context_modifiers.link);
2131 wl_list_remove(&context->im_context_language.link);
2132 wl_list_remove(&context->im_context_text_direction.link);
2134 server = context->server;
2135 server->input_method->context = NULL;
2141 context_handle_commit_string(struct wl_listener *listener, void *data)
2143 struct tinyds_text_input *text_input;
2144 struct tinyds_input_method_context *context;
2145 struct ds_tizen_input_method_context_event_commit_string *event = data;
2147 context = wl_container_of(listener, context, im_context_commit_string);
2148 text_input = context->server->text_input;
2150 ds_inf("context_handle_commit_string. text_input(%p) serial(%u) text(%s)",
2151 text_input, event->serial, event->text);
2153 ds_tizen_text_input_send_commit_string(text_input->input, event->serial, event->text);
2157 context_handle_preedit_string(struct wl_listener *listener, void *data)
2159 struct tinyds_input_method_context *context;
2160 struct tinyds_text_input *text_input;
2161 struct ds_tizen_input_method_context_event_preedit_string *event = data;
2163 context = wl_container_of(listener, context, im_context_preedit_string);
2164 text_input = context->server->text_input;
2166 ds_inf("context_handle_preedit_string. text_input(%p) serial(%u) text(%s) commit(%s)",
2167 text_input, event->serial, event->text, event->commit);
2169 ds_tizen_text_input_send_preedit_string(text_input->input, event->serial, event->text, event->commit);
2173 context_handle_preedit_styling(struct wl_listener *listener, void *data)
2175 struct tinyds_input_method_context *context;
2176 struct tinyds_text_input *text_input;
2177 struct ds_tizen_input_method_context_event_preedit_styling *event = data;
2179 context = wl_container_of(listener, context, im_context_preedit_styling);
2180 text_input = context->server->text_input;
2182 ds_inf("context_handle_preedit_styling. text_input(%p) index(%u) length(%u) style(%u)",
2183 text_input, event->index, event->length, event->style);
2185 ds_tizen_text_input_send_preedit_styling(text_input->input, event->index, event->length, event->style);
2189 context_handle_preedit_cursor(struct wl_listener *listener, void *data)
2191 struct tinyds_input_method_context *context;
2192 struct tinyds_text_input *text_input;
2193 struct ds_tizen_input_method_context_event_preedit_cursor *event = data;
2195 context = wl_container_of(listener, context, im_context_preedit_cursor);
2196 text_input = context->server->text_input;
2198 ds_inf("context_handle_preedit_cursor. text_input(%p) index(%u)",
2199 text_input, event->index);
2201 ds_tizen_text_input_send_preedit_cursor(text_input->input, event->index);
2205 context_handle_delete_surrounding_text(struct wl_listener *listener, void *data)
2207 struct tinyds_input_method_context *context;
2208 struct tinyds_text_input *text_input;
2209 struct ds_tizen_input_method_context_event_delete_surrounding_text *event = data;
2211 context = wl_container_of(listener, context, im_context_delete_surrounding_text);
2212 text_input = context->server->text_input;
2214 ds_inf("context_handle_delete_surrounding_text. text_input(%p) index(%d) length(%u)",
2215 text_input, event->index, event->length);
2217 ds_tizen_text_input_send_delete_surrounding_text(text_input->input, event->index, event->length);
2221 context_handle_cursor_position(struct wl_listener *listener, void *data)
2223 struct tinyds_input_method_context *context;
2224 struct tinyds_text_input *text_input;
2225 struct ds_tizen_input_method_context_event_cursor_position *event = data;
2227 context = wl_container_of(listener, context, im_context_cursor_position);
2228 text_input = context->server->text_input;
2230 ds_inf("context_handle_cursor_position. text_input(%p) index(%d) length(%d)",
2231 text_input, event->index, event->anchor);
2233 ds_tizen_text_input_send_cursor_position(text_input->input, event->index, event->anchor);
2237 context_handle_modifiers_map(struct wl_listener *listener, void *data)
2239 struct tinyds_input_method_context *context;
2240 struct tinyds_text_input *text_input;
2241 struct ds_tizen_input_method_context_event_modifiers_map *event = data;
2243 context = wl_container_of(listener, context, im_context_modifiers_map);
2244 text_input = context->server->text_input;
2246 ds_inf("context_handle_modifiers_map. text_input(%p) map(%p)",
2247 text_input, event->map);
2249 ds_tizen_text_input_send_modifiers_map(text_input->input, event->map);
2253 context_handle_keysym(struct wl_listener *listener, void *data)
2255 struct tinyds_input_method_context *context;
2256 struct tinyds_text_input *text_input;
2257 struct ds_tizen_input_method_context_event_keysym *event = data;
2259 context = wl_container_of(listener, context, im_context_keysym);
2260 text_input = context->server->text_input;
2262 ds_inf("context_handle_keysym. text_input(%p) serial(%u) time(%u) sysm(%u) state(%u) modifiers(%u)",
2263 text_input, event->serial, event->time, event->sym, event->state, event->modifiers);
2265 ds_tizen_text_input_send_keysym(text_input->input, event->serial, event->time, event->sym, event->state, event->modifiers);
2269 context_handle_grab_keyboard(struct wl_listener *listener, void *data)
2271 struct tinyds_input_method_context *context;
2272 struct tinyds_text_input *text_input;
2274 context = wl_container_of(listener, context, im_context_grab_keyboard);
2275 text_input = context->server->text_input;
2277 ds_inf("context_handle_grab_keyboard. text_input(%p)",
2284 context_handle_key(struct wl_listener *listener, void *data)
2286 struct tinyds_input_method_context *context;
2287 struct tinyds_text_input *text_input;
2289 context = wl_container_of(listener, context, im_context_key);
2290 text_input = context->server->text_input;
2292 ds_inf("context_handle_key. text_input(%p)",
2299 context_handle_modifiers(struct wl_listener *listener, void *data)
2301 struct tinyds_input_method_context *context;
2302 struct tinyds_text_input *text_input;
2304 context = wl_container_of(listener, context, im_context_modifiers);
2305 text_input = context->server->text_input;
2307 ds_inf("context_handle_modifiers. text_input(%p)",
2314 context_handle_language(struct wl_listener *listener, void *data)
2316 struct tinyds_input_method_context *context;
2317 struct tinyds_text_input *text_input;
2318 struct ds_tizen_input_method_context_event_language *event = data;
2320 context = wl_container_of(listener, context, im_context_language);
2321 text_input = context->server->text_input;
2323 ds_inf("context_handle_language. text_input(%p) serial(%u), language(%s)",
2324 text_input, event->serial, event->language);
2326 ds_tizen_text_input_send_language(text_input->input, event->serial, event->language);
2330 context_handle_text_direction(struct wl_listener *listener, void *data)
2332 struct tinyds_input_method_context *context;
2333 struct tinyds_text_input *text_input;
2334 struct ds_tizen_input_method_context_event_text_direction *event = data;
2336 context = wl_container_of(listener, context, im_context_text_direction);
2337 text_input = context->server->text_input;
2339 ds_inf("context_handle_text_direction. text_input(%p) serial(%u), direction(%u)",
2340 text_input, event->serial, event->direction);
2342 ds_tizen_text_input_send_text_direction(text_input->input, event->serial, event->direction);
2346 add_new_text_input(struct tinyds_server *server)
2348 struct tinyds_text_input *text_input;
2350 text_input = calloc(1, sizeof *text_input);
2354 text_input->text_input_mgr = ds_tizen_text_input_manager_create(server->display);
2355 if (!text_input->text_input_mgr) {
2357 ds_err("Could not create ds_tizen_text_input_manager");
2361 wl_list_init(&text_input->input_methods);
2363 text_input->mgr_destroy.notify = text_input_mgr_handle_destroy;
2364 ds_tizen_text_input_manager_add_destroy_listener(text_input->text_input_mgr,
2365 &text_input->mgr_destroy);
2367 text_input->new_text_input.notify = text_input_mgr_handle_new_text_input;
2368 ds_tizen_text_input_manager_add_new_text_input_listener(text_input->text_input_mgr,
2369 &text_input->new_text_input);
2371 text_input->server = server;
2372 server->text_input = text_input;
2374 ds_inf("Text_Input (%p) added", text_input);
2380 add_new_input_method(struct tinyds_server *server)
2382 struct tinyds_input_method *input_method;
2384 input_method = calloc(1, sizeof *input_method);
2388 input_method->input_method = ds_tizen_input_method_create(server->display);
2389 if (!input_method->input_method) {
2391 ds_err("Could not create ds_tizen_input_method");
2394 input_method->destroy.notify = input_method_handle_destroy;
2395 ds_tizen_input_method_add_destroy_listener(input_method->input_method,
2396 &input_method->destroy);
2398 input_method->input_method_mgr = ds_tizen_input_method_manager_create(server->display);
2399 if (!input_method->input_method_mgr) {
2401 ds_err("Could not create ds_tizen_input_method_manager");
2405 input_method->mgr_destroy.notify = input_method_mgr_handle_destroy;
2406 ds_tizen_input_method_manager_add_destroy_listener(input_method->input_method_mgr,
2407 &input_method->mgr_destroy);
2409 input_method->server = server;
2410 server->input_method = input_method;
2412 ds_inf("Input_Method (%p) added", input_method);
2418 add_new_input_method_context(struct tinyds_input_method *input_method,
2419 struct tinyds_text_input *text_input)
2421 struct tinyds_input_method_context *context;
2423 context = calloc(1, sizeof *context);
2424 if (context == NULL)
2426 ds_err("calloc is failed. tinyds_input_method_context");
2429 input_method->context = context;
2430 context->input_method = input_method;
2431 context->server = input_method->server;
2432 context->input = text_input;
2434 context->context = ds_tizen_input_method_create_context(input_method->input_method);
2435 if (context->context == NULL) {
2436 ds_err("ds_tizen_input_method_create_context() failed.");
2440 context->destroy.notify = context_handle_destroy;
2441 ds_tizen_input_method_context_add_destroy_listener(context->context,
2444 context->im_context_commit_string.notify = context_handle_commit_string;
2445 ds_tizen_input_method_context_add_commit_string_listener(context->context,
2446 &context->im_context_commit_string);
2448 context->im_context_preedit_string.notify = context_handle_preedit_string;
2449 ds_tizen_input_method_context_add_preedit_string_listener(context->context,
2450 &context->im_context_preedit_string);
2452 context->im_context_preedit_styling.notify = context_handle_preedit_styling;
2453 ds_tizen_input_method_context_add_preedit_styling_listener(context->context,
2454 &context->im_context_preedit_styling);
2456 context->im_context_preedit_cursor.notify = context_handle_preedit_cursor;
2457 ds_tizen_input_method_context_add_preedit_cursor_listener(context->context,
2458 &context->im_context_preedit_cursor);
2460 context->im_context_delete_surrounding_text.notify = context_handle_delete_surrounding_text;
2461 ds_tizen_input_method_context_add_delete_surrounding_text_listener(context->context,
2462 &context->im_context_delete_surrounding_text);
2464 context->im_context_cursor_position.notify = context_handle_cursor_position;
2465 ds_tizen_input_method_context_add_cursor_position_listener(context->context,
2466 &context->im_context_cursor_position);
2468 context->im_context_modifiers_map.notify = context_handle_modifiers_map;
2469 ds_tizen_input_method_context_add_modifiers_map_listener(context->context,
2470 &context->im_context_modifiers_map);
2472 context->im_context_keysym.notify = context_handle_keysym;
2473 ds_tizen_input_method_context_add_keysym_listener(context->context,
2474 &context->im_context_keysym);
2476 context->im_context_grab_keyboard.notify = context_handle_grab_keyboard;
2477 ds_tizen_input_method_context_add_grab_keyboard_listener(context->context,
2478 &context->im_context_grab_keyboard);
2480 context->im_context_key.notify = context_handle_key;
2481 ds_tizen_input_method_context_add_key_listener(context->context,
2482 &context->im_context_key);
2484 context->im_context_modifiers.notify = context_handle_modifiers;
2485 ds_tizen_input_method_context_add_modifiers_listener(context->context,
2486 &context->im_context_modifiers);
2488 context->im_context_language.notify = context_handle_language;
2489 ds_tizen_input_method_context_add_language_listener(context->context,
2490 &context->im_context_language);
2492 context->im_context_text_direction.notify = context_handle_text_direction;
2493 ds_tizen_input_method_context_add_text_direction_listener(context->context,
2494 &context->im_context_text_direction);