From b88657ab837a0bb91cebf00a5298269bfdd04cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 26 Oct 2011 19:24:36 +0200 Subject: [PATCH] combo-box-menu-item: Propagate pseudo classes to the combo menu ComboBoxMenuItems use ClutterClones to reconstruct the active item in the associated ComboMenu, so pseudo class changes due to state changes of the ComboBoxMenuItem don't have the intended effect (since the actual style information is taken from the associated ComboBoxMenu item). As a fix, propagate relevant pseudo class changes to the active ComboBoxMenu item. https://bugzilla.gnome.org/show_bug.cgi?id=662799 --- js/ui/popupMenu.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 0c047487f..6aee9f419 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -108,14 +108,16 @@ PopupBaseMenuItem.prototype = { this.emit('activate', event); }, - setActive: function (active) { + setActive: function (active, params) { let activeChanged = active != this.active; + params = Params.parse (params, { grabKeyboard: true }); if (activeChanged) { this.active = active; if (active) { this.actor.add_style_pseudo_class('active'); - this.actor.grab_key_focus(); + if (params.grabKeyboard) + this.actor.grab_key_focus(); } else this.actor.remove_style_pseudo_class('active'); this.emit('active-changed', active); @@ -1522,6 +1524,22 @@ PopupComboMenu.prototype = { }, _onSourceActorStyleChanged: function() { + // PopupComboBoxMenuItem clones the active item's actors + // to work with arbitrary items in the menu; this means + // that we need to propagate some style information and + // enforce style updates even when the menu is closed + let activeItem = this._getMenuItems()[this._activeItemPos]; + if (this.sourceActor.has_style_pseudo_class('insensitive')) + activeItem.actor.add_style_pseudo_class('insensitive'); + else + activeItem.actor.remove_style_pseudo_class('insensitive'); + + // To propagate the :active style, we need to make sure that the + // internal state of the PopupComboMenu is updated as well, but + // we must not move the keyboard grab + activeItem.setActive(this.sourceActor.has_style_pseudo_class('active'), + { grabKeyboard: false }); + _ensureStyle(this.actor); },