bool reroute;
bool can_shift;
bool recycle;
+ bool attach_below;
};
struct launch_context_s {
return NULL;
}
+static void __attach_window(int parent_wid, struct app_group_context_s *ctx)
+{
+ if (ctx->wid == 0)
+ return;
+
+ if (ctx->attach_below)
+ _app_group_wayland_attach_window_below(parent_wid, ctx->wid);
+ else
+ _app_group_wayland_attach_window(parent_wid, ctx->wid);
+}
+
int _app_group_node_set_window(app_group_node_h node, int wid)
{
struct app_group_context_s *ctx;
int caller_wid;
app_group_node_h caller_node;
amd_comp_status_h comp = NULL;
+ app_group_node_h next_node;
+ struct app_group_context_s *next_ctx;
if (!node) {
_E("Invalid parameter");
prev_wid = _app_group_node_get_window(g_list_previous(node));
if (prev_wid != 0)
- _app_group_wayland_attach_window(prev_wid, wid);
+ __attach_window(prev_wid, ctx);
if (ctx->can_shift && ctx->caller_id) {
caller_node = _app_group_node_find(ctx->caller_id);
caller_wid = _app_group_node_get_window(caller_node);
if (caller_wid != 0)
- _app_group_wayland_attach_window(caller_wid, wid);
+ __attach_window(caller_wid, ctx);
}
- next_wid = _app_group_node_get_window(g_list_next(node));
- if (next_wid != 0)
- _app_group_wayland_attach_window(wid, next_wid);
+ next_node = g_list_next(node);
+ next_wid = _app_group_node_get_window(next_node);
+ if (next_wid != 0) {
+ next_ctx = (struct app_group_context_s *)next_node->data;
+ __attach_window(wid, next_ctx);
+ }
return 0;
}
{
int prev_wid;
int next_wid;
+ app_group_node_h next_node;
+ struct app_group_context_s *next_ctx;
prev_wid = _app_group_node_get_window(g_list_previous(node));
if (!prev_wid)
return;
- next_wid = _app_group_node_get_window(g_list_next(node));
+ next_node = g_list_next(node);
+ next_wid = _app_group_node_get_window(next_node);
if (!next_wid)
return;
_D("Reroute");
- _app_group_wayland_attach_window(prev_wid, next_wid);
+ next_ctx = (struct app_group_context_s *)next_node->data;
+ __attach_window(prev_wid, next_ctx);
}
static bool __app_group_node_is_sub(app_group_node_h node)
pid_t caller_pid, const char *caller_id,
app_group_launch_mode_e launch_mode,
bool can_shift, bool recycle,
- int before_wid)
+ int before_wid, bool attach_below)
{
struct app_group_context_s *ctx;
app_group_h group;
else
ctx->group_sig = false;
}
+ ctx->attach_below = attach_below;
found = g_list_find_custom(__app_group_list, leader_id,
__compare_group_id);
pid_t caller_pid;
struct app_group_context_s *ctx;
int before_wid = 0;
+ bool attach_below = false;
+ app_group_node_h caller_node;
+ app_group_node_h next_node;
_D("app_group_start");
if (str && isdigit(str[0]))
before_wid = atoi(str);
+ str = bundle_get_val(b, "__K_ATTACH_BELOW");
+ if (str && !strcmp(str, "true"))
+ attach_below = true;
+
+ str = bundle_get_val(b, "__K_INSERT_AFTER_CALLER");
+ if (str && !strcmp(str, "true")) {
+ caller_node = _app_group_node_find(caller_id);
+ next_node = g_list_next(caller_node);
+ before_wid = _app_group_node_get_window(next_node);
+ }
+
if (can_attach) {
ctx = __app_group_add(leader_pid, leader_id, pid, id,
caller_pid, caller_id, launch_mode,
- false, recycle, before_wid);
+ false, recycle, before_wid, attach_below);
} else {
ctx = __app_group_add(pid, id, pid, id,
caller_pid, caller_id, launch_mode,
- can_shift, false, before_wid);
+ can_shift, false, before_wid, attach_below);
}
__set_hint(ctx, b);
}
}
}
+static void __app_group_node_insert_after_caller(app_group_node_h node,
+ struct app_group_context_s *ctx)
+{
+ app_group_node_h caller_node;
+ int caller_wid;
+ app_group_h group;
+ gint pos;
+
+ _W("node(%p), ctx(%p), ctx->caller_id(%s), ctx->wid(%d)",
+ node, ctx, ctx->caller_id, ctx->wid);
+
+ group = _app_group_find(ctx->caller_id);
+ if (!group) {
+ _E("Failed to find app group. caller_id(%s)", ctx->caller_id);
+ return;
+ }
+
+ caller_node = _app_group_node_find(ctx->caller_id);
+ caller_wid = _app_group_node_get_window(caller_node);
+ if (caller_wid == 0)
+ return;
+
+ group->list = g_list_delete_link(group->list, node);
+ pos = __app_group_get_nth(group, caller_wid);
+ if (pos == -1)
+ group->list = g_list_append(group->list, ctx);
+ else
+ group->list = g_list_insert(group->list, ctx, pos + 1);
+
+ if (ctx->wid != 0) {
+ node = _app_group_node_find_by_wid(ctx->wid);
+ _app_group_node_set_window(node, ctx->wid);
+ }
+}
+
static void __app_group_restart(const char *id, bundle *b)
{
struct app_group_context_s *ctx;
int caller_wid;
const char *caller_id;
app_group_node_h caller_node;
+ const char *str;
+ bool insert_after_caller = false;
if (!id || !b) {
_E("Invalid parameter");
}
node = _app_group_node_find(id);
- if (!node)
+ if (!node) {
+ _E("Failed to find app group node. id(%s)", id);
return;
+ }
ctx = (struct app_group_context_s *)node->data;
- if (!ctx)
+ if (!ctx) {
+ _E("context is nullptr");
return;
+ }
ctx->caller_pid = __get_caller_pid(b);
ctx->caller_id = strdup(caller_id ? caller_id : "NULL");
+ str = bundle_get_val(b, "__K_ATTACH_BELOW");
+ if (str && !strcmp(str, "true"))
+ ctx->attach_below = true;
+ else
+ ctx->attach_below = false;
+
+ str = bundle_get_val(b, "__K_INSERT_AFTER_CALLER");
+ if (str && !strcmp(str, "true"))
+ insert_after_caller = true;
+ else
+ _E("Key not found");
+
+ if (insert_after_caller) {
+ if (ctx->wid != 0) {
+ _E("Detach window(%d)", ctx->wid);
+ _app_group_wayland_detach_window(ctx->wid);
+ }
+
+ __app_group_node_insert_after_caller(node, ctx);
+ return;
+ }
+
if (ctx->can_shift) {
if (ctx->wid != 0)
_app_group_wayland_detach_window(ctx->wid);
if (ctx->wid != 0) {
caller_node = _app_group_node_find(ctx->caller_id);
caller_wid = _app_group_node_get_window(caller_node);
- if (caller_wid != 0) {
- _app_group_wayland_attach_window(caller_wid,
- ctx->wid);
- } else {
+ if (caller_wid != 0)
+ __attach_window(caller_wid, ctx);
+ else
_E("Invalid caller window id");
- }
}
}
}