2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Weston(Wayland) IVI Shell
26 * @brief Shell for IVI(In-Vehicle Infotainment).
36 #include <linux/input.h>
40 #include <sys/types.h>
44 #include <wayland-server.h>
45 #include <weston/compositor.h>
46 #include "ico_ivi_common.h"
47 #include "ico_ivi_shell.h"
48 #include "ico_ivi_shell-server-protocol.h"
50 /* Layer management */
51 struct ivi_layer_list {
52 int layer; /* Layer.ID */
54 struct wl_list surface_list; /* Surfacae list */
55 struct wl_list link; /* Link pointer for layer list */
58 /* Static table for Shell */
61 struct weston_compositor *compositor;
62 struct wl_listener destroy_listener;
63 struct weston_layer surface; /* Surface list */
64 struct ivi_layer_list ivi_layer; /* Layer list */
65 char win_animation[ICO_WINDOW_ANIMATION_LEN];
66 /* Default animation name */
67 int win_animation_time; /* animation time(ms) */
68 int win_animation_fps; /* animation frame rate(fps) */
69 int win_visible_on_create; /* Visible on create surface */
70 struct shell_surface *active_pointer_shsurf;
71 /* Pointer active shell surface */
72 struct shell_surface *active_keyboard_shsurf;
73 /* Keyboard active shell surface*/
77 enum shell_surface_type {
78 SHELL_SURFACE_NONE, /* Surface type undefine */
79 SHELL_SURFACE_TOPLEVEL, /* Top level surface for application */
80 SHELL_SURFACE_TRANSIENT, /* Child surface */
81 SHELL_SURFACE_FULLSCREEN, /* Full screen surface */
82 SHELL_SURFACE_MAXIMIZED, /* maximum screen */
83 SHELL_SURFACE_POPUP /* pop up screen */
86 /* Shell surface table */
87 struct shell_surface {
88 struct wl_resource resource;
90 struct weston_surface *surface;
91 struct wl_listener surface_destroy_listener;
92 struct weston_surface *parent;
93 struct ivi_shell *shell;
95 enum shell_surface_type type;
96 enum shell_surface_type next_type;
108 struct ivi_layer_list *layer_list;
109 struct wl_list ivi_layer;
114 unsigned short width;
115 unsigned short height;
119 struct weston_transform transform;
120 struct weston_matrix rotation;
130 struct wl_client *wclient;
131 const struct weston_shell_client *client;
134 static struct ivi_shell *default_shell = NULL;
137 /* static function prototype */
138 static void bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id);
139 static void unbind_shell(struct wl_resource *resource);
140 static struct shell_surface *get_shell_surface(struct weston_surface *surface);
141 static struct ivi_shell *shell_surface_get_shell(struct shell_surface *shsurf);
142 static void ivi_shell_restack_ivi_layer(struct ivi_shell *shell,
143 struct shell_surface *shsurf);
145 static void (*shell_hook_bind)(struct wl_client *client) = NULL;
146 static void (*shell_hook_unbind)(struct wl_client *client) = NULL;
147 static void (*shell_hook_create)(struct wl_client *client, struct wl_resource *resource,
148 struct weston_surface *surface,
149 struct shell_surface *shsurf) = NULL;
150 static void (*shell_hook_destroy)(struct weston_surface *surface) = NULL;
151 static void (*shell_hook_map)(struct weston_surface *surface, int32_t *width,
152 int32_t *height, int32_t *sx, int32_t *sy) = NULL;
153 static void (*shell_hook_change)(struct weston_surface *surface, const int to,
154 const int manager) = NULL;
155 static void (*shell_hook_select)(struct weston_surface *surface) = NULL;
158 /*--------------------------------------------------------------------------*/
160 * @brief shell_configuration: initiale configuration ico_ivi_shell
162 * @param[in] shell ico_ivi_shell static table area
165 /*--------------------------------------------------------------------------*/
167 shell_configuration(struct ivi_shell *shell)
170 char *win_animation = NULL;
171 int win_animation_time = 800;
172 int win_animation_fps = 15;
174 struct config_key shell_keys[] = {
175 { "animation", CONFIG_KEY_STRING, &win_animation },
176 { "animation_time", CONFIG_KEY_INTEGER, &win_animation_time },
177 { "animation_fps", CONFIG_KEY_INTEGER, &win_animation_fps },
178 { "visible_on_create", CONFIG_KEY_INTEGER, &shell->win_visible_on_create },
181 struct config_section cs[] = {
182 { "shell", shell_keys, ARRAY_LENGTH(shell_keys), NULL },
185 config_fd = open_config_file(ICO_IVI_PLUGIN_CONFIG);
186 parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), shell);
190 strncpy(shell->win_animation, win_animation, sizeof(shell->win_animation)-1);
192 if (win_animation_time < 100) win_animation_time = 100;
193 shell->win_animation_time = win_animation_time;
194 if (win_animation_fps > 30) win_animation_fps = 30;
195 if (win_animation_fps < 5) win_animation_fps = 5;
196 shell->win_animation_fps = win_animation_fps;
197 uifw_info("shell_configuration: Anima=%s,%dms,%dfps Visible=%d Debug=%d",
198 shell->win_animation, shell->win_animation_time, shell->win_animation_fps,
199 shell->win_visible_on_create, ico_ivi_debuglevel());
202 /*--------------------------------------------------------------------------*/
204 * @brief send_configure: send configure(resize) event to client applicstion
206 * @param[in] surface weston surface
207 * @param[in] edges surface resize position
208 * @param[in] width surface width
209 * @param[in] height surface height
212 /*--------------------------------------------------------------------------*/
214 send_configure(struct weston_surface *surface,
215 uint32_t edges, int32_t width, int32_t height)
217 struct shell_surface *shsurf = get_shell_surface(surface);
219 uifw_trace("send_configure: %08x edges=%x w/h=%d/%d map=%d",
220 (int)shsurf->surface, edges, width, height, shsurf->mapped);
221 if (shsurf->mapped == 0) return;
223 shsurf->configure_app.width = width;
224 shsurf->configure_app.height = height;
225 wl_shell_surface_send_configure(&shsurf->resource,
226 edges, width, height);
229 static const struct weston_shell_client shell_client = {
233 /*--------------------------------------------------------------------------*/
235 * @brief reset_shell_surface_type: reset surface type
237 * @param[in] shsurf shell surface
240 /*--------------------------------------------------------------------------*/
242 reset_shell_surface_type(struct shell_surface *shsurf)
244 uifw_trace("reset_shell_surface_type: [%08x]", (int)shsurf);
245 shsurf->type = SHELL_SURFACE_NONE;
249 /*--------------------------------------------------------------------------*/
251 * @brief set_surface_type: set surface type
253 * @param[in] shsurf shell surface
256 /*--------------------------------------------------------------------------*/
258 set_surface_type(struct shell_surface *shsurf)
260 struct weston_surface *surface = shsurf->surface;
261 struct weston_surface *pes = shsurf->parent;
262 struct shell_surface *psh;
264 uifw_trace("set_surface_type: [%08x] (%08x) type=%x",
265 (int)shsurf, (int)surface, (int)shsurf->next_type);
267 reset_shell_surface_type(shsurf);
269 shsurf->type = shsurf->next_type;
270 shsurf->next_type = SHELL_SURFACE_NONE;
272 switch (shsurf->type) {
273 case SHELL_SURFACE_TOPLEVEL:
275 case SHELL_SURFACE_TRANSIENT:
276 psh = get_shell_surface(pes);
278 shsurf->geometry_x = psh->geometry_x + shsurf->transient.x;
279 shsurf->geometry_y = psh->geometry_y + shsurf->transient.y;
282 shsurf->geometry_x = pes->geometry.x + shsurf->transient.x;
283 shsurf->geometry_y = pes->geometry.y + shsurf->transient.y;
291 /*--------------------------------------------------------------------------*/
293 * @brief shell_surface_pong: recceive pong(ping reply) (NOP)
295 * @param[in] client wayland client
296 * @param[in] resource pong resource
297 * @param[in] serial event serial number
300 /*--------------------------------------------------------------------------*/
302 shell_surface_pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
304 uifw_trace("shell_surface_pong: NOP[%08x]", (int)resource->data);
307 /*--------------------------------------------------------------------------*/
309 * @brief shell_surface_move: recceive move request (NOP)
311 * @param[in] client wayland client
312 * @param[in] resource move request resource
313 * @param[in] seat_resource seat resource
314 * @param[in] serial event serial number
317 /*--------------------------------------------------------------------------*/
319 shell_surface_move(struct wl_client *client, struct wl_resource *resource,
320 struct wl_resource *seat_resource, uint32_t serial)
322 uifw_trace("shell_surface_move: [%08x] NOP", (int)resource->data);
325 /*--------------------------------------------------------------------------*/
327 * @brief shell_surface_resize: recceive resize request (NOP)
329 * @param[in] client wayland client
330 * @param[in] resource resize request resource
331 * @param[in] seat_resource seat resource
332 * @param[in] serial event serial number
333 * @param[in] edges resize position
336 /*--------------------------------------------------------------------------*/
338 shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
339 struct wl_resource *seat_resource, uint32_t serial,
342 uifw_trace("shell_surface_resize: [%08x] NOP", (int)resource->data);
345 /*--------------------------------------------------------------------------*/
347 * @brief set_toplevel: set surface to TopLevel
349 * @param[in] shsurf shell surface
352 /*--------------------------------------------------------------------------*/
354 set_toplevel(struct shell_surface *shsurf)
356 shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
359 /*--------------------------------------------------------------------------*/
361 * @brief shell_surface_set_toplevel: set surface to TopLevel(client interface)
363 * @param[in] client wayland client
364 * @param[in] resource set toplevel request resource
367 /*--------------------------------------------------------------------------*/
369 shell_surface_set_toplevel(struct wl_client *client, struct wl_resource *resource)
371 struct shell_surface *shsurf = resource->data;
373 uifw_trace("shell_surface_set_toplevel: Set TopLevel[%08x] surf=%08x",
374 (int)shsurf, (int)shsurf->surface);
376 set_toplevel(shsurf);
379 /*--------------------------------------------------------------------------*/
381 * @brief set_transient: set surface to child
383 * @param[in] shsurf shell surface
384 * @param[in] parent parent surface
385 * @param[in] x relative X position from a parent
386 * @param[in] y relative Y position from a parent
387 * @param[in] flags flag(unused)
390 /*--------------------------------------------------------------------------*/
392 set_transient(struct shell_surface *shsurf,
393 struct weston_surface *parent, int x, int y, uint32_t flags)
395 /* assign to parents output */
396 shsurf->parent = parent;
397 shsurf->transient.x = x;
398 shsurf->transient.y = y;
399 shsurf->transient.flags = flags;
400 shsurf->next_type = SHELL_SURFACE_TRANSIENT;
403 /*--------------------------------------------------------------------------*/
405 * @brief shell_surface_set_transient: set surface to child(client interface)
407 * @param[in] client wayland client
408 * @param[in] resource set transient request resource
409 * @param[in] parent_resource parent surface resource
410 * @param[in] x relative X position from a parent
411 * @param[in] y relative Y position from a parent
412 * @param[in] flags flag(unused)
415 /*--------------------------------------------------------------------------*/
417 shell_surface_set_transient(struct wl_client *client, struct wl_resource *resource,
418 struct wl_resource *parent_resource,
419 int x, int y, uint32_t flags)
421 struct shell_surface *shsurf = resource->data;
422 struct weston_surface *parent = parent_resource->data;
424 uifw_trace("shell_surface_set_transient: Set Transient[%08x] surf=%08x",
425 (int)shsurf, (int)shsurf->surface);
426 set_transient(shsurf, parent, x, y, flags);
429 /*--------------------------------------------------------------------------*/
431 * @brief shell_surface_set_fullscreen: set surface to full screen(same as toplevel)
433 * @param[in] client wayland client
434 * @param[in] resource set fullscreen request resource
435 * @param[in] method method(unused)
436 * @param[in] framerate frame rate(unused)
437 * @param[in] output_resource output resource(unused)
440 /*--------------------------------------------------------------------------*/
442 shell_surface_set_fullscreen(struct wl_client *client, struct wl_resource *resource,
443 uint32_t method, uint32_t framerate,
444 struct wl_resource *output_resource)
446 struct shell_surface *shsurf = resource->data;
447 uifw_trace("shell_surface_set_fullscreen: "
448 "NOP(same as set_toplevel)[%08x]", (int)shsurf);
449 shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
452 /*--------------------------------------------------------------------------*/
454 * @brief shell_surface_set_popup: set surface to popup(same as toplevel)
456 * @param[in] client wayland client
457 * @param[in] resource set popup request resource
458 * @param[in] seat_resource seat resource(unused)
459 * @param[in] serial event serial number(unused)
460 * @param[in] parent_resource parent resource(unused)
461 * @param[in] x relative X position from a parent(unused)
462 * @param[in] y relative Y position from a parent(unused)
463 * @param[in] flags flag(unused)
466 /*--------------------------------------------------------------------------*/
468 shell_surface_set_popup(struct wl_client *client, struct wl_resource *resource,
469 struct wl_resource *seat_resource, uint32_t serial,
470 struct wl_resource *parent_resource,
471 int32_t x, int32_t y, uint32_t flags)
473 struct shell_surface *shsurf = resource->data;
474 uifw_trace("shell_surface_set_popup: NOP(same as set_toplevel)[%08x]", (int)shsurf);
475 shsurf->next_type = SHELL_SURFACE_POPUP;
478 /*--------------------------------------------------------------------------*/
480 * @brief shell_surface_set_maximized: set surface to maximized(same as toplevel)
482 * @param[in] client wayland client
483 * @param[in] resource set maximized request resource
484 * @param[in] output_resource output resource(unused)
487 /*--------------------------------------------------------------------------*/
489 shell_surface_set_maximized(struct wl_client *client, struct wl_resource *resource,
490 struct wl_resource *output_resource )
492 struct shell_surface *shsurf = resource->data;
493 uifw_trace("shell_surface_set_maximized: NOP(same as set_toplevel)[%08x]", (int)shsurf);
494 shsurf->next_type = SHELL_SURFACE_MAXIMIZED;
497 /*--------------------------------------------------------------------------*/
499 * @brief shell_surface_set_title: set surface title
501 * @param[in] client wayland client
502 * @param[in] resource set title request resource
503 * @param[in] title surface title
506 /*--------------------------------------------------------------------------*/
508 shell_surface_set_title(struct wl_client *client,
509 struct wl_resource *resource, const char *title)
511 struct shell_surface *shsurf = resource->data;
513 uifw_trace("shell_surface_set_title: [%08x] %s", (int)shsurf, title);
518 shsurf->title = strdup(title);
521 /*--------------------------------------------------------------------------*/
523 * @brief shell_surface_set_class: set surface class name
525 * @param[in] client wayland client
526 * @param[in] resource set class request resource
527 * @param[in] class surface class name
530 /*--------------------------------------------------------------------------*/
532 shell_surface_set_class(struct wl_client *client,
533 struct wl_resource *resource, const char *class)
535 struct shell_surface *shsurf = resource->data;
537 uifw_trace("shell_surface_set_class: [%08x] %s", (int)shsurf, class);
542 shsurf->class = strdup(class);
545 /*--------------------------------------------------------------------------*/
547 * @brief shell_surface_raise: raise surface
549 * @param[in] client wayland client
550 * @param[in] resource set class request resource
553 /*--------------------------------------------------------------------------*/
555 shell_surface_raise(struct wl_client *client, struct wl_resource *resource)
557 struct shell_surface *shsurf = resource->data;
559 uifw_trace("shell_surface_raise: [%08x]", (int)shsurf);
561 ivi_shell_set_raise(shsurf, 1);
564 static const struct wl_shell_surface_interface shell_surface_implementation = {
567 shell_surface_resize,
568 shell_surface_set_toplevel,
569 shell_surface_set_transient,
570 shell_surface_set_fullscreen,
571 shell_surface_set_popup,
572 shell_surface_set_maximized,
573 shell_surface_set_title,
574 shell_surface_set_class,
578 /*--------------------------------------------------------------------------*/
580 * @brief shell_surface_get_shell: get ico_ivi_shell static table
582 * @param[in] shsurf shell surface(if NULL, return default)
583 * @return ico_ivi_shell static table address
585 /*--------------------------------------------------------------------------*/
586 static struct ivi_shell *
587 shell_surface_get_shell(struct shell_surface *shsurf)
590 return shsurf->shell;
592 return default_shell;
595 /*--------------------------------------------------------------------------*/
597 * @brief destroy_shell_surface: destroy surface
599 * @param[in] shsurf shell surface
602 /*--------------------------------------------------------------------------*/
604 destroy_shell_surface(struct shell_surface *shsurf)
606 uifw_trace("destroy_shell_surface: Enter[%08x]", (int)shsurf);
608 if (shsurf->visible != FALSE) {
609 shsurf->visible = FALSE;
610 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
613 wl_list_remove(&shsurf->ivi_layer);
615 if (shell_hook_destroy) {
616 /* call sufrace destory hook routine */
617 uifw_trace("destroy_shell_surface: call ivi_shell_hook_destroy(%08x)",
618 (int)shsurf->surface);
619 (void) (*shell_hook_destroy) (shsurf->surface);
620 uifw_trace("destroy_shell_surface: ret");
623 wl_list_remove(&shsurf->surface_destroy_listener.link);
624 shsurf->surface->configure = NULL;
626 wl_list_remove(&shsurf->link);
629 uifw_trace("destroy_shell_surface: Leave");
632 /*--------------------------------------------------------------------------*/
634 * @brief shell_destroy_shell_surface: destroy surface(client interface)
636 * @param[in] resource destroy request resource
639 /*--------------------------------------------------------------------------*/
641 shell_destroy_shell_surface(struct wl_resource *resource)
643 struct shell_surface *shsurf = resource->data;
645 uifw_trace("shell_destroy_shell_surface: Enter [%08x]", (int)shsurf);
647 destroy_shell_surface(shsurf);
649 uifw_trace("shell_destroy_shell_surface: Leave");
652 /*--------------------------------------------------------------------------*/
654 * @brief shell_handle_surface_destroy: destroy surface(listener interface)
656 * @param[in] listener listener
657 * @param[in] data user data(unused)
660 /*--------------------------------------------------------------------------*/
662 shell_handle_surface_destroy(struct wl_listener *listener, void *data)
664 struct shell_surface *shsurf = container_of(listener, struct shell_surface,
665 surface_destroy_listener);
667 uifw_trace("shell_handle_surface_destroy: Enter [%08x] data=%08x",
668 (int)shsurf, (int)data);
670 if (shsurf->resource.client) {
671 wl_resource_destroy(&shsurf->resource);
673 wl_signal_emit(&shsurf->resource.destroy_signal, &shsurf->resource);
674 destroy_shell_surface(shsurf);
676 uifw_trace("shell_handle_surface_destroy: Leave");
680 shell_surface_configure(struct weston_surface *, int32_t, int32_t);
682 /*--------------------------------------------------------------------------*/
684 * @brief get_shell_surface: get shell surface
686 * @param[in] surface weston surface
687 * @return shell surface address
689 /*--------------------------------------------------------------------------*/
690 static struct shell_surface *
691 get_shell_surface(struct weston_surface *surface)
693 if (surface->configure == shell_surface_configure)
694 return surface->private;
699 /*--------------------------------------------------------------------------*/
701 * @brief create_shell_surface: create shell surface
703 * @param[in] surface weston surface
704 * @param[in] client client
705 * @return created shell surface address
707 /*--------------------------------------------------------------------------*/
708 static struct shell_surface *
709 create_shell_surface(void *shell, struct weston_surface *surface,
710 const struct weston_shell_client *client)
712 struct shell_surface *shsurf;
714 if (surface->configure) {
715 uifw_warn("create_shell_surface: surface->configure already set");
719 shsurf = calloc(1, sizeof *shsurf);
721 uifw_error("create_shell_surface: no memory to allocate shell surface");
725 uifw_trace("create_shell_surface: (%08x) [%08x] client=%08x (visible=%d)",
726 (int)surface, (int)shsurf, (int)client,
727 ((struct ivi_shell *)shell)->win_visible_on_create);
729 surface->configure = shell_surface_configure;
730 surface->private = shsurf;
732 shsurf->shell = (struct ivi_shell *) shell;
733 shsurf->surface = surface;
734 shsurf->visible = shsurf->shell->win_visible_on_create;
736 /* set default color and shader */
737 weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
739 wl_signal_init(&shsurf->resource.destroy_signal);
740 shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
741 wl_signal_add(&surface->surface.resource.destroy_signal,
742 &shsurf->surface_destroy_listener);
744 /* init link so its safe to always remove it in destroy_shell_surface */
745 wl_list_init(&shsurf->link);
747 /* empty when not in use */
748 wl_list_init(&shsurf->rotation.transform.link);
749 weston_matrix_init(&shsurf->rotation.rotation);
751 shsurf->type = SHELL_SURFACE_NONE;
752 shsurf->next_type = SHELL_SURFACE_NONE;
754 shsurf->client = client;
756 wl_list_init(&shsurf->ivi_layer);
761 /*--------------------------------------------------------------------------*/
763 * @brief shell_get_shell_surface: create shell surface(client interface)
765 * @param[in] client client
766 * @param[in] resource get shell surface request resource
767 * @param[in] id created shell surface object id in the client
768 * @param[in] surface_resource weston surface resource
771 /*--------------------------------------------------------------------------*/
773 shell_get_shell_surface(struct wl_client *client, struct wl_resource *resource,
774 uint32_t id, struct wl_resource *surface_resource)
776 struct weston_surface *surface = surface_resource->data;
777 struct ivi_shell *shell = resource->data;
778 struct shell_surface *shsurf;
780 if (get_shell_surface(surface)) {
781 wl_resource_post_error(surface_resource,
782 WL_DISPLAY_ERROR_INVALID_OBJECT,
783 "ivi_shell::get_shell_surface already requested");
787 uifw_trace("shell_get_shell_surface: Enter (%08x) client=%08x",
788 (int)surface, (int)client);
790 shsurf = create_shell_surface(shell, surface, &shell_client);
792 wl_resource_post_error(surface_resource,
793 WL_DISPLAY_ERROR_INVALID_OBJECT,
794 "surface->configure already set");
798 shsurf->wclient = client;
799 shsurf->resource.destroy = shell_destroy_shell_surface;
800 shsurf->resource.object.id = id;
801 shsurf->resource.object.interface = &wl_shell_surface_interface;
802 shsurf->resource.object.implementation =
803 (void (**)(void)) &shell_surface_implementation;
804 shsurf->resource.data = shsurf;
806 wl_client_add_resource(client, &shsurf->resource);
808 wl_list_init(&shsurf->ivi_layer);
809 uifw_trace("shell_get_shell_surface: Init shsurf(%08x) weston_surf=%08x",
810 (int)shsurf, (int)surface);
812 if (shell_hook_create) {
813 /* call surface create hook routine */
814 uifw_trace("shell_get_shell_surface: call ivi_shell_hook_create(%08x,,%08x,%08x)",
815 (int)client, (int)surface, (int)shsurf);
816 (void) (*shell_hook_create)(client, resource, surface, shsurf);
817 uifw_trace("shell_get_shell_surface: ret ivi_shell_hook_create");
819 uifw_trace("shell_get_shell_surface: Leave");
822 static const struct wl_shell_interface shell_implementation = {
823 shell_get_shell_surface
826 /*--------------------------------------------------------------------------*/
828 * @brief weston_surface_set_initial_position: set surface initial position
830 * @param[in] surface weston surface
831 * @param[in] shell ico_ivi_shell static table address
834 /*--------------------------------------------------------------------------*/
836 weston_surface_set_initial_position(struct weston_surface *surface, struct ivi_shell *shell)
838 struct weston_output *output, *target_output;
840 if (shell->win_visible_on_create) {
841 wl_list_for_each (output, &shell->compositor->output_list, link) {
842 target_output = output;
845 if (! target_output) {
846 weston_surface_set_position(surface, (float)(10 + random() % 400),
847 (float)(10 + random() % 400));
850 int range_x = target_output->width - surface->geometry.width;
851 int range_y = target_output->height - surface->geometry.height;
852 if (range_x < 0) range_x = 400;
853 if (range_y < 0) range_y = 400;
854 weston_surface_set_position(surface, (float)(random() % range_x),
855 (float)(random() % range_y));
859 weston_surface_set_position(surface, (float)0.0, (float)0.0);
863 /*--------------------------------------------------------------------------*/
865 * @brief map: surface initial mapping to screen
867 * @param[in] shell ico_ivi_shell static table address
868 * @param[in] surface weston surface
869 * @param[in] width surface width
870 * @param[in] height surface height
871 * @param[in] sx surface upper-left X position on screen
872 * @param[in] sy surface upper-left Y position on screen
875 /*--------------------------------------------------------------------------*/
877 map(struct ivi_shell *shell, struct weston_surface *surface,
878 int32_t width, int32_t height, int32_t sx, int32_t sy)
880 struct shell_surface *shsurf = get_shell_surface(surface);
881 enum shell_surface_type surface_type = shsurf->type;
882 struct weston_surface *parent;
884 uifw_trace("map: Enter(%08x) sx/sy=%d/%d, w/h=%d/%d",
885 (int)surface, ((int)sx)/256, ((int)sy)/256, width, height);
888 surface->geometry.width = width;
889 surface->geometry.height = height;
890 shsurf->geometry_x = sx;
891 shsurf->geometry_y = sy;
892 shsurf->geometry_width = width;
893 shsurf->geometry_height = height;
894 surface->geometry.dirty = 1;
896 /* initial positioning, see also configure() */
897 switch (surface_type) {
898 case SHELL_SURFACE_TOPLEVEL:
899 weston_surface_set_initial_position(surface, shell);
900 uifw_trace("map: TopLevel x/y=%d/%d w/h=%d/%d",
901 (int)surface->geometry.x, (int)surface->geometry.y,
902 (int)surface->geometry.width, (int)surface->geometry.height);
903 shsurf->geometry_x = surface->geometry.x;
904 shsurf->geometry_x = surface->geometry.y;
906 case SHELL_SURFACE_NONE:
907 weston_surface_set_position(surface, (float)(surface->geometry.x + sx),
908 (float)(surface->geometry.y + sy));
913 if ((ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) && (shsurf->visible == FALSE)) {
914 surface->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1);
915 surface->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1);
918 switch (surface_type) {
919 case SHELL_SURFACE_TRANSIENT:
920 parent = shsurf->parent;
921 wl_list_insert(parent->layer_link.prev, &surface->layer_link);
923 case SHELL_SURFACE_NONE:
926 if (! shsurf->layer_list) {
927 ivi_shell_set_layer(shsurf, ICO_IVI_DEFAULT_LAYER);
932 if (surface_type != SHELL_SURFACE_NONE) {
933 weston_surface_update_transform(surface);
934 ivi_shell_restack_ivi_layer(shell, shsurf);
937 if (shell_hook_map) {
938 /* Surface map hook routine */
939 uifw_trace("map: call ivi_shell_hook_map(%08x, x/y=%d/%d, w/h=%d/%d)",
940 (int)surface, sx, sy, width, height);
941 (void) (*shell_hook_map) (surface, &width, &height, &sx, &sy);
942 uifw_trace("map: ret ivi_shell_hook_map(%08x, x/y=%d/%d, w/h=%d/%d)",
943 (int)surface, sx, sy, width, height);
946 if (shell_hook_change) {
947 /* Surface change hook routine */
948 uifw_trace("map: call ivi_shell_hook_change(%08x)", (int)surface);
949 (void) (*shell_hook_change)(surface, -1, 1); /* Send to Manager */
950 uifw_trace("map: ret ivi_shell_hook_change")
952 uifw_trace("map: Leave");
955 /*--------------------------------------------------------------------------*/
957 * @brief configure: surface change
959 * @param[in] shell ico_ivi_shell static table address
960 * @param[in] surface weston surface
961 * @param[in] x surface upper-left X position on screen
962 * @param[in] y surface upper-left Y position on screen
963 * @param[in] width surface width
964 * @param[in] height surface height
967 /*--------------------------------------------------------------------------*/
969 configure(struct ivi_shell *shell, struct weston_surface *surface,
970 GLfloat x, GLfloat y, int32_t width, int32_t height)
972 enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
973 struct shell_surface *shsurf;
975 shsurf = get_shell_surface(surface);
977 uifw_trace("configure: Enter(%08x) [%08x] x/y=%d/%d, w/h=%d/%d",
978 (int)surface, (int)shsurf, (int)x, (int)y, width, height);
981 surface_type = shsurf->type;
982 shsurf->geometry_x = (int)x;
983 shsurf->geometry_y = (int)y;
984 shsurf->geometry_width = width;
985 shsurf->geometry_height = height;
986 ivi_shell_surface_configure(shsurf, x, y, width, height);
989 surface->geometry.x = x;
990 surface->geometry.y = y;
991 surface->geometry.width = width;
992 surface->geometry.height = height;
993 surface->geometry.dirty = 1;
996 if (surface->output) {
997 weston_surface_update_transform(surface);
1000 uifw_trace("configure: Leave");
1003 /*--------------------------------------------------------------------------*/
1005 * @brief shell_surface_configure: shell surface change
1007 * @param[in] es weston surface
1008 * @param[in] sx surface upper-left X position on screen
1009 * @param[in] sy surface upper-left Y position on screen
1012 /*--------------------------------------------------------------------------*/
1014 shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
1016 struct shell_surface *shsurf = get_shell_surface(es);
1017 struct ivi_shell *shell = shsurf->shell;
1018 int type_changed = 0;
1021 uifw_trace("shell_surface_configure: Enter(surf=%08x out=%08x buf=%08x)",
1022 (int)es, (int)es->output, (int)es->buffer);
1024 if (shsurf->restrain) {
1025 uifw_trace("shell_surface_configure: Leave(restrain)");
1029 if (shsurf->next_type != SHELL_SURFACE_NONE &&
1030 shsurf->type != shsurf->next_type) {
1031 set_surface_type(shsurf);
1035 if (! weston_surface_is_mapped(es)) {
1036 if ((es->geometry.width > 0) && (es->geometry.height >0)) {
1037 uifw_trace("shell_surface_configure: map Surface size(sx/sy=%d/%d w/h=%d/%d)",
1038 sx, sy, es->buffer->width, es->buffer->height);
1039 map(shell, es, es->geometry.width, es->geometry.height, sx, sy);
1042 uifw_trace("shell_surface_configure: map Buffer size(sx/sy=%d/%d w/h=%d/%d)",
1043 sx, sy, es->buffer->width, es->buffer->height);
1044 map(shell, es, es->buffer->width, es->buffer->height, sx, sy);
1048 if ((shsurf->mapped == 0) && (es->buffer != NULL)) {
1049 if ((es->geometry.width > 0) && (es->geometry.height >0)) {
1050 uifw_trace("shell_surface_configure: map Surface size(sx/sy=%d/%d w/h=%d/%d)",
1051 sx, sy, es->buffer->width, es->buffer->height);
1052 map(shell, es, es->geometry.width, es->geometry.height, sx, sy);
1055 uifw_trace("shell_surface_configure: map Buffer size(sx/sy=%d/%d w/h=%d/%d)",
1056 sx, sy, es->buffer->width, es->buffer->height);
1057 map(shell, es, es->buffer->width, es->buffer->height, sx, sy);
1061 GLfloat from_x, from_y;
1064 weston_surface_to_global_float(es, 0, 0, &from_x, &from_y);
1065 weston_surface_to_global_float(es, sx, sy, &to_x, &to_y);
1067 if ((es->geometry.width <= 0) || (es->geometry.height <= 0)) {
1071 /* Surface change request from App */
1072 uifw_trace("shell_surface_configure: App request change(sx/sy=%d/%d w/h=%d/%d)",
1073 sx, sy, es->buffer->width, es->buffer->height);
1074 es->geometry.width = shsurf->geometry_width;
1075 es->geometry.height = shsurf->geometry_height;
1076 es->geometry.x = shsurf->geometry_x;
1077 es->geometry.y = shsurf->geometry_y;
1078 if (es->geometry.width > es->buffer->width) {
1079 es->geometry.width = es->buffer->width;
1080 es->geometry.x = shsurf->geometry_x +
1081 (shsurf->geometry_width - es->geometry.width)/2;
1083 if (es->geometry.height > es->buffer->height) {
1084 es->geometry.height = es->buffer->height;
1085 es->geometry.y = shsurf->geometry_y +
1086 (shsurf->geometry_height - es->geometry.height)/2;
1088 ivi_shell_surface_configure(shsurf, es->geometry.x, es->geometry.y,
1089 es->geometry.width, es->geometry.height);
1090 uifw_trace("shell_surface_configure: w/h=%d/%d->%d/%d x/y=%d/%d->%d/%d",
1091 shsurf->geometry_width, shsurf->geometry_height,
1092 es->geometry.width, es->geometry.height,
1093 shsurf->geometry_x, shsurf->geometry_y,
1094 (int)es->geometry.x, (int)es->geometry.y);
1095 num_mgr = ico_ivi_send_surface_change(es,
1096 shsurf->geometry_x + to_x -from_x,
1097 shsurf->geometry_y + to_y - from_y,
1098 es->buffer->width, es->buffer->height);
1099 uifw_trace("shell_surface_configure: ret ivi_shell_hook_change(%d)", num_mgr)
1102 /* manager not exist, change surface */
1103 uifw_trace("shell_surface_configure: configure to Buffer size(no Manager) "
1104 "x=%d+%d-%d y=%d+%d-%d",
1105 (int)es->geometry.x, (int)to_x, (int)from_x,
1106 (int)es->geometry.y, (int)to_y, (int)from_y);
1107 if ((es->geometry.x > ICO_IVI_MAX_COORDINATE) &&
1108 (es->geometry.y > ICO_IVI_MAX_COORDINATE) &&
1109 (shsurf->visible)) {
1113 configure(shell, es,
1114 es->geometry.x + to_x - from_x,
1115 es->geometry.y + to_y - from_y,
1116 es->buffer->width, es->buffer->height);
1119 uifw_trace("shell_surface_configure: Leave(surf=%08x out=%08x buf=%08x)",
1120 (int)es, (int)es->output, (int)es->buffer);
1123 /*--------------------------------------------------------------------------*/
1125 * @brief bind_shell: client bind shell
1127 * @param[in] client client(ex.HomeScreen)
1128 * @param[in] data user data(ico_ivi_shell static table address)
1129 * @param[in] version interface version number(unused)
1130 * @param[in] id client object id
1133 /*--------------------------------------------------------------------------*/
1135 bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
1137 struct ivi_shell *shell = data;
1138 struct wl_resource *resource;
1140 uifw_trace("bind_shell: client=%08x id=%d", (int)client, (int)id);
1142 resource = wl_client_add_object(client, &wl_shell_interface,
1143 &shell_implementation, id, shell);
1145 resource->destroy = unbind_shell;
1147 if (shell_hook_bind) {
1148 (*shell_hook_bind)(client);
1152 /*--------------------------------------------------------------------------*/
1154 * @brief unbind_shell: client unbind shell
1156 * @param[in] resource unbind request resource
1159 /*--------------------------------------------------------------------------*/
1161 unbind_shell(struct wl_resource *resource)
1163 uifw_trace("unbind_shell");
1165 if (shell_hook_unbind) {
1166 (*shell_hook_unbind)(resource->client);
1171 /*--------------------------------------------------------------------------*/
1173 * @brief unbind_ivi_shell: client unbind ico_ivi_shell
1175 * @param[in] resource unbind request resource
1178 /*--------------------------------------------------------------------------*/
1180 unbind_ivi_shell(struct wl_resource *resource)
1182 uifw_trace("unbind_ivi_shell");
1186 /*--------------------------------------------------------------------------*/
1188 * @brief bind_ivi_shell: client bind ico_ivi_shell
1190 * @param[in] client client(ex.HomeScreen)
1191 * @param[in] data user data(ico_ivi_shell static table address)
1192 * @param[in] version interface version number(unused)
1193 * @param[in] id client object id
1196 /*--------------------------------------------------------------------------*/
1198 bind_ivi_shell(struct wl_client *client,
1199 void *data, uint32_t version, uint32_t id)
1201 struct ivi_shell *shell = data;
1202 struct wl_resource *resource;
1204 resource = wl_client_add_object(client, &ico_ivi_shell_interface,
1207 uifw_trace("bind_ivi_shell: client=%08x id=%d", (int)client, (int)id);
1209 resource->destroy = unbind_ivi_shell;
1212 /*--------------------------------------------------------------------------*/
1214 * @brief shell_destroy: destroy ico_ivi_shell
1216 * @param[in] listener shell destroy listener
1217 * @param[in] data user data(unused)
1220 /*--------------------------------------------------------------------------*/
1222 shell_destroy(struct wl_listener *listener, void *data)
1224 struct ivi_shell *shell =
1225 container_of(listener, struct ivi_shell, destroy_listener);
1227 uifw_trace("shell_destroy");
1232 /*--------------------------------------------------------------------------*/
1234 * @brief ivi_shell_restack_ivi_layer: rebuild compositor surface list
1236 * @param[in] shell ico_ivi_shell static table address
1237 * @param[in] shsurf target shell surface(if NULL, no need change surface)
1240 /*--------------------------------------------------------------------------*/
1242 ivi_shell_restack_ivi_layer(struct ivi_shell *shell, struct shell_surface *shsurf)
1244 struct shell_surface *es;
1245 struct ivi_layer_list *el;
1248 uifw_trace("ivi_shell_restack_ivi_layer: Enter[%08x]", (int)shsurf);
1250 /* make compositor surface list */
1251 wl_list_init(&shell->surface.surface_list);
1252 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1253 if (ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) {
1254 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1255 if (es->surface != NULL) {
1256 if ((el->visible == FALSE) || (es->visible == FALSE)) {
1257 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1258 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1260 else if (es->surface->buffer) {
1261 if (es->geometry_width > es->surface->buffer->width) {
1262 new_x = (float)(es->geometry_x +
1263 (es->geometry_width - es->surface->geometry.width)/2);
1266 new_x = (float)es->geometry_x;
1268 if (es->geometry_height > es->surface->buffer->height) {
1269 new_y = (float) (es->geometry_y +
1270 (es->geometry_height - es->surface->geometry.height)/2);
1273 new_y = (float)es->geometry_y;
1277 new_x = (float)(ICO_IVI_MAX_COORDINATE+1);
1278 new_y = (float)(ICO_IVI_MAX_COORDINATE+1);
1280 wl_list_insert(shell->surface.surface_list.prev,
1281 &es->surface->layer_link);
1282 if ((new_x != es->surface->geometry.x) ||
1283 (new_y != es->surface->geometry.y)) {
1284 weston_surface_damage_below(es->surface);
1285 es->surface->geometry.x = new_x;
1286 es->surface->geometry.y = new_y;
1287 weston_surface_damage_below(es->surface);
1293 if (el->visible != FALSE) {
1294 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1295 if ((es->visible != FALSE) && (es->surface) &&
1296 (es->surface->output != NULL) &&
1297 (es->surface->shader != NULL)) {
1298 wl_list_insert(shell->surface.surface_list.prev,
1299 &es->surface->layer_link);
1306 /* damage(redraw) target surfacem if target exist */
1308 weston_surface_damage_below(shsurf->surface);
1311 /* composit and draw screen(plane) */
1312 weston_compositor_schedule_repaint(shell->compositor);
1314 uifw_trace("ivi_shell_restack_ivi_layer: Leave");
1317 /*--------------------------------------------------------------------------*/
1319 * @brief ivi_shell_set_active: surface active control
1321 * @param[in] shsurf shell surface(if NULL, no active surface)
1322 * @param[in] target target device
1325 /*--------------------------------------------------------------------------*/
1327 ivi_shell_set_active(struct shell_surface *shsurf, const int target)
1329 struct ivi_shell *shell;
1330 struct weston_seat *seat;
1331 struct weston_surface *surface;
1332 int object = target;
1335 uifw_trace("ivi_shell_set_active: Enter(%08x,%x)", (int)shsurf, target);
1338 shell = shell_surface_get_shell(shsurf);
1339 surface = shsurf->surface;
1342 if (shell->active_pointer_shsurf == shsurf) {
1343 object |= ICO_IVI_SHELL_ACTIVE_POINTER;
1345 if (shell->active_keyboard_shsurf == shsurf) {
1346 object |= ICO_IVI_SHELL_ACTIVE_KEYBOARD;
1350 if (object & ICO_IVI_SHELL_ACTIVE_POINTER) {
1351 shell->active_pointer_shsurf = shsurf;
1353 if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) {
1354 shell->active_keyboard_shsurf = shsurf;
1359 shell = default_shell;
1362 object = ICO_IVI_SHELL_ACTIVE_POINTER|ICO_IVI_SHELL_ACTIVE_KEYBOARD;
1364 if (object & ICO_IVI_SHELL_ACTIVE_POINTER) {
1365 shell->active_pointer_shsurf = NULL;
1367 if (object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) {
1368 shell->active_keyboard_shsurf = NULL;
1372 wl_list_for_each(seat, &shell->compositor->seat_list, link) {
1373 if ((object & ICO_IVI_SHELL_ACTIVE_POINTER) && (seat->seat.pointer)) {
1375 uifw_trace("ivi_shell_set_active: pointer set surface(%08x=>%08x)",
1376 (int)seat->seat.pointer->focus, (int)&surface->surface);
1377 if (seat->seat.pointer->focus != &surface->surface) {
1378 weston_surface_from_global_fixed(surface,
1379 seat->seat.pointer->x,
1380 seat->seat.pointer->y,
1382 wl_pointer_set_focus(seat->seat.pointer, &surface->surface, sx, sy);
1386 uifw_trace("ivi_shell_set_active: pointer reset surface(%08x)",
1387 (int)seat->seat.pointer->focus);
1388 wl_pointer_set_focus(seat->seat.pointer, NULL,
1389 wl_fixed_from_int(0), wl_fixed_from_int(0));
1392 if ((object & ICO_IVI_SHELL_ACTIVE_KEYBOARD) && (seat->has_keyboard)) {
1394 uifw_trace("ivi_shell_set_active: keyboard set surface(%08x=>%08x)",
1395 (int)seat->seat.keyboard->focus, (int)&surface->surface);
1396 if (seat->seat.keyboard->focus != &surface->surface) {
1397 wl_keyboard_set_focus(seat->seat.keyboard, &surface->surface);
1401 uifw_trace("ivi_shell_set_active: keyboard reset surface(%08x)",
1402 (int)seat->seat.keyboard);
1403 wl_keyboard_set_focus(seat->seat.keyboard, NULL);
1407 uifw_trace("ivi_shell_set_active: seat[%08x] has no keyboard", (int)seat);
1410 uifw_trace("ivi_shell_set_active: Leave(%08x)", (int)shsurf);
1413 /*--------------------------------------------------------------------------*/
1415 * @brief ivi_shell_set_client_attr : set client ttribute
1417 * @param[in] client target client
1418 * @param[in] attr attribute
1419 * @param[in] value attribute value
1422 /*--------------------------------------------------------------------------*/
1424 ivi_shell_set_client_attr(struct wl_client *client, const int attr, const int value)
1426 struct shell_surface *es;
1427 struct ivi_layer_list *el;
1429 uifw_trace("ivi_shell_set_client_attr: Enter(%08x,%d,%d)", (int)client, attr, value);
1431 wl_list_for_each (el, &default_shell->ivi_layer.link, link) {
1432 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1433 if (es->wclient == client) {
1435 case ICO_CLEINT_ATTR_NOCONFIGURE:
1436 es->noconfigure = value;
1437 uifw_trace("ivi_shell_set_client_attr: set surface %08x", (int)es);
1445 uifw_trace("ivi_shell_set_client_attr: Leave");
1448 /*--------------------------------------------------------------------------*/
1450 * @brief ivi_shell_set_active: surface active control
1452 * @param[in] shsurf shell surface(if NULL, no active surface)
1453 * @param[in] restrain restrain(1)/not restrain(0)
1456 /*--------------------------------------------------------------------------*/
1458 ivi_shell_restrain_configure(struct shell_surface *shsurf, const int restrain)
1460 uifw_trace("ivi_shell_restrain_configure: set %08x to %d",
1461 (int)shsurf, restrain);
1462 shsurf->restrain = restrain;
1464 if (restrain == 0) {
1465 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
1469 /*--------------------------------------------------------------------------*/
1471 * @brief ivi_shell_default_animation: window default animation
1473 * @param[out] msec animation time(ms)
1474 * @param[out] fps animation frame rate(fps)
1475 * @return default animation name
1477 /*--------------------------------------------------------------------------*/
1478 WL_EXPORT const char *
1479 ivi_shell_default_animation(int *msec, int *fps)
1482 *msec = default_shell->win_animation_time;
1485 *fps = default_shell->win_animation_fps;
1487 return default_shell->win_animation;
1490 /*--------------------------------------------------------------------------*/
1492 * @brief click_to_activate_binding: clieck and select surface
1494 * @param[in] seat clicked target seat
1495 * @param[in] button click button(unused)
1496 * @param[in] data user data(ico_ivi_shell static table address)
1499 /*--------------------------------------------------------------------------*/
1501 click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
1503 struct ivi_shell *shell = data;
1504 struct shell_surface *shsurf;
1505 struct weston_surface *surface;
1507 if ((! seat) || (! seat->pointer) || (! seat->pointer->focus)) {
1508 uifw_trace("click_to_activate_binding: Surface dose not exist");
1511 surface = (struct weston_surface *) seat->pointer->focus;
1512 shsurf = get_shell_surface(surface);
1514 uifw_trace("click_to_activate_binding: Shell surface dose not exist");
1516 else if ((shsurf->type == SHELL_SURFACE_NONE) ||
1517 (shsurf->visible == 0)) {
1518 uifw_trace("click_to_activate_binding: Surface[%08x] is not visible",
1521 else if (shell->active_pointer_shsurf != shsurf) {
1522 if (shell_hook_select) {
1523 /* surface select hook routine */
1524 uifw_trace("click_to_activate_binding: call ivi_shell_hook_select[%08x]",
1526 (void) (*shell_hook_select)(surface);
1527 uifw_trace("click_to_activate_binding: ret ivi_shell_hook_select")
1530 ivi_shell_set_active(shsurf,
1531 ICO_IVI_SHELL_ACTIVE_POINTER |
1532 ICO_IVI_SHELL_ACTIVE_KEYBOARD);
1533 uifw_trace("click_to_activate_binding: no hook[%08x]", (int)shsurf);
1537 uifw_trace("click_to_activate_binding: ShellSurface[%08x] already active",
1543 /*--------------------------------------------------------------------------*/
1545 * @brief ivi_shell_set_visible: surface visible control
1547 * @param[in] shsurf shell surface
1548 * @param[in] visible visibility(1=visible/0=unvisible)
1551 /*--------------------------------------------------------------------------*/
1553 ivi_shell_set_visible(struct shell_surface *shsurf, const int visible)
1555 struct ivi_shell *shell = shell_surface_get_shell(shsurf);
1558 uifw_trace("ivi_shell_set_visible: [%08x] visible=%d", (int)shsurf, (int)visible);
1561 next = shell->win_visible_on_create;
1567 if ((shsurf->visible != FALSE) && (next == 0)) {
1568 /* change show ==> hide */
1569 shsurf->visible = FALSE;
1570 ivi_shell_restack_ivi_layer(shell, shsurf);
1572 else if ((shsurf->visible == FALSE) && (next != 0)) {
1573 /* change hide ==> show */
1574 shsurf->visible = TRUE;
1575 ivi_shell_restack_ivi_layer(shell, shsurf);
1578 /* other case, no change */
1579 uifw_trace("ivi_shell_set_visible: No change");
1583 /*--------------------------------------------------------------------------*/
1585 * @brief ivi_shell_is_visible: get surface visibility
1587 * @param[in] shsurf shell surface
1588 * @return visibility
1589 * @retval true visible
1590 * @retval false unvisible
1592 /*--------------------------------------------------------------------------*/
1594 ivi_shell_is_visible(struct shell_surface *shsurf)
1596 return(shsurf->visible);
1599 /*--------------------------------------------------------------------------*/
1601 * @brief ivi_shell_set_layer: set(or change) surface layer
1603 * @param[in] shsurf shell surface
1604 * @param[in] layer layer id
1607 /*--------------------------------------------------------------------------*/
1609 ivi_shell_set_layer(struct shell_surface *shsurf, const int layer)
1611 struct ivi_shell *shell;
1612 struct ivi_layer_list *el;
1613 struct ivi_layer_list *new_el;
1615 uifw_trace("ivi_shell_set_layer: Enter([%08x],%08x,%d)",
1616 (int)shsurf, (int)shsurf->surface, layer);
1618 shell = shell_surface_get_shell(shsurf);
1620 /* check if same layer */
1621 if ((shsurf->layer_list != NULL) && (shsurf->layer_list->layer == layer)) {
1622 uifw_trace("ivi_shell_set_layer: Leave(Same Layer)");
1626 /* search existing layer */
1627 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1628 uifw_trace("ivi_shell_set_layer: el=%08x(%d)", (int)el, el->layer);
1629 if (el->layer == layer) break;
1632 if (&el->link == &shell->ivi_layer.link) {
1633 /* layer not exist, create new layer */
1634 uifw_trace("ivi_shell_set_layer: New Layer %d", layer);
1635 new_el = malloc(sizeof(struct ivi_layer_list));
1637 uifw_trace("ivi_shell_set_layer: Leave(No Memory)");
1641 memset(new_el, 0, sizeof(struct ivi_layer_list));
1642 new_el->layer = layer;
1643 new_el->visible = TRUE;
1644 wl_list_init(&new_el->surface_list);
1645 wl_list_init(&new_el->link);
1647 wl_list_remove(&shsurf->ivi_layer);
1648 wl_list_insert(&new_el->surface_list, &shsurf->ivi_layer);
1649 shsurf->layer_list = new_el;
1651 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1652 if (layer >= el->layer) break;
1654 if (&el->link == &shell->ivi_layer.link) {
1655 wl_list_insert(shell->ivi_layer.link.prev, &new_el->link);
1658 wl_list_insert(el->link.prev, &new_el->link);
1662 uifw_trace("ivi_shell_set_layer: Add surface to Layer %d", layer);
1663 wl_list_remove(&shsurf->ivi_layer);
1664 wl_list_insert(&el->surface_list, &shsurf->ivi_layer);
1665 shsurf->layer_list = el;
1668 /* rebild compositor surface list */
1669 ivi_shell_restack_ivi_layer(shell, shsurf);
1671 uifw_trace("ivi_shell_set_layer: Leave");
1674 /*--------------------------------------------------------------------------*/
1676 * @brief ivi_shell_set_raise: surface stack control
1678 * @param[in] shsurf shell surface
1679 * @param[in] raise raise/lower(1=raise/0=lower)
1682 /*--------------------------------------------------------------------------*/
1684 ivi_shell_set_raise(struct shell_surface *shsurf, const int raise)
1686 uifw_trace("ivi_shell_set_raise: Enter(%08x,%d) layer_list=%08x",
1687 (int)shsurf->surface, raise, (int)shsurf->layer_list);
1689 wl_list_remove(&shsurf->ivi_layer);
1691 /* raise ... surface stack to top of layer */
1692 wl_list_insert(&shsurf->layer_list->surface_list, &shsurf->ivi_layer);
1693 uifw_trace("ivi_shell_set_raise: Raise Link to Top");
1696 /* Lower ... surface stack to bottom of layer */
1697 wl_list_insert(shsurf->layer_list->surface_list.prev, &shsurf->ivi_layer);
1698 uifw_trace("ivi_shell_set_raise: Lower Link to Bottom");
1701 /* rebild compositor surface list */
1702 ivi_shell_restack_ivi_layer(shell_surface_get_shell(shsurf), shsurf);
1704 uifw_trace("ivi_shell_set_raise: Leave");
1707 /*--------------------------------------------------------------------------*/
1709 * @brief ivi_shell_set_toplevel: set surface type toplevel
1711 * @param[in] shsurf shell surface
1714 /*--------------------------------------------------------------------------*/
1716 ivi_shell_set_toplevel(struct shell_surface *shsurf)
1718 uifw_trace("ivi_shell_set_toplevel: (%08x)", (int)shsurf->surface);
1719 set_toplevel(shsurf);
1722 /*--------------------------------------------------------------------------*/
1724 * @brief ivi_shell_set_surface_type: set surface type
1726 * @param[in] shsurf shell surface
1729 /*--------------------------------------------------------------------------*/
1731 ivi_shell_set_surface_type(struct shell_surface *shsurf)
1733 uifw_trace("ivi_shell_set_surfacetype: (%08x)", (int)shsurf->surface);
1734 set_surface_type(shsurf);
1737 /*--------------------------------------------------------------------------*/
1739 * @brief ivi_shell_send_configure: send surface resize event
1741 * @param[in] shsurf shell surface
1742 * @param[in] id client object id(unused)
1743 * @param[in] edges surface resize position
1744 * @param[in] width surface width
1745 * @param[in] height surface height
1748 /*--------------------------------------------------------------------------*/
1750 ivi_shell_send_configure(struct shell_surface *shsurf, const int id,
1751 const int edges, const int width, const int height)
1753 /* send cgange event to manager */
1754 uifw_trace("ivi_shell_send_configure: (%08x) edges=%x w/h=%d/%d map=%d",
1755 (int)shsurf->surface, edges, width, height, shsurf->mapped);
1757 shsurf->geometry_width = width;
1758 shsurf->geometry_height = height;
1760 if ((shsurf->mapped == 0) || (shsurf->noconfigure != 0) ||
1761 (width == 0) || (height == 0)) {
1765 /* send cgange event to application */
1766 uifw_trace("ivi_shell_send_configure: Send (%08x) w/h=%d/%d(old=%d/%d)",
1767 (int)shsurf->surface, width, height,
1768 shsurf->configure_app.width, shsurf->configure_app.height);
1769 shsurf->configure_app.width = width;
1770 shsurf->configure_app.height = height;
1772 wl_shell_surface_send_configure(&shsurf->resource,
1773 WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,
1777 /*--------------------------------------------------------------------------*/
1779 * @brief ivi_shell_set_positionsize: set surface position and size
1781 * @param[in] shsurf shell surface
1782 * @param[in] x surface upper-left X position on screen
1783 * @param[in] y surface upper-left Y position on screen
1784 * @param[in] width surface width
1785 * @param[in] height surface height
1788 /*--------------------------------------------------------------------------*/
1790 ivi_shell_set_positionsize(struct shell_surface *shsurf,
1791 const int x, const int y, const int width, const int height)
1793 shsurf->geometry_x = x;
1794 shsurf->geometry_y = y;
1795 shsurf->geometry_width = width;
1796 shsurf->geometry_height = height;
1798 weston_compositor_schedule_repaint(shell_surface_get_shell(shsurf)->compositor);
1801 /*--------------------------------------------------------------------------*/
1803 * @brief ivi_shell_set_layer_visible: layer visible control
1805 * @param[in] layer layer id
1806 * @param[in] visible visibility(1=visible/0=unvisible)
1809 /*--------------------------------------------------------------------------*/
1811 ivi_shell_set_layer_visible(const int layer, const int visible)
1813 struct ivi_shell *shell;
1814 struct ivi_layer_list *el;
1815 struct ivi_layer_list *new_el;
1816 struct shell_surface *es;
1818 uifw_trace("ivi_shell_set_layer_visible: Enter(layer=%d, visible=%d)", layer, visible);
1820 shell = shell_surface_get_shell(NULL);
1823 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1824 if (el->layer == layer) break;
1827 if (&el->link == &shell->ivi_layer.link) {
1828 /* layer not exist, create new layer */
1829 uifw_trace("ivi_shell_set_layer_visible: New Layer %d", layer);
1830 new_el = malloc(sizeof(struct ivi_layer_list));
1832 uifw_trace("ivi_shell_set_layer_visible: Leave(No Memory)");
1836 memset(new_el, 0, sizeof(struct ivi_layer_list));
1837 new_el->layer = layer;
1838 new_el->visible = TRUE;
1839 wl_list_init(&new_el->surface_list);
1840 wl_list_init(&new_el->link);
1842 wl_list_for_each (el, &shell->ivi_layer.link, link) {
1843 if (layer >= el->layer) break;
1845 if (&el->link == &shell->ivi_layer.link) {
1846 wl_list_insert(shell->ivi_layer.link.prev, &new_el->link);
1849 wl_list_insert(el->link.prev, &new_el->link);
1851 uifw_trace("ivi_shell_set_layer_visible: Leave(new layer)");
1855 /* control all surface in layer */
1856 if ((el->visible != FALSE) && (visible == 0)) {
1857 /* layer change to NOT visible */
1858 uifw_trace("ivi_shell_set_layer_visible: change to not visible");
1859 el->visible = FALSE;
1861 else if ((el->visible == FALSE) && (visible != 0)) {
1862 /* layer change to visible */
1863 uifw_trace("ivi_shell_set_layer_visible: change to visible");
1868 uifw_trace("ivi_shell_set_layer_visible: Leave(no Change %d=>%d)",
1869 el->visible, visible);
1873 /* set damege area */
1874 wl_list_for_each (es, &el->surface_list, ivi_layer) {
1875 if ((es->visible != FALSE) &&
1876 (es->surface->output != NULL) &&
1877 (es->surface->shader != NULL)) {
1878 /* Damage(redraw) target surface */
1879 weston_surface_damage_below(es->surface);
1883 /* rebild compositor surface list */
1884 ivi_shell_restack_ivi_layer(shell, NULL);
1886 uifw_trace("ivi_shell_set_layer_visible: Leave");
1889 /*--------------------------------------------------------------------------*/
1891 * @brief ivi_shell_surface_configure: surface change
1893 * @param[in] shsurf shell surface
1894 * @param[in] x surface upper-left X position on screen
1895 * @param[in] y surface upper-left Y position on screen
1896 * @param[in] width surface width
1897 * @param[in] height surface height
1900 /*--------------------------------------------------------------------------*/
1902 ivi_shell_surface_configure(struct shell_surface *shsurf, const int x,
1903 const int y, const int width, const int height)
1905 int set_unvisible = 0;
1907 if (ico_option_flag() & ICO_OPTION_FLAG_UNVISIBLE) {
1908 if ((shsurf->surface != NULL) && (shsurf->surface->buffer != NULL) &&
1909 (shsurf->surface->output != NULL) && (shsurf->surface->shader != NULL)) {
1910 if ((shsurf->visible == FALSE) ||
1911 ((shsurf->layer_list != NULL) &&
1912 (shsurf->layer_list->visible == FALSE))) {
1917 if (set_unvisible) {
1918 uifw_trace("ivi_shell_surface_configure: %08x %d,%d(%d/%d) unvisible",
1919 (int)shsurf, x, y, width, height);
1920 weston_surface_configure(shsurf->surface,
1921 ICO_IVI_MAX_COORDINATE+1, ICO_IVI_MAX_COORDINATE+1,
1925 uifw_trace("ivi_shell_surface_configure: %08x %d,%d(%d/%d) visible",
1926 (int)shsurf, x, y, width, height);
1927 weston_surface_configure(shsurf->surface, x, y, width, height);
1931 /*--------------------------------------------------------------------------*/
1933 * @brief ivi_shell_hook_bind: regist hook function for shell bind
1935 * @param[in] hook_bind hook function(if NULL, reset hook function)
1938 /*--------------------------------------------------------------------------*/
1940 ivi_shell_hook_bind(void (*hook_bind)(struct wl_client *client))
1942 uifw_trace("ivi_shell_hook_bind: Hook %08x", (int)hook_bind);
1943 shell_hook_bind = hook_bind;
1946 /*--------------------------------------------------------------------------*/
1948 * @brief ivi_shell_hook_unbind: regist hook function for shell unbind
1950 * @param[in] hook_unbind hook function(if NULL, reset hook function)
1953 /*--------------------------------------------------------------------------*/
1955 ivi_shell_hook_unbind(void (*hook_unbind)(struct wl_client *client))
1957 uifw_trace("ivi_shell_hook_unbind: Hook %08x", (int)hook_unbind);
1958 shell_hook_unbind = hook_unbind;
1961 /*--------------------------------------------------------------------------*/
1963 * @brief ivi_shell_hook_create: regist hook function for create shell surface
1965 * @param[in] hook_create hook function(if NULL, reset hook function)
1968 /*--------------------------------------------------------------------------*/
1970 ivi_shell_hook_create(void (*hook_create)(struct wl_client *client,
1971 struct wl_resource *resource, struct weston_surface *surface,
1972 struct shell_surface *shsurf))
1974 uifw_trace("ivi_shell_hook_create: Hook %08x", (int)hook_create);
1975 shell_hook_create = hook_create;
1978 /*--------------------------------------------------------------------------*/
1980 * @brief ivi_shell_hook_destroy: regist hook function for destroy shell surface
1982 * @param[in] hook_destroy hook function(if NULL, reset hook function)
1985 /*--------------------------------------------------------------------------*/
1987 ivi_shell_hook_destroy(void (*hook_destroy)(struct weston_surface *surface))
1989 uifw_trace("ivi_shell_hook_destroy: Hook %08x", (int)hook_destroy);
1990 shell_hook_destroy = hook_destroy;
1993 /*--------------------------------------------------------------------------*/
1995 * @brief ivi_shell_hook_map: regist hook function for map shell surface
1997 * @param[in] hook_map hook function(if NULL, reset hook function)
2000 /*--------------------------------------------------------------------------*/
2002 ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface,
2003 int32_t *width, int32_t *height, int32_t *sx, int32_t *sy))
2005 uifw_trace("ivi_shell_hook_map: Hook %08x", (int)hook_map);
2006 shell_hook_map = hook_map;
2009 /*--------------------------------------------------------------------------*/
2011 * @brief ivi_shell_hook_change: regist hook function for change shell surface
2013 * @param[in] hook_change hook function(if NULL, reset hook function)
2016 /*--------------------------------------------------------------------------*/
2018 ivi_shell_hook_change(void (*hook_change)(struct weston_surface *surface,
2019 const int to, const int manager))
2021 uifw_trace("ivi_shell_hook_change: Hook %08x", (int)hook_change);
2022 shell_hook_change = hook_change;
2025 /*--------------------------------------------------------------------------*/
2027 * @brief ivi_shell_hook_select: regist hook function for select(active) shell surface
2029 * @param[in] hook_select hook function(if NULL, reset hook function)
2032 /*--------------------------------------------------------------------------*/
2034 ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface))
2036 uifw_trace("ivi_shell_hook_select: Hook %08x", (int)hook_select);
2037 shell_hook_select = hook_select;
2040 /*--------------------------------------------------------------------------*/
2042 * @brief module_init: initialize ico_ivi_shell
2043 * this function called from ico_pluign_loader
2045 * @param[in] es weston compositor
2050 /*--------------------------------------------------------------------------*/
2052 module_init(struct weston_compositor *ec)
2054 struct ivi_shell *shell;
2056 uifw_info("ico_ivi_shell: Enter(module_init)");
2058 shell = malloc(sizeof *shell);
2059 if (shell == NULL) return -1;
2060 default_shell = shell;
2062 memset(shell, 0, sizeof *shell);
2063 shell->compositor = ec;
2065 shell->destroy_listener.notify = shell_destroy;
2066 wl_signal_add(&ec->destroy_signal, &shell->destroy_listener);
2067 ec->shell_interface.shell = shell;
2068 ec->shell_interface.create_shell_surface = create_shell_surface;
2069 ec->shell_interface.set_toplevel = set_toplevel;
2070 ec->shell_interface.set_transient = set_transient;
2072 wl_list_init(&shell->ivi_layer.link);
2073 weston_layer_init(&shell->surface, &ec->cursor_layer.link);
2075 uifw_trace("ico_ivi_shell: shell(%08x) ivi_layer.link.%08x=%08x/%08x",
2076 (int)shell, (int)&shell->ivi_layer.link,
2077 (int)shell->ivi_layer.link.next, (int)shell->ivi_layer.link.prev);
2079 shell_configuration(shell);
2081 if (wl_display_add_global(ec->wl_display, &wl_shell_interface, shell, bind_shell)
2085 if (wl_display_add_global(ec->wl_display, &ico_ivi_shell_interface,
2086 shell, bind_ivi_shell) == NULL) {
2090 weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
2091 click_to_activate_binding, shell);
2093 uifw_info("ico_ivi_shell: Leave(module_init)");