-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
using System.Linq; | ||
|
||
namespace Eto.GtkSharp.Forms | ||
{ | ||
public class WindowHandler : Window.IWindowHandler | ||
{ | ||
public Window FromPoint(PointF point) | ||
{ | ||
var screenWindowStackWorks = false; | ||
var windowStack = Gdk.Screen.Default.WindowStack; | ||
// doesn't work on Mac.. can't figure out if it works on windows 🤔 | ||
if (windowStack != null) | ||
{ | ||
foreach (var gdkWindow in windowStack.Reverse()) | ||
{ | ||
screenWindowStackWorks = true; | ||
if (!gdkWindow.FrameExtents.Contains((int)point.X, (int)point.Y)) | ||
continue; | ||
|
||
foreach (var window in Application.Instance.Windows) | ||
{ | ||
if (window.Handler is IGtkWindow handler && handler.Control.Window?.Handle == gdkWindow.Handle) | ||
{ | ||
return window; | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!screenWindowStackWorks) | ||
{ | ||
// fallback to looking at all windows in no particular order. | ||
// TODO: this needs a proper implementation for Mac and possibly also for Windows, | ||
// depending on whether Screen.WindowStack actually works there. | ||
var pt = Point.Round(point); | ||
foreach (var window in Application.Instance.Windows) | ||
{ | ||
if (window.Bounds.Contains(pt)) | ||
{ | ||
return window; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
using System.Linq; | ||
#if XAMMAC2 | ||
using AppKit; | ||
using Foundation; | ||
using CoreGraphics; | ||
using ObjCRuntime; | ||
using CoreAnimation; | ||
#else | ||
using MonoMac.AppKit; | ||
using MonoMac.Foundation; | ||
using MonoMac.CoreGraphics; | ||
using MonoMac.ObjCRuntime; | ||
using MonoMac.CoreAnimation; | ||
#endif | ||
|
||
namespace Eto.Mac.Forms | ||
{ | ||
public class WindowHandler : Window.IWindowHandler | ||
{ | ||
public Window FromPoint(PointF point) | ||
{ | ||
var mainFrame = NSScreen.Screens[0].Frame; | ||
var nspoint = new CGPoint(point.X, mainFrame.Height - point.Y); | ||
var windowNumber = NSWindow.WindowNumberAtPoint(nspoint, 0); | ||
foreach (var window in Application.Instance.Windows) | ||
{ | ||
if (window.Handler is IMacWindow handler && handler.Control.WindowNumber == windowNumber) | ||
{ | ||
return window; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
|
||
namespace Eto.Wpf.Forms | ||
{ | ||
|
||
public class WindowHandler : Window.IWindowHandler | ||
{ | ||
internal static readonly object MovableByWindowBackground_Key = new object(); | ||
|
||
public Window FromPoint(PointF point) | ||
{ | ||
var screenPoint = point.LogicalToScreen(); | ||
var windowHandle = Win32.WindowFromPoint(new Win32.POINT(screenPoint.X, screenPoint.Y)); | ||
if (windowHandle == IntPtr.Zero) | ||
return null; | ||
windowHandle = Win32.GetAncestor(windowHandle, Win32.GA.GA_ROOT); | ||
|
||
foreach (var window in Application.Instance.Windows) | ||
{ | ||
if (window.NativeHandle == windowHandle) | ||
{ | ||
return window; | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters