Skip to content

Commit aba3201

Browse files
committed
window-list: Disassociate parent and child if a null parent is set
1 parent c5aa97e commit aba3201

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

src/panel/widgets/window-list/toplevel.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,33 +519,41 @@ static void handle_toplevel_done(void *data, toplevel_t)
519519
// auto impl = static_cast<WayfireToplevel::impl*> (data);
520520
}
521521

522-
static void handle_toplevel_closed(void *data, toplevel_t handle)
522+
static void remove_child_from_parent(WayfireToplevel::impl *impl, toplevel_t child)
523523
{
524-
//WayfirePanelApp::get().handle_toplevel_closed(handle);
525-
auto impl = static_cast<WayfireToplevel::impl*> (data);
526524
auto parent = impl->get_parent();
527-
if (parent && impl->window_list->toplevels[parent])
525+
auto& parent_toplevel = impl->window_list->toplevels[parent];
526+
if (child && parent && parent_toplevel)
528527
{
529-
auto& children = impl->window_list->toplevels[parent]->get_children();
530-
children.erase(std::find(children.begin(), children.end(), handle));
528+
auto& children = parent_toplevel->get_children();
529+
children.erase(std::find(children.begin(), children.end(), child));
531530
}
531+
}
532+
533+
static void handle_toplevel_closed(void *data, toplevel_t handle)
534+
{
535+
//WayfirePanelApp::get().handle_toplevel_closed(handle);
536+
auto impl = static_cast<WayfireToplevel::impl*> (data);
537+
remove_child_from_parent(impl, handle);
532538
impl->window_list->handle_toplevel_closed(handle);
533539
}
534540

535541
static void handle_toplevel_parent(void *data, toplevel_t handle, toplevel_t parent)
536542
{
537543
auto impl = static_cast<WayfireToplevel::impl*> (data);
538-
impl->set_parent(parent);
539544
if (!parent)
540545
{
541546
impl->handle_output_enter(impl->window_list->output->wo);
547+
remove_child_from_parent(impl, handle);
548+
impl->set_parent(parent);
542549
return;
543550
}
544551
if (impl->window_list->toplevels[parent])
545552
{
546553
auto& children = impl->window_list->toplevels[parent]->get_children();
547554
children.push_back(handle);
548555
}
556+
impl->set_parent(parent);
549557
impl->remove_button();
550558
}
551559

0 commit comments

Comments
 (0)