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"
45 #include "protocol-trace.h"
47 #define TINYDS_UNUSED __attribute__((unused))
48 struct tinyds_keyboard;
49 struct tinyds_pointer;
53 struct tinyds_server *server;
54 struct ds_output *ds_output;
55 struct ds_allocator *allocator;
56 #ifdef USE_TDM_BUFFER_QUEUE
57 struct tinyds_renderer renderer;
58 struct ds_tdm_buffer_queue *buffer_queue;
59 struct wl_listener buffer_queue_acquirable;
61 struct ds_swapchain *swapchain;
63 struct ds_buffer *front_buffer;
65 struct wl_listener output_destroy;
66 struct wl_listener output_frame;
70 struct wl_event_source *idle_commit;
75 struct ds_tdm_output_hwc *hwc;
76 struct ds_tdm_output_hwc_window *bg_hwc_window;
81 struct ds_tizen_dpms *ds_dpms;
82 struct tinyds_server *server;
84 struct wl_listener destroy;
85 struct wl_listener set_dpms;
86 struct wl_listener get_dpms;
91 struct ds_tizen_policy *policy;
93 struct wl_listener destroy;
94 struct wl_listener new_surface;
95 struct wl_listener activate_below_by_univeral_id;
96 struct wl_listener lower_by_universal_id;
97 struct wl_listener set_transient_for;
98 struct wl_listener unset_transient_for;
99 struct wl_listener place_subsurface_below_parent;
100 struct wl_listener set_subsurface_stand_alone;
101 struct wl_listener set_background_state;
102 struct wl_listener unset_background_state;
103 struct wl_listener add_activate_above_by_universal_id;
104 struct wl_listener set_appid;
105 struct wl_listener set_transient_for_below;
107 struct wl_list policy_surfaces;
110 struct tinyds_policy_surface
112 struct ds_tizen_policy_surface *policy_surface;
114 struct wl_listener destroy;
115 struct wl_listener new_visibility;
116 struct wl_listener new_position;
117 struct wl_listener activate;
118 struct wl_listener raise;
119 struct wl_listener lower;
120 struct wl_listener set_focus_skip;
121 struct wl_listener unset_focus_skip;
122 struct wl_listener set_role;
123 struct wl_listener set_window_type;
124 struct wl_listener set_conformant;
125 struct wl_listener unset_conformant;
126 struct wl_listener get_conformant;
127 struct wl_listener set_notification_level;
128 struct wl_listener set_window_screen_mode;
129 struct wl_listener get_subsurface;
130 struct wl_listener iconify;
131 struct wl_listener uniconify;
132 struct wl_listener add_aux_hint;
133 struct wl_listener change_aux_hint;
134 struct wl_listener delete_aux_hint;
135 struct wl_listener get_supported_aux_hints;
136 struct wl_listener set_floating_mode;
137 struct wl_listener unset_floating_mode;
138 struct wl_listener set_stack_mode;
139 struct wl_listener new_subsurface_watcher;
140 struct wl_listener set_parent;
141 struct wl_listener ack_conformant_region;
142 struct wl_listener set_video;
143 struct wl_listener show;
144 struct wl_listener hide;
145 struct wl_listener set_parent_with_below;
147 struct wl_list visibilities;
148 struct wl_list positions;
149 struct wl_list subsurface_watchers;
151 struct wl_list link; //tinyds_policy::policy_surfaces
154 struct tinyds_policy_visibility
156 struct ds_tizen_policy_visibility *visibility;
158 struct wl_listener destroy;
160 struct wl_list link; //tinyds_policy::visibilities
163 struct tinyds_policy_position
165 struct ds_tizen_policy_position *position;
167 struct wl_listener destroy;
168 struct wl_listener set;
170 struct wl_list link; //tinyds_policy::positions
173 struct tinyds_policy_subsurface_watcher
175 struct ds_tizen_policy_subsurface_watcher *subsurface_watcher;
177 struct wl_listener destroy;
179 struct wl_list link; //tinyds_policy::subsurface_watchers
184 struct ds_tbm_server *tbm_server;
186 struct wl_display *display;
188 struct ds_backend *backend;
189 struct ds_backend *input_backend;
190 struct ds_compositor *compositor;
191 struct ds_xdg_shell *xdg_shell;
192 struct ds_seat *seat;
194 double output_x, output_y;
195 struct ds_tizen_input_devicemgr *devicemgr;
196 struct ds_tizen_launch_effect *effect;
197 struct ds_tizen_launch_splash *splash;
199 struct tinyds_output *output;
200 struct tinyds_dpms *dpms;
201 struct tinyds_policy *policy;
203 struct wl_event_source *stdin_source;
205 struct wl_list views;
207 struct wl_listener new_output;
208 struct wl_listener new_input;
209 struct wl_listener new_xdg_surface;
210 struct wl_listener devicemgr_destroy;
211 struct wl_listener pointer_warp;
212 struct wl_listener effect_destroy;
213 struct wl_listener effect_type_set;
214 struct wl_listener effect_type_unset;
215 struct wl_listener new_splash;
216 struct wl_listener splash_owner;
218 struct wl_list keyboards;
219 struct wl_list pointers;
221 struct tinyds_text_input *text_input;
222 struct tinyds_input_method *input_method;
227 struct tinyds_server *server;
229 struct tinyds_texture *texture;
230 struct ds_xdg_surface *xdg_surface;
232 struct wl_listener xdg_surface_map;
233 struct wl_listener xdg_surface_unmap;
234 struct wl_listener xdg_surface_destroy;
235 struct wl_listener surface_commit;
236 struct wl_list link; // tinyds_server::views
238 struct ds_tdm_output_hwc_window *hwc_window;
247 struct tinyds_pointer
249 struct ds_input_device *dev;
250 struct tinyds_server *server;
252 struct tinyds_view *focused_view;
254 struct wl_listener destroy;
255 struct wl_listener motion; //relative
256 struct wl_listener button;
257 struct wl_listener frame;
258 struct wl_list link; //tinyds_server::pointers
261 struct tinyds_keyboard
263 struct ds_input_device *dev;
264 struct tinyds_server *server;
266 struct wl_listener destroy;
267 struct wl_listener key;
268 struct wl_list link; //tinyds_server::keyboards
273 struct ds_input_device *dev;
274 struct tinyds_server *server;
276 struct wl_listener destroy;
277 struct wl_listener down;
278 struct wl_listener up;
279 struct wl_listener motion;
282 struct tinyds_text_input {
283 struct ds_tizen_text_input *input;
284 struct ds_tizen_text_input_manager *text_input_mgr;
286 struct tinyds_server *server;
287 struct ds_surface *surface;
289 struct wl_list input_methods;
291 struct wl_listener mgr_destroy;
292 struct wl_listener new_text_input;
294 struct wl_listener destroy;
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 protocol_trace_enable(false);
431 protocol_trace_fini();
433 wl_display_destroy_clients(display);
434 wl_display_destroy(display);
440 view_populate_pid(struct tinyds_view *view)
443 struct wl_client *client = NULL;
444 struct ds_surface *surface;
446 surface = ds_xdg_surface_get_surface(view->xdg_surface);
450 client = wl_resource_get_client(ds_surface_get_wl_resource(surface));
454 wl_client_get_credentials(client, &pid, NULL, NULL);
456 ds_inf("view pid(%u)", pid);
459 view->effect_type = ds_tizen_launch_effect_get_effect_type(view->server->effect, pid);
460 ds_tizen_launch_effect_unset_effect_type(view->server->effect, pid);
461 ds_inf("view effect_type(%d)", view->effect_type);
465 view_handle_xdg_surface_map(struct wl_listener *listener,
466 void *data TINYDS_UNUSED)
468 struct tinyds_view *view;
469 struct ds_keyboard *keyboard;
470 struct tinyds_keyboard *kbd;
472 view = wl_container_of(listener, view, xdg_surface_map);
475 view_populate_pid(view);
477 wl_list_for_each(kbd, &view->server->keyboards, link) {
478 keyboard = ds_input_device_get_keyboard(kbd->dev);
479 if (keyboard != NULL) {
480 ds_seat_keyboard_notify_enter(view->server->seat,
481 ds_xdg_surface_get_surface(view->xdg_surface),
482 keyboard->keycodes, keyboard->num_keycodes,
483 &keyboard->modifiers);
490 view_handle_xdg_surface_unmap(struct wl_listener *listener,
491 void *data TINYDS_UNUSED)
493 struct tinyds_view *view;
495 view = wl_container_of(listener, view, xdg_surface_unmap);
496 view->mapped = false;
500 view_handle_xdg_surface_destroy(struct wl_listener *listener,
501 void *data TINYDS_UNUSED)
503 struct tinyds_view *view;
505 view = wl_container_of(listener, view, xdg_surface_destroy);
507 draw_server_with_damage(view->server);
509 ds_tdm_output_hwc_window_destroy(view->hwc_window);
511 wl_list_remove(&view->xdg_surface_destroy.link);
512 wl_list_remove(&view->xdg_surface_map.link);
513 wl_list_remove(&view->xdg_surface_unmap.link);
514 wl_list_remove(&view->surface_commit.link);
515 wl_list_remove(&view->link);
520 view_handle_surface_commit(struct wl_listener *listener,
521 void *data TINYDS_UNUSED)
523 struct tinyds_view *view;
525 view = wl_container_of(listener, view, surface_commit);
526 draw_server_with_damage(view->server);
530 server_new_xdg_surface(struct wl_listener *listener, void *data)
532 static unsigned int seedx = 1;
533 static unsigned int seedy = 43210;
534 struct tinyds_server *server;
535 struct tinyds_view *view;
536 struct ds_xdg_surface *xdg_surface;
538 server = wl_container_of(listener, server, new_xdg_surface);
541 ds_inf("New xdg_surface(%p)", (void *)xdg_surface);
543 view = calloc(1, sizeof *view);
546 view->server = server;
547 view->xdg_surface = xdg_surface;
549 view->xdg_surface_map.notify = view_handle_xdg_surface_map;
550 ds_xdg_surface_add_map_listener(xdg_surface,
551 &view->xdg_surface_map);
553 view->xdg_surface_unmap.notify = view_handle_xdg_surface_unmap;
554 ds_xdg_surface_add_unmap_listener(xdg_surface,
555 &view->xdg_surface_unmap);
557 view->xdg_surface_destroy.notify = view_handle_xdg_surface_destroy;
558 ds_xdg_surface_add_destroy_listener(xdg_surface,
559 &view->xdg_surface_destroy);
561 view->surface_commit.notify = view_handle_surface_commit;
562 ds_surface_add_commit_listener(
563 ds_xdg_surface_get_surface(xdg_surface),
564 &view->surface_commit);
566 view->x = rand_r(&seedx) % 1000;
567 view->y = rand_r(&seedy) % 500;
569 view->hwc_window = ds_tdm_output_hwc_window_create(server->output->hwc);
570 assert(view->hwc_window);
572 wl_list_insert(server->views.prev, &view->link);
575 view->effect_type = -1;
577 ds_inf("view at (%d, %d)", view->x, view->y);
581 backend_handle_new_output(struct wl_listener *listener, void *data)
583 struct tinyds_server *server;
584 struct tinyds_output *output;
585 struct ds_output *ds_output;
586 const struct ds_output_mode *mode;
587 struct ds_tdm_box src_box;
589 server = wl_container_of(listener, server, new_output);
592 ds_inf("New output(%p)", ds_output);
597 mode = ds_output_get_preferred_mode(ds_output);
598 ds_output_set_mode(ds_output, mode);
600 output = calloc(1, sizeof *output);
604 output->server = server;
605 output->ds_output = ds_output;
606 output->width = mode->width;
607 output->height = mode->height;
608 output->damaged = true;
609 output->committable = true;
611 output_hwc_init(output);
613 #ifdef USE_TDM_BUFFER_QUEUE
614 output_buffer_queue_init(output);
615 output_renderer_init(output);
617 output_swapchain_init(output, mode->width, mode->height,
618 DRM_FORMAT_XRGB8888);
621 output->bg_hwc_window = ds_tdm_output_hwc_window_create(output->hwc);
622 assert(output->bg_hwc_window);
626 src_box.width = output->width;
627 src_box.height = output->height;
629 ds_tdm_output_hwc_window_set_src_box(output->bg_hwc_window, &src_box);
630 ds_tdm_output_hwc_window_set_position(output->bg_hwc_window, 0, 0);
631 ds_tdm_output_hwc_window_set_dest_size(output->bg_hwc_window, output->width, output->height);
632 ds_tdm_output_hwc_window_set_transform(output->bg_hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
634 output->output_destroy.notify = output_handle_destroy;
635 ds_output_add_destroy_listener(ds_output, &output->output_destroy);
637 output->output_frame.notify = output_handle_frame;
638 ds_output_add_frame_listener(ds_output, &output->output_frame);
640 ds_tizen_input_devicemgr_set_output_width_height(server->devicemgr, (uint32_t)output->width, (uint32_t)output->height);
642 server->output = output;
644 output_schedule_commit(output);
648 add_new_dpms(struct tinyds_server *server)
650 struct tinyds_dpms *dpms;
652 dpms = calloc(1, sizeof *dpms);
656 dpms->ds_dpms = ds_tizen_dpms_create(server->display);
657 if (!dpms->ds_dpms) {
659 ds_err("Could not create ds_tizen_dpms");
663 dpms->destroy.notify = dpms_handle_destroy;
664 ds_tizen_dpms_add_destroy_listener(dpms->ds_dpms, &dpms->destroy);
666 dpms->set_dpms.notify = dpms_handle_set_dpms;
667 ds_tizen_dpms_add_set_dpms_listener(dpms->ds_dpms, &dpms->set_dpms);
669 dpms->get_dpms.notify = dpms_handle_get_dpms;
670 ds_tizen_dpms_add_get_dpms_listener(dpms->ds_dpms, &dpms->get_dpms);
674 ds_inf("Dpms (%p) added", dpms);
680 backend_handle_new_input(struct wl_listener *listener, void *data)
682 struct tinyds_server *server;
683 struct ds_input_device *dev = data;
684 enum ds_input_device_type dev_type;
686 server = wl_container_of(listener, server, new_input);
688 dev_type = ds_input_device_get_type(dev);
691 case DS_INPUT_DEVICE_KEYBOARD:
692 server_add_keyboard(server, dev);
693 server->seat_caps |= WL_SEAT_CAPABILITY_KEYBOARD;
695 case DS_INPUT_DEVICE_TOUCH:
696 server_add_touch(server, dev);
697 server->seat_caps |= WL_SEAT_CAPABILITY_TOUCH;
699 case DS_INPUT_DEVICE_POINTER:
700 server_add_pointer(server, dev);
701 server->seat_caps |= WL_SEAT_CAPABILITY_POINTER;
704 ds_err("Unknown type(%d) of ds_input_device", dev_type);
708 ds_seat_set_capabilities(server->seat, server->seat_caps);
712 devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode)
714 struct ds_tizen_input_devicemgr_keymap_data *data;
716 data = calloc(1, sizeof *data);
718 ds_err("Failed to alloc memory");
722 data->name = strdup(name);
723 data->keycode = keycode;
725 wl_list_insert(list, &data->link);
729 devicemgr_cleanup_keymap_list(struct wl_list *list)
731 struct ds_tizen_input_devicemgr_keymap_data *data, *tmp;
733 wl_list_for_each_safe(data, tmp, list, link) {
734 wl_list_remove(&data->link);
741 devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr)
743 struct wl_list keymap_list;
746 wl_list_init(&keymap_list);
748 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeRaise", 455);
749 devicemgr_add_keymap_data(&keymap_list, "XF86VolumeLower", 456);
750 devicemgr_add_keymap_data(&keymap_list, "XF86LightOn", 457);
751 devicemgr_add_keymap_data(&keymap_list, "XF86LightOff", 458);
753 res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list);
755 ds_inf("Failed to set keymap");
757 devicemgr_cleanup_keymap_list(&keymap_list);
761 devicemgr_handle_pointer_warp(struct wl_listener *listener, void *data)
763 struct tinyds_server *server;
764 struct tinyds_pointer *pointer;
765 struct ds_tizen_input_devicemgr_event_pointer_warp *event = data;
766 double sx = 0.f, sy = 0.f;
767 struct tinyds_view *view = NULL;
769 server = wl_container_of(listener, server, pointer_warp);
771 ds_inf("Pointer warp: surface(%p) x(%.2f) y(%.2f)", event->surface,
774 wl_list_for_each(pointer, &server->pointers, link){
775 if (!pointer->focused_view) continue;
776 view = pointer->focused_view;
780 if (event->surface != ds_xdg_surface_get_surface(view->xdg_surface)) {
781 ds_inf("Pointer is not on the requested surface");
785 server->output_x = view->x + (event->x * server->output->width);
786 server->output_y = view->y + (event->y * server->output->height);
788 server_view_at(server, server->output_x, server->output_y, &sx, &sy);
790 ds_inf("notify motion: sx:%.2f sy:%.2f, output_x:%.1f, output_y:%.1f",
791 sx, sy, server->output_x, server->output_y);
793 ds_seat_pointer_notify_motion(server->seat,
794 event->time_msec, sx, sy);
798 devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
800 struct tinyds_server *server =
801 wl_container_of(listener, server, devicemgr_destroy);
803 wl_list_remove(&server->devicemgr_destroy.link);
804 wl_list_remove(&server->pointer_warp.link);
806 server->devicemgr = NULL;
810 launch_effect_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
812 struct tinyds_server *server =
813 wl_container_of(listener, server, effect_destroy);
815 wl_list_remove(&server->effect_destroy.link);
816 wl_list_remove(&server->effect_type_set.link);
817 wl_list_remove(&server->effect_type_unset.link);
818 wl_list_remove(&server->new_splash.link);
820 server->effect = NULL;
824 launch_effect_handle_type_set(struct wl_listener *listener, void *data)
826 struct tinyds_server *server;
827 struct ds_tizen_launch_effect_event_type_set *event = data;
828 struct tinyds_view *view = NULL;
829 bool existing = false;
831 server = wl_container_of(listener, server, effect_type_set);
833 ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch");
835 wl_list_for_each(view, &server->views, link) {
836 if (view->pid == event->pid) {
837 view->effect_type = event->effect_type;
838 ds_inf("Launch effect. existing pid");
843 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
845 ds_tizen_launch_effect_set_effect_type(server->effect, event->pid, event->effect_type);
850 launch_effect_handle_type_unset(struct wl_listener *listener, void *data)
852 struct tinyds_server *server;
853 struct ds_tizen_launch_effect_event_type_unset *event = data;
854 struct tinyds_view *view = NULL;
856 server = wl_container_of(listener, server, effect_type_unset);
858 ds_inf("Launch effect. type_unset: pid(%u)", event->pid);
860 wl_list_for_each(view, &server->views, link) {
861 if (view->pid == event->pid) {
862 view->effect_type = -1;
863 ds_inf("Launch effect. pid found");
866 ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid);
870 launch_splash_handle_owner(struct wl_listener *listener, void *data)
872 struct tinyds_server *server;
873 struct ds_tizen_launch_splash_event_owner *event = data;
874 struct tinyds_view *view = NULL;
876 server = wl_container_of(listener, server, splash_owner);
878 ds_inf("Splash owner. pid(%u)", event->pid);
880 wl_list_for_each(view, &server->views, link) {
881 if (view->pid == event->pid) {
882 if (event->pid == ds_tizen_launch_splash_get_pid(server->splash))
885 ds_tizen_launch_splash_set_pid(server->splash, event->pid);
892 launch_effect_handle_new_splash(struct wl_listener *listener, void *data)
894 struct tinyds_server *server;
895 struct ds_tizen_launch_splash *splash = data;
896 struct tinyds_view *view = NULL;
898 server = wl_container_of(listener, server, new_splash);
900 ds_inf("Launch new splash. splash(%p)", splash);
903 server->splash = splash;
905 // new view for "Launchscreen"
906 view = calloc(1, sizeof *view);
908 wl_list_insert(server->views.prev, &view->link);
909 view->pid = ds_tizen_launch_splash_get_pid(splash);
911 server->splash_owner.notify = launch_splash_handle_owner;
912 ds_tizen_launch_splash_add_owner_listener(server->splash,
913 &server->splash_owner);
917 init_server(struct tinyds_server *server, struct wl_display *display)
919 server->display = display;
921 wl_list_init(&server->views);
923 if (wl_display_init_shm(display) != 0)
926 server->backend = ds_tdm_backend_create(display);
927 if (!server->backend)
930 server->input_backend = ds_libinput_backend_create(display);
931 if (!server->input_backend) {
932 ds_backend_destroy(server->backend);
936 server->new_output.notify = backend_handle_new_output;
937 ds_backend_add_new_output_listener(server->backend,
938 &server->new_output);
940 wl_list_init(&server->keyboards);
941 wl_list_init(&server->pointers);
942 server->new_input.notify = backend_handle_new_input;
943 ds_backend_add_new_input_listener(server->input_backend, &server->new_input);
945 server->compositor = ds_compositor_create(display);
946 if (!server->compositor)
949 server->tbm_server = ds_tbm_server_create(display);
950 if (!server->tbm_server)
953 server->xdg_shell = ds_xdg_shell_create(display);
954 if (!server->xdg_shell)
957 server->new_xdg_surface.notify = server_new_xdg_surface;
958 ds_xdg_shell_add_new_surface_listener(server->xdg_shell,
959 &server->new_xdg_surface);
961 if (!add_new_dpms(server))
964 if (!new_policy(server))
967 server->seat = ds_seat_create(display, "seat0" /* arbitrary name */);
970 server->seat_caps = 0;
972 server->devicemgr = ds_tizen_input_devicemgr_create(
973 server->input_backend, server->seat);
974 if (!server->devicemgr) {
975 ds_err("Could not create ds_tizen_input_devicemgr");
979 devicemgr_set_keymap(server->devicemgr);
981 server->devicemgr_destroy.notify = devicemgr_handle_destroy;
982 ds_tizen_input_devicemgr_add_destroy_listener(server->devicemgr,
983 &server->devicemgr_destroy);
985 server->pointer_warp.notify = devicemgr_handle_pointer_warp;
986 ds_tizen_input_devicemgr_add_pointer_warp_listener(server->devicemgr,
987 &server->pointer_warp);
989 server->effect = ds_tizen_launch_effect_create(display);
990 if (!server->effect) {
994 server->effect_destroy.notify = launch_effect_handle_destroy;
995 ds_tizen_launch_effect_add_destroy_listener(server->effect,
996 &server->effect_destroy);
998 server->effect_type_set.notify = launch_effect_handle_type_set;
999 ds_tizen_launch_effect_add_type_set_listener(server->effect,
1000 &server->effect_type_set);
1002 server->effect_type_unset.notify = launch_effect_handle_type_unset;
1003 ds_tizen_launch_effect_add_type_unset_listener(server->effect,
1004 &server->effect_type_unset);
1006 server->new_splash.notify = launch_effect_handle_new_splash;
1007 ds_tizen_launch_effect_add_new_splash_listener(server->effect,
1008 &server->new_splash);
1010 if (!add_new_text_input(server))
1013 if (!add_new_input_method(server))
1016 if (protocol_trace_init(display))
1017 protocol_trace_enable(true);
1022 ds_backend_destroy(server->backend);
1023 ds_backend_destroy(server->input_backend);
1029 output_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED)
1031 struct tinyds_output *output =
1032 wl_container_of(listener, output, output_destroy);
1034 if (output->bg_hwc_window)
1035 ds_tdm_output_hwc_window_destroy(output->bg_hwc_window);
1037 wl_list_remove(&output->output_destroy.link);
1038 wl_list_remove(&output->output_frame.link);
1040 if (output->front_buffer)
1041 ds_buffer_unlock(output->front_buffer);
1043 #ifdef USE_TDM_BUFFER_QUEUE
1044 fini_renderer(&output->renderer);
1046 if (output->swapchain)
1047 ds_swapchain_destroy(output->swapchain);
1049 if (output->allocator)
1050 ds_allocator_destroy(output->allocator);
1053 wl_display_terminate(output->server->display);
1055 output->server->output = NULL;
1061 output_commit(struct tinyds_output *output)
1063 uint32_t num_changed = 0;
1064 uint32_t num_windows = 0, current_num_windows = 0;
1065 struct ds_tdm_output_hwc_window **composited_hwc_windows = NULL;
1066 struct ds_tdm_output_hwc_window **changed_hwc_windows = NULL;
1067 enum ds_tdm_output_hwc_window_composition composition;
1068 struct tinyds_view *view;
1070 bool need_target = false;
1071 bool fully_obscured = false;
1072 struct ds_buffer *ds_buffer;
1073 struct ds_tdm_box src_box;
1076 if (!output->committable)
1079 if (!output->damaged && !output->target_updated)
1082 wl_list_for_each_reverse(view, &output->server->views, link) {
1083 if (!view->hwc_window)
1086 ds_buffer = ds_surface_get_buffer(
1087 ds_xdg_surface_get_surface(view->xdg_surface));
1096 ds_buffer_get_size(ds_buffer, &w, &h);
1098 if ((output->width <= w) && (output->height <= h))
1099 fully_obscured = true;
1102 if (fully_obscured) {
1103 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
1104 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
1106 ds_tdm_output_hwc_window_set_composition(output->bg_hwc_window,
1107 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT);
1113 composited_hwc_windows = calloc(num_windows, sizeof *composited_hwc_windows);
1114 if (!composited_hwc_windows)
1117 wl_list_for_each_reverse(view, &output->server->views, link) {
1118 if (!view->hwc_window)
1121 ds_buffer = ds_surface_get_buffer(
1122 ds_xdg_surface_get_surface(view->xdg_surface));
1126 ds_tdm_output_hwc_window_set_buffer(view->hwc_window, ds_buffer);
1128 ds_buffer_get_size(ds_buffer, &w, &h);
1135 ds_tdm_output_hwc_window_set_src_box(view->hwc_window, &src_box);
1136 ds_tdm_output_hwc_window_set_position(view->hwc_window, view->x, view->y);
1137 ds_tdm_output_hwc_window_set_dest_size(view->hwc_window, w, h);
1138 ds_tdm_output_hwc_window_set_transform(view->hwc_window, WL_OUTPUT_TRANSFORM_NORMAL);
1141 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1142 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE);
1144 composited_hwc_windows[current_num_windows] = view->hwc_window;
1145 current_num_windows++;
1147 ds_tdm_output_hwc_window_set_composition(view->hwc_window,
1148 DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_NONE);
1152 if (!fully_obscured) {
1153 composited_hwc_windows[current_num_windows] = output->bg_hwc_window;
1154 current_num_windows++;
1158 if (!ds_tdm_output_hwc_validate(output->hwc, composited_hwc_windows,
1159 num_windows, &num_changed)) {
1160 free(composited_hwc_windows);
1161 ds_err("Could not hwc validate");
1165 if (composited_hwc_windows)
1166 free(composited_hwc_windows);
1168 if (num_changed > 0) {
1169 changed_hwc_windows = calloc(num_windows, sizeof *changed_hwc_windows);
1170 if (!changed_hwc_windows)
1173 if (!ds_tdm_output_hwc_get_changed_composition(output->hwc, &num_changed,
1174 changed_hwc_windows)) {
1175 free(changed_hwc_windows);
1176 ds_err("Could not get chaged composition");
1180 for (i = 0; i < num_changed; i++) {
1181 composition = ds_tdm_output_hwc_window_get_composition(changed_hwc_windows[i]);
1182 if (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT) {
1189 if (changed_hwc_windows)
1190 free(changed_hwc_windows);
1192 if (need_target && output->damaged)
1193 draw_output(output);
1195 #ifdef USE_TDM_BUFFER_QUEUE
1196 struct ds_buffer *buffer;
1198 buffer = ds_tdm_buffer_queue_acquire(output->buffer_queue);
1200 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, buffer)) {
1201 ds_err("Could not set hwc client target buffer");
1205 output_swap_buffer(output, buffer);
1209 if (!ds_tdm_output_hwc_accept_validation(output->hwc)) {
1210 ds_err("Could not hwc accept validateion");
1214 ds_output_commit(output->ds_output);
1216 output->committable = false;
1217 output->damaged = false;
1218 output->target_updated = false;
1220 wl_list_for_each(view, &output->server->views, link) {
1221 enum ds_tdm_output_hwc_window_composition composition;
1226 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1227 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1228 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1229 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1230 view_send_frame_done(view);
1233 ds_dbg("output:%p commit", output);
1237 output_handle_frame(struct wl_listener *listener, void *data TINYDS_UNUSED)
1239 struct tinyds_output *output =
1240 wl_container_of(listener, output, output_frame);
1242 ds_dbg("output:%p handle frame", output);
1244 output->committable = true;
1246 output_commit(output);
1250 draw_server_with_damage(struct tinyds_server *server)
1252 server->output->damaged = true;
1253 output_schedule_commit(server->output);
1257 output_hwc_init(struct tinyds_output *output)
1259 struct ds_tdm_output *tdm_output;
1261 tdm_output = ds_tdm_output_from_output(output->ds_output);
1264 output->hwc = ds_tdm_output_get_hwc(tdm_output);
1265 assert(output->hwc);
1267 ds_tdm_output_hwc_set_enabled(output->hwc, true);
1270 #ifdef USE_TDM_BUFFER_QUEUE
1272 output_handle_buffer_queue_acquirable(struct wl_listener *listener,
1273 void *data TINYDS_UNUSED)
1275 struct tinyds_output *output;
1277 output = wl_container_of(listener, output, buffer_queue_acquirable);
1279 output->target_updated = true;
1280 output_schedule_commit(output);
1284 output_buffer_queue_init(struct tinyds_output *output)
1286 struct ds_tdm_output *tdm_output;
1288 tdm_output = ds_tdm_output_from_output(output->ds_output);
1291 output->buffer_queue = ds_tdm_output_get_buffer_queue(tdm_output);
1292 assert(output->buffer_queue);
1294 output->buffer_queue_acquirable.notify =
1295 output_handle_buffer_queue_acquirable;
1296 ds_tdm_buffer_queue_add_acquirable_listener(output->buffer_queue,
1297 &output->buffer_queue_acquirable);
1301 output_renderer_init(struct tinyds_output *output)
1303 init_renderer(&output->renderer);
1305 renderer_set_surface_queue(&output->renderer,
1306 ds_tdm_buffer_queue_get_native_queue(output->buffer_queue));
1308 renderer_set_bg_color(&output->renderer, 80, 80, 80);
1312 output_draw_with_renderer(struct tinyds_output *output)
1314 struct tinyds_view *view;
1316 ds_dbg(">> BEGIN UPDATE TEXTURES");
1318 wl_list_for_each(view, &output->server->views, link) {
1319 struct ds_buffer *ds_buffer;
1320 struct ds_tbm_client_buffer *tbm_buffer;
1321 tbm_surface_h surface;
1322 enum ds_tdm_output_hwc_window_composition composition;
1327 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1328 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1329 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1330 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1333 ds_buffer = ds_surface_get_buffer(
1334 ds_xdg_surface_get_surface(view->xdg_surface));
1338 tbm_buffer = ds_tbm_client_buffer_from_buffer(ds_buffer);
1342 surface = ds_tbm_client_buffer_get_tbm_surface(tbm_buffer);
1346 renderer_add_texture(&output->renderer, surface, view->x, view->y);
1348 view_send_frame_done(view);
1351 ds_dbg("<< END UPDATE TEXTURES");
1353 renderer_draw(&output->renderer);
1357 output_swapchain_init(struct tinyds_output *output,
1358 int width, int height, uint32_t format)
1361 output->allocator = ds_tbm_allocator_create();
1362 assert(output->allocator);
1364 output->swapchain = ds_swapchain_create(output->allocator,
1365 width, height, format);
1366 assert(output->swapchain);
1370 output_draw_with_swapchain(struct tinyds_output *output)
1372 struct tinyds_view *view;
1373 struct ds_buffer *output_buffer;
1374 pixman_image_t *output_image;
1375 enum ds_tdm_output_hwc_window_composition composition;
1377 output_buffer = ds_swapchain_acquire(output->swapchain, NULL);
1381 output_image = pixman_image_from_buffer(output_buffer,
1382 DS_BUFFER_DATA_PTR_ACCESS_WRITE);
1383 if (!output_image) {
1384 ds_buffer_unlock(output_buffer);
1388 pixman_image_fill_color(output_image, 80, 80, 80);
1390 wl_list_for_each(view, &output->server->views, link) {
1394 composition = ds_tdm_output_hwc_window_get_composition(view->hwc_window);
1395 if ((composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_DEVICE) ||
1396 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_VIDEO) ||
1397 (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CURSOR))
1400 draw_view(view, output_image);
1402 pixman_image_unref(output_image);
1404 if (!ds_tdm_output_hwc_set_client_target_buffer(output->hwc, output_buffer)) {
1405 ds_err("Could not set hwc client target buffer");
1406 ds_buffer_unlock(output_buffer);
1410 output_swap_buffer(output, output_buffer);
1414 draw_view(struct tinyds_view *view, pixman_image_t *dst_image)
1416 struct ds_buffer *buffer;
1417 pixman_image_t *src_image;
1419 buffer = ds_surface_get_buffer(
1420 ds_xdg_surface_get_surface(view->xdg_surface));
1424 src_image = pixman_image_from_buffer(buffer,
1425 DS_BUFFER_DATA_PTR_ACCESS_READ);
1426 pixman_image_composite32(PIXMAN_OP_OVER,
1432 pixman_image_get_width(src_image),
1433 pixman_image_get_height(src_image));
1434 pixman_image_unref(src_image);
1436 view_send_frame_done(view);
1441 draw_output(struct tinyds_output *output)
1443 #ifdef USE_TDM_BUFFER_QUEUE
1444 output_draw_with_renderer(output);
1446 output_draw_with_swapchain(output);
1449 ds_dbg("output:%p draw", output);
1453 output_swap_buffer(struct tinyds_output *output, struct ds_buffer *buffer)
1455 ds_output_attach_buffer(output->ds_output, buffer);
1457 if (output->front_buffer)
1458 ds_buffer_unlock(output->front_buffer);
1459 output->front_buffer = buffer;
1463 view_send_frame_done(struct tinyds_view *view)
1465 struct timespec now;
1466 clock_gettime(CLOCK_MONOTONIC, &now);
1467 ds_surface_send_frame_done(ds_xdg_surface_get_surface(view->xdg_surface),
1472 server_dispatch_stdin(int fd, uint32_t mask, void *data)
1474 struct tinyds_server *server = data;
1476 wl_display_terminate(server->display);
1482 dpms_handle_destroy(struct wl_listener *listener, void *data)
1484 struct tinyds_dpms *dpms;
1486 dpms = wl_container_of(listener, dpms, destroy);
1488 ds_inf("Dpms(%p) destroyed", dpms);
1490 wl_list_remove(&dpms->destroy.link);
1491 wl_list_remove(&dpms->set_dpms.link);
1492 wl_list_remove(&dpms->get_dpms.link);
1498 dpms_handle_set_dpms(struct wl_listener *listener, void *data)
1500 struct tinyds_dpms *dpms;
1501 struct ds_tizen_dpms_event *event = data;
1503 dpms = wl_container_of(listener, dpms, set_dpms);
1505 ds_inf("Dpms(%p) set dpms : %d", dpms, event->mode);
1508 //set dpms mode to output
1509 ds_tizen_dpms_send_set_result(dpms->ds_dpms, event->mode,
1510 DS_TIZEN_DPMS_ERROR_NONE);
1514 dpms_handle_get_dpms(struct wl_listener *listener, void *data)
1516 struct tinyds_dpms *dpms;
1518 dpms = wl_container_of(listener, dpms, get_dpms);
1520 ds_inf("Dpms(%p) get dpms", dpms);
1523 //get dpms mode from output
1524 ds_tizen_dpms_send_get_result(dpms->ds_dpms, DS_TIZEN_DPMS_MODE_ON,
1525 DS_TIZEN_DPMS_ERROR_NONE);
1529 keyboard_handle_device_destroy(struct wl_listener *listener, void *data)
1531 struct tinyds_keyboard *kbd;
1533 kbd = wl_container_of(listener, kbd, destroy);
1535 ds_inf("Keyboard(%p) destroyed", kbd);
1537 wl_list_remove(&kbd->destroy.link);
1538 wl_list_remove(&kbd->key.link);
1539 wl_list_remove(&kbd->link);
1545 server_handle_keybinding(struct tinyds_server *server, xkb_keysym_t sym)
1548 case XKB_KEY_BackSpace:
1549 wl_display_terminate(server->display);
1559 keyboard_handle_key(struct wl_listener *listener, void *data)
1561 struct tinyds_keyboard *kbd;
1562 struct ds_event_keyboard_key *event = data;
1563 struct ds_keyboard *ds_keyboard;
1564 struct xkb_state *xkb_state;
1565 const xkb_keysym_t *syms;
1567 bool handled = false;
1569 kbd = wl_container_of(listener, kbd, key);
1571 ds_inf("Keyboard(%p) event key: keycode(%d), state(%d), time_msec(%d), "
1572 "update_state(%d)", kbd->dev,
1573 event->keycode, event->state, event->time_msec,
1574 event->update_state);
1576 ds_keyboard = ds_input_device_get_keyboard(kbd->dev);
1578 if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
1579 xkb_state = ds_keyboard_get_xkb_state(ds_keyboard);
1581 nsyms = xkb_state_key_get_syms(xkb_state, event->keycode + 8,
1583 for (int i = 0; i < nsyms; i++) {
1584 handled = server_handle_keybinding(kbd->server, syms[i]);
1590 ds_seat_keyboard_notify_key(kbd->server->seat, event->time_msec,
1591 event->keycode, event->state);
1596 server_add_keyboard(struct tinyds_server *server, struct ds_input_device *dev)
1598 struct tinyds_keyboard *kbd;
1599 struct xkb_context *context;
1600 struct xkb_keymap *keymap;
1602 kbd = calloc(1, sizeof *kbd);
1606 kbd->server = server;
1608 context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
1612 keymap = xkb_keymap_new_from_names(context, NULL,
1613 XKB_KEYMAP_COMPILE_NO_FLAGS);
1616 ds_err("Failed to compile keymap");
1617 xkb_context_unref(context);
1621 ds_keyboard_set_keymap(ds_input_device_get_keyboard(dev), keymap);
1623 xkb_keymap_unref(keymap);
1624 xkb_context_unref(context);
1626 kbd->destroy.notify = keyboard_handle_device_destroy;
1627 ds_input_device_add_destroy_listener(dev, &kbd->destroy);
1629 kbd->key.notify = keyboard_handle_key;
1630 ds_keyboard_add_key_listener(ds_input_device_get_keyboard(dev), &kbd->key);
1632 wl_list_insert(&server->keyboards, &kbd->link);
1634 ds_inf("Keyboard(%p) added", kbd);
1642 static struct tinyds_view *
1643 server_view_at(struct tinyds_server *server, double lx, double ly,
1644 double *sx, double *sy)
1646 struct tinyds_view *view;
1647 struct ds_surface *surface;
1648 struct ds_buffer *buffer;
1649 int x, y, w = 0, h = 0;
1651 wl_list_for_each(view, &server->views, link) {
1652 surface = ds_xdg_surface_get_surface(view->xdg_surface);
1653 buffer = ds_surface_get_buffer(surface);
1654 ds_buffer_get_size(buffer, &w, &h);
1659 if (lx >= x && lx <= x + w && ly >= y && ly <= y + h) {
1671 touch_handle_device_destroy(struct wl_listener *listener, void *data)
1673 struct tinyds_touch *touch;
1675 touch = wl_container_of(listener, touch, destroy);
1677 ds_inf("Touch(%p) destroyed", touch);
1679 wl_list_remove(&touch->destroy.link);
1680 wl_list_remove(&touch->down.link);
1681 wl_list_remove(&touch->up.link);
1682 wl_list_remove(&touch->motion.link);
1688 touch_handle_down(struct wl_listener *listener, void *data)
1690 struct ds_event_touch_down *event = data;
1691 struct tinyds_touch *touch;
1692 struct tinyds_view *view;
1693 struct tinyds_server *server;
1694 double sx = 0.f, sy = 0.f;
1696 touch = wl_container_of(listener, touch, down);
1698 server = touch->server;
1699 server->output_x = event->x * server->output->width;
1700 server->output_y = event->y * server->output->height;
1702 ds_inf("Touch(%p) event down: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1703 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1705 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1708 ds_seat_touch_notify_down(touch->server->seat, ds_xdg_surface_get_surface(view->xdg_surface),
1709 event->time_msec, event->id, sx, sy);
1714 touch_handle_up(struct wl_listener *listener, void *data)
1716 struct ds_event_touch_up *event = data;
1717 struct tinyds_touch *touch;
1719 touch = wl_container_of(listener, touch, up);
1721 ds_inf("Touch(%p) event up: id(%d) time_msec(%d)",
1722 touch->dev, event->id, event->time_msec);
1724 ds_seat_touch_notify_up(touch->server->seat, event->time_msec, event->id);
1728 touch_handle_motion(struct wl_listener *listener, void *data)
1730 struct ds_event_touch_motion *event = data;
1731 struct tinyds_touch *touch;
1732 struct tinyds_view *view;
1733 struct tinyds_server *server;
1734 double sx = 0.f, sy = 0.f;
1736 touch = wl_container_of(listener, touch, motion);
1738 server = touch->server;
1739 server->output_x = event->x * server->output->width;
1740 server->output_y = event->y * server->output->height;
1742 ds_inf("Touch(%p) event motion: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f",
1743 touch->dev, event->id, event->x, event->y, server->output_x, server->output_y);
1745 view = server_view_at(server, server->output_x, server->output_y, &sx, &sy);
1748 ds_seat_touch_notify_motion(server->seat, event->time_msec,
1754 server_add_touch(struct tinyds_server *server, struct ds_input_device *dev)
1756 struct tinyds_touch *touch;
1758 touch = calloc(1, sizeof *touch);
1762 touch->server = server;
1764 touch->destroy.notify = touch_handle_device_destroy;
1765 ds_input_device_add_destroy_listener(dev, &touch->destroy);
1767 touch->down.notify = touch_handle_down;
1768 ds_touch_add_down_listener(ds_input_device_get_touch(dev), &touch->down);
1770 touch->up.notify = touch_handle_up;
1771 ds_touch_add_up_listener(ds_input_device_get_touch(dev), &touch->up);
1773 touch->motion.notify = touch_handle_motion;
1774 ds_touch_add_motion_listener(ds_input_device_get_touch(dev), &touch->motion);
1776 ds_inf("Touch(%p) added", touch);
1780 pointer_handle_device_destroy(struct wl_listener *listener, void *data)
1782 struct tinyds_pointer *pointer;
1784 pointer = wl_container_of(listener, pointer, destroy);
1786 ds_inf("Pointer(%p) destroyed", pointer);
1788 wl_list_remove(&pointer->destroy.link);
1789 wl_list_remove(&pointer->motion.link);
1790 wl_list_remove(&pointer->button.link);
1791 wl_list_remove(&pointer->frame.link);
1792 wl_list_remove(&pointer->link);
1798 pointer_handle_motion(struct wl_listener *listener, void *data)
1800 struct tinyds_pointer *pointer;
1801 struct ds_event_pointer_motion *event = data;
1802 struct tinyds_view *view;
1803 struct tinyds_server *server;
1807 pointer = wl_container_of(listener, pointer, motion);
1809 server = pointer->server;
1810 if (server->output) {
1811 ow = server->output->width;
1812 oh = server->output->height;
1815 if (server->output_x + event->delta_x >= ow)
1816 server->output_x = ow;
1817 else if(server->output_x + event->delta_x <= 0.f)
1818 server->output_x = 0.f;
1820 server->output_x = server->output_x + event->delta_x ;
1821 if (server->output_y + event->delta_y >= oh)
1822 server->output_y = oh;
1823 else if(server->output_y + event->delta_y <= 0.f)
1824 server->output_y = 0.f;
1826 server->output_y = server->output_y + event->delta_y ;
1828 ds_inf("Pointer(%p) motion: (delta_x %.1f delta_y %.1f) output_x %.1f output_y %.1f",
1829 pointer, event->delta_x, event->delta_y, server->output_x, server->output_y);
1831 view = server_view_at(pointer->server, server->output_x, server->output_y, &sx, &sy);
1833 if (pointer->focused_view != view) {
1834 if (pointer->focused_view) {
1835 ds_inf("Clear pointer focus from view(%p)", pointer->focused_view);
1836 ds_seat_pointer_notify_clear_focus(pointer->server->seat);
1837 pointer->focused_view = NULL;
1841 ds_inf("Set pointer focus to view(%p)", view);
1842 ds_seat_pointer_notify_enter(pointer->server->seat,
1843 ds_xdg_surface_get_surface(view->xdg_surface), sx, sy);
1844 pointer->focused_view = view;
1849 ds_seat_pointer_notify_motion(pointer->server->seat,
1850 event->time_msec, sx, sy);
1855 pointer_handle_button(struct wl_listener *listener, void *data)
1857 struct tinyds_pointer *pointer;
1858 struct ds_event_pointer_button *event = data;
1860 pointer = wl_container_of(listener, pointer, button);
1862 ds_inf("Pointer(%p) button(%d): state(%s) time(%d)",
1863 pointer, event->button,
1864 (event->state == DS_BUTTON_PRESSED) ? "Pressed" : "Released",
1867 ds_seat_pointer_notify_button(pointer->server->seat, event->time_msec, event->button, event->state);
1871 pointer_handle_frame(struct wl_listener *listener, void *data)
1873 struct tinyds_pointer *pointer;
1875 pointer = wl_container_of(listener, pointer, frame);
1877 ds_inf("Pointer(%p) frame", pointer);
1878 ds_seat_pointer_notify_frame(pointer->server->seat);
1882 server_add_pointer(struct tinyds_server *server, struct ds_input_device *dev)
1884 struct tinyds_pointer *pointer;
1886 pointer = calloc(1, sizeof *pointer);
1890 pointer->server = server;
1891 server->output_x = 200;
1892 server->output_y = 200;
1894 pointer->destroy.notify = pointer_handle_device_destroy;
1895 ds_input_device_add_destroy_listener(dev, &pointer->destroy);
1897 pointer->motion.notify = pointer_handle_motion;
1898 ds_pointer_add_motion_listener(ds_input_device_get_pointer(dev),
1901 pointer->button.notify = pointer_handle_button;
1902 ds_pointer_add_button_listener(ds_input_device_get_pointer(dev),
1905 pointer->frame.notify = pointer_handle_frame;
1906 ds_pointer_add_frame_listener(ds_input_device_get_pointer(dev),
1909 pointer->focused_view = NULL;
1911 wl_list_insert(&server->pointers, &pointer->link);
1913 ds_inf("Pointer(%p) added", pointer);
1917 output_schedule_commit_handle_idle_timer(void *data)
1919 struct tinyds_output *output = data;
1920 output->idle_commit = NULL;
1922 output_commit(output);
1926 output_schedule_commit(struct tinyds_output *output)
1928 if (output->idle_commit)
1931 struct wl_event_loop *ev = wl_display_get_event_loop(output->server->display);
1932 output->idle_commit =
1933 wl_event_loop_add_idle(ev, output_schedule_commit_handle_idle_timer, output);
1937 text_input_mgr_handle_destroy(struct wl_listener *listener, void *data)
1939 struct tinyds_text_input *text_input;
1940 struct tinyds_server *server;
1942 ds_inf("text_input_mgr_handle_destroy");
1943 text_input = wl_container_of(listener, text_input, mgr_destroy);
1945 wl_list_remove(&text_input->mgr_destroy.link);
1946 wl_list_remove(&text_input->new_text_input.link);
1948 server = text_input->server;
1949 server->text_input = NULL;
1953 text_input_handle_destroy(struct wl_listener *listener, void *data)
1955 struct tinyds_text_input *text_input;
1957 ds_inf("text_input_handle_destroy");
1959 text_input = wl_container_of(listener, text_input, destroy);
1961 wl_list_remove(&text_input->destroy.link);
1962 wl_list_remove(&text_input->text_input_activate.link);
1963 wl_list_remove(&text_input->text_input_deactivate.link);
1964 wl_list_remove(&text_input->text_input_reset.link);
1965 wl_list_remove(&text_input->text_input_set_content_type.link);
1966 wl_list_remove(&text_input->text_input_invoke_action.link);
1967 wl_list_remove(&text_input->text_input_commit_state.link);
1968 wl_list_remove(&text_input->text_input_set_preferred_language.link);
1974 text_input_handle_activate(struct wl_listener *listener, void *data)
1976 struct tinyds_text_input *text_input;
1977 struct tinyds_input_method *input_method;
1978 struct ds_tizen_text_input_event_activate *event = data;
1980 text_input = wl_container_of(listener, text_input, text_input_activate);
1982 input_method = text_input->server->input_method;
1984 ds_inf("text_input_handle_activate. text_input(%p) seat(%p) surface(%p) text_input(%p)",
1985 text_input, event->seat, event->surface, event->text_input);
1987 if (input_method->input == text_input)
1989 if (input_method->input)
1990 ;//deactivate_input_method(server->input_method);
1991 input_method->input = text_input;
1992 wl_list_insert(&text_input->input_methods, &input_method->link);
1994 text_input->surface = event->surface;
1996 if (!add_new_input_method_context(input_method, text_input))
1999 // ds_tizen_input_method_send_set_text_input_id();
2003 text_input_handle_deactivate(struct wl_listener *listener, void *data)
2005 struct tinyds_text_input *text_input;
2006 struct tinyds_input_method *input_method, *tmp;
2007 struct ds_tizen_text_input_event_deactivate *event = data;
2009 text_input = wl_container_of(listener, text_input, text_input_deactivate);
2010 ds_inf("text_input_handle_deactivate. text_input(%p) seat(%p) text_input(%p)",
2011 text_input, event->seat, event->text_input);
2013 wl_list_for_each_safe(input_method, tmp, &text_input->input_methods, link) {
2014 if (!input_method->input_method || !input_method->context->context) continue;
2015 ds_tizen_input_method_send_deactivate(input_method->input_method, input_method->context->context);
2016 input_method->input = NULL;
2017 input_method->context = NULL;
2018 wl_list_remove(&input_method->link);
2021 text_input->surface = NULL;
2022 // ds_tizen_input_method_send_close_connection();
2026 text_input_handle_reset(struct wl_listener *listener, void *data)
2028 struct tinyds_text_input *text_input;
2029 struct tinyds_input_method *input_method;
2031 text_input = wl_container_of(listener, text_input, text_input_reset);
2033 ds_inf("text_input_handle_reset. text_input(%p)", text_input);
2035 wl_list_for_each(input_method, &text_input->input_methods, link) {
2036 if (!input_method->context || !input_method->context->context) continue;
2037 ds_tizen_input_method_context_send_reset(input_method->context->context);
2042 text_input_handle_set_content_type(struct wl_listener *listener, void *data)
2044 struct tinyds_text_input *text_input;
2045 struct ds_tizen_text_input_event_set_content_type *event = data;
2046 struct tinyds_input_method *input_method;
2048 text_input = wl_container_of(listener, text_input, text_input_set_content_type);
2050 ds_inf("text_input_handle_content_type. text_input(%p) hint(%u) purpose(%u)",
2051 text_input, event->hint, event->purpose);
2053 wl_list_for_each(input_method, &text_input->input_methods, link) {
2054 if (!input_method->context || !input_method->context->context) continue;
2055 ds_tizen_input_method_context_send_content_type(input_method->context->context,
2056 event->hint, event->purpose);
2061 text_input_handle_invoke_action(struct wl_listener *listener, void *data)
2063 struct tinyds_text_input *text_input;
2064 struct ds_tizen_text_input_event_invoke_action *event = data;
2065 struct tinyds_input_method *input_method;
2067 text_input = wl_container_of(listener, text_input, text_input_invoke_action);
2069 ds_inf("text_input_handle_invoke_action. text_input(%p) button(%u) index(%u)",
2070 text_input, event->button, event->index);
2072 wl_list_for_each(input_method, &text_input->input_methods, link) {
2073 if (!input_method->context || !input_method->context->context) continue;
2074 ds_tizen_input_method_context_send_invoke_action(input_method->context->context,
2075 event->button, event->index);
2080 text_input_handle_commit_state(struct wl_listener *listener, void *data)
2082 struct tinyds_text_input *text_input;
2083 struct ds_tizen_text_input_event_commit_state *event = data;
2084 struct tinyds_input_method *input_method;
2086 text_input = wl_container_of(listener, text_input, text_input_commit_state);
2088 ds_inf("text_input_handle_commit_state. text_input(%p) serial(%u)",
2089 text_input, event->serial);
2091 wl_list_for_each(input_method, &text_input->input_methods, link) {
2092 if (!input_method->context || !input_method->context->context) continue;
2093 ds_tizen_input_method_context_send_commit_state(input_method->context->context,
2099 text_input_handle_set_preferred_language(struct wl_listener *listener, void *data)
2101 struct tinyds_text_input *text_input;
2102 struct ds_tizen_text_input_event_set_preferred_language *event = data;
2103 struct tinyds_input_method *input_method;
2105 text_input = wl_container_of(listener, text_input, text_input_set_preferred_language);
2107 ds_inf("text_input_handle_set_preferred_language. text_input(%p) language(%s)",
2108 text_input, event->language);
2110 wl_list_for_each(input_method, &text_input->input_methods, link) {
2111 if (!input_method->context || !input_method->context->context) continue;
2112 ds_tizen_input_method_context_send_preferred_language(input_method->context->context,
2118 text_input_mgr_handle_new_text_input(struct wl_listener *listener, void *data)
2120 struct tinyds_text_input *text_input;
2121 struct ds_tizen_text_input *input = data;
2123 text_input = wl_container_of(listener, text_input, new_text_input);
2125 ds_inf("text_input_mgr_handle_new_text_input");
2127 text_input->input = input;
2129 text_input->destroy.notify = text_input_handle_destroy;
2130 ds_tizen_text_input_add_destroy_listener(text_input->input,
2131 &text_input->destroy);
2133 text_input->text_input_activate.notify = text_input_handle_activate;
2134 ds_tizen_text_input_add_activate_listener(text_input->input,
2135 &text_input->text_input_activate);
2137 text_input->text_input_deactivate.notify = text_input_handle_deactivate;
2138 ds_tizen_text_input_add_deactivate_listener(text_input->input,
2139 &text_input->text_input_deactivate);
2141 text_input->text_input_reset.notify = text_input_handle_reset;
2142 ds_tizen_text_input_add_reset_listener(text_input->input,
2143 &text_input->text_input_reset);
2145 text_input->text_input_set_content_type.notify = text_input_handle_set_content_type;
2146 ds_tizen_text_input_add_set_content_type_listener(text_input->input,
2147 &text_input->text_input_set_content_type);
2149 text_input->text_input_invoke_action.notify = text_input_handle_invoke_action;
2150 ds_tizen_text_input_add_invoke_action_listener(text_input->input,
2151 &text_input->text_input_invoke_action);
2153 text_input->text_input_commit_state.notify = text_input_handle_commit_state;
2154 ds_tizen_text_input_add_commit_state_listener(text_input->input,
2155 &text_input->text_input_commit_state);
2157 text_input->text_input_set_preferred_language.notify = text_input_handle_set_preferred_language;
2158 ds_tizen_text_input_add_set_preferred_language_listener(text_input->input,
2159 &text_input->text_input_set_preferred_language);
2163 input_method_mgr_handle_destroy(struct wl_listener *listener, void *data)
2165 struct tinyds_input_method *input_method;
2167 ds_inf("input_method_mgr_handle_destroy");
2169 input_method = wl_container_of(listener, input_method, mgr_destroy);
2171 wl_list_remove(&input_method->mgr_destroy.link);
2175 input_method_handle_destroy(struct wl_listener *listener, void *data)
2177 struct tinyds_input_method *input_method;
2178 struct tinyds_server *server;
2180 ds_inf("input_method_handle_destroy");
2182 input_method = wl_container_of(listener, input_method, destroy);
2184 wl_list_remove(&input_method->destroy.link);
2186 server = input_method->server;
2187 server->input_method = NULL;
2193 context_handle_destroy(struct wl_listener *listener, void *data)
2195 struct tinyds_input_method_context *context;
2196 struct tinyds_server *server;
2198 ds_inf("context_handle_destroy");
2200 context = wl_container_of(listener, context, destroy);
2202 wl_list_remove(&context->destroy.link);
2204 wl_list_remove(&context->im_context_commit_string.link);
2205 wl_list_remove(&context->im_context_preedit_string.link);
2206 wl_list_remove(&context->im_context_preedit_styling.link);
2207 wl_list_remove(&context->im_context_preedit_cursor.link);
2208 wl_list_remove(&context->im_context_delete_surrounding_text.link);
2209 wl_list_remove(&context->im_context_cursor_position.link);
2210 wl_list_remove(&context->im_context_modifiers_map.link);
2211 wl_list_remove(&context->im_context_keysym.link);
2212 wl_list_remove(&context->im_context_grab_keyboard.link);
2213 wl_list_remove(&context->im_context_key.link);
2214 wl_list_remove(&context->im_context_modifiers.link);
2215 wl_list_remove(&context->im_context_language.link);
2216 wl_list_remove(&context->im_context_text_direction.link);
2218 server = context->server;
2219 server->input_method->context = NULL;
2225 context_handle_commit_string(struct wl_listener *listener, void *data)
2227 struct tinyds_text_input *text_input;
2228 struct tinyds_input_method_context *context;
2229 struct ds_tizen_input_method_context_event_commit_string *event = data;
2231 context = wl_container_of(listener, context, im_context_commit_string);
2232 text_input = context->server->text_input;
2234 ds_inf("context_handle_commit_string. text_input(%p) serial(%u) text(%s)",
2235 text_input, event->serial, event->text);
2237 ds_tizen_text_input_send_commit_string(text_input->input, event->serial, event->text);
2241 context_handle_preedit_string(struct wl_listener *listener, void *data)
2243 struct tinyds_input_method_context *context;
2244 struct tinyds_text_input *text_input;
2245 struct ds_tizen_input_method_context_event_preedit_string *event = data;
2247 context = wl_container_of(listener, context, im_context_preedit_string);
2248 text_input = context->server->text_input;
2250 ds_inf("context_handle_preedit_string. text_input(%p) serial(%u) text(%s) commit(%s)",
2251 text_input, event->serial, event->text, event->commit);
2253 ds_tizen_text_input_send_preedit_string(text_input->input, event->serial, event->text, event->commit);
2257 context_handle_preedit_styling(struct wl_listener *listener, void *data)
2259 struct tinyds_input_method_context *context;
2260 struct tinyds_text_input *text_input;
2261 struct ds_tizen_input_method_context_event_preedit_styling *event = data;
2263 context = wl_container_of(listener, context, im_context_preedit_styling);
2264 text_input = context->server->text_input;
2266 ds_inf("context_handle_preedit_styling. text_input(%p) index(%u) length(%u) style(%u)",
2267 text_input, event->index, event->length, event->style);
2269 ds_tizen_text_input_send_preedit_styling(text_input->input, event->index, event->length, event->style);
2273 context_handle_preedit_cursor(struct wl_listener *listener, void *data)
2275 struct tinyds_input_method_context *context;
2276 struct tinyds_text_input *text_input;
2277 struct ds_tizen_input_method_context_event_preedit_cursor *event = data;
2279 context = wl_container_of(listener, context, im_context_preedit_cursor);
2280 text_input = context->server->text_input;
2282 ds_inf("context_handle_preedit_cursor. text_input(%p) index(%u)",
2283 text_input, event->index);
2285 ds_tizen_text_input_send_preedit_cursor(text_input->input, event->index);
2289 context_handle_delete_surrounding_text(struct wl_listener *listener, void *data)
2291 struct tinyds_input_method_context *context;
2292 struct tinyds_text_input *text_input;
2293 struct ds_tizen_input_method_context_event_delete_surrounding_text *event = data;
2295 context = wl_container_of(listener, context, im_context_delete_surrounding_text);
2296 text_input = context->server->text_input;
2298 ds_inf("context_handle_delete_surrounding_text. text_input(%p) index(%d) length(%u)",
2299 text_input, event->index, event->length);
2301 ds_tizen_text_input_send_delete_surrounding_text(text_input->input, event->index, event->length);
2305 context_handle_cursor_position(struct wl_listener *listener, void *data)
2307 struct tinyds_input_method_context *context;
2308 struct tinyds_text_input *text_input;
2309 struct ds_tizen_input_method_context_event_cursor_position *event = data;
2311 context = wl_container_of(listener, context, im_context_cursor_position);
2312 text_input = context->server->text_input;
2314 ds_inf("context_handle_cursor_position. text_input(%p) index(%d) length(%d)",
2315 text_input, event->index, event->anchor);
2317 ds_tizen_text_input_send_cursor_position(text_input->input, event->index, event->anchor);
2321 context_handle_modifiers_map(struct wl_listener *listener, void *data)
2323 struct tinyds_input_method_context *context;
2324 struct tinyds_text_input *text_input;
2325 struct ds_tizen_input_method_context_event_modifiers_map *event = data;
2327 context = wl_container_of(listener, context, im_context_modifiers_map);
2328 text_input = context->server->text_input;
2330 ds_inf("context_handle_modifiers_map. text_input(%p) map(%p)",
2331 text_input, event->map);
2333 ds_tizen_text_input_send_modifiers_map(text_input->input, event->map);
2337 context_handle_keysym(struct wl_listener *listener, void *data)
2339 struct tinyds_input_method_context *context;
2340 struct tinyds_text_input *text_input;
2341 struct ds_tizen_input_method_context_event_keysym *event = data;
2343 context = wl_container_of(listener, context, im_context_keysym);
2344 text_input = context->server->text_input;
2346 ds_inf("context_handle_keysym. text_input(%p) serial(%u) time(%u) sysm(%u) state(%u) modifiers(%u)",
2347 text_input, event->serial, event->time, event->sym, event->state, event->modifiers);
2349 ds_tizen_text_input_send_keysym(text_input->input, event->serial, event->time, event->sym, event->state, event->modifiers);
2353 context_handle_grab_keyboard(struct wl_listener *listener, void *data)
2355 struct tinyds_input_method_context *context;
2356 struct tinyds_text_input *text_input;
2358 context = wl_container_of(listener, context, im_context_grab_keyboard);
2359 text_input = context->server->text_input;
2361 ds_inf("context_handle_grab_keyboard. text_input(%p)",
2368 context_handle_key(struct wl_listener *listener, void *data)
2370 struct tinyds_input_method_context *context;
2371 struct tinyds_text_input *text_input;
2373 context = wl_container_of(listener, context, im_context_key);
2374 text_input = context->server->text_input;
2376 ds_inf("context_handle_key. text_input(%p)",
2383 context_handle_modifiers(struct wl_listener *listener, void *data)
2385 struct tinyds_input_method_context *context;
2386 struct tinyds_text_input *text_input;
2388 context = wl_container_of(listener, context, im_context_modifiers);
2389 text_input = context->server->text_input;
2391 ds_inf("context_handle_modifiers. text_input(%p)",
2398 context_handle_language(struct wl_listener *listener, void *data)
2400 struct tinyds_input_method_context *context;
2401 struct tinyds_text_input *text_input;
2402 struct ds_tizen_input_method_context_event_language *event = data;
2404 context = wl_container_of(listener, context, im_context_language);
2405 text_input = context->server->text_input;
2407 ds_inf("context_handle_language. text_input(%p) serial(%u), language(%s)",
2408 text_input, event->serial, event->language);
2410 ds_tizen_text_input_send_language(text_input->input, event->serial, event->language);
2414 context_handle_text_direction(struct wl_listener *listener, void *data)
2416 struct tinyds_input_method_context *context;
2417 struct tinyds_text_input *text_input;
2418 struct ds_tizen_input_method_context_event_text_direction *event = data;
2420 context = wl_container_of(listener, context, im_context_text_direction);
2421 text_input = context->server->text_input;
2423 ds_inf("context_handle_text_direction. text_input(%p) serial(%u), direction(%u)",
2424 text_input, event->serial, event->direction);
2426 ds_tizen_text_input_send_text_direction(text_input->input, event->serial, event->direction);
2430 add_new_text_input(struct tinyds_server *server)
2432 struct tinyds_text_input *text_input;
2434 text_input = calloc(1, sizeof *text_input);
2438 text_input->text_input_mgr = ds_tizen_text_input_manager_create(server->display);
2439 if (!text_input->text_input_mgr) {
2441 ds_err("Could not create ds_tizen_text_input_manager");
2445 wl_list_init(&text_input->input_methods);
2447 text_input->mgr_destroy.notify = text_input_mgr_handle_destroy;
2448 ds_tizen_text_input_manager_add_destroy_listener(text_input->text_input_mgr,
2449 &text_input->mgr_destroy);
2451 text_input->new_text_input.notify = text_input_mgr_handle_new_text_input;
2452 ds_tizen_text_input_manager_add_new_text_input_listener(text_input->text_input_mgr,
2453 &text_input->new_text_input);
2455 text_input->server = server;
2456 server->text_input = text_input;
2458 ds_inf("Text_Input (%p) added", text_input);
2464 add_new_input_method(struct tinyds_server *server)
2466 struct tinyds_input_method *input_method;
2468 input_method = calloc(1, sizeof *input_method);
2472 input_method->input_method = ds_tizen_input_method_create(server->display);
2473 if (!input_method->input_method) {
2475 ds_err("Could not create ds_tizen_input_method");
2478 input_method->destroy.notify = input_method_handle_destroy;
2479 ds_tizen_input_method_add_destroy_listener(input_method->input_method,
2480 &input_method->destroy);
2482 input_method->input_method_mgr = ds_tizen_input_method_manager_create(server->display);
2483 if (!input_method->input_method_mgr) {
2485 ds_err("Could not create ds_tizen_input_method_manager");
2489 input_method->mgr_destroy.notify = input_method_mgr_handle_destroy;
2490 ds_tizen_input_method_manager_add_destroy_listener(input_method->input_method_mgr,
2491 &input_method->mgr_destroy);
2493 input_method->server = server;
2494 server->input_method = input_method;
2496 ds_inf("Input_Method (%p) added", input_method);
2502 add_new_input_method_context(struct tinyds_input_method *input_method,
2503 struct tinyds_text_input *text_input)
2505 struct tinyds_input_method_context *context;
2507 context = calloc(1, sizeof *context);
2508 if (context == NULL)
2510 ds_err("calloc is failed. tinyds_input_method_context");
2513 input_method->context = context;
2514 context->input_method = input_method;
2515 context->server = input_method->server;
2516 context->input = text_input;
2518 context->context = ds_tizen_input_method_create_context(input_method->input_method);
2519 if (context->context == NULL) {
2520 ds_err("ds_tizen_input_method_create_context() failed.");
2524 context->destroy.notify = context_handle_destroy;
2525 ds_tizen_input_method_context_add_destroy_listener(context->context,
2528 context->im_context_commit_string.notify = context_handle_commit_string;
2529 ds_tizen_input_method_context_add_commit_string_listener(context->context,
2530 &context->im_context_commit_string);
2532 context->im_context_preedit_string.notify = context_handle_preedit_string;
2533 ds_tizen_input_method_context_add_preedit_string_listener(context->context,
2534 &context->im_context_preedit_string);
2536 context->im_context_preedit_styling.notify = context_handle_preedit_styling;
2537 ds_tizen_input_method_context_add_preedit_styling_listener(context->context,
2538 &context->im_context_preedit_styling);
2540 context->im_context_preedit_cursor.notify = context_handle_preedit_cursor;
2541 ds_tizen_input_method_context_add_preedit_cursor_listener(context->context,
2542 &context->im_context_preedit_cursor);
2544 context->im_context_delete_surrounding_text.notify = context_handle_delete_surrounding_text;
2545 ds_tizen_input_method_context_add_delete_surrounding_text_listener(context->context,
2546 &context->im_context_delete_surrounding_text);
2548 context->im_context_cursor_position.notify = context_handle_cursor_position;
2549 ds_tizen_input_method_context_add_cursor_position_listener(context->context,
2550 &context->im_context_cursor_position);
2552 context->im_context_modifiers_map.notify = context_handle_modifiers_map;
2553 ds_tizen_input_method_context_add_modifiers_map_listener(context->context,
2554 &context->im_context_modifiers_map);
2556 context->im_context_keysym.notify = context_handle_keysym;
2557 ds_tizen_input_method_context_add_keysym_listener(context->context,
2558 &context->im_context_keysym);
2560 context->im_context_grab_keyboard.notify = context_handle_grab_keyboard;
2561 ds_tizen_input_method_context_add_grab_keyboard_listener(context->context,
2562 &context->im_context_grab_keyboard);
2564 context->im_context_key.notify = context_handle_key;
2565 ds_tizen_input_method_context_add_key_listener(context->context,
2566 &context->im_context_key);
2568 context->im_context_modifiers.notify = context_handle_modifiers;
2569 ds_tizen_input_method_context_add_modifiers_listener(context->context,
2570 &context->im_context_modifiers);
2572 context->im_context_language.notify = context_handle_language;
2573 ds_tizen_input_method_context_add_language_listener(context->context,
2574 &context->im_context_language);
2576 context->im_context_text_direction.notify = context_handle_text_direction;
2577 ds_tizen_input_method_context_add_text_direction_listener(context->context,
2578 &context->im_context_text_direction);
2584 visibility_handle_destroy(struct wl_listener *listener, void *data)
2586 struct tinyds_policy_visibility *visibility;
2588 visibility = wl_container_of(listener, visibility, destroy);
2590 ds_inf("Policy Visibility(%p) destroy", visibility);
2592 wl_list_remove(&visibility->destroy.link);
2593 wl_list_remove(&visibility->link);
2598 position_handle_destroy(struct wl_listener *listener, void *data)
2600 struct tinyds_policy_position *position;
2602 position = wl_container_of(listener, position, destroy);
2604 ds_inf("Policy Position(%p) destroy", position);
2606 wl_list_remove(&position->destroy.link);
2607 wl_list_remove(&position->set.link);
2608 wl_list_remove(&position->link);
2613 position_handle_set(struct wl_listener *listener, void *data)
2615 struct tinyds_policy_position *position;
2617 position = wl_container_of(listener, position, set);
2619 ds_inf("Policy Position(%p) set", position);
2625 subsurface_watcher_handle_destroy(struct wl_listener *listener, void *data)
2627 struct tinyds_policy_subsurface_watcher *subsurface_watcher;
2629 subsurface_watcher = wl_container_of(listener, subsurface_watcher, destroy);
2631 ds_inf("Policy Subsurface_Watcher(%p) destroy", subsurface_watcher);
2633 wl_list_remove(&subsurface_watcher->destroy.link);
2634 wl_list_remove(&subsurface_watcher->link);
2635 free(subsurface_watcher);
2639 policy_surface_handle_destroy(struct wl_listener *listener, void *data)
2641 struct tinyds_policy_surface *policy_surface;
2643 policy_surface = wl_container_of(listener, policy_surface, destroy);
2645 ds_inf("Policy Info(%p) destroy", policy_surface);
2647 wl_list_remove(&policy_surface->destroy.link);
2648 wl_list_remove(&policy_surface->new_visibility.link);
2649 wl_list_remove(&policy_surface->new_position.link);
2650 wl_list_remove(&policy_surface->activate.link);
2651 wl_list_remove(&policy_surface->raise.link);
2652 wl_list_remove(&policy_surface->lower.link);
2653 wl_list_remove(&policy_surface->set_focus_skip.link);
2654 wl_list_remove(&policy_surface->unset_focus_skip.link);
2655 wl_list_remove(&policy_surface->set_role.link);
2656 wl_list_remove(&policy_surface->set_window_type.link);
2657 wl_list_remove(&policy_surface->set_conformant.link);
2658 wl_list_remove(&policy_surface->unset_conformant.link);
2659 wl_list_remove(&policy_surface->get_conformant.link);
2660 wl_list_remove(&policy_surface->set_notification_level.link);
2661 wl_list_remove(&policy_surface->set_window_screen_mode.link);
2662 wl_list_remove(&policy_surface->get_subsurface.link);
2663 wl_list_remove(&policy_surface->iconify.link);
2664 wl_list_remove(&policy_surface->uniconify.link);
2665 wl_list_remove(&policy_surface->add_aux_hint.link);
2666 wl_list_remove(&policy_surface->change_aux_hint.link);
2667 wl_list_remove(&policy_surface->delete_aux_hint.link);
2668 wl_list_remove(&policy_surface->get_supported_aux_hints.link);
2669 wl_list_remove(&policy_surface->set_floating_mode.link);
2670 wl_list_remove(&policy_surface->unset_floating_mode.link);
2671 wl_list_remove(&policy_surface->set_stack_mode.link);
2672 wl_list_remove(&policy_surface->new_subsurface_watcher.link);
2673 wl_list_remove(&policy_surface->set_parent.link);
2674 wl_list_remove(&policy_surface->ack_conformant_region.link);
2675 wl_list_remove(&policy_surface->set_video.link);
2676 wl_list_remove(&policy_surface->show.link);
2677 wl_list_remove(&policy_surface->hide.link);
2678 wl_list_remove(&policy_surface->set_parent_with_below.link);
2679 wl_list_remove(&policy_surface->link);
2680 free(policy_surface);
2684 policy_surface_handle_new_visibility(struct wl_listener *listener, void *data)
2686 struct tinyds_policy_surface *policy_surface;
2687 struct tinyds_policy_visibility *visibility;
2688 struct ds_tizen_event_policy_surface_new_visibility *event;
2690 policy_surface = wl_container_of(listener, policy_surface, new_visibility);
2691 event = (struct ds_tizen_event_policy_surface_new_visibility *)data;
2693 ds_inf("Policy Info(%p) new_visibility", policy_surface);
2695 visibility = calloc(1, sizeof *visibility);
2699 visibility->visibility = event->visibility;
2701 visibility->destroy.notify = visibility_handle_destroy;
2702 ds_tizen_policy_visibility_add_destroy_listener(visibility->visibility,
2703 &visibility->destroy);
2705 wl_list_insert(&policy_surface->visibilities, &visibility->link);
2709 policy_surface_handle_new_position(struct wl_listener *listener, void *data)
2711 struct tinyds_policy_surface *policy_surface;
2712 struct tinyds_policy_position *position;
2713 struct ds_tizen_event_policy_surface_new_position *event;
2715 policy_surface = wl_container_of(listener, policy_surface, new_position);
2716 event = (struct ds_tizen_event_policy_surface_new_position *)data;
2718 ds_inf("Policy Info(%p) new_position", policy_surface);
2720 position = calloc(1, sizeof *position);
2724 position->position = event->position;
2726 position->destroy.notify = position_handle_destroy;
2727 ds_tizen_policy_position_add_destroy_listener(position->position,
2728 &position->destroy);
2730 position->set.notify = position_handle_set;
2731 ds_tizen_policy_position_add_set_listener(position->position,
2734 wl_list_insert(&policy_surface->positions, &position->link);
2738 policy_surface_handle_activate(struct wl_listener *listener, void *data)
2740 struct tinyds_policy_surface *policy_surface;
2742 policy_surface = wl_container_of(listener, policy_surface, activate);
2744 ds_inf("Policy Info(%p) activate", policy_surface);
2750 policy_surface_handle_raise(struct wl_listener *listener, void *data)
2752 struct tinyds_policy_surface *policy_surface;
2754 policy_surface = wl_container_of(listener, policy_surface, raise);
2756 ds_inf("Policy Info(%p) raise", policy_surface);
2762 policy_surface_handle_lower(struct wl_listener *listener, void *data)
2764 struct tinyds_policy_surface *policy_surface;
2766 policy_surface = wl_container_of(listener, policy_surface, raise);
2768 ds_inf("Policy Info(%p) lower", policy_surface);
2774 policy_surface_handle_set_focus_skip(struct wl_listener *listener, void *data)
2776 struct tinyds_policy_surface *policy_surface;
2778 policy_surface = wl_container_of(listener, policy_surface, set_focus_skip);
2780 ds_inf("Policy Info(%p) set_focus_skip", policy_surface);
2786 policy_surface_handle_unset_focus_skip(struct wl_listener *listener, void *data)
2788 struct tinyds_policy_surface *policy_surface;
2790 policy_surface = wl_container_of(listener, policy_surface, unset_focus_skip);
2792 ds_inf("Policy Info(%p) unset_focus_skip", policy_surface);
2798 policy_surface_handle_set_role(struct wl_listener *listener, void *data)
2800 struct tinyds_policy_surface *policy_surface;
2802 policy_surface = wl_container_of(listener, policy_surface, set_role);
2804 ds_inf("Policy Info(%p) set_role", policy_surface);
2810 policy_surface_handle_set_window_type(struct wl_listener *listener, void *data)
2812 struct tinyds_policy_surface *policy_surface;
2814 policy_surface = wl_container_of(listener, policy_surface, set_window_type);
2816 ds_inf("Policy Info(%p) set_window_type", policy_surface);
2822 policy_surface_handle_set_conformant(struct wl_listener *listener, void *data)
2824 struct tinyds_policy_surface *policy_surface;
2826 policy_surface = wl_container_of(listener, policy_surface, set_conformant);
2828 ds_inf("Policy Info(%p) set_conformant", policy_surface);
2834 policy_surface_handle_unset_conformant(struct wl_listener *listener, void *data)
2836 struct tinyds_policy_surface *policy_surface;
2838 policy_surface = wl_container_of(listener, policy_surface, unset_conformant);
2840 ds_inf("Policy Info(%p) unset_conformant", policy_surface);
2846 policy_surface_handle_get_conformant(struct wl_listener *listener, void *data)
2848 struct tinyds_policy_surface *policy_surface;
2850 policy_surface = wl_container_of(listener, policy_surface, get_conformant);
2852 ds_inf("Policy Info(%p) get_conformant", policy_surface);
2858 policy_surface_handle_set_notification_level(struct wl_listener *listener, void *data)
2860 struct tinyds_policy_surface *policy_surface;
2862 policy_surface = wl_container_of(listener, policy_surface, set_notification_level);
2864 ds_inf("Policy Info(%p) set_notification_level", policy_surface);
2870 policy_surface_handle_set_window_screen_mode(struct wl_listener *listener, void *data)
2872 struct tinyds_policy_surface *policy_surface;
2874 policy_surface = wl_container_of(listener, policy_surface, set_window_screen_mode);
2876 ds_inf("Policy Info(%p) set_window_screen_mode", policy_surface);
2882 policy_surface_handle_get_subsurface(struct wl_listener *listener, void *data)
2884 struct tinyds_policy_surface *policy_surface;
2886 policy_surface = wl_container_of(listener, policy_surface, get_subsurface);
2888 ds_inf("Policy Info(%p) get_subsurface", policy_surface);
2894 policy_surface_handle_iconify(struct wl_listener *listener, void *data)
2896 struct tinyds_policy_surface *policy_surface;
2898 policy_surface = wl_container_of(listener, policy_surface, iconify);
2900 ds_inf("Policy Info(%p) iconify", policy_surface);
2906 policy_surface_handle_uniconify(struct wl_listener *listener, void *data)
2908 struct tinyds_policy_surface *policy_surface;
2910 policy_surface = wl_container_of(listener, policy_surface, uniconify);
2912 ds_inf("Policy Info(%p) uniconify", policy_surface);
2918 policy_surface_handle_add_aux_hint(struct wl_listener *listener, void *data)
2920 struct tinyds_policy_surface *policy_surface;
2922 policy_surface = wl_container_of(listener, policy_surface, add_aux_hint);
2924 ds_inf("Policy Info(%p) add_aux_hint", policy_surface);
2930 policy_surface_handle_change_aux_hint(struct wl_listener *listener, void *data)
2932 struct tinyds_policy_surface *policy_surface;
2934 policy_surface = wl_container_of(listener, policy_surface, change_aux_hint);
2936 ds_inf("Policy Info(%p) change_aux_hint", policy_surface);
2942 policy_surface_handle_delete_aux_hint(struct wl_listener *listener, void *data)
2944 struct tinyds_policy_surface *policy_surface;
2946 policy_surface = wl_container_of(listener, policy_surface, delete_aux_hint);
2948 ds_inf("Policy Info(%p) delete_aux_hint", policy_surface);
2954 policy_surface_handle_get_supported_aux_hints(struct wl_listener *listener, void *data)
2956 struct tinyds_policy_surface *policy_surface;
2958 policy_surface = wl_container_of(listener, policy_surface, get_supported_aux_hints);
2960 ds_inf("Policy Info(%p) get_supported_aux_hints", policy_surface);
2966 policy_surface_handle_set_floating_mode(struct wl_listener *listener, void *data)
2968 struct tinyds_policy_surface *policy_surface;
2970 policy_surface = wl_container_of(listener, policy_surface, set_floating_mode);
2972 ds_inf("Policy Info(%p) set_floating_mode", policy_surface);
2978 policy_surface_handle_unset_floating_mode(struct wl_listener *listener, void *data)
2980 struct tinyds_policy_surface *policy_surface;
2982 policy_surface = wl_container_of(listener, policy_surface, unset_floating_mode);
2984 ds_inf("Policy Info(%p) unset_floating_mode", policy_surface);
2990 policy_surface_handle_set_stack_mode(struct wl_listener *listener, void *data)
2992 struct tinyds_policy_surface *policy_surface;
2994 policy_surface = wl_container_of(listener, policy_surface, set_stack_mode);
2996 ds_inf("Policy Info(%p) set_stack_mode", policy_surface);
3002 policy_surface_handle_new_subsurface_watcher(struct wl_listener *listener, void *data)
3004 struct tinyds_policy_surface *policy_surface;
3005 struct tinyds_policy_subsurface_watcher*subsurface_watcher;
3006 struct ds_tizen_event_policy_surface_new_subsurface_watcher *event;
3008 policy_surface = wl_container_of(listener, policy_surface, new_subsurface_watcher);
3009 event = (struct ds_tizen_event_policy_surface_new_subsurface_watcher *)data;
3011 ds_inf("Policy Info(%p) new_subsurface_watcher", policy_surface);
3013 subsurface_watcher = calloc(1, sizeof *subsurface_watcher);
3014 if (!subsurface_watcher)
3017 subsurface_watcher->subsurface_watcher = event->subsurface_watcher;
3019 subsurface_watcher->destroy.notify = subsurface_watcher_handle_destroy;
3020 ds_tizen_policy_subsurface_watcher_add_destroy_listener(subsurface_watcher->subsurface_watcher,
3021 &subsurface_watcher->destroy);
3023 wl_list_insert(&policy_surface->subsurface_watchers, &subsurface_watcher->link);
3027 policy_surface_handle_set_parent(struct wl_listener *listener, void *data)
3029 struct tinyds_policy_surface *policy_surface;
3031 policy_surface = wl_container_of(listener, policy_surface, set_parent);
3033 ds_inf("Policy Info(%p) set_parent", policy_surface);
3039 policy_surface_handle_ack_conformant_region(struct wl_listener *listener, void *data)
3041 struct tinyds_policy_surface *policy_surface;
3043 policy_surface = wl_container_of(listener, policy_surface, ack_conformant_region);
3045 ds_inf("Policy Info(%p) ack_conformant_region", policy_surface);
3051 policy_surface_handle_set_video(struct wl_listener *listener, void *data)
3053 struct tinyds_policy_surface *policy_surface;
3055 policy_surface = wl_container_of(listener, policy_surface, set_video);
3057 ds_inf("Policy Info(%p) set_video", policy_surface);
3063 policy_surface_handle_show(struct wl_listener *listener, void *data)
3065 struct tinyds_policy_surface *policy_surface;
3067 policy_surface = wl_container_of(listener, policy_surface, show);
3069 ds_inf("Policy Info(%p) show", policy_surface);
3075 policy_surface_handle_hide(struct wl_listener *listener, void *data)
3077 struct tinyds_policy_surface *policy_surface;
3079 policy_surface = wl_container_of(listener, policy_surface, hide);
3081 ds_inf("Policy Info(%p) hide", policy_surface);
3087 policy_surface_handle_set_parent_with_below(struct wl_listener *listener, void *data)
3089 struct tinyds_policy_surface *policy_surface;
3091 policy_surface = wl_container_of(listener, policy_surface, set_parent_with_below);
3093 ds_inf("Policy Info(%p) set_parent_with_below", policy_surface);
3099 policy_handle_destroy(struct wl_listener *listener, void *data)
3101 struct tinyds_policy *policy;
3103 policy = wl_container_of(listener, policy, destroy);
3105 ds_inf("Policy(%p) destroy", policy);
3107 wl_list_remove(&policy->destroy.link);
3108 wl_list_remove(&policy->new_surface.link);
3109 wl_list_remove(&policy->activate_below_by_univeral_id.link);
3110 wl_list_remove(&policy->lower_by_universal_id.link);
3111 wl_list_remove(&policy->set_transient_for.link);
3112 wl_list_remove(&policy->unset_transient_for.link);
3113 wl_list_remove(&policy->place_subsurface_below_parent.link);
3114 wl_list_remove(&policy->set_subsurface_stand_alone.link);
3115 wl_list_remove(&policy->set_background_state.link);
3116 wl_list_remove(&policy->unset_background_state.link);
3117 wl_list_remove(&policy->add_activate_above_by_universal_id.link);
3118 wl_list_remove(&policy->set_appid.link);
3119 wl_list_remove(&policy->set_transient_for_below.link);
3125 policy_handle_new_surface(struct wl_listener *listener, void *data)
3127 struct tinyds_policy *policy;
3128 struct tinyds_policy_surface *policy_surface;
3129 struct ds_tizen_event_policy_new_surface *event;
3131 policy = wl_container_of(listener, policy, new_surface);
3132 event = (struct ds_tizen_event_policy_new_surface *)data;
3134 ds_inf("Policy(%p) new_surface", policy);
3136 policy_surface = calloc(1, sizeof *policy_surface);
3137 if (!policy_surface)
3140 policy_surface->policy_surface = event->policy_surface;
3142 policy_surface->destroy.notify = policy_surface_handle_destroy;
3143 ds_tizen_policy_surface_add_destroy_listener(policy_surface->policy_surface,
3144 &policy_surface->destroy);
3146 policy_surface->new_visibility.notify = policy_surface_handle_new_visibility;
3147 ds_tizen_policy_surface_add_new_visibility_listener(policy_surface->policy_surface,
3148 &policy_surface->new_visibility);
3150 policy_surface->new_position.notify = policy_surface_handle_new_position;
3151 ds_tizen_policy_surface_add_new_position_listener(policy_surface->policy_surface,
3152 &policy_surface->new_position);
3154 policy_surface->activate.notify = policy_surface_handle_activate;
3155 ds_tizen_policy_surface_add_activate_listener(policy_surface->policy_surface,
3156 &policy_surface->activate);
3158 policy_surface->raise.notify = policy_surface_handle_raise;
3159 ds_tizen_policy_surface_add_raise_listener(policy_surface->policy_surface,
3160 &policy_surface->raise);
3162 policy_surface->lower.notify = policy_surface_handle_lower;
3163 ds_tizen_policy_surface_add_lower_listener(policy_surface->policy_surface,
3164 &policy_surface->lower);
3166 policy_surface->set_focus_skip.notify = policy_surface_handle_set_focus_skip;
3167 ds_tizen_policy_surface_add_set_focus_skip_listener(policy_surface->policy_surface,
3168 &policy_surface->set_focus_skip);
3170 policy_surface->unset_focus_skip.notify = policy_surface_handle_unset_focus_skip;
3171 ds_tizen_policy_surface_add_unset_focus_skip_listener(policy_surface->policy_surface,
3172 &policy_surface->unset_focus_skip);
3174 policy_surface->set_role.notify = policy_surface_handle_set_role;
3175 ds_tizen_policy_surface_add_set_role_listener(policy_surface->policy_surface,
3176 &policy_surface->set_role);
3178 policy_surface->set_window_type.notify = policy_surface_handle_set_window_type;
3179 ds_tizen_policy_surface_add_set_window_type_listener(policy_surface->policy_surface,
3180 &policy_surface->set_window_type);
3182 policy_surface->set_conformant.notify = policy_surface_handle_set_conformant;
3183 ds_tizen_policy_surface_add_set_conformant_listener(policy_surface->policy_surface,
3184 &policy_surface->set_conformant);
3186 policy_surface->unset_conformant.notify = policy_surface_handle_unset_conformant;
3187 ds_tizen_policy_surface_add_unset_conformant_listener(policy_surface->policy_surface,
3188 &policy_surface->unset_conformant);
3190 policy_surface->get_conformant.notify = policy_surface_handle_get_conformant;
3191 ds_tizen_policy_surface_add_get_conformant_listener(policy_surface->policy_surface,
3192 &policy_surface->get_conformant);
3194 policy_surface->set_notification_level.notify =
3195 policy_surface_handle_set_notification_level;
3196 ds_tizen_policy_surface_add_set_notification_level_listener(
3197 policy_surface->policy_surface, &policy_surface->set_notification_level);
3199 policy_surface->set_window_screen_mode.notify =
3200 policy_surface_handle_set_window_screen_mode;
3201 ds_tizen_policy_surface_add_set_window_screen_mode_listener(
3202 policy_surface->policy_surface, &policy_surface->set_window_screen_mode);
3204 policy_surface->get_subsurface.notify = policy_surface_handle_get_subsurface;
3205 ds_tizen_policy_surface_add_get_subsurface_listener(policy_surface->policy_surface,
3206 &policy_surface->get_subsurface);
3208 policy_surface->iconify.notify = policy_surface_handle_iconify;
3209 ds_tizen_policy_surface_add_iconify_listener(policy_surface->policy_surface,
3210 &policy_surface->iconify);
3212 policy_surface->uniconify.notify = policy_surface_handle_uniconify;
3213 ds_tizen_policy_surface_add_uniconify_listener(policy_surface->policy_surface,
3214 &policy_surface->uniconify);
3216 policy_surface->add_aux_hint.notify = policy_surface_handle_add_aux_hint;
3217 ds_tizen_policy_surface_add_add_aux_hint_listener(policy_surface->policy_surface,
3218 &policy_surface->add_aux_hint);
3220 policy_surface->change_aux_hint.notify = policy_surface_handle_change_aux_hint;
3221 ds_tizen_policy_surface_add_change_aux_hint_listener(policy_surface->policy_surface,
3222 &policy_surface->change_aux_hint);
3224 policy_surface->delete_aux_hint.notify = policy_surface_handle_delete_aux_hint;
3225 ds_tizen_policy_surface_add_delete_aux_hint_listener(policy_surface->policy_surface,
3226 &policy_surface->delete_aux_hint);
3228 policy_surface->get_supported_aux_hints.notify =
3229 policy_surface_handle_get_supported_aux_hints;
3230 ds_tizen_policy_surface_add_get_supported_aux_hints_listener(
3231 policy_surface->policy_surface, &policy_surface->get_supported_aux_hints);
3233 policy_surface->set_floating_mode.notify =
3234 policy_surface_handle_set_floating_mode;
3235 ds_tizen_policy_surface_add_set_floating_mode_listener(
3236 policy_surface->policy_surface, &policy_surface->set_floating_mode);
3238 policy_surface->unset_floating_mode.notify =
3239 policy_surface_handle_unset_floating_mode;
3240 ds_tizen_policy_surface_add_unset_floating_mode_listener(
3241 policy_surface->policy_surface, &policy_surface->unset_floating_mode);
3243 policy_surface->set_stack_mode.notify = policy_surface_handle_set_stack_mode;
3244 ds_tizen_policy_surface_add_set_stack_mode_listener(policy_surface->policy_surface,
3245 &policy_surface->set_stack_mode);
3247 policy_surface->new_subsurface_watcher.notify =
3248 policy_surface_handle_new_subsurface_watcher;
3249 ds_tizen_policy_surface_add_new_subsurface_watcher_listener(
3250 policy_surface->policy_surface, &policy_surface->new_subsurface_watcher);
3252 policy_surface->set_parent.notify = policy_surface_handle_set_parent;
3253 ds_tizen_policy_surface_add_set_parent_listener(policy_surface->policy_surface,
3254 &policy_surface->set_parent);
3256 policy_surface->ack_conformant_region.notify =
3257 policy_surface_handle_ack_conformant_region;
3258 ds_tizen_policy_surface_add_ack_conformant_region_listener(
3259 policy_surface->policy_surface, &policy_surface->ack_conformant_region);
3261 policy_surface->set_video.notify = policy_surface_handle_set_video;
3262 ds_tizen_policy_surface_add_set_video_listener(policy_surface->policy_surface,
3263 &policy_surface->set_video);
3265 policy_surface->show.notify = policy_surface_handle_show;
3266 ds_tizen_policy_surface_add_show_listener(policy_surface->policy_surface,
3267 &policy_surface->show);
3269 policy_surface->hide.notify = policy_surface_handle_hide;
3270 ds_tizen_policy_surface_add_hide_listener(policy_surface->policy_surface,
3271 &policy_surface->hide);
3273 policy_surface->set_parent_with_below.notify =
3274 policy_surface_handle_set_parent_with_below;
3275 ds_tizen_policy_surface_add_set_parent_with_below_listener(
3276 policy_surface->policy_surface, &policy_surface->set_parent_with_below);
3279 wl_list_init(&policy_surface->visibilities);
3280 wl_list_init(&policy_surface->positions);
3281 wl_list_init(&policy_surface->subsurface_watchers);
3283 wl_list_insert(&policy->policy_surfaces, &policy_surface->link);
3287 policy_handle_activate_below_by_univeral_id(struct wl_listener *listener, void *data)
3289 struct tinyds_policy *policy;
3291 policy = wl_container_of(listener, policy, activate_below_by_univeral_id);
3293 ds_inf("Policy(%p) activate_below_by_univeral_id", policy);
3299 policy_handle_lower_by_universal_id(struct wl_listener *listener, void *data)
3301 struct tinyds_policy *policy;
3303 policy = wl_container_of(listener, policy, lower_by_universal_id);
3305 ds_inf("Policy(%p) lower_by_universal_id", policy);
3311 policy_handle_set_transient_for(struct wl_listener *listener, void *data)
3313 struct tinyds_policy *policy;
3315 policy = wl_container_of(listener, policy, set_transient_for);
3317 ds_inf("Policy(%p) set_transient_for", policy);
3323 policy_handle_unset_transient_for(struct wl_listener *listener, void *data)
3325 struct tinyds_policy *policy;
3327 policy = wl_container_of(listener, policy, unset_transient_for);
3329 ds_inf("Policy(%p) unset_transient_for", policy);
3335 policy_handle_place_subsurface_below_parent(struct wl_listener *listener, void *data)
3337 struct tinyds_policy *policy;
3339 policy = wl_container_of(listener, policy, place_subsurface_below_parent);
3341 ds_inf("Policy(%p) place_subsurface_below_parent", policy);
3347 policy_handle_set_subsurface_stand_alone(struct wl_listener *listener, void *data)
3349 struct tinyds_policy *policy;
3351 policy = wl_container_of(listener, policy, set_subsurface_stand_alone);
3353 ds_inf("Policy(%p) set_subsurface_stand_alone", policy);
3359 policy_handle_set_background_state(struct wl_listener *listener, void *data)
3361 struct tinyds_policy *policy;
3363 policy = wl_container_of(listener, policy, set_background_state);
3365 ds_inf("Policy(%p) set_background_state", policy);
3371 policy_handle_unset_background_state(struct wl_listener *listener, void *data)
3373 struct tinyds_policy *policy;
3375 policy = wl_container_of(listener, policy, unset_background_state);
3377 ds_inf("Policy(%p) unset_background_state", policy);
3383 policy_handle_add_activate_above_by_universal_id(struct wl_listener *listener, void *data)
3385 struct tinyds_policy *policy;
3387 policy = wl_container_of(listener, policy, add_activate_above_by_universal_id);
3389 ds_inf("Policy(%p) add_activate_above_by_universal_id", policy);
3395 policy_handle_set_appid(struct wl_listener *listener, void *data)
3397 struct tinyds_policy *policy;
3399 policy = wl_container_of(listener, policy, set_appid);
3401 ds_inf("Policy(%p) set_appid", policy);
3407 policy_handle_set_transient_for_below(struct wl_listener *listener, void *data)
3409 struct tinyds_policy *policy;
3411 policy = wl_container_of(listener, policy, set_transient_for_below);
3413 ds_inf("Policy(%p) set_transient_for_below", policy);
3419 new_policy(struct tinyds_server *server)
3421 struct tinyds_policy *policy;
3423 policy = calloc(1, sizeof *policy);
3427 policy->policy = ds_tizen_policy_create(server->display);
3428 if (!policy->policy) {
3430 ds_err("Could not create ds_tizen_policy");
3434 policy->destroy.notify = policy_handle_destroy;
3435 ds_tizen_policy_add_destroy_listener(policy->policy, &policy->destroy);
3437 policy->new_surface.notify = policy_handle_new_surface;
3438 ds_tizen_policy_add_new_surface_listener(policy->policy, &policy->new_surface);
3440 policy->activate_below_by_univeral_id.notify =
3441 policy_handle_activate_below_by_univeral_id;
3442 ds_tizen_policy_add_activate_below_by_univeral_id_listener(policy->policy,
3443 &policy->activate_below_by_univeral_id);
3445 policy->lower_by_universal_id.notify = policy_handle_lower_by_universal_id;
3446 ds_tizen_policy_add_lower_by_universal_id_listener(policy->policy,
3447 &policy->lower_by_universal_id);
3449 policy->set_transient_for.notify = policy_handle_set_transient_for;
3450 ds_tizen_policy_add_set_transient_for_listener(policy->policy,
3451 &policy->set_transient_for);
3453 policy->unset_transient_for.notify = policy_handle_unset_transient_for;
3454 ds_tizen_policy_add_unset_transient_for_listener(policy->policy,
3455 &policy->unset_transient_for);
3457 policy->place_subsurface_below_parent.notify =
3458 policy_handle_place_subsurface_below_parent;
3459 ds_tizen_policy_add_place_subsurface_below_parent_listener(policy->policy,
3460 &policy->place_subsurface_below_parent);
3462 policy->set_subsurface_stand_alone.notify =
3463 policy_handle_set_subsurface_stand_alone;
3464 ds_tizen_policy_add_set_subsurface_stand_alone_listener(policy->policy,
3465 &policy->set_subsurface_stand_alone);
3467 policy->set_background_state.notify = policy_handle_set_background_state;
3468 ds_tizen_policy_add_set_background_state_listener(policy->policy,
3469 &policy->set_background_state);
3471 policy->unset_background_state.notify = policy_handle_unset_background_state;
3472 ds_tizen_policy_add_unset_background_state_listener(policy->policy,
3473 &policy->unset_background_state);
3475 policy->add_activate_above_by_universal_id.notify =
3476 policy_handle_add_activate_above_by_universal_id;
3477 ds_tizen_policy_add_activate_above_by_universal_id_listener(policy->policy,
3478 &policy->add_activate_above_by_universal_id);
3480 policy->set_appid.notify = policy_handle_set_appid;
3481 ds_tizen_policy_add_set_appid_listener(policy->policy, &policy->set_appid);
3483 policy->set_transient_for_below.notify =
3484 policy_handle_set_transient_for_below;
3485 ds_tizen_policy_add_set_transient_for_below_listener(policy->policy,
3486 &policy->set_transient_for_below);
3488 wl_list_init(&policy->policy_surfaces);
3490 server->policy = policy;
3492 ds_inf("Policy (%p) created", policy);