[gnome-shell] switcherPopup: Lookup index of items when hovering or clicking
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] switcherPopup: Lookup index of items when hovering or clicking
- Date: Wed, 26 Feb 2020 22:53:07 +0000 (UTC)
commit bf213af362d8ecf88a5e1c8af3d264470caf32a6
Author: Jonas Dreßler <verdre v0yd nl>
Date: Wed Jan 15 16:19:41 2020 +0100
switcherPopup: Lookup index of items when hovering or clicking
Right now the index that gets selected on click and motion events is set
when connecting the event inside the addItem function. If items are
added or removed (for example when an application is closed by pressing
"q"), this index isn't valid anymore and has to be updated.
To fix this, use the items themselves instead of the index as arguments
for the event handlers and lookup the index of the item inside the event
handler.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/167
js/ui/altTab.js | 4 +++-
js/ui/switcherPopup.js | 15 +++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 12b7849399..35d991e208 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -775,7 +775,9 @@ class AppSwitcher extends SwitcherPopup.SwitcherList {
// We override SwitcherList's _onItemEnter method to delay
// activation when the thumbnail list is open
- _onItemEnter(index) {
+ _onItemEnter(item) {
+ const index = this._items.indexOf(item);
+
if (this._mouseTimeOutId != 0)
GLib.source_remove(this._mouseTimeOutId);
if (this._altTabPopup.thumbnailsVisible) {
diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js
index 46a4b158ad..f7ee2e769f 100644
--- a/js/ui/switcherPopup.js
+++ b/js/ui/switcherPopup.js
@@ -427,9 +427,8 @@ var SwitcherList = GObject.registerClass({
bbox.set_child(item);
this._list.add_actor(bbox);
- let n = this._items.length;
- bbox.connect('clicked', () => this._onItemClicked(n));
- bbox.connect('motion-event', () => this._onItemEnter(n));
+ bbox.connect('clicked', () => this._onItemClicked(bbox));
+ bbox.connect('motion-event', () => this._onItemEnter(bbox));
bbox.label_actor = label;
@@ -452,14 +451,14 @@ var SwitcherList = GObject.registerClass({
this._items[index].remove_accessible_state(state);
}
- _onItemClicked(index) {
- this._itemActivated(index);
+ _onItemClicked(item) {
+ this._itemActivated(this._items.indexOf(item));
}
- _onItemEnter(index) {
+ _onItemEnter(item) {
// Avoid reentrancy
- if (index !== this._highlighted)
- this._itemEntered(index);
+ if (item !== this._items[this._highlighted])
+ this._itemEntered(this._items.indexOf(item));
return Clutter.EVENT_PROPAGATE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]