#include "frame_private.h"
#include "log_private.h"
#include "private.h"
+#include "window_context.h"
struct frame_broker_s {
char *name;
aul_launcher_service_h als;
screen_connector_launcher_service_h scls;
frame_context_h context;
+ window_context_h window_context;
};
struct request_s {
frame_context_set_frame(context, NULL);
}
+static void __window_context_resume_cb(void *user_data)
+{
+ frame_broker_h broker = user_data;
+ frame_context_h context = broker->context;
+
+ _W("[__RESUME__] context(%p)", context);
+}
+
+static void __window_context_pause_cb(void *user_data)
+{
+ frame_broker_h broker = user_data;
+ frame_context_h context = broker->context;
+ frame_h frame = NULL;
+ frame_direction_e direction;
+
+ _W("[__PAUSE__] context(%p)", context);
+
+ if (!context)
+ return;
+
+ frame_context_get_frame(context, &frame);
+ frame_get_direction(frame, &direction);
+ if (direction == FRAME_DIRECTION_FORWARD)
+ frame_context_on_pause(context);
+}
+
API int frame_broker_create(void *wl2_win,
frame_context_lifecycle_callback_s *callback,
void *user_data,
.cleanup = __scls_cleanup_cb,
.reset = __scls_reset_cb
};
+ window_context_event_callback_s we_callback = {
+ .resume = __window_context_resume_cb,
+ .pause = __window_context_pause_cb
+ };
struct frame_broker_s *broker;
+ unsigned int win;
int ret;
if (!wl2_win || !callback || !handle) {
screen_connector_launcher_service_set_ops(scls, &ops, broker);
+ win = ecore_wl2_window_id_get((Ecore_Wl2_Window *)wl2_win);
+ ret = window_context_create(win, &we_callback, broker,
+ &broker->window_context);
+ if (ret != 0) {
+ _E("Failed to create window context. error(%d)", ret);
+ frame_broker_destroy(broker);
+ return ret;
+ }
+
broker->scls = scls;
broker->wl2_win = wl2_win;
broker->callback = *callback;
if (handle->context)
frame_context_destroy(handle->context);
+ window_context_destroy(handle->window_context);
screen_connector_launcher_service_destroy(handle->scls);
aul_launcher_service_destroy(handle->als);
free(handle->name);
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <Ecore_Wl2.h>
+#include <glib.h>
+
+#include "frame_types.h"
+#include "log_private.h"
+#include "window_context.h"
+
+struct window_context_s {
+ unsigned int win;
+ bool fully_obscured;
+ Ecore_Event_Handler *hide;
+ Ecore_Event_Handler *visibility_change;
+ Ecore_Event_Handler *pre_visibility_change;
+ window_context_event_callback_s callback;
+ void *user_data;
+};
+
+static Eina_Bool __window_hide_cb(void *data, int type, void *event)
+{
+ Ecore_Wl2_Event_Window_Hide *ev = event;
+ window_context_h context = data;
+
+ _D("[__HIDE__] win(%u)", ev->win);
+ if (context->win == ev->win) {
+ if (!context->fully_obscured) {
+ context->callback.pause(context->user_data);
+ context->fully_obscured = true;
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __window_visibility_change_cb(void *data, int type,
+ void *event)
+{
+ Ecore_Wl2_Event_Window_Visibility_Change *ev = event;
+ window_context_h context = data;
+
+ _D("[__VISIBILITY_CHANGE__] win(%u), fully_obscured(%d)",
+ ev->win, ev->fully_obscured);
+ if (context->win == ev->win) {
+ if (ev->fully_obscured && !context->fully_obscured) {
+ context->callback.pause(context->user_data);
+ context->fully_obscured = true;
+ } else if (!ev->fully_obscured && context->fully_obscured) {
+ context->callback.resume(context->user_data);
+ context->fully_obscured = false;
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __window_pre_visibility_change_cb(void *data, int type,
+ void *event)
+{
+ Ecore_Wl2_Event_Window_Pre_Visibility_Change *ev = event;
+ window_context_h context = data;
+
+ _D("[__PRE_VISIBILITY_CHANGE__] win(%u)", ev->win);
+ if (ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
+ if (context->win == ev->win && context->fully_obscured) {
+ context->callback.resume(context->user_data);
+ context->fully_obscured = false;
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+int window_context_create(unsigned int win,
+ window_context_event_callback_s *callback,
+ void *user_data,
+ window_context_h *handle)
+{
+ struct window_context_s *context;
+
+ if (!win || !callback || !callback->resume || !callback->pause ||
+ !handle) {
+ _E("Invalid parameter");
+ return FRAME_BROKER_ERROR_INVALID_PARAMETER;
+ }
+
+ context = calloc(1, sizeof(struct window_context_s));
+ if (!context) {
+ _E("Out of memory");
+ return FRAME_BROKER_ERROR_OUT_OF_MEMORY;
+ }
+
+ context->hide = ecore_event_handler_add(
+ ECORE_WL2_EVENT_WINDOW_HIDE,
+ __window_hide_cb, context);
+
+ context->visibility_change = ecore_event_handler_add(
+ ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
+ __window_visibility_change_cb, context);
+
+ context->pre_visibility_change = ecore_event_handler_add(
+ ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
+ __window_pre_visibility_change_cb, context);
+
+ context->win = win;
+ context->callback = *callback;
+ context->user_data = user_data;
+
+ *handle = context;
+
+ return FRAME_BROKER_ERROR_NONE;
+}
+
+int window_context_destroy(window_context_h handle)
+{
+ if (!handle) {
+ _E("Invalid parameter");
+ return FRAME_BROKER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handle->pre_visibility_change)
+ ecore_event_handler_del(handle->pre_visibility_change);
+ if (handle->visibility_change)
+ ecore_event_handler_del(handle->visibility_change);
+ if (handle->hide)
+ ecore_event_handler_del(handle->hide);
+
+ free(handle);
+
+ return FRAME_BROKER_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WINDOW_CONTEXT_H__
+#define __WINDOW_CONTEXT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct window_context_s *window_context_h;
+
+typedef void (*window_context_resume_cb)(void *user_data);
+
+typedef void (*window_context_pause_cb)(void *user_data);
+
+typedef struct {
+ window_context_resume_cb resume;
+ window_context_pause_cb pause;
+} window_context_event_callback_s;
+
+int window_context_create(unsigned int win,
+ window_context_event_callback_s *callback,
+ void *user_data,
+ window_context_h *handle);
+
+int window_context_destroy(window_context_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WINDOW_CONTEXT_H__ */