diff options
author | Vsevolod Kukol <sevoku@xamarin.com> | 2016-07-09 10:39:46 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@xamarin.com> | 2016-07-18 17:21:18 +0300 |
commit | ffeb89efa13cd6da6f6c9bfd3881a6f48cc7eb1c (patch) | |
tree | 004620d8aaa4ca639abfb02d1eed6d1d41207227 /main/src/core/MonoDevelop.Ide | |
parent | 5c3dda5eec479187520fcb196ece15bc91f9b475 (diff) |
[Ide] Fix Pad focused state detection
Control.HasFocus does not indicate whether the
Pad is focused or not. For a precise detection
we need to check if the Focus widget of the
Toplevel window is a child of the Pad.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide')
4 files changed, 33 insertions, 1 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs index 44d30e284d..22f9f71be5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItem.cs @@ -338,6 +338,21 @@ namespace MonoDevelop.Components.Docking frame.SetDockLocation (this, location); } + internal bool HasFocus { + get { + if (gtkContent.HasFocus || widget.HasFocus) + return true; + + Gtk.Window win = gtkContent.Toplevel as Gtk.Window; + if (win != null) { + if (Status == DockItemStatus.AutoHide) + return win.HasToplevelFocus; + return (win.HasToplevelFocus && win.Focus?.IsChildOf (widget) == true); + } + return false; + } + } + internal void SetFocus () { SetFocus (gtkContent); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs index 146bd082c8..c93d594450 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/GtkWorkarounds.cs @@ -1409,6 +1409,17 @@ namespace MonoDevelop.Components } } + public static bool IsChildOf (this Gtk.Widget child, Gtk.Widget widget) + { + var parent = child.Parent; + while (parent != null) { + if (parent == widget) + return true; + parent = parent.Parent; + }; + return false; + } + #if MAC static void OnMappedDisableButtons (object sender, EventArgs args) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs index 1b2f886975..a6c71bd1c5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DocumentSwitcher.cs @@ -652,7 +652,7 @@ namespace MonoDevelop.Ide Title = pad.Title, Tag = pad }; - if (pad.InternalContent.Initialized && pad.Window.Content.Control.HasFocus) + if (pad.InternalContent.Initialized && pad.Window.HasFocus) activeItem = item; padCategory.AddItem (item); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs index b366448645..a12a811b05 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/IPadContainer.cs @@ -88,6 +88,8 @@ namespace MonoDevelop.Ide.Gui /// will be automatically reset when the pad is made visible. /// </summary> bool HasNewData { get; set; } + + bool HasFocus { get; } /// <summary> /// Interface providing the content widget @@ -227,6 +229,10 @@ namespace MonoDevelop.Ide.Gui Item.Visible = value; } } + + public bool HasFocus { + get { return Item.HasFocus; } + } public bool AutoHide { get { |