Skip to content

Commit e2cb99a

Browse files
committed
window-list/gwl: Simplify window focus updates.
Instead of starting at the primary window and iterating thru transients to check for focus, check the MetaDisplay's focus-window to see if the primary window is an ancestor. Cjs seems to have an issue nesting the meta_window_foreach_transient closure inside the notify closure for the window 'appears-focused' property. This causes a reference count warning for GClosure, and occasionally a crash. This is reproducible with a normal GtkDialog with a transient parent set, and toggle the window list item for the application.
1 parent c0e6a43 commit e2cb99a

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

files/usr/share/cinnamon/applets/[email protected]/appGroup.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,10 @@ const getFocusState = function(metaWindow) {
5454
return true;
5555
}
5656

57-
let transientHasFocus = false;
58-
metaWindow.foreach_transient(function(transient) {
59-
if (transient && transient.appears_focused) {
60-
transientHasFocus = true;
61-
return false;
62-
}
57+
if (global.display.focus_window && metaWindow.is_ancestor_of_transient(global.display.focus_window))
6358
return true;
64-
});
65-
return transientHasFocus;
59+
60+
return false;
6661
};
6762

6863
class AppGroup {

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,21 +553,16 @@ class AppMenuButton {
553553
}
554554

555555
_hasFocus() {
556-
if (this.metaWindow.minimized)
556+
if (!this.metaWindow || this.metaWindow.minimized)
557557
return false;
558558

559559
if (this.metaWindow.has_focus())
560560
return true;
561561

562-
let transientHasFocus = false;
563-
this.metaWindow.foreach_transient(function(transient) {
564-
if (transient.has_focus()) {
565-
transientHasFocus = true;
566-
return false;
567-
}
562+
if (global.display.focus_window && this.metaWindow.is_ancestor_of_transient(global.display.focus_window))
568563
return true;
569-
});
570-
return transientHasFocus;
564+
565+
return false
571566
}
572567

573568
onFocus() {

0 commit comments

Comments
 (0)