Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorVsevolod Kukol <sevoku@microsoft.com>2019-07-03 23:52:51 +0300
committerGitHub <noreply@github.com>2019-07-03 23:52:51 +0300
commit7897c62d20407aecb1fcdd1e1ab4eb46ddf637bf (patch)
treeb8b53678ab369d84e59065f974d8df545a90653d /main
parent378dc27434b11684decdaf7517ca1023166bad33 (diff)
parent64c49c45cad7a0c15d18ccf2447b7a1b2b65c790 (diff)
Merge pull request #8044 from mono/backport-pr-8032-to-release-8.2
[release-8.2] Adds a ZOrder system based in GtkNSViewHost
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolbox.cs153
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolboxWidget.cs8
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ClickedButton.cs26
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/SearchTextField.cs16
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ToggleButton.cs18
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxPad.cs25
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs10
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/SplitterMacHostWidget.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/HPanedThin.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/DragEventTrapView.cs9
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/GtkNSViewHost.cs43
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/Messaging.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/NSViewExtensions.cs80
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj1
14 files changed, 133 insertions, 263 deletions
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolbox.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolbox.cs
index cc7f53b0a3..d94a8bbc68 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolbox.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolbox.cs
@@ -41,13 +41,6 @@ using MonoDevelop.Components.Mac;
namespace MonoDevelop.DesignerSupport.Toolbox
{
- interface INativeChildView
- {
- event EventHandler Focused;
- void OnKeyPressed (object o, Gtk.KeyPressEventArgs ev);
- void OnKeyReleased (object o, Gtk.KeyReleaseEventArgs ev);
- }
-
class MacToolbox : NSStackView, IPropertyPadProvider, IToolboxConfiguration
{
const string ToolboxItemContextMenuCommand = "/MonoDevelop/DesignerSupport/ToolboxItemContextMenu";
@@ -60,7 +53,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
public event EventHandler DragBegin;
public event EventHandler DragSourceUnset;
public event EventHandler<Gtk.TargetEntry []> DragSourceSet;
- public event EventHandler ContentFocused;
public ItemToolboxNode SelectedNode => toolboxWidget.SelectedItem?.Node;
@@ -108,10 +100,8 @@ namespace MonoDevelop.DesignerSupport.Toolbox
filterEntry.AccessibilityTitle = GettextCatalog.GetString ("Search Toolbox");
filterEntry.AccessibilityHelp = GettextCatalog.GetString ("Enter a term to search for it in the toolbox");
filterEntry.Activated += FilterTextChanged;
- filterEntry.Focused += FilterEntry_Focused;
horizontalStackView.AddArrangedSubview (filterEntry);
- AddWidgetToFocusChain (filterEntry);
filterEntry.SetContentCompressionResistancePriority ((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
filterEntry.SetContentHuggingPriorityForOrientation ((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
@@ -122,10 +112,8 @@ namespace MonoDevelop.DesignerSupport.Toolbox
catToggleButton.ToolTip = GettextCatalog.GetString ("Show categories");
catToggleButton.AccessibilityHelp = GettextCatalog.GetString ("Toggle to show categories");
catToggleButton.Activated += ToggleCategorisation;
- catToggleButton.Focused += CatToggleButton_Focused;
horizontalStackView.AddArrangedSubview (catToggleButton);
- AddWidgetToFocusChain (catToggleButton);
catToggleButton.SetContentCompressionResistancePriority ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
catToggleButton.SetContentHuggingPriorityForOrientation ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
@@ -136,10 +124,8 @@ namespace MonoDevelop.DesignerSupport.Toolbox
compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString ("Compact Layout");
compactModeToggleButton.AccessibilityHelp = GettextCatalog.GetString ("Toggle for toolbox to use compact layout");
compactModeToggleButton.Activated += ToggleCompactMode;
- compactModeToggleButton.Focused += CompactModeToggleButton_Focused;
horizontalStackView.AddArrangedSubview (compactModeToggleButton);
- AddWidgetToFocusChain (compactModeToggleButton);
compactModeToggleButton.SetContentCompressionResistancePriority ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
compactModeToggleButton.SetContentHuggingPriorityForOrientation ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
@@ -150,10 +136,8 @@ namespace MonoDevelop.DesignerSupport.Toolbox
toolboxAddButton.AccessibilityHelp = GettextCatalog.GetString ("Add toolbox items");
toolboxAddButton.ToolTip = GettextCatalog.GetString ("Add toolbox items");
toolboxAddButton.Activated += ToolboxAddButton_Clicked;
- toolboxAddButton.Focused += ToolboxAddButton_Focused;
horizontalStackView.AddArrangedSubview (toolboxAddButton);
- AddWidgetToFocusChain (toolboxAddButton);
toolboxAddButton.SetContentCompressionResistancePriority ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
toolboxAddButton.SetContentHuggingPriorityForOrientation ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
@@ -163,7 +147,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
toolboxWidget = new MacToolboxWidget (container) {
AccessibilityTitle = GettextCatalog.GetString ("Toolbox Toolbar"),
};
- AddWidgetToFocusChain (toolboxWidget);
var scrollView = new NSScrollView () {
HasVerticalScroller = true,
@@ -181,7 +164,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
filterEntry.Changed += FilterEntry_Changed;
toolboxWidget.DragBegin += ToolboxWidget_DragBegin;
- toolboxWidget.MouseDownActivated += ToolboxWidget_MouseDownActivated;
toolboxWidget.ActivateSelectedItem += ToolboxWidget_ActivateSelectedItem;
toolboxWidget.MenuOpened += ToolboxWidget_MenuOpened;
toolboxWidget.RegionCollapsed += FilterTextChanged;
@@ -216,26 +198,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
Refilter ();
}
- void ToolboxAddButton_Focused (object sender, EventArgs e)
- {
- ChangeFocusedView (sender as INativeChildView);
- }
-
- void CompactModeToggleButton_Focused (object sender, EventArgs e)
- {
- ChangeFocusedView (sender as INativeChildView);
- }
-
- void CatToggleButton_Focused (object sender, EventArgs e)
- {
- ChangeFocusedView (sender as INativeChildView);
- }
-
- void FilterEntry_Focused (object sender, EventArgs e)
- {
- ChangeFocusedView (sender as INativeChildView);
- }
-
void ToolboxWidget_DragBegin (object sender, EventArgs e)
{
if (this.toolboxWidget.SelectedItem != null) {
@@ -243,116 +205,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
}
}
- void ToolboxWidget_MouseDownActivated (NSEvent obj)
- {
- ContentFocused?.Invoke (this, EventArgs.Empty);
- }
-
- internal void FocusSelectedView ()
- {
- if (Window == null) {
- return;
- }
- if (FocusedView is NSView focusView && Window.FirstResponder != focusView && focusView.AcceptsFirstResponder ()) {
- Window.MakeFirstResponder (focusView);
- }
- }
-
- public override bool BecomeFirstResponder ()
- {
- return false;
- }
-
- #region Focus Chain
-
- int focusedViewIndex = -1;
- INativeChildView FocusedView => focusedViewIndex == -1 ? null : responderViewChain [focusedViewIndex];
- List<INativeChildView> responderViewChain = new List<INativeChildView> ();
-
- void AddWidgetToFocusChain (INativeChildView view)
- {
- if (responderViewChain.Contains (view)) {
- return;
- }
- responderViewChain.Add (view);
- view.Focused -= View_Focused;
- view.Focused += View_Focused;
-
- if (focusedViewIndex == -1) {
- focusedViewIndex = 0;
- }
- }
-
- void View_Focused (object sender, EventArgs e)
- {
- ChangeFocusedView (sender as INativeChildView);
- }
-
- void ChangeFocusedView (INativeChildView view)
- {
- var index = responderViewChain.IndexOf (view);
- if (index != -1)
- focusedViewIndex = index;
- }
-
- void FocusPreviousItem (GLib.SignalArgs ev)
- {
- if (focusedViewIndex <= 0) {
- //leave element
- Window.ResignFirstResponder ();
- if (ev != null) {
- ev.RetVal = false;
- }
- } else {
- focusedViewIndex--;
- if (((NSView)FocusedView).Hidden) {
- FocusPreviousItem (ev);
- } else {
- Window.MakeFirstResponder ((NSView)FocusedView);
- }
- }
- }
-
- void FocusNextItem (GLib.SignalArgs ev)
- {
- if (focusedViewIndex >= responderViewChain.Count - 1) {
- //leave element
- Window.ResignFirstResponder ();
- if (ev != null) {
- ev.RetVal = false;
- }
- } else {
- focusedViewIndex++;
- if (((NSView)FocusedView).Hidden) {
- FocusNextItem (ev);
- } else {
- Window.MakeFirstResponder ((NSView)FocusedView);
- }
- }
- }
-
- #endregion
-
- internal void KeyReleased (object o, Gtk.KeyReleaseEventArgs ev)
- {
- ev.RetVal = true;
- }
-
- internal void OnKeyPressed (object o, Gtk.KeyPressEventArgs ev)
- {
- ev.RetVal = true;
- if (ev.Event.Key == Gdk.Key.Tab || ev.Event.Key == Gdk.Key.ISO_Left_Tab) {
- if (ev.Event.State == Gdk.ModifierType.ShiftMask) {
- FocusPreviousItem (ev);
- } else {
- FocusNextItem (ev);
- }
- return;
- }
-
- FocusedView?.OnKeyPressed (o, ev);
- }
-
#region Toolbar event handlers
void ToggleCompactMode (object sender, EventArgs e)
@@ -528,20 +380,15 @@ namespace MonoDevelop.DesignerSupport.Toolbox
{
if (disposing) {
filterEntry.Activated -= FilterTextChanged;
- filterEntry.Focused -= FilterEntry_Focused;
catToggleButton.Activated -= ToggleCategorisation;
- catToggleButton.Focused -= CatToggleButton_Focused;
compactModeToggleButton.Activated -= ToggleCompactMode;
- compactModeToggleButton.Focused -= CompactModeToggleButton_Focused;
toolboxAddButton.Activated -= ToolboxAddButton_Clicked;
- toolboxAddButton.Focused -= ToolboxAddButton_Focused;
toolboxWidget.ActivateSelectedItem -= ToolboxWidget_ActivateSelectedItem;
toolboxWidget.MenuOpened -= ToolboxWidget_MenuOpened;
- toolboxWidget.MouseDownActivated -= ToolboxWidget_MouseDownActivated;
toolboxWidget.DragBegin -= ToolboxWidget_DragBegin;
toolboxWidget.RegionCollapsed -= FilterTextChanged;
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolboxWidget.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolboxWidget.cs
index d8a6c9b2ce..519721942e 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolboxWidget.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/MacToolboxWidget.cs
@@ -39,7 +39,7 @@ using MonoDevelop.Components.Mac;
namespace MonoDevelop.DesignerSupport.Toolbox
{
[Register ("MacToolboxWidget")]
- class MacToolboxWidget : NSCollectionView, IToolboxWidget, INativeChildView
+ class MacToolboxWidget : NSCollectionView, IToolboxWidget
{
internal const string ImageViewItemName = "ImageViewItem";
internal const string LabelViewItemName = "LabelViewItem";
@@ -57,7 +57,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
public event EventHandler DragBegin;
public event EventHandler<CGPoint> MenuOpened;
public event EventHandler ActivateSelectedItem;
- public Action<NSEvent> MouseDownActivated { get; set; }
IPadWindow container;
NSTextField messageTextField;
@@ -256,11 +255,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox
public override void MouseDown (NSEvent theEvent)
{
- // MouseDownActivated needs to be called before logic activating toolbox item
- // because MacToolbox uses this event to focus GTK widget that hosts MacToolboxWidget
- // resulting into stealing focus from toolbox consumer that gains focus when toolbox item is activated
- MouseDownActivated?.Invoke (theEvent);
-
collectionViewDelegate.IsLastSelectionFromMouseDown = true;
base.MouseDown (theEvent);
if (SelectedItem != null && theEvent.ClickCount > 1) {
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ClickedButton.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ClickedButton.cs
index 6ee0f8eb2a..bf9627a161 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ClickedButton.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ClickedButton.cs
@@ -33,7 +33,7 @@ using MonoDevelop.Components.Mac;
namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
{
- class ClickedButton : NSButton, INativeChildView
+ class ClickedButton : NSButton
{
public event EventHandler Focused;
@@ -54,30 +54,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
Focused?.Invoke (this, EventArgs.Empty);
return base.BecomeFirstResponder ();
}
-
- #region INativeChildView
-
- public void OnKeyPressed (object o, Gtk.KeyPressEventArgs ev)
- {
- if (ev.Event.State == Gdk.ModifierType.None && (ev.Event.Key == Gdk.Key.KP_Enter || ev.Event.Key == Gdk.Key.KP_Space)) {
- PerformClick (this);
- }
- }
-
- public void OnKeyReleased (object o, Gtk.KeyReleaseEventArgs ev)
- {
-
- }
-
- public override void KeyDown (NSEvent theEvent)
- {
- base.KeyDown (theEvent);
- if ((int)theEvent.ModifierFlags == (int)KeyModifierFlag.None && (theEvent.KeyCode == (int)KeyCodes.Enter || theEvent.KeyCode == (int)KeyCodes.Space)) {
- PerformClick (this);
- }
- }
-
- #endregion
}
}
#endif \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/SearchTextField.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/SearchTextField.cs
index 79c024f1e9..819eaaf109 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/SearchTextField.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/SearchTextField.cs
@@ -32,7 +32,7 @@ using AppKit;
namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
{
- class SearchTextField : NSSearchField, INativeChildView
+ class SearchTextField : NSSearchField
{
public event EventHandler Focused;
@@ -46,20 +46,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
Focused?.Invoke (this, EventArgs.Empty);
return base.BecomeFirstResponder ();
}
-
- #region INativeChildView
-
- public void OnKeyPressed (object o, Gtk.KeyPressEventArgs ev)
- {
-
- }
-
- public void OnKeyReleased (object o, Gtk.KeyReleaseEventArgs ev)
- {
-
- }
-
- #endregion
}
}
#endif \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ToggleButton.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ToggleButton.cs
index e9b56395fe..a215e42f6b 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ToggleButton.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.Toolbox/NativeViews/ToggleButton.cs
@@ -34,7 +34,7 @@ using MonoDevelop.Components.Mac;
namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
{
- class ToggleButton : NSButton, INativeChildView
+ class ToggleButton : NSButton
{
public event EventHandler Focused;
@@ -69,22 +69,6 @@ namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
PerformClick (this);
}
}
-
- #region INativeChildView
-
- public void OnKeyPressed (object o, Gtk.KeyPressEventArgs ev)
- {
- if (ev.Event.State == Gdk.ModifierType.None && (ev.Event.Key == Gdk.Key.KP_Enter || ev.Event.Key == Gdk.Key.KP_Space)) {
- PerformClick (this);
- }
- }
-
- public void OnKeyReleased (object o, Gtk.KeyReleaseEventArgs ev)
- {
-
- }
-
- #endregion
}
}
#endif \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxPad.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxPad.cs
index cf0bf27251..e649a96d36 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxPad.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ToolboxPad.cs
@@ -55,21 +55,15 @@ namespace MonoDevelop.DesignerSupport
#if MAC
this.window = window;
toolbox = new Toolbox.MacToolbox (DesignerSupport.Service.ToolboxService, window);
- widget = GtkMacInterop.NSViewToGtkWidget (toolbox);
- widget.CanFocus = true;
- widget.Sensitive = true;
- widget.KeyPressEvent += toolbox.OnKeyPressed;
- widget.KeyReleaseEvent += toolbox.KeyReleased;
+ widget = new GtkNSViewHost (toolbox);
widget.DragDataGet += Widget_DragDataGet;
widget.DragBegin += Widget_DragBegin;
widget.DragEnd += Widget_DragEnd;
- widget.Focused += Widget_Focused;
this.window.PadContentShown += Container_PadContentShown;
this.window.PadContentHidden += Container_PadContentHidden;
- toolbox.ContentFocused += Toolbox_ContentFocused;
toolbox.DragSourceSet += Toolbox_DragSourceSet;
toolbox.DragBegin += Toolbox_DragBegin;
@@ -92,11 +86,6 @@ namespace MonoDevelop.DesignerSupport
isDragging = false;
}
- void Widget_Focused (object sender, EventArgs args)
- {
- toolbox.FocusSelectedView();
- }
-
void Widget_DragBegin (object sender, DragBeginArgs args)
{
if (!isDragging) {
@@ -120,14 +109,6 @@ namespace MonoDevelop.DesignerSupport
}
}
- void Toolbox_ContentFocused (object sender, EventArgs args)
- {
- if (!widget.HasFocus) {
- widget.HasFocus = true;
- toolbox.FocusSelectedView ();
- }
- }
-
void Toolbox_DragBegin (object sender, EventArgs args)
{
var selectedNode = toolbox.SelectedNode;
@@ -170,15 +151,11 @@ namespace MonoDevelop.DesignerSupport
widget.DragDataGet -= Widget_DragDataGet;
widget.DragBegin -= Widget_DragBegin;
widget.DragEnd -= Widget_DragEnd;
- widget.Focused -= Widget_Focused;
- widget.KeyPressEvent -= toolbox.OnKeyPressed;
- widget.KeyReleaseEvent -= toolbox.KeyReleased;
widget.Destroy ();
widget.Dispose ();
widget = null;
}
if (toolbox != null) {
- toolbox.ContentFocused -= Toolbox_ContentFocused;
toolbox.DragBegin -= Toolbox_DragBegin;
toolbox.DragSourceSet -= Toolbox_DragSourceSet;
toolbox.Dispose ();
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs
index 2dd13f38f1..00173c9d43 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockContainer.cs
@@ -161,16 +161,18 @@ namespace MonoDevelop.Components.Docking
int usedSplitters;
+ const int SplitterSize = 5;
+
internal void AllocateSplitter (DockGroup grp, int index, Gdk.Rectangle a)
{
var s = splitters[usedSplitters++];
if (a.Height > a.Width) {
- a.Width = 5;
- a.X -= 2;
+ a.Width = SplitterSize;
+ a.X -= (int)(SplitterSize / 2);
}
else {
- a.Height = 5;
- a.Y -= 2;
+ a.Height = SplitterSize;
+ a.Y -= (int)(SplitterSize / 2);
}
s.SizeAllocate (a);
s.Init (grp, index);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/SplitterMacHostWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/SplitterMacHostWidget.cs
index f0859dea41..4f6cd550eb 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/SplitterMacHostWidget.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/SplitterMacHostWidget.cs
@@ -42,7 +42,7 @@ namespace MonoDevelop.Components.Docking
public SplitterMacHostWidget ()
{
view = new MacSplitterWidget ();
- host = new GtkNSViewHost (view, AppKit.NSWindowOrderingMode.Above);
+ host = new GtkNSViewHost (view);
}
public Widget Parent => host.Parent;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/HPanedThin.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/HPanedThin.cs
index d7dce73991..8cfe8e8990 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/HPanedThin.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/HPanedThin.cs
@@ -160,7 +160,7 @@ namespace MonoDevelop.Components
horizontal = parent is HPanedThin;
handle = new MacPanedHandleView (parent);
- host = new Gtk.GtkNSViewHost (handle, NSWindowOrderingMode.Above);
+ host = new Gtk.GtkNSViewHost (handle);
GrabAreaSize = HandleGrabWidth;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/DragEventTrapView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/DragEventTrapView.cs
index f57f6fd6c5..ce2e77bf37 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/DragEventTrapView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/DragEventTrapView.cs
@@ -49,8 +49,11 @@ namespace MonoDevelop.Components.Mac
/// NOTE: this view should be added with NSWindowOrderingMode.Above to its superview, to
/// make sure the it's the first widget to receive pointer events.
/// </remarks>
- abstract class DragEventTrapView : NSView
+ abstract class DragEventTrapView : NSView, Gtk.INSViewOrdering
{
+ const int DefaultSplitterZOrder = 1000;
+ public int ZOrder => DefaultSplitterZOrder;
+
NSCursor currentCursor;
bool hover, dragging;
@@ -99,6 +102,7 @@ namespace MonoDevelop.Components.Mac
public override void MouseEntered (NSEvent theEvent)
{
+ AddGdkEventFilter ();
lastEventTimestamp = theEvent.Timestamp;
if (!dragging) {
SetDragCursor ();
@@ -112,6 +116,7 @@ namespace MonoDevelop.Components.Mac
lastEventTimestamp = theEvent.Timestamp;
if (!dragging) {
SetDefaultCursor ();
+ RemoveGdkEventFilter ();
}
hover = false;
base.MouseExited (theEvent);
@@ -130,8 +135,6 @@ namespace MonoDevelop.Components.Mac
{
lastEventTimestamp = theEvent.Timestamp;
dragging = true;
-
- AddGdkEventFilter ();
}
public override void MouseUp (NSEvent theEvent)
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/GtkNSViewHost.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/GtkNSViewHost.cs
index be3c2cdf5a..17999656f8 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/GtkNSViewHost.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/GtkNSViewHost.cs
@@ -24,13 +24,25 @@ using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-
using AppKit;
using CoreGraphics;
using ObjCRuntime;
+using Foundation;
namespace Gtk
{
+ /// <summary>
+ /// This interface helps to reorganize the ZOrder of a native view inside a GdkQuarz window
+ /// </summary>
+ public interface INSViewOrdering
+ {
+ /// <summary>
+ /// This parameter is taking into account when this viewhost is added.
+ /// More values means the view is on top of others
+ /// </summary>
+ public int ZOrder { get; }
+ }
+
public sealed class GtkNSViewHost : Widget
{
const string LIBGTKQUARTZ = "libgtk-quartz-2.0.dylib";
@@ -67,7 +79,6 @@ namespace Gtk
NSView view;
NSView superview;
bool sizeAllocated;
- NSWindowOrderingMode? zOrder;
public GtkNSViewHost (NSView view)
{
@@ -76,11 +87,6 @@ namespace Gtk
WidgetFlags |= WidgetFlags.NoWindow;
}
- public GtkNSViewHost (NSView view, NSWindowOrderingMode position) : this (view)
- {
- zOrder = position;
- }
-
void UpdateViewFrame ()
{
LogEnter ();
@@ -147,6 +153,20 @@ namespace Gtk
}
}
+ NSComparisonResult CompareViews (NSView view1, NSView view2)
+ {
+ if (view1 is INSViewOrdering viewOrdering1) {
+
+ if (view2 is INSViewOrdering viewOrdering2 && viewOrdering2.ZOrder >= viewOrdering1.ZOrder)
+ return NSComparisonResult.Ascending;
+ //view 1 on top
+ return NSComparisonResult.Descending;
+
+ }
+ //if view1 is not ordering view 2 on top
+ return NSComparisonResult.Ascending;
+ }
+
protected override void OnRealized ()
{
LogEnter ();
@@ -157,15 +177,12 @@ namespace Gtk
var superviewHandle = gdk_quartz_window_get_nsview (GdkWindow.Handle);
if (superviewHandle != IntPtr.Zero)
superview = Runtime.GetNSObject<NSView> (superviewHandle);
- }
+ }
if (superview != null && view != null) {
- if (zOrder.HasValue)
- superview.AddSubview (view, zOrder.Value, null);
- else
- superview.AddSubview (view);
+ superview.AddSubview (view);
+ superview.SortSubviews (CompareViews);
}
-
base.OnRealized ();
UpdateViewFrame ();
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/Messaging.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/Messaging.cs
index fecd358c0f..a22c65271e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/Messaging.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/Messaging.cs
@@ -61,6 +61,9 @@ namespace MonoDevelop.Components.Mac
[DllImport (LIBOBJC_DYLIB, EntryPoint="objc_msgSend")]
public static extern uint UInt32_objc_msgSend (IntPtr receiver, IntPtr selector);
+
+ [DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
+ public extern static void void_objc_msgSend_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, IntPtr arg2);
}
}
#endif
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/NSViewExtensions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/NSViewExtensions.cs
new file mode 100644
index 0000000000..9d7e89b4cc
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/NSViewExtensions.cs
@@ -0,0 +1,80 @@
+//
+// Author:
+// Rolf Kvinge <rolf@xamarin.com>
+//
+// Copyright (c) Microsoft Corp. (https://www.microsoft.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Runtime.InteropServices;
+using Foundation;
+using ObjCRuntime;
+
+namespace AppKit
+{
+ public static class NSViewExtensions
+ {
+ delegate nint view_compare_func (IntPtr view1, IntPtr view2, IntPtr context);
+ static view_compare_func view_comparer = view_compare;
+
+ sealed class SortData
+ {
+ public Exception Exception;
+ public Func<NSView, NSView, NSComparisonResult> Comparer;
+ }
+
+ [MonoPInvokeCallback (typeof (view_compare_func))]
+ static nint view_compare (IntPtr view1, IntPtr view2, IntPtr context)
+ {
+ var data = (SortData)GCHandle.FromIntPtr (context).Target;
+ try {
+ var a = (NSView)Runtime.GetNSObject (view1);
+ var b = (NSView)Runtime.GetNSObject (view2);
+ return (nint)(long)data.Comparer (a, b);
+ } catch (Exception e) {
+ data.Exception = e;
+ return (nint)(long)NSComparisonResult.Same;
+ }
+ }
+
+ public static void SortSubviews (this NSView view, Func<NSView, NSView, NSComparisonResult> comparer)
+ {
+ if (comparer == null)
+ throw new ArgumentNullException (nameof (comparer));
+
+ var func = Marshal.GetFunctionPointerForDelegate (view_comparer);
+ var context = new SortData () { Comparer = comparer };
+ var handle = GCHandle.Alloc (context);
+ try {
+ SortSubviews (view, func, GCHandle.ToIntPtr (handle));
+ if (context.Exception != null)
+ throw new Exception ($"An exception occurred during sorting.", context.Exception);
+ } finally {
+ handle.Free ();
+ }
+ }
+
+ static readonly IntPtr sel_sortSubviewsUsingFunction_context_ = Selector.GetHandle ("sortSubviewsUsingFunction:context:");
+ static void SortSubviews (NSView view, IntPtr function_pointer, IntPtr context)
+ {
+ MonoDevelop.Components.Mac.Messaging.void_objc_msgSend_IntPtr_IntPtr (view.Handle, sel_sortSubviewsUsingFunction_context_, function_pointer, context);
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
index 35329ccb92..4314bb4e98 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
@@ -4252,6 +4252,7 @@
<Compile Include="MonoDevelop.Components.Docking\SplitterMacHostWidget.cs" />
<Compile Include="MonoDevelop.Components\Mac\DragEventTrapView.cs" />
<Compile Include="MonoDevelop.Components\Mac\NativeToolkitHelper.cs" />
+ <Compile Include="MonoDevelop.Components\Mac\NSViewExtensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'DebugMac' OR '$(Configuration)' == 'ReleaseMac'">
<Compile Include="MonoDevelop.Components\Mac\KeyCodes.cs" />