8 #include <drm_fourcc.h>
10 #include <wayland-server.h>
11 #include <libds/log.h>
12 #include <libds/backend.h>
13 #include <libds/output.h>
14 #include <libds/compositor.h>
15 #include <libds/xdg_shell.h>
16 #include <libds-tizen/allocator/tbm.h>
17 #include <libds-tizen/backend/tdm.h>
18 #include <libds/backend/libinput.h>
19 #include <libds-tizen/tbm_server.h>
20 #include <libds-tizen/dpms.h>
21 #include <libds/input_device.h>
22 #include <libds/keyboard.h>
23 #include <libds/touch.h>
24 #include <libds/pointer.h>
25 #include <libds/seat.h>
26 #include <libds-tizen/input_devicemgr.h>
27 #include <xkbcommon/xkbcommon.h>
28 #include <libds/interfaces/keyboard.h>
29 #include <libds-tizen/launch.h>
30 #include <libds-tizen/backend/tdm_output_hwc.h>
31 #include <libds-tizen/input_method.h>
32 #include <libds-tizen/text_input.h>
33 #include <libds-tizen/policy.h>
35 #define USE_TDM_BUFFER_QUEUE
37 #ifdef USE_TDM_BUFFER_QUEUE
38 #include "pixman-tbm-helper.h"
39 #include "tinyds-tdm-renderer.h"
41 #include <libds/swapchain.h>
44 #include "pixman-helper.h"
46 #define TINYDS_UNUSED __attribute__((unused))
47 struct tinyds_keyboard;
48 struct tinyds_pointer;
52 struct tinyds_server *server;
53 struct ds_output *ds_output;
54 struct ds_allocator *allocator;
55 #ifdef USE_TDM_BUFFER_QUEUE
56 struct tinyds_renderer renderer;
57 struct ds_tdm_buffer_queue *buffer_queue;
58 struct wl_listener buffer_queue_acquirable;
60 struct ds_swapchain *swapchain;
62 struct ds_buffer *front_buffer;
64 struct wl_listener output_destroy;
65 struct wl_listener output_frame;
69 struct wl_event_source *idle_commit;
74 struct ds_tdm_output_hwc *hwc;
75 struct ds_tdm_output_hwc_window *bg_hwc_window;
80 struct ds_tizen_dpms *ds_dpms;
81 struct tinyds_server *server;
83 struct wl_listener destroy;
84 struct wl_listener set_dpms;
85 struct wl_listener get_dpms;
90 struct ds_tizen_policy *policy;
92 struct wl_listener destroy;
93 struct wl_listener new_surface;
94 struct wl_listener activate_below_by_univeral_id;
95 struct wl_listener lower_by_universal_id;
96 struct wl_listener set_transient_for;
97 struct wl_listener unset_transient_for;
98 struct wl_listener place_subsurface_below_parent;
99 struct wl_listener set_subsurface_stand_alone;
100 struct wl_listener set_background_state;
101 struct wl_listener unset_background_state;
102 struct wl_listener add_activate_above_by_universal_id;
103 struct wl_listener set_appid;
104 struct wl_listener set_transient_for_below;
106 struct wl_list policy_surfaces;
109 struct tinyds_policy_surface
111 struct ds_tizen_policy_surface *policy_surface;
113 struct wl_listener destroy;
114 struct wl_listener new_visibility;
115 struct wl_listener new_position;
116 struct wl_listener activate;
117 struct wl_listener raise;
118 struct wl_listener lower;
119 struct wl_listener set_focus_skip;
120 struct wl_listener unset_focus_skip;
121 struct wl_listener set_role;
122 struct wl_listener set_window_type;
123 struct wl_listener set_conformant;
124 struct wl_listener unset_conformant;
125 struct wl_listener get_conformant;
126 struct wl_listener set_notification_level;
127 struct wl_listener set_window_screen_mode;
128 struct wl_listener get_subsurface;
129 struct wl_listener iconify;
130 struct wl_listener uniconify;
131 struct wl_listener add_aux_hint;
132 struct wl_listener change_aux_hint;
133 struct wl_listener delete_aux_hint;
134 struct wl_listener get_supported_aux_hints;
135 struct wl_listener set_floating_mode;
136 struct wl_listener unset_floating_mode;
137 struct wl_listener set_stack_mode;
138 struct wl_listener new_subsurface_watcher;
139 struct wl_listener set_parent;
140 struct wl_listener ack_conformant_region;
141 struct wl_listener set_video;
142 struct wl_listener show;
143 struct wl_listener hide;
144 struct wl_listener set_parent_with_below;
146 struct wl_list visibilities;
147 struct wl_list positions;
148 struct wl_list subsurface_watchers;
150 struct wl_list link; //tinyds_policy::policy_surfaces
153 struct tinyds_policy_visibility
155 struct ds_tizen_policy_visibility *visibility;
157 struct wl_listener destroy;
159 struct wl_list link; //tinyds_policy::visibilities
162 struct tinyds_policy_position
164 struct ds_tizen_policy_position *position;
166 struct wl_listener destroy;
167 struct wl_listener set;
169 struct wl_list link; //tinyds_policy::positions
172 struct tinyds_policy_subsurface_watcher
174 struct ds_tizen_policy_subsurface_watcher *subsurface_watcher;
176 struct wl_listener destroy;
178 struct wl_list link; //tinyds_policy::subsurface_watchers
183 struct ds_tbm_server *tbm_server;
185 struct wl_display *display;
187 struct ds_backend *backend;
188 struct ds_backend *input_backend;
189 struct ds_compositor *compositor;
190 struct ds_xdg_shell *xdg_shell;
191 struct ds_seat *seat;
193 double output_x, output_y;
194 struct ds_tizen_input_devicemgr *devicemgr;
195 struct ds_tizen_launch_effect *effect;
196 struct ds_tizen_launch_splash *splash;
198 struct tinyds_output *output;
199 struct tinyds_dpms *dpms;
200 struct tinyds_policy *policy;
202 struct wl_event_source *stdin_source;
204 struct wl_list views;
206 struct wl_listener new_output;
207 struct wl_listener new_input;
208 struct wl_listener new_xdg_surface;
209 struct wl_listener devicemgr_destroy;
210 struct wl_listener pointer_warp;
211 struct wl_listener effect_destroy;
212 struct wl_listener effect_type_set;
213 struct wl_listener effect_type_unset;
214 struct wl_listener new_splash;
215 struct wl_listener splash_owner;
217 struct wl_list keyboards;
218 struct wl_list pointers;
220 struct tinyds_text_input *text_input;
221 struct tinyds_input_method *input_method;
226 struct tinyds_server *server;
228 struct tinyds_texture *texture;
229 struct ds_xdg_surface *xdg_surface;
231 struct wl_listener xdg_surface_map;
232 struct wl_listener xdg_surface_unmap;
233 struct wl_listener xdg_surface_destroy;
234 struct wl_listener surface_commit;
235 struct wl_list link; // tinyds_server::views
237 struct ds_tdm_output_hwc_window *hwc_window;
246 struct tinyds_pointer
248 struct ds_input_device *dev;
249 struct tinyds_server *server;
251 struct tinyds_view *focused_view;
253 struct wl_listener destroy;
254 struct wl_listener motion; //relative
255 struct wl_listener button;
256 struct wl_listener frame;
257 struct wl_list link; //tinyds_server::pointers
260 struct tinyds_keyboard
262 struct ds_input_device *dev;
263 struct tinyds_server *server;
265 struct wl_listener destroy;
266 struct wl_listener key;
267 struct wl_list link; //tinyds_server::keyboards
272 struct ds_input_device *dev;
273 struct tinyds_server *server;
275 struct wl_listener destroy;
276 struct wl_listener down;
277 struct wl_listener up;
278 struct wl_listener motion;
281 struct tinyds_text_input {
282 struct ds_tizen_text_input *input;
283 struct ds_tizen_text_input_manager *text_input_mgr;
285 struct tinyds_server *server;
286 struct ds_surface *surface;
288 struct wl_list input_methods;
290 struct wl_listener destroy;
291 struct wl_listener mgr_destroy;
293 struct wl_listener new_text_input;
295 struct wl_listener text_input_activate;
296 struct wl_listener text_input_deactivate;
297 struct wl_listener text_input_reset;
298 struct wl_listener text_input_set_content_type;
299 struct wl_listener text_input_invoke_action;
300 struct wl_listener text_input_commit_state;
301 struct wl_listener text_input_set_preferred_language;
304 struct tinyds_input_method {
305 struct ds_tizen_input_method *input_method;
306 struct ds_tizen_input_method_manager *input_method_mgr;
308 struct tinyds_server *server;
309 struct tinyds_text_input *input;
310 struct tinyds_input_method_context *context;
314 struct wl_listener destroy;
315 struct wl_listener mgr_destroy;
318 struct tinyds_input_method_context {
319 struct ds_tizen_input_method_context *context;
321 struct tinyds_server *server;
322 struct tinyds_text_input *input;
323 struct tinyds_input_method *input_method;
325 struct wl_listener destroy;
327 struct wl_listener im_context_commit_string;
328 struct wl_listener im_context_preedit_string;
329 struct wl_listener im_context_preedit_styling;
330 struct wl_listener im_context_preedit_cursor;
331 struct wl_listener im_context_delete_surrounding_text;
332 struct wl_listener im_context_cursor_position;
333 struct wl_listener im_context_modifiers_map;
334 struct wl_listener im_context_keysym;
335 struct wl_listener im_context_grab_keyboard;
336 struct wl_listener im_context_key;
337 struct wl_listener im_context_modifiers;
338 struct wl_listener im_context_language;
339 struct wl_listener im_context_text_direction;
342 struct tinyds_server tinyds;
344 static bool init_server(struct tinyds_server *server, struct wl_display *display);
345 static int server_dispatch_stdin(int fd, uint32_t mask, void *data);
346 static void output_handle_destroy(struct wl_listener *listener, void *data);
347 static void output_handle_frame(struct wl_listener *listener, void *data);
348 static void draw_server_with_damage(struct tinyds_server *server);
349 static void draw_output(struct tinyds_output *output);
350 static void output_swap_buffer(struct tinyds_output *output,
351 struct ds_buffer *buffer);
352 static void view_send_frame_done(struct tinyds_view *view);
353 static void output_hwc_init(struct tinyds_output *output);
354 static void output_schedule_commit(struct tinyds_output *output);
355 static void output_commit(struct tinyds_output *output);
356 #ifdef USE_TDM_BUFFER_QUEUE
357 static void output_buffer_queue_init(struct tinyds_output *output);
358 static void output_renderer_init(struct tinyds_output *output);
359 static void output_draw_with_renderer(struct tinyds_output *output);
361 static void output_swapchain_init(struct tinyds_output *output,
362 int width, int height, uint32_t format);
363 static void output_draw_with_swapchain(struct tinyds_output *output);
364 static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image);
366 static void dpms_handle_destroy(struct wl_listener *listener, void *data);
367 static void dpms_handle_set_dpms(struct wl_listener *listener, void *data);
368 static void dpms_handle_get_dpms(struct wl_listener *listener, void *data);
369 static void server_add_keyboard(struct tinyds_server *server,
370 struct ds_input_device *dev);
371 static void server_add_pointer(struct tinyds_server *server,
372 struct ds_input_device *dev);
373 static void server_add_touch(struct tinyds_server *server,
374 struct ds_input_device *dev);
375 static bool new_policy(struct tinyds_server *server);
376 static struct tinyds_view *
377 server_view_at(struct tinyds_server *server, double lx, double ly,
378 double *sx, double *sy);
380 static bool add_new_text_input(struct tinyds_server *server);
381 static bool add_new_input_method(struct tinyds_server *server);
382 static bool add_new_input_method_context(
383 struct tinyds_input_method *input_method,
384 struct tinyds_text_input *text_input);
386 static void text_input_mgr_handle_destroy(struct wl_listener *listener,
387 void *data TINYDS_UNUSED);
388 static void text_input_mgr_handle_new_text_input(struct wl_listener *listener,
389 void *data TINYDS_UNUSED);
391 static void input_method_mgr_handle_destroy(struct wl_listener *listener,
392 void *data TINYDS_UNUSED);
394 static void input_method_handle_destroy(struct wl_listener *listener,
395 void *data TINYDS_UNUSED);
400 struct tinyds_server *server = &tinyds;
401 struct wl_display *display;
402 struct wl_event_loop *loop;
406 ds_log_init(DS_INF, NULL);
408 display = wl_display_create();
411 res = init_server(server, display);
414 socket = wl_display_add_socket_auto(display);
417 ds_backend_start(server->backend);
418 ds_backend_start(server->input_backend);
420 setenv("WAYLAND_DISPLAY", socket, true);
422 ds_inf("Running Wayland compositor on WAYLAND_DISPLAY=%s", socket);
424 loop = wl_display_get_event_loop(display);
425 server->stdin_source = wl_event_loop_add_fd(loop, STDIN_FILENO,
426 WL_EVENT_READABLE, server_dispatch_stdin, server);
428 wl_display_run(display);
430 wl_display_destroy_clients(display);
431 wl_display_destroy(display);
437 view_populate_pid(struct tinyds_view *view)
440 struct wl_client *client = NULL;
441 struct ds_surface *surface;
443 surface = ds_xdg_surface_get_surface(view->xdg_surface);
447 client = wl_resource_get_client(ds_surface_get_wl_resource(surface));
451 wl_client_get_credentials(client, &pid, NULL, NULL);
453 ds_inf("view pid(%u)", pid);
456 view->effect_type = ds_tizen_launch_effect_get_effect_type(view->server->effect, pid);
457 ds_tizen_launch_effect_unset_effect_type(view->server->effect, pid);
458 ds_inf("view effect_type(%d)", view->effect_type);
462 view_handle_xdg_surface_map(struct wl_listener *listener,
463 void *data TINYDS_UNUSED)
465 struct tinyds_view *view;
466 struct ds_keyboard *keyboard;
467 struct tinyds_keyboard *kbd;
469 view = wl_container_of(listener, view, xdg_surface_map);
472 view_populate_pid(view);
474 wl_list_for_each(kbd, &view->server->keyboards, link) {
475 keyboard = ds_input_device_get_keyboard(kbd->dev);
476 if (keyboard != NULL) {
477 ds_seat_keyboard_notify_enter(view->server->seat,
478 ds_xdg_surface_get_surface(view->xdg_surface),
479 keyboard->keycodes, keyboard->num_keycodes,
480 &keyboard->modifiers);
487 view_handle_xdg_surface_unmap(struct wl_listener *listener,
488 void *data TINYDS_UNUSED)
490 struct tinyds_view *view;
492 view = wl_container_of(listener, view, xdg_surface_unmap);
493 view->mapped = false;
497 view_handle_xdg_surface_destroy(struct wl_listener *listener,
498 void *data TINYDS_UNUSED)
500 struct tinyds_view *view;
502 view = wl_container_of(listener, view, xdg_surface_destroy);
504 draw_server_with_damage(view->server);
506 ds_tdm_output_hwc_window_destroy(view->hwc_window);
508 wl_list_remove(&view->xdg_surface_destroy.link);
509 wl_list_remove(&view->xdg_surface_map.link);
510 wl_list_remove(&view->xdg_surface_unmap.link);
511 wl_list_remove(&view->surface_commit.link);
512 wl_list_remove(&view->link);
517 view_handle_surface_commit(struct wl_listener *listener,
518 void *data TINYDS_UNUSED)
520 struct tinyds_view *view;
522 view = wl_container_of(listener, view, surface_commit);
523 draw_server_with_damage(view->server);
527 server_new_xdg_surface(struct wl_listener *listener, void *data)
529 static unsigned int seedx = 1;
530 static unsigned int seedy = 43210;
531 struct tinyds_server *server;
532 struct tinyds_view *view;
533 struct ds_xdg_surface *xdg_surface;
535 server = wl_container_of(listener, server, new_xdg_surface);
538 ds_inf("New xdg_surface(%p)", (void *)xdg_surface);
540 view = calloc(1, sizeof *view);
543 view->server = server;
544 view->xdg_surface = xdg_surface;
546 view->xdg_surface_map.notify = view_handle_xdg_surface_map;
547 ds_xdg_surface_add_map_listener(xdg_surface,
548 &view->xdg_surface_map);
550 view->xdg_surface_unmap.notify = view_handle_xdg_surface_unmap;
551 ds_xdg_surface_add_unmap_listener(xdg_surface,
552 &view->xdg_surface_unmap);
554 view->xdg_surface_destroy.notify = view_handle_xdg_surface_destroy;
555 ds_xdg_surface_add_destroy_listener(xdg_surface,
556 &view->xdg_surface_destroy);
558 view->surface_commit.notify = view_handle_surface_commit;
559 ds_surface_add_commit_listener(
560 ds_xdg_surface_get_surface(xdg_surface),
561 &view->surface_commit);
563 view->x = rand_r(&seedx) % 1000;
564 view->y = rand_r(&seedy) % 500;
566 view->hwc_window = ds_tdm_output_hwc_window_create(server->output->hwc);
567 assert(view->hwc_window);
569 wl_list_insert(server->views.prev, &view->link);
572 view->effect_type = -1;
574 ds_inf("view at (%d, %d)", view->x, view->y);
578 backend_handle_new_output(struct wl_listener *listener, void *data)
580 struct tinyds_server *server;
581 struct tinyds_output *output;
582 struct ds_output *ds_output;
583 const struct ds_output_mode *mode;
584 struct ds_tdm_box src_box;
586 server = wl_container_of(listener, server, new_output);
589 ds_inf("New output(%p)", ds_output);
594 mode = ds_output_get_preferred_mode(ds_output);
595 ds_output_set_mode(ds_output, mode);
597 output = calloc(1, sizeof *output);
601 output->server = server;
602 output->ds_output = ds_output;
603 output->width = mode->width;
604 output->height = mode->height;
605 output->damaged = true;
606 output->committable = true;
608 output_hwc_init(output);
610 #ifdef USE_TDM_BUFFER_QUEUE
611 output_buffer_queue_init(output);
612 output_renderer_init(output);
614 output_swapchain_init(output, mode->width, mode->height,
615 DRM_FORMAT_XRGB8888);
618 output->bg_hwc_window = ds_tdm_output_hwc_window_create(output->hwc);
619 assert(output->bg_hwc_window);
623 src_box.width = output->width;
624 src_box.height = output->height;
626 ds_tdm_output_hwc_window_set_src_box(output->bg_hwc_window, &src_box);
627 ds_tdm_output_hwc_window_set_position(output->bg_hwc_window, 0, 0);
628 ds_tdm_output_hwc_window_set_dest_size(output->bg_hwc_window, output->width, output->height);
629 ds_tdm_output_hwc_window_set_transform(output->bg_hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
631 output->output_destroy.notify = output_handle_destroy;
632 ds_output_add_destroy_listener(ds_output, &output->output_destroy);
634 output->output_frame.notify = output_handle_frame;
635 ds_output_add_frame_listener(ds_output, &output->output_frame);
637 ds_tizen_input_devicemgr_set_output_width_height(server->devicemgr, (uint32_t)output->width, (uint32_t)output->height);
639 server->output = output;
641 output_schedule_commit(output);
645 add_new_dpms(struct tinyds_server *server)
647 struct tinyds_dpms *dpms;
649 dpms = calloc(1, sizeof *dpms);
653 dpms->ds_dpms = ds_tizen_dpms_create(server->display);
654 if (!dpms->ds_dpms) {
656 ds_err("Could not create ds_tizen_dpms");
660 dpms->destroy.notify = dpms_handle_destroy;
661 ds_tizen_dpms_add_destroy_listener(dpms->ds_dpms, &dpms->destroy);
663 dpms->set_dpms.notify = dpms_handle_set_dpms;
664 ds_tizen_dpms_add_set_dpms_listener(dpms->ds_dpms, &dpms->set_dpms);
666 dpms->get_dpms.notify = dpms_handle_get_dpms;
667 ds_tizen_dpms_add_get_dpms_listener(dpms->ds_dpms, &dpms->get_dpms);
671 ds_inf("Dpms (%p) added", dpms);
677 backend_handle_new_input(struct wl_listener *listener, void *data)
679 struct tinyds_server *server;
680 struct ds_input_device *dev = data;
681 enum ds_input_device_type dev_type;
683 server = wl_container_of(listener, server, new_input);
685 dev_type = ds_input_device_get_type(dev);
688 case DS_INPUT_DEVICE_KEYBOARD:
689 server_add_keyboard(server, dev);
690 server->seat_caps |= WL_SEAT_CAPABILITY_KEYBOARD;
692 case DS_INPUT_DEVICE_TOUCH:
693 server_add_touch(server, dev);
694 server->seat_caps |= WL_SEAT_CAPABILITY_TOUCH;
696 case DS_INPUT_DEVICE_POINTER:
697 server_add_pointer(server, dev);
698 server->seat_caps |= WL_SEAT_CAPABILITY_POINTER;
701 ds_err("Unknown type(%d) of ds_input_device", dev_type);
705 ds_seat_set_capabilities(server->seat, server->seat_caps);
709 devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode)
711 struct ds_tizen_input_devicemgr_keymap_data *data;
713 data = calloc(1, sizeof *data);
715 ds_err("Failed to alloc memory");
719 data->name = strdup(name);
720 data->keycode = keycode;
722 wl_list_insert(list, &data->link);
726 devicemgr_cleanup_keymap_list(struct wl_list *list)
728 struct ds_tizen_input_devicemgr_keymap_data *data, *tmp;
730 wl_list_for_each_safe(data, tmp, list, link) {
731 wl_list_remove(&data->link);
738 devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr)
740 struct wl_list keymap_list;
743 wl_list_init(&keymap_list);
745 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeRaise", 455);
746 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeLower", 456);
747 devicemgr_add_keymap_data(&keymap_list, "XF86LightOn", 457);
748 devicemgr_add_keymap_data(&keymap_list, "XF86LightOff", 458);
750 res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list);
752 ds_inf("Failed to set keymap");
754 devicemgr_cleanup_keymap_list(&keymap_list);
758 devicemgr_handle_pointer_warp(struct wl_listener *listener, void *data)
760 struct tinyds_server *server;
761 struct tinyds_pointer *pointer;
762 struct ds_tizen_input_devicemgr_event_pointer_warp *event = data;
763 double sx = 0.f, sy = 0.f;
764 struct tinyds_view *view = NULL;
766 server = wl_container_of(listener, server, pointer_warp);
768 ds_inf("Pointer warp: surface(%p) x(%.2f) y(%.2f)", event->surface,
771 wl_list_for_each(pointer, &server->pointers, link){
772 if (!pointer->focused_view) continue;
773 view = pointer->focused_view;
777 if (event->surface != ds_xdg_surface_get_surface(view->xdg_surface)) {
778 ds_inf("Pointer is not on the requested surface");
782 server->output_x = view->x + (event->x * server->output->width);
783 server->output_y = view->y + (event->y * server->output->height);
785 server_view_at(server, server->output_x, server->output_y, &sx, &sy);
787 ds_inf("notify motion: sx:%.2f sy:%.2f, output_x:%.1f, output_y:%.1f",
788 sx, sy, server->output_x, server->output_y);
790 ds_seat_pointer_notify_motion(server->seat,
791 event->time_msec, sx, sy);
795 devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
797 struct tinyds_server *server =
798 wl_container_of(listener, server, devicemgr_destroy);
800 wl_list_remove(&server->devicemgr_destroy.link);
801 wl_list_remove(&server->pointer_warp.link);
803 server->devicemgr = NULL;
807 launch_effect_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
809 struct tinyds_server *server =
810 wl_container_of(listener, server, effect_destroy);
812 wl_list_remove(&server->effect_destroy.link);
813 wl_list_remove(&server->effect_type_set.link);
814 wl_list_remove(&server->effect_type_unset.link);
815 wl_list_remove(&server->new_splash.link);
817 server->effect = NULL;
821 launch_effect_handle_type_set(struct wl_listener *listener, void *data)
823 struct tinyds_server *server;
824 struct ds_tizen_launch_effect_event_type_set *event = data;
825 struct tinyds_view *view = NULL;
826 bool existing = false;
828 server = wl_container_of(listener, server, effect_type_set);
830 ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch");
832 wl_list_for_each(view, &server->views, link) {
833 if (view->pid == event->pid) {
834 view->effect_type = event->effect_type;
835 ds_inf("Launch effect. existing pid");
840 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
842 ds_tizen_launch_effect_set_effect_type(server->effect, event->pid, event->effect_type);
847 launch_effect_handle_type_unset(struct wl_listener *listener, void *data)
849 struct tinyds_server *server;
850 struct ds_tizen_launch_effect_event_type_unset *event = data;
851 struct tinyds_view *view = NULL;
853 server = wl_container_of(listener, server, effect_type_unset);
855 ds_inf("Launch effect. type_unset: pid(%u)", event->pid);
857 wl_list_for_each(view, &server->views, link) {
858 if (view->pid == event->pid) {
859 view->effect_type = -1;
860 ds_inf("Launch effect. pid found");
863 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
867 launch_splash_handle_owner(struct wl_listener *listener, void *data)
869 struct tinyds_server *server;
870 struct ds_tizen_launch_splash_event_owner *event = data;
871 struct tinyds_view *view = NULL;
873 server = wl_container_of(listener, server, splash_owner);
875 ds_inf("Splash owner. pid(%u)", event->pid);
877 wl_list_for_each(view, &server->views, link) {
878 if (view->pid == event->pid) {
879 if (event->pid == ds_tizen_launch_splash_get_pid(server->splash))
882 ds_tizen_launch_splash_set_pid(server->splash, event->pid);
889 launch_effect_handle_new_splash(struct wl_listener *listener, void *data)
891 struct tinyds_server *server;
892 struct ds_tizen_launch_splash *splash = data;
893 struct tinyds_view *view = NULL;
895 server = wl_container_of(listener, server, new_splash);
897 ds_inf("Launch new splash. splash(%p)", splash);
900 server->splash = splash;
902 // new view for "Launchscreen"
903 view = calloc(1, sizeof *view);
905 wl_list_insert(server->views.prev, &view->link);
906 view->pid = ds_tizen_launch_splash_get_pid(splash);
908 server->splash_owner.notify = launch_splash_handle_owner;
909 ds_tizen_launch_splash_add_owner_listener(server->splash,
910 &server->splash_owner);
914 init_server(struct tinyds_server *server, struct wl_display *display)
916 server->display = display;
918 wl_list_init(&server->views);
920 if (wl_display_init_shm(display) != 0)
923 server->backend = ds_tdm_backend_create(display);
924 if (!server->backend)
927 server->input_backend = ds_libinput_backend_create(display);
928 if (!server->input_backend) {
929 ds_backend_destroy(server->backend);
933 server->new_output.notify = backend_handle_new_output;
934 ds_backend_add_new_output_listener(server->backend,
935 &server->new_output);
937 wl_list_init(&server->keyboards);
938 wl_list_init(&server->pointers);
939 server->new_input.notify = backend_handle_new_input;
940 ds_backend_add_new_input_listener(server->input_backend, &server->new_input);
942 server->compositor = ds_compositor_create(display);
943 if (!server->compositor)
946 server->tbm_server = ds_tbm_server_create(display);
947 if (!server->tbm_server)
950 server->xdg_shell = ds_xdg_shell_create(display);
951 if (!server->xdg_shell)
954 server->new_xdg_surface.notify = server_new_xdg_surface;
955 ds_xdg_shell_add_new_surface_listener(server->xdg_shell,
956 &server->new_xdg_surface);
958 if (!add_new_dpms(server))
961 if (!new_policy(server))
964 server->seat = ds_seat_create(display, "seat0" /* arbitrary name */);
967 server->seat_caps = 0;
969 server->devicemgr = ds_tizen_input_devicemgr_create(
970 server->input_backend, server->seat);
971 if (!server->devicemgr) {
972 ds_err("Could not create ds_tizen_input_devicemgr");
976 devicemgr_set_keymap(server->devicemgr);
978 server->devicemgr_destroy.notify = devicemgr_handle_destroy;
979 ds_tizen_input_devicemgr_add_destroy_listener(server->devicemgr,
980 &server->devicemgr_destroy);
982 server->pointer_warp.notify = devicemgr_handle_pointer_warp;
983 ds_tizen_input_devicemgr_add_pointer_warp_listener(server->devicemgr,
984 &server->pointer_warp);
986 server->effect = ds_tizen_launch_effect_create(display);
987 if (!server->effect) {
991 server->effect_destroy.notify = launch_effect_handle_destroy;
992 ds_tizen_launch_effect_add_destroy_listener(server->effect,
993 &server->effect_destroy);
995 server->effect_type_set.notify = launch_effect_handle_type_set;
996 ds_tizen_launch_effect_add_type_set_listener(server->effect,
997 &server->effect_type_set);
999 server->effect_type_unset.notify = launch_effect_handle_type_unset;
1000 ds_tizen_launch_effect_add_type_unset_listener(server->effect,
1001 &server->effect_type_unset);
1003 server->new_splash.notify = launch_effect_handle_new_splash;
1004 ds_tizen_launch_effect_add_new_splash_listener(server->effect,
1005 &server->new_splash);
1007 if (!add_new_text_input(server))
1010 if (!add_new_input_method(server))
1016 ds_backend_destroy(server->backend);
1017 ds_backend_destroy(server->input_backend);
1023 output_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
1025 struct tinyds_output *output =
1026 wl_container_of(listener, output, output_destroy);
1028 if (output->bg_hwc_window)
1029 ds_tdm_output_hwc_window_destroy(output->bg_hwc_window);
1031 wl_list_remove(&output->output_destroy.link);
1032 wl_list_remove(&output->output_frame.link);
1034 if (output->front_buffer)
1035 ds_buffer_unlock(output->front_buffer);
1037 #ifdef USE_TDM_BUFFER_QUEUE
1038 fini_renderer(&output->renderer);
1040 if (output->swapchain)
1041 ds_swapchain_destroy(output->swapchain);
1043 if (output->allocator)
1044 ds_allocator_destroy(output->allocator);
1047 wl_display_terminate(output->server->display);
1049 output->server->output = NULL;
1055 output_commit(struct tinyds_output *output)
1057 uint32_t num_changed = 0;
1058 uint32_t num_windows = 0, current_num_windows = 0;
1059 struct ds_tdm_output_hwc_window **composited_hwc_windows = NULL;
1060 struct ds_tdm_output_hwc_window **changed_hwc_windows = NULL;
1061 enum ds_tdm_output_hwc_window_composition composition;
1062 struct tinyds_view *view;
1064 bool need_target = false;
1065 bool fully_obscured = false;
1066 struct ds_buffer *ds_buffer;
1067 struct ds_tdm_box src_box;
1070 if (!output->committable)
1073 if (!output->damaged && !output->target_updated)
1076 wl_list_for_each_reverse(view, &output->server->views, link) {
1077 if (!view->hwc_window)
1080 ds_buffer = ds_surface_get_buffer(
1081 ds_xdg_surface_get_surface(view->xdg_surface));
1090 ds_buffer_get_size(ds_buffer, &w, &h);
1092 if ((output->width <= w) && (output->height <= h))
1093 fully_obscured = true;
1096 if (fully_obscured) {
1097 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
1098 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
1100 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
1101 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT);
1107 composited_hwc_windows = calloc(num_windows, sizeof *composited_hwc_windows);
1108 if (!composited_hwc_windows)
1111 wl_list_for_each_reverse(view, &output->server->views, link) {
1112 if (!view->hwc_window)
1115 ds_buffer = ds_surface_get_buffer(
1116 ds_xdg_surface_get_surface(view->xdg_surface));
1120 ds_tdm_output_hwc_window_set_buffer(view->hwc_window, ds_buffer);
1122 ds_buffer_get_size(ds_buffer, &w, &h);
1129 ds_tdm_output_hwc_window_set_src_box(view->hwc_window, &src_box);
1130 ds_tdm_output_hwc_window_set_position(view->hwc_window, view->x, view->y);
1131 ds_tdm_output_hwc_window_set_dest_size(view->hwc_window, w, h);
1132 ds_tdm_output_hwc_window_set_transform(view->hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
1135 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1136 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE);
1138 composited_hwc_windows[current_num_windows] = view->hwc_window;
1139 current_num_windows++;
1141 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1142 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
1146 if (!fully_obscured) {
1147 composited_hwc_windows[current_num_windows] = output->bg_hwc_window;
1148 current_num_windows++;
1152 if (!ds_tdm_output_hwc_validate(output->hwc, composited_hwc_windows,
1153 num_windows, &num_changed)) {
1154 free(composited_hwc_windows);
1155 ds_err("Could not hwc validate");
1159 if (composited_hwc_windows)
1160 free(composited_hwc_windows);
1162 if (num_changed > 0) {
1163 changed_hwc_windows = calloc(num_windows, sizeof *changed_hwc_windows);
1164 if (!changed_hwc_windows)
1167 if (!ds_tdm_output_hwc_get_changed_composition(output->hwc, &num_changed,
1168 changed_hwc_windows)) {
1169 free(changed_hwc_windows);
1170 ds_err("Could not get chaged composition");
1174 for (i = 0; i < num_changed; i++) {
1175 composition = ds_tdm_output_hwc_window_get_composition(changed_hwc_windows[i]);
1176 if (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT) {
1183 if (changed_hwc_windows)
1184 free(changed_hwc_windows);
1186 if (need_target && output->damaged)
1187 draw_output(output);
1189 #ifdef USE_TDM_BUFFER_QUEUE
1190 struct ds_buffer *buffer;
1192 buffer = ds_tdm_buffer_queue_acquire(output->buffer_queue);
1194 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, buffer)) {
1195 ds_err("Could not set hwc client target buffer");
1199 output_swap_buffer(output, buffer);
1203 if (!ds_tdm_output_hwc_accept_validation(output->hwc)) {
1204 ds_err("Could not hwc accept validateion");
1208 ds_output_commit(output->ds_output);
1210 output->committable = false;
1211 output->damaged = false;
1212 output->target_updated = false;
1214 wl_list_for_each(view, &output->server->views, link) {
1215 enum ds_tdm_output_hwc_window_composition composition;
1220 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1221 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1222 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1223 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1224 view_send_frame_done(view);
1227 ds_dbg("output:%p commit", output);
1231 output_handle_frame(struct wl_listener *listener, void *data TINYDS_UNUSED)
1233 struct tinyds_output *output =
1234 wl_container_of(listener, output, output_frame);
1236 ds_dbg("output:%p handle frame", output);
1238 output->committable = true;
1240 output_commit(output);
1244 draw_server_with_damage(struct tinyds_server *server)
1246 server->output->damaged = true;
1247 output_schedule_commit(server->output);
1251 output_hwc_init(struct tinyds_output *output)
1253 struct ds_tdm_output *tdm_output;
1255 tdm_output = ds_tdm_output_from_output(output->ds_output);
1258 output->hwc = ds_tdm_output_get_hwc(tdm_output);
1259 assert(output->hwc);
1261 ds_tdm_output_hwc_set_enabled(output->hwc, true);
1264 #ifdef USE_TDM_BUFFER_QUEUE
1266 output_handle_buffer_queue_acquirable(struct wl_listener *listener,
1267 void *data TINYDS_UNUSED)
1269 struct tinyds_output *output;
1271 output = wl_container_of(listener, output, buffer_queue_acquirable);
1273 output->target_updated = true;
1274 output_schedule_commit(output);
1278 output_buffer_queue_init(struct tinyds_output *output)
1280 struct ds_tdm_output *tdm_output;
1282 tdm_output = ds_tdm_output_from_output(output->ds_output);
1285 output->buffer_queue = ds_tdm_output_get_buffer_queue(tdm_output);
1286 assert(output->buffer_queue);
1288 output->buffer_queue_acquirable.notify =
1289 output_handle_buffer_queue_acquirable;
1290 ds_tdm_buffer_queue_add_acquirable_listener(output->buffer_queue,
1291 &output->buffer_queue_acquirable);
1295 output_renderer_init(struct tinyds_output *output)
1297 init_renderer(&output->renderer);
1299 renderer_set_surface_queue(&output->renderer,
1300 ds_tdm_buffer_queue_get_native_queue(output->buffer_queue));
1302 renderer_set_bg_color(&output->renderer, 80, 80, 80);
1306 output_draw_with_renderer(struct tinyds_output *output)
1308 struct tinyds_view *view;
1310 ds_dbg(">> BEGIN UPDATE TEXTURES");
1312 wl_list_for_each(view, &output->server->views, link) {
1313 struct ds_buffer *ds_buffer;
1314 struct ds_tbm_client_buffer *tbm_buffer;
1315 tbm_surface_h surface;
1316 enum ds_tdm_output_hwc_window_composition composition;
1321 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1322 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1323 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1324 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1327 ds_buffer = ds_surface_get_buffer(
1328 ds_xdg_surface_get_surface(view->xdg_surface));
1332 tbm_buffer = ds_tbm_client_buffer_from_buffer(ds_buffer);
1336 surface = ds_tbm_client_buffer_get_tbm_surface(tbm_buffer);
1340 renderer_add_texture(&output->renderer, surface, view->x, view->y);
1342 view_send_frame_done(view);
1345 ds_dbg("<< END UPDATE TEXTURES");
1347 renderer_draw(&output->renderer);
1351 output_swapchain_init(struct tinyds_output *output,
1352 int width, int height, uint32_t format)
1355 output->allocator = ds_tbm_allocator_create();
1356 assert(output->allocator);
1358 output->swapchain = ds_swapchain_create(output->allocator,
1359 width, height, format);
1360 assert(output->swapchain);
1364 output_draw_with_swapchain(struct tinyds_output *output)
1366 struct tinyds_view *view;
1367 struct ds_buffer *output_buffer;
1368 pixman_image_t *output_image;
1369 enum ds_tdm_output_hwc_window_composition composition;
1371 output_buffer = ds_swapchain_acquire(output->swapchain, NULL);
1375 output_image = pixman_image_from_buffer(output_buffer,
1376 DS_BUFFER_DATA_PTR_ACCESS_WRITE);
1377 if (!output_image) {
1378 ds_buffer_unlock(output_buffer);
1382 pixman_image_fill_color(output_image, 80, 80, 80);
1384 wl_list_for_each(view, &output->server->views, link) {
1388 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1389 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1390 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1391 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1394 draw_view(view, output_image);
1396 pixman_image_unref(output_image);
1398 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, output_buffer)) {
1399 ds_err("Could not set hwc client target buffer");
1400 ds_buffer_unlock(output_buffer);
1404 output_swap_buffer(output, output_buffer);
1408 draw_view(struct tinyds_view *view, pixman_image_t *dst_image)
1410 struct ds_buffer *buffer;
1411 pixman_image_t *src_image;
1413 buffer = ds_surface_get_buffer(
1414 ds_xdg_surface_get_surface(view->xdg_surface));
1418 src_image = pixman_image_from_buffer(buffer,
1419 DS_BUFFER_DATA_PTR_ACCESS_READ);
1420 pixman_image_composite32(PIXMAN_OP_OVER,
1426 pixman_image_get_width(src_image),
1427 pixman_image_get_height(src_image));
1428 pixman_image_unref(src_image);
1430 view_send_frame_done(view);
1435 draw_output(struct tinyds_output *output)
1437 #ifdef USE_TDM_BUFFER_QUEUE
1438 output_draw_with_renderer(output);
1440 output_draw_with_swapchain(output);
1443 ds_dbg("output:%p draw", output);
1447 output_swap_buffer(struct tinyds_output *output, struct ds_buffer *buffer)
1449 ds_output_attach_buffer(output->ds_output, buffer);
1451 if (output->front_buffer)
1452 ds_buffer_unlock(output->front_buffer);
1453 output->front_buffer = buffer;
1457 view_send_frame_done(struct tinyds_view *view)
1459 struct timespec now;
1460 clock_gettime(CLOCK_MONOTONIC, &now);
1461 ds_surface_send_frame_done(ds_xdg_surface_get_surface(view->xdg_surface),
1466 server_dispatch_stdin(int fd, uint32_t mask, void *data)
1468 struct tinyds_server *server = data;
1470 wl_display_terminate(server->display);
1476 dpms_handle_destroy(struct wl_listener *listener, void *data)
1478 struct tinyds_dpms *dpms;
1480 dpms = wl_container_of(listener, dpms, destroy);
1482 ds_inf("Dpms(%p) destroyed", dpms);
1484 wl_list_remove(&dpms->destroy.link);
1485 wl_list_remove(&dpms->set_dpms.link);
1486 wl_list_remove(&dpms->get_dpms.link);
1492 dpms_handle_set_dpms(struct wl_listener *listener, void *data)
1494 struct tinyds_dpms *dpms;
1495 struct ds_tizen_dpms_event *event = data;
1497 dpms = wl_container_of(listener, dpms, set_dpms);
1499 ds_inf("Dpms(%p) set dpms : %d", dpms, event->mode);
1502 //set dpms mode to output
1503 ds_tizen_dpms_send_set_result(dpms->ds_dpms, event->mode,
1504 DS_TIZEN_DPMS_ERROR_NONE);
1508 dpms_handle_get_dpms(struct wl_listener *listener, void *data)
1510 struct tinyds_dpms *dpms;
1512 dpms = wl_container_of(listener, dpms, get_dpms);
1514 ds_inf("Dpms(%p) get dpms", dpms);
1517 //get dpms mode from output
1518 ds_tizen_dpms_send_get_result(dpms->ds_dpms, DS_TIZEN_DPMS_MODE_ON,
1519 DS_TIZEN_DPMS_ERROR_NONE);
1523 keyboard_handle_device_destroy(struct wl_listener *listener, void *data)
1525 struct tinyds_keyboard *kbd;
1527 kbd = wl_container_of(listener, kbd, destroy);
1529 ds_inf("Keyboard(%p) destroyed", kbd);
1531 wl_list_remove(&kbd->destroy.link);
1532 wl_list_remove(&kbd->key.link);
1533 wl_list_remove(&kbd->link);
1539 server_handle_keybinding(struct tinyds_server *server, xkb_keysym_t sym)
1542 case XKB_KEY_BackSpace:
1543 wl_display_terminate(server->display);
1553 keyboard_handle_key(struct wl_listener *listener, void *data)
1555 struct tinyds_keyboard *kbd;
1556 struct ds_event_keyboard_key *event = data;
1557 struct ds_keyboard *ds_keyboard;
1558 struct xkb_state *xkb_state;
1559 const xkb_keysym_t *syms;
1561 bool handled = false;
1563 kbd = wl_container_of(listener, kbd, key);
1565 ds_inf("Keyboard(%p) event key: keycode(%d), state(%d), time_msec(%d), "
1566 "update_state(%d)", kbd->dev,
1567 event->keycode, event->state, event->time_msec,
1568 event->update_state);
1570 ds_keyboard = ds_input_device_get_keyboard(kbd->dev);
1572 if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
1573 xkb_state = ds_keyboard_get_xkb_state(ds_keyboard);
1575 nsyms = xkb_state_key_get_syms(xkb_state, event->keycode + 8,
1577 for (int i = 0; i < nsyms; i++) {
1578 handled = server_handle_keybinding(kbd->server, syms[i]);
1584 ds_seat_keyboard_notify_key(kbd->server->seat, event->time_msec,
1585 event->keycode, event->state);
1590 server_add_keyboard(struct tinyds_server *server, struct ds_input_device *dev)
1592 struct tinyds_keyboard *kbd;
1593 struct xkb_context *context;
1594 struct xkb_keymap *keymap;
1596 kbd = calloc(1, sizeof *kbd);
1600 kbd->server = server;
1602 context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
1606 keymap = xkb_keymap_new_from_names(context, NULL,
1607 XKB_KEYMAP_COMPILE_NO_FLAGS);
1610 ds_err("Failed to compile keymap");
1611 xkb_context_unref(context);
1615 ds_keyboard_set_keymap(ds_input_device_get_keyboard(dev), keymap);
1617 xkb_keymap_unref(keymap);
1618 xkb_context_unref(context);
1620 kbd->destroy.notify = keyboard_handle_device_destroy;
1621 ds_input_device_add_destroy_listener(dev, &kbd->destroy);
1623 kbd->key.notify = keyboard_handle_key;
1624 ds_keyboard_add_key_listener(ds_input_device_get_keyboard(dev), &kbd->key);
1626 wl_list_insert(&server->keyboards, &kbd->link);
1628 ds_inf("Keyboard(%p) added", kbd);
1636 static struct tinyds_view *
1637 server_view_at(struct tinyds_server *server, double lx, double ly,
1638 double *sx, double *sy)
1640 struct tinyds_view *view;
1641 struct ds_surface *surface;
1642 struct ds_buffer *buffer;
1643 int x, y, w = 0, h = 0;
1645 wl_list_for_each(view, &server->views, link) {
1646 surface = ds_xdg_surface_get_surface(view->xdg_surface);
1647 buffer = ds_surface_get_buffer(surface);
1648 ds_buffer_get_size(buffer, &w, &h);
1653 if (lx >= x && lx <= x + w && ly >= y && ly <= y + h) {
1665 touch_handle_device_destroy(struct wl_listener *listener, void *data)
1667 struct tinyds_touch *touch;
1669 touch = wl_container_of(listener, touch, destroy);
1671 ds_inf("Touch(%p) destroyed", touch);
1673 wl_list_remove(&touch->destroy.link);
1674 wl_list_remove(&touch->down.link);
1675 wl_list_remove(&touch->up.link);
1676 wl_list_remove(&touch->motion.link);
1682 touch_handle_down(struct wl_listener *listener, void *data)
1684 struct ds_event_touch_down *event = data;
1685 struct tinyds_touch *touch;
1686 struct tinyds_view *view;
1687 struct tinyds_server *server;
1688 double sx = 0.f, sy = 0.f;
1690 touch = wl_container_of(listener, touch, down);
1692 server = touch->server;
1693 server->output_x = event->x * server->output->width;
1694 server->output_y = event->y * server->output->height;
1696 ds_inf("Touch(%p) event down: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1697 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1699 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1702 ds_seat_touch_notify_down(touch->server->seat, ds_xdg_surface_get_surface(view->xdg_surface),
1703 event->time_msec, event->id, sx, sy);
1708 touch_handle_up(struct wl_listener *listener, void *data)
1710 struct ds_event_touch_up *event = data;
1711 struct tinyds_touch *touch;
1713 touch = wl_container_of(listener, touch, up);
1715 ds_inf("Touch(%p) event up: id(%d) time_msec(%d)",
1716 touch->dev, event->id, event->time_msec);
1718 ds_seat_touch_notify_up(touch->server->seat, event->time_msec, event->id);
1722 touch_handle_motion(struct wl_listener *listener, void *data)
1724 struct ds_event_touch_motion *event = data;
1725 struct tinyds_touch *touch;
1726 struct tinyds_view *view;
1727 struct tinyds_server *server;
1728 double sx = 0.f, sy = 0.f;
1730 touch = wl_container_of(listener, touch, motion);
1732 server = touch->server;
1733 server->output_x = event->x * server->output->width;
1734 server->output_y = event->y * server->output->height;
1736 ds_inf("Touch(%p) event motion: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1737 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1739 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1742 ds_seat_touch_notify_motion(server->seat, event->time_msec,
1748 server_add_touch(struct tinyds_server *server, struct ds_input_device *dev)
1750 struct tinyds_touch *touch;
1752 touch = calloc(1, sizeof *touch);
1756 touch->server = server;
1758 touch->destroy.notify = touch_handle_device_destroy;
1759 ds_input_device_add_destroy_listener(dev, &touch->destroy);
1761 touch->down.notify = touch_handle_down;
1762 ds_touch_add_down_listener(ds_input_device_get_touch(dev), &touch->down);
1764 touch->up.notify = touch_handle_up;
1765 ds_touch_add_up_listener(ds_input_device_get_touch(dev), &touch->up);
1767 touch->motion.notify = touch_handle_motion;
1768 ds_touch_add_motion_listener(ds_input_device_get_touch(dev), &touch->motion);
1770 ds_inf("Touch(%p) added", touch);
1774 pointer_handle_device_destroy(struct wl_listener *listener, void *data)
1776 struct tinyds_pointer *pointer;
1778 pointer = wl_container_of(listener, pointer, destroy);
1780 ds_inf("Pointer(%p) destroyed", pointer);
1782 wl_list_remove(&pointer->destroy.link);
1783 wl_list_remove(&pointer->motion.link);
1784 wl_list_remove(&pointer->button.link);
1785 wl_list_remove(&pointer->frame.link);
1786 wl_list_remove(&pointer->link);
1792 pointer_handle_motion(struct wl_listener *listener, void *data)
1794 struct tinyds_pointer *pointer;
1795 struct ds_event_pointer_motion *event = data;
1796 struct tinyds_view *view;
1797 struct tinyds_server *server;
1801 pointer = wl_container_of(listener, pointer, motion);
1803 server = pointer->server;
1804 if (server->output) {
1805 ow = server->output->width;
1806 oh = server->output->height;
1809 if (server->output_x + event->delta_x >= ow)
1810 server->output_x = ow;
1811 else if(server->output_x + event->delta_x <= 0.f)
1812 server->output_x = 0.f;
1814 server->output_x = server->output_x + event->delta_x ;
1815 if (server->output_y + event->delta_y >= oh)
1816 server->output_y = oh;
1817 else if(server->output_y + event->delta_y <= 0.f)
1818 server->output_y = 0.f;
1820 server->output_y = server->output_y + event->delta_y ;
1822 ds_inf("Pointer(%p) motion: (delta_x %.1f delta_y %.1f) output_x %.1f output_y %.1f",
1823 pointer, event->delta_x, event->delta_y, server->output_x, server->output_y);
1825 view = server_view_at(pointer->server, server->output_x, server->output_y, &sx, &sy);
1827 if (pointer->focused_view != view) {
1828 if (pointer->focused_view) {
1829 ds_inf("Clear pointer focus from view(%p)", pointer->focused_view);
1830 ds_seat_pointer_notify_clear_focus(pointer->server->seat);
1831 pointer->focused_view = NULL;
1835 ds_inf("Set pointer focus to view(%p)", view);
1836 ds_seat_pointer_notify_enter(pointer->server->seat,
1837 ds_xdg_surface_get_surface(view->xdg_surface), sx, sy);
1838 pointer->focused_view = view;
1843 ds_seat_pointer_notify_motion(pointer->server->seat,
1844 event->time_msec, sx, sy);
1849 pointer_handle_button(struct wl_listener *listener, void *data)
1851 struct tinyds_pointer *pointer;
1852 struct ds_event_pointer_button *event = data;
1854 pointer = wl_container_of(listener, pointer, button);
1856 ds_inf("Pointer(%p) button(%d): state(%s) time(%d)",
1857 pointer, event->button,
1858 (event->state == DS_BUTTON_PRESSED) ? "Pressed" : "Released",
1861 ds_seat_pointer_notify_button(pointer->server->seat, event->time_msec, event->button, event->state);
1865 pointer_handle_frame(struct wl_listener *listener, void *data)
1867 struct tinyds_pointer *pointer;
1869 pointer = wl_container_of(listener, pointer, frame);
1871 ds_inf("Pointer(%p) frame", pointer);
1872 ds_seat_pointer_notify_frame(pointer->server->seat);
1876 server_add_pointer(struct tinyds_server *server, struct ds_input_device *dev)
1878 struct tinyds_pointer *pointer;
1880 pointer = calloc(1, sizeof *pointer);
1884 pointer->server = server;
1885 server->output_x = 200;
1886 server->output_y = 200;
1888 pointer->destroy.notify = pointer_handle_device_destroy;
1889 ds_input_device_add_destroy_listener(dev, &pointer->destroy);
1891 pointer->motion.notify = pointer_handle_motion;
1892 ds_pointer_add_motion_listener(ds_input_device_get_pointer(dev),
1895 pointer->button.notify = pointer_handle_button;
1896 ds_pointer_add_button_listener(ds_input_device_get_pointer(dev),
1899 pointer->frame.notify = pointer_handle_frame;
1900 ds_pointer_add_frame_listener(ds_input_device_get_pointer(dev),
1903 pointer->focused_view = NULL;
1905 wl_list_insert(&server->pointers, &pointer->link);
1907 ds_inf("Pointer(%p) added", pointer);
1911 output_schedule_commit_handle_idle_timer(void *data)
1913 struct tinyds_output *output = data;
1914 output->idle_commit = NULL;
1916 output_commit(output);
1920 output_schedule_commit(struct tinyds_output *output)
1922 if (output->idle_commit)
1925 struct wl_event_loop *ev = wl_display_get_event_loop(output->server->display);
1926 output->idle_commit =
1927 wl_event_loop_add_idle(ev, output_schedule_commit_handle_idle_timer, output);
1931 text_input_mgr_handle_destroy(struct wl_listener *listener, void *data)
1933 struct tinyds_text_input *text_input;
1934 struct tinyds_server *server;
1936 ds_inf("text_input_mgr_handle_destroy");
1937 text_input = wl_container_of(listener, text_input, mgr_destroy);
1939 wl_list_remove(&text_input->mgr_destroy.link);
1940 wl_list_remove(&text_input->destroy.link);
1942 wl_list_remove(&text_input->new_text_input.link);
1944 wl_list_remove(&text_input->text_input_activate.link);
1945 wl_list_remove(&text_input->text_input_deactivate.link);
1946 wl_list_remove(&text_input->text_input_reset.link);
1947 wl_list_remove(&text_input->text_input_set_content_type.link);
1948 wl_list_remove(&text_input->text_input_invoke_action.link);
1949 wl_list_remove(&text_input->text_input_commit_state.link);
1950 wl_list_remove(&text_input->text_input_set_preferred_language.link);
1952 server = text_input->server;
1953 server->text_input = NULL;
1959 text_input_handle_destroy(struct wl_listener *listener, void *data)
1961 struct tinyds_text_input *text_input;
1963 ds_inf("text_input_handle_destroy");
1965 text_input = wl_container_of(listener, text_input, destroy);
1967 wl_list_remove(&text_input->destroy.link);
1971 text_input_handle_activate(struct wl_listener *listener, void *data)
1973 struct tinyds_text_input *text_input;
1974 struct tinyds_input_method *input_method;
1975 struct ds_tizen_text_input_event_activate *event = data;
1977 text_input = wl_container_of(listener, text_input, text_input_activate);
1979 input_method = text_input->server->input_method;
1981 ds_inf("text_input_handle_activate. text_input(%p) seat(%p) surface(%p) text_input(%p)",
1982 text_input, event->seat, event->surface, event->text_input);
1984 if (input_method->input == text_input)
1986 if (input_method->input)
1987 ;//deactivate_input_method(server->input_method);
1988 input_method->input = text_input;
1989 wl_list_insert(&text_input->input_methods, &input_method->link);
1991 text_input->surface = event->surface;
1993 if (!add_new_input_method_context(input_method, text_input))
1996 // ds_tizen_input_method_send_set_text_input_id();
2000 text_input_handle_deactivate(struct wl_listener *listener, void *data)
2002 struct tinyds_text_input *text_input;
2003 struct tinyds_input_method *input_method, *tmp;
2004 struct ds_tizen_text_input_event_deactivate *event = data;
2006 text_input = wl_container_of(listener, text_input, text_input_deactivate);
2007 ds_inf("text_input_handle_deactivate. text_input(%p) seat(%p) text_input(%p)",
2008 text_input, event->seat, event->text_input);
2010 wl_list_for_each_safe(input_method, tmp, &text_input->input_methods, link) {
2011 if (!input_method->input_method || !input_method->context->context) continue;
2012 ds_tizen_input_method_send_deactivate(input_method->input_method, input_method->context->context);
2013 input_method->input = NULL;
2014 input_method->context = NULL;
2015 wl_list_remove(&input_method->link);
2018 text_input->surface = NULL;
2019 // ds_tizen_input_method_send_close_connection();
2023 text_input_handle_reset(struct wl_listener *listener, void *data)
2025 struct tinyds_text_input *text_input;
2026 struct tinyds_input_method *input_method;
2028 text_input = wl_container_of(listener, text_input, text_input_reset);
2030 ds_inf("text_input_handle_reset. text_input(%p)", text_input);
2032 wl_list_for_each(input_method, &text_input->input_methods, link) {
2033 if (!input_method->context || !input_method->context->context) continue;
2034 ds_tizen_input_method_context_send_reset(input_method->context->context);
2039 text_input_handle_set_content_type(struct wl_listener *listener, void *data)
2041 struct tinyds_text_input *text_input;
2042 struct ds_tizen_text_input_event_set_content_type *event = data;
2043 struct tinyds_input_method *input_method;
2045 text_input = wl_container_of(listener, text_input, text_input_set_content_type);
2047 ds_inf("text_input_handle_content_type. text_input(%p) hint(%u) purpose(%u)",
2048 text_input, event->hint, event->purpose);
2050 wl_list_for_each(input_method, &text_input->input_methods, link) {
2051 if (!input_method->context || !input_method->context->context) continue;
2052 ds_tizen_input_method_context_send_content_type(input_method->context->context,
2053 event->hint, event->purpose);
2058 text_input_handle_invoke_action(struct wl_listener *listener, void *data)
2060 struct tinyds_text_input *text_input;
2061 struct ds_tizen_text_input_event_invoke_action *event = data;
2062 struct tinyds_input_method *input_method;
2064 text_input = wl_container_of(listener, text_input, text_input_invoke_action);
2066 ds_inf("text_input_handle_invoke_action. text_input(%p) button(%u) index(%u)",
2067 text_input, event->button, event->index);
2069 wl_list_for_each(input_method, &text_input->input_methods, link) {
2070 if (!input_method->context || !input_method->context->context) continue;
2071 ds_tizen_input_method_context_send_invoke_action(input_method->context->context,
2072 event->button, event->index);
2077 text_input_handle_commit_state(struct wl_listener *listener, void *data)
2079 struct tinyds_text_input *text_input;
2080 struct ds_tizen_text_input_event_commit_state *event = data;
2081 struct tinyds_input_method *input_method;
2083 text_input = wl_container_of(listener, text_input, text_input_commit_state);
2085 ds_inf("text_input_handle_commit_state. text_input(%p) serial(%u)",
2086 text_input, event->serial);
2088 wl_list_for_each(input_method, &text_input->input_methods, link) {
2089 if (!input_method->context || !input_method->context->context) continue;
2090 ds_tizen_input_method_context_send_commit_state(input_method->context->context,
2096 text_input_handle_set_preferred_language(struct wl_listener *listener, void *data)
2098 struct tinyds_text_input *text_input;
2099 struct ds_tizen_text_input_event_set_preferred_language *event = data;
2100 struct tinyds_input_method *input_method;
2102 text_input = wl_container_of(listener, text_input, text_input_set_preferred_language);
2104 ds_inf("text_input_handle_set_preferred_language. text_input(%p) language(%s)",
2105 text_input, event->language);
2107 wl_list_for_each(input_method, &text_input->input_methods, link) {
2108 if (!input_method->context || !input_method->context->context) continue;
2109 ds_tizen_input_method_context_send_preferred_language(input_method->context->context,
2115 text_input_mgr_handle_new_text_input(struct wl_listener *listener, void *data)
2117 struct tinyds_text_input *text_input;
2118 struct ds_tizen_text_input *input = data;
2120 text_input = wl_container_of(listener, text_input, new_text_input);
2122 ds_inf("text_input_mgr_handle_new_text_input");
2124 text_input->input = input;
2126 text_input->destroy.notify = text_input_handle_destroy;
2127 ds_tizen_text_input_add_destroy_listener(text_input->input,
2128 &text_input->destroy);
2130 text_input->text_input_activate.notify = text_input_handle_activate;
2131 ds_tizen_text_input_add_activate_listener(text_input->input,
2132 &text_input->text_input_activate);
2134 text_input->text_input_deactivate.notify = text_input_handle_deactivate;
2135 ds_tizen_text_input_add_deactivate_listener(text_input->input,
2136 &text_input->text_input_deactivate);
2138 text_input->text_input_reset.notify = text_input_handle_reset;
2139 ds_tizen_text_input_add_reset_listener(text_input->input,
2140 &text_input->text_input_reset);
2142 text_input->text_input_set_content_type.notify = text_input_handle_set_content_type;
2143 ds_tizen_text_input_add_set_content_type_listener(text_input->input,
2144 &text_input->text_input_set_content_type);
2146 text_input->text_input_invoke_action.notify = text_input_handle_invoke_action;
2147 ds_tizen_text_input_add_invoke_action_listener(text_input->input,
2148 &text_input->text_input_invoke_action);
2150 text_input->text_input_commit_state.notify = text_input_handle_commit_state;
2151 ds_tizen_text_input_add_commit_state_listener(text_input->input,
2152 &text_input->text_input_commit_state);
2154 text_input->text_input_set_preferred_language.notify = text_input_handle_set_preferred_language;
2155 ds_tizen_text_input_add_set_preferred_language_listener(text_input->input,
2156 &text_input->text_input_set_preferred_language);
2160 input_method_mgr_handle_destroy(struct wl_listener *listener, void *data)
2162 struct tinyds_input_method *input_method;
2164 ds_inf("input_method_mgr_handle_destroy");
2166 input_method = wl_container_of(listener, input_method, mgr_destroy);
2168 wl_list_remove(&input_method->mgr_destroy.link);
2172 input_method_handle_destroy(struct wl_listener *listener, void *data)
2174 struct tinyds_input_method *input_method;
2175 struct tinyds_server *server;
2177 ds_inf("input_method_handle_destroy");
2179 input_method = wl_container_of(listener, input_method, destroy);
2181 wl_list_remove(&input_method->destroy.link);
2183 server = input_method->server;
2184 server->input_method = NULL;
2190 context_handle_destroy(struct wl_listener *listener, void *data)
2192 struct tinyds_input_method_context *context;
2193 struct tinyds_server *server;
2195 ds_inf("context_handle_destroy");
2197 context = wl_container_of(listener, context, destroy);
2199 wl_list_remove(&context->destroy.link);
2201 wl_list_remove(&context->im_context_commit_string.link);
2202 wl_list_remove(&context->im_context_preedit_string.link);
2203 wl_list_remove(&context->im_context_preedit_styling.link);
2204 wl_list_remove(&context->im_context_preedit_cursor.link);
2205 wl_list_remove(&context->im_context_delete_surrounding_text.link);
2206 wl_list_remove(&context->im_context_cursor_position.link);
2207 wl_list_remove(&context->im_context_modifiers_map.link);
2208 wl_list_remove(&context->im_context_keysym.link);
2209 wl_list_remove(&context->im_context_grab_keyboard.link);
2210 wl_list_remove(&context->im_context_key.link);
2211 wl_list_remove(&context->im_context_modifiers.link);
2212 wl_list_remove(&context->im_context_language.link);
2213 wl_list_remove(&context->im_context_text_direction.link);
2215 server = context->server;
2216 server->input_method->context = NULL;
2222 context_handle_commit_string(struct wl_listener *listener, void *data)
2224 struct tinyds_text_input *text_input;
2225 struct tinyds_input_method_context *context;
2226 struct ds_tizen_input_method_context_event_commit_string *event = data;
2228 context = wl_container_of(listener, context, im_context_commit_string);
2229 text_input = context->server->text_input;
2231 ds_inf("context_handle_commit_string. text_input(%p) serial(%u) text(%s)",
2232 text_input, event->serial, event->text);
2234 ds_tizen_text_input_send_commit_string(text_input->input, event->serial, event->text);
2238 context_handle_preedit_string(struct wl_listener *listener, void *data)
2240 struct tinyds_input_method_context *context;
2241 struct tinyds_text_input *text_input;
2242 struct ds_tizen_input_method_context_event_preedit_string *event = data;
2244 context = wl_container_of(listener, context, im_context_preedit_string);
2245 text_input = context->server->text_input;
2247 ds_inf("context_handle_preedit_string. text_input(%p) serial(%u) text(%s) commit(%s)",
2248 text_input, event->serial, event->text, event->commit);
2250 ds_tizen_text_input_send_preedit_string(text_input->input, event->serial, event->text, event->commit);
2254 context_handle_preedit_styling(struct wl_listener *listener, void *data)
2256 struct tinyds_input_method_context *context;
2257 struct tinyds_text_input *text_input;
2258 struct ds_tizen_input_method_context_event_preedit_styling *event = data;
2260 context = wl_container_of(listener, context, im_context_preedit_styling);
2261 text_input = context->server->text_input;
2263 ds_inf("context_handle_preedit_styling. text_input(%p) index(%u) length(%u) style(%u)",
2264 text_input, event->index, event->length, event->style);
2266 ds_tizen_text_input_send_preedit_styling(text_input->input, event->index, event->length, event->style);
2270 context_handle_preedit_cursor(struct wl_listener *listener, void *data)
2272 struct tinyds_input_method_context *context;
2273 struct tinyds_text_input *text_input;
2274 struct ds_tizen_input_method_context_event_preedit_cursor *event = data;
2276 context = wl_container_of(listener, context, im_context_preedit_cursor);
2277 text_input = context->server->text_input;
2279 ds_inf("context_handle_preedit_cursor. text_input(%p) index(%u)",
2280 text_input, event->index);
2282 ds_tizen_text_input_send_preedit_cursor(text_input->input, event->index);
2286 context_handle_delete_surrounding_text(struct wl_listener *listener, void *data)
2288 struct tinyds_input_method_context *context;
2289 struct tinyds_text_input *text_input;
2290 struct ds_tizen_input_method_context_event_delete_surrounding_text *event = data;
2292 context = wl_container_of(listener, context, im_context_delete_surrounding_text);
2293 text_input = context->server->text_input;
2295 ds_inf("context_handle_delete_surrounding_text. text_input(%p) index(%d) length(%u)",
2296 text_input, event->index, event->length);
2298 ds_tizen_text_input_send_delete_surrounding_text(text_input->input, event->index, event->length);
2302 context_handle_cursor_position(struct wl_listener *listener, void *data)
2304 struct tinyds_input_method_context *context;
2305 struct tinyds_text_input *text_input;
2306 struct ds_tizen_input_method_context_event_cursor_position *event = data;
2308 context = wl_container_of(listener, context, im_context_cursor_position);
2309 text_input = context->server->text_input;
2311 ds_inf("context_handle_cursor_position. text_input(%p) index(%d) length(%d)",
2312 text_input, event->index, event->anchor);
2314 ds_tizen_text_input_send_cursor_position(text_input->input, event->index, event->anchor);
2318 context_handle_modifiers_map(struct wl_listener *listener, void *data)
2320 struct tinyds_input_method_context *context;
2321 struct tinyds_text_input *text_input;
2322 struct ds_tizen_input_method_context_event_modifiers_map *event = data;
2324 context = wl_container_of(listener, context, im_context_modifiers_map);
2325 text_input = context->server->text_input;
2327 ds_inf("context_handle_modifiers_map. text_input(%p) map(%p)",
2328 text_input, event->map);
2330 ds_tizen_text_input_send_modifiers_map(text_input->input, event->map);
2334 context_handle_keysym(struct wl_listener *listener, void *data)
2336 struct tinyds_input_method_context *context;
2337 struct tinyds_text_input *text_input;
2338 struct ds_tizen_input_method_context_event_keysym *event = data;
2340 context = wl_container_of(listener, context, im_context_keysym);
2341 text_input = context->server->text_input;
2343 ds_inf("context_handle_keysym. text_input(%p) serial(%u) time(%u) sysm(%u) state(%u) modifiers(%u)",
2344 text_input, event->serial, event->time, event->sym, event->state, event->modifiers);
2346 ds_tizen_text_input_send_keysym(text_input->input, event->serial, event->time, event->sym, event->state, event->modifiers);
2350 context_handle_grab_keyboard(struct wl_listener *listener, void *data)
2352 struct tinyds_input_method_context *context;
2353 struct tinyds_text_input *text_input;
2355 context = wl_container_of(listener, context, im_context_grab_keyboard);
2356 text_input = context->server->text_input;
2358 ds_inf("context_handle_grab_keyboard. text_input(%p)",
2365 context_handle_key(struct wl_listener *listener, void *data)
2367 struct tinyds_input_method_context *context;
2368 struct tinyds_text_input *text_input;
2370 context = wl_container_of(listener, context, im_context_key);
2371 text_input = context->server->text_input;
2373 ds_inf("context_handle_key. text_input(%p)",
2380 context_handle_modifiers(struct wl_listener *listener, void *data)
2382 struct tinyds_input_method_context *context;
2383 struct tinyds_text_input *text_input;
2385 context = wl_container_of(listener, context, im_context_modifiers);
2386 text_input = context->server->text_input;
2388 ds_inf("context_handle_modifiers. text_input(%p)",
2395 context_handle_language(struct wl_listener *listener, void *data)
2397 struct tinyds_input_method_context *context;
2398 struct tinyds_text_input *text_input;
2399 struct ds_tizen_input_method_context_event_language *event = data;
2401 context = wl_container_of(listener, context, im_context_language);
2402 text_input = context->server->text_input;
2404 ds_inf("context_handle_language. text_input(%p) serial(%u), language(%s)",
2405 text_input, event->serial, event->language);
2407 ds_tizen_text_input_send_language(text_input->input, event->serial, event->language);
2411 context_handle_text_direction(struct wl_listener *listener, void *data)
2413 struct tinyds_input_method_context *context;
2414 struct tinyds_text_input *text_input;
2415 struct ds_tizen_input_method_context_event_text_direction *event = data;
2417 context = wl_container_of(listener, context, im_context_text_direction);
2418 text_input = context->server->text_input;
2420 ds_inf("context_handle_text_direction. text_input(%p) serial(%u), direction(%u)",
2421 text_input, event->serial, event->direction);
2423 ds_tizen_text_input_send_text_direction(text_input->input, event->serial, event->direction);
2427 add_new_text_input(struct tinyds_server *server)
2429 struct tinyds_text_input *text_input;
2431 text_input = calloc(1, sizeof *text_input);
2435 text_input->text_input_mgr = ds_tizen_text_input_manager_create(server->display);
2436 if (!text_input->text_input_mgr) {
2438 ds_err("Could not create ds_tizen_text_input_manager");
2442 wl_list_init(&text_input->input_methods);
2444 text_input->destroy.notify = text_input_mgr_handle_destroy;
2445 ds_tizen_text_input_manager_add_destroy_listener(text_input->text_input_mgr,
2446 &text_input->destroy);
2448 text_input->new_text_input.notify = text_input_mgr_handle_new_text_input;
2449 ds_tizen_text_input_manager_add_new_text_input_listener(text_input->text_input_mgr,
2450 &text_input->new_text_input);
2452 text_input->server = server;
2453 server->text_input = text_input;
2455 ds_inf("Text_Input (%p) added", text_input);
2461 add_new_input_method(struct tinyds_server *server)
2463 struct tinyds_input_method *input_method;
2465 input_method = calloc(1, sizeof *input_method);
2469 input_method->input_method = ds_tizen_input_method_create(server->display);
2470 if (!input_method->input_method) {
2472 ds_err("Could not create ds_tizen_input_method");
2475 input_method->destroy.notify = input_method_handle_destroy;
2476 ds_tizen_input_method_add_destroy_listener(input_method->input_method,
2477 &input_method->destroy);
2479 input_method->input_method_mgr = ds_tizen_input_method_manager_create(server->display);
2480 if (!input_method->input_method_mgr) {
2482 ds_err("Could not create ds_tizen_input_method_manager");
2486 input_method->mgr_destroy.notify = input_method_mgr_handle_destroy;
2487 ds_tizen_input_method_manager_add_destroy_listener(input_method->input_method_mgr,
2488 &input_method->mgr_destroy);
2490 input_method->server = server;
2491 server->input_method = input_method;
2493 ds_inf("Input_Method (%p) added", input_method);
2499 add_new_input_method_context(struct tinyds_input_method *input_method,
2500 struct tinyds_text_input *text_input)
2502 struct tinyds_input_method_context *context;
2504 context = calloc(1, sizeof *context);
2505 if (context == NULL)
2507 ds_err("calloc is failed. tinyds_input_method_context");
2510 input_method->context = context;
2511 context->input_method = input_method;
2512 context->server = input_method->server;
2513 context->input = text_input;
2515 context->context = ds_tizen_input_method_create_context(input_method->input_method);
2516 if (context->context == NULL) {
2517 ds_err("ds_tizen_input_method_create_context() failed.");
2521 context->destroy.notify = context_handle_destroy;
2522 ds_tizen_input_method_context_add_destroy_listener(context->context,
2525 context->im_context_commit_string.notify = context_handle_commit_string;
2526 ds_tizen_input_method_context_add_commit_string_listener(context->context,
2527 &context->im_context_commit_string);
2529 context->im_context_preedit_string.notify = context_handle_preedit_string;
2530 ds_tizen_input_method_context_add_preedit_string_listener(context->context,
2531 &context->im_context_preedit_string);
2533 context->im_context_preedit_styling.notify = context_handle_preedit_styling;
2534 ds_tizen_input_method_context_add_preedit_styling_listener(context->context,
2535 &context->im_context_preedit_styling);
2537 context->im_context_preedit_cursor.notify = context_handle_preedit_cursor;
2538 ds_tizen_input_method_context_add_preedit_cursor_listener(context->context,
2539 &context->im_context_preedit_cursor);
2541 context->im_context_delete_surrounding_text.notify = context_handle_delete_surrounding_text;
2542 ds_tizen_input_method_context_add_delete_surrounding_text_listener(context->context,
2543 &context->im_context_delete_surrounding_text);
2545 context->im_context_cursor_position.notify = context_handle_cursor_position;
2546 ds_tizen_input_method_context_add_cursor_position_listener(context->context,
2547 &context->im_context_cursor_position);
2549 context->im_context_modifiers_map.notify = context_handle_modifiers_map;
2550 ds_tizen_input_method_context_add_modifiers_map_listener(context->context,
2551 &context->im_context_modifiers_map);
2553 context->im_context_keysym.notify = context_handle_keysym;
2554 ds_tizen_input_method_context_add_keysym_listener(context->context,
2555 &context->im_context_keysym);
2557 context->im_context_grab_keyboard.notify = context_handle_grab_keyboard;
2558 ds_tizen_input_method_context_add_grab_keyboard_listener(context->context,
2559 &context->im_context_grab_keyboard);
2561 context->im_context_key.notify = context_handle_key;
2562 ds_tizen_input_method_context_add_key_listener(context->context,
2563 &context->im_context_key);
2565 context->im_context_modifiers.notify = context_handle_modifiers;
2566 ds_tizen_input_method_context_add_modifiers_listener(context->context,
2567 &context->im_context_modifiers);
2569 context->im_context_language.notify = context_handle_language;
2570 ds_tizen_input_method_context_add_language_listener(context->context,
2571 &context->im_context_language);
2573 context->im_context_text_direction.notify = context_handle_text_direction;
2574 ds_tizen_input_method_context_add_text_direction_listener(context->context,
2575 &context->im_context_text_direction);
2581 visibility_handle_destroy(struct wl_listener *listener, void *data)
2583 struct tinyds_policy_visibility *visibility;
2585 visibility = wl_container_of(listener, visibility, destroy);
2587 ds_inf("Policy Visibility(%p) destroy", visibility);
2589 wl_list_remove(&visibility->link);
2594 position_handle_destroy(struct wl_listener *listener, void *data)
2596 struct tinyds_policy_position *position;
2598 position = wl_container_of(listener, position, destroy);
2600 ds_inf("Policy Position(%p) destroy", position);
2602 wl_list_remove(&position->link);
2607 position_handle_set(struct wl_listener *listener, void *data)
2609 struct tinyds_policy_position *position;
2611 position = wl_container_of(listener, position, set);
2613 ds_inf("Policy Position(%p) set", position);
2619 subsurface_watcher_handle_destroy(struct wl_listener *listener, void *data)
2621 struct tinyds_policy_subsurface_watcher *subsurface_watcher;
2623 subsurface_watcher = wl_container_of(listener, subsurface_watcher, destroy);
2625 ds_inf("Policy Subsurface_Watcher(%p) destroy", subsurface_watcher);
2627 wl_list_remove(&subsurface_watcher->link);
2628 free(subsurface_watcher);
2632 policy_surface_handle_destroy(struct wl_listener *listener, void *data)
2634 struct tinyds_policy_surface *policy_surface;
2636 policy_surface = wl_container_of(listener, policy_surface, destroy);
2638 ds_inf("Policy Info(%p) destroy", policy_surface);
2640 wl_list_remove(&policy_surface->link);
2641 free(policy_surface);
2645 policy_surface_handle_new_visibility(struct wl_listener *listener, void *data)
2647 struct tinyds_policy_surface *policy_surface;
2648 struct tinyds_policy_visibility *visibility;
2649 struct ds_tizen_event_policy_surface_new_visibility *event;
2651 policy_surface = wl_container_of(listener, policy_surface, new_visibility);
2652 event = (struct ds_tizen_event_policy_surface_new_visibility *)data;
2654 ds_inf("Policy Info(%p) new_visibility", policy_surface);
2656 visibility = calloc(1, sizeof *visibility);
2660 visibility->visibility = event->visibility;
2662 visibility->destroy.notify = visibility_handle_destroy;
2663 ds_tizen_policy_visibility_add_destroy_listener(visibility->visibility,
2664 &visibility->destroy);
2666 wl_list_insert(&policy_surface->visibilities, &visibility->link);
2670 policy_surface_handle_new_position(struct wl_listener *listener, void *data)
2672 struct tinyds_policy_surface *policy_surface;
2673 struct tinyds_policy_position *position;
2674 struct ds_tizen_event_policy_surface_new_position *event;
2676 policy_surface = wl_container_of(listener, policy_surface, new_position);
2677 event = (struct ds_tizen_event_policy_surface_new_position *)data;
2679 ds_inf("Policy Info(%p) new_position", policy_surface);
2681 position = calloc(1, sizeof *position);
2685 position->position = event->position;
2687 position->destroy.notify = position_handle_destroy;
2688 ds_tizen_policy_position_add_destroy_listener(position->position,
2689 &position->destroy);
2691 position->set.notify = position_handle_set;
2692 ds_tizen_policy_position_add_set_listener(position->position,
2695 wl_list_insert(&policy_surface->positions, &position->link);
2699 policy_surface_handle_activate(struct wl_listener *listener, void *data)
2701 struct tinyds_policy_surface *policy_surface;
2703 policy_surface = wl_container_of(listener, policy_surface, activate);
2705 ds_inf("Policy Info(%p) activate", policy_surface);
2711 policy_surface_handle_raise(struct wl_listener *listener, void *data)
2713 struct tinyds_policy_surface *policy_surface;
2715 policy_surface = wl_container_of(listener, policy_surface, raise);
2717 ds_inf("Policy Info(%p) raise", policy_surface);
2723 policy_surface_handle_lower(struct wl_listener *listener, void *data)
2725 struct tinyds_policy_surface *policy_surface;
2727 policy_surface = wl_container_of(listener, policy_surface, raise);
2729 ds_inf("Policy Info(%p) lower", policy_surface);
2735 policy_surface_handle_set_focus_skip(struct wl_listener *listener, void *data)
2737 struct tinyds_policy_surface *policy_surface;
2739 policy_surface = wl_container_of(listener, policy_surface, set_focus_skip);
2741 ds_inf("Policy Info(%p) set_focus_skip", policy_surface);
2747 policy_surface_handle_unset_focus_skip(struct wl_listener *listener, void *data)
2749 struct tinyds_policy_surface *policy_surface;
2751 policy_surface = wl_container_of(listener, policy_surface, unset_focus_skip);
2753 ds_inf("Policy Info(%p) unset_focus_skip", policy_surface);
2759 policy_surface_handle_set_role(struct wl_listener *listener, void *data)
2761 struct tinyds_policy_surface *policy_surface;
2763 policy_surface = wl_container_of(listener, policy_surface, set_role);
2765 ds_inf("Policy Info(%p) set_role", policy_surface);
2771 policy_surface_handle_set_window_type(struct wl_listener *listener, void *data)
2773 struct tinyds_policy_surface *policy_surface;
2775 policy_surface = wl_container_of(listener, policy_surface, set_window_type);
2777 ds_inf("Policy Info(%p) set_window_type", policy_surface);
2783 policy_surface_handle_set_conformant(struct wl_listener *listener, void *data)
2785 struct tinyds_policy_surface *policy_surface;
2787 policy_surface = wl_container_of(listener, policy_surface, set_conformant);
2789 ds_inf("Policy Info(%p) set_conformant", policy_surface);
2795 policy_surface_handle_unset_conformant(struct wl_listener *listener, void *data)
2797 struct tinyds_policy_surface *policy_surface;
2799 policy_surface = wl_container_of(listener, policy_surface, unset_conformant);
2801 ds_inf("Policy Info(%p) unset_conformant", policy_surface);
2807 policy_surface_handle_get_conformant(struct wl_listener *listener, void *data)
2809 struct tinyds_policy_surface *policy_surface;
2811 policy_surface = wl_container_of(listener, policy_surface, get_conformant);
2813 ds_inf("Policy Info(%p) get_conformant", policy_surface);
2819 policy_surface_handle_set_notification_level(struct wl_listener *listener, void *data)
2821 struct tinyds_policy_surface *policy_surface;
2823 policy_surface = wl_container_of(listener, policy_surface, set_notification_level);
2825 ds_inf("Policy Info(%p) set_notification_level", policy_surface);
2831 policy_surface_handle_set_window_screen_mode(struct wl_listener *listener, void *data)
2833 struct tinyds_policy_surface *policy_surface;
2835 policy_surface = wl_container_of(listener, policy_surface, set_window_screen_mode);
2837 ds_inf("Policy Info(%p) set_window_screen_mode", policy_surface);
2843 policy_surface_handle_get_subsurface(struct wl_listener *listener, void *data)
2845 struct tinyds_policy_surface *policy_surface;
2847 policy_surface = wl_container_of(listener, policy_surface, get_subsurface);
2849 ds_inf("Policy Info(%p) get_subsurface", policy_surface);
2855 policy_surface_handle_iconify(struct wl_listener *listener, void *data)
2857 struct tinyds_policy_surface *policy_surface;
2859 policy_surface = wl_container_of(listener, policy_surface, iconify);
2861 ds_inf("Policy Info(%p) iconify", policy_surface);
2867 policy_surface_handle_uniconify(struct wl_listener *listener, void *data)
2869 struct tinyds_policy_surface *policy_surface;
2871 policy_surface = wl_container_of(listener, policy_surface, uniconify);
2873 ds_inf("Policy Info(%p) uniconify", policy_surface);
2879 policy_surface_handle_add_aux_hint(struct wl_listener *listener, void *data)
2881 struct tinyds_policy_surface *policy_surface;
2883 policy_surface = wl_container_of(listener, policy_surface, add_aux_hint);
2885 ds_inf("Policy Info(%p) add_aux_hint", policy_surface);
2891 policy_surface_handle_change_aux_hint(struct wl_listener *listener, void *data)
2893 struct tinyds_policy_surface *policy_surface;
2895 policy_surface = wl_container_of(listener, policy_surface, change_aux_hint);
2897 ds_inf("Policy Info(%p) change_aux_hint", policy_surface);
2903 policy_surface_handle_delete_aux_hint(struct wl_listener *listener, void *data)
2905 struct tinyds_policy_surface *policy_surface;
2907 policy_surface = wl_container_of(listener, policy_surface, delete_aux_hint);
2909 ds_inf("Policy Info(%p) delete_aux_hint", policy_surface);
2915 policy_surface_handle_get_supported_aux_hints(struct wl_listener *listener, void *data)
2917 struct tinyds_policy_surface *policy_surface;
2919 policy_surface = wl_container_of(listener, policy_surface, get_supported_aux_hints);
2921 ds_inf("Policy Info(%p) get_supported_aux_hints", policy_surface);
2927 policy_surface_handle_set_floating_mode(struct wl_listener *listener, void *data)
2929 struct tinyds_policy_surface *policy_surface;
2931 policy_surface = wl_container_of(listener, policy_surface, set_floating_mode);
2933 ds_inf("Policy Info(%p) set_floating_mode", policy_surface);
2939 policy_surface_handle_unset_floating_mode(struct wl_listener *listener, void *data)
2941 struct tinyds_policy_surface *policy_surface;
2943 policy_surface = wl_container_of(listener, policy_surface, unset_floating_mode);
2945 ds_inf("Policy Info(%p) unset_floating_mode", policy_surface);
2951 policy_surface_handle_set_stack_mode(struct wl_listener *listener, void *data)
2953 struct tinyds_policy_surface *policy_surface;
2955 policy_surface = wl_container_of(listener, policy_surface, set_stack_mode);
2957 ds_inf("Policy Info(%p) set_stack_mode", policy_surface);
2963 policy_surface_handle_new_subsurface_watcher(struct wl_listener *listener, void *data)
2965 struct tinyds_policy_surface *policy_surface;
2966 struct tinyds_policy_subsurface_watcher*subsurface_watcher;
2967 struct ds_tizen_event_policy_surface_new_subsurface_watcher *event;
2969 policy_surface = wl_container_of(listener, policy_surface, new_subsurface_watcher);
2970 event = (struct ds_tizen_event_policy_surface_new_subsurface_watcher *)data;
2972 ds_inf("Policy Info(%p) new_subsurface_watcher", policy_surface);
2974 subsurface_watcher = calloc(1, sizeof *subsurface_watcher);
2975 if (!subsurface_watcher)
2978 subsurface_watcher->subsurface_watcher = event->subsurface_watcher;
2980 subsurface_watcher->destroy.notify = subsurface_watcher_handle_destroy;
2981 ds_tizen_policy_subsurface_watcher_add_destroy_listener(subsurface_watcher->subsurface_watcher,
2982 &subsurface_watcher->destroy);
2984 wl_list_insert(&policy_surface->subsurface_watchers, &subsurface_watcher->link);
2988 policy_surface_handle_set_parent(struct wl_listener *listener, void *data)
2990 struct tinyds_policy_surface *policy_surface;
2992 policy_surface = wl_container_of(listener, policy_surface, set_parent);
2994 ds_inf("Policy Info(%p) set_parent", policy_surface);
3000 policy_surface_handle_ack_conformant_region(struct wl_listener *listener, void *data)
3002 struct tinyds_policy_surface *policy_surface;
3004 policy_surface = wl_container_of(listener, policy_surface, ack_conformant_region);
3006 ds_inf("Policy Info(%p) ack_conformant_region", policy_surface);
3012 policy_surface_handle_set_video(struct wl_listener *listener, void *data)
3014 struct tinyds_policy_surface *policy_surface;
3016 policy_surface = wl_container_of(listener, policy_surface, set_video);
3018 ds_inf("Policy Info(%p) set_video", policy_surface);
3024 policy_surface_handle_show(struct wl_listener *listener, void *data)
3026 struct tinyds_policy_surface *policy_surface;
3028 policy_surface = wl_container_of(listener, policy_surface, show);
3030 ds_inf("Policy Info(%p) show", policy_surface);
3036 policy_surface_handle_hide(struct wl_listener *listener, void *data)
3038 struct tinyds_policy_surface *policy_surface;
3040 policy_surface = wl_container_of(listener, policy_surface, hide);
3042 ds_inf("Policy Info(%p) hide", policy_surface);
3048 policy_surface_handle_set_parent_with_below(struct wl_listener *listener, void *data)
3050 struct tinyds_policy_surface *policy_surface;
3052 policy_surface = wl_container_of(listener, policy_surface, set_parent_with_below);
3054 ds_inf("Policy Info(%p) set_parent_with_below", policy_surface);
3060 policy_handle_destroy(struct wl_listener *listener, void *data)
3062 struct tinyds_policy *policy;
3064 policy = wl_container_of(listener, policy, destroy);
3066 ds_inf("Policy(%p) destroy", policy);
3072 policy_handle_new_surface(struct wl_listener *listener, void *data)
3074 struct tinyds_policy *policy;
3075 struct tinyds_policy_surface *policy_surface;
3076 struct ds_tizen_event_policy_new_surface *event;
3078 policy = wl_container_of(listener, policy, new_surface);
3079 event = (struct ds_tizen_event_policy_new_surface *)data;
3081 ds_inf("Policy(%p) new_surface", policy);
3083 policy_surface = calloc(1, sizeof *policy_surface);
3084 if (!policy_surface)
3087 policy_surface->policy_surface = event->policy_surface;
3089 policy_surface->destroy.notify = policy_surface_handle_destroy;
3090 ds_tizen_policy_surface_add_destroy_listener(policy_surface->policy_surface,
3091 &policy_surface->destroy);
3093 policy_surface->new_visibility.notify = policy_surface_handle_new_visibility;
3094 ds_tizen_policy_surface_add_new_visibility_listener(policy_surface->policy_surface,
3095 &policy_surface->new_visibility);
3097 policy_surface->new_position.notify = policy_surface_handle_new_position;
3098 ds_tizen_policy_surface_add_new_position_listener(policy_surface->policy_surface,
3099 &policy_surface->new_position);
3101 policy_surface->activate.notify = policy_surface_handle_activate;
3102 ds_tizen_policy_surface_add_activate_listener(policy_surface->policy_surface,
3103 &policy_surface->activate);
3105 policy_surface->raise.notify = policy_surface_handle_raise;
3106 ds_tizen_policy_surface_add_raise_listener(policy_surface->policy_surface,
3107 &policy_surface->raise);
3109 policy_surface->lower.notify = policy_surface_handle_lower;
3110 ds_tizen_policy_surface_add_lower_listener(policy_surface->policy_surface,
3111 &policy_surface->lower);
3113 policy_surface->set_focus_skip.notify = policy_surface_handle_set_focus_skip;
3114 ds_tizen_policy_surface_add_set_focus_skip_listener(policy_surface->policy_surface,
3115 &policy_surface->set_focus_skip);
3117 policy_surface->unset_focus_skip.notify = policy_surface_handle_unset_focus_skip;
3118 ds_tizen_policy_surface_add_unset_focus_skip_listener(policy_surface->policy_surface,
3119 &policy_surface->unset_focus_skip);
3121 policy_surface->set_role.notify = policy_surface_handle_set_role;
3122 ds_tizen_policy_surface_add_set_role_listener(policy_surface->policy_surface,
3123 &policy_surface->set_role);
3125 policy_surface->set_window_type.notify = policy_surface_handle_set_window_type;
3126 ds_tizen_policy_surface_add_set_window_type_listener(policy_surface->policy_surface,
3127 &policy_surface->set_window_type);
3129 policy_surface->set_conformant.notify = policy_surface_handle_set_conformant;
3130 ds_tizen_policy_surface_add_set_conformant_listener(policy_surface->policy_surface,
3131 &policy_surface->set_conformant);
3133 policy_surface->unset_conformant.notify = policy_surface_handle_unset_conformant;
3134 ds_tizen_policy_surface_add_unset_conformant_listener(policy_surface->policy_surface,
3135 &policy_surface->unset_conformant);
3137 policy_surface->get_conformant.notify = policy_surface_handle_get_conformant;
3138 ds_tizen_policy_surface_add_get_conformant_listener(policy_surface->policy_surface,
3139 &policy_surface->get_conformant);
3141 policy_surface->set_notification_level.notify =
3142 policy_surface_handle_set_notification_level;
3143 ds_tizen_policy_surface_add_set_notification_level_listener(
3144 policy_surface->policy_surface, &policy_surface->set_notification_level);
3146 policy_surface->set_window_screen_mode.notify =
3147 policy_surface_handle_set_window_screen_mode;
3148 ds_tizen_policy_surface_add_set_window_screen_mode_listener(
3149 policy_surface->policy_surface, &policy_surface->set_window_screen_mode);
3151 policy_surface->get_subsurface.notify = policy_surface_handle_get_subsurface;
3152 ds_tizen_policy_surface_add_get_subsurface_listener(policy_surface->policy_surface,
3153 &policy_surface->get_subsurface);
3155 policy_surface->iconify.notify = policy_surface_handle_iconify;
3156 ds_tizen_policy_surface_add_iconify_listener(policy_surface->policy_surface,
3157 &policy_surface->iconify);
3159 policy_surface->uniconify.notify = policy_surface_handle_uniconify;
3160 ds_tizen_policy_surface_add_uniconify_listener(policy_surface->policy_surface,
3161 &policy_surface->uniconify);
3163 policy_surface->add_aux_hint.notify = policy_surface_handle_add_aux_hint;
3164 ds_tizen_policy_surface_add_add_aux_hint_listener(policy_surface->policy_surface,
3165 &policy_surface->add_aux_hint);
3167 policy_surface->change_aux_hint.notify = policy_surface_handle_change_aux_hint;
3168 ds_tizen_policy_surface_add_change_aux_hint_listener(policy_surface->policy_surface,
3169 &policy_surface->change_aux_hint);
3171 policy_surface->delete_aux_hint.notify = policy_surface_handle_delete_aux_hint;
3172 ds_tizen_policy_surface_add_delete_aux_hint_listener(policy_surface->policy_surface,
3173 &policy_surface->delete_aux_hint);
3175 policy_surface->get_supported_aux_hints.notify =
3176 policy_surface_handle_get_supported_aux_hints;
3177 ds_tizen_policy_surface_add_get_supported_aux_hints_listener(
3178 policy_surface->policy_surface, &policy_surface->get_supported_aux_hints);
3180 policy_surface->set_floating_mode.notify =
3181 policy_surface_handle_set_floating_mode;
3182 ds_tizen_policy_surface_add_set_floating_mode_listener(
3183 policy_surface->policy_surface, &policy_surface->set_floating_mode);
3185 policy_surface->unset_floating_mode.notify =
3186 policy_surface_handle_unset_floating_mode;
3187 ds_tizen_policy_surface_add_unset_floating_mode_listener(
3188 policy_surface->policy_surface, &policy_surface->unset_floating_mode);
3190 policy_surface->set_stack_mode.notify = policy_surface_handle_set_stack_mode;
3191 ds_tizen_policy_surface_add_set_stack_mode_listener(policy_surface->policy_surface,
3192 &policy_surface->set_stack_mode);
3194 policy_surface->new_subsurface_watcher.notify =
3195 policy_surface_handle_new_subsurface_watcher;
3196 ds_tizen_policy_surface_add_new_subsurface_watcher_listener(
3197 policy_surface->policy_surface, &policy_surface->new_subsurface_watcher);
3199 policy_surface->set_parent.notify = policy_surface_handle_set_parent;
3200 ds_tizen_policy_surface_add_set_parent_listener(policy_surface->policy_surface,
3201 &policy_surface->set_parent);
3203 policy_surface->ack_conformant_region.notify =
3204 policy_surface_handle_ack_conformant_region;
3205 ds_tizen_policy_surface_add_ack_conformant_region_listener(
3206 policy_surface->policy_surface, &policy_surface->ack_conformant_region);
3208 policy_surface->set_video.notify = policy_surface_handle_set_video;
3209 ds_tizen_policy_surface_add_set_video_listener(policy_surface->policy_surface,
3210 &policy_surface->set_video);
3212 policy_surface->show.notify = policy_surface_handle_show;
3213 ds_tizen_policy_surface_add_show_listener(policy_surface->policy_surface,
3214 &policy_surface->show);
3216 policy_surface->hide.notify = policy_surface_handle_hide;
3217 ds_tizen_policy_surface_add_hide_listener(policy_surface->policy_surface,
3218 &policy_surface->hide);
3220 policy_surface->set_parent_with_below.notify =
3221 policy_surface_handle_set_parent_with_below;
3222 ds_tizen_policy_surface_add_set_parent_with_below_listener(
3223 policy_surface->policy_surface, &policy_surface->set_parent_with_below);
3226 wl_list_init(&policy_surface->visibilities);
3227 wl_list_init(&policy_surface->positions);
3228 wl_list_init(&policy_surface->subsurface_watchers);
3230 wl_list_insert(&policy->policy_surfaces, &policy_surface->link);
3234 policy_handle_activate_below_by_univeral_id(struct wl_listener *listener, void *data)
3236 struct tinyds_policy *policy;
3238 policy = wl_container_of(listener, policy, activate_below_by_univeral_id);
3240 ds_inf("Policy(%p) activate_below_by_univeral_id", policy);
3246 policy_handle_lower_by_universal_id(struct wl_listener *listener, void *data)
3248 struct tinyds_policy *policy;
3250 policy = wl_container_of(listener, policy, lower_by_universal_id);
3252 ds_inf("Policy(%p) lower_by_universal_id", policy);
3258 policy_handle_set_transient_for(struct wl_listener *listener, void *data)
3260 struct tinyds_policy *policy;
3262 policy = wl_container_of(listener, policy, set_transient_for);
3264 ds_inf("Policy(%p) set_transient_for", policy);
3270 policy_handle_unset_transient_for(struct wl_listener *listener, void *data)
3272 struct tinyds_policy *policy;
3274 policy = wl_container_of(listener, policy, unset_transient_for);
3276 ds_inf("Policy(%p) unset_transient_for", policy);
3282 policy_handle_place_subsurface_below_parent(struct wl_listener *listener, void *data)
3284 struct tinyds_policy *policy;
3286 policy = wl_container_of(listener, policy, place_subsurface_below_parent);
3288 ds_inf("Policy(%p) place_subsurface_below_parent", policy);
3294 policy_handle_set_subsurface_stand_alone(struct wl_listener *listener, void *data)
3296 struct tinyds_policy *policy;
3298 policy = wl_container_of(listener, policy, set_subsurface_stand_alone);
3300 ds_inf("Policy(%p) set_subsurface_stand_alone", policy);
3306 policy_handle_set_background_state(struct wl_listener *listener, void *data)
3308 struct tinyds_policy *policy;
3310 policy = wl_container_of(listener, policy, set_background_state);
3312 ds_inf("Policy(%p) set_background_state", policy);
3318 policy_handle_unset_background_state(struct wl_listener *listener, void *data)
3320 struct tinyds_policy *policy;
3322 policy = wl_container_of(listener, policy, unset_background_state);
3324 ds_inf("Policy(%p) unset_background_state", policy);
3330 policy_handle_add_activate_above_by_universal_id(struct wl_listener *listener, void *data)
3332 struct tinyds_policy *policy;
3334 policy = wl_container_of(listener, policy, add_activate_above_by_universal_id);
3336 ds_inf("Policy(%p) add_activate_above_by_universal_id", policy);
3342 policy_handle_set_appid(struct wl_listener *listener, void *data)
3344 struct tinyds_policy *policy;
3346 policy = wl_container_of(listener, policy, set_appid);
3348 ds_inf("Policy(%p) set_appid", policy);
3354 policy_handle_set_transient_for_below(struct wl_listener *listener, void *data)
3356 struct tinyds_policy *policy;
3358 policy = wl_container_of(listener, policy, set_transient_for_below);
3360 ds_inf("Policy(%p) set_transient_for_below", policy);
3366 new_policy(struct tinyds_server *server)
3368 struct tinyds_policy *policy;
3370 policy = calloc(1, sizeof *policy);
3374 policy->policy = ds_tizen_policy_create(server->display);
3375 if (!policy->policy) {
3377 ds_err("Could not create ds_tizen_policy");
3381 policy->destroy.notify = policy_handle_destroy;
3382 ds_tizen_policy_add_destroy_listener(policy->policy, &policy->destroy);
3384 policy->new_surface.notify = policy_handle_new_surface;
3385 ds_tizen_policy_add_new_surface_listener(policy->policy, &policy->new_surface);
3387 policy->activate_below_by_univeral_id.notify =
3388 policy_handle_activate_below_by_univeral_id;
3389 ds_tizen_policy_add_activate_below_by_univeral_id_listener(policy->policy,
3390 &policy->activate_below_by_univeral_id);
3392 policy->lower_by_universal_id.notify = policy_handle_lower_by_universal_id;
3393 ds_tizen_policy_add_lower_by_universal_id_listener(policy->policy,
3394 &policy->lower_by_universal_id);
3396 policy->set_transient_for.notify = policy_handle_set_transient_for;
3397 ds_tizen_policy_add_set_transient_for_listener(policy->policy,
3398 &policy->set_transient_for);
3400 policy->unset_transient_for.notify = policy_handle_unset_transient_for;
3401 ds_tizen_policy_add_unset_transient_for_listener(policy->policy,
3402 &policy->unset_transient_for);
3404 policy->place_subsurface_below_parent.notify =
3405 policy_handle_place_subsurface_below_parent;
3406 ds_tizen_policy_add_place_subsurface_below_parent_listener(policy->policy,
3407 &policy->place_subsurface_below_parent);
3409 policy->set_subsurface_stand_alone.notify =
3410 policy_handle_set_subsurface_stand_alone;
3411 ds_tizen_policy_add_set_subsurface_stand_alone_listener(policy->policy,
3412 &policy->set_subsurface_stand_alone);
3414 policy->set_background_state.notify = policy_handle_set_background_state;
3415 ds_tizen_policy_add_set_background_state_listener(policy->policy,
3418 policy->unset_background_state.notify = policy_handle_unset_background_state;
3419 ds_tizen_policy_add_unset_background_state_listener(policy->policy,
3420 &policy->unset_background_state);
3422 policy->add_activate_above_by_universal_id.notify =
3423 policy_handle_add_activate_above_by_universal_id;
3424 ds_tizen_policy_add_activate_above_by_universal_id_listener(policy->policy,
3425 &policy->add_activate_above_by_universal_id);
3427 policy->set_appid.notify = policy_handle_set_appid;
3428 ds_tizen_policy_add_set_appid_listener(policy->policy, &policy->set_appid);
3430 policy->set_transient_for_below.notify =
3431 policy_handle_set_transient_for_below;
3432 ds_tizen_policy_add_set_transient_for_below_listener(policy->policy,
3433 &policy->set_transient_for_below);
3435 wl_list_init(&policy->policy_surfaces);
3437 server->policy = policy;
3439 ds_inf("Policy (%p) created", policy);