diff options
28 files changed, 6725 insertions, 755 deletions
diff --git a/ico-uxf-weston-plugin.manifest b/ico-uxf-weston-plugin.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/ico-uxf-weston-plugin.manifest @@ -0,0 +1,5 @@ +<manifest> + <request> + <domain name="_"/> + </request> +</manifest> diff --git a/packaging/ico-uxf-weston-plugin.changes b/packaging/ico-uxf-weston-plugin.changes index ccb988d..59e312b 100644 --- a/packaging/ico-uxf-weston-plugin.changes +++ b/packaging/ico-uxf-weston-plugin.changes @@ -1,3 +1,12 @@ +* Wed Dec 25 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20131122.001017@2122c69 +- 0.9.11 release. +-- bug fix: A ivi cursor layer may pick up a touch event. +-- bug fix: TIVI-1997 - Touch doesn't work in ico homescreen after some operations +-- bug fix: TIVI-2244 - ico-uxf-weston-plugin depends on mesa/intel DRI +-- bug fix: TIVI-2256 - Weston gonna crash when launching some apps +-- revise: Correspondence to version up of Wayland 1.3.0 and Weston 1.3.1. +-- revise: add manifest file for SMACK label setting. + * Wed Nov 06 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20131010.203258@58015fa - 0.9.07 release. -- fix for: TIVI-1758 - Weston VKB is not stable for MiniBrowser diff --git a/packaging/ico-uxf-weston-plugin.spec b/packaging/ico-uxf-weston-plugin.spec index e57a324..a64b0e2 100644 --- a/packaging/ico-uxf-weston-plugin.spec +++ b/packaging/ico-uxf-weston-plugin.spec @@ -1,13 +1,13 @@ Name: ico-uxf-weston-plugin Summary: Weston Plugins for IVI -Version: 0.9.07 -Release: 1.1 +Version: 0.9.11 +Release: 2.1 Group: Graphics & UI Framework/Automotive UI License: MIT URL: "" Source0: %{name}-%{version}.tar.bz2 -BuildRequires: pkgconfig(weston) >= 1.3 +BuildRequires: pkgconfig(weston) >= 1.3.0 BuildRequires: pkgconfig(pixman-1) BuildRequires: pkgconfig(xkbcommon) >= 0.0.578 BuildRequires: pkgconfig(eina) @@ -18,7 +18,7 @@ BuildRequires: pkgconfig(ecore-wayland) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(ecore) BuildRequires: mesa-devel -Requires: weston >= 1.3 +Requires: weston >= 1.3.0 Requires: weekeyboard %description @@ -54,6 +54,7 @@ install -m 0644 settings/weston.ini %{buildroot}%{weston_conf} %postun -p /sbin/ldconfig %files +%manifest %{name}.manifest %defattr(-,root,root,-) %license COPYING %dir %{_libdir}/weston/ @@ -62,11 +63,13 @@ install -m 0644 settings/weston.ini %{buildroot}%{weston_conf} %{weston_conf}/weston.ini %files devel +%manifest %{name}.manifest %defattr(-,root,root,-) %{_includedir}/%{name}/desktop-shell-client-protocol.h %{_includedir}/%{name}/input-method-client-protocol.h %{_includedir}/%{name}/workspaces-client-protocol.h %{_includedir}/%{name}/ico_input_mgr-client-protocol.h %{_includedir}/%{name}/ico_window_mgr-client-protocol.h +%{_includedir}/%{name}/ico_window_mgr.h %{_includedir}/%{name}/ico_input_mgr.h %{_libdir}/libico-uxf-weston-plugin.so diff --git a/protocol/ico_input_mgr.xml b/protocol/ico_input_mgr.xml index 6e4c993..a9cbdc6 100644 --- a/protocol/ico_input_mgr.xml +++ b/protocol/ico_input_mgr.xml @@ -6,6 +6,15 @@ to Multi Input Manager from HomeScreen. </description> + <enum name="touch_event"> + <description summary="touch event code"> + Declare touch event code for send_input_event. + </description> + <entry name="up" value="0" summary="touch up event"/> + <entry name="down" value="1" summary="touch down event"/> + <entry name="reset" value="9" summary="reset touch focus"/> + </enum> + <request name="add_input_app"> <description summary="assign input switch to application"> Assign input switch to application from HomeScreen. @@ -126,7 +135,8 @@ </description> <entry name="add" value="1" summary="add input region"/> <entry name="remove" value="2" summary="remove input region"/> - <entry name="removeall" value="4" summary="remove all input region"/> + <entry name="change" value="4" summary="change surface"/> + <entry name="removeall" value="8" summary="remove all input region"/> </enum> <request name="configure_input"> diff --git a/protocol/ico_window_mgr.xml b/protocol/ico_window_mgr.xml index a77d10f..65e47fc 100644 --- a/protocol/ico_window_mgr.xml +++ b/protocol/ico_window_mgr.xml @@ -72,6 +72,7 @@ </description> <entry name="egl" value="1" summary="EGL buffer"/> <entry name="shm" value="2" summary="wl_shm_buffer"/> + <entry name="pixel" value="4" summary="glReadPixels image"/> </enum> <enum name="map_surface_event"> @@ -208,6 +209,15 @@ <arg name="pid" type="int"/> </request> + <request name="set_map_buffer"> + <description summary="set shared memory surfaces image buffer"> + Set shared memory surfaces image buffer. + </description> + <arg name="shmname" type="string"/> + <arg name="bufsize" type="uint"/> + <arg name="bufnum" type="uint"/> + </request> + <request name="map_surface"> <description summary="shared surfaces to system application"> Shared surfaces to system application(ex.HomeScreen). diff --git a/settings/weston.ini b/settings/weston.ini index 237a75a..48d3b1d 100644 --- a/settings/weston.ini +++ b/settings/weston.ini @@ -1,9 +1,13 @@ [core] +shell= modules=ico_plugin_loader.so [shell] num-workspaces=1 shell-exe= +locking=false +animation=zoom +startup-animation=fade [input-method] path=/bin/weekeyboard @@ -49,14 +53,22 @@ default=fade;500;30 # input panel surface animation(name;time) inputpanel=fade;200 +[ivi-thumbnail] +gpu_accel_fps=10 +shm_buffer_fps=2 +no_accel_fps=5 + [ivi-option] # option flags -# bit.0 1=show surface at screen create if HomeScreen exist/0=not show surface at create -# bit.1 1=1=show if display not exist/0=not show if display not exist -# bit.2 1=show input panel automatically/0=not show automaticaly -# bit.8 1=surface fixed aspect rate/0=not fixed aspect rate +# 0x0001 1=show surface at screen create if HomeScreen exist/0=not show surface at create +# 0x0002 1=1=show if display not exist/0=not show if display not exist +# 0x0004 1=show input panel automatically/0=not show automaticaly +# 0x0080 1=surface fixed aspect rate/0=not fixed aspect rate +# 0x8000 1=no use GPU dependent acceleration +# 0x1000 1=force use Intel Sandybridge Mobile GPU dependent acceleration flag=0x0004 -# debug log output level -# 0=no debug log write(1=err/2=warn/3=info/4=trace/5=debug) -log=4 +# debug log output level and debug flag +# lower 16 bit: log level(0=no/1=err/2=warn/3=info/4=trace/5=debug) +# upper 16 bit: debug flag(0x00010000: performance log) +log=0x00000004 diff --git a/settings/weston.service b/settings/weston.service index 16d2980..49dce8b 100644 --- a/settings/weston.service +++ b/settings/weston.service @@ -3,7 +3,9 @@ Description=Weston Requires=dbus.socket [Service] -ExecStart=/usr/bin/weston-launch --user app -- -i0 --log=/tmp/weston.log +ExecStart=/usr/bin/weston-launch -- -i0 --log=/tmp/weston.log +StandardInput=tty +TTYPath=/dev/tty1 [Install] WantedBy=weston.target diff --git a/src/Makefile.am b/src/Makefile.am index f4c1dba..ab5f846 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,6 +6,7 @@ pkginclude_HEADERS = \ workspaces-client-protocol.h \ ico_window_mgr-client-protocol.h \ ico_input_mgr-client-protocol.h \ + ico_window_mgr.h \ ico_input_mgr.h libico_uxf_weston_plugin_la_LIBADD = -ldrm_intel -lrt -lm @@ -46,7 +47,8 @@ ico_plugin_loader_la_LIBADD = $(PLUGIN_LIBS) ico_plugin_loader_la_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_plugin_loader_la_SOURCES = \ ico_plugin_loader.c \ - ico_ivi_common.h + ico_ivi_common_private.h \ + ico_plugin_version.h # IVI-Shell ico_ivi_shell = ico_ivi_shell.la @@ -55,8 +57,8 @@ ico_ivi_shell_la_LIBADD = $(PLUGIN_LIBS) ico_ivi_shell_la_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_ivi_shell_la_SOURCES = \ ico_ivi_shell.c \ - ico_ivi_shell.h \ - ico_ivi_common.h \ + ico_ivi_shell_private.h \ + ico_ivi_common_private.h \ desktop-shell-protocol.c \ input-method-protocol.c \ workspaces-protocol.c \ @@ -71,9 +73,10 @@ ico_window_mgr_la_LIBADD = -ldrm_intel $(PLUGIN_LIBS) $(AUL_LIBS) ico_window_mgr_la_CFLAGS = -I/usr/include/libdrm $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_window_mgr_la_SOURCES = \ ico_window_mgr.c \ + ico_window_mgr_private.h \ ico_window_mgr.h \ - ico_ivi_common.h \ - ico_ivi_shell.h \ + ico_ivi_common_private.h \ + ico_ivi_shell_private.h \ ico_window_mgr-protocol.c \ ico_window_mgr-server-protocol.h # @@ -84,8 +87,8 @@ ico_window_animation_la_LIBADD = $(PLUGIN_LIBS) $(AUL_LIBS) ico_window_animation_la_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_window_animation_la_SOURCES = \ ico_window_animation.c \ - ico_window_mgr.h \ - ico_ivi_common.h + ico_window_mgr_private.h \ + ico_ivi_common._privateh # Multi Input Manager ico_input_mgr = ico_input_mgr.la @@ -95,8 +98,8 @@ ico_input_mgr_la_CFLAGS = $(GCC_CFLAGS) $(EXT_CFLAGS) $(PLUGIN_CFLAGS) ico_input_mgr_la_SOURCES = \ ico_input_mgr.c \ ico_input_mgr.h \ - ico_window_mgr.h \ - ico_ivi_common.h \ + ico_window_mgr_private.h \ + ico_ivi_common._privateh \ ico_input_mgr-protocol.c \ ico_input_mgr-server-protocol.h diff --git a/src/ico_input_mgr.c b/src/ico_input_mgr.c index 4988d4d..b24fbed 100644 --- a/src/ico_input_mgr.c +++ b/src/ico_input_mgr.c @@ -39,12 +39,13 @@ #include <time.h> #include <sys/types.h> +#include <pixman.h> #include <wayland-server.h> #include <weston/compositor.h> -#include "ico_ivi_common.h" -#include "ico_ivi_shell.h" -#include "ico_window_mgr.h" +#include "ico_ivi_common_private.h" +#include "ico_ivi_shell_private.h" #include "ico_input_mgr.h" +#include "ico_window_mgr_private.h" #include "ico_window_mgr-server-protocol.h" #include "ico_input_mgr-server-protocol.h" @@ -123,8 +124,8 @@ struct uifw_input_device { int y; /* current Y coordinate */ int pend_x; /* pending X coordinate */ int pend_y; /* pending Y coordinate */ + uint16_t node; /* display number */ uint16_t pending; /* pending flag */ - char res[2]; /* (unused) */ struct weston_surface *grab; /* current grab surface */ }; @@ -182,6 +183,12 @@ static void ico_mgr_unset_input_region(struct wl_client *client, struct wl_resource *resource, const char *taret, int32_t x, int32_t y, int32_t width, int32_t height); + /* input region set/unset */ +static void ico_set_input_region(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, int32_t height, + int32_t hotspot_x, int32_t hotspot_y, int32_t cursor_x, + int32_t cursor_y, int32_t cursor_width, + int32_t cursor_height, uint32_t attr); /* create and regist Input Controller table*/ static void ico_device_configure_input(struct wl_client *client, struct wl_resource *resource, const char *device, @@ -671,42 +678,22 @@ ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, } break; case EVENT_TOUCH: - if (value >= 7) { + if (value == ICO_INPUT_MGR_CONTROL_TOUCH_EVENT_RESET) { + /* reset touch focus */ grabsave = pInputMgr->seat->touch->focus; uifw_trace("ico_mgr_send_input_event: notify_touch(UnGrab dev=%08x sys=%08x)", (int)dev->grab, (int)grabsave); dev->grab = NULL; - if (pInputMgr->seat->num_tp > 0) { - if (value == 7) { - if (pInputMgr->seat->num_tp > 1) { - uifw_debug("ico_mgr_send_input_event: num=%d Up is true", - pInputMgr->seat->num_tp); - value = 0; - } - else { - uifw_debug("ico_mgr_send_input_event: num=%d Up is false", - pInputMgr->seat->num_tp); - } - } - if (value != 7) { - if (pInputMgr->seat->touch->grab) { - notify_touch(pInputMgr->seat, ctime, - 0, fix_x, fix_y, WL_TOUCH_UP); - } - else { - uifw_debug("ico_mgr_send_input_event: reset num count down(%d)", - pInputMgr->seat->num_tp); - pInputMgr->seat->num_tp --; - } + if (grabsave) { + weston_touch_set_focus(pInputMgr->seat, NULL); + if (pInputMgr->seat->num_tp > 0) { + uifw_debug("ico_mgr_send_input_event: num=%d reset for reset focuse", + pInputMgr->seat->num_tp); + pInputMgr->seat->num_tp = 0; } } - if (pInputMgr->seat->num_tp > 10) { - uifw_debug("ico_mgr_send_input_event: num=%d reset", - pInputMgr->seat->num_tp); - pInputMgr->seat->num_tp = 0; /* safty gard */ - } } - if ((value > 0) && (value != 9) && (value != 7)) { + else if (value == ICO_INPUT_MGR_CONTROL_TOUCH_EVENT_DOWN) { grabsave = pInputMgr->seat->touch->focus; dev->grab = weston_compositor_pick_surface( pInputMgr->compositor, fix_x, fix_y, &dx, &dy); @@ -716,15 +703,13 @@ ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, if (grabsave != dev->grab) { weston_touch_set_focus(pInputMgr->seat, dev->grab); } - notify_touch(pInputMgr->seat, ctime, 0, fix_x, fix_y, WL_TOUCH_DOWN); - ico_window_mgr_active_surface(dev->grab); - if (pInputMgr->seat->num_tp == 0) { + if (pInputMgr->seat->num_tp > 0) { uifw_debug("ico_mgr_send_input_event: touch_down illegal num, modify"); - pInputMgr->seat->num_tp = 1; /* safty gard */ + weston_touch_set_focus(pInputMgr->seat, NULL); + pInputMgr->seat->num_tp = 0; } - } - else if (value == 7) { - dev->grab = NULL; + notify_touch(pInputMgr->seat, ctime, 0, fix_x, fix_y, WL_TOUCH_DOWN); + ico_window_mgr_active_surface(dev->grab); } else { grabsave = pInputMgr->seat->touch->focus; @@ -733,15 +718,15 @@ ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, if ((grabsave != dev->grab) && (dev->grab != NULL)) { weston_touch_set_focus(pInputMgr->seat, dev->grab); } + if ((pInputMgr->seat->num_tp == 0) || (pInputMgr->seat->num_tp > 10)) { + uifw_debug("ico_mgr_send_input_event: num=%d reset", + pInputMgr->seat->num_tp); + pInputMgr->seat->num_tp = 1; + } notify_touch(pInputMgr->seat, ctime, 0, 0, 0, WL_TOUCH_UP); if (grabsave == dev->grab) grabsave = NULL; weston_touch_set_focus(pInputMgr->seat, grabsave); dev->grab = NULL; - if (pInputMgr->seat->num_tp > 10) { - uifw_debug("ico_mgr_send_input_event: num=%d reset", - pInputMgr->seat->num_tp); - pInputMgr->seat->num_tp = 0; /* safty gard */ - } } break; case EVENT_KEY: @@ -839,6 +824,8 @@ ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, usurf->surface->resource, &dummy_array); } serial = wl_display_next_serial(pInputMgr->compositor->wl_display); + uifw_trace("ico_mgr_send_input_event: send Key (%d, %d) to %08x", + code, value, usurf->surfaceid); wl_keyboard_send_key(cres, serial, ctime, code, value ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED); @@ -847,6 +834,10 @@ ico_mgr_send_input_event(struct wl_client *client, struct wl_resource *resource, wl_keyboard_send_leave(cres, serial, usurf->surface->resource); } } + else { + uifw_trace("ico_mgr_send_input_event: Key client %08x dose not exist", + (int)usurf->surface->resource); + } break; default: break; @@ -886,10 +877,6 @@ ico_mgr_set_input_region(struct wl_client *client, struct wl_resource *resource, int32_t cursor_width, int32_t cursor_height, uint32_t attr) { struct uifw_win_surface *usurf; /* UIFW surface */ - struct uifw_region_mng *p; - struct ico_uifw_input_region *rp; - struct wl_array array; - int i; uifw_trace("ico_mgr_set_input_region: Enter(%s %d/%d-%d/%d(%d/%d) %d/%d-%d/%d)", target, x, y, width, height, hotspot_x, hotspot_y, @@ -902,61 +889,9 @@ ico_mgr_set_input_region(struct wl_client *client, struct wl_resource *resource, return; } - if (wl_list_empty(&pInputMgr->free_region)) { - p = malloc(sizeof(struct uifw_region_mng) * 50); - if (! p) { - uifw_error("ico_mgr_set_input_region: No Memory"); - return; - } - memset(p, 0, sizeof(struct uifw_region_mng)*50); - for (i = 0; i < 50; i++, p++) { - wl_list_insert(pInputMgr->free_region.prev, &p->link); - } - } - p = container_of(pInputMgr->free_region.next, struct uifw_region_mng, link); - wl_list_remove(&p->link); - p->region.node = usurf->node_tbl->node; - p->region.surfaceid = usurf->surfaceid; - p->region.surface_x = usurf->x; - p->region.surface_y = usurf->y; - p->region.x = x; - p->region.y = y; - p->region.width = width; - p->region.height = height; - if ((hotspot_x <= 0) && (hotspot_y <= 0)) { - p->region.hotspot_x = width / 2; - p->region.hotspot_y = height / 2; - } - else { - p->region.hotspot_x = hotspot_x; - p->region.hotspot_y = hotspot_y; - } - if ((cursor_width <= 0) && (cursor_height <= 0)) { - p->region.cursor_x = x; - p->region.cursor_y = y; - p->region.cursor_width = width; - p->region.cursor_height = height; - } - else { - p->region.cursor_x = cursor_x; - p->region.cursor_y = cursor_y; - p->region.cursor_width = cursor_width; - p->region.cursor_height = cursor_height; - } - p->region.change = ico_window_mgr_is_visible(usurf); - wl_list_insert(usurf->input_region.prev, &p->link); + ico_set_input_region(1, usurf, x, y, width, height, hotspot_x, hotspot_y, + cursor_x, cursor_y, cursor_width, cursor_height, attr); - /* send input region to haptic device input controller */ - if (p->region.change > 0) { - wl_array_init(&array); - rp = (struct ico_uifw_input_region *) - wl_array_add(&array, sizeof(struct ico_uifw_input_region)); - if (rp) { - memcpy(rp, &p->region, sizeof(struct ico_uifw_input_region)); - rp->change = ICO_INPUT_MGR_DEVICE_REGION_ADD; - ico_input_send_region_event(&array); - } - } uifw_trace("ico_mgr_set_input_region: Leave"); } @@ -980,12 +915,6 @@ ico_mgr_unset_input_region(struct wl_client *client, struct wl_resource *resourc int32_t width, int32_t height) { struct uifw_win_surface *usurf; /* UIFW surface */ - struct uifw_region_mng *p; /* input region mamagement table*/ - struct uifw_region_mng *np; /* next region mamagement table */ - struct ico_uifw_input_region *rp; /* input region */ - struct wl_array array; - int alldel; - int delcount = 0; uifw_trace("ico_mgr_unset_input_region: Enter(%s %d/%d-%d/%d)", target, x, y, width, height); @@ -997,50 +926,21 @@ ico_mgr_unset_input_region(struct wl_client *client, struct wl_resource *resourc return; } - if ((x <= 0) && (y <= 0) && (width <= 0) && (height <= 0)) { - alldel = 1; - } - else { - alldel = 0; - } - - wl_array_init(&array); + ico_set_input_region(0, usurf, x, y, width, height, 0, 0, 0, 0, 0, 0, 0); - wl_list_for_each_safe(p, np, &usurf->input_region, link) { - if ((alldel != 0) || - ((x == p->region.x) && (y == p->region.y) && - (width == p->region.width) && (height == p->region.height))) { - if (p->region.change > 0) { - /* visible, send remove event */ - rp = (struct ico_uifw_input_region *) - wl_array_add(&array, sizeof(struct ico_uifw_input_region)); - if (rp) { - delcount ++; - memcpy(rp, &p->region, sizeof(struct ico_uifw_input_region)); - rp->change = ICO_INPUT_MGR_DEVICE_REGION_REMOVE; - } - } - wl_list_remove(&p->link); - wl_list_insert(pInputMgr->free_region.prev, &p->link); - } - } - if (delcount > 0) { - /* send region delete to haptic device input controller */ - ico_input_send_region_event(&array); - } uifw_trace("ico_mgr_unset_input_region: Leave"); } /*--------------------------------------------------------------------------*/ /** - * @brief ico_input_hook_region_visible: change surface visibility + * @brief ico_input_hook_region_change: change surface attribute * * @param[in] usurf UIFW surface * @return none */ /*--------------------------------------------------------------------------*/ static void -ico_input_hook_region_visible(struct uifw_win_surface *usurf) +ico_input_hook_region_change(struct uifw_win_surface *usurf) { struct uifw_region_mng *p; /* input region mamagement table*/ struct ico_uifw_input_region *rp; /* input region */ @@ -1050,7 +950,7 @@ ico_input_hook_region_visible(struct uifw_win_surface *usurf) visible = ico_window_mgr_is_visible(usurf); - uifw_trace("ico_input_hook_region_visible: Entery(surf=%08x, visible=%d)", + uifw_trace("ico_input_hook_region_change: Entery(surf=%08x, visible=%d)", usurf->surfaceid, visible); wl_array_init(&array); @@ -1058,7 +958,7 @@ ico_input_hook_region_visible(struct uifw_win_surface *usurf) wl_list_for_each(p, &usurf->input_region, link) { if (((p->region.change > 0) && (visible <= 0)) || ((p->region.change <= 0) && (visible > 0))) { - /* visible change, send remove event */ + /* visible change, send add/remove event */ rp = (struct ico_uifw_input_region *) wl_array_add(&array, sizeof(struct ico_uifw_input_region)); if (rp) { @@ -1071,15 +971,33 @@ ico_input_hook_region_visible(struct uifw_win_surface *usurf) rp->change = ICO_INPUT_MGR_DEVICE_REGION_REMOVE; } } + p->region.change = visible; + p->region.node = usurf->node_tbl->node; + p->region.surface_x = usurf->x; + p->region.surface_y = usurf->y; + } + else if ((p->region.node != usurf->node_tbl->node) || + (p->region.surface_x != usurf->x) || + (p->region.surface_y != usurf->y)) { + /* surface position change, send change event */ + p->region.node = usurf->node_tbl->node; + p->region.surface_x = usurf->x; + p->region.surface_y = usurf->y; + + rp = (struct ico_uifw_input_region *) + wl_array_add(&array, sizeof(struct ico_uifw_input_region)); + if (rp) { + chgcount ++; + memcpy(rp, &p->region, sizeof(struct ico_uifw_input_region)); + rp->change = ICO_INPUT_MGR_DEVICE_REGION_CHANGE; + } } - p->region.change = visible; } if (chgcount > 0) { /* send region delete to haptic device input controller */ ico_input_send_region_event(&array); } - - uifw_trace("ico_input_hook_region_visible: Leave"); + uifw_trace("ico_input_hook_region_change: Leave"); } /*--------------------------------------------------------------------------*/ @@ -1126,6 +1044,143 @@ ico_input_hook_region_destroy(struct uifw_win_surface *usurf) /*--------------------------------------------------------------------------*/ /** + * @brief ico_set_input_region: input region set/unset + * + * @param[in] set set(1)/unset(0) + * @param[in] usurf UIFW surface + * @param[in] x input region X coordinate + * @param[in] y input region X coordinate + * @param[in] width input region width + * @param[in] height input region height + * @param[in] hotspot_x hotspot of X relative coordinate + * @param[in] hotspot_y hotspot of Y relative coordinate + * @param[in] cursor_x cursor region X coordinate + * @param[in] cursor_y cursor region X coordinate + * @param[in] cursor_width cursor region width + * @param[in] cursor_height cursor region height + * @param[in] attr region attributes(currently unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +ico_set_input_region(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, int32_t height, + int32_t hotspot_x, int32_t hotspot_y, int32_t cursor_x, int32_t cursor_y, + int32_t cursor_width, int32_t cursor_height, uint32_t attr) +{ + struct uifw_region_mng *p; /* input region mamagement table*/ + struct uifw_region_mng *np; /* next region mamagement table */ + struct ico_uifw_input_region *rp; /* input region */ + struct wl_array array; + int i; + int alldel; + int delcount; + + uifw_trace("ico_set_input_region: Enter(%s %d/%d-%d/%d(%d/%d) %d/%d-%d/%d)", + set ? "Set" : "Unset", x, y, width, height, hotspot_x, hotspot_y, + cursor_x, cursor_y, cursor_width, cursor_height); + + if (set) { + if (wl_list_empty(&pInputMgr->free_region)) { + p = malloc(sizeof(struct uifw_region_mng) * 50); + if (! p) { + uifw_error("ico_set_input_region: No Memory"); + return; + } + memset(p, 0, sizeof(struct uifw_region_mng)*50); + for (i = 0; i < 50; i++, p++) { + wl_list_insert(pInputMgr->free_region.prev, &p->link); + } + } + p = container_of(pInputMgr->free_region.next, struct uifw_region_mng, link); + wl_list_remove(&p->link); + p->region.node = usurf->node_tbl->node; + p->region.surfaceid = usurf->surfaceid; + p->region.surface_x = usurf->x; + p->region.surface_y = usurf->y; + p->region.x = x; + p->region.y = y; + p->region.width = width; + p->region.height = height; + if ((hotspot_x <= 0) && (hotspot_y <= 0)) { + p->region.hotspot_x = width / 2; + p->region.hotspot_y = height / 2; + } + else { + p->region.hotspot_x = hotspot_x; + p->region.hotspot_y = hotspot_y; + } + if ((cursor_width <= 0) && (cursor_height <= 0)) { + p->region.cursor_x = x; + p->region.cursor_y = y; + p->region.cursor_width = width; + p->region.cursor_height = height; + } + else { + p->region.cursor_x = cursor_x; + p->region.cursor_y = cursor_y; + p->region.cursor_width = cursor_width; + p->region.cursor_height = cursor_height; + } + p->region.change = ico_window_mgr_is_visible(usurf); + wl_list_insert(usurf->input_region.prev, &p->link); + + /* send input region to haptic device input controller */ + if (p->region.change > 0) { + wl_array_init(&array); + rp = (struct ico_uifw_input_region *) + wl_array_add(&array, sizeof(struct ico_uifw_input_region)); + if (rp) { + memcpy(rp, &p->region, sizeof(struct ico_uifw_input_region)); + rp->change = ICO_INPUT_MGR_DEVICE_REGION_ADD; + ico_input_send_region_event(&array); + } + uifw_trace("ico_set_input_region: Leave(Set)"); + } + else { + uifw_trace("ico_set_input_region: Leave(Set but Unvisible)"); + } + } + else { + delcount = 0; + + if ((x <= 0) && (y <= 0) && (width <= 0) && (height <= 0)) { + alldel = 1; + } + else { + alldel = 0; + } + + wl_array_init(&array); + + wl_list_for_each_safe(p, np, &usurf->input_region, link) { + if ((alldel != 0) || + ((x == p->region.x) && (y == p->region.y) && + (width == p->region.width) && (height == p->region.height))) { + if (p->region.change > 0) { + /* visible, send remove event */ + rp = (struct ico_uifw_input_region *) + wl_array_add(&array, sizeof(struct ico_uifw_input_region)); + if (rp) { + delcount ++; + memcpy(rp, &p->region, sizeof(struct ico_uifw_input_region)); + rp->change = ICO_INPUT_MGR_DEVICE_REGION_REMOVE; + } + } + wl_list_remove(&p->link); + wl_list_insert(pInputMgr->free_region.prev, &p->link); + } + } + if (delcount > 0) { + /* send region delete to haptic device input controller */ + ico_input_send_region_event(&array); + } + uifw_trace("ico_set_input_region: Leave(Unset)"); + } +} + +/*--------------------------------------------------------------------------*/ +/** * @brief ico_input_send_region_event: send region event to Haptic dic * * @param[in] usurf UIFW surface @@ -1804,8 +1859,9 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) pInputMgr->seat = container_of(ec->seat_list.next, struct weston_seat, link); /* set hook for input region control */ - ico_window_mgr_set_hook_visible(ico_input_hook_region_visible); + ico_window_mgr_set_hook_change(ico_input_hook_region_change); ico_window_mgr_set_hook_destory(ico_input_hook_region_destroy); + ico_window_mgr_set_hook_inputregion(ico_set_input_region); uifw_info("ico_input_mgr: Leave(module_init)"); return 0; diff --git a/src/ico_input_mgr.h b/src/ico_input_mgr.h index c23cba9..8b4d9bd 100644 --- a/src/ico_input_mgr.h +++ b/src/ico_input_mgr.h @@ -33,6 +33,7 @@ struct ico_uifw_input_region { uint16_t change; /* change method */ /* ICO_INPUT_MGR_DEVICE_REGION_ADD */ /* ICO_INPUT_MGR_DEVICE_REGION_REMOVE */ + /* ICO_INPUT_MGR_DEVICE_REGION_CHANGE */ /* ICO_INPUT_MGR_DEVICE_REGION_REMOVEALL*/ uint16_t node; /* display node */ uint32_t surfaceid; /* surface Id */ diff --git a/src/ico_ivi_common.h b/src/ico_ivi_common_private.h index b11d45a..94e303d 100644 --- a/src/ico_ivi_common.h +++ b/src/ico_ivi_common_private.h @@ -27,8 +27,11 @@ * @date Jul-26-2013 */ -#ifndef _ICO_IVI_COMMON_H_ -#define _ICO_IVI_COMMON_H_ +#ifndef _ICO_IVI_COMMON_PRIVATE_H_ +#define _ICO_IVI_COMMON_PRIVATE_H_ + +/* Log for performance evaluations */ +#define PERFORMANCE_EVALUATIONS 1 /* Macros */ #define ICO_IVI_NODEID_2_HOSTID(nodeid) (((unsigned int)nodeid) >> 8) @@ -56,16 +59,22 @@ #define FALSE 0 #endif +/* Option flags */ +#define ICO_IVI_OPTION_SHOW_SURFACE 0x0001 /* new surface show on create */ +#define ICO_IVI_OPTION_SHOW_NODISP 0x0002 /* show if display not exist */ +#define ICO_IVI_OPTION_SHOW_INPUTLAYER 0x0004 /* show input panel layer */ +#define ICO_IVI_OPTION_FIXED_ASPECT 0x0080 /* surface fixed aspect rate */ +#define ICO_IVI_OPTION_GPU_NODEPEND 0x8000 /* no use GPU dependent acceleration*/ +#define ICO_IVI_OPTION_GPU_DEPENDINTEL 0x1000 /* use Intel GPU dependent acceleration*/ + /* depends for Intel GPU */ /* Debug flags */ -#define ICO_IVI_DEBUG_SHOW_SURFACE 0x0001 /* new surface show on create */ -#define ICO_IVI_DEBUG_SHOW_NODISP 0x0002 /* show if display not exist */ -#define ICO_IVI_DEBUG_SHOW_INPUTLAYER 0x0004 /* show input panel layer */ -#define ICO_IVI_DEBUG_FIXED_ASPECT 0x0100 /* surface fixed aspect rate */ +#define ICO_IVI_DEBUG_PERF_LOG 0x0001 /* performance log */ /* Function prototype */ int ico_ivi_get_mynode(void); /* Get my node numner */ +int ico_ivi_optionflag(void); /* Get option flag */ +int ico_ivi_debuglevel(void); /* Get debug log level */ int ico_ivi_debugflag(void); /* Get debug flag */ -int ico_ivi_debuglevel(void); /* Get debug level */ /* Get default animation name */ const char *ico_ivi_default_animation_name(void); int ico_ivi_default_animation_time(void); /* Get default animation time(ms) */ @@ -76,11 +85,26 @@ int ico_ivi_default_animation_fps(void); /* Get animation frame rate(fps) #define UIFW_DEBUG_OUT 1 /* 1=Debug Print/0=No Debug Print */ #if UIFW_DEBUG_OUT > 0 +#define uifw_perf(fmt,...) \ + { if (ico_ivi_debugflag() & ICO_IVI_DEBUG_PERF_LOG) {weston_log("PRF>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } #define uifw_debug(fmt,...) \ { if (ico_ivi_debuglevel() >= 5) {weston_log("DBG>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } #define uifw_trace(fmt,...) \ { if (ico_ivi_debuglevel() >= 4) {weston_log("TRC>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } + +#ifdef UIFW_DETAIL_OUT +#if UIFW_DETAIL_OUT > 0 +#define uifw_detail(fmt,...) \ + { if (ico_ivi_debuglevel() >= 5) {weston_log("DBG>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } +#else +#define uifw_detail(fmt,...) +#endif +#else +#define uifw_detail(fmt,...) +#endif + #else /*UIFW_DEBUG_OUT*/ +#define uifw_perf(fmt,...) #define uifw_debug(fmt,...) #define uifw_trace(fmt,...) #endif /*UIFW_DEBUG_OUT*/ @@ -92,5 +116,4 @@ int ico_ivi_default_animation_fps(void); /* Get animation frame rate(fps) #define uifw_error(fmt,...) \ { if (ico_ivi_debuglevel() >= 1) {weston_log("ERR>"fmt" (%s:%d)\n",##__VA_ARGS__,__FILE__,__LINE__);} } -#endif /*_ICO_IVI_COMMON_H_*/ - +#endif /*_ICO_IVI_COMMON_PRIVATE_H_*/ diff --git a/src/ico_ivi_shell.c b/src/ico_ivi_shell.c index 5f7c376..fbdd901 100644 --- a/src/ico_ivi_shell.c +++ b/src/ico_ivi_shell.c @@ -39,7 +39,7 @@ #include "input-method-server-protocol.h" #include "workspaces-server-protocol.h" #include <weston/config-parser.h> -#include "ico_ivi_shell.h" +#include "ico_ivi_shell_private.h" #define DEFAULT_NUM_WORKSPACES 1 #define DEFAULT_WORKSPACE_CHANGE_ANIMATION_LENGTH 200 @@ -164,6 +164,7 @@ struct desktop_shell { uint32_t binding_modifier; enum animation_type win_animation_type; + enum animation_type startup_animation_type; }; #if 0 /* move to ico_ivi_shell.h */ @@ -333,7 +334,7 @@ static void (*shell_hook_map)(struct weston_surface *surface, int32_t *width, int32_t *height, int32_t *sx, int32_t *sy) = NULL; static void (*shell_hook_configure)(struct weston_surface *surface) = NULL; static void (*shell_hook_select)(struct weston_surface *surface) = NULL; -static void (*shell_hook_title)(struct weston_surface *surface, const char *title) = NULL; +static char *(*shell_hook_title)(struct weston_surface *surface, const char *title) = NULL; static void (*shell_hook_move)(struct weston_surface *surface, int *dx, int *dy) = NULL; static void (*shell_hook_show_layer)(int layertype, int show, void *data) = NULL; static int (*shell_hook_fullscreen)(int event, struct weston_surface *surface) = NULL; @@ -468,9 +469,6 @@ get_modifier(char *modifier) static enum animation_type get_animation_type(char *animation) { - if (!animation) - return ANIMATION_NONE; - if (!strcmp("zoom", animation)) return ANIMATION_ZOOM; else if (!strcmp("fade", animation)) @@ -502,6 +500,13 @@ shell_configuration(struct desktop_shell *shell) weston_config_section_get_string(section, "animation", &s, "none"); shell->win_animation_type = get_animation_type(s); free(s); + weston_config_section_get_string(section, + "startup-animation", &s, "fade"); + shell->startup_animation_type = get_animation_type(s); + free(s); + if (shell->startup_animation_type == ANIMATION_ZOOM) + shell->startup_animation_type = ANIMATION_NONE; + weston_config_section_get_uint(section, "num-workspaces", &shell->workspaces.num, DEFAULT_NUM_WORKSPACES); @@ -515,6 +520,7 @@ shell_configuration(struct desktop_shell *shell) if (section) { weston_config_section_get_int(section, "log", &ico_debug_level, DEFAULT_DEBUG_LEVEL); + ico_debug_level &= 0x0ffff; } } @@ -782,15 +788,12 @@ workspace_translate_in(struct workspace *ws, double fraction) static void broadcast_current_workspace_state(struct desktop_shell *shell) { - struct wl_list *link; + struct wl_resource *resource; - for (link = shell->workspaces.client_list.next; - link != &shell->workspaces.client_list; - link = link->next) { - workspace_manager_send_state(wl_resource_from_link(link), + wl_resource_for_each(resource, &shell->workspaces.client_list) + workspace_manager_send_state(resource, shell->workspaces.current, shell->workspaces.num); - } } static void @@ -1150,10 +1153,14 @@ touch_move_grab_down(struct weston_touch_grab *grab, uint32_t time, static void touch_move_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id) { - struct shell_touch_grab *shell_grab = container_of(grab, - struct shell_touch_grab, - grab); - shell_touch_grab_end(shell_grab); + struct weston_touch_move_grab *move = + (struct weston_touch_move_grab *) container_of( + grab, struct shell_touch_grab, grab); + + if (grab->touch->seat->num_tp == 0) { + shell_touch_grab_end(&move->base); + free(move); + } } static void @@ -1177,10 +1184,22 @@ touch_move_grab_motion(struct weston_touch_grab *grab, uint32_t time, weston_compositor_schedule_repaint(es->compositor); } +static void +touch_move_grab_cancel(struct weston_touch_grab *grab) +{ + struct weston_touch_move_grab *move = + (struct weston_touch_move_grab *) container_of( + grab, struct shell_touch_grab, grab); + + shell_touch_grab_end(&move->base); + free(move); +} + static const struct weston_touch_grab_interface touch_move_grab_interface = { touch_move_grab_down, touch_move_grab_up, touch_move_grab_motion, + touch_move_grab_cancel, }; static int @@ -1255,10 +1274,21 @@ move_grab_button(struct weston_pointer_grab *grab, } } +static void +move_grab_cancel(struct weston_pointer_grab *grab) +{ + struct shell_grab *shell_grab = + container_of(grab, struct shell_grab, grab); + + shell_grab_end(shell_grab); + free(grab); +} + static const struct weston_pointer_grab_interface move_grab_interface = { noop_grab_focus, move_grab_motion, move_grab_button, + move_grab_cancel, }; static int @@ -1387,10 +1417,20 @@ resize_grab_button(struct weston_pointer_grab *grab, } } +static void +resize_grab_cancel(struct weston_pointer_grab *grab) +{ + struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; + + shell_grab_end(&resize->base); + free(grab); +} + static const struct weston_pointer_grab_interface resize_grab_interface = { noop_grab_focus, resize_grab_motion, resize_grab_button, + resize_grab_cancel, }; /* @@ -1519,10 +1559,20 @@ busy_cursor_grab_button(struct weston_pointer_grab *base, } } +static void +busy_cursor_grab_cancel(struct weston_pointer_grab *base) +{ + struct shell_grab *grab = (struct shell_grab *) base; + + shell_grab_end(grab); + free(grab); +} + static const struct weston_pointer_grab_interface busy_cursor_grab_interface = { busy_cursor_grab_focus, busy_cursor_grab_motion, busy_cursor_grab_button, + busy_cursor_grab_cancel, }; static void @@ -1668,21 +1718,34 @@ shell_surface_pong(struct wl_client *client, struct wl_resource *resource, } static void -shell_surface_set_title(struct wl_client *client, - struct wl_resource *resource, const char *title) +set_title(struct shell_surface *shsurf, const char *title) { - struct shell_surface *shsurf = wl_resource_get_user_data(resource); - - free(shsurf->title); - shsurf->title = strdup(title); + char *p; /* if ico_window_mgr hook, call hook routine */ if (shell_hook_title) { - (*shell_hook_title)(shsurf->surface, shsurf->title); + p = (*shell_hook_title)(shsurf->surface, title); + if (p) { + free(shsurf->title); + shsurf->title = strdup(p); + } + } + else { + free(shsurf->title); + shsurf->title = strdup(title); } } static void +shell_surface_set_title(struct wl_client *client, + struct wl_resource *resource, const char *title) +{ + struct shell_surface *shsurf = wl_resource_get_user_data(resource); + + set_title(shsurf, title); +} + +static void shell_surface_set_class(struct wl_client *client, struct wl_resource *resource, const char *class) { @@ -1709,9 +1772,9 @@ restore_output_mode(struct weston_output *output) if (output->current_mode != output->original_mode || (int32_t)output->current_scale != output->original_scale) weston_output_switch_mode(output, - output->original_mode, - output->original_scale, - WESTON_MODE_SWITCH_RESTORE_NATIVE); + output->original_mode, + output->original_scale, + WESTON_MODE_SWITCH_RESTORE_NATIVE); } static void @@ -2064,7 +2127,7 @@ shell_configure_fullscreen(struct shell_surface *shsurf) shsurf->fullscreen.framerate}; if (weston_output_switch_mode(output, &mode, surface->buffer_scale, - WESTON_MODE_SWITCH_SET_TEMPORARY) == 0) { + WESTON_MODE_SWITCH_SET_TEMPORARY) == 0) { weston_surface_set_position(surface, output->x - surf_x, output->y - surf_y); @@ -2284,8 +2347,8 @@ popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time) wl_resource_for_each(resource, &pointer->focus_resource_list) { weston_surface_from_global_fixed(pointer->focus, - pointer->x, pointer->y, - &sx, &sy); + pointer->x, pointer->y, + &sx, &sy); wl_pointer_send_motion(resource, time, sx, sy); } } @@ -2307,11 +2370,11 @@ popup_grab_button(struct weston_pointer_grab *grab, serial = wl_display_get_serial(display); wl_resource_for_each(resource, resource_list) { wl_pointer_send_button(resource, serial, - time, button, state); + time, button, state); } } else if (state == WL_POINTER_BUTTON_STATE_RELEASED && - (shseat->popup_grab.initial_up || - time - shseat->seat->pointer->grab_time > 500)) { + (shseat->popup_grab.initial_up || + time - shseat->seat->pointer->grab_time > 500)) { popup_grab_end(grab->pointer); } @@ -2319,10 +2382,17 @@ popup_grab_button(struct weston_pointer_grab *grab, shseat->popup_grab.initial_up = 1; } +static void +popup_grab_cancel(struct weston_pointer_grab *grab) +{ + popup_grab_end(grab->pointer); +} + static const struct weston_pointer_grab_interface popup_grab_interface = { popup_grab_focus, popup_grab_motion, popup_grab_button, + popup_grab_cancel, }; static void @@ -2657,6 +2727,7 @@ launch_screensaver(struct desktop_shell *shell) return; } + uifw_trace("launch_screensaver: launch %s", shell->screensaver.path); weston_client_launch(shell->compositor, &shell->screensaver.process, shell->screensaver.path, @@ -2930,6 +3001,26 @@ move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *dat } static void +touch_move_binding(struct weston_seat *seat, uint32_t time, void *data) +{ + struct weston_surface *focus = + (struct weston_surface *) seat->touch->focus; + struct weston_surface *surface; + struct shell_surface *shsurf; + + surface = weston_surface_get_main_surface(focus); + if (surface == NULL) + return; + + shsurf = get_shell_surface(surface); + if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN || + shsurf->type == SHELL_SURFACE_MAXIMIZED) + return; + + surface_touch_move(shsurf, (struct weston_seat *) seat); +} + +static void resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) { struct weston_surface *focus = @@ -3151,10 +3242,21 @@ rotate_grab_button(struct weston_pointer_grab *grab, } } +static void +rotate_grab_cancel(struct weston_pointer_grab *grab) +{ + struct rotate_grab *rotate = + container_of(grab, struct rotate_grab, base.grab); + + shell_grab_end(&rotate->base); + free(rotate); +} + static const struct weston_pointer_grab_interface rotate_grab_interface = { noop_grab_focus, rotate_grab_motion, rotate_grab_button, + rotate_grab_cancel, }; static void @@ -3290,27 +3392,15 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface) } static void -click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t button, - void *data) +activate_binding(struct weston_seat *seat, + struct desktop_shell *shell, + struct weston_surface *focus) { - struct weston_seat *ws = (struct weston_seat *) seat; - struct desktop_shell *shell = data; - struct weston_surface *focus; struct weston_surface *main_surface; - uifw_debug("click_to_activate_binding: mouse=%08x(%08x) touch=%08x(%08x)", - (int)seat->pointer, seat->pointer ? (int)seat->pointer->focus : 0, - (int)seat->touch, seat->touch ? (int)seat->touch->focus : 0); - if (seat->pointer == NULL) { - uifw_debug("click_to_activate_binding: system has no mouse, Skip"); + if (!focus) return; - } - focus = (struct weston_surface *) seat->pointer->focus; - if (!focus) { - uifw_debug("click_to_activate_binding: no focus, Skip"); - return; - } if (is_black_surface(focus, &main_surface)) focus = main_surface; @@ -3318,8 +3408,7 @@ click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t butt if (get_shell_surface_type(main_surface) == SHELL_SURFACE_NONE) return; - if (seat->pointer->grab == &seat->pointer->default_grab) - activate(shell, focus, ws); + activate(shell, focus, seat); /* if ico_window_mgr hook, call hook routine */ if (shell_hook_select) { @@ -3328,41 +3417,24 @@ click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t butt } static void -touch_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t button, +click_to_activate_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data) { - struct weston_seat *ws = (struct weston_seat *) seat; - struct desktop_shell *shell = data; - struct weston_surface *focus; - struct weston_surface *main_surface; - - uifw_debug("touch_to_activate_binding: mouse=%08x(%08x) touch=%08x(%08x)", - (int)seat->pointer, seat->pointer ? (int)seat->pointer->focus : 0, - (int)seat->touch, seat->touch ? (int)seat->touch->focus : 0); - if (seat->touch == NULL) { - uifw_debug("touch_to_activate_binding: system has no touch panel, Skip"); + if (seat->pointer->grab != &seat->pointer->default_grab) return; - } - focus = (struct weston_surface *) seat->touch->focus; - if (!focus) { - uifw_debug("touch_to_activate_binding: no focus, Skip"); - return; - } - if (is_black_surface(focus, &main_surface)) - focus = main_surface; + activate_binding(seat, data, + (struct weston_surface *) seat->pointer->focus); +} - main_surface = weston_surface_get_main_surface(focus); - if (get_shell_surface_type(main_surface) == SHELL_SURFACE_NONE) +static void +touch_to_activate_binding(struct weston_seat *seat, uint32_t time, void *data) +{ + if (seat->touch->grab != &seat->touch->default_grab) return; - if (seat->touch->grab == &seat->touch->default_grab) - activate(shell, focus, ws); - - /* if ico_window_mgr hook, call hook routine */ - if (shell_hook_select) { - (*shell_hook_select)(focus); - } + activate_binding(seat, data, + (struct weston_surface *) seat->touch->focus); } static void @@ -3499,7 +3571,12 @@ do_shell_fade_startup(void *data) { struct desktop_shell *shell = data; - shell_fade(shell, FADE_IN); + if (shell->startup_animation_type == ANIMATION_FADE) + shell_fade(shell, FADE_IN); + else if (shell->startup_animation_type == ANIMATION_NONE) { + weston_surface_destroy(shell->fade.surface); + shell->fade.surface = NULL; + } } static void @@ -3716,7 +3793,8 @@ weston_surface_set_initial_position (struct weston_surface *surface, */ panel_height = get_output_panel_height(shell, target_output); range_x = target_output->width - surface->geometry.width; - range_y = target_output->height - surface->geometry.height; + range_y = (target_output->height - panel_height) - + surface->geometry.height; if (range_x > 0) { dx = random() % range_x; @@ -3996,6 +4074,7 @@ launch_desktop_shell_process(void *data) weston_log("no shell program\n"); } else { + uifw_trace("launch_desktop_shell_process: launch %s", shell_exe); shell->child.client = weston_client_launch(shell->compositor, &shell->child.process, shell_exe, @@ -4063,6 +4142,7 @@ bind_desktop_shell(struct wl_client *client, return; } +weston_log("bind_desktop_shell: client=%08x shell=%08x\n", (int)client, (int)shell->child.client); wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "permission to bind desktop_shell denied"); @@ -4530,9 +4610,18 @@ switcher_modifier(struct weston_keyboard_grab *grab, uint32_t serial, switcher_destroy(switcher); } +static void +switcher_cancel(struct weston_keyboard_grab *grab) +{ + struct switcher *switcher = container_of(grab, struct switcher, grab); + + switcher_destroy(switcher); +} + static const struct weston_keyboard_grab_interface switcher_grab = { switcher_key, switcher_modifier, + switcher_cancel, }; static void @@ -4640,7 +4729,7 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time, if (check_binding) { if (weston_compositor_run_debug_binding(ec, db->seat, time, - key, state)) { + key, state)) { /* We ran a binding so swallow the press and keep the * grab to swallow the released too. */ send = 0; @@ -4682,13 +4771,23 @@ debug_binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, wl_resource_for_each(resource, resource_list) { wl_keyboard_send_modifiers(resource, serial, mods_depressed, - mods_latched, mods_locked, group); + mods_latched, mods_locked, group); } } +static void +debug_binding_cancel(struct weston_keyboard_grab *grab) +{ + struct debug_binding_grab *db = (struct debug_binding_grab *) grab; + + weston_keyboard_end_grab(grab->keyboard); + free(db); +} + struct weston_keyboard_grab_interface debug_binding_keyboard_grab = { debug_binding_key, - debug_binding_modifiers + debug_binding_modifiers, + debug_binding_cancel, }; static void @@ -4847,9 +4946,9 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) weston_compositor_add_button_binding(ec, BTN_LEFT, 0, click_to_activate_binding, shell); - weston_compositor_add_button_binding(ec, BTN_TOUCH, 0, - touch_to_activate_binding, - shell); + weston_compositor_add_touch_binding(ec, 0, + touch_to_activate_binding, + shell); weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL, MODIFIER_SUPER | MODIFIER_ALT, surface_opacity_binding, NULL); @@ -4865,6 +4964,7 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) zoom_key_binding, NULL); weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding, shell); + weston_compositor_add_touch_binding(ec, mod, touch_move_binding, shell); weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod, resize_binding, shell); @@ -4921,14 +5021,13 @@ module_init(struct weston_compositor *ec, unsigned int i; struct wl_event_loop *loop; - shell = malloc(sizeof *shell); + shell = zalloc(sizeof *shell); if (shell == NULL) return -1; /* save shell management table for other plugin */ _ico_ivi_shell = shell; - memset(shell, 0, sizeof *shell); shell->compositor = ec; shell->destroy_listener.notify = shell_destroy; @@ -4952,6 +5051,7 @@ module_init(struct weston_compositor *ec, ec->shell_interface.set_xwayland = set_xwayland; ec->shell_interface.move = surface_move; ec->shell_interface.resize = surface_resize; + ec->shell_interface.set_title = set_title; wl_list_init(&shell->input_panel.surfaces); @@ -5268,8 +5368,8 @@ ico_ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface)) */ /*--------------------------------------------------------------------------*/ WL_EXPORT void -ico_ivi_shell_hook_title(void (*hook_title)(struct weston_surface *surface, - const char *title)) +ico_ivi_shell_hook_title(char *(*hook_title)(struct weston_surface *surface, + const char *title)) { shell_hook_title = hook_title; } @@ -5318,4 +5418,3 @@ ico_ivi_shell_hook_fullscreen(int (*hook_fullscreen) { shell_hook_fullscreen = hook_fullscreen; } - diff --git a/src/ico_ivi_shell.h b/src/ico_ivi_shell_private.h index 5211ec5..03c346a 100644 --- a/src/ico_ivi_shell.h +++ b/src/ico_ivi_shell_private.h @@ -27,8 +27,8 @@ * @date Jul-26-2013 */ -#ifndef _ICO_IVI_SHELL_H_ -#define _ICO_IVI_SHELL_H_ +#ifndef _ICO_IVI_SHELL_PRIVATE_H_ +#define _ICO_IVI_SHELL_PRIVATE_H_ #include "ico_window_mgr-server-protocol.h" @@ -88,7 +88,7 @@ void ico_ivi_shell_hook_map(void (*hook_map)(struct weston_surface *surface, int32_t *width, int32_t *height, int32_t *sx, int32_t *sy)); void ico_ivi_shell_hook_configure(void (*hook_configure)(struct weston_surface *surface)); void ico_ivi_shell_hook_select(void (*hook_select)(struct weston_surface *surface)); -void ico_ivi_shell_hook_title(void (*hook_title)(struct weston_surface *surface, +void ico_ivi_shell_hook_title(char *(*hook_title)(struct weston_surface *surface, const char *title)); void ico_ivi_shell_hook_move(void (*hook_move)(struct weston_surface *surface, int *dx, int *dy)); @@ -96,5 +96,4 @@ void ico_ivi_shell_hook_show_layer(void (*hook_show)(int layertype, int show, vo void ico_ivi_shell_hook_fullscreen(int (*hook_fullscreen) (int event, struct weston_surface *surface)); -#endif /*_ICO_IVI_SHELL_H_*/ - +#endif /*_ICO_IVI_SHELL_PRIVATE_H_*/ diff --git a/src/ico_plugin_loader.c b/src/ico_plugin_loader.c index 404b5f5..3ef9346 100644 --- a/src/ico_plugin_loader.c +++ b/src/ico_plugin_loader.c @@ -42,7 +42,8 @@ #include <weston/compositor.h> #include <weston/config-parser.h> -#include "ico_ivi_common.h" +#include "ico_ivi_common_private.h" +#include "ico_plugin_version.h" /* Internal function to load one plugin. */ static void load_module(struct weston_compositor *ec, const char *path, const char *entry, @@ -153,6 +154,8 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) char *end; char buffer[256]; + weston_log("INF>ico-uxf-weston-plugin " ICO_PLUIGN_VERSION "\n"); + uifw_info("ico_plugin_loader: Enter(module_init)"); /* get ivi debug level */ @@ -160,7 +163,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) if (section) { weston_config_section_get_int(section, "log", &debug_level, 3); } - + /* get plugin module name from config file(weston_ivi_plugin.ini) */ section = weston_config_get_section(ec->config, "ivi-plugin", NULL, NULL); if (section) { diff --git a/src/ico_plugin_version.h b/src/ico_plugin_version.h new file mode 100644 index 0000000..10b2d59 --- /dev/null +++ b/src/ico_plugin_version.h @@ -0,0 +1 @@ +#define ICO_PLUIGN_VERSION "0.9.11 (Dec-25-2013)" diff --git a/src/ico_window_animation.c b/src/ico_window_animation.c index 0be76d8..5e53bf6 100644 --- a/src/ico_window_animation.c +++ b/src/ico_window_animation.c @@ -39,9 +39,10 @@ #include <sys/stat.h> #include <weston/compositor.h> -#include "ico_ivi_common.h" -#include "ico_ivi_shell.h" -#include "ico_window_mgr.h" +#include <pixman.h> +#include "ico_ivi_common_private.h" +#include "ico_ivi_shell_private.h" +#include "ico_window_mgr_private.h" /* Animation type */ #define ANIMA_ZOOM 1 /* ZoomIn/ZoomOut */ @@ -318,6 +319,12 @@ ico_window_animation(const int op, void *data) ret = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA; } usurf->animation.type = op; +#if PERFORMANCE_EVALUATIONS > 0 + if (ret != ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) { + uifw_perf("SWAP_BUFFER Start Animation appid=%s surface=%08x anima=%d", + usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima); + } +#endif /*PERFORMANCE_EVALUATIONS*/ } weston_compositor_schedule_repaint(weston_ec); return ret; @@ -487,6 +494,10 @@ animation_end(struct uifw_win_surface *usurf, const int disp) if (! disp) { ico_window_mgr_restack_layer(usurf); } +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER End Animation appid=%s surface=%08x anima=%d", + usurf->uclient->appid, usurf->surfaceid, usurf->animation.anima); +#endif /*PERFORMANCE_EVALUATIONS*/ } /*--------------------------------------------------------------------------*/ diff --git a/src/ico_window_mgr.c b/src/ico_window_mgr.c index be7ddbc..be69f7d 100644 --- a/src/ico_window_mgr.c +++ b/src/ico_window_mgr.c @@ -39,39 +39,35 @@ #include <signal.h> #include <math.h> #include <time.h> +#include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <limits.h> +#include <pixman.h> #include <wayland-server.h> #include <dirent.h> #include <aul/aul.h> #include <bundle.h> #include <EGL/egl.h> -#include <EGL/eglext.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #include <GL/internal/dri_interface.h> -/* inport Mesa version */ -#if EGL_EGLEXT_VERSION >= 16 -#define MESA_VERSION 921 -#else -#define MESA_VERSION 913 -#endif - #include <weston/compositor.h> -#if MESA_VERSION >= 921 #include <libdrm/intel_bufmgr.h> -#endif -#include "ico_ivi_common.h" -#include "ico_ivi_shell.h" + +/* detail debug log */ +#define UIFW_DETAIL_OUT 0 /* 1=detail debug log/0=no detail log */ + +#include "ico_ivi_common_private.h" +#include "ico_ivi_shell_private.h" +#include "ico_window_mgr_private.h" #include "ico_window_mgr.h" #include "desktop-shell-server-protocol.h" #include "ico_window_mgr-server-protocol.h" - /* SurfaceID */ #define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */ #define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */ @@ -83,18 +79,18 @@ /* show/hide animation with position */ #define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000 -/* wl_buffer (inport from wayland-1.2.0/src/wayland-server.h) */ -struct uifw_wl_buffer { /* struct wl_buffer */ - struct wl_resource resource; - int32_t width, height; - uint32_t busy_count; -}; +/* GPU type code */ +#define ICO_GPUTYPE_NOACCELERATION 0 /* Do not use GPU-dependent acceleration*/ +#define ICO_GPUTYPE_INTEL_SANDYBRIDGE 1 /* Intel Sandybridge Mobile */ + +/* Code for Intel Sandybridge Mobile GPU dependent acceleration */ /* wl_drm_buffer (inport from mesa-9.1.3 & mesa-9.2.1/ */ /* src/egl/wayland/wayland-drm/wayland-drm.h) */ struct uifw_drm_buffer { - struct uifw_wl_buffer buffer; + struct wl_resource *resource; void *drm; /* struct wl_drm */ + int32_t width, height; uint32_t format; const void *driver_format; int32_t offset[3]; @@ -105,7 +101,6 @@ struct uifw_drm_buffer { /* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h */ /* mesa-9.2.1/src/mesa/drivers/dri/i915/intel_regions.h */ /* mesa-9.2.1/src/mesa/drivers/dri/i965/intel_regions.h) */ -#if MESA_VERSION >= 920 struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */ void *bo; /**< buffer manager's buffer */ uint32_t refcount; /**< Reference count for region */ @@ -116,21 +111,6 @@ struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */ uint32_t tiling; /**< Which tiling mode the region is in */ uint32_t name; /**< Global name for the bo */ }; -#else /*MESA_VERSION < 920*/ -struct uifw_intel_region { /* struct intel_region */ - void *bo; /**< buffer manager's buffer */ - uint32_t refcount; /**< Reference count for region */ - uint32_t cpp; /**< bytes per pixel */ - uint32_t width; /**< in pixels */ - uint32_t height; /**< in pixels */ - uint32_t pitch; /**< in bytes */ - char *map; /**< only non-NULL when region is actually mapped */ - uint32_t map_refcount; /**< Reference count for mapping */ - uint32_t tiling; /**< Which tiling mode the region is in */ - uint32_t name; /**< Global name for the bo */ - void *screen; /* screen */ -}; -#endif /*MESA_VERSION*/ struct uifw_dri_image { /* struct __DRIimageRec */ struct uifw_intel_region *region; @@ -141,17 +121,16 @@ struct uifw_dri_image { /* struct __DRIimageRec */ uint32_t strides[3]; uint32_t offsets[3]; void *planar_format; /* intel_image_format */ -#if MESA_VERSION >= 920 uint32_t width; uint32_t height; uint32_t tile_x; uint32_t tile_y; bool has_depthstencil; /* i965 only */ -#endif /*MESA_VERSION*/ void *data; }; -/* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c) */ +/* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c, */ +/* weston-1.3.1/src/gl-renderer.c */ enum buffer_type { BUFFER_TYPE_NULL, BUFFER_TYPE_SHM, @@ -174,6 +153,7 @@ struct uifw_gl_surface_state { /* struct gl_surface_state */ enum buffer_type buffer_type; int pitch; /* in pixels */ int height; /* in pixels */ + int y_inverted; /* add weston 1.3.x */ }; /* Multi Windiw Manager */ @@ -188,14 +168,12 @@ struct ico_win_mgr { struct wl_list ivi_layer_list; /* Layer management table list */ struct uifw_win_layer *touch_layer; /* layer table for touch panel layer */ - struct uifw_win_layer *cursor_layer; /* layer table for cursor layer */ struct wl_list map_list; /* surface map list */ struct uifw_surface_map *free_maptable; /* free maped surface table list */ struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY]; /* animation for map check */ struct wl_event_source *wait_mapevent; /* map event send wait timer */ - int waittime; /* minimaum send wait time(ms) */ struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */ struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */ @@ -242,7 +220,7 @@ static void win_mgr_register_surface( /* surface destroy */ static void win_mgr_destroy_surface(struct weston_surface *surface); /* map new surface */ -static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width, +static void win_mgr_surface_map(struct weston_surface *surface, int32_t *width, int32_t *height, int32_t *sx, int32_t *sy); /* send surface change event to manager */ static void win_mgr_change_surface(struct weston_surface *surface, @@ -255,7 +233,7 @@ static void win_mgr_shell_configure(struct weston_surface *surface); /* surface select */ static void win_mgr_select_surface(struct weston_surface *surface); /* surface set title */ -static void win_mgr_set_title(struct weston_surface *surface, const char *title); +static char *win_mgr_set_title(struct weston_surface *surface, const char *title); /* surface move request from shell */ static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy); /* shell layer visible control */ @@ -313,13 +291,16 @@ static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, const char *appid, int32_t pid); /* check and change all mapped surface */ -static void win_mgr_check_mapsurrace(struct weston_animation *animation, +static void win_mgr_check_mapsurface(struct weston_animation *animation, struct weston_output *output, uint32_t msecs); /* check timer of mapped surface */ -static int win_mgr_timer_mapsurrace(void *data); +static int win_mgr_timer_mapsurface(void *data); /* check and change mapped surface */ static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime); + /* set map buffer */ +static void uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource, + const char *shmname, uint32_t bufsize, uint32_t bufnum); /* map surface to system application */ static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource, uint32_t surfaceid, int32_t framerate); @@ -342,8 +323,14 @@ static int ico_get_animation_name(const char *animation); /* hook for animation */ static int (*win_mgr_hook_animation)(const int op, void *data) = NULL; /* hook for input region */ -static void (*win_mgr_hook_visible)(struct uifw_win_surface *usurf) = NULL; +static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL; static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL; +static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, + int32_t height, int32_t hotspot_x, int32_t hotspot_y, + int32_t cursor_x, int32_t cursor_y, + int32_t cursor_width, int32_t cursor_height, + uint32_t attr) = NULL; /* static tables */ /* Multi Window Manager interface */ @@ -358,12 +345,23 @@ static const struct ico_window_mgr_interface ico_window_mgr_implementation = { uifw_set_active, uifw_set_layer_visible, uifw_get_surfaces, + uifw_set_map_buffer, uifw_map_surface, uifw_unmap_surface }; + +/* GPU driver name */ +static const struct _ico_gputype_table { + int gpu_type; /* GPU type code */ + char *gpu_name; /* GPU driver name */ +} ico_window_mgr_gpu_type[] = { + { ICO_GPUTYPE_INTEL_SANDYBRIDGE, "Mesa DRI Intel(R) Sandybridge Mobile" }, + { 0, "\0" } +}; + /* plugin common value(without ico_plugin_loader) */ -static int _ico_ivi_debug_flag = 0; /* debug flags */ +static int _ico_ivi_option_flag = 0; /* option flags */ static int _ico_ivi_debug_level = 3; /* debug Level */ static char *_ico_ivi_animation_name = NULL; /* default animation name */ static int _ico_ivi_animation_time = 500; /* default animation time */ @@ -381,6 +379,11 @@ static int _ico_ivi_touch_layer = 101; /* touch panel layer id static int _ico_ivi_cursor_layer = 102; /* cursor layer id */ static int _ico_ivi_startup_layer = 109; /* deafult layer id at system startup*/ +static int _ico_ivi_gpu_type = 0; /* GPU type for get EGL buffer */ +static int _ico_ivi_map_framerate_gpu = 30; /* framerate of map surface for GPU*/ +static int _ico_ivi_map_framerate_shm = 2; /* framerate of map surface for shm buffer*/ +static int _ico_ivi_map_framerate_pixel = 5; /* framerate of map surface for ReadPixels*/ + /* static management table */ static struct ico_win_mgr *_ico_win_mgr = NULL; static int _ico_num_nodes = 0; @@ -390,16 +393,16 @@ static struct weston_seat *touch_check_seat = NULL; /*--------------------------------------------------------------------------*/ /** - * @brief ico_ivi_debugflag: get debug flags + * @brief ico_ivi_optionflag: get option flags * * @param None - * @return debug flags + * @return option flags */ /*--------------------------------------------------------------------------*/ WL_EXPORT int -ico_ivi_debugflag(void) +ico_ivi_optionflag(void) { - return _ico_ivi_debug_flag; + return _ico_ivi_option_flag; } /*--------------------------------------------------------------------------*/ @@ -412,13 +415,28 @@ ico_ivi_debugflag(void) * @retval 1 Only error output * @retval 2 Error and Warning output * @retval 3 Error, Warning and information output - * @retval 4 All output with debug write + * @retval 4 Error, Warning, information and Debug Trace output + * @retval 5 All output with debug write */ /*--------------------------------------------------------------------------*/ WL_EXPORT int ico_ivi_debuglevel(void) { - return _ico_ivi_debug_level; + return (_ico_ivi_debug_level & 0x0ffff); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_debugflag: get debug flags + * + * @param None + * @return debug flags + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_debugflag(void) +{ + return ((_ico_ivi_debug_level >> 16) & 0x0ffff); } /*--------------------------------------------------------------------------*/ @@ -1132,7 +1150,7 @@ win_mgr_register_surface(int layertype, struct wl_client *client, int layer; uint32_t hash; - uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x,layer=%x)", + uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x,layertype=%x)", (int)surface, (int)client, (int)resource, layertype); /* check new surface */ @@ -1165,7 +1183,7 @@ win_mgr_register_surface(int layertype, struct wl_client *client, wl_list_init(&usurf->surf_map); wl_list_init(&usurf->input_region); usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name()); - usurf->animation.hide_time = ico_ivi_default_animation_time();; + usurf->animation.hide_time = ico_ivi_default_animation_time(); usurf->animation.show_anima = usurf->animation.hide_anima; usurf->animation.show_time = usurf->animation.hide_time; usurf->animation.move_anima = usurf->animation.hide_anima; @@ -1181,7 +1199,7 @@ win_mgr_register_surface(int layertype, struct wl_client *client, } if ((layertype != LAYER_TYPE_INPUTPANEL) && ((_ico_win_mgr->num_manager <= 0) || - (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE))) { + (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE))) { uifw_trace("win_mgr_register_surface: No Manager, Force visible"); usurf->visible = 1; } @@ -1233,6 +1251,7 @@ win_mgr_register_surface(int layertype, struct wl_client *client, else { _ico_win_mgr->wshash[hash] = usurf; } + /* set default layer id */ switch (layertype) { case LAYER_TYPE_BACKGROUND: @@ -1260,7 +1279,7 @@ win_mgr_register_surface(int layertype, struct wl_client *client, /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_map_surface: map surface + * @brief win_mgr_surface_map: map surface to display * * @param[in] surface Weston surface * @param[in] width surface width @@ -1271,21 +1290,21 @@ win_mgr_register_surface(int layertype, struct wl_client *client, */ /*--------------------------------------------------------------------------*/ static void -win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height, +win_mgr_surface_map(struct weston_surface *surface, int32_t *width, int32_t *height, int32_t *sx, int32_t *sy) { struct uifw_win_surface *usurf; - uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)", + uifw_trace("win_mgr_surface_map: Enter(%08x, x/y=%d/%d w/h=%d/%d)", (int)surface, *sx, *sy, *width, *height); usurf = find_uifw_win_surface_by_ws(surface); if (usurf) { - uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d", + uifw_trace("win_mgr_surface_map: surf=%08x w/h=%d/%d vis=%d", usurf->surfaceid, usurf->width, usurf->height, usurf->visible); if ((usurf->width > 0) && (usurf->height > 0)) { - uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize" + uifw_trace("win_mgr_surface_map: HomeScreen registed, PositionSize" "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d", usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height, usurf->visible); @@ -1296,7 +1315,7 @@ win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *hei usurf->width, usurf->height); } else { - uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, " + uifw_trace("win_mgr_surface_map: HomeScreen not regist Surface, " "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)", usurf->surfaceid, *sx, *sy, *width, *height); usurf->width = *width; @@ -1334,10 +1353,10 @@ win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *hei if (usurf->x < 0) usurf->x = 0; if (usurf->y < 0) usurf->y = 0; } - uifw_trace("win_mgr_map_surface: set position %08x %d.%d/%d", + uifw_trace("win_mgr_surface_map: set position %08x %d.%d/%d", usurf->surfaceid, usurf->node_tbl->node, usurf->x, usurf->y); } - if (((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_SURFACE) == 0) && + if (((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE) == 0) && (_ico_win_mgr->num_manager > 0)) { /* HomeScreen exist, coodinate set by HomeScreen */ if (usurf->visible) { @@ -1350,12 +1369,12 @@ win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *hei ICO_IVI_MAX_COORDINATE+1, usurf->width, usurf->height); } - uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d", + uifw_trace("win_mgr_surface_map: Change size/position x/y=%d/%d w/h=%d/%d", (int)surface->geometry.x, (int)surface->geometry.y, surface->geometry.width, surface->geometry.height); } else if (usurf->layertype != LAYER_TYPE_INPUTPANEL) { - uifw_trace("win_mgr_map_surface: No HomeScreen, chaneg to Visible"); + uifw_trace("win_mgr_surface_map: No HomeScreen, chaneg to Visible"); ico_window_mgr_set_visible(usurf, 1); } else { @@ -1375,10 +1394,10 @@ win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *hei if (usurf->visible) { ico_window_mgr_restack_layer(NULL); } - uifw_trace("win_mgr_map_surface: Leave"); + uifw_trace("win_mgr_surface_map: Leave"); } else { - uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)"); + uifw_trace("win_mgr_surface_map: Leave(No UIFW Surface)"); } } @@ -1401,12 +1420,6 @@ ico_window_mgr_restack_layer(struct uifw_win_surface *usurf) struct weston_surface *surface, *surfacetmp; int num_visible = 0; int layertype; - int old_visible; - - /* save current visible */ - if (usurf) { - old_visible = ico_window_mgr_is_visible(usurf); - } /* make compositor surface list */ wlayer = ico_ivi_shell_weston_layer(); @@ -1422,14 +1435,14 @@ ico_window_mgr_restack_layer(struct uifw_win_surface *usurf) wl_list_init(&wlayer->surface_list); wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { - if (el->layertype == LAYER_TYPE_CURSOR) continue; wl_list_for_each (eu, &el->surface_list, ivi_layer) { if (eu->surface == NULL) continue; /* target only panel or unknown layer */ layertype = ico_ivi_shell_layertype(eu->surface); if ((layertype != LAYER_TYPE_PANEL) && (layertype != LAYER_TYPE_INPUTPANEL) && - (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_UNKNOWN)) { + (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_CURSOR) && + (layertype != LAYER_TYPE_UNKNOWN)) { continue; } wl_list_remove(&eu->surface->layer_link); @@ -1497,13 +1510,6 @@ ico_window_mgr_restack_layer(struct uifw_win_surface *usurf) _ico_win_mgr->shell_init = 1; ico_ivi_shell_startup(_ico_win_mgr->shell); } - - /* if visible change, call hook for input region */ - if ((usurf != NULL) && (win_mgr_hook_visible != NULL)) { - if (old_visible != ico_window_mgr_is_visible(usurf)) { - (*win_mgr_hook_visible)(usurf); - } - } uifw_trace("ico_window_mgr_restack_layer: Leave"); } @@ -1578,10 +1584,6 @@ win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer, } else if ((int)layer == _ico_ivi_cursor_layer ) { new_el->layertype = LAYER_TYPE_CURSOR; - _ico_win_mgr->cursor_layer = new_el; - } - else if(layertype != 0) { - new_el->layertype = layertype; } else { new_el->layertype = LAYER_TYPE_PANEL; @@ -1604,6 +1606,9 @@ win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer, wl_list_remove(&usurf->ivi_layer); wl_list_insert(&new_el->surface_list, &usurf->ivi_layer); usurf->win_layer = new_el; + if (new_el->layertype == LAYER_TYPE_CURSOR) { + usurf->layertype = LAYER_TYPE_CURSOR; + } } return new_el; } @@ -1622,14 +1627,21 @@ win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer) { struct uifw_win_layer *el; struct uifw_win_layer *new_el; + uint32_t oldlayer; uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)", usurf->surfaceid, (int)usurf->surface, layer); /* check if same layer */ - if ((usurf->win_layer != NULL) && (usurf->win_layer->layer == layer)) { - uifw_trace("win_mgr_set_layer: Leave(Same Layer)"); - return; + if (usurf->win_layer != NULL) { + oldlayer = usurf->win_layer->layer ; + if (oldlayer == layer) { + uifw_trace("win_mgr_set_layer: Leave(Same Layer)"); + return; + } + } + else { + oldlayer = 0; } /* search existing layer */ @@ -1651,6 +1663,28 @@ win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer) usurf->win_layer = el; win_mgr_set_raise(usurf, 3); } + + /* set input region */ + if (layer == (uint32_t)_ico_ivi_cursor_layer) { + uifw_trace("win_mgr_set_layer: %08x cursor Change to cursor layer (%d,%d)-(%d,%d)", + usurf->surfaceid, + usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, + usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); + pixman_region32_fini(&usurf->surface->pending.input); + pixman_region32_init_rect(&usurf->surface->pending.input, + ICO_IVI_MAX_COORDINATE + 1, ICO_IVI_MAX_COORDINATE + 1, + 1, 1); + } + else if (oldlayer == (uint32_t)_ico_ivi_cursor_layer) { + uifw_trace("win_mgr_set_layer: %08x cursor Change to normal layer (%d,%d)-(%d,%d)", + usurf->surfaceid, + usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, + usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); + pixman_region32_fini(&usurf->surface->pending.input); + pixman_region32_init_rect(&usurf->surface->pending.input, + INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); + } + /* rebild compositor surface list */ if (usurf->visible) { ico_window_mgr_restack_layer(usurf); @@ -1967,6 +2001,8 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, struct weston_surface *es; int op; int retanima; + int oldx, oldy; + struct uifw_node_table *oldnode; uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x", surfaceid, node, x, y, width, height, flags); @@ -1976,6 +2012,9 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid); return; } + oldx = usurf->x; + oldy = usurf->y; + oldnode = usurf->node_tbl; uclient = find_client_from_client(client); @@ -1983,7 +2022,7 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, if (((int)node) >= _ico_num_nodes) { uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)", node, _ico_num_nodes); - if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_NODISP) == 0) { + if ((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_NODISP) == 0) { if (usurf->visible) { /* no display, change to hide */ uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE, @@ -2017,7 +2056,7 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, if (uclient) { if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && - (uclient->manager == 0)) uclient = NULL; + (uclient->manager == 0) && (uclient->privilege == 0)) uclient = NULL; } if (! uclient) { if ((usurf->width > 0) && (usurf->height > 0)) { @@ -2042,6 +2081,7 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, usurf->animation.pos_width = usurf->width; usurf->animation.pos_height = usurf->height; usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0; + usurf->x = x; usurf->y = y; usurf->width = width; @@ -2097,7 +2137,14 @@ uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, usurf->y = y; usurf->width = width; usurf->height = height; - uifw_trace("uifw_set_positionsize: Leave(OK,but no buffer)"); + uifw_trace("uifw_set_positionsize: Leave(OK, but no buffer)"); + } + + /* if position change, call hook for input region */ + if (win_mgr_hook_change != NULL) { + if ((oldx != usurf->x) || (oldy != usurf->y) || (oldnode != usurf->node_tbl)) { + (*win_mgr_hook_change)(usurf); + } } } @@ -2122,6 +2169,7 @@ uifw_set_visible(struct wl_client *client, struct wl_resource *resource, struct uifw_client *uclient; int restack; int retanima; + int oldvisible; uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)", surfaceid, visible, raise, flags); @@ -2131,11 +2179,12 @@ uifw_set_visible(struct wl_client *client, struct wl_resource *resource, uifw_trace("uifw_set_visible: Leave(Surface Not Exist)"); return; } + oldvisible = ico_window_mgr_is_visible(usurf); uclient = find_client_from_client(client); if (uclient) { if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && - (uclient->manager == 0)) { + (uclient->manager == 0) && (uclient->privilege == 0)) { uifw_trace("uifw_set_visible: Request from App(%s), not Manager", uclient->appid); uclient = NULL; @@ -2152,6 +2201,12 @@ uifw_set_visible(struct wl_client *client, struct wl_resource *resource, if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) { +#if PERFORMANCE_EVALUATIONS > 0 + if (! usurf->visible) { + uifw_perf("SWAP_BUFFER Show appid=%s surface=%08x", + usurf->uclient->appid, usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ if ((! usurf->visible) || (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { usurf->visible = 1; @@ -2193,6 +2248,12 @@ uifw_set_visible(struct wl_client *client, struct wl_resource *resource, } else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) { +#if PERFORMANCE_EVALUATIONS > 0 + if (usurf->visible) { + uifw_perf("SWAP_BUFFER Hide appid=%s surface=%08x", + usurf->uclient->appid, usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ if ((usurf->visible) || (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { @@ -2268,6 +2329,13 @@ uifw_set_visible(struct wl_client *client, struct wl_resource *resource, ICO_WINDOW_MGR_V_NOCHANGE), raise, uclient ? 0 : 1, 0,0); } + + /* if visible change, call hook for input region */ + if (win_mgr_hook_change != NULL) { + if (oldvisible != ico_window_mgr_is_visible(usurf)) { + (*win_mgr_hook_change)(usurf); + } + } uifw_trace("uifw_set_visible: Leave(OK)"); } @@ -2577,15 +2645,18 @@ uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, struct uifw_win_surface *usurf; int layertype = 0; - if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) { + if ((layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) || + (layer == (uint32_t)_ico_ivi_background_layer)) { layer = _ico_ivi_background_layer; layertype = LAYER_TYPE_BACKGROUND; } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) { + else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) || + (layer == (uint32_t)_ico_ivi_touch_layer)) { layer = _ico_ivi_touch_layer; layertype = LAYER_TYPE_TOUCH; } - else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) { + else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) || + (layer == (uint32_t)_ico_ivi_cursor_layer)) { layer = _ico_ivi_cursor_layer; layertype = LAYER_TYPE_CURSOR; } @@ -2715,7 +2786,7 @@ uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_check_mapsurrace: check and change all surface + * @brief win_mgr_check_mapsurface: check and change all surface * * @param[in] animation weston animation table(unused) * @param[in] outout weston output table(unused) @@ -2724,7 +2795,7 @@ uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, */ /*--------------------------------------------------------------------------*/ static void -win_mgr_check_mapsurrace(struct weston_animation *animation, +win_mgr_check_mapsurface(struct weston_animation *animation, struct weston_output *output, uint32_t msecs) { struct uifw_surface_map *sm; @@ -2734,7 +2805,7 @@ win_mgr_check_mapsurrace(struct weston_animation *animation, /* check touch down counter */ if (touch_check_seat) { if (touch_check_seat->num_tp > 10) { - uifw_trace("win_mgr_change_mapsurface: illegal touch counter(num=%d), reset", + uifw_trace("win_mgr_check_mapsurface: illegal touch counter(num=%d), reset", (int)touch_check_seat->num_tp); touch_check_seat->num_tp = 0; } @@ -2743,6 +2814,8 @@ win_mgr_check_mapsurrace(struct weston_animation *animation, /* check all mapped surfaces */ curtime = weston_compositor_get_time(); wl_list_for_each (sm, &_ico_win_mgr->map_list, map_link) { + uifw_detail("win_mgr_check_mapsurface: sm=%08x surf=%08x", + (int)sm, sm->usurf->surfaceid); win_mgr_change_mapsurface(sm, 0, curtime); if (sm->eventque) { if (sm->interval < wait) { @@ -2752,31 +2825,27 @@ win_mgr_check_mapsurrace(struct weston_animation *animation, } /* check frame interval */ - if (wait < 99999999) { + if (wait < 2000) { wait = wait / 2; } else { wait = 1000; } - if (wait != _ico_win_mgr->waittime) { - _ico_win_mgr->waittime = wait; - wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, - _ico_win_mgr->waittime); - } + wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, wait); } /*--------------------------------------------------------------------------*/ /** - * @brief win_mgr_timer_mapsurrace: mapped surface check timer + * @brief win_mgr_timer_mapsurface: mapped surface check timer * * @param[in] data user data(unused) - * @return none + * @return fixed 1 */ /*--------------------------------------------------------------------------*/ static int -win_mgr_timer_mapsurrace(void *data) +win_mgr_timer_mapsurface(void *data) { - win_mgr_check_mapsurrace(NULL, NULL, 0); + win_mgr_check_mapsurface(NULL, NULL, 0); return 1; } @@ -2804,17 +2873,26 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti int stride; uint32_t format; uint32_t dtime; + int idx, idx2; + int delta, settime2; + struct ico_uifw_image_buffer *p; + + uifw_detail("win_mgr_change_mapsurface: surf=%08x event=%d", sm->usurf->surfaceid, event); + if (event == 0) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; + } /* check if buffered */ + drm_buffer = NULL; es = sm->usurf->surface; - if ((es == NULL) || (es->buffer_ref.buffer == NULL) || - (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) || - (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL) || - (((struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer)->driver_buffer - == NULL)) { - /* surface has no buffer, error */ - uifw_trace("win_mgr_change_mapsurface: surface(%08x) has no buffer", - sm->usurf->surfaceid); + if ((es == NULL) || + ((sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) && + ((es->buffer_ref.buffer == NULL) || + (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0)))) { + /* surface has no buffer */ + uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer %08x %08x", + sm->usurf->surfaceid, (int)es, + es ? (int)es->buffer_ref.buffer : 0); if (sm->initflag) { event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; } @@ -2822,91 +2900,249 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti event = 0; } } - else { - gl_state = (struct uifw_gl_surface_state *)es->renderer_state; - if (gl_state->buffer_type == BUFFER_TYPE_SHM) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; + else if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + if ((es->buffer_ref.buffer->legacy_buffer != NULL) && (es->renderer_state != NULL)) { + drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( + (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer); + if ((drm_buffer != NULL) && (drm_buffer->driver_buffer == NULL)) { + drm_buffer = NULL; + } } - else if (gl_state->buffer_type != BUFFER_TYPE_EGL) { - event = 0; + if (drm_buffer == NULL) { + /* surface has no buffer */ + uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer", + sm->usurf->surfaceid); + if (sm->initflag) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; + } + else { + event = 0; + } + } + } + else if (sm->uclient->shmbuf == NULL) { + /* no GPU acceleration but no buffer */ + uifw_debug("win_mgr_change_mapsurface: client has no shared memory buffer"); + if (sm->initflag) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; } else { - drm_buffer = (struct uifw_drm_buffer *)es->buffer_ref.buffer->legacy_buffer; - dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer; - dri_region = dri_image->region; - width = es->buffer_ref.buffer->width; - height = es->buffer_ref.buffer->height; - stride = drm_buffer->stride[0]; - if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { - format = EGL_TEXTURE_RGB; + event = 0; + } + } + + if ((event != 0) && (event != ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP)) { + + if (sm->type == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + gl_state = (struct uifw_gl_surface_state *)es->renderer_state; + if (gl_state->buffer_type == BUFFER_TYPE_SHM) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; } - else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { - format = EGL_TEXTURE_RGBA; + else if (gl_state->buffer_type != BUFFER_TYPE_EGL) { + event = 0; } else { - /* unknown format, error */ - format = EGL_NO_TEXTURE; - } - eglname = dri_region->name; -#if MESA_VERSION >= 921 - if (eglname == 0) { - if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) { - uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error"); - eglname = 0; + dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer; + dri_region = dri_image->region; + width = es->buffer_ref.buffer->width; + height = es->buffer_ref.buffer->height; + stride = drm_buffer->stride[0]; + if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { + format = EGL_TEXTURE_RGB; } + else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { + format = EGL_TEXTURE_RGBA; + } + else { + /* unknown format, error */ + format = EGL_NO_TEXTURE; + } + eglname = dri_region->name; + if (eglname == 0) { + if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) { + uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error"); + eglname = 0; + } + } + if ((sm->initflag == 0) && (eglname != 0) && + (width > 0) && (height > 0) && (stride > 0)) { + sm->initflag = 1; + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; + } + else { + if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) { + event = 0; + } + else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { + if ((sm->width != width) || (sm->height != height) || + (sm->stride != stride) || (format != sm->format)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; + } + else if (eglname != sm->eglname) { +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER appid=%s surface=%08x name=%d", + sm->usurf->uclient->appid, sm->usurf->surfaceid, + sm->eglname); +#endif /*PERFORMANCE_EVALUATIONS*/ + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + sm->eventque = 1; + event = 0; + } + } + else if (sm->eventque) { + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + event = 0; + } + } + else { + event =0; + } + } + } + sm->width = width; + sm->height = height; + sm->stride = stride; + sm->eglname = eglname; + sm->format = format; } -#endif - if ((sm->initflag == 0) && (eglname != 0) && - (width > 0) && (height > 0) && (stride > 0)) { - sm->initflag = 1; - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; - } - else { - if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) { + } + else { + if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_PIXEL) || (sm->eventque != 0) || + (es->buffer_ref.buffer == NULL) || (es->buffer_ref.buffer != sm->curbuf)) { + sm->curbuf = es->buffer_ref.buffer; + if (es->buffer_ref.buffer != NULL) { + width = es->buffer_ref.buffer->width; + height = es->buffer_ref.buffer->height; + } + else { + width = sm->usurf->client_width; + height = sm->usurf->client_height; + } + /* get shared memory buffer area */ + idx2 = sm->uclient->bufnum; + settime2 = 0x7fffffff; + for (idx = 0; idx < sm->uclient->bufnum; idx++) { + p = (struct ico_uifw_image_buffer *) + (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); + if (p->settime == p->reftime) break; + delta = curtime - p->settime; + if (delta < 0) { + delta = delta + 0x80000000; + } + if ((delta > 3000) && (delta < settime2)) { + idx2 = idx; + settime2 = p->settime; + } + } + uifw_detail("win_mgr_change_mapsurface: PIX %08x idx=%d idx2=%d w/h=%d/%d", + sm->usurf->surfaceid, idx, idx2, width, height); + if (idx >= sm->uclient->bufnum) { + idx = idx2; + } + if (idx >= sm->uclient->bufnum) { + uifw_debug("win_mgr_change_mapsurface: shared buffer full"); event = 0; + sm->curbuf = NULL; + sm->eventque = 1; } - else if (event == 0) { - if ((sm->width != width) || (sm->height != height) || - (sm->stride != stride) || (format != sm->format)) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; + else if ((sm->initflag == 0) && (width > 0) && (height > 0)) { + sm->initflag = 1; + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; + uifw_detail("win_mgr_change_mapsurface: PIX MAP event %08x", + sm->usurf->surfaceid); + } + else { + if ((width <= 0) || (height <= 0)) { + event = 0; + sm->curbuf = NULL; + uifw_detail("win_mgr_change_mapsurface: PIX %08x w/h=0/0", + sm->usurf->surfaceid); } - else if (eglname != sm->eglname) { -#if 1 /* log for speed test */ - uifw_debug("win_mgr_change_mapsurface: SWAPBUFFER(surf=%08x name=%d)", - sm->usurf->surfaceid, sm->eglname); -#endif - dtime = curtime - sm->lasttime; - if ((sm->interval > 0) && (dtime < sm->interval)) { - sm->eventque = 1; - event = 0; + else if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS) { +#if PERFORMANCE_EVALUATIONS > 0 + if (sm->type != ICO_WINDOW_MGR_MAP_TYPE_SHM) { + uifw_perf("SWAP_BUFFER appid=%s surface=%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ + if ((sm->width != width) || (sm->height != height)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; } else { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + sm->eventque = 1; + event = 0; + uifw_detail("win_mgr_change_mapsurface: PIX %08x new queue", + sm->usurf->surfaceid); + } + else if (sm->eventque) { + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + event = 0; + uifw_detail("win_mgr_change_mapsurface: PIX %08x queued", + sm->usurf->surfaceid); + } + } } } - else if (sm->eventque) { - dtime = curtime - sm->lasttime; - if ((sm->interval == 0) || (dtime >= sm->interval)) { - event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; + } + sm->width = width; + sm->height = height; + sm->stride = width; + sm->format = EGL_TEXTURE_RGBA; + if (event != 0) { + /* read pixel */ + p = (struct ico_uifw_image_buffer *) + (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); + height = (sm->uclient->bufsize - sizeof(struct ico_uifw_image_buffer)) + / (width * 4); + uifw_detail("win_mgr_change_mapsurface: PIX read buf=%08x height=%d(%d)", + (int)p, height, sm->height); + if ((height < sm->height) && + (sm->type == ICO_WINDOW_MGR_MAP_TYPE_SHM)) { + uifw_warn("win_mgr_change_mapsurface: Buffer SHM, " + "but buffer overflow(%d>%d)", sm->height, height); + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; + sm->eventque = 0; + } + else { + if (height > sm->height) { + height = sm->height; + } + if ((*(_ico_win_mgr->compositor->renderer->read_surface_pixels)) + (es, PIXMAN_a8r8g8b8, p->image, + 0, 0, sm->width, height) != 0) { + uifw_debug("win_mgr_change_mapsurface: Error read pixel %s.%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; + sm->eventque = 0; + } + else { + uifw_detail("win_mgr_change_mapsurface: PIX read pixels(%d)", + idx+1); + p->surfaceid = sm->usurf->surfaceid; + p->settime = curtime; + p->width = sm->width; + p->height = height; + sm->eglname = idx + 1; } } } } - sm->width = width; - sm->height = height; - sm->stride = stride; - sm->eglname = eglname; - sm->format = format; + else { + event = 0; + } } } if (event != 0) { -#if 0 /* too many logs */ - uifw_debug("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%d " - "w/h/s=%d/%d/%d format=%x", - event, sm->usurf->surfaceid, sm->eglname, - sm->width, sm->height, sm->stride, sm->format); -#endif + uifw_detail("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x type=%d " + "name=%d w/h/s=%d/%d/%d format=%x", + event, sm->usurf->surfaceid, sm->type, sm->eglname, + sm->width, sm->height, sm->stride, sm->format); sm->lasttime = curtime; sm->eventque = 0; ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event, @@ -2924,6 +3160,80 @@ win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curti /*--------------------------------------------------------------------------*/ /** + * @brief uifw_set_map_buffer: set map surface image buffer + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] shmname shared memory name(POSIX I/F) + * @param[in] bufsize buffer size in byte + * @param[in] bufnum number of buffers + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_map_buffer(struct wl_client *client, struct wl_resource *resource, + const char *shmname, uint32_t bufsize, uint32_t bufnum) +{ + struct uifw_client *uclient; + struct ico_uifw_image_buffer *p; + char *shmbuf; + int shmfd; + int i; + + uifw_trace("uifw_set_map_buffer: Enter(%s,%d,%d)", + shmname ? shmname : "(null)", bufsize, bufnum); + + uclient = find_client_from_client(client); + if ((! uclient) || (! uclient->mgr)) { + /* client dose not exist, error */ + uifw_trace("uifw_set_map_buffer: Leave(client=%08x dose not exist)", (int)client); + return; + } + + if ((shmname == NULL) || (*shmname == 0) || (*shmname == ' ') || + (bufsize == 0) || (bufnum == 0)) { + /* delete shared memory buffer */ + if (uclient->shmbuf) { + munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum); + uclient->shmbuf = NULL; + } + uifw_trace("uifw_set_map_buffer: Leave(delete shared memory buffer)"); + return; + } + + shmfd = shm_open(shmname, O_RDWR, 0600); + if (shmfd == -1) { + /* shared memory dose not exist */ + uifw_trace("uifw_set_map_buffer: Leave(shared memory(%s) dose not exist)", shmname); + return; + } + + shmbuf = (char *)mmap(NULL, bufsize * bufnum, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0); + close(shmfd); + + if (shmbuf == NULL) { + /* can not map shared memory */ + uifw_trace("uifw_set_map_buffer: Leave(can not map shared memory(%s))", shmname); + return; + } + if (uclient->shmbuf) { + munmap(uclient->shmbuf, uclient->bufsize * uclient->bufnum); + } + + uclient->shmbuf = shmbuf; + uclient->bufsize = bufsize; + uclient->bufnum = bufnum; + for (i = 0; i < (int)bufnum; i++) { + p = (struct ico_uifw_image_buffer *)(((char *)shmbuf) + bufsize * i); + memset((char *)p, 0, sizeof(struct ico_uifw_image_buffer)); + memcpy((char *)&p->magich, ICO_UIFW_IMAGE_BUFFER_MAGICH, 4); + memcpy((char *)&p->magict, ICO_UIFW_IMAGE_BUFFER_MAGICT, 4); + } + uifw_trace("uifw_set_map_buffer: Leave(shm addr=%08x)", (int)uclient->shmbuf); +} + +/*--------------------------------------------------------------------------*/ +/** * @brief uifw_map_surface: mapped surface buffer to system application * * @param[in] client Weyland client @@ -2944,6 +3254,7 @@ uifw_map_surface(struct wl_client *client, struct wl_resource *resource, struct uifw_client *uclient; struct uifw_drm_buffer *drm_buffer; struct uifw_gl_surface_state *gl_state; + int maptype; uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate); @@ -2976,13 +3287,49 @@ uifw_map_surface(struct wl_client *client, struct wl_resource *resource, /* check buffer type */ gl_state = (struct uifw_gl_surface_state *)es->renderer_state; - if ((gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) { - /* wl_shm_buffer not support */ - ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 4, 0, 0, 0, 0, 0); - uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, " - "not support)", surfaceid); - return; + if ((_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) || + (gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) { + /* wl_shm_buffer support ReadPixels */ + if ((_ico_win_mgr->compositor->renderer == NULL) || + (_ico_win_mgr->compositor->renderer->read_surface_pixels == NULL)) { + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 4, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) not support ReadPixels)", + surfaceid); + return; + } + else if ((gl_state != NULL) && (gl_state->buffer_type == BUFFER_TYPE_SHM) && + (es->buffer_ref.buffer != NULL)) { + maptype = ICO_WINDOW_MGR_MAP_TYPE_SHM; + } + else { + maptype = ICO_WINDOW_MGR_MAP_TYPE_PIXEL; + } + if (uclient->shmbuf == NULL) { + /* ReadPixcels but client has no shared memory buffer */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 5, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(client has no shared memory buffer)"); + return; + } + } + else { + /* H/W(GPU) driver EGL buffer (Intel only) */ + maptype = ICO_WINDOW_MGR_MAP_TYPE_EGL; + } + + /* maximum framerate */ + if (maptype == ICO_WINDOW_MGR_MAP_TYPE_EGL) { + if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_gpu)) + framerate = _ico_ivi_map_framerate_gpu; + } + else if (maptype == ICO_WINDOW_MGR_MAP_TYPE_SHM) { + if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_shm)) + framerate = _ico_ivi_map_framerate_shm; + } + else { + if ((framerate <= 0) || (framerate > _ico_ivi_map_framerate_pixel)) + framerate = _ico_ivi_map_framerate_pixel; } /* check same surface */ @@ -3003,7 +3350,7 @@ uifw_map_surface(struct wl_client *client, struct wl_resource *resource, if (! sm) { ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, - surfaceid, 5, 0, 0, 0, 0, 0); + surfaceid, 6, 0, 0, 0, 0, 0); uifw_trace("uifw_map_surface: Leave(malloc error)"); return; } @@ -3014,12 +3361,9 @@ uifw_map_surface(struct wl_client *client, struct wl_resource *resource, wl_list_init(&sm->surf_link); sm->usurf = usurf; sm->uclient = uclient; - sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL; + sm->type = maptype; sm->framerate = framerate; - if (sm->framerate > 60) sm->framerate = 60; - if (sm->framerate > 0) { - sm->interval = (1000 / sm->framerate) - 1; - } + sm->interval = (1000 / sm->framerate) - 1; wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link); wl_list_insert(usurf->surf_map.prev, &sm->surf_link); } @@ -3029,38 +3373,68 @@ uifw_map_surface(struct wl_client *client, struct wl_resource *resource, sm->framerate, framerate); if (sm->framerate != framerate) { sm->framerate = framerate; - if (sm->framerate > 60) sm->framerate = 60; - if (sm->framerate > 0) { - sm->interval = (1000 / sm->framerate) - 1; - } + sm->interval = (1000 / sm->framerate) - 1; win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time()); } return; } buffer = es->buffer_ref.buffer; - if ((buffer != NULL) && (gl_state->buffer_type == BUFFER_TYPE_EGL)) { + if (buffer != NULL) { sm->width = buffer->width; sm->height = buffer->height; - drm_buffer = (struct uifw_drm_buffer *)buffer->legacy_buffer; - if (drm_buffer != NULL) { - sm->stride = drm_buffer->stride[0]; - if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { - sm->format = EGL_TEXTURE_RGB; + if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { + sm->stride = sm->width; + sm->format = EGL_TEXTURE_RGBA; + if ((sm->width > 0) && (sm->height > 0)) { + sm->initflag = 1; } - else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { - sm->format = EGL_TEXTURE_RGBA; + uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", + maptype, surfaceid, framerate, buffer->width, buffer->height); + } + else { + drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( + (struct wl_resource *)buffer->legacy_buffer); + if (drm_buffer != NULL) { + sm->stride = drm_buffer->stride[0]; + if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { + sm->format = EGL_TEXTURE_RGB; + } + else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { + sm->format = EGL_TEXTURE_RGBA; + } + else { + /* unknown format, error */ + sm->format = EGL_NO_TEXTURE; + } + if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) && + (gl_state != NULL)) { + sm->initflag = 1; + } + uifw_debug("uifw_map_surface: map EGL surface=%08x,fps=%d,w/h=%d/%d", + surfaceid, framerate, buffer->width, buffer->height); } else { - /* unknown format, error */ - sm->format = EGL_NO_TEXTURE; - } - if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) && - (gl_state != NULL)) { - sm->initflag = 1; + uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", + surfaceid, framerate); } } } + else if (maptype != ICO_WINDOW_MGR_MAP_TYPE_EGL) { + sm->width = usurf->client_width; + sm->height = usurf->client_height; + sm->stride = sm->width; + sm->format = EGL_TEXTURE_RGBA; + if ((sm->width > 0) && (sm->height > 0)) { + sm->initflag = 1; + } + uifw_debug("uifw_map_surface: map type=%d,surface=%08x,fps=%d,w/h=%d/%d", + maptype, surfaceid, framerate, sm->width, sm->height); + } + else { + uifw_debug("uifw_map_surface: map EGL but no buffer surface=%08x,fps=%d", + surfaceid, framerate); + } /* send map event */ if (sm->initflag) { @@ -3087,6 +3461,8 @@ uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, struct uifw_win_surface *usurf; struct uifw_surface_map *sm, *sm_tmp; struct uifw_client *uclient; + struct ico_uifw_image_buffer *p; + int idx; uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid); @@ -3133,6 +3509,19 @@ uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, surfaceid, sm->type, sm->eglname, sm->width, sm->height, sm->stride, sm->format); } + if ((sm->type != ICO_WINDOW_MGR_MAP_TYPE_EGL) && + (sm->uclient->shmbuf != NULL)) { + /* reset shared memory buffer */ + for (idx = 0; idx < sm->uclient->bufnum; idx++) { + p = (struct ico_uifw_image_buffer *) + (((char *)sm->uclient->shmbuf) + idx * sm->uclient->bufsize); + if (p->surfaceid == surfaceid) { + p->surfaceid = 0; + p->settime = 0; + p->reftime = 0; + } + } + } wl_list_remove(&sm->surf_link); wl_list_remove(&sm->map_link); sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; @@ -3413,39 +3802,230 @@ win_mgr_select_surface(struct weston_surface *surface) * * @param[in] surface weston surface * @param[in] title title name - * @return none + * @return title string + * @retval != NULL title string + * @retval NULL no title string */ /*--------------------------------------------------------------------------*/ -static void +static char * win_mgr_set_title(struct weston_surface *surface, const char *title) { struct uifw_win_surface *usurf; + char *optpoint, *ppoint, *bpoint, *cpoint; + int layer, visible, raise, node, x, y, width, height, attribute; + int rx, ry, rw, rh; + char wktitle[ICO_IVI_WINNAME_LENGTH + 256]; uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title); usurf = find_uifw_win_surface_by_ws(surface); if (! usurf) { uifw_trace("win_mgr_set_title: Leave(Not Exist)"); - return; + return (char *)title; + } + + layer = -1; + visible = -1; + raise = -1; + node = -1; + x = -1; + y = -1; + width = -1; + height = -1; + attribute = -1; + + strncpy(wktitle, title, ICO_IVI_WINNAME_LENGTH+256-1); + wktitle[ICO_IVI_WINNAME_LENGTH+256-1] = 0; + + /* get option parameters */ + optpoint = strstr(wktitle, "@@"); + + if (optpoint != NULL) { + *optpoint = 0; + + usurf->uclient->privilege = 1; /* privilege application */ + ppoint = optpoint + 2; + while (1) { + bpoint = strtok(ppoint, "=;"); + ppoint = NULL; + if (! bpoint) break; + if (strcasecmp(bpoint, "layer") == 0) { + /* layer name or number */ + bpoint = strtok(ppoint, "=;"); + if (bpoint) { + if (strcasecmp(bpoint, "background") == 0) { + layer = _ico_ivi_background_layer; + } + else if (strcasecmp(bpoint, "default") == 0) { + layer = _ico_ivi_default_layer; + } + else if (strcasecmp(bpoint, "touch") == 0) { + layer = _ico_ivi_touch_layer; + } + else if (strcasecmp(bpoint, "cursor") == 0) { + layer = _ico_ivi_cursor_layer; + } + else if (strcasecmp(bpoint, "startup") == 0) { + layer = _ico_ivi_startup_layer; + } + else { + layer = strtol(bpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "show") == 0) { + /* show */ + visible = 1; + } + else if (strcasecmp(bpoint, "hide") == 0) { + /* hide */ + visible = 0; + } + else if (strcasecmp(bpoint, "raise") == 0) { + /* raiee */ + raise = 1; + } + else if (strcasecmp(bpoint, "lower") == 0) { + /* lower */ + raise = 0; + } + else if (strcasecmp(bpoint, "node") == 0) { + /* node */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + node = strtol(bpoint, (char **)0, 0); + } + } + else if (strcasecmp(bpoint, "position") == 0) { + /* position */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + cpoint = strtok(ppoint, ";"); + if (cpoint) { + x = strtol(bpoint, (char **)0, 0); + y = strtol(cpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "size") == 0) { + /* size */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + cpoint = strtok(ppoint, ";"); + if (cpoint) { + width = strtol(bpoint, (char **)0, 0); + height = strtol(cpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "attribute") == 0) { + /* attribute flags */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + attribute = strtol(bpoint, (char **)0, 0); + } + } + else if (strcasecmp(bpoint, "region") == 0) { + /* set input region */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = 0; + rw = 100; + rh = 50; + rx = strtol(bpoint, (char **)0, 0); + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ","); + if (bpoint) { + rw = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ";"); + if (bpoint) { + rh = strtol(bpoint, (char **)0, 0); + } + if (win_mgr_hook_inputregion) { + (*win_mgr_hook_inputregion)(1, usurf, rx, ry, rw, rh, 0, 0, + 0, 0, 0, 0, 0); + } + } + } + else if (strcasecmp(bpoint, "unregion") == 0) { + /* unset input region */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = 0; + rw = 100; + rh = 50; + rx = strtol(bpoint, (char **)0, 0); + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ","); + if (bpoint) { + rw = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ";"); + if (bpoint) { + rh = strtol(bpoint, (char **)0, 0); + } + if (win_mgr_hook_inputregion) { + (*win_mgr_hook_inputregion)(0, usurf, rx, ry, rw, rh, 0, 0, + 0, 0, 0, 0, 0); + } + } + } + } } - if (((usurf->width > 0) && (usurf->height > 0)) && - ((usurf->created == 0) || - (strncmp(title, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) { - strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1); - usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; - if (usurf->created == 0) { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0); - usurf->created = 1; + + if ((optpoint == NULL) || (wktitle[0] != 0)) { + if (((usurf->width > 0) && (usurf->height > 0)) && + ((usurf->created == 0) || + (strncmp(wktitle, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) { + strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); + usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; + if (usurf->created == 0) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0); + usurf->created = 1; + } + else { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0); + } } else { - ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0); + strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); + usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; } } - else { - strncpy(usurf->winname, title, ICO_IVI_WINNAME_LENGTH-1); - usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; + + if (optpoint) { + if (layer >= 0) { + uifw_set_window_layer(usurf->uclient->client, NULL, usurf->surfaceid, layer); + } + if (attribute >= 0) { + uifw_set_attributes(usurf->uclient->client, NULL, usurf->surfaceid, attribute); + } + if ((node >= 0) || (x >=0) || (y >= 0) || (width >=0) || (height >= 0)) { + if (node < 0) node = usurf->node_tbl->node; + if (x < 0) x = ICO_IVI_MAX_COORDINATE + 1; + if (y < 0) y = ICO_IVI_MAX_COORDINATE + 1; + if (width < 0) width = ICO_IVI_MAX_COORDINATE + 1; + if (height < 0) height = ICO_IVI_MAX_COORDINATE + 1; + uifw_set_positionsize(usurf->uclient->client, NULL, usurf->surfaceid, + node, x, y, width, height, 0); + } + if ((visible >= 0) || (raise >= 0)) { + if (visible < 0) visible = ICO_WINDOW_MGR_V_NOCHANGE; + if (raise < 0) raise = ICO_WINDOW_MGR_V_NOCHANGE; + uifw_set_visible(usurf->uclient->client, NULL, usurf->surfaceid, + visible, raise, 0); + } } uifw_trace("win_mgr_set_title: Leave"); + + return usurf->winname; } /*--------------------------------------------------------------------------*/ @@ -3530,7 +4110,7 @@ win_mgr_show_layer(int layertype, int show, void *data) usurf->raise = 1; win_mgr_change_surface(usurf->surface, -1, 1); } - if ((show == 0) || (ico_ivi_debugflag() & ICO_IVI_DEBUG_SHOW_INPUTLAYER)) { + if ((show == 0) || (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_INPUTLAYER)) { /* show input panel automatically */ ico_window_mgr_set_visible(usurf, show | 2); } @@ -3595,7 +4175,7 @@ win_mgr_fullscreen(int event, struct weston_surface *surface) } switch(event) { - case SHELL_FULLSCREEN_ISTOP: /* check if top surrace */ + case SHELL_FULLSCREEN_ISTOP: /* check if top surface */ if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) { if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue; @@ -3636,7 +4216,7 @@ win_mgr_fullscreen(int event, struct weston_surface *surface) height = usurf->node_tbl->disp_height; sx = 0; sy = 0; - win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy); + win_mgr_surface_map(usurf->surface, &width, &height, &sx, &sy); } if ((usurf->surface != NULL) && (usurf->mapped != 0) && (usurf->surface->buffer_ref.buffer != NULL)) { @@ -3651,7 +4231,7 @@ win_mgr_fullscreen(int event, struct weston_surface *surface) height = usurf->node_tbl->disp_height; sx = 0; sy = 0; - win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy); + win_mgr_surface_map(usurf->surface, &width, &height, &sx, &sy); } break; default: @@ -3681,6 +4261,7 @@ win_mgr_reset_focus(struct uifw_win_surface *usurf) seat = container_of (_ico_win_mgr->compositor->seat_list.next, struct weston_seat, link); surface = usurf->surface; if ((seat != NULL) && (surface != NULL)) { +#if 0 /* pointer grab can not release */ /* reset pointer focus */ if ((seat->pointer != NULL) && (seat->pointer->focus == surface)) { weston_pointer_set_focus(seat->pointer, NULL, @@ -3690,6 +4271,7 @@ win_mgr_reset_focus(struct uifw_win_surface *usurf) if ((seat->touch != NULL) && (seat->touch->focus == surface)) { weston_touch_set_focus(seat, NULL); } +#endif /* pointer grab can not release */ /* reset keyboard focus */ if ((seat->keyboard != NULL) && (seat->keyboard->focus == surface)) { weston_keyboard_set_focus(seat->keyboard, NULL); @@ -3789,7 +4371,7 @@ win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise) { struct uifw_win_surface *eu; - uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%x type=%d", + uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%d type=%x", (int)usurf, raise, (int)usurf->win_layer->layer, usurf->layertype); wl_list_remove(&usurf->ivi_layer); @@ -4037,6 +4619,12 @@ ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, int num_mgr = 0; struct uifw_manager* mgr; + /* if DESTROY and no send CREATE, Nop */ + if ((event == ICO_WINDOW_MGR_WINDOW_DESTROYED) && + (usurf != NULL) && (usurf->created == 0)) { + return 0; + } + /* if appid not fix, check and fix appid */ if ((usurf != NULL) && (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) { @@ -4096,7 +4684,7 @@ ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, case ICO_WINDOW_MGR_WINDOW_CONFIGURE: uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE" - "(surf=%08x,app=%s,node=%x,type=%x,layer=%x," + "(surf=%08x,app=%s,node=%x,type=%x,layer=%d," "x/y=%d/%d,w/h=%d/%d,hint=%d)", (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid, usurf->node_tbl->node, usurf->layertype, @@ -4118,7 +4706,7 @@ ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, case ICO_WINDOW_MGR_LAYER_VISIBLE: uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE" - "(layer=%x,visivle=%d)", (int)mgr->resource, param1, param2); + "(layer=%d,visivle=%d)", (int)mgr->resource, param1, param2); ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2); break; @@ -4166,7 +4754,7 @@ win_mgr_set_scale(struct uifw_win_surface *usurf) scaley, usurf->height, usurf->client_height); usurf->xadd = 0; usurf->yadd = 0; - if ((ico_ivi_debugflag() & ICO_IVI_DEBUG_FIXED_ASPECT) || + if ((ico_ivi_optionflag() & ICO_IVI_OPTION_FIXED_ASPECT) || (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT)) { if (scalex > scaley) { scalex = scaley; @@ -4311,14 +4899,13 @@ ico_window_mgr_get_client_usurf(const char *target) * @retval =1 visible * @retval =0 not visible * @retval =-1 surface visible but layer not vlsible - * @retval =-2 surface visible but lower + * @retval =-2 surface visible but lower(currently not support) */ /*--------------------------------------------------------------------------*/ WL_EXPORT int ico_window_mgr_is_visible(struct uifw_win_surface *usurf) { - if ((usurf->visible == 0) || (usurf->surface == NULL) || - (usurf->mapped == 0) || (usurf->surface->buffer_ref.buffer == NULL)) { + if ((usurf->visible == 0) || (usurf->surface == NULL) || (usurf->mapped == 0)) { return 0; } if (usurf->win_layer->visible == 0) { @@ -4378,16 +4965,16 @@ ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data /*--------------------------------------------------------------------------*/ /** - * @brief ico_window_mgr_set_hook_visible: set input region hook routine + * @brief ico_window_mgr_set_hook_change: set input region hook routine * - * @param[in] hook_visible hook routine + * @param[in] hook_change hook routine * @return none */ /*--------------------------------------------------------------------------*/ WL_EXPORT void -ico_window_mgr_set_hook_visible(void (*hook_visible)(struct uifw_win_surface *usurf)) +ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf)) { - win_mgr_hook_visible = hook_visible; + win_mgr_hook_change = hook_change; } /*--------------------------------------------------------------------------*/ @@ -4406,6 +4993,25 @@ ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *us /*--------------------------------------------------------------------------*/ /** + * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine + * + * @param[in] hook_inputregion hook routine + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_hook_inputregion( + void (*hook_inputregion)(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, + int32_t height, int32_t hotspot_x, int32_t hotspot_y, + int32_t cursor_x, int32_t cursor_y, int32_t cursor_width, + int32_t cursor_height, uint32_t attr)) +{ + win_mgr_hook_inputregion = hook_inputregion; +} + +/*--------------------------------------------------------------------------*/ +/** * @brief module_init: initialize ico_window_mgr * this function called from ico_pluign_loader * @@ -4435,7 +5041,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) /* get ivi debug level */ section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL); if (section) { - weston_config_section_get_int(section, "flag", &_ico_ivi_debug_flag, 0); + weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0); weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3); } @@ -4510,6 +5116,26 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) if (_ico_ivi_inputpanel_anima_time < 100) _ico_ivi_inputpanel_anima_time = _ico_ivi_animation_time; + /* get thumbnail maximum frame rate */ + section = weston_config_get_section(ec->config, "ivi-thumbnail", NULL, NULL); + if (section) { + weston_config_section_get_int(section, "gpu_accel_fps", + &_ico_ivi_map_framerate_gpu, 30); + if ((_ico_ivi_map_framerate_gpu <= 0) || (_ico_ivi_map_framerate_gpu > 60)) { + _ico_ivi_map_framerate_gpu = 30; + } + weston_config_section_get_int(section, "shm_buffer_fps", + &_ico_ivi_map_framerate_shm, 5); + if ((_ico_ivi_map_framerate_shm <= 0) || (_ico_ivi_map_framerate_shm > 10)) { + _ico_ivi_map_framerate_shm = 5; + } + weston_config_section_get_int(section, "no_accel_fps", + &_ico_ivi_map_framerate_pixel, 10); + if ((_ico_ivi_map_framerate_pixel <= 0) || (_ico_ivi_map_framerate_pixel > 20)) { + _ico_ivi_map_framerate_pixel = 10; + } + } + /* create ico_window_mgr management table */ _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr)); if (_ico_win_mgr == NULL) { @@ -4554,7 +5180,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) _ico_num_nodes = 0; wl_list_for_each (output, &ec->output_list, link) { wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link); - _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurrace; + _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurface; wl_list_insert(output->animation_list.prev, &_ico_win_mgr->map_animation[_ico_num_nodes].link); _ico_num_nodes++; @@ -4621,10 +5247,9 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) /* get seat for touch down counter check */ touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link); - _ico_win_mgr->waittime = 1000; loop = wl_display_get_event_loop(ec->wl_display); _ico_win_mgr->wait_mapevent = - wl_event_loop_add_timer(loop, win_mgr_timer_mapsurrace, NULL); + wl_event_loop_add_timer(loop, win_mgr_timer_mapsurface, NULL); wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000); /* Hook to IVI-Shell */ @@ -4632,7 +5257,7 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) ico_ivi_shell_hook_unbind(win_mgr_unbind_client); ico_ivi_shell_hook_create(win_mgr_register_surface); ico_ivi_shell_hook_destroy(win_mgr_destroy_surface); - ico_ivi_shell_hook_map(win_mgr_map_surface); + ico_ivi_shell_hook_map(win_mgr_surface_map); ico_ivi_shell_hook_configure(win_mgr_shell_configure); ico_ivi_shell_hook_select(win_mgr_select_surface); ico_ivi_shell_hook_title(win_mgr_set_title); @@ -4650,9 +5275,43 @@ module_init(struct weston_compositor *ec, int *argc, char *argv[]) _ico_ivi_default_layer, _ico_ivi_background_layer); uifw_info("ico_window_mgr: layer touch=%d cursor=%d startup=%d", _ico_ivi_touch_layer, _ico_ivi_cursor_layer, _ico_ivi_startup_layer); - uifw_info("ico_window_mgr: option flag=0x%04x log level=%d", - _ico_ivi_debug_flag, _ico_ivi_debug_level); + uifw_info("ico_window_mgr: thumbnail framerate gpu_accel=%d shm_buff=%d no_accel=%d", + _ico_ivi_map_framerate_gpu, _ico_ivi_map_framerate_shm, + _ico_ivi_map_framerate_pixel); + uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x", + _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff, + (_ico_ivi_debug_level >> 16) & 0x0ffff); + + /* get GPU type for H/W support of the thumbnail acquisition */ + if (ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_NODEPEND) { + /* can not use GPU H/W dependent acceleration */ + _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; + uifw_info("ico_window_mgr: GPU type=No Acceleration by option flag"); + } + else if (ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_DEPENDINTEL) { + /* use Intel GPU H/W dependent acceleration */ + _ico_ivi_gpu_type = ICO_GPUTYPE_INTEL_SANDYBRIDGE; + uifw_info("ico_window_mgr: GPU type=Acceleration Intel GPU by option flag"); + } + else { + _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; + p = (char *)glGetString(GL_RENDERER); + if (p) { + uifw_info("ico_window_mgr: Renderer=<%s>", p); + for (i = 0; ico_window_mgr_gpu_type[i].gpu_type; i++) { + if (strncmp(p, ico_window_mgr_gpu_type[i].gpu_name, + strlen(ico_window_mgr_gpu_type[i].gpu_name)) == 0) { + _ico_ivi_gpu_type = ico_window_mgr_gpu_type[i].gpu_type; + uifw_info("ico_window_mgr: GPU type=Acceleration %d", _ico_ivi_gpu_type); + break; + } + } + } + if (_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) { + uifw_info("ico_window_mgr: GPU type=No Acceleration(can not find GPU)"); + } + } uifw_info("ico_window_mgr: Leave(module_init)"); return 0; diff --git a/src/ico_window_mgr.h b/src/ico_window_mgr.h index 74bf5d4..7fa21c7 100644 --- a/src/ico_window_mgr.h +++ b/src/ico_window_mgr.h @@ -30,212 +30,20 @@ #ifndef _ICO_WINDOW_MGR_H_ #define _ICO_WINDOW_MGR_H_ -/* Manager management table */ -struct uifw_manager { - struct wl_resource *resource; /* Manager resource */ - int manager; /* Manager(=event send flag) */ - struct wl_list link; /* link to next manager */ +/* surface image buffer in wl_shm_pool */ +struct ico_uifw_image_buffer { + uint32_t magich; /* Magic number, fixed "UIFH"(no NULL terminate)*/ + uint32_t surfaceid; /* surface id */ + uint32_t settime; /* buffer set time(set by weston) */ + uint32_t width; /* width */ + uint32_t height; /* height */ + uint32_t reftime; /* buffer refer time(set by app) */ + uint32_t res; /* (unused) */ + uint32_t magict; /* Magic number, fixed "UIFT"(no NULL terminate)*/ + unsigned char image[4]; /* surface image(variable length) */ }; -/* Cleint management table */ -struct uifw_client { - struct wl_client *client; /* Wayland client */ - int pid; /* ProcessId (pid) */ - char appid[ICO_IVI_APPID_LENGTH]; /* ApplicationId(from AppCore AUL) */ - struct uifw_manager *mgr; /* Manager table (if manager) */ - char manager; /* Manager flag (Need send event) */ - char fixed_appid; /* ApplicationId fix flag(and counter) */ - char noconfigure; /* no need configure event */ - char res; /* (unused) */ - struct wl_list surface_link; /* surface list of same client */ - struct wl_list link; -}; - -/* Node information */ -struct uifw_node_table { - uint16_t node; /* node Id */ - uint16_t displayno; /* weston display number */ - struct weston_output *output; /* weston output */ - int disp_x; /* display frame buffer X-coordinate */ - int disp_y; /* display frame buffer Y-coordinate */ - int disp_width; /* display width */ - int disp_height; /* display height */ -}; - -/* Layer management table */ -struct uifw_win_layer { - uint32_t layer; /* Layer Id */ - char visible; /* visibility */ - char layertype; /* layer type */ - char res[2]; /* (unused) */ - struct wl_list surface_list; /* Surfacae list */ - struct wl_list link; /* Link pointer for layer list */ -}; - -/* Surface map table */ -struct uifw_win_surface; -struct uifw_surface_map { - struct uifw_win_surface *usurf; /* UIFW surface */ - struct uifw_client *uclient; /* UIFW client */ - uint32_t eglname; /* EGL buffer name */ - uint32_t format; /* format */ - uint16_t type; /* buffer type(currently only EGL buffer)*/ - uint16_t width; /* width */ - uint16_t height; /* height */ - uint16_t stride; /* stride */ - uint16_t framerate; /* update frame rate (frame/sec) */ - uint16_t interval; /* interval time (ms) */ - uint32_t lasttime; /* last event time (ms) */ - char initflag; /* map event send flag(0=no/1=yes) */ - char eventque; /* send event queue flag */ - char res[2]; /* (unused) */ - struct wl_list map_link; /* surface map list */ - struct wl_list surf_link; /* surface map list from UIFW surface */ -}; - -/* UIFW surface */ -struct shell_surface; -struct uifw_win_surface { - uint32_t surfaceid; /* UIFW SurfaceId */ - struct uifw_node_table *node_tbl; /* Node manager of ico_window_mgr */ - struct uifw_win_layer *win_layer; /* surface layer */ - struct uifw_win_layer *old_layer; /* saved surface layer for change full screen*/ - struct weston_surface *surface; /* Weston surface */ - struct shell_surface *shsurf; /* Shell(IVI-Shell) surface */ - struct uifw_client *uclient; /* Client */ - struct weston_transform transform; /* transform matrix */ - float scalex; /* surface transform scale of X */ - float scaley; /* surface transform scale of Y */ - int x; /* X-coordinate */ - int y; /* Y-coordinate */ - short xadd; /* X-coordinate delta */ - short yadd; /* Y-coordinate delta */ - uint16_t width; /* Width */ - uint16_t height; /* Height */ - uint16_t client_width; /* Widht that a client(App) required */ - uint16_t client_height; /* Height that a client(App) required */ - uint16_t conf_width; /* Width that notified to client */ - uint16_t conf_height; /* Height that notified to client */ - uint32_t attributes; /* surface attributes */ - char winname[ICO_IVI_WINNAME_LENGTH];/* Window name */ - char disable; /* can not display */ - char visible; /* visibility */ - char raise; /* raise(top of the layer) */ - char created; /* sended created event to manager */ - char mapped; /* end of map */ - char restrain_configure; /* restrant configure event */ - char set_transform; /* surface transform flag */ - char layertype; /* surface layer type */ - char old_layertype; /* surface old layer type */ - char res[3]; /* (unused) */ - struct _uifw_win_surface_animation { /* wndow animation */ - struct weston_animation animation; /* weston animation control */ - uint16_t type; /* current animation type */ - uint16_t anima; /* curremt animation Id */ - uint16_t next_anima; /* next animation Id */ - uint16_t hide_anima; /* animation Id for hide */ - uint16_t hide_time; /* animation time(ms) for hide */ - uint16_t show_anima; /* animation Id for show */ - uint16_t show_time; /* animation time(ms) for show */ - uint16_t move_anima; /* animation Id for move */ - uint16_t move_time; /* animation time(ms) for move */ - uint16_t resize_anima; /* animation Id for resize */ - uint16_t resize_time; /* animation time(ms) for resize */ - uint16_t time; /* current animation time(ms) */ - uint16_t pos_x; /* start/end X-coordinate */ - uint16_t pos_y; /* start/end Y-coordinate */ - uint16_t pos_width; /* start/end width */ - uint16_t pos_height; /* start/end height */ - short current; /* animation current percentage */ - char state; /* animation state */ - char visible; /* need hide(1)/show(2) at end of animation*/ - char restrain_configure; /* restrain surface resize */ - char ahalf; /* after half */ - char no_configure; /* no send configure to client */ - char res; /* (unused) */ - uint32_t starttime; /* start time(ms) */ - void *animadata; /* animation data */ - } animation; - struct wl_list ivi_layer; /* surface list of same layer */ - struct wl_list client_link; /* surface list of same client */ - struct wl_list surf_map; /* surface map list */ - struct wl_list input_region; /* surface input region list */ - struct uifw_win_surface *next_idhash; /* UIFW SurfaceId hash list */ - struct uifw_win_surface *next_wshash; /* Weston SurfaceId hash list */ -}; - -/* layer type */ -#define ICO_WINDOW_MGR_LAYER_TYPE_NORMAL 0 /* normal layer */ -#define ICO_WINDOW_MGR_LAYER_TYPE_BACKGROUND 1 /* touch input layer */ -#define ICO_WINDOW_MGR_LAYER_TYPE_INPUT 7 /* touch input layer */ -#define ICO_WINDOW_MGR_LAYER_TYPE_CURSOR 8 /* cursor layer */ - -/* animation operation */ -/* default animation */ -#define ICO_WINDOW_MGR_ANIMATION_NONE 0 /* no animation */ - -/* return code of animation hook function*/ -#define ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA -1 /* no animation */ -#define ICO_WINDOW_MGR_ANIMATION_RET_ANIMA 0 /* animation */ -#define ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL 1 /* animation but no control */ - -/* animation state */ -#define ICO_WINDOW_MGR_ANIMATION_STATE_NONE 0 /* not animation */ -#define ICO_WINDOW_MGR_ANIMATION_STATE_SHOW 1 /* show(in) animation */ -#define ICO_WINDOW_MGR_ANIMATION_STATE_HIDE 2 /* hide(out) animation */ -#define ICO_WINDOW_MGR_ANIMATION_STATE_MOVE 3 /* move animation */ -#define ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE 4 /* resize animation */ - -/* extended(plugin) animation operation */ -#define ICO_WINDOW_MGR_ANIMATION_NAME 0 /* convert animation name to Id */ -#define ICO_WINDOW_MGR_ANIMATION_DESTROY 99 /* surface destroy */ -#define ICO_WINDOW_MGR_ANIMATION_OPNONE 0 /* no animation */ -#define ICO_WINDOW_MGR_ANIMATION_OPHIDE 1 /* change to hide */ -#define ICO_WINDOW_MGR_ANIMATION_OPSHOW 2 /* change to show */ -#define ICO_WINDOW_MGR_ANIMATION_OPMOVE 3 /* surface move */ -#define ICO_WINDOW_MGR_ANIMATION_OPRESIZE 4 /* surface resize */ -#define ICO_WINDOW_MGR_ANIMATION_OPCANCEL 9 /* animation cancel */ -#define ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS 11 /* change to hide with position */ -#define ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS 12 /* change to show with position */ - -/* Prototype for function */ - /* surface visible control */ -void ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible); - /* get client applicationId */ -char *ico_window_mgr_get_appid(struct wl_client* client); - /* get display coordinate */ -void ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y); - /* change weston surface */ -void ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, int x, int y, - int width, int height); - /* surface change */ -void ico_window_mgr_change_surface(struct uifw_win_surface *usurf, - const int to, const int manager); - /* check active keyboard surface */ -int ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf); - /* get UIFW client table */ -struct uifw_client *ico_window_mgr_get_uclient(const char *appid); - /* get UIFW surface table */ -struct uifw_win_surface *ico_window_mgr_get_usurf(const uint32_t surfaceid); - /* get UIFW surface table */ -struct uifw_win_surface *ico_window_mgr_get_usurf_client(const uint32_t surfaceid, - struct wl_client *client); - /* get application surface */ -struct uifw_win_surface *ico_window_mgr_get_client_usurf(const char *target); - /* rebuild surface layer list */ -void ico_window_mgr_restack_layer(struct uifw_win_surface *usurf); - /* touch layer control for input manager*/ -void ico_window_mgr_touch_layer(int omit); - /* chek surface visibility */ -int ico_window_mgr_is_visible(struct uifw_win_surface *usurf); - /* set active surface */ -void ico_window_mgr_active_surface(struct weston_surface *surface); - /* set window animation hook */ -void ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data)); - /* set surface visible change hook */ -void ico_window_mgr_set_hook_visible(void (*hook_visible)(struct uifw_win_surface *usurf)); - /* set surface destory hook */ -void ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf)); +#define ICO_UIFW_IMAGE_BUFFER_MAGICH "UIFH" +#define ICO_UIFW_IMAGE_BUFFER_MAGICT "UIFT" #endif /*_ICO_WINDOW_MGR_H_*/ - diff --git a/src/ico_window_mgr_private.h b/src/ico_window_mgr_private.h new file mode 100644 index 0000000..34450e1 --- /dev/null +++ b/src/ico_window_mgr_private.h @@ -0,0 +1,244 @@ +/* + * Copyright © 2010-2011 Intel Corporation + * Copyright © 2008-2011 Kristian Høgsberg + * Copyright © 2013 TOYOTA MOTOR CORPORATION. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the copyright holders not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. The copyright holders make + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/** + * @brief Public functions in ico_window_mgr Weston plugin + * + * @date Jul-26-2013 + */ + +#ifndef _ICO_WINDOW_MGR_PRIVATE_H_ +#define _ICO_WINDOW_MGR_PRIVATE_H_ + +/* Manager management table */ +struct uifw_manager { + struct wl_resource *resource; /* Manager resource */ + int manager; /* Manager(=event send flag) */ + struct wl_list link; /* link to next manager */ +}; + +/* Cleint management table */ +struct uifw_client { + struct wl_client *client; /* Wayland client */ + int pid; /* ProcessId (pid) */ + char appid[ICO_IVI_APPID_LENGTH];/* ApplicationId(from AppCore AUL) */ + struct uifw_manager *mgr; /* Manager table (if manager) */ + char manager; /* Manager flag (Need send event) */ + char fixed_appid; /* ApplicationId fix flag(and counter) */ + char noconfigure; /* no need configure event */ + char privilege; /* privilege aplication */ + char *shmbuf; /* shared memory for surface image */ + int bufsize; /* shared memory buffer size */ + int bufnum; /* number of shared memory buffer */ + struct wl_list surface_link; /* surface list of same client */ + struct wl_list link; +}; + +/* Node information */ +struct uifw_node_table { + uint16_t node; /* node Id */ + uint16_t displayno; /* weston display number */ + struct weston_output *output; /* weston output */ + int disp_x; /* display frame buffer X-coordinate */ + int disp_y; /* display frame buffer Y-coordinate */ + int disp_width; /* display width */ + int disp_height; /* display height */ +}; + +/* Layer management table */ +struct uifw_win_layer { + uint32_t layer; /* Layer Id */ + char visible; /* visibility */ + char layertype; /* layer type */ + char res[2]; /* (unused) */ + struct wl_list surface_list; /* Surfacae list */ + struct wl_list link; /* Link pointer for layer list */ +}; + +/* Surface map table */ +struct uifw_win_surface; +struct uifw_surface_map { + struct uifw_win_surface *usurf; /* UIFW surface */ + struct uifw_client *uclient; /* UIFW client */ + struct weston_buffer *curbuf; /* current buffer */ + uint32_t eglname; /* EGL buffer name */ + uint32_t format; /* format */ + uint16_t type; /* buffer type(currently only EGL buffer)*/ + uint16_t width; /* width */ + uint16_t height; /* height */ + uint16_t stride; /* stride */ + uint16_t framerate; /* update frame rate (frame/sec) */ + uint16_t interval; /* interval time (ms) */ + uint32_t lasttime; /* last event time (ms) */ + char initflag; /* map event send flag(0=no/1=yes) */ + char eventque; /* send event queue flag */ + char res[2]; /* (unused) */ + struct wl_list map_link; /* surface map list */ + struct wl_list surf_link; /* surface map list from UIFW surface */ +}; + +/* UIFW surface */ +struct shell_surface; +struct uifw_win_surface { + uint32_t surfaceid; /* UIFW SurfaceId */ + struct uifw_node_table *node_tbl; /* Node manager of ico_window_mgr */ + struct uifw_win_layer *win_layer; /* surface layer */ + struct uifw_win_layer *old_layer; /* saved surface layer for change full screen*/ + struct weston_surface *surface; /* Weston surface */ + struct shell_surface *shsurf; /* Shell(IVI-Shell) surface */ + struct uifw_client *uclient; /* Client */ + struct weston_transform transform; /* transform matrix */ + float scalex; /* surface transform scale of X */ + float scaley; /* surface transform scale of Y */ + int x; /* X-coordinate */ + int y; /* Y-coordinate */ + short xadd; /* X-coordinate delta */ + short yadd; /* Y-coordinate delta */ + uint16_t width; /* Width */ + uint16_t height; /* Height */ + uint16_t client_width; /* Widht that a client(App) required */ + uint16_t client_height; /* Height that a client(App) required */ + uint16_t conf_width; /* Width that notified to client */ + uint16_t conf_height; /* Height that notified to client */ + uint32_t attributes; /* surface attributes */ + char winname[ICO_IVI_WINNAME_LENGTH];/* Window name */ + char disable; /* can not display */ + char visible; /* visibility */ + char raise; /* raise(top of the layer) */ + char created; /* sended created event to manager */ + char mapped; /* end of map */ + char restrain_configure; /* restrant configure event */ + char set_transform; /* surface transform flag */ + char layertype; /* surface layer type */ + char old_layertype; /* surface old layer type */ + char res[3]; /* (unused) */ + struct _uifw_win_surface_animation { /* wndow animation */ + struct weston_animation animation; /* weston animation control */ + uint16_t type; /* current animation type */ + uint16_t anima; /* curremt animation Id */ + uint16_t next_anima; /* next animation Id */ + uint16_t hide_anima; /* animation Id for hide */ + uint16_t hide_time; /* animation time(ms) for hide */ + uint16_t show_anima; /* animation Id for show */ + uint16_t show_time; /* animation time(ms) for show */ + uint16_t move_anima; /* animation Id for move */ + uint16_t move_time; /* animation time(ms) for move */ + uint16_t resize_anima; /* animation Id for resize */ + uint16_t resize_time; /* animation time(ms) for resize */ + uint16_t time; /* current animation time(ms) */ + uint16_t pos_x; /* start/end X-coordinate */ + uint16_t pos_y; /* start/end Y-coordinate */ + uint16_t pos_width; /* start/end width */ + uint16_t pos_height; /* start/end height */ + short current; /* animation current percentage */ + char state; /* animation state */ + char visible; /* need hide(1)/show(2) at end of animation*/ + char restrain_configure; /* restrain surface resize */ + char ahalf; /* after half */ + char no_configure; /* no send configure to client */ + char res; /* (unused) */ + uint32_t starttime; /* start time(ms) */ + void *animadata; /* animation data */ + } animation; + struct wl_list ivi_layer; /* surface list of same layer */ + struct wl_list client_link; /* surface list of same client */ + struct wl_list surf_map; /* surface map list */ + struct wl_list input_region; /* surface input region list */ + struct uifw_win_surface *next_idhash; /* UIFW SurfaceId hash list */ + struct uifw_win_surface *next_wshash; /* Weston SurfaceId hash list */ +}; + +/* animation operation */ +/* default animation */ +#define ICO_WINDOW_MGR_ANIMATION_NONE 0 /* no animation */ + +/* return code of animation hook function*/ +#define ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA -1 /* no animation */ +#define ICO_WINDOW_MGR_ANIMATION_RET_ANIMA 0 /* animation */ +#define ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL 1 /* animation but no control */ + +/* animation state */ +#define ICO_WINDOW_MGR_ANIMATION_STATE_NONE 0 /* not animation */ +#define ICO_WINDOW_MGR_ANIMATION_STATE_SHOW 1 /* show(in) animation */ +#define ICO_WINDOW_MGR_ANIMATION_STATE_HIDE 2 /* hide(out) animation */ +#define ICO_WINDOW_MGR_ANIMATION_STATE_MOVE 3 /* move animation */ +#define ICO_WINDOW_MGR_ANIMATION_STATE_RESIZE 4 /* resize animation */ + +/* extended(plugin) animation operation */ +#define ICO_WINDOW_MGR_ANIMATION_NAME 0 /* convert animation name to Id */ +#define ICO_WINDOW_MGR_ANIMATION_DESTROY 99 /* surface destroy */ +#define ICO_WINDOW_MGR_ANIMATION_OPNONE 0 /* no animation */ +#define ICO_WINDOW_MGR_ANIMATION_OPHIDE 1 /* change to hide */ +#define ICO_WINDOW_MGR_ANIMATION_OPSHOW 2 /* change to show */ +#define ICO_WINDOW_MGR_ANIMATION_OPMOVE 3 /* surface move */ +#define ICO_WINDOW_MGR_ANIMATION_OPRESIZE 4 /* surface resize */ +#define ICO_WINDOW_MGR_ANIMATION_OPCANCEL 9 /* animation cancel */ +#define ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS 11 /* change to hide with position */ +#define ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS 12 /* change to show with position */ + +/* Prototype for function */ + /* surface visible control */ +void ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible); + /* get client applicationId */ +char *ico_window_mgr_get_appid(struct wl_client* client); + /* get display coordinate */ +void ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y); + /* change weston surface */ +void ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, int x, int y, + int width, int height); + /* surface change */ +void ico_window_mgr_change_surface(struct uifw_win_surface *usurf, + const int to, const int manager); + /* check active keyboard surface */ +int ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf); + /* get UIFW client table */ +struct uifw_client *ico_window_mgr_get_uclient(const char *appid); + /* get UIFW surface table */ +struct uifw_win_surface *ico_window_mgr_get_usurf(const uint32_t surfaceid); + /* get UIFW surface table */ +struct uifw_win_surface *ico_window_mgr_get_usurf_client(const uint32_t surfaceid, + struct wl_client *client); + /* get application surface */ +struct uifw_win_surface *ico_window_mgr_get_client_usurf(const char *target); + /* rebuild surface layer list */ +void ico_window_mgr_restack_layer(struct uifw_win_surface *usurf); + /* touch layer control for input manager*/ +void ico_window_mgr_touch_layer(int omit); + /* chek surface visibility */ +int ico_window_mgr_is_visible(struct uifw_win_surface *usurf); + /* set active surface */ +void ico_window_mgr_active_surface(struct weston_surface *surface); + /* set window animation hook */ +void ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data)); + /* set surface attribute change hook */ +void ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf)); + /* set surface destory hook */ +void ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf)); + /* set input region set/unset hook */ +void ico_window_mgr_set_hook_inputregion(void (*hook_inputregion)( + int set, struct uifw_win_surface *usurf, int32_t x, int32_t y, + int32_t width, int32_t height, int32_t hotspot_x, int32_t hotspot_y, + int32_t cursor_x, int32_t cursor_y, int32_t cursor_width, + int32_t cursor_height, uint32_t attr)); + +#endif /*_ICO_WINDOW_MGR_PRIVATE_H_*/ diff --git a/src/ico_window_mgr_speed_test.c b/src/ico_window_mgr_speed_test.c new file mode 100644 index 0000000..f9440ae --- /dev/null +++ b/src/ico_window_mgr_speed_test.c @@ -0,0 +1,4997 @@ +/* + * Copyright © 2010-2011 Intel Corporation + * Copyright © 2008-2011 Kristian Høgsberg + * Copyright © 2013 TOYOTA MOTOR CORPORATION. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the copyright holders not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. The copyright holders make + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/** + * @brief Multi Window Manager (Weston(Wayland) PlugIn) + * + * @date Jul-26-2013 + */ + +#define PIXEL_SPEED_TEST 1 + +#define _GNU_SOURCE + +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> +#include <unistd.h> +#include <linux/input.h> +#include <assert.h> +#include <signal.h> +#include <math.h> +#include <time.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <limits.h> +#include <pixman.h> +#include <wayland-server.h> +#include <dirent.h> +#include <aul/aul.h> +#include <bundle.h> + +#include <EGL/egl.h> +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#include <GL/internal/dri_interface.h> + +#include <weston/compositor.h> +#include <libdrm/intel_bufmgr.h> +#include "ico_ivi_common.h" +#include "ico_ivi_shell.h" +#include "ico_window_mgr.h" +#include "desktop-shell-server-protocol.h" +#include "ico_window_mgr-server-protocol.h" + + +/* SurfaceID */ +#define INIT_SURFACE_IDS 1024 /* SurfaceId table initiale size */ +#define ADD_SURFACE_IDS 512 /* SurfaceId table additional size */ +#define SURCAFE_ID_MASK 0x0ffff /* SurfaceId bit mask pattern */ +#define UIFW_HASH 64 /* Hash value (2's compliment) */ + +/* Internal fixed value */ +#define ICO_WINDOW_MGR_APPID_FIXCOUNT 5 /* retry count of appid fix */ + /* show/hide animation with position */ +#define ICO_WINDOW_MGR_ANIMATION_POS 0x10000000 + +/* GPU type code */ +#define ICO_GPUTYPE_NOACCELERATION 0 /* Do not use GPU-dependent acceleration*/ +#define ICO_GPUTYPE_INTEL_SANDYBRIDGE 1 /* Intel Sandybridge Mobile */ + +/* Code for Intel Sandybridge Mobile GPU dependent acceleration */ + +/* wl_drm_buffer (inport from mesa-9.1.3 & mesa-9.2.1/ */ +/* src/egl/wayland/wayland-drm/wayland-drm.h) */ +struct uifw_drm_buffer { + struct wl_resource *resource; + void *drm; /* struct wl_drm */ + int32_t width, height; + uint32_t format; + const void *driver_format; + int32_t offset[3]; + int32_t stride[3]; + void *driver_buffer; +}; + +/* __DRIimage (inport from mesa-9.1.3/src/mesa/drivers/dri/intel/intel_regions.h */ +/* mesa-9.2.1/src/mesa/drivers/dri/i915/intel_regions.h */ +/* mesa-9.2.1/src/mesa/drivers/dri/i965/intel_regions.h) */ +struct uifw_intel_region { /* struct intel_region for mesa 9.2.1 */ + void *bo; /**< buffer manager's buffer */ + uint32_t refcount; /**< Reference count for region */ + uint32_t cpp; /**< bytes per pixel */ + uint32_t width; /**< in pixels */ + uint32_t height; /**< in pixels */ + uint32_t pitch; /**< in bytes */ + uint32_t tiling; /**< Which tiling mode the region is in */ + uint32_t name; /**< Global name for the bo */ +}; + +struct uifw_dri_image { /* struct __DRIimageRec */ + struct uifw_intel_region *region; + int internal_format; + uint32_t dri_format; + uint32_t format; + uint32_t offset; + uint32_t strides[3]; + uint32_t offsets[3]; + void *planar_format; /* intel_image_format */ + uint32_t width; + uint32_t height; + uint32_t tile_x; + uint32_t tile_y; + bool has_depthstencil; /* i965 only */ + void *data; +}; + +/* gl_surface_state (inport from weston-1.2.1/src/gl-renderer.c, */ +/* weston-1.3.1/src/gl-renderer.c */ +enum buffer_type { + BUFFER_TYPE_NULL, + BUFFER_TYPE_SHM, + BUFFER_TYPE_EGL +}; +struct uifw_gl_surface_state { /* struct gl_surface_state */ + GLfloat color[4]; + struct gl_shader *shader; + + GLuint textures[3]; + int num_textures; + int needs_full_upload; + pixman_region32_t texture_damage; + + void *images[3]; /* EGLImageKHR */ + GLenum target; + int num_images; + + struct weston_buffer_reference buffer_ref; + enum buffer_type buffer_type; + int pitch; /* in pixels */ + int height; /* in pixels */ + int y_inverted; /* add weston 1.3.x */ +}; + +/* Multi Windiw Manager */ +struct ico_win_mgr { + struct weston_compositor *compositor; /* Weston compositor */ + void *shell; /* shell(ico_ivi_shell) table address */ + int32_t surface_head; /* (HostID << 24) | (DisplayNo << 16) */ + + struct wl_list client_list; /* Clients */ + struct wl_list manager_list; /* Manager(ex.HomeScreen) list */ + int num_manager; /* Number of managers */ + + struct wl_list ivi_layer_list; /* Layer management table list */ + struct uifw_win_layer *touch_layer; /* layer table for touch panel layer */ + + struct wl_list map_list; /* surface map list */ + struct uifw_surface_map *free_maptable; /* free maped surface table list */ + struct weston_animation map_animation[ICO_IVI_MAX_DISPLAY]; + /* animation for map check */ + struct wl_event_source *wait_mapevent; /* map event send wait timer */ + int waittime; /* minimaum send wait time(ms) */ + + struct uifw_win_surface *active_pointer_usurf; /* Active Pointer Surface */ + struct uifw_win_surface *active_keyboard_usurf; /* Active Keyboard Surface */ + + struct uifw_win_surface *idhash[UIFW_HASH]; /* UIFW SerfaceID */ + struct uifw_win_surface *wshash[UIFW_HASH]; /* Weston Surface */ + + uint32_t surfaceid_count; /* Number of surface id */ + uint32_t surfaceid_max; /* Maximum number of surface id */ + uint16_t *surfaceid_map; /* SurfaceId assign bit map */ + + char shell_init; /* shell initialize flag */ + char res[3]; /* (unused) */ +}; + +/* Internal macros */ +/* UIFW SurfaceID */ +#define MAKE_IDHASH(v) (((uint32_t)v) & (UIFW_HASH-1)) +/* Weston Surface */ +#define MAKE_WSHASH(v) ((((uint32_t)v) >> 5) & (UIFW_HASH-1)) + +/* function prototype */ + /* get surface table from weston surface*/ +static struct uifw_win_surface *find_uifw_win_surface_by_ws( + struct weston_surface *wsurf); + /* get client table from weston client */ +static struct uifw_client* find_client_from_client(struct wl_client *client); + /* assign new surface id */ +static uint32_t generate_id(void); + /* bind shell client */ +static void win_mgr_bind_client(struct wl_client *client, void *shell); + /* unind shell client */ +static void win_mgr_unbind_client(struct wl_client *client); +#if 0 /* work around: Walk through child processes until app ID is found */ + /* get parent pid */ +static pid_t win_mgr_get_ppid(pid_t pid); +#endif /* work around: Walk through child processes until app ID is found */ + /* get appid from pid */ +static void win_mgr_get_client_appid(struct uifw_client *uclient); + /* create new surface */ +static void win_mgr_register_surface( + int layertype, struct wl_client *client, struct wl_resource *resource, + struct weston_surface *surface, struct shell_surface *shsurf); + /* surface destroy */ +static void win_mgr_destroy_surface(struct weston_surface *surface); + /* map new surface */ +static void win_mgr_map_surface(struct weston_surface *surface, int32_t *width, + int32_t *height, int32_t *sx, int32_t *sy); + /* send surface change event to manager */ +static void win_mgr_change_surface(struct weston_surface *surface, + const int to, const int manager); + /* window manager surface configure */ +static void win_mgr_surface_configure(struct uifw_win_surface *usurf, + int x, int y, int width, int height); + /* shell surface configure */ +static void win_mgr_shell_configure(struct weston_surface *surface); + /* surface select */ +static void win_mgr_select_surface(struct weston_surface *surface); + /* surface set title */ +static char *win_mgr_set_title(struct weston_surface *surface, const char *title); + /* surface move request from shell */ +static void win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy); + /* shell layer visible control */ +static void win_mgr_show_layer(int layertype, int show, void *data); + /* shell full screen surface control */ +static int win_mgr_fullscreen(int event, struct weston_surface *surface); + /* set raise */ +static void win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise); + /* surface change from manager */ +static int win_mgr_surface_change_mgr(struct weston_surface *surface, const int x, + const int y, const int width, const int height); + /* reset surface focus */ +static void win_mgr_reset_focus(struct uifw_win_surface *usurf); + /* create new layer */ +static struct uifw_win_layer *win_mgr_create_layer(struct uifw_win_surface *usurf, + const uint32_t layer, const int layertype); + /* set surface layer */ +static void win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer); + /* set active surface */ +static void win_mgr_set_active(struct uifw_win_surface *usurf, const int target); + + /* declare manager */ +static void uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, + int manager); + /* set window layer */ +static void uifw_set_window_layer(struct wl_client *client, + struct wl_resource *resource, + uint32_t surfaceid, uint32_t layer); + /* set surface size and position */ +static void uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t node, int32_t x, int32_t y, + int32_t width, int32_t height, int32_t flags); + /* show/hide and raise/lower surface */ +static void uifw_set_visible(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t visible, int32_t raise, + int32_t flag); + /* set surface animation */ +static void uifw_set_animation(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t type, + const char *animation, int32_t time); + /* set surface attributes */ +static void uifw_set_attributes(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t attributes); + /* surface visibility control with animation*/ +static void uifw_visible_animation(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t visible, + int32_t x, int32_t y, int32_t width, int32_t height); + /* set active surface (form HomeScreen) */ +static void uifw_set_active(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t active); + /* layer visibility control */ +static void uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, + uint32_t layer, int32_t visible); + /* get application surfaces */ +static void uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, + const char *appid, int32_t pid); + /* check and change all mapped surface */ +static void win_mgr_check_mapsurrace(struct weston_animation *animation, + struct weston_output *output, uint32_t msecs); + /* check timer of mapped surface */ +static int win_mgr_timer_mapsurrace(void *data); + /* check and change mapped surface */ +static void win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, + uint32_t curtime); + /* map surface to system application */ +static void uifw_map_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t framerate); + /* unmap surface */ +static void uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid); + /* bind manager */ +static void bind_ico_win_mgr(struct wl_client *client, + void *data, uint32_t version, uint32_t id); + /* unbind manager */ +static void unbind_ico_win_mgr(struct wl_resource *resource); + /* send event to manager */ +static int ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, + const int param1, const int param2, const int param3, + const int param4, const int param5); + /* set surface transform */ +static int win_mgr_set_scale(struct uifw_win_surface *usurf); + /* convert animation name to Id value */ +static int ico_get_animation_name(const char *animation); + /* hook for animation */ +static int (*win_mgr_hook_animation)(const int op, void *data) = NULL; + /* hook for input region */ +static void (*win_mgr_hook_change)(struct uifw_win_surface *usurf) = NULL; +static void (*win_mgr_hook_destory)(struct uifw_win_surface *usurf) = NULL; +static void (*win_mgr_hook_inputregion)(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, + int32_t height, int32_t hotspot_x, int32_t hotspot_y, + int32_t cursor_x, int32_t cursor_y, + int32_t cursor_width, int32_t cursor_height, + uint32_t attr) = NULL; + +/* static tables */ +/* Multi Window Manager interface */ +static const struct ico_window_mgr_interface ico_window_mgr_implementation = { + uifw_declare_manager, + uifw_set_window_layer, + uifw_set_positionsize, + uifw_set_visible, + uifw_set_animation, + uifw_set_attributes, + uifw_visible_animation, + uifw_set_active, + uifw_set_layer_visible, + uifw_get_surfaces, + uifw_map_surface, + uifw_unmap_surface +}; + + +/* GPU driver name */ +static const struct _ico_gputype_table { + int gpu_type; /* GPU type code */ + char *gpu_name; /* GPU driver name */ +} ico_window_mgr_gpu_type[] = { + { ICO_GPUTYPE_INTEL_SANDYBRIDGE, "Mesa DRI Intel(R) Sandybridge Mobile" }, + { 0, "\0" } +}; + +/* plugin common value(without ico_plugin_loader) */ +static int _ico_ivi_option_flag = 0; /* option flags */ +static int _ico_ivi_debug_level = 3; /* debug Level */ +static char *_ico_ivi_animation_name = NULL; /* default animation name */ +static int _ico_ivi_animation_time = 500; /* default animation time */ +static int _ico_ivi_animation_fps = 30; /* animation frame rate */ +static char *_ico_ivi_inputpanel_animation = NULL; /* default animation name for input panel*/ +static int _ico_ivi_inputpanel_anima_time = 0; /* default animation time for input panel*/ + +static int _ico_ivi_inputpanel_display = 0; /* input panel display number */ +static int _ico_ivi_inputdeco_mag = 100; /* input panel magnification rate(%)*/ +static int _ico_ivi_inputdeco_diff = 0; /* input panel difference from the bottom*/ + +static int _ico_ivi_background_layer = 0; /* background layer */ +static int _ico_ivi_default_layer = 1; /* deafult layer id at surface create*/ +static int _ico_ivi_touch_layer = 101; /* touch panel layer id */ +static int _ico_ivi_cursor_layer = 102; /* cursor layer id */ +static int _ico_ivi_startup_layer = 109; /* deafult layer id at system startup*/ + +static int _ico_ivi_gpu_type = 0; /* GPU type for get EGL buffer */ + +/* static management table */ +static struct ico_win_mgr *_ico_win_mgr = NULL; +static int _ico_num_nodes = 0; +static struct uifw_node_table _ico_node_table[ICO_IVI_MAX_DISPLAY]; +static struct weston_seat *touch_check_seat = NULL; +#if PIXEL_SPEED_TEST > 0 +static char *speed_buffer = NULL; +#endif + + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_optionflag: get option flags + * + * @param None + * @return option flags + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_optionflag(void) +{ + return _ico_ivi_option_flag; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_debuglevel: answer debug output level. + * + * @param none + * @return debug output level + * @retval 0 No debug output + * @retval 1 Only error output + * @retval 2 Error and Warning output + * @retval 3 Error, Warning and information output + * @retval 4 Error, Warning, information and Debug Trace output + * @retval 5 All output with debug write + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_debuglevel(void) +{ + return (_ico_ivi_debug_level & 0x0ffff); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_debugflag: get debug flags + * + * @param None + * @return debug flags + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_debugflag(void) +{ + return ((_ico_ivi_debug_level >> 16) & 0x0ffff); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_default_animation_name: get default animation name + * + * @param None + * @return Default animation name + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT const char * +ico_ivi_default_animation_name(void) +{ + return _ico_ivi_animation_name; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_default_animation_time: get default animation time + * + * @param None + * @return Default animation time(miri sec) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_default_animation_time(void) +{ + return _ico_ivi_animation_time; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_default_animation_fps: get default animation frame rate + * + * @param None + * @return Default animation frame rate(frames/sec) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_default_animation_fps(void) +{ + return _ico_ivi_animation_fps; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_ivi_get_mynode: Get my NodeId + * + * @param None + * @return NodeId of my node + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_ivi_get_mynode(void) +{ + /* Reference Platform 0.90 only support 1 ECU */ + return 0; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_weston_surface: set weston surface + * + * @param[in] usurf UIFW surface + * @param[in] x X coordinate on screen + * @param[in] y Y coordinate on screen + * @param[in] width width + * @param[in] height height + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_weston_surface(struct uifw_win_surface *usurf, + int x, int y, int width, int height) +{ + struct weston_surface *es = usurf->surface; + int buf_width, buf_height; + + if (es == NULL) { + uifw_trace("ico_window_mgr_set_weston_surface: usurf(%08x) has no surface", + (int)usurf); + return; + } + + if (es->buffer_ref.buffer != NULL) { + buf_width = weston_surface_buffer_width(es); + buf_height = weston_surface_buffer_height(es); + if ((width <= 0) || (height <= 0)) { + width = buf_width; + usurf->width = buf_width; + height = buf_height; + usurf->height = buf_height; + } + if ((usurf->width > buf_width) && (usurf->scalex <= 1.0f)) { + width = buf_width; + x += (usurf->width - buf_width)/2; + } + if ((usurf->height > buf_height) && (usurf->scaley <= 1.0f)) { + height = buf_height; + y += (usurf->height - buf_height)/2; + } + if (usurf->visible) { + x += usurf->node_tbl->disp_x; + y += usurf->node_tbl->disp_y; + } + else { + x = ICO_IVI_MAX_COORDINATE+1; + y = ICO_IVI_MAX_COORDINATE+1; + } + if ((es->geometry.x != x) || (es->geometry.y != y) || + (es->geometry.width != width) || (es->geometry.height != height)) { + weston_surface_damage_below(es); + win_mgr_surface_configure(usurf, x, y, width, height); + } + weston_surface_damage(es); + weston_compositor_schedule_repaint(_ico_win_mgr->compositor); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_weston_surface: set weston surface + * + * @param[in] usurf UIFW surface + * @param[in] x X coordinate on screen + * @param[in] y Y coordinate on screen + * @param[in] width width + * @param[in] height height + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_change_surface(struct uifw_win_surface *usurf, + const int to, const int manager) +{ + uifw_trace("ico_window_mgr_change_surface: Enter(%08x,%d,%d)", + usurf->surfaceid, to, manager); + win_mgr_change_surface(usurf->surface, to, manager); + uifw_trace("ico_window_mgr_change_surface: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_usurf: find UIFW surface by surface id + * + * @param[in] surfaceid UIFW surface id + * @return UIFW surface table address + * @retval !=NULL success(surface table address) + * @retval NULL error(surface id dose not exist) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT struct uifw_win_surface * +ico_window_mgr_get_usurf(const uint32_t surfaceid) +{ + struct uifw_win_surface *usurf; + + usurf = _ico_win_mgr->idhash[MAKE_IDHASH(surfaceid)]; + + while (usurf) { + if (usurf->surfaceid == surfaceid) { + return usurf; + } + usurf = usurf->next_idhash; + } + uifw_trace("ico_window_mgr_get_usurf: NULL"); + return NULL; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_usurf_client: find UIFW surface by surface id/or client + * + * @param[in] surfaceid UIFW surface id + * @param[in] client Wayland client + * @return UIFW surface table address + * @retval !=NULL success(surface table address) + * @retval NULL error(surface id or client dose not exist) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT struct uifw_win_surface * +ico_window_mgr_get_usurf_client(const uint32_t surfaceid, struct wl_client *client) +{ + struct uifw_win_surface *usurf; + struct uifw_client *uclient; + + if (surfaceid == ICO_WINDOW_MGR_V_MAINSURFACE) { + uclient = find_client_from_client(client); + if (uclient) { + if (&uclient->surface_link != uclient->surface_link.next) { + usurf = container_of (uclient->surface_link.next, + struct uifw_win_surface, client_link); + } + else { + usurf = NULL; + } + } + else { + usurf = NULL; + } + } + else { + usurf = ico_window_mgr_get_usurf(surfaceid); + } + return usurf; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief find_uifw_win_surface_by_ws: find UIFW surface by weston surface + * + * @param[in] wsurf Weston surface + * @return UIFW surface table address + * @retval !=NULL success(surface table address) + * @retval NULL error(surface dose not exist) + */ +/*--------------------------------------------------------------------------*/ +static struct uifw_win_surface * +find_uifw_win_surface_by_ws(struct weston_surface *wsurf) +{ + struct uifw_win_surface *usurf; + + usurf = _ico_win_mgr->wshash[MAKE_WSHASH(wsurf)]; + + while (usurf) { + if (usurf->surface == wsurf) { + return usurf; + } + usurf = usurf->next_wshash; + } + uifw_trace("find_uifw_win_surface_by_ws: NULL"); + return NULL; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief find_client_from_client: find UIFW client by wayland client + * + * @param[in] client Wayland client + * @return UIFW client table address + * @retval !=NULL success(client table address) + * @retval NULL error(client dose not exist) + */ +/*--------------------------------------------------------------------------*/ +static struct uifw_client* +find_client_from_client(struct wl_client *client) +{ + struct uifw_client *uclient; + + wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) { + if (uclient->client == client) { + return(uclient); + } + } + uifw_trace("find_client_from_client: client.%08x is NULL", (int)client); + return NULL; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_appid: find application id by wayland client + * + * @param[in] client Wayland client + * @return application id + * @retval !=NULL success(application id) + * @retval NULL error(client dose not exist) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT char * +ico_window_mgr_get_appid(struct wl_client* client) +{ + struct uifw_client *uclient; + + uclient = find_client_from_client(client); + + if (! uclient) { + return NULL; + } + return uclient->appid; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_display_coordinate: get display coordinate + * + * @param[in] displayno display number + * @param[out] x relative X coordinate + * @param[out] y relative Y coordinate + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_get_display_coordinate(int displayno, int *x, int *y) +{ + if ((displayno <= _ico_num_nodes) || (displayno < 0)) { + displayno = 0; + } + *x = _ico_node_table[displayno].disp_x; + *y = _ico_node_table[displayno].disp_y; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief generate_id: generate uniq id for UIFW surface id + * + * @param none + * @return uniq id for UIFW surface id + */ +/*--------------------------------------------------------------------------*/ +static uint32_t +generate_id(void) +{ + int rep; + int i; + int map; + uint16_t *new_map; + uint32_t surfaceId; + + /* next assign id */ + _ico_win_mgr->surfaceid_count ++; + + /* serach free id from bitmap */ + for (rep = 0; rep < (int)(_ico_win_mgr->surfaceid_max/16); rep++) { + if (_ico_win_mgr->surfaceid_count >= _ico_win_mgr->surfaceid_max) { + _ico_win_mgr->surfaceid_count = 0; + } + if (_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] != 0xffff) { + /* find free id from bitmap */ + map = 1 << (_ico_win_mgr->surfaceid_count % 16); + for (i = (_ico_win_mgr->surfaceid_count % 16); i < 16; i++) { + if ((_ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] & map) + == 0) { + _ico_win_mgr->surfaceid_map[_ico_win_mgr->surfaceid_count/16] |= map; + _ico_win_mgr->surfaceid_count + = (_ico_win_mgr->surfaceid_count/16)*16 + i; + + surfaceId = (_ico_win_mgr->surfaceid_count + 1) + | _ico_win_mgr->surface_head; + uifw_trace("generate_id: SurfaceId=%08x", surfaceId); + return(surfaceId); + } + map = map << 1; + } + } + _ico_win_mgr->surfaceid_count += 16; + } + + /* no free id in bitmap, extend bitmap */ + if ((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) > SURCAFE_ID_MASK) { + /* too many surfaces, system error */ + uifw_trace("generate_id: SurffaceId Overflow(%d, Max=%d), Abort", + _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK); + fprintf(stderr, "generate_id: SurffaceId Overflow(%d, Max=%d), Abort\n", + _ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS, SURCAFE_ID_MASK); + abort(); + } + + new_map = (uint16_t *) malloc((_ico_win_mgr->surfaceid_max + ADD_SURFACE_IDS) / 8); + memcpy(new_map, _ico_win_mgr->surfaceid_map, _ico_win_mgr->surfaceid_max/8); + memset(&new_map[_ico_win_mgr->surfaceid_max/16], 0, ADD_SURFACE_IDS/8); + _ico_win_mgr->surfaceid_count = _ico_win_mgr->surfaceid_max; + new_map[_ico_win_mgr->surfaceid_count/16] |= 1; + _ico_win_mgr->surfaceid_max += ADD_SURFACE_IDS; + free(_ico_win_mgr->surfaceid_map); + _ico_win_mgr->surfaceid_map = new_map; + + uifw_trace("generate_id: Extent SurfaceId=%d(Max.%d)", + _ico_win_mgr->surfaceid_count+1, _ico_win_mgr->surfaceid_max); + surfaceId = (_ico_win_mgr->surfaceid_count + 1) | _ico_win_mgr->surface_head; + + uifw_trace("generate_id: SurfaceId=%08x", surfaceId); + return(surfaceId); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_bind_client: desktop_shell from client + * + * @param[in] client Wayland client + * @param[in] shell shell(ico_ivi_shell) table address + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_bind_client(struct wl_client *client, void *shell) +{ + struct uifw_client *uclient; + int newclient; + pid_t pid; + uid_t uid; + gid_t gid; + + uifw_trace("win_mgr_bind_client: Enter(client=%08x, shell=%08x)", + (int)client, (int)shell); + + /* save shell table address */ + if (shell) { + _ico_win_mgr->shell = shell; + } + + /* set client */ + uclient = find_client_from_client(client); + if (! uclient) { + /* client not exist, create client management table */ + uifw_trace("win_mgr_bind_client: Create Client"); + uclient = (struct uifw_client *)malloc(sizeof(struct uifw_client)); + if (!uclient) { + uifw_error("win_mgr_bind_client: Error, No Memory"); + return; + } + memset(uclient, 0, sizeof(struct uifw_client)); + uclient->client = client; + wl_list_init(&uclient->surface_link); + newclient = 1; + } + else { + newclient = 0; + } + wl_client_get_credentials(client, &pid, &uid, &gid); + uifw_trace("win_mgr_bind_client: client=%08x pid=%d uid=%d gid=%d", + (int)client, (int)pid, (int)uid, (int)gid); + if (pid > 0) { + uclient->pid = (int)pid; + /* get applicationId from AppCore(AUL) */ + win_mgr_get_client_appid(uclient); + + if (newclient > 0) { + wl_list_insert(&_ico_win_mgr->client_list, &uclient->link); + } + } + else { + uifw_trace("win_mgr_bind_client: client=%08x pid dose not exist", (int)client); + } + uifw_trace("win_mgr_bind_client: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_unbind_client: unbind desktop_shell from client + * + * @param[in] client Wayland client + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_unbind_client(struct wl_client *client) +{ + struct uifw_client *uclient; + + uifw_trace("win_mgr_unbind_client: Enter(client=%08x)", (int)client); + + uclient = find_client_from_client(client); + if (uclient) { + /* Client exist, Destory client management table */ + wl_list_remove(&uclient->link); + free(uclient); + } + uifw_trace("win_mgr_unbind_client: Leave"); +} + +#if 0 /* work around: Walk through child processes until app ID is found */ +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_get_ppid: Get parent process ID. + * + * Similar to getppid(), except that this implementation accepts an + * arbitrary process ID. + * + * @param[in] pid Process ID of child process + * @return parent process ID on success, -1 on failure + */ +/*--------------------------------------------------------------------------*/ +static pid_t +win_mgr_get_ppid(pid_t pid) +{ + pid_t ppid = -1; + char procpath[PATH_MAX] = { 0 }; + + snprintf(procpath, sizeof(procpath)-1, "/proc/%d/status", pid); + + /* We better have read permissions! */ + int const fd = open(procpath, O_RDONLY); + + if (fd < 0) + return ppid; + + char buffer[1024] = { 0 }; + + ssize_t const size = read(fd, buffer, sizeof(buffer)); + close(fd); + + if (size <= 0) + return ppid; + + /* Find line containing the parent process ID. */ + char const * const ppid_line = strstr(buffer, "PPid"); + + if (ppid_line != NULL) + sscanf(ppid_line, "PPid: %d", &ppid); + + return ppid; +} +#endif /* work around: Walk through child processes until app ID is found */ + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_get_client_appid: get applicationId from pid + * + * @param[in] uclient UIFW client management table + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_get_client_appid(struct uifw_client *uclient) +{ + int status = AUL_R_ERROR; + + memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH); + +#if 0 /* work around: Walk through child processes until app ID is found */ + /* + * Walk the parent process chain until we find a parent process + * with an app ID. + */ + int pid; + + for (pid = uclient->pid; + pid > 1 && status != AUL_R_OK; + pid = win_mgr_get_ppid(pid)) { + + status = aul_app_get_appid_bypid(pid, + uclient->appid, + ICO_IVI_APPID_LENGTH); + + uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d " + "pid=%d appid=<%s>", status, pid, uclient->appid); + } + /* + * Walk the child process chain as well since app ID was not yet found + */ + if (status != AUL_R_OK) { + + DIR *dr; + struct dirent *de; + struct stat ps; + pid_t tpid; + uid_t uid; + gid_t gid; + + dr = opendir("/proc/"); + + /* get uid */ + wl_client_get_credentials(uclient->client, &tpid, &uid, &gid); + + while(((de = readdir(dr)) != NULL) && (status != AUL_R_OK)) { + + char fullpath[PATH_MAX] = { 0 }; + int is_child = 0; + int tmppid; + + snprintf(fullpath, sizeof(fullpath)-1, "/proc/%s", de->d_name); + + if (stat(fullpath, &ps) == -1) { + continue; + } + + /* find pid dirs for this user (uid) only */ + if (ps.st_uid != uid) + continue; + + pid = atoi(de->d_name); + + /* check if it's a valid child */ + if (pid < uclient->pid) + continue; + + /* scan up to pid to find if a chain exists */ + for (tmppid = pid; tmppid > uclient->pid;) { + tmppid = win_mgr_get_ppid(tmppid); + if (tmppid == uclient->pid) + is_child = 1; + } + + if (is_child) { + status = aul_app_get_appid_bypid(pid, uclient->appid, + ICO_IVI_APPID_LENGTH); + + uifw_debug("win_mgr_get_client_appid: aul_app_get_appid_bypid " + "ret=%d pid=%d appid=<%s>", status, pid, + uclient->appid); + } + } + } +#else /* work around: Walk through child processes until app ID is found */ + status = aul_app_get_appid_bypid(uclient->pid, uclient->appid, ICO_IVI_APPID_LENGTH); + uifw_trace("win_mgr_get_client_appid: aul_app_get_appid_bypid ret=%d " + "pid=%d appid=<%s>", status, uclient->pid, uclient->appid); +#endif /* work around: Walk through child processes until app ID is found */ + + if (uclient->appid[0] != 0) { + /* OK, end of get appid */ + uclient->fixed_appid = ICO_WINDOW_MGR_APPID_FIXCOUNT; + } + else { + /* client does not exist in AppCore, search Linux process table */ + + int fd; + int size; + int i; + int j; + char procpath[128]; + + uclient->fixed_appid ++; + memset(uclient->appid, 0, ICO_IVI_APPID_LENGTH); + snprintf(procpath, sizeof(procpath)-1, "/proc/%d/cmdline", uclient->pid); + fd = open(procpath, O_RDONLY); + if (fd >= 0) { + size = read(fd, procpath, sizeof(procpath)); + for (; size > 0; size--) { + if (procpath[size-1]) break; + } + if (size > 0) { + /* get program base name */ + i = 0; + for (j = 0; j < size; j++) { + if (procpath[j] == 0) break; + if (procpath[j] == '/') i = j + 1; + } + j = 0; + for (; i < size; i++) { + uclient->appid[j] = procpath[i]; + if ((uclient->appid[j] == 0) || + (j >= (ICO_IVI_APPID_LENGTH-1))) break; + j++; + } + /* search application number in apprication start option */ + if ((uclient->appid[j] == 0) && (j < (ICO_IVI_APPID_LENGTH-2))) { + for (; i < size; i++) { + if ((procpath[i] == 0) && + (procpath[i+1] == '@')) { + strncpy(&uclient->appid[j], &procpath[i+1], + ICO_IVI_APPID_LENGTH - j - 2); + } + } + } + } + close(fd); + } + for (i = strlen(uclient->appid)-1; i >= 0; i--) { + if (uclient->appid[i] != ' ') break; + } + uclient->appid[i+1] = 0; + if (uclient->appid[0]) { + uifw_trace("win_mgr_get_client_appid: pid=%d appid=<%s> from " + "Process table(%d)", + uclient->pid, uclient->appid, uclient->fixed_appid ); + } + else { + uifw_trace("win_mgr_get_client_appid: pid=%d dose not exist in Process table", + uclient->pid); + sprintf(uclient->appid, "?%d?", uclient->pid); + } + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_get_animation_name: convert animation name to Id value + * + * @param[in] animation animation name + * @return animation Id value + */ +/*--------------------------------------------------------------------------*/ +static int +ico_get_animation_name(const char *animation) +{ + int anima = ICO_WINDOW_MGR_ANIMATION_NONE; + + if (strcasecmp(animation, "none") == 0) { + return ICO_WINDOW_MGR_ANIMATION_NONE; + } + + if (win_mgr_hook_animation) { + anima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_NAME, (void *)animation); + } + if (anima <= 0) { + anima = ICO_WINDOW_MGR_ANIMATION_NONE; + } + return anima; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_register_surface: create UIFW surface + * + * @param[in] layertype surface layer type + * @param[in] client Wayland client + * @param[in] resource client resource + * @param[in] surface Weston surface + * @param[in] shsurf shell surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_register_surface(int layertype, struct wl_client *client, + struct wl_resource *resource, struct weston_surface *surface, + struct shell_surface *shsurf) +{ + struct uifw_win_surface *usurf; + struct uifw_win_surface *phash; + struct uifw_win_surface *bhash; + int layer; + uint32_t hash; + + uifw_trace("win_mgr_register_surface: Enter(surf=%08x,client=%08x,res=%08x,layertype=%x)", + (int)surface, (int)client, (int)resource, layertype); + + /* check new surface */ + if (find_uifw_win_surface_by_ws(surface)) { + /* surface exist, NOP */ + uifw_trace("win_mgr_register_surface: Leave(Already Exist)"); + return; + } + + /* set default color and shader */ + weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1); + + /* create UIFW surface management table */ + usurf = malloc(sizeof(struct uifw_win_surface)); + if (! usurf) { + uifw_error("win_mgr_register_surface: No Memory"); + return; + } + + memset(usurf, 0, sizeof(struct uifw_win_surface)); + + usurf->surfaceid = generate_id(); + usurf->surface = surface; + usurf->shsurf = shsurf; + usurf->layertype = layertype; + usurf->node_tbl = &_ico_node_table[0]; /* set default node table (display no=0) */ + wl_list_init(&usurf->ivi_layer); + wl_list_init(&usurf->client_link); + wl_list_init(&usurf->animation.animation.link); + wl_list_init(&usurf->surf_map); + wl_list_init(&usurf->input_region); + usurf->animation.hide_anima = ico_get_animation_name(ico_ivi_default_animation_name()); + usurf->animation.hide_time = ico_ivi_default_animation_time(); + usurf->animation.show_anima = usurf->animation.hide_anima; + usurf->animation.show_time = usurf->animation.hide_time; + usurf->animation.move_anima = usurf->animation.hide_anima; + usurf->animation.move_time = usurf->animation.hide_time; + usurf->animation.resize_anima = usurf->animation.hide_anima; + usurf->animation.resize_time = usurf->animation.hide_time; + if (layertype == LAYER_TYPE_INPUTPANEL) { + usurf->attributes = ICO_WINDOW_MGR_ATTR_FIXED_ASPECT; + usurf->animation.hide_anima = ico_get_animation_name(_ico_ivi_inputpanel_animation); + usurf->animation.hide_time = _ico_ivi_inputpanel_anima_time; + usurf->animation.show_anima = usurf->animation.hide_anima; + usurf->animation.show_time = usurf->animation.hide_time; + } + if ((layertype != LAYER_TYPE_INPUTPANEL) && + ((_ico_win_mgr->num_manager <= 0) || + (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE))) { + uifw_trace("win_mgr_register_surface: No Manager, Force visible"); + usurf->visible = 1; + } + else { + uifw_trace("win_mgr_register_surface: Manager exist, Not visible"); + usurf->visible = 0; + } + + /* set client */ + usurf->uclient = find_client_from_client(client); + if (! usurf->uclient) { + /* client not exist, create client management table */ + uifw_trace("win_mgr_register_surface: Create Client"); + win_mgr_bind_client(client, NULL); + usurf->uclient = find_client_from_client(client); + if (! usurf->uclient) { + uifw_error("win_mgr_register_surface: No Memory"); + return; + } + } + wl_list_insert(usurf->uclient->surface_link.prev, &usurf->client_link); + + /* make surface id hash table */ + hash = MAKE_IDHASH(usurf->surfaceid); + phash = _ico_win_mgr->idhash[hash]; + bhash = NULL; + while (phash) { + bhash = phash; + phash = phash->next_idhash; + } + if (bhash) { + bhash->next_idhash = usurf; + } + else { + _ico_win_mgr->idhash[hash] = usurf; + } + + /* make weston surface hash table */ + hash = MAKE_WSHASH(usurf->surface); + phash = _ico_win_mgr->wshash[hash]; + bhash = NULL; + while (phash) { + bhash = phash; + phash = phash->next_wshash; + } + if (bhash) { + bhash->next_wshash = usurf; + } + else { + _ico_win_mgr->wshash[hash] = usurf; + } + + /* set default layer id */ + switch (layertype) { + case LAYER_TYPE_BACKGROUND: + layer = _ico_ivi_background_layer; + break; + case LAYER_TYPE_TOUCH: + layer = _ico_ivi_touch_layer; + break; + case LAYER_TYPE_CURSOR: + layer = _ico_ivi_cursor_layer; + break; + default: + if (_ico_win_mgr->num_manager > 0) { + layer = _ico_ivi_default_layer; + } + else { + layer = _ico_ivi_startup_layer; + } + break; + } + win_mgr_set_layer(usurf, layer); + + uifw_trace("win_mgr_register_surface: Leave(surfaceId=%08x)", usurf->surfaceid); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_map_surface: map surface + * + * @param[in] surface Weston surface + * @param[in] width surface width + * @param[in] height surface height + * @param[in] sx X coordinate on screen + * @param[in] sy Y coordinate on screen + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_map_surface(struct weston_surface *surface, int32_t *width, int32_t *height, + int32_t *sx, int32_t *sy) +{ + struct uifw_win_surface *usurf; + + uifw_trace("win_mgr_map_surface: Enter(%08x, x/y=%d/%d w/h=%d/%d)", + (int)surface, *sx, *sy, *width, *height); + + usurf = find_uifw_win_surface_by_ws(surface); + + if (usurf) { + uifw_trace("win_mgr_map_surface: surf=%08x w/h=%d/%d vis=%d", + usurf->surfaceid, usurf->width, usurf->height, usurf->visible); + if ((usurf->width > 0) && (usurf->height > 0)) { + uifw_trace("win_mgr_map_surface: HomeScreen registed, PositionSize" + "(surf=%08x x/y=%d/%d w/h=%d/%d vis=%d", + usurf->surfaceid, usurf->x, usurf->y, usurf->width, usurf->height, + usurf->visible); + *width = usurf->width; + *height = usurf->height; + win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, + usurf->node_tbl->disp_y + usurf->y, + usurf->width, usurf->height); + } + else { + uifw_trace("win_mgr_map_surface: HomeScreen not regist Surface, " + "Change PositionSize(surf=%08x x/y=%d/%d w/h=%d/%d)", + usurf->surfaceid, *sx, *sy, *width, *height); + usurf->width = *width; + usurf->height = *height; + usurf->x = *sx; + usurf->y = *sy; + if (usurf->x < 0) usurf->x = 0; + if (usurf->y < 0) usurf->y = 0; + if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { + /* set position */ + usurf->node_tbl = &_ico_node_table[_ico_ivi_inputpanel_display]; + + usurf->width = (float)usurf->surface->geometry.width + * (float)_ico_ivi_inputdeco_mag / 100.0f; + usurf->height = (float)usurf->surface->geometry.height + * (float)_ico_ivi_inputdeco_mag / 100.0f; + + if ((usurf->width > (usurf->node_tbl->disp_width - 16)) || + (usurf->height > (usurf->node_tbl->disp_height - 16))) { + usurf->x = (usurf->node_tbl->disp_width + - usurf->surface->geometry.width) / 2; + usurf->y = usurf->node_tbl->disp_height + - usurf->surface->geometry.height - 16 + - _ico_ivi_inputdeco_diff; + if (usurf->x < 0) usurf->x = 0; + if (usurf->y < 0) usurf->y = 0; + } + else { + win_mgr_set_scale(usurf); + + usurf->x = (usurf->node_tbl->disp_width + - usurf->width) / 2; + usurf->y = usurf->node_tbl->disp_height + - usurf->height - 16 - _ico_ivi_inputdeco_diff; + if (usurf->x < 0) usurf->x = 0; + if (usurf->y < 0) usurf->y = 0; + } + uifw_trace("win_mgr_map_surface: set position %08x %d.%d/%d", + usurf->surfaceid, usurf->node_tbl->node, usurf->x, usurf->y); + } + if (((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_SURFACE) == 0) && + (_ico_win_mgr->num_manager > 0)) { + /* HomeScreen exist, coodinate set by HomeScreen */ + if (usurf->visible) { + win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, + usurf->node_tbl->disp_y + usurf->y, + usurf->width, usurf->height); + } + else { + win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1, + ICO_IVI_MAX_COORDINATE+1, + usurf->width, usurf->height); + } + uifw_trace("win_mgr_map_surface: Change size/position x/y=%d/%d w/h=%d/%d", + (int)surface->geometry.x, (int)surface->geometry.y, + surface->geometry.width, surface->geometry.height); + } + else if (usurf->layertype != LAYER_TYPE_INPUTPANEL) { + uifw_trace("win_mgr_map_surface: No HomeScreen, chaneg to Visible"); + ico_window_mgr_set_visible(usurf, 1); + } + else { + if (usurf->visible) { + win_mgr_surface_configure(usurf, usurf->node_tbl->disp_x + usurf->x, + usurf->node_tbl->disp_y + usurf->y, + usurf->width, usurf->height); + } + else { + win_mgr_surface_configure(usurf, ICO_IVI_MAX_COORDINATE+1, + ICO_IVI_MAX_COORDINATE+1, + usurf->width, usurf->height); + } + } + } + usurf->mapped = 1; + if (usurf->visible) { + ico_window_mgr_restack_layer(NULL); + } + uifw_trace("win_mgr_map_surface: Leave"); + } + else { + uifw_trace("win_mgr_map_surface: Leave(No UIFW Surface)"); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_restack_layer: restack surface list + * + * @param[in] usurf UIFW surface (if NULL, no surface) + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_restack_layer(struct uifw_win_surface *usurf) +{ + struct uifw_win_surface *eu; + struct uifw_win_layer *el; + int32_t buf_width, buf_height; + float new_x, new_y; + struct weston_layer *wlayer; + struct weston_surface *surface, *surfacetmp; + int num_visible = 0; + int layertype; + + /* make compositor surface list */ + wlayer = ico_ivi_shell_weston_layer(); + + uifw_trace("ico_window_mgr_restack_layer: Enter(surf=%08x) layer=%08x", + (int)usurf, (int)wlayer); + + /* remove all surfaces in panel_layer */ + wl_list_for_each_safe (surface, surfacetmp, &wlayer->surface_list, layer_link) { + wl_list_remove(&surface->layer_link); + wl_list_init(&surface->layer_link); + } + wl_list_init(&wlayer->surface_list); + + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + wl_list_for_each (eu, &el->surface_list, ivi_layer) { + if (eu->surface == NULL) continue; + + /* target only panel or unknown layer */ + layertype = ico_ivi_shell_layertype(eu->surface); + if ((layertype != LAYER_TYPE_PANEL) && (layertype != LAYER_TYPE_INPUTPANEL) && + (layertype != LAYER_TYPE_FULLSCREEN) && (layertype != LAYER_TYPE_CURSOR) && + (layertype != LAYER_TYPE_UNKNOWN)) { + continue; + } + wl_list_remove(&eu->surface->layer_link); + wl_list_init(&eu->surface->layer_link); + + if (eu->mapped != 0) { + if ((el->visible == FALSE) || (eu->visible == FALSE)) { + new_x = (float)(ICO_IVI_MAX_COORDINATE+1); + new_y = (float)(ICO_IVI_MAX_COORDINATE+1); + } + else if (eu->surface->buffer_ref.buffer) { + buf_width = weston_surface_buffer_width(eu->surface); + buf_height = weston_surface_buffer_height(eu->surface); + if ((eu->width > buf_width) && (eu->scalex <= 1.0f)) { + new_x = (float)(eu->x + + (eu->width - eu->surface->geometry.width)/2); + } + else { + new_x = (float)eu->x; + } + if ((eu->height > buf_height) && (eu->scaley <= 1.0f)) { + new_y = (float) (eu->y + + (eu->height - eu->surface->geometry.height)/2); + } + else { + new_y = (float)eu->y; + } + new_x += eu->node_tbl->disp_x + eu->xadd; + new_y += eu->node_tbl->disp_y + eu->yadd; + num_visible ++; + } + else { + new_x = (float)(eu->x + eu->node_tbl->disp_x + eu->xadd); + new_y = (float)(eu->y + eu->node_tbl->disp_y + eu->yadd); + } + wl_list_insert(wlayer->surface_list.prev, &eu->surface->layer_link); + if ((eu->restrain_configure == 0) && + ((new_x != eu->surface->geometry.x) || + (new_y != eu->surface->geometry.y))) { + weston_surface_damage_below(eu->surface); + weston_surface_set_position(eu->surface, (float)new_x, (float)new_y); + weston_surface_damage(eu->surface); + } + uifw_debug("ico_window_mgr_restack_layer:%3d(%d).%08x(%08x:%d) " + "x/y=%d/%d w/h=%d/%d %x", + el->layer, el->visible, eu->surfaceid, (int)eu->surface, + eu->visible, (int)eu->surface->geometry.x, + (int)eu->surface->geometry.y, eu->surface->geometry.width, + eu->surface->geometry.height, eu->layertype); + } + } + } + + /* damage(redraw) target surfacem if target exist */ + if (usurf) { + weston_surface_damage(usurf->surface); + } + + /* composit and draw screen(plane) */ + weston_compositor_schedule_repaint(_ico_win_mgr->compositor); + + if ((_ico_win_mgr->shell_init == 0) && (num_visible > 0) && + (_ico_win_mgr->shell != NULL) && (_ico_win_mgr->num_manager > 0)) { + /* start shell fade */ + _ico_win_mgr->shell_init = 1; + ico_ivi_shell_startup(_ico_win_mgr->shell); + } + uifw_trace("ico_window_mgr_restack_layer: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_touch_layer: touch panel layer control + * + * @param[in] omit omit touch layer flag (TRUE=omit/FALSE=not omit) + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_touch_layer(int omit) +{ + struct uifw_win_surface *eu; + + /* check current touch layer mode */ + if ((_ico_win_mgr->touch_layer == NULL) || + ((omit != FALSE) && (_ico_win_mgr->touch_layer->visible == FALSE))) { + uifw_trace("ico_window_mgr_touch_layer: touch layer not exist or hide"); + return; + } + + wl_list_for_each (eu, &_ico_win_mgr->touch_layer->surface_list, ivi_layer) { + if ((eu->surface == NULL) || (eu->mapped == 0)) continue; + if (omit != FALSE) { + eu->animation.pos_x = (int)eu->surface->geometry.x; + eu->animation.pos_y = (int)eu->surface->geometry.y; + eu->surface->geometry.x = (float)(ICO_IVI_MAX_COORDINATE+1); + eu->surface->geometry.y = (float)(ICO_IVI_MAX_COORDINATE+1); + } + else { + eu->surface->geometry.x = (float)eu->animation.pos_x; + eu->surface->geometry.y = (float)eu->animation.pos_y; + } + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_create_layer: create new layer + * + * @param[in] usurf UIFW surface, (if need) + * @param[in] layer layer id + * @param[in] layertype layer type if need + * @return new layer + * @retval != NULL success(layer management table) + * @retval == NULL error(No Memory) + */ +/*--------------------------------------------------------------------------*/ +static struct uifw_win_layer * +win_mgr_create_layer(struct uifw_win_surface *usurf, const uint32_t layer, + const int layertype) +{ + struct uifw_win_layer *el; + struct uifw_win_layer *new_el; + + new_el = malloc(sizeof(struct uifw_win_layer)); + if (! new_el) { + uifw_trace("win_mgr_create_layer: Leave(No Memory)"); + return NULL; + } + + memset(new_el, 0, sizeof(struct uifw_win_layer)); + new_el->layer = layer; + if ((int)layer == _ico_ivi_background_layer ) { + new_el->layertype = LAYER_TYPE_BACKGROUND; + } + else if ((int)layer == _ico_ivi_touch_layer ) { + new_el->layertype = LAYER_TYPE_TOUCH; + _ico_win_mgr->touch_layer = new_el; + } + else if ((int)layer == _ico_ivi_cursor_layer ) { + new_el->layertype = LAYER_TYPE_CURSOR; + } + else { + new_el->layertype = LAYER_TYPE_PANEL; + } + new_el->visible = TRUE; + wl_list_init(&new_el->surface_list); + wl_list_init(&new_el->link); + + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + if (layer >= el->layer) break; + } + if (&el->link == &_ico_win_mgr->ivi_layer_list) { + wl_list_insert(_ico_win_mgr->ivi_layer_list.prev, &new_el->link); + } + else { + wl_list_insert(el->link.prev, &new_el->link); + } + + if (usurf) { + wl_list_remove(&usurf->ivi_layer); + wl_list_insert(&new_el->surface_list, &usurf->ivi_layer); + usurf->win_layer = new_el; + if (new_el->layertype == LAYER_TYPE_CURSOR) { + usurf->layertype = LAYER_TYPE_CURSOR; + } + } + return new_el; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_set_layer: set(or change) surface layer + * + * @param[in] usurf UIFW surface + * @param[in] layer layer id + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_set_layer(struct uifw_win_surface *usurf, const uint32_t layer) +{ + struct uifw_win_layer *el; + struct uifw_win_layer *new_el; + uint32_t oldlayer; + + uifw_trace("win_mgr_set_layer: Enter(%08x,%08x,%x)", + usurf->surfaceid, (int)usurf->surface, layer); + + /* check if same layer */ + if (usurf->win_layer != NULL) { + oldlayer = usurf->win_layer->layer ; + if (oldlayer == layer) { + uifw_trace("win_mgr_set_layer: Leave(Same Layer)"); + return; + } + } + else { + oldlayer = 0; + } + + /* search existing layer */ + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + if (el->layer == layer) break; + } + + if (&el->link == &_ico_win_mgr->ivi_layer_list) { + /* layer not exist, create new layer */ + uifw_trace("win_mgr_set_layer: New Layer %d(%d)", layer, usurf->layertype); + new_el = win_mgr_create_layer(usurf, layer, usurf->layertype); + if (! new_el) { + uifw_trace("win_mgr_set_layer: Leave(No Memory)"); + return; + } + } + else { + uifw_trace("win_mgr_set_layer: Add surface to Layer %d", layer); + usurf->win_layer = el; + win_mgr_set_raise(usurf, 3); + } + + /* set input region */ + if (layer == (uint32_t)_ico_ivi_cursor_layer) { + uifw_trace("win_mgr_set_layer: %08x cursor Change to cursor layer (%d,%d)-(%d,%d)", + usurf->surfaceid, + usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, + usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); + pixman_region32_fini(&usurf->surface->pending.input); + pixman_region32_init_rect(&usurf->surface->pending.input, + ICO_IVI_MAX_COORDINATE + 1, ICO_IVI_MAX_COORDINATE + 1, + 1, 1); + } + else if (oldlayer == (uint32_t)_ico_ivi_cursor_layer) { + uifw_trace("win_mgr_set_layer: %08x cursor Change to normal layer (%d,%d)-(%d,%d)", + usurf->surfaceid, + usurf->surface->input.extents.x1, usurf->surface->input.extents.y1, + usurf->surface->input.extents.x2, usurf->surface->input.extents.y2); + pixman_region32_fini(&usurf->surface->pending.input); + pixman_region32_init_rect(&usurf->surface->pending.input, + INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); + } + + /* rebild compositor surface list */ + if (usurf->visible) { + ico_window_mgr_restack_layer(usurf); + } + uifw_trace("win_mgr_set_layer: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_set_active: set(or change) active surface + * + * @param[in] usurf UIFW surface + * @param[in] target target device + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_set_active(struct uifw_win_surface *usurf, const int target) +{ + struct weston_seat *seat; + struct weston_surface *surface; + int object = target; +#if 0 /* pointer grab can not release */ + int savetp, i; +#endif /* pointer grab can not release */ + + uifw_trace("win_mgr_set_active: Enter(%08x,%x)", (int)usurf, target); + + if ((usurf) && (usurf->shsurf) && (usurf->surface)) { + surface = usurf->surface; + if ((object & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) == 0) { + surface = NULL; + if (_ico_win_mgr->active_pointer_usurf == usurf) { + object |= ICO_WINDOW_MGR_ACTIVE_POINTER; + } + if (_ico_win_mgr->active_keyboard_usurf == usurf) { + object |= ICO_WINDOW_MGR_ACTIVE_KEYBOARD; + } + } + else { + if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { + _ico_win_mgr->active_pointer_usurf = usurf; + } + if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) { + _ico_win_mgr->active_keyboard_usurf = usurf; + } + } + } + else { + surface = NULL; + if (object == 0) { + object = ICO_WINDOW_MGR_ACTIVE_POINTER | ICO_WINDOW_MGR_ACTIVE_KEYBOARD; + } + if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { + _ico_win_mgr->active_pointer_usurf = NULL; + } + if (object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) { + _ico_win_mgr->active_keyboard_usurf = NULL; + } + } + + wl_list_for_each (seat, &_ico_win_mgr->compositor->seat_list, link) { +#if 0 /* pointer grab can not release */ + if (object & ICO_WINDOW_MGR_ACTIVE_POINTER) { + if (surface) { + if ((seat->pointer != NULL) && (seat->pointer->focus != surface)) { + uifw_trace("win_mgr_set_active: pointer reset focus(%08x)", + (int)seat->pointer->focus); + if (seat->pointer->button_count > 0) { + /* emulate button release */ + notify_button(seat, weston_compositor_get_time(), + seat->pointer->grab_button, + WL_POINTER_BUTTON_STATE_RELEASED); + /* count up button, because real mouse botan release */ + seat->pointer->button_count ++; + } + weston_pointer_set_focus(seat->pointer, NULL, + wl_fixed_from_int(0), wl_fixed_from_int(0)); + } + else { + uifw_trace("win_mgr_set_active: pointer nochange surface(%08x)", + (int)surface); + } + if ((seat->touch != NULL) && (seat->touch->focus != surface)) { + uifw_trace("win_mgr_set_active: touch reset surface(%08x)", + (int)seat->touch->focus); + if (seat->num_tp > 10) { + seat->num_tp = 0; /* safty gard */ + } + else if (seat->num_tp > 0) { + /* emulate touch up */ + savetp = seat->num_tp; + for (i = 0; i < savetp; i++) { + notify_touch(seat, weston_compositor_get_time(), i+1, + seat->touch->grab_x, seat->touch->grab_y, + WL_TOUCH_UP); + } + /* touch count up, becase real touch release */ + seat->num_tp = savetp; + } + weston_touch_set_focus(seat, NULL); + } + else { + uifw_trace("win_mgr_set_active: touch nochange surface(%08x)", + (int)surface); + } + } + else { + uifw_trace("win_mgr_set_active: pointer reset surface(%08x)", + (int)seat->pointer->focus); + if ((seat->pointer != NULL) && (seat->pointer->focus != NULL)) { + if (seat->pointer->button_count > 0) { + /* emulate button release */ + notify_button(seat, weston_compositor_get_time(), + seat->pointer->grab_button, + WL_POINTER_BUTTON_STATE_RELEASED); + seat->pointer->button_count ++; + } + weston_pointer_set_focus(seat->pointer, NULL, + wl_fixed_from_int(0), wl_fixed_from_int(0)); + } + if ((seat->touch != NULL) && (seat->touch->focus != NULL)) { + if (seat->num_tp > 10) { + seat->num_tp = 0; /* safty gard */ + } + else if (seat->num_tp > 0) { + /* emulate touch up */ + savetp = seat->num_tp; + for (i = 0; i < savetp; i++) { + notify_touch(seat, weston_compositor_get_time(), i+1, + seat->touch->grab_x, seat->touch->grab_y, + WL_TOUCH_UP); + } + /* touch count up, becase real touch release */ + seat->num_tp = savetp; + } + weston_touch_set_focus(seat, NULL); + } + } + } +#endif /* pointer grab can not release */ + if ((object & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) && (seat->keyboard)) { + if (surface) { + if (seat->keyboard->focus != surface) { + weston_keyboard_set_focus(seat->keyboard, surface); + uifw_trace("win_mgr_set_active: keyboard change surface(%08x=>%08x)", + (int)seat->keyboard->focus, (int)surface); + } + else { + uifw_trace("win_mgr_set_active: keyboard nochange surface(%08x)", + (int)surface); + } + } + else { + uifw_trace("win_mgr_set_active: keyboard reset surface(%08x)", + (int)seat->keyboard); + weston_keyboard_set_focus(seat->keyboard, NULL); + } + } + } + uifw_trace("win_mgr_set_active: Leave(%08x)", (int)usurf); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_ismykeyboard: check active keyboard + * + * @param[in] usurf UIFW surface + * @return check result + * @retval =1 usurf is active keyboard surface + * @retval =0 usurf is not active + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_window_mgr_ismykeyboard(struct uifw_win_surface *usurf) +{ + return (_ico_win_mgr->active_keyboard_usurf == usurf) ? 1 : 0; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_declare_manager: declare manager(ex.SystemController) client + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] manager manager(1=manager, 0=not manager) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_declare_manager(struct wl_client *client, struct wl_resource *resource, int manager) +{ + struct uifw_manager* mgr; + struct uifw_win_surface *usurf; + struct uifw_client *uclient; + struct uifw_win_layer *el; + + uifw_trace("uifw_declare_manager: Enter client=%08x manager=%d", + (int)client, manager); + + uclient = find_client_from_client(client); + if (! uclient) { + uifw_trace("uifw_declare_manager: Leave(unknown client=%08x)", (int)client); + return; + } + + uclient->manager = manager; + + /* client set to manager */ + _ico_win_mgr->num_manager = 0; + wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { + if (mgr->resource == resource) { + if (mgr->manager != manager) { + uifw_trace("uifw_declare_manager: Event Client.%08x Callback %d=>%d", + (int)client, mgr->manager, manager); + mgr->manager = manager; + + if (manager) { + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + wl_list_for_each (usurf, &el->surface_list, ivi_layer) { + /* send window create event to manager */ + if (usurf->created != 0) { + uifw_trace("uifw_declare_manager: Send manager(%08x) " + "WINDOW_CREATED(surf=%08x,pid=%d,appid=%s)", + (int)resource, usurf->surfaceid, + usurf->uclient->pid, usurf->uclient->appid); + ico_window_mgr_send_window_created(resource, + usurf->surfaceid, + usurf->winname, + usurf->uclient->pid, + usurf->uclient->appid, + usurf->layertype << 12); + } + } + } + } + } + } + if (mgr->manager) { + _ico_win_mgr->num_manager++; + } + } + uifw_trace("uifw_declare_manager: Leave(managers=%d)", _ico_win_mgr->num_manager); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_window_layer: set layer id to surface + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] layer layer id + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_window_layer(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t layer) +{ + if (layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) { + layer = _ico_ivi_background_layer; + } + else if (layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) { + layer = _ico_ivi_touch_layer; + } + else if (layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) { + layer = _ico_ivi_cursor_layer; + } + else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) { + layer = _ico_ivi_startup_layer; + } + + uifw_trace("uifw_set_window_layer: Enter res=%08x surfaceid=%08x layer=%d", + (int)resource, surfaceid, layer); + + struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + + if (! usurf) { + uifw_trace("uifw_set_window_layer: Leave(No Surface(id=%08x))", surfaceid); + return; + } + + if (usurf->win_layer->layer != layer) { + win_mgr_set_layer(usurf, layer); + win_mgr_change_surface(usurf->surface, -1, 1); + } + uifw_trace("uifw_set_window_layer: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_positionsize: set surface position and size + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] node surface node id + * @param[in] x X coordinate on screen(if bigger than 16383, no change) + * @param[in] y Y coordinate on screen(if bigger than 16383, no change) + * @param[in] width surface width(if bigger than 16383, no change) + * @param[in] height surface height(if bigger than 16383, no change) + * @param[in] flags with/without animation and client configure flag + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_positionsize(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t node, int32_t x, int32_t y, + int32_t width, int32_t height, int32_t flags) +{ + struct uifw_client *uclient; + struct uifw_win_surface *usurf; + struct weston_surface *es; + int op; + int retanima; + int oldx, oldy; + struct uifw_node_table *oldnode; + + uifw_trace("uifw_set_positionsize: Enter surf=%08x node=%x x/y/w/h=%d/%d/%d/%d flag=%x", + surfaceid, node, x, y, width, height, flags); + + usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + if (! usurf) { + uifw_trace("uifw_set_positionsize: Leave(surf=%08x NOT Found)", surfaceid); + return; + } + oldx = usurf->x; + oldy = usurf->y; + oldnode = usurf->node_tbl; + + uclient = find_client_from_client(client); + + usurf->disable = 0; + if (((int)node) >= _ico_num_nodes) { + uifw_trace("uifw_set_positionsize: node=%d dose not exist(max=%d)", + node, _ico_num_nodes); + if ((ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_NODISP) == 0) { + if (usurf->visible) { + /* no display, change to hide */ + uifw_set_visible(client, resource, surfaceid, ICO_WINDOW_MGR_VISIBLE_HIDE, + ICO_WINDOW_MGR_V_NOCHANGE, 0); + } + usurf->disable = 1; + } + node = 0; + } + usurf->node_tbl = &_ico_node_table[node]; + + es = usurf->surface; + if (es) { + /* weston surface exist */ + es = usurf->surface; + retanima = ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA; + + /* if x,y,width,height bigger then ICO_IVI_MAX_COORDINATE, no change */ + if (x > ICO_IVI_MAX_COORDINATE) x = usurf->x; + if (y > ICO_IVI_MAX_COORDINATE) y = usurf->y; + if (width > ICO_IVI_MAX_COORDINATE) width = usurf->width; + if (height > ICO_IVI_MAX_COORDINATE) height = usurf->height; + + /* check animation */ + if ((usurf->animation.restrain_configure != 0) && + (x == usurf->x) && (y == usurf->y) && + (width == usurf->width) && (height == usurf->height)) { + uifw_trace("uifw_set_positionsize: Leave(same position size at animation)"); + return; + } + + if (uclient) { + if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && + (uclient->manager == 0) && (uclient->privilege == 0)) uclient = NULL; + } + if (! uclient) { + if ((usurf->width > 0) && (usurf->height > 0)) { + win_mgr_surface_change_mgr(es, x, y, width, height); + uifw_trace("uifw_set_positionsize: Leave(Request from App)"); + return; + } + + uifw_trace("uifw_set_positionsize: Initial Position/Size visible=%d", + usurf->visible); + /* Initiale position is (0,0) */ + weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x), + (float)(usurf->node_tbl->disp_y)); + } + + uifw_trace("uifw_set_positionsize: Old geometry x/y=%d/%d,w/h=%d/%d", + (int)es->geometry.x, (int)es->geometry.y, + (int)es->geometry.width, (int)es->geometry.height); + + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + usurf->animation.no_configure = (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? 1 : 0; + + usurf->x = x; + usurf->y = y; + usurf->width = width; + usurf->height = height; + if (_ico_win_mgr->num_manager <= 0) { + /* no manager(HomeScreen), set geometory */ + weston_surface_set_position(es, (float)(usurf->node_tbl->disp_x + x), + (float)(usurf->node_tbl->disp_y + y)); + } + if ((es->output) && (es->buffer_ref.buffer) && + (es->geometry.width > 0) && (es->geometry.height > 0)) { + uifw_trace("uifw_set_positionsize: Fixed Geometry, Change(Vis=%d)", + usurf->visible); + if (usurf->visible) { + if ((flags & ICO_WINDOW_MGR_FLAGS_ANIMATION) && + (win_mgr_hook_animation != NULL)) { + /* with animation */ + if ((x != (usurf->surface->geometry.x - usurf->node_tbl->disp_x)) || + (y != (usurf->surface->geometry.y - usurf->node_tbl->disp_y))) { + op = ICO_WINDOW_MGR_ANIMATION_OPMOVE; + } + else if ((width != usurf->surface->geometry.width) || + (height != usurf->surface->geometry.height)) { + op = ICO_WINDOW_MGR_ANIMATION_OPRESIZE; + } + else { + op = ICO_WINDOW_MGR_ANIMATION_OPNONE; + } + if (((op == ICO_WINDOW_MGR_ANIMATION_OPMOVE) && + (usurf->animation.move_anima != ICO_WINDOW_MGR_ANIMATION_NONE)) || + ((op == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) && + (usurf->animation.resize_anima != ICO_WINDOW_MGR_ANIMATION_NONE))) { + retanima = (*win_mgr_hook_animation)(op, (void *)usurf); + uifw_trace("uifw_set_positionsize: ret call anima = %d", retanima); + } + } + if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) || + (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) { + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + } + } + } + if ((retanima == ICO_WINDOW_MGR_ANIMATION_RET_NOANIMA) || + (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL)) { + win_mgr_change_surface(es, + (flags & ICO_WINDOW_MGR_FLAGS_NO_CONFIGURE) ? -1 : 0, 1); + } + uifw_trace("uifw_set_positionsize: Leave(OK,output=%08x)", (int)es->output); + } + else { + usurf->x = x; + usurf->y = y; + usurf->width = width; + usurf->height = height; + uifw_trace("uifw_set_positionsize: Leave(OK,but no buffer)"); + } + + /* if position change, call hook for input region */ + if (win_mgr_hook_change != NULL) { + if ((oldx != usurf->x) || (oldy != usurf->y) || (oldnode != usurf->node_tbl)) { + (*win_mgr_hook_change)(usurf); + } + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_visible: surface visible/raise control + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] visible visible(1=show/0=hide/other=no change) + * @param[in] raise raise(1=raise/0=lower/other=no change) + * @param[in] flags with/without animation + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_visible(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t visible, int32_t raise, int32_t flags) +{ + struct uifw_win_surface *usurf; + struct uifw_client *uclient; + int restack; + int retanima; + int oldvisible; + + uifw_trace("uifw_set_visible: Enter(surf=%08x,%d,%d,%x)", + surfaceid, visible, raise, flags); + + usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + if ((! usurf) || (! usurf->surface)) { + uifw_trace("uifw_set_visible: Leave(Surface Not Exist)"); + return; + } + oldvisible = ico_window_mgr_is_visible(usurf); + + uclient = find_client_from_client(client); + if (uclient) { + if ((surfaceid != ICO_WINDOW_MGR_V_MAINSURFACE) && + (uclient->manager == 0) && (uclient->privilege == 0)) { + uifw_trace("uifw_set_visible: Request from App(%s), not Manager", + uclient->appid); + uclient = NULL; + } + else { + uifw_trace("uifw_set_visible: Request from Manager(%s)", uclient->appid); + } + } + else { + uifw_trace("uifw_set_visible: Request from Unknown App, not Manager"); + } + + restack = 0; + + if ((usurf->disable == 0) && (visible == ICO_WINDOW_MGR_VISIBLE_SHOW)) { + +#if PERFORMANCE_EVALUATIONS > 0 + if (! usurf->visible) { + uifw_perf("SWAP_BUFFER Show appid=%s surface=%08x", + usurf->uclient->appid, usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ + if ((! usurf->visible) || + (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { + usurf->visible = 1; + uifw_trace("uifw_set_visible: Change to Visible"); + + ico_ivi_shell_set_toplevel(usurf->shsurf); + + /* Weston surface configure */ + uifw_trace("uifw_set_visible: Visible to Weston WSurf=%08x,%d.%d/%d/%d/%d", + (int)usurf->surface, usurf->node_tbl->node, usurf->x, usurf->y, + usurf->width, usurf->height); + ico_ivi_shell_set_surface_type(usurf->shsurf); + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + + restack = 1; /* need damage */ + + if ((flags & (ICO_WINDOW_MGR_ANIMATION_POS|ICO_WINDOW_MGR_FLAGS_ANIMATION)) && + (usurf->animation.show_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && + (win_mgr_hook_animation != NULL)) { + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + usurf->animation.no_configure = 0; + retanima = (*win_mgr_hook_animation)( + (flags & ICO_WINDOW_MGR_ANIMATION_POS) ? + ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS : + ICO_WINDOW_MGR_ANIMATION_OPSHOW, + (void *)usurf); + uifw_trace("uifw_set_visible: ret call anima = %d", retanima); + } + } + else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && + (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { + uifw_trace("uifw_set_visible: Leave(No Change)"); + return; + } + } + else if (visible == ICO_WINDOW_MGR_VISIBLE_HIDE) { + +#if PERFORMANCE_EVALUATIONS > 0 + if (usurf->visible) { + uifw_perf("SWAP_BUFFER Hide appid=%s surface=%08x", + usurf->uclient->appid, usurf->surfaceid); + } +#endif /*PERFORMANCE_EVALUATIONS*/ + if ((usurf->visible) || + (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { + + /* Reset focus */ + win_mgr_reset_focus(usurf); + + /* Weston surface configure */ + weston_surface_damage_below(usurf->surface); + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + + retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA; + if ((flags & (ICO_WINDOW_MGR_FLAGS_ANIMATION|ICO_WINDOW_MGR_ANIMATION_POS)) && + (usurf->animation.hide_anima != ICO_WINDOW_MGR_ANIMATION_NONE) && + (win_mgr_hook_animation != NULL)) { + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + usurf->animation.no_configure = 0; + retanima = (*win_mgr_hook_animation)( + (flags & ICO_WINDOW_MGR_ANIMATION_POS) ? + ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS : + ICO_WINDOW_MGR_ANIMATION_OPHIDE, + (void *)usurf); + } + if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) { + usurf->visible = 0; + uifw_trace("uifw_set_visible: Change to UnVisible"); + /* change visible to unvisible, restack surface list */ + restack = 1; + /* Weston surface configure */ + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + } + else { + uifw_trace("uifw_set_visible: UnVisible but animation"); + } + } + else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && + (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { + uifw_trace("uifw_set_visible: Leave(No Change)"); + return; + } + } + else if ((raise != ICO_WINDOW_MGR_RAISE_LOWER) && + (raise != ICO_WINDOW_MGR_RAISE_RAISE)) { + uifw_trace("uifw_set_visible: Leave(No Change)"); + return; + } + + /* raise/lower */ + if ((raise == ICO_WINDOW_MGR_RAISE_LOWER) || (raise == ICO_WINDOW_MGR_RAISE_RAISE)) { + win_mgr_set_raise(usurf, raise); + if (usurf->visible == 0) { + restack |= 2; + } + } + else { + raise = ICO_WINDOW_MGR_V_NOCHANGE; + } + + if (restack) { + ico_window_mgr_restack_layer(usurf); + } + + /* send event(VISIBLE) to manager */ + if (restack) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, + usurf, + (visible == ICO_WINDOW_MGR_VISIBLE_SHOW) ? 1 : + ((visible == ICO_WINDOW_MGR_VISIBLE_HIDE) ? 0 : + ICO_WINDOW_MGR_V_NOCHANGE), + raise, uclient ? 0 : 1, 0,0); + } + + /* if visible change, call hook for input region */ + if (win_mgr_hook_change != NULL) { + if (oldvisible != ico_window_mgr_is_visible(usurf)) { + (*win_mgr_hook_change)(usurf); + } + } + uifw_trace("uifw_set_visible: Leave(OK)"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_animation: set animation of surface visible/unvisible + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] type how to change surface + * @param[in] anmation animation name + * @param[in] time animation time(ms), if 0, default time + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_animation(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t type, const char *animation, int32_t time) +{ + int animaid; + struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + + uifw_trace("uifw_set_transition: surf=%08x,type=%x,anim=%s,time=%d", + surfaceid, type, animation, time); + + if (usurf) { + if ((*animation != 0) && (*animation != ' ')) { + animaid = ico_get_animation_name(animation); + uifw_trace("uifw_set_animation: Leave(OK) type=%d", animaid); + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { + if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDE) || + (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPHIDEPOS)) { + usurf->animation.next_anima = animaid; + } + else { + usurf->animation.hide_anima = animaid; + } + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { + if ((usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOW) || + (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPSHOWPOS)) { + usurf->animation.next_anima = animaid; + } + else { + usurf->animation.show_anima = animaid; + } + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { + if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPMOVE) { + usurf->animation.next_anima = animaid; + } + else { + usurf->animation.move_anima = animaid; + } + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { + if (usurf->animation.type == ICO_WINDOW_MGR_ANIMATION_OPRESIZE) { + usurf->animation.next_anima = animaid; + } + else { + usurf->animation.resize_anima = animaid; + } + } + } + if ((time > 0) && (time != ICO_WINDOW_MGR_V_NOCHANGE)) { + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE) { + usurf->animation.hide_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW) { + usurf->animation.show_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE) { + usurf->animation.move_time = time; + } + if (type & ICO_WINDOW_MGR_ANIMATION_TYPE_RESIZE) { + usurf->animation.resize_time = time; + } + } + } + else { + uifw_trace("uifw_set_animation: Surface(%08x) Not exist", surfaceid); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_attributes: set surface attributes + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] attributes surface attributes + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_attributes(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, uint32_t attributes) +{ + struct uifw_win_surface *usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + + uifw_trace("uifw_set_attributes: Enter(surf=%08x,attributes=%x)", surfaceid, attributes); + + if (usurf) { + usurf->attributes = attributes; + if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) == + (ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT)) { + usurf->attributes &= + ~(ICO_WINDOW_MGR_ATTR_ALIGN_LEFT|ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT); + } + if ((attributes & (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) == + (ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM)) { + usurf->attributes &= + ~(ICO_WINDOW_MGR_ATTR_ALIGN_TOP|ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM); + } + } + uifw_trace("uifw_set_attributes: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_visible_animation: surface visibility control with animation + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid surface id + * @param[in] visible visible(1=show/0=hide) + * @param[in] x X coordinate on screen(if bigger than 16383, no change) + * @param[in] y Y coordinate on screen(if bigger than 16383, no change) + * @param[in] width surface width(if bigger than 16383, no change) + * @param[in] height surface height(if bigger than 16383, no change) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_visible_animation(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t visible, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + struct uifw_win_surface *usurf; + + uifw_trace("uifw_visible_animation: Enter(%08x,%d,x/y=%d/%d,w/h=%d/%d)", + surfaceid, visible, x, y, width, height); + + usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + + if ((! usurf) || (! usurf->surface)) { + uifw_trace("uifw_visible_animation: Leave(Surface Not Exist)"); + return; + } + + usurf->animation.pos_x = x; + usurf->animation.pos_y = y; + if (width > 0) usurf->animation.pos_width = width; + else usurf->animation.pos_width = 1; + if (height > 0) usurf->animation.pos_height = height; + else usurf->animation.pos_height = 1; + usurf->animation.no_configure = 0; + + uifw_set_visible(client, resource, surfaceid, visible, + ICO_WINDOW_MGR_V_NOCHANGE, ICO_WINDOW_MGR_ANIMATION_POS); + + uifw_trace("uifw_visible_animation: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_active: set active surface + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid UIFW surface id + * @param[in] active target device + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_active(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t active) +{ + struct uifw_win_surface *usurf; + + uifw_trace("uifw_set_active: Enter(surf=%08x,active=%x)", surfaceid, active); + + if ((surfaceid > 0) && + ((active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) != 0)) { + usurf = ico_window_mgr_get_usurf_client(surfaceid, client); + } + else { + usurf = NULL; + } + if (usurf) { + switch (active & (ICO_WINDOW_MGR_ACTIVE_POINTER|ICO_WINDOW_MGR_ACTIVE_KEYBOARD)) { + case ICO_WINDOW_MGR_ACTIVE_POINTER: + if (usurf != _ico_win_mgr->active_pointer_usurf) { + uifw_trace("uifw_set_active: pointer active change %08x->%08x", + _ico_win_mgr->active_pointer_usurf ? + _ico_win_mgr->active_pointer_usurf->surfaceid : 0, + usurf ? usurf->surfaceid : 0); + if (_ico_win_mgr->active_pointer_usurf) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_pointer_usurf, + (_ico_win_mgr->active_keyboard_usurf == + _ico_win_mgr->active_pointer_usurf) ? + ICO_WINDOW_MGR_ACTIVE_KEYBOARD : + ICO_WINDOW_MGR_ACTIVE_NONE, + 0,0,0,0); + } + _ico_win_mgr->active_pointer_usurf = usurf; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + usurf, + ICO_WINDOW_MGR_ACTIVE_POINTER | + (_ico_win_mgr->active_keyboard_usurf == usurf) ? + ICO_WINDOW_MGR_ACTIVE_KEYBOARD : 0, + 0,0,0,0); + win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER); + } + break; + case ICO_WINDOW_MGR_ACTIVE_KEYBOARD: + if (usurf != _ico_win_mgr->active_keyboard_usurf) { + uifw_trace("uifw_set_active: keyboard active change %08x->%08x", + _ico_win_mgr->active_keyboard_usurf ? + _ico_win_mgr->active_keyboard_usurf->surfaceid : 0, + usurf ? usurf->surfaceid : 0); + if (_ico_win_mgr->active_keyboard_usurf) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_keyboard_usurf, + (_ico_win_mgr->active_keyboard_usurf == + _ico_win_mgr->active_pointer_usurf) ? + ICO_WINDOW_MGR_ACTIVE_POINTER : + ICO_WINDOW_MGR_ACTIVE_NONE, + 0,0,0,0); + } + _ico_win_mgr->active_keyboard_usurf = usurf; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + usurf, + ICO_WINDOW_MGR_ACTIVE_KEYBOARD | + (_ico_win_mgr->active_pointer_usurf == usurf) ? + ICO_WINDOW_MGR_ACTIVE_POINTER : 0, + 0,0,0,0); + win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_KEYBOARD); + } + break; + default: + if ((usurf != _ico_win_mgr->active_pointer_usurf) || + (usurf != _ico_win_mgr->active_keyboard_usurf)) { + uifw_trace("uifw_set_active: active change %08x/%08x->%08x", + _ico_win_mgr->active_pointer_usurf ? + _ico_win_mgr->active_pointer_usurf->surfaceid : 0, + _ico_win_mgr->active_keyboard_usurf ? + _ico_win_mgr->active_keyboard_usurf->surfaceid : 0, + usurf ? usurf->surfaceid : 0); + if (_ico_win_mgr->active_pointer_usurf) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_pointer_usurf, + ICO_WINDOW_MGR_ACTIVE_NONE, + 0,0,0,0); + if (_ico_win_mgr->active_keyboard_usurf == + _ico_win_mgr->active_pointer_usurf) { + _ico_win_mgr->active_keyboard_usurf = NULL; + } + } + if (_ico_win_mgr->active_keyboard_usurf) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + _ico_win_mgr->active_keyboard_usurf, + ICO_WINDOW_MGR_ACTIVE_NONE, + 0,0,0,0); + } + _ico_win_mgr->active_pointer_usurf = usurf; + _ico_win_mgr->active_keyboard_usurf = usurf; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + usurf, + ICO_WINDOW_MGR_ACTIVE_POINTER | + ICO_WINDOW_MGR_ACTIVE_KEYBOARD, + 0,0,0,0); + win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | + ICO_WINDOW_MGR_ACTIVE_KEYBOARD); + } + break; + } + uifw_trace("uifw_set_active: Leave(Change Active)"); + } + else { + win_mgr_set_active(NULL, active); + uifw_trace("uifw_set_active: Leave(Reset active surface)"); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_set_layer_visible: layer visible control + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] layer layer id + * @param[in] visible visible(1=show/0=hide) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_set_layer_visible(struct wl_client *client, struct wl_resource *resource, + uint32_t layer, int32_t visible) +{ + struct uifw_win_layer *el; + struct uifw_win_layer *new_el; + struct uifw_win_surface *usurf; + int layertype = 0; + + if ((layer == ICO_WINDOW_MGR_LAYERTYPE_BACKGROUND) || + (layer == (uint32_t)_ico_ivi_background_layer)) { + layer = _ico_ivi_background_layer; + layertype = LAYER_TYPE_BACKGROUND; + } + else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_TOUCH) || + (layer == (uint32_t)_ico_ivi_touch_layer)) { + layer = _ico_ivi_touch_layer; + layertype = LAYER_TYPE_TOUCH; + } + else if ((layer == ICO_WINDOW_MGR_LAYERTYPE_CURSOR) || + (layer == (uint32_t)_ico_ivi_cursor_layer)) { + layer = _ico_ivi_cursor_layer; + layertype = LAYER_TYPE_CURSOR; + } + else if (layer == ICO_WINDOW_MGR_LAYERTYPE_STARTUP) { + layer = _ico_ivi_startup_layer; + } + + uifw_trace("uifw_set_layer_visible: Enter(layer=%d, visilbe=%d)", layer, visible); + + /* Search Layer */ + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + if (el->layer == layer) break; + } + + if (&el->link == &_ico_win_mgr->ivi_layer_list) { + /* layer not exist, create new layer */ + uifw_trace("uifw_set_layer_visible: New Layer %d", layer); + new_el = win_mgr_create_layer(NULL, layer, layertype); + if (! new_el) { + uifw_trace("uifw_set_layer_visible: Leave(No Memory)"); + return; + } + new_el->visible = (visible != 0) ? TRUE : FALSE; + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL, + layer, new_el->visible, 0,0,0); + uifw_trace("uifw_set_layer_visible: Leave(new layer)"); + return; + } + + /* control all surface in layer */ + if ((el->visible != FALSE) && (visible == 0)) { + /* layer change to NOT visible */ + uifw_trace("uifw_set_layer_visible: change to not visible"); + el->visible = FALSE; + } + else if ((el->visible == FALSE) && (visible != 0)) { + /* layer change to visible */ + uifw_trace("uifw_set_layer_visible: change to visible"); + el->visible = TRUE; + } + else { + /* no change */ + uifw_trace("uifw_set_layer_visible: Leave(no Change %d=>%d)", + el->visible, visible); + return; + } + + /* set damege area */ + wl_list_for_each (usurf, &el->surface_list, ivi_layer) { + if ((usurf->visible != FALSE) && (usurf->surface != NULL) && + (usurf->surface->output != NULL)) { + /* Reset focus if hide */ + if (visible == 0) { + win_mgr_reset_focus(usurf); + } + /* Damage(redraw) target surface */ + weston_surface_damage_below(usurf->surface); + } + } + + /* rebild compositor surface list */ + ico_window_mgr_restack_layer(NULL); + + /* send layer visible event to manager */ + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_LAYER_VISIBLE, NULL, + layer, el->visible, 0,0,0); + + uifw_trace("uifw_set_layer_visible: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_get_surfaces: get application surfaces + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] appid application id + * @param[in] pid process id + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_get_surfaces(struct wl_client *client, struct wl_resource *resource, + const char *appid, int32_t pid) +{ + struct uifw_client *uclient; + struct uifw_win_layer *el; + struct uifw_win_surface *usurf; + struct wl_array reply; + uint32_t *up; + + uifw_trace("uifw_get_surfaces: Enter(appid=%s, pid=%d)", appid ? appid : " ", pid); + + wl_array_init(&reply); + + wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) { + if ((appid != NULL) && (*appid != ' ')) { + if (strcmp(uclient->appid, appid) == 0) break; + } + if (pid != 0) { + if (uclient->pid == pid) break; + } + } + if (&uclient->link == &_ico_win_mgr->client_list) { + uifw_trace("uifw_get_surfaces: appid=%s pid=%d dose not exist", + appid ? appid : " ", pid); + } + else { + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + wl_list_for_each (usurf, &el->surface_list, ivi_layer) { + if (usurf->uclient == uclient) { + uifw_trace("uifw_get_surfaces: %s(%d) surf=%08x", + uclient->appid, uclient->pid, usurf->surfaceid); + up = (uint32_t *)wl_array_add(&reply, sizeof(uint32_t)); + if (up) { + *up = usurf->surfaceid; + } + } + } + } + } + ico_window_mgr_send_app_surfaces(resource, uclient->appid, uclient->pid, &reply); + + wl_array_release(&reply); + uifw_trace("uifw_get_surfaces: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_check_mapsurrace: check and change all surface + * + * @param[in] animation weston animation table(unused) + * @param[in] outout weston output table(unused) + * @param[in] mseces current time(unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_check_mapsurrace(struct weston_animation *animation, + struct weston_output *output, uint32_t msecs) +{ + struct uifw_surface_map *sm; + uint32_t curtime; + int wait = 99999999; + + /* check touch down counter */ + if (touch_check_seat) { + if (touch_check_seat->num_tp > 10) { + uifw_trace("win_mgr_change_mapsurface: illegal touch counter(num=%d), reset", + (int)touch_check_seat->num_tp); + touch_check_seat->num_tp = 0; + } + } + + /* check all mapped surfaces */ + curtime = weston_compositor_get_time(); + wl_list_for_each (sm, &_ico_win_mgr->map_list, map_link) { + win_mgr_change_mapsurface(sm, 0, curtime); + if (sm->eventque) { + if (sm->interval < wait) { + wait = sm->interval; + } + } + } + + /* check frame interval */ + if (wait < 99999999) { + wait = wait / 2; + } + else { + wait = 1000; + } + if (wait != _ico_win_mgr->waittime) { + _ico_win_mgr->waittime = wait; + wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, + _ico_win_mgr->waittime); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_timer_mapsurrace: mapped surface check timer + * + * @param[in] data user data(unused) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static int +win_mgr_timer_mapsurrace(void *data) +{ + win_mgr_check_mapsurrace(NULL, NULL, 0); + return 1; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_change_mapsurface: check and change mapped surface + * + * @param[in] sm map surface table + * @param[in] event send event (if 0, send if changed) + * @param[in] curtime current time(ms) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_change_mapsurface(struct uifw_surface_map *sm, int event, uint32_t curtime) +{ + struct uifw_drm_buffer *drm_buffer; + struct uifw_dri_image *dri_image; + struct uifw_intel_region *dri_region; + struct uifw_gl_surface_state *gl_state; + struct weston_surface *es; + uint32_t eglname; + int width; + int height; + int stride; + uint32_t format; + uint32_t dtime; + + /* check if buffered */ + es = sm->usurf->surface; + if ((es == NULL) || (es->buffer_ref.buffer == NULL) || + (es->buffer_ref.buffer->width <= 0) || (es->buffer_ref.buffer->height <= 0) || + (es->buffer_ref.buffer->legacy_buffer == NULL) || (es->renderer_state == NULL)) { + drm_buffer = NULL; + } + else { + drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( + (struct wl_resource *)es->buffer_ref.buffer->legacy_buffer); + if ((drm_buffer != NULL) && (drm_buffer->driver_buffer == NULL)) { + drm_buffer = NULL; + } + } + if ((drm_buffer == NULL) || (_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION)) { + /* surface has no buffer or not use GPU acceleration */ + /* currently, not support No Intel GPU, so same as no surafce */ + /* if (! es) { */ + /* UIFW surface has no weston surface, error */ + uifw_debug("win_mgr_change_mapsurface: surface(%08x) has no buffer", + sm->usurf->surfaceid); + if (sm->initflag) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP; + } + else { + event = 0; + } + /* } */ + } + else { + gl_state = (struct uifw_gl_surface_state *)es->renderer_state; + if (gl_state->buffer_type == BUFFER_TYPE_SHM) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR; + } + else if (gl_state->buffer_type != BUFFER_TYPE_EGL) { + event = 0; + } + else { + dri_image = (struct uifw_dri_image *)drm_buffer->driver_buffer; + dri_region = dri_image->region; + width = es->buffer_ref.buffer->width; + height = es->buffer_ref.buffer->height; + stride = drm_buffer->stride[0]; + if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { + format = EGL_TEXTURE_RGB; + } + else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { + format = EGL_TEXTURE_RGBA; + } + else { + /* unknown format, error */ + format = EGL_NO_TEXTURE; + } + eglname = dri_region->name; + if (eglname == 0) { + if (drm_intel_bo_flink((drm_intel_bo *)dri_region->bo, &eglname)) { + uifw_warn("win_mgr_change_mapsurface: drm_intel_bo_flink() Error"); + eglname = 0; + } + } + if ((sm->initflag == 0) && (eglname != 0) && + (width > 0) && (height > 0) && (stride > 0)) { + sm->initflag = 1; + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP; + } + else { + if ((eglname == 0) || (width <= 0) || (height <= 0) || (stride <= 0)) { + event = 0; + } + else if (event == 0) { + if ((sm->width != width) || (sm->height != height) || + (sm->stride != stride) || (format != sm->format)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE; + } + else if (eglname != sm->eglname) { +#if PIXEL_SPEED_TEST > 0 + uifw_debug("start read pixel %s.%08x (%d,%d)", + sm->usurf->uclient->appid, sm->usurf->surfaceid, + sm->width, sm->height); + if ((*(_ico_win_mgr->compositor->renderer->read_surface_pixels)) + (sm->usurf->surface, PIXMAN_a8r8g8b8, + speed_buffer, 0, 0, sm->width, sm->height) != 0) { + uifw_debug("error read pixel %s.%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); + } + else { + uifw_debug("end read pixel %s.%08x", + sm->usurf->uclient->appid, sm->usurf->surfaceid); + } +#endif +#if PERFORMANCE_EVALUATIONS > 0 + uifw_perf("SWAP_BUFFER appid=%s surface=%08x name=%d", + sm->usurf->uclient->appid, sm->usurf->surfaceid, + sm->eglname); +#endif /*PERFORMANCE_EVALUATIONS*/ + dtime = curtime - sm->lasttime; + if ((sm->interval > 0) && (dtime < sm->interval)) { + sm->eventque = 1; + event = 0; + } + else { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; + } + } + else if (sm->eventque) { + dtime = curtime - sm->lasttime; + if ((sm->interval == 0) || (dtime >= sm->interval)) { + event = ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS; + } + } + } + } + sm->width = width; + sm->height = height; + sm->stride = stride; + sm->eglname = eglname; + sm->format = format; + } + } + + if (event != 0) { +#if 0 /* too many logs */ + uifw_debug("win_mgr_change_mapsurface: send MAP event(ev=%d surf=%08x name=%d " + "w/h/s=%d/%d/%d format=%x", + event, sm->usurf->surfaceid, sm->eglname, + sm->width, sm->height, sm->stride, sm->format); +#endif + sm->lasttime = curtime; + sm->eventque = 0; + ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, event, + sm->usurf->surfaceid, sm->type, sm->eglname, + sm->width, sm->height, sm->stride, sm->format); + if (event == ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR) { + /* free map table if error */ + wl_list_remove(&sm->surf_link); + wl_list_remove(&sm->map_link); + sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; + _ico_win_mgr->free_maptable = sm; + } + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_map_surface: mapped surface buffer to system application + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid surface id + * @param[in] framerate frame rate of surface update(frame/sec) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_map_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid, int32_t framerate) +{ + struct uifw_win_surface *usurf; + struct weston_surface *es; + struct uifw_surface_map *sm; + struct weston_buffer *buffer; + struct uifw_client *uclient; + struct uifw_drm_buffer *drm_buffer; + struct uifw_gl_surface_state *gl_state; + + uifw_trace("uifw_map_surface: Enter(surface=%08x,fps=%d)", surfaceid, framerate); + + usurf = ico_window_mgr_get_usurf(surfaceid); + if (! usurf) { + /* surface dose not exist, error */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 1, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface=%08x dose not exist)", surfaceid); + return; + } + uclient = find_client_from_client(client); + if ((! uclient) || (! uclient->mgr)) { + /* client dose not exist, error */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 2, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(client=%08x dose not exist)", (int)client); + return; + } + + /* check if buffered */ + es = usurf->surface; + if (es == NULL) { + /* surface has no buffer, error */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 3, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) has no surface)", surfaceid); + return; + } + + /* check buffer type */ + gl_state = (struct uifw_gl_surface_state *)es->renderer_state; + if ((_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) || + (gl_state == NULL) || (gl_state->buffer_type == BUFFER_TYPE_SHM)) { + /* wl_shm_buffer not support */ + ico_window_mgr_send_map_surface(resource, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 4, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(surface(%08x) is wl_shm_buffer, " + "not support)", surfaceid); + return; + } + + /* check same surface */ + wl_list_for_each(sm, &usurf->surf_map, surf_link) { + if ((sm->usurf == usurf) && (sm->uclient == uclient)) { + break; + } + } + + if (&sm->surf_link == &usurf->surf_map) { + /* create map table */ + sm = _ico_win_mgr->free_maptable; + if (sm) { + _ico_win_mgr->free_maptable = (struct uifw_surface_map *)sm->usurf; + } + else { + sm = (struct uifw_surface_map *)malloc(sizeof(struct uifw_surface_map)); + if (! sm) { + ico_window_mgr_send_map_surface(resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR, + surfaceid, 6, 0, 0, 0, 0, 0); + uifw_trace("uifw_map_surface: Leave(malloc error)"); + return; + } + } + memset(sm, 0, sizeof(struct uifw_surface_map)); + + wl_list_init(&sm->map_link); + wl_list_init(&sm->surf_link); + sm->usurf = usurf; + sm->uclient = uclient; + sm->type = ICO_WINDOW_MGR_MAP_TYPE_EGL; + sm->framerate = framerate; + if (sm->framerate > 60) sm->framerate = 60; + if (sm->framerate > 0) { + sm->interval = (1000 / sm->framerate) - 1; + } + wl_list_insert(_ico_win_mgr->map_list.next, &sm->map_link); + wl_list_insert(usurf->surf_map.prev, &sm->surf_link); + } + else { + /* change frame rate */ + uifw_trace("uifw_map_surface: Leave(chagne frame rate %d->%d", + sm->framerate, framerate); + if (sm->framerate != framerate) { + sm->framerate = framerate; + if (sm->framerate > 60) sm->framerate = 60; + if (sm->framerate > 0) { + sm->interval = (1000 / sm->framerate) - 1; + } + win_mgr_change_mapsurface(sm, 0, weston_compositor_get_time()); + } + return; + } + + buffer = es->buffer_ref.buffer; + if ((buffer != NULL) && (gl_state->buffer_type == BUFFER_TYPE_EGL)) { + sm->width = buffer->width; + sm->height = buffer->height; + drm_buffer = (struct uifw_drm_buffer *)wl_resource_get_user_data( + (struct wl_resource *)buffer->legacy_buffer); + if (drm_buffer != NULL) { + sm->stride = drm_buffer->stride[0]; + if (drm_buffer->format == __DRI_IMAGE_FOURCC_XRGB8888) { + sm->format = EGL_TEXTURE_RGB; + } + else if (drm_buffer->format == __DRI_IMAGE_FOURCC_ARGB8888) { + sm->format = EGL_TEXTURE_RGBA; + } + else { + /* unknown format, error */ + sm->format = EGL_NO_TEXTURE; + } + if ((sm->width > 0) && (sm->height > 0) && (sm->stride > 0) && + (gl_state != NULL)) { + sm->initflag = 1; + } + } + } + + /* send map event */ + if (sm->initflag) { + win_mgr_change_mapsurface(sm, ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP, + weston_compositor_get_time()); + } + uifw_trace("uifw_map_surface: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief uifw_unmap_surface: unmap surface buffer + * + * @param[in] client Weyland client + * @param[in] resource resource of request + * @param[in] surfaceid surface id + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +uifw_unmap_surface(struct wl_client *client, struct wl_resource *resource, + uint32_t surfaceid) +{ + struct uifw_win_surface *usurf; + struct uifw_surface_map *sm, *sm_tmp; + struct uifw_client *uclient; + + uifw_trace("uifw_unmap_surface: Enter(surface=%08x)", surfaceid); + + usurf = ico_window_mgr_get_usurf(surfaceid); + if (! usurf) { + /* surface dose not exist, error */ + uifw_trace("uifw_unmap_surface: Leave(surface=%08x dose not exist)", surfaceid); + return; + } + if (client) { + uclient = find_client_from_client(client); + if ((! uclient) || (! uclient->mgr)) { + /* client dose not exist, error */ + uifw_trace("uifw_unmap_surface: Leave(client=%08x dose not exist)", (int)client); + return; + } + } + else { + uclient = NULL; + wl_list_for_each (sm, &usurf->surf_map, surf_link) { + if (sm->uclient->mgr != NULL) { + uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x " + "w/h/s=%d/%d/%d format=%x", + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid, + sm->eglname, sm->width, sm->height, sm->stride, sm->format); + ico_window_mgr_send_map_surface(sm->uclient->mgr->resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, + surfaceid, sm->type, sm->eglname, sm->width, + sm->height, sm->stride, sm->format); + } + } + } + + wl_list_for_each_safe (sm, sm_tmp, &usurf->surf_map, surf_link) { + if (((uclient != NULL) && (sm->uclient != uclient))) continue; + /* send unmap event */ + if ((uclient != NULL) && (uclient->mgr != NULL)) { + uifw_trace("uifw_unmap_surface: send UNMAP event(ev=%d surf=%08x name=%08x " + "w/h/s=%d/%d/%d format=%x", + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, surfaceid, + sm->eglname, sm->width, sm->height, sm->stride, sm->format); + ico_window_mgr_send_map_surface(uclient->mgr->resource, + ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP, + surfaceid, sm->type, sm->eglname, sm->width, + sm->height, sm->stride, sm->format); + } + wl_list_remove(&sm->surf_link); + wl_list_remove(&sm->map_link); + sm->usurf = (struct uifw_win_surface *)_ico_win_mgr->free_maptable; + _ico_win_mgr->free_maptable = sm; + } + uifw_trace("uifw_unmap_surface: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_surface_change_mgr: surface chagen from manager(HomeScreen) + * + * @param[in] surface Weston surface + * @param[in] x X coordinate on screen + * @param[in] y Y coordinate on screen + * @param[in] width surface width + * @param[in] height surface height + * @return number of managers + * @retval > 0 number of managers + * @retval 0 manager not exist + */ +/*--------------------------------------------------------------------------*/ +static int +win_mgr_surface_change_mgr(struct weston_surface *surface, + const int x, const int y, const int width, const int height) +{ + int num_mgr; + struct uifw_win_surface *usurf; + + uifw_trace("win_mgr_surface_change_mgr: Enter(%08x,x/y=%d/%d,w/h=%d/%d)", + (int)surface, x, y, width, height); + + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_surface_change_mgr: Leave(Not Exist)"); + return 0; + } + + num_mgr = ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, + usurf, x, y, width, height, 1); + + uifw_trace("win_mgr_surface_change_mgr: Leave(%d)", num_mgr); + return num_mgr; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_change_surface: surface change + * + * @param[in] surface Weston surface + * @param[in] to destination(0=Client&Manager,1=Client,-1=Manager) + * @param[in] manager request from manager(0=Client,1=Manager) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_change_surface(struct weston_surface *surface, const int to, const int manager) +{ + struct uifw_win_surface *usurf; + struct weston_surface *es; + int x; + int y; + int repaint = 0; + + uifw_trace("win_mgr_change_surface: Enter(%08x,%d,%d)", (int)surface, to, manager); + + /* Find surface */ + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_change_surface: Leave(Not Exist)"); + return; + } + es = usurf->surface; + if (! es) { + uifw_trace("win_mgr_change_surface: Leave(No weston surface)"); + return; + } + + /* set surface size */ + uifw_debug("win_mgr_change_surface: set surface x/y=%d/%d=>%d/%d w/h=%d/%d=>%d/%d", + (int)es->geometry.x, (int)es->geometry.y, usurf->x, usurf->y, + usurf->width, usurf->height, es->geometry.width, es->geometry.height); + if ((usurf->width <= 0) || (usurf->height <= 0)) { + usurf->width = es->geometry.width; + usurf->height = es->geometry.height; + } + win_mgr_set_scale(usurf); + if (usurf->visible) { + weston_surface_set_position(usurf->surface, + (float)(usurf->node_tbl->disp_x + + usurf->x + usurf->xadd), + (float)(usurf->node_tbl->disp_y + + usurf->y + usurf->yadd)); + ico_window_mgr_restack_layer(usurf); + } + else { + weston_surface_set_position(usurf->surface, (float)(ICO_IVI_MAX_COORDINATE+1), + (float)(ICO_IVI_MAX_COORDINATE+1)); + } + + /* send wayland event to client */ + if ((to >= 0) && (usurf->shsurf != NULL) && (manager !=0) && + (usurf->width > 0) && (usurf->height > 0)) { + if ((usurf->width != usurf->conf_width) || + (usurf->height != usurf->conf_height)) { + usurf->conf_width = usurf->width; + usurf->conf_height = usurf->height; + uifw_trace("win_mgr_change_surface: SURFACE_CONFIGURE %08x(%08x),w/h=%d/%d ", + usurf->surfaceid, (int)es, usurf->width, usurf->height); + ico_ivi_shell_send_configure(es, + WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, + usurf->width, usurf->height); + } + } + + if (usurf->visible) { + x = usurf->node_tbl->disp_x + usurf->x; + y = usurf->node_tbl->disp_y + usurf->y; + } + else { + x = ICO_IVI_MAX_COORDINATE+1; + y = ICO_IVI_MAX_COORDINATE+1; + } + /* change geometry if request from manager */ + if (manager) { + if ((usurf->width != es->geometry.width) || + (usurf->height != es->geometry.height) || + (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) { + win_mgr_surface_configure(usurf, (float)x, (float)y, usurf->width, usurf->height); + repaint ++; + } + } + + /* send manager event to HomeScreen */ + if (to <= 0) { + if (manager) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, + usurf, usurf->x, usurf->y, + usurf->width, usurf->height, 0); + } + else { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, + usurf, (int)es->geometry.x, (int)es->geometry.y, + es->geometry.width, es->geometry.height, 1); + } + } + + /* change geometry if request from client */ + if (! manager) { + if ((usurf->width != es->geometry.width) || (usurf->height != es->geometry.height) || + (es->geometry.x != (float)x) || (es->geometry.y != (float)y)) { + win_mgr_surface_configure(usurf, x, y, usurf->width, usurf->height); + repaint ++; + } + } + + if (repaint) { + uifw_trace("win_mgr_change_surface: repaint"); + weston_compositor_schedule_repaint(_ico_win_mgr->compositor); + } + uifw_trace("win_mgr_change_surface: Leave(OK)"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_surface_configure: UIFW surface configure + * + * @param[in] usurf UIFW surface + * @param[in] x X coordinate on screen + * @param[in] y Y coordinate on screen + * @param[in] width surface width + * @param[in] height surface height + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_surface_configure(struct uifw_win_surface *usurf, + int x, int y, int width, int height) +{ + struct weston_surface *es; + + es = usurf->surface; + if ((es != NULL) && (es->buffer_ref.buffer)) { + if (usurf->client_width == 0) { + usurf->client_width = es->geometry.width; + if (usurf->client_width == 0) + usurf->client_width = weston_surface_buffer_width(es); + } + if (usurf->client_height == 0) { + usurf->client_height = es->geometry.height; + if (usurf->client_height == 0) + usurf->client_height = weston_surface_buffer_height(es); + } + + /* not set geometry width/height */ + win_mgr_set_scale(usurf); + weston_surface_set_position(es, x + usurf->xadd, y + usurf->yadd); + } +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_shell_configure: shell surface configure + * + * @param[in] surface Weston surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_shell_configure(struct weston_surface *surface) +{ + struct uifw_win_surface *usurf; + int buf_width; + int buf_height; + + uifw_trace("win_mgr_shell_configure: Enter(%08x)", (int)surface); + + /* Find UIFW surface */ + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_shell_configure: Leave(Not Exist)"); + return; + } + + usurf->client_width = surface->geometry.width; + usurf->client_height = surface->geometry.height; + buf_width = weston_surface_buffer_width(surface); + buf_height = weston_surface_buffer_height(surface); + uifw_trace("win_mgr_shell_configure: %08x client w/h=%d/%d buf=%d/%d", + usurf->surfaceid, + usurf->client_width, usurf->client_height, buf_width, buf_height); + if (usurf->client_width > buf_width) usurf->client_width = buf_width; + if (usurf->client_height > buf_height) usurf->client_height = buf_height; + + /* send event to manager */ + win_mgr_change_surface(surface, -1, 0); + + uifw_trace("win_mgr_shell_configure: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_select_surface: select surface by Bottun/Touch + * + * @param[in] surface Weston surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_select_surface(struct weston_surface *surface) +{ + struct uifw_win_surface *usurf; + + uifw_trace("win_mgr_select_surface: Enter(%08x)", (int)surface); + + /* find surface */ + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_select_surface: Leave(Not Exist)"); + return; + } + if (usurf != _ico_win_mgr->active_pointer_usurf) { + + /* send active event to manager */ + if (ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0) <= 0) { + uifw_trace("win_mgr_select_surface: not found manager, set active"); + win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | + ICO_WINDOW_MGR_ACTIVE_KEYBOARD); + } + } + uifw_trace("win_mgr_select_surface: Leave(OK)"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_set_title: set tile name to surface + * + * @param[in] surface weston surface + * @param[in] title title name + * @return title string + * @retval != NULL title string + * @retval NULL no title string + */ +/*--------------------------------------------------------------------------*/ +static char * +win_mgr_set_title(struct weston_surface *surface, const char *title) +{ + struct uifw_win_surface *usurf; + char *optpoint, *ppoint, *bpoint, *cpoint; + int layer, visible, raise, node, x, y, width, height, attribute; + int rx, ry, rw, rh; + char wktitle[ICO_IVI_WINNAME_LENGTH + 256]; + + uifw_trace("win_mgr_set_title: Enter(%08x) name=%s", (int)surface, title); + + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_set_title: Leave(Not Exist)"); + return (char *)title; + } + + layer = -1; + visible = -1; + raise = -1; + node = -1; + x = -1; + y = -1; + width = -1; + height = -1; + attribute = -1; + + strncpy(wktitle, title, ICO_IVI_WINNAME_LENGTH+256-1); + wktitle[ICO_IVI_WINNAME_LENGTH+256-1] = 0; + + /* get option parameters */ + optpoint = strstr(wktitle, "@@"); + + if (optpoint != NULL) { + *optpoint = 0; + + usurf->uclient->privilege = 1; /* privilege application */ + ppoint = optpoint + 2; + while (1) { + bpoint = strtok(ppoint, "=;"); + ppoint = NULL; + if (! bpoint) break; + if (strcasecmp(bpoint, "layer") == 0) { + /* layer name or number */ + bpoint = strtok(ppoint, "=;"); + if (bpoint) { + if (strcasecmp(bpoint, "background") == 0) { + layer = _ico_ivi_background_layer; + } + else if (strcasecmp(bpoint, "default") == 0) { + layer = _ico_ivi_default_layer; + } + else if (strcasecmp(bpoint, "touch") == 0) { + layer = _ico_ivi_touch_layer; + } + else if (strcasecmp(bpoint, "cursor") == 0) { + layer = _ico_ivi_cursor_layer; + } + else if (strcasecmp(bpoint, "startup") == 0) { + layer = _ico_ivi_startup_layer; + } + else { + layer = strtol(bpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "show") == 0) { + /* show */ + visible = 1; + } + else if (strcasecmp(bpoint, "hide") == 0) { + /* hide */ + visible = 0; + } + else if (strcasecmp(bpoint, "raise") == 0) { + /* raiee */ + raise = 1; + } + else if (strcasecmp(bpoint, "lower") == 0) { + /* lower */ + raise = 0; + } + else if (strcasecmp(bpoint, "node") == 0) { + /* node */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + node = strtol(bpoint, (char **)0, 0); + } + } + else if (strcasecmp(bpoint, "position") == 0) { + /* position */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + cpoint = strtok(ppoint, ";"); + if (cpoint) { + x = strtol(bpoint, (char **)0, 0); + y = strtol(cpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "size") == 0) { + /* size */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + cpoint = strtok(ppoint, ";"); + if (cpoint) { + width = strtol(bpoint, (char **)0, 0); + height = strtol(cpoint, (char **)0, 0); + } + } + } + else if (strcasecmp(bpoint, "attribute") == 0) { + /* attribute flags */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + attribute = strtol(bpoint, (char **)0, 0); + } + } + else if (strcasecmp(bpoint, "region") == 0) { + /* set input region */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = 0; + rw = 100; + rh = 50; + rx = strtol(bpoint, (char **)0, 0); + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ","); + if (bpoint) { + rw = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ";"); + if (bpoint) { + rh = strtol(bpoint, (char **)0, 0); + } + if (win_mgr_hook_inputregion) { + (*win_mgr_hook_inputregion)(1, usurf, rx, ry, rw, rh, 0, 0, + 0, 0, 0, 0, 0); + } + } + } + else if (strcasecmp(bpoint, "unregion") == 0) { + /* unset input region */ + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = 0; + rw = 100; + rh = 50; + rx = strtol(bpoint, (char **)0, 0); + bpoint = strtok(ppoint, ","); + if (bpoint) { + ry = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ","); + if (bpoint) { + rw = strtol(bpoint, (char **)0, 0); + } + bpoint = strtok(ppoint, ";"); + if (bpoint) { + rh = strtol(bpoint, (char **)0, 0); + } + if (win_mgr_hook_inputregion) { + (*win_mgr_hook_inputregion)(0, usurf, rx, ry, rw, rh, 0, 0, + 0, 0, 0, 0, 0); + } + } + } + } + } + + if ((optpoint == NULL) || (wktitle[0] != 0)) { + if (((usurf->width > 0) && (usurf->height > 0)) && + ((usurf->created == 0) || + (strncmp(wktitle, usurf->winname, ICO_IVI_WINNAME_LENGTH-1) != 0))) { + strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); + usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; + if (usurf->created == 0) { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CREATED, usurf, 0,0,0,0,0); + usurf->created = 1; + } + else { + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_NAME, usurf, 0,0,0,0,0); + } + } + else { + strncpy(usurf->winname, wktitle, ICO_IVI_WINNAME_LENGTH-1); + usurf->winname[ICO_IVI_WINNAME_LENGTH-1] = 0; + } + } + + if (optpoint) { + if (layer >= 0) { + uifw_set_window_layer(usurf->uclient->client, NULL, usurf->surfaceid, layer); + } + if (attribute >= 0) { + uifw_set_attributes(usurf->uclient->client, NULL, usurf->surfaceid, attribute); + } + if ((node >= 0) || (x >=0) || (y >= 0) || (width >=0) || (height >= 0)) { + if (node < 0) node = usurf->node_tbl->node; + if (x < 0) x = ICO_IVI_MAX_COORDINATE + 1; + if (y < 0) y = ICO_IVI_MAX_COORDINATE + 1; + if (width < 0) width = ICO_IVI_MAX_COORDINATE + 1; + if (height < 0) height = ICO_IVI_MAX_COORDINATE + 1; + uifw_set_positionsize(usurf->uclient->client, NULL, usurf->surfaceid, + node, x, y, width, height, 0); + } + if ((visible >= 0) || (raise >= 0)) { + if (visible < 0) visible = ICO_WINDOW_MGR_V_NOCHANGE; + if (raise < 0) raise = ICO_WINDOW_MGR_V_NOCHANGE; + uifw_set_visible(usurf->uclient->client, NULL, usurf->surfaceid, + visible, raise, 0); + } + } + uifw_trace("win_mgr_set_title: Leave"); + + return usurf->winname; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_surface_move: set tile name to surface + * + * @param[in] surface weston surface + * @param[in] title title name + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_surface_move(struct weston_surface *surface, int *dx, int *dy) +{ + struct uifw_win_surface *usurf; + + uifw_trace("win_mgr_surface_move: Enter(%08x) x/y=%d,%d", (int)surface, *dx, *dy); + + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_surface_move: Leave(Not Exist)"); + return; + } + if (usurf->visible) { + *dx = usurf->node_tbl->disp_x + usurf->x; + *dy = usurf->node_tbl->disp_y + usurf->y; + } + else { + *dx = ICO_IVI_MAX_COORDINATE+1; + *dy = ICO_IVI_MAX_COORDINATE+1; + } + uifw_trace("win_mgr_surface_move: Leave(change to x/y=%d/%d)", *dx, *dy); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_show_layer: shell layer visible control + * + * @param[in] layertype shell layer type + * @param[in] show show(1)/hide(0) + * @param[in] data requested weston surface in show + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_show_layer(int layertype, int show, void *data) +{ + struct uifw_win_layer *el; + struct uifw_win_surface *usurf; + struct uifw_win_surface *inusurf = NULL; + + uifw_trace("win_mgr_show_layer: Enter(type=%d, show=%d, data=%08x)", + layertype, show, (int)data); + + if (layertype != LAYER_TYPE_INPUTPANEL) { + uifw_trace("win_mgr_show_layer: Leave(layertype npt InputPanel)"); + return; + } + if (show) { + if (data == NULL) { + uifw_trace("win_mgr_show_layer: Leave(show but input surface not exist)"); + return; + } + inusurf = find_uifw_win_surface_by_ws((struct weston_surface *)data); + if (! inusurf) { + uifw_trace("win_mgr_show_layer: Leave(show but unknown input surface)"); + return; + } + } + + /* all input panel surface show/hide */ + wl_list_for_each (el, &_ico_win_mgr->ivi_layer_list, link) { + if ((el->layertype == LAYER_TYPE_CURSOR) || + (el->layertype == LAYER_TYPE_TOUCH)) continue; + wl_list_for_each (usurf, &el->surface_list, ivi_layer) { + if ((usurf->layertype == LAYER_TYPE_INPUTPANEL) && + (usurf->surface != NULL) && (usurf->mapped != 0) && + (usurf->surface->buffer_ref.buffer != NULL)) { + + if ((inusurf != NULL) && (usurf->win_layer != inusurf->win_layer)) { + win_mgr_set_layer(usurf, usurf->win_layer->layer); + usurf->raise = 1; + win_mgr_change_surface(usurf->surface, -1, 1); + } + if ((show == 0) || (ico_ivi_optionflag() & ICO_IVI_OPTION_SHOW_INPUTLAYER)) { + /* show input panel automatically */ + ico_window_mgr_set_visible(usurf, show | 2); + } + else { + /* send hint event to HomeScreen */ + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, + usurf, show, ICO_WINDOW_MGR_RAISE_RAISE, 1, 0,0); + } + } + } + } + uifw_trace("win_mgr_show_layer: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_fullscreen: shell full screen surface control + * + * @param[in] event control event + * @param[in] surface target weston surface + * @return result + */ +/*--------------------------------------------------------------------------*/ +static int +win_mgr_fullscreen(int event, struct weston_surface *surface) +{ + struct uifw_win_surface *usurf; + struct uifw_win_surface *tmpusurf; + struct uifw_win_layer *ulayer; + int width, height; + int sx, sy; + + uifw_trace("win_mgr_fullscreen: Enter(event=%d, surface=%08x)", event, (int)surface); + + if (event == SHELL_FULLSCREEN_HIDEALL) { + /* hide all fullscreen srface */ + uifw_trace("win_mgr_fullscreen: SHELL_FULLSCREEN_HIDEALL"); + + wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) { + if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue; + wl_list_for_each_safe (usurf, tmpusurf, &ulayer->surface_list, ivi_layer) { + if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { + ico_window_mgr_set_visible(usurf, 2); + usurf->layertype = usurf->old_layertype; + win_mgr_set_layer(usurf, usurf->old_layer->layer); + win_mgr_change_surface(usurf->surface, -1, 1); + /* send event to HomeScreen */ + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, + usurf, usurf->x, usurf->y, + usurf->width, usurf->height, 0); + } + } + } + uifw_trace("win_mgr_fullscreen: Leave"); + return 0; + } + + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_fullscreen: Leave(surface dose not exist)"); + return -1; + } + + switch(event) { + case SHELL_FULLSCREEN_ISTOP: /* check if top surrace */ + if (usurf->layertype == LAYER_TYPE_FULLSCREEN) { + wl_list_for_each (ulayer, &_ico_win_mgr->ivi_layer_list, link) { + if (ulayer->layertype >= LAYER_TYPE_TOUCH) continue; + wl_list_for_each(tmpusurf, &ulayer->surface_list, ivi_layer) { + if (usurf == tmpusurf) { + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" + "(fullscreen surface)", usurf->surfaceid); + return 1; + } + if (tmpusurf->layertype == LAYER_TYPE_FULLSCREEN) { + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" + "(fullscreen surface but not top)", usurf->surfaceid); + return 0; + } + } + } + } + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_ISTOP" + "(not fullscreen surface)", usurf->surfaceid); + return 0; + case SHELL_FULLSCREEN_SET: /* change surface to full screen */ + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_SET", usurf->surfaceid); + if (usurf->layertype != LAYER_TYPE_FULLSCREEN) { + usurf->old_layertype = usurf->layertype; + usurf->layertype = LAYER_TYPE_FULLSCREEN; + usurf->old_layer = usurf->win_layer; + /* send hint event to HomeScreen */ + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_CONFIGURE, + usurf, usurf->x, usurf->y, + usurf->width, usurf->height, 1); + } + break; + case SHELL_FULLSCREEN_STACK: /* change surface to top of layer */ + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_STACK", usurf->surfaceid); + if (usurf->mapped == 0) { + uifw_trace("win_mgr_fullscreen: not map, change to map"); + width = usurf->node_tbl->disp_width; + height = usurf->node_tbl->disp_height; + sx = 0; + sy = 0; + win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy); + } + if ((usurf->surface != NULL) && (usurf->mapped != 0) && + (usurf->surface->buffer_ref.buffer != NULL)) { + /* fullscreen surface raise */ + win_mgr_set_raise(usurf, 1); + } + break; + case SHELL_FULLSCREEN_CONF: /* configure full screen surface */ + uifw_trace("win_mgr_fullscreen: %08x SHELL_FULLSCREEN_CONF", usurf->surfaceid); + if (usurf->mapped == 0) { + width = usurf->node_tbl->disp_width; + height = usurf->node_tbl->disp_height; + sx = 0; + sy = 0; + win_mgr_map_surface(usurf->surface, &width, &height, &sx, &sy); + } + break; + default: + uifw_trace("win_mgr_fullscreen: Leave(unknown event %d)", event); + return -1; + } + uifw_trace("win_mgr_fullscreen: Leave"); + return 0; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_reset_focus: reset surface focus + * + * @param[in] usurf UIFW surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_reset_focus(struct uifw_win_surface *usurf) +{ + struct weston_seat *seat; + struct weston_surface *surface; + + uifw_trace("win_mgr_reset_focus: Enter(%08x)", usurf->surfaceid); + + seat = container_of (_ico_win_mgr->compositor->seat_list.next, struct weston_seat, link); + surface = usurf->surface; + if ((seat != NULL) && (surface != NULL)) { +#if 0 /* pointer grab can not release */ + /* reset pointer focus */ + if ((seat->pointer != NULL) && (seat->pointer->focus == surface)) { + weston_pointer_set_focus(seat->pointer, NULL, + wl_fixed_from_int(0), wl_fixed_from_int(0)); + } + /* reset touch focus */ + if ((seat->touch != NULL) && (seat->touch->focus == surface)) { + weston_touch_set_focus(seat, NULL); + } +#endif /* pointer grab can not release */ + /* reset keyboard focus */ + if ((seat->keyboard != NULL) && (seat->keyboard->focus == surface)) { + weston_keyboard_set_focus(seat->keyboard, NULL); + } + } + uifw_trace("win_mgr_reset_focus: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_visible: change surface visibility + * + * @param[in] usurf UIFW surface + * @param[in] visible bit 0: visible(=1)/unvisible(=0) + * bit 1: widht anima(=1)/without anima(=0) + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_visible(struct uifw_win_surface *usurf, const int visible) +{ + int retanima; + + if (visible & 1) { + if ((usurf->visible == 0) || + (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { + uifw_trace("ico_window_mgr_set_visible: Chagne to Visible(%08x) x/y=%d/%d", + usurf->surfaceid, usurf->x, usurf->y); + usurf->visible = 1; + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + if ((visible & 2) && (win_mgr_hook_animation != NULL)) { + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + usurf->animation.no_configure = 0; + retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPSHOW, + (void *)usurf); + uifw_trace("ico_window_mgr_set_visible: show animation = %d", retanima); + } + /* change unvisible to visible, restack surface list */ + ico_window_mgr_restack_layer(usurf); + } + } + else { + if ((usurf->visible != 0) || + (usurf->animation.state != ICO_WINDOW_MGR_ANIMATION_STATE_NONE)) { + + uifw_trace("ico_window_mgr_set_visible: Chagne to Unvisible(%08x)", + usurf->surfaceid); + + /* Reset focus */ + win_mgr_reset_focus(usurf); + + retanima = ICO_WINDOW_MGR_ANIMATION_RET_ANIMA; + if ((visible & 2) && (win_mgr_hook_animation != NULL)) { + usurf->animation.pos_x = usurf->x; + usurf->animation.pos_y = usurf->y; + usurf->animation.pos_width = usurf->width; + usurf->animation.pos_height = usurf->height; + usurf->animation.no_configure = 0; + retanima = (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_OPHIDE, + (void *)usurf); + uifw_trace("ico_window_mgr_set_visible: hide animation = %d", retanima); + if (retanima != ICO_WINDOW_MGR_ANIMATION_RET_ANIMANOCTL) { + usurf->visible = 0; + /* Weston surface configure */ + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + } + } + else { + usurf->visible = 0; + /* Weston surface configure */ + ico_window_mgr_set_weston_surface(usurf, usurf->x, usurf->y, + usurf->width, usurf->height); + } + ico_window_mgr_restack_layer(usurf); + } + } + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, + usurf, usurf->visible, usurf->raise, 0, 0, 0); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_set_raise: change surface raise/lower + * + * @param[in] usurf UIFW surface + * @param[in] raise raise(=1)/lower(0) + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_set_raise(struct uifw_win_surface *usurf, const int raise) +{ + struct uifw_win_surface *eu; + + uifw_trace("win_mgr_set_raise: Enter(%08x,%d) layer=%d type=%x", + (int)usurf, raise, (int)usurf->win_layer->layer, usurf->layertype); + + wl_list_remove(&usurf->ivi_layer); + if (raise & 1) { + /* raise ... surface stack to top of layer */ + if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { + /* if input panel, top of surface list */ + uifw_trace("win_mgr_set_raise: Raise Link to Top(InputPanel)"); + wl_list_insert(&usurf->win_layer->surface_list, &usurf->ivi_layer); + } + else { + /* if not input panel, search not input panel */ + wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) { + if (eu->layertype != LAYER_TYPE_INPUTPANEL) break; + } + uifw_trace("win_mgr_set_raise: Raise Link to Top(Normal)"); + wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer); + } + usurf->raise = 1; + } + else { + /* Lower ... surface stack to bottom of layer */ + if (usurf->layertype == LAYER_TYPE_INPUTPANEL) { + /* if input panel, search not input panel */ + uifw_trace("win_mgr_set_raise: Lower Link to Bottom(InputPanel)"); + wl_list_for_each (eu, &usurf->win_layer->surface_list, ivi_layer) { + if (eu->layertype != LAYER_TYPE_INPUTPANEL) break; + } + wl_list_insert(eu->ivi_layer.prev, &usurf->ivi_layer); + } + else { + /* if not input panel, bottom of surface list */ + uifw_trace("win_mgr_set_raise: Lower Link to Bottom(Normal)"); + wl_list_insert(usurf->win_layer->surface_list.prev, &usurf->ivi_layer); + } + usurf->raise = 0; + } + + /* rebild compositor surface list */ + if ((raise & 2) == 0) { + if (usurf->visible) { + ico_window_mgr_restack_layer(usurf); + } + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_VISIBLE, + usurf, usurf->visible, usurf->raise, 0, 0,0); + } + uifw_trace("win_mgr_set_raise: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_destroy_surface: surface destroy + * + * @param[in] surface Weston surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +win_mgr_destroy_surface(struct weston_surface *surface) +{ + struct uifw_win_surface *usurf; + struct uifw_win_surface *phash; + struct uifw_win_surface *bhash; + uint32_t hash; + + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("win_mgr_destroy_surface: UIFW surface Not Exist"); + return; + } + uifw_trace("win_mgr_destroy_surface: Enter(%08x) %08x", (int)surface, usurf->surfaceid); + + /* Reset focus */ + win_mgr_reset_focus(usurf); + + /* destory input region */ + if (win_mgr_hook_destory) { + (*win_mgr_hook_destory)(usurf); + } + + /* unmap surface */ + if (&usurf->surf_map != usurf->surf_map.next) { + uifw_unmap_surface(NULL, NULL, usurf->surfaceid); + } + + /* destroy active surface */ + if (usurf == _ico_win_mgr->active_pointer_usurf) { + _ico_win_mgr->active_pointer_usurf = NULL; + } + if (usurf == _ico_win_mgr->active_keyboard_usurf) { + _ico_win_mgr->active_keyboard_usurf = NULL; + } + + /* destroy animation extenson */ + if (win_mgr_hook_animation) { + (*win_mgr_hook_animation)(ICO_WINDOW_MGR_ANIMATION_DESTROY, (void *)usurf); + } + + /* delete from layer list */ + wl_list_remove(&usurf->ivi_layer); + ico_window_mgr_restack_layer(NULL); + + /* delete from cleint list */ + wl_list_remove(&usurf->client_link); + + /* delete from hash table */ + hash = MAKE_IDHASH(usurf->surfaceid); + phash = _ico_win_mgr->idhash[hash]; + bhash = NULL; + while ((phash) && (phash != usurf)) { + bhash = phash; + phash = phash->next_idhash; + } + if (bhash) { + bhash->next_idhash = usurf->next_idhash; + } + else { + _ico_win_mgr->idhash[hash] = usurf->next_idhash; + } + + hash = MAKE_WSHASH(usurf->surface); + phash = _ico_win_mgr->wshash[hash]; + bhash = NULL; + while ((phash) && (phash != usurf)) { + bhash = phash; + phash = phash->next_wshash; + } + if (bhash) { + bhash->next_wshash = usurf->next_wshash; + } + else { + _ico_win_mgr->wshash[hash] = usurf->next_wshash; + } + + ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_DESTROYED, + usurf, 0,0,0,0,0); + + hash = usurf->surfaceid & SURCAFE_ID_MASK; + _ico_win_mgr->surfaceid_map[(hash - 1)/16] &= ~(1 << ((hash - 1) % 16)); + + free(usurf); + uifw_trace("win_mgr_destroy_surface: Leave(OK)"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief bind_ico_win_mgr: bind Multi Window Manager from client + * + * @param[in] client client + * @param[in] data user data(unused) + * @param[in] version protocol version(unused) + * @param[in] id client object id + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +bind_ico_win_mgr(struct wl_client *client, + void *data, uint32_t version, uint32_t id) +{ + struct wl_resource *add_resource; + struct uifw_manager *mgr; + struct uifw_client *uclient; + + uifw_trace("bind_ico_win_mgr: Enter(client=%08x, id=%x)", (int)client, (int)id); + + add_resource = wl_resource_create(client, &ico_window_mgr_interface, 1, id); + if (add_resource) { + wl_resource_set_implementation(add_resource, &ico_window_mgr_implementation, + _ico_win_mgr, unbind_ico_win_mgr); + } + + /* Create client management tabel */ + uclient = find_client_from_client(client); + if (! uclient) { + win_mgr_bind_client(client, NULL); + uclient = find_client_from_client(client); + } + + /* Manager */ + mgr = (struct uifw_manager *)malloc(sizeof(struct uifw_manager)); + if (! mgr) { + uifw_error("bind_ico_win_mgr: Error, No Memory"); + return; + } + memset(mgr, 0, sizeof(struct uifw_manager)); + mgr->resource = add_resource; + if (uclient) { + uclient->mgr = mgr; + } + wl_list_insert(&_ico_win_mgr->manager_list, &mgr->link); + + uifw_trace("bind_ico_win_mgr: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief unbind_ico_win_mgr: unbind Multi Window Manager from client + * + * @param[in] resource client resource + * @return none + */ +/*--------------------------------------------------------------------------*/ +static void +unbind_ico_win_mgr(struct wl_resource *resource) +{ + struct uifw_manager *mgr, *itmp; + + uifw_trace("unbind_ico_win_mgr: Enter"); + + /* Remove manager from manager list */ + _ico_win_mgr->num_manager = 0; + wl_list_for_each_safe (mgr, itmp, &_ico_win_mgr->manager_list, link) { + if (mgr->resource == resource) { + wl_list_remove(&mgr->link); + free(mgr); + } + else { + if (mgr->manager) { + _ico_win_mgr->num_manager++; + } + } + } + uifw_trace("unbind_ico_win_mgr: Leave"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_win_mgr_send_to_mgr: send event to manager(HomeScreen) + * + * @param[in] event event code(if -1, not send event) + * @param[in] usurf UIFW surface table + * @param[in] param1 parameter 1 + * @param[in] : : + * @param[in] param5 parameter 5 + * @return number of managers + * @retval > 0 number of managers + * @retval 0 manager not exist + */ +/*--------------------------------------------------------------------------*/ +static int +ico_win_mgr_send_to_mgr(const int event, struct uifw_win_surface *usurf, + const int param1, const int param2, const int param3, + const int param4, const int param5) +{ + int num_mgr = 0; + struct uifw_manager* mgr; + + /* if appid not fix, check and fix appid */ + if ((usurf != NULL) && + (usurf->uclient->fixed_appid < ICO_WINDOW_MGR_APPID_FIXCOUNT)) { + win_mgr_get_client_appid(usurf->uclient); + } + + /* send created if not send created event */ + if ((usurf != NULL) && (usurf->created == 0) && + (((usurf->width > 0) && (usurf->height > 0)) || + ((event != ICO_WINDOW_MGR_WINDOW_CREATED) && + (event != ICO_WINDOW_MGR_WINDOW_NAME)))) { + wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { + if (mgr->manager) { + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_CREATED" + "(surf=%08x,name=%s,pid=%d,appid=%s,type=%x)", (int)mgr->resource, + usurf->surfaceid, usurf->winname, usurf->uclient->pid, + usurf->uclient->appid, usurf->layertype); + ico_window_mgr_send_window_created(mgr->resource, usurf->surfaceid, + usurf->winname, usurf->uclient->pid, + usurf->uclient->appid, + usurf->layertype << 12); + } + } + usurf->created = 1; + } + + wl_list_for_each (mgr, &_ico_win_mgr->manager_list, link) { + if (mgr->manager) { + num_mgr ++; + + switch(event) { + case ICO_WINDOW_MGR_WINDOW_CREATED: + /* Do nothing anymore because sended window create event */ + break; + + case ICO_WINDOW_MGR_WINDOW_NAME: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) WINDOW_NAME" + "(surf=%08x,name=%s)", (int)mgr->resource, + usurf->surfaceid, usurf->winname); + ico_window_mgr_send_window_name(mgr->resource, usurf->surfaceid, + usurf->winname); + break; + + case ICO_WINDOW_MGR_WINDOW_DESTROYED: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) DESTROYED" + "(surf=%08x)", (int)mgr->resource, usurf->surfaceid); + ico_window_mgr_send_window_destroyed(mgr->resource, usurf->surfaceid); + break; + + case ICO_WINDOW_MGR_WINDOW_VISIBLE: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) VISIBLE" + "(surf=%08x,vis=%d,raise=%d,hint=%d)", + (int)mgr->resource, usurf->surfaceid, param1, param2, param3); + ico_window_mgr_send_window_visible(mgr->resource, + usurf->surfaceid, param1, param2, param3); + break; + + case ICO_WINDOW_MGR_WINDOW_CONFIGURE: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) CONFIGURE" + "(surf=%08x,app=%s,node=%x,type=%x,layer=%d," + "x/y=%d/%d,w/h=%d/%d,hint=%d)", + (int)mgr->resource, usurf->surfaceid, usurf->uclient->appid, + usurf->node_tbl->node, usurf->layertype, + usurf->win_layer->layer, param1, param2, param3, param4, param5); + ico_window_mgr_send_window_configure(mgr->resource, usurf->surfaceid, + usurf->node_tbl->node, + usurf->layertype << 12, + usurf->win_layer->layer, + param1, param2, param3, param4, param5); + break; + + case ICO_WINDOW_MGR_WINDOW_ACTIVE: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) ACTIVE" + "(surf=%08x,active=%d)", (int)mgr->resource, usurf->surfaceid, + param1); + ico_window_mgr_send_window_active(mgr->resource, usurf->surfaceid, + (uint32_t)param1); + break; + + case ICO_WINDOW_MGR_LAYER_VISIBLE: + uifw_trace("ico_win_mgr_send_to_mgr: Send Manager(%08x) LAYER_VISIBLE" + "(layer=%d,visivle=%d)", (int)mgr->resource, param1, param2); + ico_window_mgr_send_layer_visible(mgr->resource, (uint32_t)param1, param2); + break; + + default: + uifw_error("ico_win_mgr_send_to_mgr: Illegal event(%08x)", event); + break; + } + } + } + return num_mgr; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief win_mgr_set_scale: set surface transform scale + * + * @param[in] usurf UIFW surface + * @return chagne display + * @retval =1 change display + * @retval =0 no change + */ +/*--------------------------------------------------------------------------*/ +static int +win_mgr_set_scale(struct uifw_win_surface *usurf) +{ + struct weston_surface *es; + float scalex; + float scaley; + int ret = 0; + + es = usurf->surface; + if ((es != NULL) && (es->buffer_ref.buffer)) { + if (usurf->client_width == 0) usurf->client_width = es->geometry.width; + if (usurf->client_height == 0) usurf->client_height = es->geometry.height; + if ((usurf->client_width > 0) && (usurf->client_height > 0)) { + scalex = (float)usurf->width / (float)usurf->client_width; + scaley = (float)usurf->height / (float)usurf->client_height; + } + else { + scalex = 1.0f; + scaley = 1.0f; + } + uifw_debug("win_mgr_set_scale: %08x X=%4.2f(%d/%d) Y=%4.2f(%d/%d)", + usurf->surfaceid, scalex, usurf->width, usurf->client_width, + scaley, usurf->height, usurf->client_height); + usurf->xadd = 0; + usurf->yadd = 0; + if ((ico_ivi_optionflag() & ICO_IVI_OPTION_FIXED_ASPECT) || + (usurf->attributes & ICO_WINDOW_MGR_ATTR_FIXED_ASPECT)) { + if (scalex > scaley) { + scalex = scaley; + if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_LEFT) == 0) { + usurf->xadd = (float)usurf->width - ((float)usurf->client_width * scalex); + if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_RIGHT) == 0) { + usurf->xadd /= 2; + } + } + } + else if (scalex < scaley) { + scaley = scalex; + if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_TOP) == 0) { + usurf->yadd = (float)usurf->height - ((float)usurf->client_height * scaley); + if ((usurf->attributes & ICO_WINDOW_MGR_ATTR_ALIGN_BOTTOM) == 0) { + usurf->yadd /= 2; + } + } + } + uifw_trace("win_mgr_set_scale: %08x fixed aspect x/yadd=%d/%d", + usurf->surfaceid, usurf->xadd, usurf->yadd); + } + if ((scalex != usurf->scalex) || (scaley != usurf->scaley)) { + usurf->scalex = scalex; + usurf->scaley = scaley; + if ((scalex != 1.0f) || (scaley != 1.0f)) { + weston_matrix_init(&usurf->transform.matrix); + weston_matrix_scale(&usurf->transform.matrix, scalex, scaley, 1.0f); + uifw_trace("win_mgr_set_scale: change scale(%d)", usurf->set_transform); + if (usurf->set_transform == 0) { + usurf->set_transform = 1; + wl_list_init(&usurf->transform.link); + wl_list_insert(&es->geometry.transformation_list, &usurf->transform.link); + } + } + else if (usurf->set_transform != 0) { + uifw_trace("win_mgr_set_scale: reset transform"); + usurf->set_transform = 0; + wl_list_remove(&usurf->transform.link); + } + weston_surface_geometry_dirty(es); + weston_surface_update_transform(es); + weston_surface_damage_below(es); + weston_surface_damage(es); + ret = 1; + } + } + return ret; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_uclient: get UIFW client table + * + * @param[in] appid application Id + * @return UIFW client table + * @retval !=NULL success(UIFW client table address) + * @retval = NULL error(appid not exist) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT struct uifw_client * +ico_window_mgr_get_uclient(const char *appid) +{ + struct uifw_client *uclient; + + wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) { + if (strcmp(uclient->appid, appid) == 0) { + return uclient; + } + } + return NULL; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_get_client_usurf: get client UIFW surface table + * + * @param[in] target surface window name and application Id(winname@appid) + * @return UIFW surface table + * @retval !=NULL success(UIFW surface table address) + * @retval = NULL error(appid or winname not exist) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT struct uifw_win_surface * +ico_window_mgr_get_client_usurf(const char *target) +{ + struct uifw_client *uclient; + struct uifw_win_surface *usurf; + int i, j; + char winname[ICO_IVI_WINNAME_LENGTH]; + char appid[ICO_IVI_APPID_LENGTH]; + + /* get window name and application id */ + j = 0; + for (i = 0; target[i]; i++) { + if (target[i] == '@') { + if (target[i+1] != '@') break; + i ++; + } + if (j < (ICO_IVI_WINNAME_LENGTH-1)) { + winname[j++] = target[i]; + } + } + winname[j] = 0; + if (target[i] == '@') { + i ++; + } + else { + winname[0] = 0; + i = 0; + } + j = 0; + for ( ; target[i]; i++) { + if ((target[i] == '@') && (target[i+1] == '@')) i ++; + if (j < (ICO_IVI_APPID_LENGTH-1)) { + appid[j++] = target[i]; + } + } + appid[j] = 0; + uifw_debug("ico_window_mgr_get_client_usurf: target=<%s> appid=<%s> win=<%s>", + target, appid, winname); + + wl_list_for_each (uclient, &_ico_win_mgr->client_list, link) { + if (strcmp(uclient->appid, appid) == 0) { + wl_list_for_each (usurf, &uclient->surface_link, client_link) { + if ((winname[0] == 0) || + (strcmp(winname, usurf->winname) == 0)) { + return usurf; + } + } + } + } + return NULL; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_is_visible: check surface visible + * + * @param[in] usurf UIFW surface + * @return visibility + * @retval =1 visible + * @retval =0 not visible + * @retval =-1 surface visible but layer not vlsible + * @retval =-2 surface visible but lower(currently not support) + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +ico_window_mgr_is_visible(struct uifw_win_surface *usurf) +{ + if ((usurf->visible == 0) || (usurf->surface == NULL) || (usurf->mapped == 0)) { + return 0; + } + if (usurf->win_layer->visible == 0) { + return -1; + } + return 1; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_active_surface: set active surface + * + * @param[in] surface Weston surface + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_active_surface(struct weston_surface *surface) +{ + struct uifw_win_surface *usurf; + + /* find surface */ + usurf = find_uifw_win_surface_by_ws(surface); + if (! usurf) { + uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", (int)surface); + uifw_trace("ico_window_mgr_active_surface: Leave(Not Exist)"); + return; + } + uifw_trace("ico_window_mgr_active_surface: Enter(%08x)", usurf->surfaceid); + + if ((usurf != _ico_win_mgr->active_pointer_usurf) || + (usurf != _ico_win_mgr->active_keyboard_usurf)) { + + /* set weston active surface */ + win_mgr_set_active(usurf, ICO_WINDOW_MGR_ACTIVE_POINTER | + ICO_WINDOW_MGR_ACTIVE_KEYBOARD); + /* send active event to manager */ + (void) ico_win_mgr_send_to_mgr(ICO_WINDOW_MGR_WINDOW_ACTIVE, + usurf, ICO_WINDOW_MGR_ACTIVE_SELECTED, 0,0,0,0); + } + uifw_trace("ico_window_mgr_active_surface: Leave(OK)"); +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_hook_animation: set animation hook routine + * + * @param[in] hook_animation hook routine + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_hook_animation(int (*hook_animation)(const int op, void *data)) +{ + win_mgr_hook_animation = hook_animation; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_hook_change: set input region hook routine + * + * @param[in] hook_change hook routine + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_hook_change(void (*hook_change)(struct uifw_win_surface *usurf)) +{ + win_mgr_hook_change = hook_change; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_hook_destory: set input region hook routine + * + * @param[in] hook_destroy hook routine + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_hook_destory(void (*hook_destroy)(struct uifw_win_surface *usurf)) +{ + win_mgr_hook_destory = hook_destroy; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief ico_window_mgr_set_hook_inputregion: set input region hook routine + * + * @param[in] hook_inputregion hook routine + * @return none + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT void +ico_window_mgr_set_hook_inputregion( + void (*hook_inputregion)(int set, struct uifw_win_surface *usurf, + int32_t x, int32_t y, int32_t width, + int32_t height, int32_t hotspot_x, int32_t hotspot_y, + int32_t cursor_x, int32_t cursor_y, int32_t cursor_width, + int32_t cursor_height, uint32_t attr)) +{ + win_mgr_hook_inputregion = hook_inputregion; +} + +/*--------------------------------------------------------------------------*/ +/** + * @brief module_init: initialize ico_window_mgr + * this function called from ico_pluign_loader + * + * @param[in] es weston compositor + * @param[in] argc number of arguments(unused) + * @param[in] argv argument list(unused) + * @return result + * @retval 0 sccess + * @retval -1 error + */ +/*--------------------------------------------------------------------------*/ +WL_EXPORT int +module_init(struct weston_compositor *ec, int *argc, char *argv[]) +{ + int nodeId; + int i; + int idx; + struct weston_output *output; + struct weston_config_section *section; + char *displayno = NULL; + char *p; + char *wrkstrp; + struct wl_event_loop *loop; + + uifw_info("ico_window_mgr: Enter(module_init)"); + + /* get ivi debug level */ + section = weston_config_get_section(ec->config, "ivi-option", NULL, NULL); + if (section) { + weston_config_section_get_int(section, "flag", &_ico_ivi_option_flag, 0); + weston_config_section_get_int(section, "log", &_ico_ivi_debug_level, 3); + } + + /* get display number */ + section = weston_config_get_section(ec->config, "ivi-display", NULL, NULL); + if (section) { + weston_config_section_get_string(section, "displayno", &displayno, NULL); + weston_config_section_get_int(section, "inputpanel", + &_ico_ivi_inputpanel_display, 0); + } + + /* get layer id */ + section = weston_config_get_section(ec->config, "ivi-layer", NULL, NULL); + if (section) { + weston_config_section_get_int(section, "default", &_ico_ivi_default_layer, 1); + weston_config_section_get_int(section, "background", &_ico_ivi_background_layer, 0); + weston_config_section_get_int(section, "touch", &_ico_ivi_touch_layer, 101); + weston_config_section_get_int(section, "cursor", &_ico_ivi_cursor_layer, 102); + weston_config_section_get_int(section, "startup", &_ico_ivi_startup_layer, 103); + weston_config_section_get_string(section, "inputpaneldeco", &wrkstrp, NULL); + if (wrkstrp) { + p = strtok(wrkstrp, ";,"); + if (p) { + _ico_ivi_inputdeco_mag = strtol(p, (char **)0, 0); + p = strtok(NULL, ";,"); + if (p) { + _ico_ivi_inputdeco_diff = strtol(p, (char **)0, 0); + } + } + free(wrkstrp); + } + } + if (_ico_ivi_inputdeco_mag < 20) _ico_ivi_inputdeco_mag = 100; + + /* get animation default */ + section = weston_config_get_section(ec->config, "ivi-animation", NULL, NULL); + if (section) { + weston_config_section_get_string(section, "default", &_ico_ivi_animation_name, NULL); + weston_config_section_get_string(section, "inputpanel", + &_ico_ivi_inputpanel_animation, NULL); + weston_config_section_get_int(section, "time", &_ico_ivi_animation_time, 500); + weston_config_section_get_int(section, "fps", &_ico_ivi_animation_fps, 30); + if (_ico_ivi_animation_name) { + p = strtok(_ico_ivi_animation_name, ";,"); + if (p) { + p = strtok(NULL, ";."); + if (p) { + _ico_ivi_animation_time = strtol(p, (char **)0, 0); + p = strtok(NULL, ";."); + if (p) { + _ico_ivi_animation_fps = strtol(p, (char **)0, 0); + } + } + } + } + if (_ico_ivi_inputpanel_animation) { + p = strtok(_ico_ivi_inputpanel_animation, ";,"); + if (p) { + p = strtok(NULL, ",;"); + if (p) { + _ico_ivi_inputpanel_anima_time = strtol(p, (char **)0, 0); + } + } + } + } + if (_ico_ivi_animation_name == NULL) + _ico_ivi_animation_name = (char *)"fade"; + if (_ico_ivi_inputpanel_animation == NULL) + _ico_ivi_inputpanel_animation = (char *)"fade"; + if (_ico_ivi_animation_time < 100) _ico_ivi_animation_time = 500; + if (_ico_ivi_animation_fps < 3) _ico_ivi_animation_fps = 30; + if (_ico_ivi_inputpanel_anima_time < 100) + _ico_ivi_inputpanel_anima_time = _ico_ivi_animation_time; + + /* create ico_window_mgr management table */ + _ico_win_mgr = (struct ico_win_mgr *)malloc(sizeof(struct ico_win_mgr)); + if (_ico_win_mgr == NULL) { + uifw_error("ico_window_mgr: malloc failed"); + return -1; + } + + memset(_ico_win_mgr, 0, sizeof(struct ico_win_mgr)); + _ico_win_mgr->surfaceid_map = (uint16_t *) malloc(INIT_SURFACE_IDS/8); + if (! _ico_win_mgr->surfaceid_map) { + uifw_error("ico_window_mgr: malloc failed"); + return -1; + } + memset(_ico_win_mgr->surfaceid_map, 0, INIT_SURFACE_IDS/8); + + _ico_win_mgr->compositor = ec; + + _ico_win_mgr->surfaceid_max = INIT_SURFACE_IDS; + _ico_win_mgr->surfaceid_count = INIT_SURFACE_IDS; + + uifw_trace("ico_window_mgr: wl_global_create(bind_ico_win_mgr)"); + if (wl_global_create(ec->wl_display, &ico_window_mgr_interface, 1, + _ico_win_mgr, bind_ico_win_mgr) == NULL) { + uifw_error("ico_window_mgr: Error(wl_global_create)"); + return -1; + } + + wl_list_init(&_ico_win_mgr->client_list); + wl_list_init(&_ico_win_mgr->manager_list); + wl_list_init(&_ico_win_mgr->ivi_layer_list); + wl_list_init(&_ico_win_mgr->map_list); + + _ico_win_mgr->free_maptable = NULL; + + /* create display list */ + if (displayno != NULL) { + p = displayno; + } + else { + p = NULL; + } + _ico_num_nodes = 0; + wl_list_for_each (output, &ec->output_list, link) { + wl_list_init(&_ico_win_mgr->map_animation[_ico_num_nodes].link); + _ico_win_mgr->map_animation[_ico_num_nodes].frame = win_mgr_check_mapsurrace; + wl_list_insert(output->animation_list.prev, + &_ico_win_mgr->map_animation[_ico_num_nodes].link); + _ico_num_nodes++; + if (_ico_num_nodes >= ICO_IVI_MAX_DISPLAY) break; + } + memset(&_ico_node_table[0], 0, sizeof(_ico_node_table)); + i = 0; + wl_list_for_each (output, &ec->output_list, link) { + p = strtok(p, ","); + if (p) { + idx = strtol(p, (char **)0, 0); + uifw_trace("ico_window_mgr: config Display.%d is weston display.%d", i, idx); + p = NULL; + if ((idx < 0) || (idx >= _ico_num_nodes)) { + idx = i; + } + } + else { + idx = i; + } + if (_ico_node_table[idx].node) { + for (idx = 0; idx < _ico_num_nodes; idx++) { + if (_ico_node_table[idx].node == 0) break; + } + if (idx >= _ico_num_nodes) { + uifw_error("ico_window_mgr: number of display overflow"); + idx = 0; + } + } + _ico_node_table[idx].node = idx + 0x100; + _ico_node_table[idx].displayno = i; + _ico_node_table[idx].output = output; + _ico_node_table[idx].disp_x = output->x; + _ico_node_table[idx].disp_y = output->y; + _ico_node_table[idx].disp_width = output->width; + _ico_node_table[idx].disp_height = output->height; + i ++; + if (i >= _ico_num_nodes) break; + } + idx = 0; + for (i = 0; i < _ico_num_nodes; i++) { + _ico_node_table[i].node &= 0x0ff; + uifw_info("ico_window_mgr: Display.%d no=%d x/y=%d/%d w/h=%d/%d", + i, _ico_node_table[i].displayno, + _ico_node_table[i].disp_x, _ico_node_table[i].disp_y, + _ico_node_table[i].disp_width, _ico_node_table[i].disp_height); + } + if (displayno) free(displayno); + + if (_ico_ivi_inputpanel_display >= _ico_num_nodes) { + _ico_ivi_inputpanel_display = 0; + } + uifw_info("ico_window_mgr: inputpanel_display=%d", _ico_ivi_inputpanel_display); + + /* set default display to ico_ivi_shell */ + ivi_shell_set_default_display(_ico_node_table[_ico_ivi_inputpanel_display].output); + + /* my node Id ... this version fixed 0 */ + nodeId = ico_ivi_get_mynode(); + + _ico_win_mgr->surface_head = ICO_IVI_SURFACEID_BASE(nodeId); + uifw_trace("ico_window_mgr: NoedId=%04x SurfaceIdBase=%08x", + nodeId, _ico_win_mgr->surface_head); + + /* get seat for touch down counter check */ + touch_check_seat = container_of(ec->seat_list.next, struct weston_seat, link); + _ico_win_mgr->waittime = 1000; + loop = wl_display_get_event_loop(ec->wl_display); + _ico_win_mgr->wait_mapevent = + wl_event_loop_add_timer(loop, win_mgr_timer_mapsurrace, NULL); + wl_event_source_timer_update(_ico_win_mgr->wait_mapevent, 1000); + + /* Hook to IVI-Shell */ + ico_ivi_shell_hook_bind(win_mgr_bind_client); + ico_ivi_shell_hook_unbind(win_mgr_unbind_client); + ico_ivi_shell_hook_create(win_mgr_register_surface); + ico_ivi_shell_hook_destroy(win_mgr_destroy_surface); + ico_ivi_shell_hook_map(win_mgr_map_surface); + ico_ivi_shell_hook_configure(win_mgr_shell_configure); + ico_ivi_shell_hook_select(win_mgr_select_surface); + ico_ivi_shell_hook_title(win_mgr_set_title); + ico_ivi_shell_hook_move(win_mgr_surface_move); + ico_ivi_shell_hook_show_layer(win_mgr_show_layer); + ico_ivi_shell_hook_fullscreen(win_mgr_fullscreen); + + uifw_info("ico_window_mgr: animation name=%s/%s time=%d/%d fps=%d", + _ico_ivi_animation_name, _ico_ivi_inputpanel_animation, + _ico_ivi_animation_time, _ico_ivi_inputpanel_anima_time, + _ico_ivi_animation_fps); + uifw_info("ico_window_mgr: input panel mag=%d%% diff=%d", + _ico_ivi_inputdeco_mag,_ico_ivi_inputdeco_diff); + uifw_info("ico_window_mgr: layer default=%d background=%d", + _ico_ivi_default_layer, _ico_ivi_background_layer); + uifw_info("ico_window_mgr: layer touch=%d cursor=%d startup=%d", + _ico_ivi_touch_layer, _ico_ivi_cursor_layer, _ico_ivi_startup_layer); + uifw_info("ico_window_mgr: option flag=0x%04x log level=%d debug flag=0x%04x", + _ico_ivi_option_flag, _ico_ivi_debug_level & 0x0ffff, + (_ico_ivi_debug_level >> 16) & 0x0ffff); + + /* get GPU type for H/W support of the thumbnail acquisition */ + if (ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_NODEPEND) { + /* can not use GPU H/W dependent acceleration */ + _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; + uifw_info("ico_window_mgr: GPU type=No Acceleration by option flag"); + } + else if (ico_ivi_optionflag() & ICO_IVI_OPTION_GPU_DEPENDINTEL) { + /* use Intel GPU H/W dependent acceleration */ + _ico_ivi_gpu_type = ICO_GPUTYPE_INTEL_SANDYBRIDGE; + uifw_info("ico_window_mgr: GPU type=Acceleration Intel GPU by option flag"); + } + else { + _ico_ivi_gpu_type = ICO_GPUTYPE_NOACCELERATION; + + p = (char *)glGetString(GL_RENDERER); + if (p) { + uifw_info("ico_window_mgr: Renderer=<%s>", p); + for (i = 0; ico_window_mgr_gpu_type[i].gpu_type; i++) { + if (strncmp(p, ico_window_mgr_gpu_type[i].gpu_name, + strlen(ico_window_mgr_gpu_type[i].gpu_name)) == 0) { + _ico_ivi_gpu_type = ico_window_mgr_gpu_type[i].gpu_type; + uifw_info("ico_window_mgr: GPU type=Acceleration %d", _ico_ivi_gpu_type); + break; + } + } + } + if (_ico_ivi_gpu_type == ICO_GPUTYPE_NOACCELERATION) { + uifw_info("ico_window_mgr: GPU type=No Acceleration(can not find GPU)"); + } + } +#if PIXEL_SPEED_TEST > 0 + speed_buffer = malloc(1920*1080*4); +#endif + + uifw_info("ico_window_mgr: Leave(module_init)"); + + return 0; +} diff --git a/tests/weston-plugin-test b/tests/weston-plugin-test index 97e21b7..c053efb 100755 --- a/tests/weston-plugin-test +++ b/tests/weston-plugin-test @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.anima b/tests/weston-plugin-test.anima index f88ef14..c18b089 100755 --- a/tests/weston-plugin-test.anima +++ b/tests/weston-plugin-test.anima @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.input b/tests/weston-plugin-test.input index 2a56604..d3dbd89 100755 --- a/tests/weston-plugin-test.input +++ b/tests/weston-plugin-test.input @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.map b/tests/weston-plugin-test.map index e86c5d7..2124ae9 100755 --- a/tests/weston-plugin-test.map +++ b/tests/weston-plugin-test.map @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -49,7 +50,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.region b/tests/weston-plugin-test.region index 59ef8d6..05d9806 100755 --- a/tests/weston-plugin-test.region +++ b/tests/weston-plugin-test.region @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.resize b/tests/weston-plugin-test.resize index 4bbb1ce..2018120 100755 --- a/tests/weston-plugin-test.resize +++ b/tests/weston-plugin-test.resize @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston-plugin-test.send_input b/tests/weston-plugin-test.send_input index 28e5afa..1e781d9 100755 --- a/tests/weston-plugin-test.send_input +++ b/tests/weston-plugin-test.send_input @@ -17,8 +17,9 @@ export WESTON_IVI_PLUGIN_DIR="../src/.libs" # 4 Start Weston export XDG_CONFIG_HOME="../tests" +export XDG_RUNTIME_DIR="/run/user/5000" MOD_DIR="$PWD/../src/.libs" -/usr/bin/weston --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & +/usr/bin/weston --tty=2 --modules=$MOD_DIR/ico_plugin_loader.so --idle-time=0 $WESTON_BACKEND --log=../tests/testlog/weston.log & sleep 1 # 5 Set library path @@ -47,7 +48,7 @@ fi if [ "$?" != "1" ] ; then FOUND_ERR=1 fi -/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" +/bin/grep "error" testlog/* | /bin/grep -v "error_but_no_problem_for_test" | /bin/grep -v "failed to restore kb mode:" | /bin/grep -v "failed to set KD_TEXT mode on tty:" if [ "$?" != "1" ] ; then FOUND_ERR=1 fi diff --git a/tests/weston.ini b/tests/weston.ini index 664d600..ab0f4eb 100644 --- a/tests/weston.ini +++ b/tests/weston.ini @@ -1,13 +1,18 @@ [core] +shell= modules=error_but_no_problem_for_test.so # This is Error for Test(No Problem) [shell] num-workspaces=1 shell-exe= +locking=false +animation=zoom +startup-animation=fade [input-method] -path=/bin/weekeyboard +#path=/bin/weekeyboard +path= #[output] #name=HDMI1 @@ -52,12 +57,15 @@ inputpanel=fade;200 [ivi-option] # option flags -# bit.0 1=show surface at screen create if HomeScreen exist/0=not show surface at create -# bit.1 1=1=show if display not exist/0=not show if display not exist -# bit.2 1=show input panel automatically/0=not show automaticaly -# bit.8 1=surface fixed aspect rate/0=not fixed aspect rate -flag=0x0006 - -# debug log output level -# 0=no debug log write(1=err/2=warn/3=info/4=trace/5=debug) -log=5 +# 0x0001 1=show surface at screen create if HomeScreen exist/0=not show surface at create +# 0x0002 1=1=show if display not exist/0=not show if display not exist +# 0x0004 1=show input panel automatically/0=not show automaticaly +# 0x0080 1=surface fixed aspect rate/0=not fixed aspect rate +# 0x8000 1=no use GPU dependent acceleration +# 0x1000 1=force use Intel Sandybridge Mobile GPU dependent acceleration +flag=0x0004 + +# debug log output level and debug flag +# lower 16 bit: log level(0=no/1=err/2=warn/3=info/4=trace/5=debug) +# upper 16 bit: debug flag(0x00010000: performance log) +log=0x00010005 |