2 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <Ecore_Wayland.h>
26 #include <glib-object.h>
30 #include "appcore_base.h"
31 #include "appcore_multiwindow_base.h"
32 #include "appcore_multiwindow_base_private.h"
34 typedef struct _win_context {
35 appcore_multiwindow_base_instance_h inst;
39 static GList *__win_contexts;
41 static gint __comp(gconstpointer a, gconstpointer b)
43 const win_context *cxt = a;
54 static gint __comp_wid(gconstpointer a, gconstpointer b)
56 int wid = GPOINTER_TO_INT(b);
57 const win_context *cxt = a;
62 if (cxt->win_id == wid)
68 static win_context *__find_win_context(appcore_multiwindow_base_instance_h h)
70 GList *node = g_list_find_custom(__win_contexts, h, __comp);
78 static win_context *__find_win_context_by_wid(int wid)
80 GList *node = g_list_find_custom(__win_contexts, GINT_TO_POINTER(wid), __comp_wid);
88 EXPORT_API void appcore_multiwindow_base_window_on_show(int type, void *event)
92 EXPORT_API void appcore_multiwindow_base_window_on_hide(int type, void *event)
94 Ecore_Wl_Event_Window_Hide *ev = event;
95 win_context *cxt = __find_win_context_by_wid(ev->win);
100 __win_contexts = g_list_remove(__win_contexts, cxt);
104 EXPORT_API void appcore_multiwindow_base_window_on_lower(int type, void *event)
108 EXPORT_API void appcore_multiwindow_base_window_on_visibility(int type, void *event)
110 Ecore_Wl_Event_Window_Visibility_Change *ev = event;
111 win_context *cxt = __find_win_context_by_wid(ev->win);
116 if (ev->fully_obscured)
117 appcore_multiwindow_base_instance_pause(cxt->inst);
119 appcore_multiwindow_base_instance_resume(cxt->inst);
122 EXPORT_API void appcore_multiwindow_base_window_on_pre_visibility(int type, void *event)
124 Ecore_Wl_Event_Window_Pre_Visibility_Change *ev = event;
125 win_context *cxt = __find_win_context_by_wid(ev->win);
130 if (ev->type == ECORE_WL_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED)
131 appcore_multiwindow_base_instance_resume(cxt->inst);
134 EXPORT_API void appcore_multiwindow_base_window_bind(appcore_multiwindow_base_instance_h h, Ecore_Wl_Window *wl_win)
140 _ERR("Invalid parameter");
144 cxt = __find_win_context(h);
146 _ERR("This instance is already binded");
150 id = ecore_wl_window_id_get(wl_win);
152 cxt = malloc(sizeof(win_context));
154 _ERR("Out of memory");
160 __win_contexts = g_list_append(__win_contexts, cxt);