window: Propagate stickyness across modal dialog chains

While marking a parent window as sticky or non-sticky always propagates
to the children, also propagate to the parents if the dialog in question
is modal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3870>
This commit is contained in:
Jonas Ådahl 2024-07-16 11:44:58 +02:00 committed by Marge Bot
parent c079e2696d
commit 288d57f6a5
4 changed files with 122 additions and 0 deletions

View File

@ -4907,6 +4907,27 @@ stick_foreach_func (MetaWindow *window,
return TRUE;
}
static void
foreach_modal_ancestor (MetaWindow *window,
void (*func) (MetaWindow *window))
{
MetaWindow *parent;
if (window->type != META_WINDOW_MODAL_DIALOG)
return;
parent = window->transient_for;
while (parent)
{
func (parent);
if (parent->type != META_WINDOW_MODAL_DIALOG)
break;
parent = parent->transient_for;
}
}
void
meta_window_stick (MetaWindow *window)
{
@ -4918,6 +4939,7 @@ meta_window_stick (MetaWindow *window)
meta_window_foreach_transient (window,
stick_foreach_func,
&stick);
foreach_modal_ancestor (window, window_stick_impl);
}
void
@ -4931,6 +4953,7 @@ meta_window_unstick (MetaWindow *window)
meta_window_foreach_transient (window,
stick_foreach_func,
&stick);
foreach_modal_ancestor (window, window_unstick_impl);
}
void

View File

@ -737,6 +737,8 @@ stacking_tests = [
'sloppy-focus-pointer-rest',
'sloppy-focus-auto-raise',
'sticky',
'sticky-modals',
'sticky-transients',
'strut-monitor-changes'
]

View File

@ -0,0 +1,63 @@
new_client w wayland
create w/1
create w/2
create w/3
create w/4
create w/5
set_parent w/2 1
set_parent w/3 2
set_modal w/3
set_parent w/4 3
set_modal w/4
set_parent w/5 3
show w/1
show w/2
show w/3
show w/4
show w/5
assert_stacking w/1 w/2 w/3 w/4 w/5
assert_sticky w/1 false
assert_sticky w/2 false
assert_sticky w/3 false
assert_sticky w/4 false
assert_sticky w/5 false
# Marking root as sticky propagates to all children
stick w/1
assert_sticky w/1 true
assert_sticky w/2 true
assert_sticky w/3 true
assert_sticky w/4 true
assert_sticky w/5 true
# Marking a non-modal child as sticky does not propaget
unstick w/5
assert_sticky w/1 true
assert_sticky w/2 true
assert_sticky w/3 true
assert_sticky w/4 true
assert_sticky w/5 false
# Marking a modal as sticky propagates to all modal ancestors
unstick w/4
assert_sticky w/1 true
assert_sticky w/2 false
assert_sticky w/3 false
assert_sticky w/4 false
assert_sticky w/5 false
# Marking a modal as sticky propagates to modal ancestors, and all children
stick w/3
assert_sticky w/1 true
assert_sticky w/2 true
assert_sticky w/3 true
assert_sticky w/4 true
assert_sticky w/5 true
destroy w/5
destroy w/4
destroy w/3
destroy w/2
destroy w/1

View File

@ -0,0 +1,34 @@
new_client w wayland
create w/1
create w/2
create w/3
set_parent w/2 1
set_parent w/3 2
show w/1
show w/2
show w/3
assert_stacking w/1 w/2 w/3
assert_sticky w/1 false
assert_sticky w/2 false
assert_sticky w/3 false
stick w/1
assert_sticky w/1 true
assert_sticky w/2 true
assert_sticky w/3 true
unstick w/2
assert_sticky w/1 true
assert_sticky w/2 false
assert_sticky w/3 false
stick w/3
assert_sticky w/1 true
assert_sticky w/2 false
assert_sticky w/3 true
destroy w/3
destroy w/2
destroy w/1