2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief user experiance library(initialize/terminate/event)
21 #include <sys/ioctl.h>
25 #include "wayland-client.h"
26 #include "ico_window_mgr-client-protocol.h"
28 #include "ico_uxf_conf.h"
29 #include "ico_uxf_private.h"
31 /* static functions */
32 /* wayland standard callback functions */
33 static void ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
34 uint32_t name, const char *interface,
36 static void ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output,
37 int32_t x, int32_t y, int32_t physical_width,
38 int32_t physical_height, int32_t subpixel,
39 const char *make, const char *model,
41 static void ico_uxf_output_modecb(void *data, struct wl_output *wl_output,
42 uint32_t flags, int32_t width, int32_t height,
44 static void ico_uxf_create_window(uint32_t surfaceid, const char *appid, uint32_t node,
45 uint32_t layer, int32_t x, int32_t y,
46 int32_t width, int32_t height);
48 /* ico_window_mgr(Multi Window Manager) callback functions */
50 static void ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
51 uint32_t surfaceid, const char *winname, int32_t pid,
53 static void ico_uxf_window_namecb(void *data, struct ico_window_mgr *ico_window_mgr,
54 uint32_t surfaceid, const char *winname);
55 static void ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
57 static void ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
58 uint32_t surfaceid, int32_t visible, int32_t raise,
60 static void ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
61 uint32_t surfaceid, uint32_t node,
62 uint32_t layer, int32_t x, int32_t y,
63 int32_t width, int32_t height, int32_t hint);
64 static void ico_uxf_window_activecb(void *data, struct ico_window_mgr *ico_window_mgr,
65 uint32_t surfaceid, int32_t active);
66 static void ico_uxf_window_layer_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
67 uint32_t layer, int32_t visible);
68 static void ico_uxf_window_surfacecb(void *data, struct ico_window_mgr *ico_window_mgr,
69 const char *appid, struct wl_array *surfaces);
70 static void ico_uxf_window_mapcb(void *data, struct ico_window_mgr *ico_window_mgr,
71 int32_t event, uint32_t surfaceid, int32_t width,
72 int32_t height, int32_t stride, int32_t format);
74 /* ico_input_mgr(Multi Input Manager) callback functions */
75 static void ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
76 const char *device, int32_t type,
77 const char *swname, int32_t input,
78 const char *codename, int32_t code);
79 static void ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput,
80 const char *device, int32_t input, const char *codename,
82 static void ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput,
83 uint32_t time, const char *device, int32_t input,
84 int32_t code, int32_t state);
86 /* AppCore(AUL) callback function */
87 static int ico_uxf_aul_aulcb(int pid, void *data);
89 /* Variables & Tables */
90 Ico_Uxf_Api_Mng gIco_Uxf_Api_Mng = { 0 };
92 static pthread_mutex_t sMutex;
94 /* Wayland Registry Listener */
95 static const struct wl_registry_listener ico_uxf_registry_listener = {
96 ico_uxf_wayland_globalcb
99 /* Window Manger Interface */
100 static const struct ico_window_mgr_listener windowlistener = {
101 ico_uxf_window_createdcb,
102 ico_uxf_window_namecb,
103 ico_uxf_window_destroyedcb,
104 ico_uxf_window_visiblecb,
105 ico_uxf_window_configurecb,
106 ico_uxf_window_activecb,
107 ico_uxf_window_layer_visiblecb,
108 ico_uxf_window_surfacecb,
112 /* Input Manger Interface */
113 static const struct ico_exinput_listener exinputlistener = {
114 ico_uxf_input_capabilitiescb,
115 ico_uxf_input_codecb,
116 ico_uxf_input_inputcb
119 /* Wayland Output interface */
120 static const struct wl_output_listener outputlistener = {
121 ico_uxf_output_geometrycb,
122 ico_uxf_output_modecb
126 /*--------------------------------------------------------------------------*/
128 * @brief ico_uxf_init: initialize user interface library hor HomeScreen
130 * @param[in] name application id
132 * @retval ICO_UXF_EOK success
133 * @retval ICO_UXF_EBUSY error(cullentry terminating)
134 * @retval ICO_UXF_ESRCH error(configuration error)
135 * @retval ICO_UXF_ENOSYS error(system error)
137 /*--------------------------------------------------------------------------*/
139 ico_uxf_init(const char *name)
141 Ico_Uxf_Mng_Display *dsp;
142 Ico_Uxf_Mng_Layer *lay;
143 Ico_Uxf_Mng_Process *prc;
144 pthread_mutexattr_t sMutexAttr;
145 Ico_Uxf_Sys_Config *sysconf;
146 Ico_Uxf_App_Config *appconf;
147 Ico_Uxf_conf_appdisplay *appdsp;
148 Ico_Uxf_Mng_Callback *freecb;
149 Ico_Uxf_Mng_EventQue *freeeq;
153 ico_uxf_log_open(name);
155 if (gIco_Uxf_Api_Mng.Initialized) {
156 if (gIco_Uxf_Api_Mng.Initialized < 0) {
157 uifw_trace("ico_uxf_init: Enter");
158 uifw_warn("ico_uxf_init: Leave(EBUSY)");
159 return ICO_UXF_EBUSY;
161 uifw_trace("ico_uxf_init: Enter");
162 uifw_trace("ico_uxf_init: Leave(EOK)");
165 uifw_trace("ico_uxf_init: Enter");
167 gIco_Uxf_Api_Mng.Initialized = -1;
168 memset(gIco_Uxf_Api_Mng.MyProcess, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
169 strncpy(gIco_Uxf_Api_Mng.MyProcess, name, ICO_UXF_MAX_PROCESS_NAME);
170 gIco_Uxf_Api_Mng.EventMask = 0;
171 gIco_Uxf_Api_Mng.WaylandFd = -1;
172 gIco_Uxf_Api_Mng.Wayland_Display = NULL;
173 gIco_Uxf_Api_Mng.InitTimer = ICO_UXF_SUSP_INITTIME;
174 gIco_Uxf_Api_Mng.Win_Show_Anima = 1;
175 gIco_Uxf_Api_Mng.Win_Hide_Anima = 1;
177 /* read configurations */
178 sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
179 appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
180 if ((sysconf == NULL) || (appconf == NULL)) {
181 uifw_error("ico_uxf_init: Leave(ESRCH), Configuration Read Error");
182 return ICO_UXF_ESRCH;
185 uifw_trace("ico_uxf_init: set display configurations");
186 /* set display configurations */
187 for (dn = 0; dn < sysconf->displayNum; dn++) {
188 dsp = ico_uxf_mng_display(sysconf->display[dn].id, 1);
189 dsp->attr.type = sysconf->display[dn].type;
190 dsp->attr.num_layers = sysconf->display[dn].layerNum;
191 dsp->attr.hostId = sysconf->display[dn].hostId;
192 dsp->attr.displayNo = sysconf->display[dn].displayno;
193 dsp->attr.w = sysconf->display[dn].width;
194 dsp->attr.h = sysconf->display[dn].height;
195 dsp->attr.pWidth = -1;
196 dsp->attr.pHeight = -1;
197 dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
198 dsp->attr.inch = sysconf->display[dn].inch;
199 strncpy(dsp->attr.name, sysconf->display[dn].name, ICO_UXF_MAX_WIN_NAME);
200 dsp->attr.name[ICO_UXF_MAX_WIN_NAME] = 0;
202 for (tn = 0; tn < sysconf->display[dn].layerNum; tn++) {
203 lay = ico_uxf_mng_layer(sysconf->display[dn].id,
204 sysconf->display[dn].layer[tn].id, 1);
205 lay->attr.display = sysconf->display[dn].id;
206 lay->attr.w = sysconf->display[dn].width;
207 lay->attr.h = sysconf->display[dn].height;
208 lay->attr.menuoverlap = sysconf->display[dn].layer[tn].menuoverlap;
209 lay->mng_display = dsp;
213 uifw_trace("ico_uxf_init: set application configurations(num=%d)",
214 appconf->applicationNum);
215 /* set application configurations */
216 for(dn = 0; dn < appconf->applicationNum; dn++) {
217 prc = ico_uxf_mng_process(appconf->application[dn].appid, 1);
218 prc->attr.internalid = 0;
219 prc->appconf = (void *)&appconf->application[dn];
220 prc->attr.status = ICO_UXF_PROCSTATUS_STOP;
221 prc->attr.type = appconf->application[dn].categoryId;
222 prc->attr.hostId = appconf->application[dn].hostId;
223 prc->attr.myHost = (prc->attr.hostId == sysconf->misc.myhostId) ? 1 : 0;
224 prc->attr.noicon = appconf->application[dn].noicon;
225 prc->attr.autostart = appconf->application[dn].autostart;
226 prc->attr.invisiblecpu = appconf->application[dn].invisiblecpu;
228 appdsp = &appconf->application[dn].display[0];
229 prc->attr.mainwin.window = 0;
230 prc->attr.mainwin.windowtype = appconf->application[dn].categoryId;
231 prc->attr.mainwin.display = appdsp->displayId;
232 prc->attr.mainwin.layer = appdsp->layerId;
233 prc->attr.mainwin.x =
234 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
235 prc->attr.mainwin.y =
236 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
237 prc->attr.mainwin.w =
238 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
239 prc->attr.mainwin.h =
240 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
241 prc->attr.mainwin.name[ICO_UXF_MAX_WIN_NAME] = 0;
242 prc->attr.numwindows = appconf->application[dn].displayzoneNum;
243 /* get sub windows */
244 if (prc->attr.numwindows > 1) {
245 prc->attr.subwin = malloc(sizeof(Ico_Uxf_ProcessWin) *
246 (prc->attr.numwindows - 1));
247 if (! prc->attr.subwin) {
248 uifw_error("ico_uxf_init: No Memory");
249 appconf->application[dn].displayzoneNum = 1;
250 prc->attr.numwindows = 1;
253 memset(prc->attr.subwin, 0, (prc->attr.numwindows - 1));
254 for (tn = 0; tn < (prc->attr.numwindows - 1); tn++) {
256 prc->attr.subwin[tn].windowtype = prc->attr.mainwin.windowtype;
257 prc->attr.subwin[tn].display = appdsp->displayId;
258 prc->attr.subwin[tn].layer = appdsp->layerId;
259 prc->attr.subwin[tn].x =
260 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
261 prc->attr.subwin[tn].y =
262 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
263 prc->attr.subwin[tn].w =
264 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
265 prc->attr.subwin[tn].h =
266 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
272 gIco_Uxf_Api_Mng.Mng_MyProcess
273 = ico_uxf_mng_process(gIco_Uxf_Api_Mng.MyProcess, 0);
274 if (!gIco_Uxf_Api_Mng.Mng_MyProcess) {
275 uifw_error("ico_uxf_init: Leave(ESRCH), Unknown Apprication(%s)",
276 gIco_Uxf_Api_Mng.MyProcess);
277 return ICO_UXF_ESRCH;
279 gIco_Uxf_Api_Mng.Mng_MyProcess->attr.internalid = getpid();
280 gIco_Uxf_Api_Mng.Mng_MyProcess->attr.status = ICO_UXF_PROCSTATUS_RUN;
282 dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
284 uifw_trace("ico_uxf_init: App.%s MainDisplay.%d %08x",
285 gIco_Uxf_Api_Mng.Mng_MyProcess->attr.process,
286 gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, dsp);
288 for (ret = 0; ret < (2000/50); ret++) {
289 gIco_Uxf_Api_Mng.Wayland_Display = wl_display_connect(NULL);
290 if (gIco_Uxf_Api_Mng.Wayland_Display) break;
293 if (! gIco_Uxf_Api_Mng.Wayland_Display) {
294 uifw_error("ico_uxf_init:Can not connect to wayland, Abort!!");
295 fprintf(stderr, "ico_uxf_init:Can not connect to wayland, Abort!!\n");
299 gIco_Uxf_Api_Mng.Wayland_Registry
300 = wl_display_get_registry(gIco_Uxf_Api_Mng.Wayland_Display);
301 wl_registry_add_listener(gIco_Uxf_Api_Mng.Wayland_Registry,
302 &ico_uxf_registry_listener, (void *)0);
304 for (ret = 0; ret < (500/20); ret++) {
305 if ((gIco_Uxf_Api_Mng.Wayland_WindowMgr != NULL) &&
306 (gIco_Uxf_Api_Mng.Wayland_exInput != NULL) &&
307 (gIco_Uxf_Api_Mng.Wayland_InputMgr != NULL)) break;
308 uifw_trace("ico_uxf_init: call wl_display_dispatch(%08x)",
309 (int)gIco_Uxf_Api_Mng.Wayland_Display);
310 wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
313 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
314 uifw_trace("ico_uxf_init: Wayland/Weston connect OK");
316 gIco_Uxf_Api_Mng.WaylandFd
317 = wl_display_get_fd(gIco_Uxf_Api_Mng.Wayland_Display);
319 /* initialize mutex */
320 (void) pthread_mutexattr_init(&sMutexAttr);
321 if (pthread_mutex_init(&sMutex, &sMutexAttr) != 0) {
322 uifw_error("ico_uxf_init: Leave(ENOSYS), Mutex Create Error %d", errno);
323 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
324 gIco_Uxf_Api_Mng.Wayland_Display = NULL;
325 gIco_Uxf_Api_Mng.Initialized = 0;
326 return ICO_UXF_ENOSYS;
329 /* allocate free control blocks */
330 freecb = ico_uxf_alloc_callback();
331 ico_uxf_free_callback(freecb);
332 freeeq = ico_uxf_alloc_eventque();
333 ico_uxf_free_eventque(freeeq);
335 /* flush wayland connection */
336 ico_window_mgr_declare_manager(gIco_Uxf_Api_Mng.Wayland_WindowMgr, 1);
337 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
339 /* application launch/dead callback from AppCore(aul) */
340 aul_listen_app_launch_signal(ico_uxf_aul_aulcb, (void *)0);
341 aul_listen_app_dead_signal(ico_uxf_aul_aulcb, (void *)1);
343 gIco_Uxf_Api_Mng.Initialized = 1;
345 uifw_trace("ico_uxf_init: Leave(EOK)");
351 /*--------------------------------------------------------------------------*/
353 * @brief ico_uxf_wl_display_fd: get wayland file discriptor
356 * @return wayland connect socket file descriptor
357 * @retval >=0 success(file descriptor)
358 * @retval < 0 error(wayland not connect)
360 /*--------------------------------------------------------------------------*/
362 ico_uxf_wl_display_fd(void)
364 uifw_trace("ico_uxf_wl_display_fd: fd=%d", gIco_Uxf_Api_Mng.WaylandFd);
366 return gIco_Uxf_Api_Mng.WaylandFd;
369 /*--------------------------------------------------------------------------*/
371 * @brief ico_uxf_shutdown: terminate user interface library hor HomeScreen
375 * @retval ICO_UXF_EOK success
376 * @retval ICO_UXF_EBUSY error(cullentry terminating)
378 /*--------------------------------------------------------------------------*/
380 ico_uxf_shutdown(void)
382 uifw_trace("ico_uxf_shutdown: Enter");
384 if (gIco_Uxf_Api_Mng.Initialized <= 0) {
385 if (gIco_Uxf_Api_Mng.Initialized < 0) {
386 uifw_warn("ico_uxf_shutdown: Leave(EBUSY)");
387 return ICO_UXF_EBUSY;
389 uifw_trace("ico_uxf_shutdown: Leave(EOK)");
392 gIco_Uxf_Api_Mng.Initialized = -1;
393 gIco_Uxf_Api_Mng.LastEvent = 0;
395 (void) pthread_mutex_destroy(&sMutex);
397 if (gIco_Uxf_Api_Mng.Wayland_Seat) {
398 wl_seat_destroy(gIco_Uxf_Api_Mng.Wayland_Seat);
399 gIco_Uxf_Api_Mng.Wayland_Seat = NULL;
401 if (gIco_Uxf_Api_Mng.Wayland_exInput) {
402 ico_exinput_destroy(gIco_Uxf_Api_Mng.Wayland_exInput);
403 gIco_Uxf_Api_Mng.Wayland_exInput = NULL;
405 if (gIco_Uxf_Api_Mng.Wayland_InputMgr) {
406 ico_input_mgr_control_destroy(gIco_Uxf_Api_Mng.Wayland_InputMgr);
407 gIco_Uxf_Api_Mng.Wayland_InputMgr = NULL;
409 if (gIco_Uxf_Api_Mng.Wayland_Compositor) {
410 wl_compositor_destroy(gIco_Uxf_Api_Mng.Wayland_Compositor);
411 gIco_Uxf_Api_Mng.Wayland_Compositor = NULL;
413 if (gIco_Uxf_Api_Mng.Wayland_Display) {
414 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
415 wl_display_disconnect(gIco_Uxf_Api_Mng.Wayland_Display);
416 gIco_Uxf_Api_Mng.Wayland_Display = NULL;
419 gIco_Uxf_Api_Mng.Initialized = 0;
421 uifw_trace("ico_uxf_shutdown: Leave(EOK)");
425 /*--------------------------------------------------------------------------*/
427 * @brief ico_uxf_main_loop_iterate: process user interface library events
432 /*--------------------------------------------------------------------------*/
434 ico_uxf_main_loop_iterate(void)
437 Ico_Uxf_Mng_EventQue *wkque;
438 Ico_Uxf_Mng_Callback *callback;
439 Ico_Uxf_Event_Cb func;
441 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
444 if (ioctl(gIco_Uxf_Api_Mng.WaylandFd, FIONREAD, &arg) < 0) {
445 uifw_warn("ico_uxf_main_loop_iterate: ioclt(FIONREAD,) Error %d", errno);
450 wl_display_dispatch(gIco_Uxf_Api_Mng.Wayland_Display);
453 ico_uxf_enter_critical();
456 while (gIco_Uxf_Api_Mng.EventQue) {
458 wkque = gIco_Uxf_Api_Mng.EventQue;
459 gIco_Uxf_Api_Mng.EventQue = gIco_Uxf_Api_Mng.EventQue->next;
461 gIco_Uxf_Api_Mng.LastEvent = wkque->detail.event;
462 callback = gIco_Uxf_Api_Mng.Callback;
464 if (callback->eventmask & gIco_Uxf_Api_Mng.LastEvent) {
465 func = callback->func;
467 ico_uxf_leave_critical();
469 uifw_trace("ico_uxf_main_loop: Call Event Callback(%08x,,%08x)",
470 gIco_Uxf_Api_Mng.LastEvent, arg);
471 (*func)(gIco_Uxf_Api_Mng.LastEvent, wkque->detail, arg);
473 ico_uxf_enter_critical();
475 callback = callback->next;
477 ico_uxf_free_eventque(wkque);
480 ico_uxf_leave_critical();
482 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
485 /*--------------------------------------------------------------------------*/
487 * @brief ico_uxf_callback_set: set event calback function
489 * @param[in] mask event mask
490 * @param[in] func callback function
491 * @param[in] arg user argument
493 * @retval ICO_UXF_EOK success
494 * @retval ICO_UXF_ESRCH error(user interface library not initialized)
495 * @retval ICO_UXF_EINVAL error(illegal event mask)
496 * @retval ICO_UXF_EBUSY error(already set same event)
498 /*--------------------------------------------------------------------------*/
500 ico_uxf_callback_set(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
502 Ico_Uxf_Mng_Callback *callback;
505 uifw_trace("ico_uxf_callback_set: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
507 if (gIco_Uxf_Api_Mng.Initialized <= 0) {
508 uifw_warn("ico_uxf_callback_set: Leave(ESRCH)");
509 return ICO_UXF_ESRCH;
516 wkmask = ICO_UXF_EVENT_ALL;
518 if ((wkmask & ICO_UXF_EVENT_VALIDALL) == 0) {
519 uifw_warn("ico_uxf_callback_set: Leave(EINVAL)");
520 return ICO_UXF_EINVAL;
523 ico_uxf_enter_critical();
525 callback = gIco_Uxf_Api_Mng.Callback;
527 if ((callback->eventmask == wkmask) && (callback->func == func) &&
528 (callback->arg == arg)) {
530 ico_uxf_leave_critical();
531 uifw_warn("ico_uxf_callback_set: Leave(EBUSY)");
532 return ICO_UXF_EBUSY;
536 callback = ico_uxf_alloc_callback();
538 callback->eventmask = wkmask;
539 callback->func = func;
542 ico_uxf_regist_callback(callback);
544 gIco_Uxf_Api_Mng.EventMask |= wkmask;
546 ico_uxf_leave_critical();
548 uifw_trace("ico_uxf_callback_set: Leave(EOK)");
552 /*--------------------------------------------------------------------------*/
554 * @brief ico_uxf_callback_remove: remove event calback function
556 * @param[in] mask event mask
557 * @param[in] func callback function
558 * @param[in] arg user argument
560 * @retval ICO_UXF_EOK success
561 * @retval ICO_UXF_ESRCH error(user interface library not initialized)
563 /*--------------------------------------------------------------------------*/
565 ico_uxf_callback_remove(const unsigned int mask, Ico_Uxf_Event_Cb func, const int arg)
567 Ico_Uxf_Mng_Callback *callback;
570 uifw_trace("ico_uxf_callback_remove: Enter(%08x,%08x,%08x)", mask, (int)func, arg);
572 if (gIco_Uxf_Api_Mng.Initialized <= 0) {
573 uifw_warn("ico_uxf_callback_remove: Leave(ESRCH)");
574 return ICO_UXF_ESRCH;
581 wkmask = ICO_UXF_EVENT_ALL;
584 ico_uxf_enter_critical();
586 gIco_Uxf_Api_Mng.EventMask = 0;
588 callback = gIco_Uxf_Api_Mng.Callback;
591 if ((callback->eventmask == wkmask) && (callback->func == func) &&
592 (callback->arg == arg)) {
593 ico_uxf_remove_callback(callback);
596 gIco_Uxf_Api_Mng.EventMask |= callback->eventmask;
598 callback = callback->next;
601 ico_uxf_leave_critical();
603 uifw_trace("ico_uxf_callback_remove: Leave(EOK)");
607 /*--------------------------------------------------------------------------*/
609 * @brief ico_uxf_free_procwin: free active window management table(internal function)
611 * @param[in] prc application management table address
614 /*--------------------------------------------------------------------------*/
616 ico_uxf_free_procwin(Ico_Uxf_Mng_Process *prc)
618 Ico_Uxf_Mng_Window *p;
619 Ico_Uxf_Mng_Window *pp;
620 Ico_Uxf_Mng_Window *freep;
623 uifw_trace("ico_uxf_free_procwin: Enter(%d)", prc->attr.process);
625 for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
626 p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
627 pp = (Ico_Uxf_Mng_Window *)0;
629 if (p->attr.process == prc->attr.process) {
633 gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
638 uifw_trace("ico_uxf_free_procwin: Free Window(%08x)", freep->attr.window);
647 uifw_trace("ico_uxf_free_procwin: Leave");
650 /*--------------------------------------------------------------------------*/
652 * @brief ico_uxf_wayland_globalcb: wayland global callback(static function)
654 * @param[in] data user data(unused)
655 * @param[in] registry wayland registry
656 * @param[in] name wayland display Id(unused)
657 * @param[in] interface wayland interface name
658 * @param[in] version wayland interface version number(unused)
661 /*--------------------------------------------------------------------------*/
663 ico_uxf_wayland_globalcb(void *data, struct wl_registry *registry,
664 uint32_t name, const char *interface, uint32_t version)
666 uifw_trace("ico_uxf_wayland_globalcb: Enter(Event=%s DispId=%08x)", interface, name);
668 if (strcmp(interface, "ico_window_mgr") == 0) {
669 gIco_Uxf_Api_Mng.Wayland_WindowMgr = (struct ico_window_mgr *)
670 wl_registry_bind(registry, name, &ico_window_mgr_interface, 1);
671 ico_window_mgr_add_listener(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
672 &windowlistener, NULL);
674 else if (strcmp(interface, "ico_exinput") == 0) {
676 gIco_Uxf_Api_Mng.Wayland_exInput = (struct ico_exinput *)
677 wl_registry_bind(registry, name, &ico_exinput_interface, 1);
678 ico_exinput_add_listener(gIco_Uxf_Api_Mng.Wayland_exInput, &exinputlistener, NULL);
680 else if (strcmp(interface, "ico_input_mgr_control") == 0) {
681 /* regist Multi Input Manager interface */
682 gIco_Uxf_Api_Mng.Wayland_InputMgr = (struct ico_input_mgr_control *)
683 wl_registry_bind(registry, name, &ico_input_mgr_control_interface, 1);
685 else if (strcmp(interface, "wl_output") == 0) {
686 /* regist wl_output listener to get display info */
687 gIco_Uxf_Api_Mng.Wayland_Output = (struct wl_output *)
688 wl_registry_bind(registry, name, &wl_output_interface, 1);
689 wl_output_add_listener(gIco_Uxf_Api_Mng.Wayland_Output, &outputlistener, NULL);
691 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
692 uifw_trace("ico_uxf_wayland_globalcb: Leave");
695 /*--------------------------------------------------------------------------*/
697 * @brief ico_uxf_output_geometrycb: wayland display attribute callback(static function)
699 * @param[in] data user data(unused)
700 * @param[in] wl_output wayland wl_output interface
701 * @param[in] x display upper-left X coodinate
702 * @param[in] y display upper-left Y coodinate
703 * @param[in] physical_width display physical width
704 * @param[in] physical_height display physical height
705 * @param[in] subpixel display sub pixcel
706 * @param[in] make display maker
707 * @param[in] model diaplay model
708 * @param[in] transform transform
711 /*--------------------------------------------------------------------------*/
713 ico_uxf_output_geometrycb(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
714 int32_t physical_width, int32_t physical_height, int32_t subpixel,
715 const char *make, const char *model, int32_t transform)
717 Ico_Uxf_Mng_Display *dsp;
719 uifw_trace("ico_uxf_output_geometrycb: Enter(x/y=%d/%d, pwidth/height=%d/%d, trans=%d)",
720 x, y, physical_width, physical_height, transform);
722 dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
725 if ((transform == WL_OUTPUT_TRANSFORM_90)
726 || (transform == WL_OUTPUT_TRANSFORM_270)
727 || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_90)
728 || (transform == WL_OUTPUT_TRANSFORM_FLIPPED_270)) {
729 dsp->attr.pWidth = physical_height;
730 dsp->attr.pHeight = physical_width;
731 dsp->attr.orientation = ICO_UXF_ORIENTATION_VERTICAL;
734 dsp->attr.pWidth = physical_width;
735 dsp->attr.pHeight = physical_height;
736 dsp->attr.orientation = ICO_UXF_ORIENTATION_HORIZONTAL;
739 uifw_trace("ico_uxf_output_geometrycb: Leave");
742 /*--------------------------------------------------------------------------*/
744 * @brief ico_uxf_output_modecb: wayland display mode callback(static function)
746 * @param[in] data user data(unused)
747 * @param[in] wl_output wayland wl_output interface
748 * @param[in] flags flags
749 * @param[in] width display width
750 * @param[in] height display height
751 * @param[in] refresh display refresh rate
754 /*--------------------------------------------------------------------------*/
756 ico_uxf_output_modecb(void *data, struct wl_output *wl_output, uint32_t flags,
757 int32_t width, int32_t height, int32_t refresh)
759 Ico_Uxf_Mng_Display *dsp;
761 uifw_trace("ico_uxf_output_modecb: Enter(flg=%d, width=%d, height=%d, ref=%d)",
762 flags, width, height, refresh);
764 dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
766 if (dsp && (flags & WL_OUTPUT_MODE_CURRENT)) {
767 if (dsp->attr.orientation == ICO_UXF_ORIENTATION_VERTICAL) {
768 dsp->attr.pWidth = height;
769 dsp->attr.pHeight = width;
772 dsp->attr.pWidth = width;
773 dsp->attr.pHeight = height;
776 uifw_trace("ico_uxf_output_modecb: Leave");
779 /*--------------------------------------------------------------------------*/
781 * @brief ico_uxf_create_window: Create/Set Window management table(static function)
783 * @param[in] surfaceid ico_window_mgr surface Id
784 * @param[in] appid client application Id
785 * @param[in] node surface node Id
786 * @param[in] layer surface layer
787 * @param[in] x surface upper-left X coodinate
788 * @param[in] y surface upper-left Y coodinate
789 * @param[in] width surface width
790 * @param[in] height surface height
793 /*--------------------------------------------------------------------------*/
795 ico_uxf_create_window(uint32_t surfaceid, const char *appid, uint32_t node, uint32_t layer,
796 int32_t x, int32_t y, int32_t width, int32_t height)
798 Ico_Uxf_Mng_Window *win;
799 Ico_Uxf_Mng_EventQue *que;
801 Ico_Uxf_Mng_Process *prc;
803 ico_uxf_enter_critical();
805 win = ico_uxf_mng_window(surfaceid, 0);
808 win = ico_uxf_mng_window(surfaceid, 1);
809 win->attr.eventmask = ICO_UXF_EVENT_NEWWINDOW;
811 display = ICO_UXF_SURFACEID_2_NODEID(surfaceid);
812 win->mng_display = ico_uxf_mng_display(display, 0);
813 win->mng_layer = ico_uxf_mng_layer(display, layer, 0);
814 win->attr.display = display;
815 win->attr.layer = layer;
816 memset(win->attr.process, 0, ICO_UXF_MAX_PROCESS_NAME + 1);
817 strncpy(win->attr.process, appid, ICO_UXF_MAX_PROCESS_NAME);
818 win->attr.node = node;
822 win->attr.h = height;
824 prc = ico_uxf_mng_process(appid, 0);
825 win->mng_process = prc;
826 if ((prc != NULL) && (prc->attr.mainwin.window != (int)surfaceid)) {
828 win->attr.subwindow = 1;
831 if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_NEWWINDOW) {
833 que = ico_uxf_alloc_eventque();
835 que->detail.event = ICO_UXF_EVENT_NEWWINDOW;
836 que->detail.window.display = display;
837 que->detail.window.window = surfaceid;
838 que->detail.window.layer = layer;
839 que->detail.window.x = win->attr.x;
840 que->detail.window.y = win->attr.y;
841 que->detail.window.w = win->attr.w;
842 que->detail.window.h = win->attr.h;
843 que->detail.window.visible = win->attr.visible;
844 que->detail.window.raise = win->attr.raise;
845 que->detail.window.active = win->attr.active;
847 ico_uxf_regist_eventque(que);
849 ico_uxf_leave_critical();
852 /*--------------------------------------------------------------------------*/
854 * @brief ico_uxf_window_createdcb: wayland surface create callback(static function)
856 * @param[in] data user data(unused)
857 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
858 * @param[in] surfaceid ico_window_mgr surface Id
859 * @param[in] winname surface window name(title)
860 * @param[in] pid wayland client process Id
861 * @param[in] appid wayland client application Id
864 /*--------------------------------------------------------------------------*/
866 ico_uxf_window_createdcb(void *data, struct ico_window_mgr *ico_window_mgr,
867 uint32_t surfaceid, const char *winname, int32_t pid,
870 Ico_Uxf_Mng_Process *prc;
871 Ico_Uxf_Mng_ProcWin *ppwin;
872 Ico_Uxf_Mng_ProcWin *ppw;
874 uifw_trace("ico_uxf_window_createdcb: Enter(surf=%08x name=%s pid=%d appid=%s myapp=%s)",
875 (int)surfaceid, winname, pid, appid, gIco_Uxf_Api_Mng.MyProcess);
877 prc = ico_uxf_mng_process(appid, 0);
879 /* set window animation */
880 if (prc->appconf != NULL) {
881 if (((Ico_Uxf_conf_application *)prc->appconf)->animation) {
882 ico_window_mgr_set_animation(
883 gIco_Uxf_Api_Mng.Wayland_WindowMgr, surfaceid,
884 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE|ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW|
885 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
886 ((Ico_Uxf_conf_application *)prc->appconf)->animation,
887 ((Ico_Uxf_conf_application *)prc->appconf)->animation_time);
889 else if (((Ico_Uxf_conf_application *)prc->appconf)->animation_time > 0) {
890 ico_window_mgr_set_animation(
891 gIco_Uxf_Api_Mng.Wayland_WindowMgr, surfaceid,
892 ICO_WINDOW_MGR_ANIMATION_TYPE_HIDE|ICO_WINDOW_MGR_ANIMATION_TYPE_SHOW|
893 ICO_WINDOW_MGR_ANIMATION_TYPE_MOVE,
894 " ", ((Ico_Uxf_conf_application *)prc->appconf)->animation_time);
897 if (prc->attr.mainwin.window <= 0) {
898 uifw_trace("ico_uxf_window_createdcb: Set Main Window, Config Data");
899 prc->attr.mainwin.window = surfaceid;
900 ico_uxf_create_window(surfaceid, appid, prc->attr.mainwin.node,
901 prc->attr.mainwin.layer, prc->attr.mainwin.x,
902 prc->attr.mainwin.y, prc->attr.mainwin.w,
903 prc->attr.mainwin.h);
904 if (gIco_Uxf_Api_Mng.Hook_Window) {
905 (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
906 ICO_UXF_HOOK_WINDOW_CREATE_MAIN);
910 uifw_trace("ico_uxf_window_createdcb: Sub Window, Dummy Data");
911 ico_uxf_create_window(surfaceid, appid, prc->attr.mainwin.node,
912 prc->attr.mainwin.layer, ICO_UXF_MAX_COORDINATE,
913 ICO_UXF_MAX_COORDINATE, 1, 1);
914 ppwin = (Ico_Uxf_Mng_ProcWin *)malloc(sizeof(Ico_Uxf_Mng_ProcWin));
916 memset(ppwin, 0, sizeof(Ico_Uxf_Mng_ProcWin));
917 ppwin->attr.window = surfaceid;
918 ppwin->attr.display = prc->attr.mainwin.display;
920 prc->procwin = ppwin;
930 if (gIco_Uxf_Api_Mng.Hook_Window) {
931 (*gIco_Uxf_Api_Mng.Hook_Window)(prc->attr.process, surfaceid,
932 ICO_UXF_HOOK_WINDOW_CREATE_SUB);
937 uifw_warn("ico_uxf_window_createdcb: Application.%s dose not exist", appid);
939 uifw_trace("ico_uxf_window_createdcb: Leave");
942 /*--------------------------------------------------------------------------*/
944 * @brief ico_uxf_window_namecb: wayland change surface name callback(static function)
946 * @param[in] data user data(unused)
947 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
948 * @param[in] surfaceid ico_window_mgr surface Id
949 * @param[in] winname surface window name(title)
952 /*--------------------------------------------------------------------------*/
954 ico_uxf_window_namecb(void *data, struct ico_window_mgr *ico_window_mgr,
955 uint32_t surfaceid, const char *winname)
957 uifw_trace("ico_uxf_window_namecb: surf=%08x name=%s, NOP", (int)surfaceid, winname);
960 /*--------------------------------------------------------------------------*/
962 * @brief ico_uxf_window_destroyedcb: wayland surface destroy callback(static function)
964 * @param[in] data user data(unused)
965 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
966 * @param[in] surfaceid ico_window_mgr surface Id
969 /*--------------------------------------------------------------------------*/
971 ico_uxf_window_destroyedcb(void *data, struct ico_window_mgr *ico_window_mgr,
974 Ico_Uxf_Mng_Window *p;
975 Ico_Uxf_Mng_Window *pp;
976 Ico_Uxf_Mng_Window *freep;
977 Ico_Uxf_Mng_Process *prc;
978 Ico_Uxf_Mng_EventQue *que;
980 char wkappid[ICO_UXF_MAX_PROCESS_NAME+1];
983 uifw_trace("ico_uxf_window_destroyedcb: Enter(surf=%08x)", (int)surfaceid);
985 ico_uxf_enter_critical();
987 p = ico_uxf_mng_window(surfaceid, 0);
990 ico_uxf_leave_critical();
991 uifw_trace("ico_uxf_window_destroyedcb: Leave(Surface=%08x dose not exist)",
995 prc = p->mng_process;
996 if ((prc != NULL) && (prc->attr.mainwin.window == (int)surfaceid)) {
997 prc->attr.mainwin.window = 0;
1000 strcpy(wkappid, p->attr.process);
1001 wksubwindow = p->attr.subwindow;
1003 if ((gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_DESTORYWINDOW) &&
1004 (p->attr.eventmask & ICO_UXF_EVENT_DESTORYWINDOW)) {
1006 que = ico_uxf_alloc_eventque();
1007 que->detail.event = ICO_UXF_EVENT_DESTORYWINDOW;
1008 que->detail.window.display = p->attr.display;
1009 que->detail.window.window = surfaceid;
1010 que->detail.window.layer = p->attr.layer;
1011 que->detail.window.x = p->attr.x;
1012 que->detail.window.y = p->attr.y;
1013 que->detail.window.w = p->attr.w;
1014 que->detail.window.h = p->attr.h;
1015 que->detail.window.visible = p->attr.visible;
1016 que->detail.window.raise = p->attr.raise;
1017 que->detail.window.active = p->attr.active;
1018 ico_uxf_regist_eventque(que);
1021 for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
1022 p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
1023 pp = (Ico_Uxf_Mng_Window *)0;
1025 if (p->attr.window == (int)surfaceid) {
1029 gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
1034 uifw_trace("ico_uxf_window_destroyedcb: Free Window.%08x(%08x)",
1035 (int)freep, freep->attr.window);
1037 hash = ICO_UXF_MISC_HASHSIZE;
1044 ico_uxf_leave_critical();
1046 if (gIco_Uxf_Api_Mng.Hook_Window) {
1047 (*gIco_Uxf_Api_Mng.Hook_Window)(wkappid, surfaceid,
1048 wksubwindow ? ICO_UXF_HOOK_WINDOW_DESTORY_SUB :
1049 ICO_UXF_HOOK_WINDOW_DESTORY_MAIN);
1051 uifw_trace("ico_uxf_window_destroyedcb: Leave");
1054 /*--------------------------------------------------------------------------*/
1056 * @brief ico_uxf_window_visiblecb: wayland surface visible callback(static function)
1058 * @param[in] data user data(unused)
1059 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1060 * @param[in] surfaceid ico_window_mgr surface Id
1061 * @param[in] visible surface visible(1=visible/0=unvisible/other=nochange)
1062 * @param[in] raise surface raise(1=raise/0=lower/other=nochange)
1063 * @param[in] hint client request(1=client request(not changed)/0=changed)
1066 /*--------------------------------------------------------------------------*/
1068 ico_uxf_window_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
1069 uint32_t surfaceid, int32_t visible, int32_t raise, int32_t hint)
1071 Ico_Uxf_Mng_Window *win;
1072 Ico_Uxf_Mng_EventQue *que;
1076 ico_uxf_enter_critical();
1078 win = ico_uxf_mng_window(surfaceid, 0);
1081 ico_uxf_leave_critical();
1082 uifw_trace("ico_uxf_window_visiblecb: Surface=%08x dose not exist",
1089 if (ovisible == 9) {
1090 ovisible = win->attr.visible;
1093 oraise = win->attr.raise;
1096 if ((win->attr.visible != ovisible) ||
1097 (win->attr.raise != oraise)) {
1099 if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE) &&
1100 (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE)) ||
1101 ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_VISIBLE_REQ) &&
1102 (win->attr.eventmask & ICO_UXF_EVENT_VISIBLE_REQ))) {
1104 que = ico_uxf_alloc_eventque();
1106 (hint == 0) ? ICO_UXF_EVENT_VISIBLE : ICO_UXF_EVENT_VISIBLE_REQ;
1107 que->detail.window.display = win->attr.display;
1108 que->detail.window.window = win->attr.window;
1109 que->detail.window.layer = win->attr.layer;
1110 que->detail.window.x = win->attr.x;
1111 que->detail.window.y = win->attr.y;
1112 que->detail.window.w = win->attr.w;
1113 que->detail.window.h = win->attr.h;
1114 que->detail.window.visible = ovisible;
1115 que->detail.window.raise = oraise;
1116 que->detail.window.active = win->attr.active;
1118 ico_uxf_regist_eventque(que);
1121 ico_uxf_leave_critical();
1124 /*--------------------------------------------------------------------------*/
1126 * @brief ico_uxf_window_configurecb: wayland surface configure callback(static function)
1128 * @param[in] data user data(unused)
1129 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1130 * @param[in] surfaceid ico_window_mgr surface Id
1131 * @param[in] node surface node Id
1132 * @param[in] x surface upper-left X coodinate
1133 * @param[in] y surface upper-left Y coodinate
1134 * @param[in] width surface width
1135 * @param[in] height surface height
1136 * @param[in] hint client request(1=client request(not changed)/0=changed)
1139 /*--------------------------------------------------------------------------*/
1141 ico_uxf_window_configurecb(void *data, struct ico_window_mgr *ico_window_mgr,
1142 uint32_t surfaceid, uint32_t node,
1143 uint32_t layer, int32_t x, int32_t y,
1144 int32_t width, int32_t height, int32_t hint)
1146 Ico_Uxf_Mng_Window *win;
1147 Ico_Uxf_Mng_EventQue *que;
1149 #if 0 /* too many logout, change to comment out */
1150 uifw_trace("ico_uxf_window_configurecb: surf=%08x node=%x layer=%x "
1151 "x/y=%d/%d w/h=%d/%d hint=%d",
1152 (int)surfaceid, node, layer, x, y, width, height, hint);
1153 #endif /* too many logout, change to comment out */
1155 ico_uxf_enter_critical();
1157 win = ico_uxf_mng_window(surfaceid, 0);
1160 uifw_error("ico_uxf_window_configurecb: Unknown surface Id(%08x)", (int)surfaceid);
1163 if ((win->attr.layer != (int)layer) ||
1164 (win->attr.x != x) || (win->attr.y != y) ||
1165 (win->attr.w != width) || (win->attr.h != height)) {
1167 if (((hint == 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE) &&
1168 (win->attr.eventmask & ICO_UXF_EVENT_RESIZE)) ||
1169 ((hint != 0) && (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_RESIZE_REQ) &&
1170 (win->attr.eventmask & ICO_UXF_EVENT_RESIZE_REQ))) {
1172 que = ico_uxf_alloc_eventque();
1175 (hint == 0) ? ICO_UXF_EVENT_RESIZE : ICO_UXF_EVENT_RESIZE_REQ;
1176 que->detail.window.display = win->mng_display->attr.display;
1177 que->detail.window.window = win->attr.window;
1178 que->detail.window.layer = layer;
1179 que->detail.window.x = x;
1180 que->detail.window.y = y;
1181 que->detail.window.w = width;
1182 que->detail.window.h = height;
1183 que->detail.window.visible = win->attr.visible;
1184 que->detail.window.raise = win->attr.raise;
1185 que->detail.window.active = win->attr.active;
1187 ico_uxf_regist_eventque(que);
1192 win->attr.w = width;
1193 win->attr.h = height;
1194 if (win->attr.layer != (int)layer) {
1195 win->attr.layer = layer;
1196 win->mng_layer = ico_uxf_mng_layer(win->mng_display->attr.display,
1202 ico_uxf_leave_critical();
1205 /*--------------------------------------------------------------------------*/
1207 * @brief ico_uxf_window_activecb: wayland surface active callback(static function)
1209 * @param[in] data user data(unused)
1210 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1211 * @param[in] surfaceid ico_window_mgr surface Id
1212 * @param[in] active surface active(1=active/0=not active)
1215 /*--------------------------------------------------------------------------*/
1217 ico_uxf_window_activecb(void *data, struct ico_window_mgr *ico_window_mgr,
1218 uint32_t surfaceid, int32_t active)
1220 Ico_Uxf_Mng_Window *win;
1221 Ico_Uxf_Mng_EventQue *que;
1223 uifw_trace("ico_uxf_window_activecb: Enter(surf=%08x active=%d)", surfaceid, active);
1225 ico_uxf_enter_critical();
1227 win = ico_uxf_mng_window(surfaceid, 0);
1230 if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_ACTIVEWINDOW) {
1232 que = ico_uxf_alloc_eventque();
1234 que->detail.event = ICO_UXF_EVENT_ACTIVEWINDOW;
1235 que->detail.window.display = ICO_UXF_SURFACEID_2_NODEID(surfaceid);
1236 que->detail.window.window = surfaceid;
1237 if (active == ICO_WINDOW_MGR_ACTIVE_SELECTED) {
1238 que->detail.window.active = ICO_UXF_WINDOW_SELECT;
1239 win->attr.active = ICO_UXF_WINDOW_POINTER_ACTIVE |
1240 ICO_UXF_WINDOW_KEYBOARD_ACTIVE;
1243 que->detail.window.active = 0;
1244 if (active & ICO_WINDOW_MGR_ACTIVE_POINTER) {
1245 que->detail.window.active |= ICO_UXF_WINDOW_POINTER_ACTIVE;
1247 if (active & ICO_WINDOW_MGR_ACTIVE_KEYBOARD) {
1248 que->detail.window.active |= ICO_UXF_WINDOW_KEYBOARD_ACTIVE;
1250 win->attr.active = que->detail.window.active;
1252 ico_uxf_regist_eventque(que);
1255 ico_uxf_leave_critical();
1256 uifw_trace("ico_uxf_window_activecb: Leave");
1259 /*--------------------------------------------------------------------------*/
1261 * @brief ico_uxf_window_layer_visiblecb: wayland layer visible callback(static function)
1263 * @param[in] data user data(unused)
1264 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1265 * @param[in] layer layer Id
1266 * @param[in] visible layer visible(1=visible/0=unvisible/other=nochange)
1269 /*--------------------------------------------------------------------------*/
1271 ico_uxf_window_layer_visiblecb(void *data, struct ico_window_mgr *ico_window_mgr,
1272 uint32_t layer, int32_t visible)
1274 uifw_trace("ico_uxf_window_layer_visiblecb: layer=%x visible=%d, NOP", layer, visible);
1277 /*--------------------------------------------------------------------------*/
1279 * @brief ico_uxf_window_surfacecb: query applicationsurface callback(static function)
1281 * @param[in] data user data(unused)
1282 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1283 * @param[in] appid application Id
1284 * @param[in] suface surface Id array
1287 /*--------------------------------------------------------------------------*/
1289 ico_uxf_window_surfacecb(void *data, struct ico_window_mgr *ico_window_mgr,
1290 const char *appid, struct wl_array *surfaces)
1292 uifw_trace("ico_uxf_window_surfacecb: appid=%s, NOP", appid);
1295 /*--------------------------------------------------------------------------*/
1297 * @brief ico_uxf_window_mapcb: surface map event callback(static function)
1299 * @param[in] data user data(unused)
1300 * @param[in] ico_window_mgr wayland ico_window_mgr plugin interface
1301 * @param[in] event event
1302 * @param[in] surfaceid surface Id
1303 * @param[in] width surface width
1304 * @param[in] height surface height
1305 * @param[in] stride surface buffer(frame buffer) stride
1306 * @param[in] format surface buffer format
1309 /*--------------------------------------------------------------------------*/
1311 ico_uxf_window_mapcb(void *data, struct ico_window_mgr *ico_window_mgr,
1312 int32_t event, uint32_t surfaceid, int32_t width,
1313 int32_t height, int32_t stride, int32_t format)
1315 uifw_trace("ico_uxf_window_mapcb: surf=%08x event=%d w/h/s/f=%d/%d/%d/%d",
1316 (int)surfaceid, event, width, height, stride, format);
1319 /*--------------------------------------------------------------------------*/
1321 * @brief ico_uxf_input_capabilitiescb: wayland extended input
1322 * input capabilities callback(static function)
1324 * @param[in] data user data(unused)
1325 * @param[in] ico_exinput wayland ico_input_mgr plugin interface
1326 * @param[in] device input device name
1327 * @param[in] type input device type
1328 * @param[in] swname input switch name
1329 * @param[in] input input switch number
1330 * @param[in] codename input code name
1331 * @param[in] code input code value
1334 /*--------------------------------------------------------------------------*/
1336 ico_uxf_input_capabilitiescb(void *data, struct ico_exinput *ico_exinput,
1337 const char *device, int32_t type, const char *swname,
1338 int32_t input, const char *codename, int32_t code)
1341 Ico_Uxf_Sys_Config *sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
1342 Ico_Uxf_InputDev *inputdev;
1343 Ico_Uxf_InputDev *bpdev;
1344 Ico_Uxf_InputSw *inputsw;
1345 Ico_Uxf_InputSw *bpsw;
1347 uifw_trace("ico_uxf_input_capabilitiescb: "
1348 "Enter(device=%s type=%d sw=%s input=%d code=%s[%d])",
1349 device, type, swname, input, codename, code);
1351 if (! sysconf) return;
1353 /* search and create input device table */
1355 inputdev = gIco_Uxf_Api_Mng.InputDev;
1357 if (strcasecmp(inputdev->device, device) == 0) break;
1359 inputdev = inputdev->next;
1362 inputdev = malloc(sizeof(Ico_Uxf_InputDev));
1364 uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
1367 memset(inputdev, 0, sizeof(Ico_Uxf_InputDev));
1370 bpdev->next = inputdev;
1373 gIco_Uxf_Api_Mng.InputDev = inputdev;
1376 strncpy(inputdev->device, device, sizeof(inputdev->device)-1);
1377 inputdev->type = type;
1380 inputsw = inputdev->inputSw;
1382 if (strcasecmp(inputsw->swname, swname) == 0) break;
1384 inputsw = inputsw->next;
1387 inputsw = malloc(sizeof(Ico_Uxf_InputSw));
1389 uifw_error("ico_uxf_input_capabilitiescb: Leave(No Memory)");
1393 bpsw->next = inputsw;
1396 inputdev->inputSw = inputsw;
1398 inputdev->numInputSw ++;
1400 memset(inputsw, 0, sizeof(Ico_Uxf_InputSw));
1401 strncpy(inputsw->swname, swname, sizeof(inputsw->swname)-1);
1402 inputsw->input = input;
1403 inputsw->numCode = 1;
1404 inputsw->inputCode[0].code = code;
1405 strncpy(inputsw->inputCode[0].codename, codename,
1406 sizeof(inputsw->inputCode[0].codename)-1);
1407 uifw_trace("ico_uxf_input_capabilitiescb: create new inputsw");
1409 /* send fixed application if fixed switch */
1410 for (i = 0; i < sysconf->inputdevNum; i++) {
1411 if (strcasecmp(sysconf->inputdev[i].name, inputdev->device) != 0) continue;
1413 for (j = 0; j < sysconf->inputdev[i].inputswNum; j++) {
1414 if (! sysconf->inputdev[i].inputsw[j].appid) continue;
1415 if (strcasecmp(sysconf->inputdev[i].inputsw[j].name,
1416 inputsw->swname) != 0) continue;
1418 uifw_trace("ico_uxf_input_capabilitiescb: input %s.%s = %s",
1419 inputdev->device, inputsw->swname,
1420 sysconf->inputdev[i].inputsw[j].appid);
1421 ico_input_mgr_control_add_input_app(gIco_Uxf_Api_Mng.Wayland_InputMgr,
1422 sysconf->inputdev[i].inputsw[j].appid,
1423 inputdev->device, inputsw->input, 1,
1424 sysconf->inputdev[i].inputsw[j].keycode);
1429 uifw_trace("ico_uxf_input_capabilitiescb: Leave");
1432 /*--------------------------------------------------------------------------*/
1434 * @brief ico_uxf_input_codecb: wayland extended input
1435 * input code callback(static function)
1437 * @param[in] data user data(unused)
1438 * @param[in] ico_exinput wayland ico_input_mgr plugin interface
1439 * @param[in] device input device name
1440 * @param[in] input input switch number
1441 * @param[in] codename input code name
1442 * @param[in] code input code value
1445 /*--------------------------------------------------------------------------*/
1447 ico_uxf_input_codecb(void *data, struct ico_exinput *ico_exinput, const char *device,
1448 int32_t input, const char *codename, int32_t code)
1451 Ico_Uxf_InputDev *inputdev;
1452 Ico_Uxf_InputSw *inputsw;
1454 uifw_trace("ico_uxf_input_codecb: device=%s input=%d code=%s[%d]",
1455 device, input, codename, code);
1457 /* search input device table */
1458 inputdev = gIco_Uxf_Api_Mng.InputDev;
1460 if (strcasecmp(inputdev->device, device) == 0) break;
1461 inputdev = inputdev->next;
1464 uifw_error("ico_uxf_input_codecb: device.%s dose not exist", device);
1468 /* search input switch */
1469 inputsw = inputdev->inputSw;
1471 if (inputsw->input == input) break;
1472 inputsw = inputsw->next;
1475 uifw_error("ico_uxf_input_codecb: device.%s input=%d dose not exist",
1479 for (i = 0; i < inputsw->numCode; i++) {
1480 if (inputsw->inputCode[i].code == code) break;
1482 if (i >= inputsw->numCode) {
1484 uifw_error("ico_uxf_input_codecb: device.%s input=%d number of codes overflow",
1488 inputsw->numCode ++;
1489 i = inputsw->numCode - 1;
1491 memset(inputsw->inputCode[i].codename, 0, sizeof(inputsw->inputCode[i].codename));
1492 strncpy(inputsw->inputCode[i].codename, codename,
1493 sizeof(inputsw->inputCode[i].codename)-1);
1494 inputsw->inputCode[i].code = code;
1497 /*--------------------------------------------------------------------------*/
1499 * @brief ico_uxf_input_inputcb: wayland extended input
1500 * input switch callback(static function)
1502 * @param[in] data user data(unused)
1503 * @param[in] ico_exinput wayland ico_input_mgr plugin interface
1504 * @param[in] time input time(miri-sec)
1505 * @param[in] device input device name
1506 * @param[in] input input switch number
1507 * @param[in] code input code value
1508 * @param[in] state input state(1=switch On/0=switch Off)
1511 /*--------------------------------------------------------------------------*/
1513 ico_uxf_input_inputcb(void *data, struct ico_exinput *ico_exinput, uint32_t time,
1514 const char *device, int32_t input, int32_t code, int32_t state)
1516 Ico_Uxf_Mng_EventQue *que;
1517 uifw_trace("ico_uxf_input_inputcb: device=%s input=%d code=%d state=%d",
1518 device, input, code, state);
1520 if (gIco_Uxf_Api_Mng.EventMask & ICO_UXF_EVENT_EXINPUT) {
1522 ico_uxf_enter_critical();
1523 que = ico_uxf_alloc_eventque();
1525 strncpy(que->detail.exinput.device, device,
1526 sizeof(que->detail.exinput.device)-1);
1527 que->detail.exinput.input = input;
1528 que->detail.exinput.code = code;
1529 que->detail.exinput.state = state;
1531 ico_uxf_regist_eventque(que);
1532 ico_uxf_leave_critical();
1536 /*--------------------------------------------------------------------------*/
1538 * @brief ico_uxf_aul_aulcb: AppCore(AUL) application launch/dead callback(static function)
1540 * @param[in] pid target application process Id
1541 * @param[in] data user data(0=launch, 1=dead)
1542 * @return result(always 0, means success)
1544 /*--------------------------------------------------------------------------*/
1546 ico_uxf_aul_aulcb(int pid, void *data)
1548 Ico_Uxf_Mng_Process *proc;
1550 Ico_Uxf_Mng_EventQue *que;
1552 char appid[ICO_UXF_MAX_PROCESS_NAME+1];
1555 memset(appid, 0, sizeof(appid));
1557 (void) aul_app_get_appid_bypid(pid, appid, sizeof(appid));
1558 uifw_trace("ico_uxf_aul_aulcb: Enter(pid=%d, dead=No, appid=%s)", pid, appid);
1561 uifw_trace("ico_uxf_aul_aulcb: Enter(pid=%d, dead=Yes)", pid);
1563 for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
1564 proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1566 if (proc->attr.internalid == pid) break;
1567 if (strcmp(proc->attr.process, appid) == 0) break;
1568 proc = proc->nextidhash;
1573 /* not handle process, */
1574 /* or the process is correctly terminated by ico_uxf_process_terminate */
1575 uifw_trace("ico_uxf_aul_aulcb: Leave(not find)");
1578 uifw_trace("ico_uxf_aul_aulcb: find(appid=%s)", proc->attr.process);
1580 ico_uxf_enter_critical();
1582 que = ico_uxf_alloc_eventque();
1583 strncpy(que->detail.process.process, proc->attr.process, ICO_UXF_MAX_PROCESS_NAME);
1585 que->detail.event = ICO_UXF_EVENT_TERMPROCESS;
1586 que->detail.process.status = ICO_UXF_PROCSTATUS_STOP;
1588 /* delete process info */
1589 proc->attr.status = ICO_UXF_PROCSTATUS_STOP;
1590 proc->attr.internalid = -1;
1591 proc->attr.mainwin.window = 0;
1592 ico_uxf_free_procwin(proc);
1595 que->detail.event = ICO_UXF_EVENT_EXECPROCESS;
1596 que->detail.process.status = ICO_UXF_PROCSTATUS_RUN;
1598 /* setup process info */
1599 if (proc->attr.status != ICO_UXF_PROCSTATUS_RUN) {
1600 proc->attr.internalid = pid;
1601 if (proc->attr.status != ICO_UXF_PROCSTATUS_INIT) {
1602 /* child process, search parent process */
1603 uifw_trace("ico_uxf_aul_aulcb: fork&exec %s", proc->attr.process);
1604 proc->attr.child = 1;
1605 /* save parent application if exist */
1606 if (gIco_Uxf_Api_Mng.Mng_LastProcess != proc) {
1607 proc->parent = gIco_Uxf_Api_Mng.Mng_LastProcess;
1610 uifw_trace("ico_uxf_aul_aulcb: same process %s real %s", proc->attr.process,
1611 proc->parent ? proc->parent->attr.process : "(None)");
1615 proc->attr.child = 0;
1617 proc->attr.status = ICO_UXF_PROCSTATUS_RUN;
1622 ico_uxf_regist_eventque(que);
1624 ico_uxf_leave_critical();
1626 uifw_trace("ico_uxf_aul_aulcb: Leave");
1630 /*--------------------------------------------------------------------------*/
1632 * @brief ico_uxf_set_lastapp: save last application
1634 * @param[in] appid applicationId (if NULL, no last application)
1637 /*--------------------------------------------------------------------------*/
1639 ico_uxf_set_lastapp(const char *appid)
1642 gIco_Uxf_Api_Mng.Mng_LastProcess = ico_uxf_mng_process(appid, 0);
1645 gIco_Uxf_Api_Mng.Mng_LastProcess = NULL;
1649 /*--------------------------------------------------------------------------*/
1651 * @brief ico_uxf_getchild_appid: get child applicationId
1653 * @param[in] appid parent applicationId
1654 * @return last child applicationId
1655 * @retval !=NULL success(applicationId)
1656 * @retval ==NULL no child application
1658 /*--------------------------------------------------------------------------*/
1660 ico_uxf_getchild_appid(const char *appid)
1662 Ico_Uxf_Mng_Process *pproc;
1663 Ico_Uxf_Mng_Process *proc;
1666 pproc = ico_uxf_mng_process(appid, 0);
1668 /* unknown parent application, no child */
1669 uifw_trace("ico_uxf_getchild_appid: Unknown parent(%s)", appid);
1674 for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
1675 proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1677 if (proc->parent == pproc) {
1678 uifw_trace("ico_uxf_getchild_appid: child(%s) parent(%s)",
1679 proc->attr.process, appid);
1680 return proc->attr.process;
1682 proc = proc->nextidhash;
1685 uifw_trace("ico_uxf_getchild_appid: parent(%s) has no child", appid);
1689 /*--------------------------------------------------------------------------*/
1691 * @brief ico_uxf_set_lastapp: save last application
1693 * @param[in] appid applicationId (if NULL, no last application)
1696 /*--------------------------------------------------------------------------*/
1698 ico_uxf_timer_wake(const int msec)
1700 Ico_Uxf_Mng_Process *proc;
1703 if (gIco_Uxf_Api_Mng.InitTimer > 0) {
1704 gIco_Uxf_Api_Mng.InitTimer -= msec;
1705 if (gIco_Uxf_Api_Mng.InitTimer > 0) {
1708 gIco_Uxf_Api_Mng.InitTimer = 0;
1711 if (gIco_Uxf_Api_Mng.NeedTimer == 0) {
1714 gIco_Uxf_Api_Mng.NeedTimer = 0;
1715 for (hash = 0; hash < ICO_UXF_MISC_HASHSIZE; hash++) {
1716 proc = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
1718 if (proc->susptimer > 0) {
1719 if (msec >= proc->susptimer) {
1720 proc->susptimer = 0;
1721 if (proc->attr.suspend) {
1722 if (proc->susp == 0) {
1724 uifw_trace("ico_uxf_timer_wake: CPU suspend pid=%d",
1725 proc->attr.internalid);
1726 kill(proc->attr.internalid, SIGSTOP);
1729 else if (proc->susp == 0) {
1730 uifw_trace("ico_uxf_timer_wake: CPU resume pid=%d(show=%d)",
1731 proc->attr.internalid, proc->showmode);
1732 ico_window_mgr_set_visible(gIco_Uxf_Api_Mng.Wayland_WindowMgr,
1733 proc->attr.mainwin.window,
1734 ICO_WINDOW_MGR_VISIBLE_SHOW,
1735 ICO_WINDOW_MGR_V_NOCHANGE,
1736 (proc->showmode != 0) ?
1737 ICO_WINDOW_MGR_ANIMATION_ANIMATION :
1738 ICO_WINDOW_MGR_ANIMATION_NOANIMATION);
1739 wl_display_flush(gIco_Uxf_Api_Mng.Wayland_Display);
1743 proc->susptimer -= msec;
1744 gIco_Uxf_Api_Mng.NeedTimer ++;
1747 proc = proc->nextidhash;
1752 /*--------------------------------------------------------------------------*/
1754 * @brief ico_uxf_enter_critical: enter critical section(internal function)
1759 /*--------------------------------------------------------------------------*/
1761 ico_uxf_enter_critical(void)
1763 if (pthread_mutex_lock(&sMutex)) {
1764 uifw_error("ico_uxf_enter_critical: Error<%d>", errno);
1768 /*--------------------------------------------------------------------------*/
1770 * @brief ico_uxf_leave_critical: leave critical section(internal function)
1775 /*--------------------------------------------------------------------------*/
1777 ico_uxf_leave_critical(void)
1779 if (pthread_mutex_unlock(&sMutex)) {
1780 uifw_error("ico_uxf_leave_critical: Error<%d>", errno);
1784 /*--------------------------------------------------------------------------*/
1786 * @brief ico_uxf_alloc_callback: allocate callback management table(internal function)
1789 * @return allocated callback management table address
1791 /*--------------------------------------------------------------------------*/
1792 Ico_Uxf_Mng_Callback *
1793 ico_uxf_alloc_callback(void)
1795 Ico_Uxf_Mng_Callback *p;
1798 p = gIco_Uxf_Api_Mng.CallbackFree;
1800 p = (Ico_Uxf_Mng_Callback *)malloc(sizeof(Ico_Uxf_Mng_Callback) *
1801 ICO_UXF_MNG_BLOCK_ALLOCS);
1803 uifw_error("ico_uxf_alloc_callback: NO Memory (malloc Error)");
1806 gIco_Uxf_Api_Mng.CallbackFree = p;
1808 for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++) {
1809 if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1)) {
1813 p->next = (struct _Ico_Uxf_Mng_Callback *)0;
1816 p = gIco_Uxf_Api_Mng.CallbackFree;
1818 gIco_Uxf_Api_Mng.CallbackFree = p->next;
1822 /*--------------------------------------------------------------------------*/
1824 * @brief ico_uxf_free_callback: release callback management table(internal function)
1826 * @param[in] p callback management table address
1829 /*--------------------------------------------------------------------------*/
1831 ico_uxf_free_callback(Ico_Uxf_Mng_Callback *p)
1833 p->next = gIco_Uxf_Api_Mng.CallbackFree;
1834 gIco_Uxf_Api_Mng.CallbackFree = p;
1837 /*--------------------------------------------------------------------------*/
1839 * @brief ico_uxf_regist_callback: register a callback management table(internal function)
1841 * @param[in] p callback management table address
1844 /*--------------------------------------------------------------------------*/
1846 ico_uxf_regist_callback(Ico_Uxf_Mng_Callback *p)
1848 p->next = (struct _Ico_Uxf_Mng_Callback *)0;
1850 if (gIco_Uxf_Api_Mng.Callback) {
1851 gIco_Uxf_Api_Mng.CallbackLast->next = p;
1852 gIco_Uxf_Api_Mng.CallbackLast = p;
1855 gIco_Uxf_Api_Mng.Callback = p;
1856 gIco_Uxf_Api_Mng.CallbackLast = gIco_Uxf_Api_Mng.Callback;
1860 /*--------------------------------------------------------------------------*/
1862 * @brief ico_uxf_remove_callback: remove a callback management table(internal function)
1864 * @param[in] p callback management table address
1867 /*--------------------------------------------------------------------------*/
1869 ico_uxf_remove_callback(Ico_Uxf_Mng_Callback *p)
1871 Ico_Uxf_Mng_Callback *pp;
1872 Ico_Uxf_Mng_Callback *before;
1874 pp = gIco_Uxf_Api_Mng.Callback;
1875 before = (Ico_Uxf_Mng_Callback *)0;
1884 before->next = p->next;
1886 gIco_Uxf_Api_Mng.CallbackLast = before;
1890 gIco_Uxf_Api_Mng.Callback = p->next;
1895 /*--------------------------------------------------------------------------*/
1897 * @brief ico_uxf_alloc_eventque: allocate event queue block(internal function)
1900 * @return allocated event queue control block address
1902 /*--------------------------------------------------------------------------*/
1903 Ico_Uxf_Mng_EventQue
1904 *ico_uxf_alloc_eventque(void)
1906 Ico_Uxf_Mng_EventQue *p;
1909 p = gIco_Uxf_Api_Mng.EventQueFree;
1911 p = (Ico_Uxf_Mng_EventQue *)
1912 malloc(sizeof(Ico_Uxf_Mng_EventQue) * ICO_UXF_MNG_BLOCK_ALLOCS);
1914 uifw_error("ico_uxf_alloc_eventque: NO Memory (malloc Error)");
1917 gIco_Uxf_Api_Mng.EventQueFree = p;
1919 for (idx = 0; idx < ICO_UXF_MNG_BLOCK_ALLOCS; idx++, p++) {
1920 if (idx != (ICO_UXF_MNG_BLOCK_ALLOCS-1)) {
1924 p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
1927 p = gIco_Uxf_Api_Mng.EventQueFree;
1929 gIco_Uxf_Api_Mng.EventQueFree = p->next;
1934 /*--------------------------------------------------------------------------*/
1936 * @brief ico_uxf_free_eventque: release event queue block(internal function)
1938 * @param[in] p event queue control block address
1941 /*--------------------------------------------------------------------------*/
1943 ico_uxf_free_eventque(Ico_Uxf_Mng_EventQue *p)
1945 p->next = gIco_Uxf_Api_Mng.EventQueFree;
1946 gIco_Uxf_Api_Mng.EventQueFree = p;
1949 /*--------------------------------------------------------------------------*/
1951 * @brief ico_uxf_regist_eventque: register a event queue(internal function)
1953 * @param[in] p event queue control block address
1956 /*--------------------------------------------------------------------------*/
1958 ico_uxf_regist_eventque(Ico_Uxf_Mng_EventQue *p)
1960 p->next = (struct _Ico_Uxf_Mng_EventQue *)0;
1962 if (gIco_Uxf_Api_Mng.EventQue) {
1963 gIco_Uxf_Api_Mng.EventQueLast->next = p;
1964 gIco_Uxf_Api_Mng.EventQueLast = p;
1967 gIco_Uxf_Api_Mng.EventQue = p;
1968 gIco_Uxf_Api_Mng.EventQueLast = gIco_Uxf_Api_Mng.EventQue;
1972 /*--------------------------------------------------------------------------*/
1974 * @brief ico_uxf_mng_display: get display management table(internal function)
1976 * @param[in] display display Id
1977 * @param[in] create create flag(1=create tabell if not exist/0=not create)
1978 * @return display management table address
1979 * @retval !=NULL display management table address
1980 * @retval ==NULL display dose not exist(parameter 'create' only 0)
1982 /*--------------------------------------------------------------------------*/
1983 Ico_Uxf_Mng_Display *
1984 ico_uxf_mng_display(const int display, const int create)
1986 Ico_Uxf_Mng_Display *p;
1987 Ico_Uxf_Mng_Display *plast;
1989 p = gIco_Uxf_Api_Mng.Mng_Display;
1990 plast = (Ico_Uxf_Mng_Display *)0;
1992 if (p->attr.display == display) break;
1997 if ((! p) && (create != 0)) {
1999 p = (Ico_Uxf_Mng_Display *) malloc(sizeof(Ico_Uxf_Mng_Display));
2001 uifw_error("ico_uxf_mng_display: NO Memory (malloc Error)");
2004 memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Display));
2005 p->attr.display = display;
2010 gIco_Uxf_Api_Mng.Mng_Display = p;
2016 /*--------------------------------------------------------------------------*/
2018 * @brief ico_uxf_mng_layer: get layer management table(internal function)
2020 * @param[in] display display Id
2021 * @param[in] layer layer Id
2022 * @param[in] create create flag(1=create tabell if not exist/0=not create)
2023 * @return layer management table address
2024 * @retval !=NULL layer management table address
2025 * @retval ==NULL layer dose not exist(parameter 'create' only 0)
2027 /*--------------------------------------------------------------------------*/
2029 ico_uxf_mng_layer(const int display, const int layer, const int create)
2031 Ico_Uxf_Mng_Layer *p;
2032 Ico_Uxf_Mng_Layer *plast;
2034 p = gIco_Uxf_Api_Mng.Mng_Layer;
2035 plast = (Ico_Uxf_Mng_Layer *)0;
2037 if ((p->attr.display == display) &&
2038 (p->attr.layer == layer)) break;
2043 if ((! p) && (create != 0)) {
2045 p = (Ico_Uxf_Mng_Layer *) malloc(sizeof(Ico_Uxf_Mng_Layer));
2047 uifw_error("ico_uxf_mng_layer: NO Memory (malloc Error)");
2050 memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Layer));
2051 p->attr.layer = layer;
2056 gIco_Uxf_Api_Mng.Mng_Layer = p;
2062 /*--------------------------------------------------------------------------*/
2064 * @brief ico_uxf_mng_window: get window management table(internal function)
2066 * @param[in] window window Id(same as ico_window_mgr surface Id)
2067 * @param[in] create create flag(1=create tabell if not exist/0=not create)
2068 * @return window management table address
2069 * @retval !=NULL window management table address
2070 * @retval ==NULL window dose not exist(parameter 'create' only 0)
2072 /*--------------------------------------------------------------------------*/
2073 Ico_Uxf_Mng_Window *
2074 ico_uxf_mng_window(const int window, const int create)
2076 Ico_Uxf_Mng_Window *p;
2077 Ico_Uxf_Mng_Window *plast = (Ico_Uxf_Mng_Window *)0;
2080 hash = ICO_UXF_MISC_HASHBYID(window);
2081 p = gIco_Uxf_Api_Mng.Hash_WindowId[hash];
2083 if (p->attr.window == window) break;
2088 if ((! p) && (create != 0)) {
2090 p = (Ico_Uxf_Mng_Window *) malloc(sizeof(Ico_Uxf_Mng_Window));
2092 uifw_error("ico_uxf_mng_window: NO Memory (malloc Error)");
2095 memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Window));
2096 p->attr.window = window;
2098 plast->nextidhash = p;
2101 gIco_Uxf_Api_Mng.Hash_WindowId[hash] = p;
2103 uifw_trace("ico_uxf_mng_window: Create New Table=%08x", (int)p);
2108 /*--------------------------------------------------------------------------*/
2110 * @brief ico_uxf_mng_process: get process management table(internal function)
2112 * @param[in] process application Id
2113 * @param[in] create create flag(1=create tabell if not exist/0=not create)
2114 * @return process management table address
2115 * @retval !=NULL process management table address
2116 * @retval ==NULL process dose not exist(parameter 'create' only 0)
2118 /*--------------------------------------------------------------------------*/
2119 Ico_Uxf_Mng_Process *
2120 ico_uxf_mng_process(const char *process, const int create)
2122 Ico_Uxf_Mng_Process *p;
2123 Ico_Uxf_Mng_Process *plast = (Ico_Uxf_Mng_Process *)0;
2126 hash = ICO_UXF_MISC_HASHBYNAME(process);
2127 p = gIco_Uxf_Api_Mng.Hash_ProcessId[hash];
2129 if(strncmp(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME) == 0) break;
2134 if ((! p) && (create != 0)) {
2136 p = (Ico_Uxf_Mng_Process *) malloc(sizeof(Ico_Uxf_Mng_Process));
2138 uifw_error("ico_uxf_mng_process: NO Memory (malloc Error)");
2141 memset((char *)p, 0, sizeof(Ico_Uxf_Mng_Process));
2142 strncpy(p->attr.process, process, ICO_UXF_MAX_PROCESS_NAME);
2144 plast->nextidhash = p;
2147 gIco_Uxf_Api_Mng.Hash_ProcessId[hash] = p;
2153 /*--------------------------------------------------------------------------*/
2155 * @brief ico_uxf_update_procwin: update a process management table
2157 * @param[in] appid application id
2158 * @param[in] type type(install/uninstall)
2159 * @param[in] func window create/destroy hook function
2162 /*--------------------------------------------------------------------------*/
2164 ico_uxf_update_procwin(const char *appid, int type)
2166 Ico_Uxf_Mng_Process *prc = NULL;
2167 Ico_Uxf_Sys_Config *sysconf;
2168 Ico_Uxf_App_Config *appconf;
2169 Ico_Uxf_conf_appdisplay *appdsp;
2171 Ico_Uxf_conf_application *app = NULL;
2173 uifw_trace("ico_uxf_update_procwin: Enter(appid=%s, type=%d)", appid, type);
2175 if (gIco_Uxf_Api_Mng.Initialized <= 0) {
2176 uifw_trace("ico_uxf_callback_remove: Leave(not initialized)");
2179 prc = ico_uxf_mng_process(appid, 0);
2181 if (type == ICO_UXF_CONF_EVENT_INSTALL) {
2183 sysconf = (Ico_Uxf_Sys_Config *)ico_uxf_getSysConfig();
2184 appconf = (Ico_Uxf_App_Config *)ico_uxf_getAppConfig();
2185 if ((sysconf == NULL) || (appconf == NULL)) {
2186 uifw_trace("ico_uxf_update_procwin: Leave(cannot find tables)");
2189 for (dn = 0; dn < appconf->applicationNum; dn++) {
2190 app = &appconf->application[dn];
2191 if (strncmp(app->appid, appid, ICO_UXF_MAX_PROCESS_NAME) == 0) {
2192 uifw_trace("ico_uxf_update_procwin: Install(%s)", appid);
2193 /* add process management table */
2194 prc = ico_uxf_mng_process(appid, 1);
2195 prc->attr.internalid = 0;
2196 prc->attr.status = ICO_UXF_PROCSTATUS_STOP;
2197 prc->attr.type = app->categoryId;
2198 prc->attr.hostId = app->hostId;
2199 prc->attr.myHost = (prc->attr.hostId == sysconf->misc.myhostId) ? 1 : 0;
2201 appdsp = &app->display[0];
2202 prc->attr.mainwin.window = 0;
2203 prc->attr.mainwin.windowtype = app->categoryId;
2204 prc->attr.mainwin.display = appdsp->displayId;
2205 prc->attr.mainwin.layer = appdsp->layerId;
2206 prc->attr.mainwin.x =
2207 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
2208 prc->attr.mainwin.y =
2209 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
2210 prc->attr.mainwin.w =
2211 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
2212 prc->attr.mainwin.h =
2213 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
2214 prc->attr.mainwin.name[ICO_UXF_MAX_WIN_NAME] = 0;
2215 prc->attr.numwindows = app->displayzoneNum;
2216 /* get sub windows */
2217 if (prc->attr.numwindows > 1) {
2218 prc->attr.subwin = malloc(sizeof(Ico_Uxf_ProcessWin) *
2219 (prc->attr.numwindows - 1));
2220 if (! prc->attr.subwin) {
2221 uifw_trace("ico_uxf_update_procwin: Install(No memory)");
2222 app->displayzoneNum = 1;
2223 prc->attr.numwindows = 1;
2226 memset(prc->attr.subwin, 0, (prc->attr.numwindows - 1));
2227 for (tn = 0; tn < (prc->attr.numwindows - 1); tn++) {
2229 prc->attr.subwin[tn].windowtype = prc->attr.mainwin.windowtype;
2230 prc->attr.subwin[tn].display = appdsp->displayId;
2231 prc->attr.subwin[tn].layer = appdsp->layerId;
2232 prc->attr.subwin[tn].x =
2233 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].x;
2234 prc->attr.subwin[tn].y =
2235 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].y;
2236 prc->attr.subwin[tn].w =
2237 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].width;
2238 prc->attr.subwin[tn].h =
2239 sysconf->display[appdsp->displayId].zone[appdsp->zoneId].height;
2247 else if (type == ICO_UXF_CONF_EVENT_UNINSTALL) {
2249 /* not delete process management table */
2253 uifw_trace("ico_uxf_update_procwin: Leave");
2258 /*--------------------------------------------------------------------------*/
2260 * @brief ico_uxf_window_screen_size_get: get display physical size
2262 * @param[out] width variable to receive the width of the display
2263 * @param[out] height variable to receive the height of the display
2266 /*--------------------------------------------------------------------------*/
2268 ico_uxf_window_screen_size_get(int *width, int *height)
2270 Ico_Uxf_Mng_Display *dsp;
2271 dsp = ico_uxf_mng_display(gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display, 0);
2273 uifw_trace("ico_uxf_window_screen_size_get: Enter(dsp=%d(%d))",
2274 dsp, gIco_Uxf_Api_Mng.Mng_MyProcess->attr.mainwin.display);
2276 if ((dsp != NULL) && (width != NULL) && (height != NULL)) {
2277 uifw_trace("ico_uxf_window_screen_size_get: %dx%d",
2278 dsp->attr.pWidth, dsp->attr.pHeight);
2279 *width = dsp->attr.pWidth;
2280 *height = dsp->attr.pHeight;
2284 /*--------------------------------------------------------------------------*/
2286 * @brief ico_uxf_window_hook: set window create/destroy hook function
2288 * @param[in] func window create/destroy hook function
2291 /*--------------------------------------------------------------------------*/
2293 ico_uxf_window_hook(Ico_Uxf_Hook func)
2295 uifw_trace("ico_uxf_window_hook: Window Control Hook=%08x", (int)func);
2297 gIco_Uxf_Api_Mng.Hook_Window = func;