Skip to content

Commit 324adee

Browse files
authored
Merge pull request #2836 from MahApps/develop
Merging content for 1.4.3 develop to master
2 parents 8709b27 + 41fd0a4 commit 324adee

12 files changed

Lines changed: 195 additions & 22 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# PLEASE READ BEFORE POSTING AN ISSUE
2+
3+
This is a place for issues for MahApps itself. Questions are better asked in the [Gitter](https://gitter.im/MahApps/MahApps.Metro) room or at [stackoverflow](http://stackoverflow.com/questions/tagged/mahapps.metro).
4+
5+
### Seriously consider creating and linking to a test repo which takes absolutely minimal setup to illustrate how reproduce the problem.
6+
7+
My time is limited and .Zip files, code snippets and partial examples are often a time sink. GitHub also provides great communication and code review tools which can be utilised.
8+
9+
## HOW TO POST A GOOD SAMPLE.
10+
11+
Follow these guidelines and I will most likely look at the issue sooner:
12+
13+
* Post a full GitHub repository. Not a zip file, half baked snippet etc. If GitHub is new to you consider it a great learning opportunity and chance to get involved.
14+
* The repository should have just ONE step max for me to get running, and that is "Restore NuGet Packages". If there are any other missing dependencies, or uncompiling features I will most likely move on to another issue.
15+
* I'm not trying to be awkward. I'm just busy and I'm helping a lot of people, not just you, so help me out and I will help you out.
16+
17+
118
## What steps will reproduce this issue?
219

320
_Write problem description here_
@@ -6,11 +23,13 @@ _Write problem description here_
623

724
_Write expected outcome here_
825

26+
### Repo
27+
28+
_Link to the Repo_
929

10-
--
1130
### Environment
1231

1332
- MahApps.Metro __v?.?.?__
14-
- Windows __??__
33+
- Windows OS __??__
1534
- Visual Studio __20xx__
1635
- .NET Framework __?.?__

docs/logo.svg

Lines changed: 65 additions & 0 deletions
Loading

docs/logo.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<UserControl x:Class="MaterialBlend.MahApps"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MaterialBlend"
7+
mc:Ignorable="d" Height="349.5" Width="342.727">
8+
<Grid>
9+
<Path Data="M204.10463,161.30817 C193.68001,161.19063 185.10269,163.60248 185.10269,163.60248 144.24985,171.9998 120.99989,223.49998 99.499748,221.00005 84.499748,221.00005 58.999649,188.00003 58.499645,192.49994 57.999649,196.99985 61.999672,308.50076 131.99968,313.50076 191.99968,318.50037 238.5,249.25021 238.5,249.25021 L239.29802,249.91621 C239.29802,249.91621 285.79837,319.16635 345.79837,314.16675 415.79837,309.16675 419.79837,197.66585 419.29837,193.16594 418.79837,188.66603 393.29828,221.66603 378.29828,221.66603 356.79816,224.166 333.54819,172.66577 292.69534,164.26848 292.69534,164.26848 274.54831,159.16573 258.96503,164.16626 252.94939,166.74416 246.1281,168.73558 239.73712,173.507 L239.32588,173.8278 238.06091,172.84102 C231.66992,168.06958 224.84865,166.07816 218.83302,163.50027 213.96324,161.93761 208.84311,161.36159 204.10463,161.30817 z M237.5,0.5 C368.39148,0.5 474.5,106.60851 474.5,237.5 474.5,368.39148 368.39148,474.5 237.5,474.5 106.60851,474.5 0.5,368.39148 0.5,237.5 0.5,106.60851 106.60851,0.5 237.5,0.5 z" Fill="#FF0071BD" Stretch="Fill" Stroke="Black"/>
10+
11+
</Grid>
12+
</UserControl>

docs/release-notes/1.4.3.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 1.4.3 Notes
2+
3+
## Changes / Fixes
4+
5+
- Fix Flyout AutoClose sample
6+
- Try to handle call fail of GetPhysicalCursorPos. [#2830](https://github.com/MahApps/MahApps.Metro/issues/2830)
7+
8+
## Closed Issues
9+
10+
- [#2832](https://github.com/MahApps/MahApps.Metro/issues/2832) Wrong window maximize on two monitor systems.
11+
- [#2830](https://github.com/MahApps/MahApps.Metro/issues/2830) GetPhysicalCursorPos

src/MahApps.Metro.Build/MahApps.Metro.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
33
<metadata>
44
<id>MahApps.Metro</id>
5-
<version>1.4.2.0</version>
5+
<version>1.4.3.0</version>
66
<title>MahApps.Metro</title>
77
<authors>Jan Karger, Dennis Daume, Brendan Forster, Paul Jenkins, Jake Ginnivan, Alex Mitchell</authors>
88
<owners>punker76,shiftkey,aeoth,jakeginnivan</owners>

src/MahApps.Metro.Samples/MahApps.Metro.Demo/MahApps.Metro.Demo.Shared/ExampleWindows/FlyoutDemo.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private void ShowDynamicFlyout(object sender, RoutedEventArgs e)
185185

186186
private void ShowAutoCloseFlyout(object sender, RoutedEventArgs e)
187187
{
188-
this.ToggleFlyout(12);
188+
this.ToggleFlyout(13);
189189
}
190190

191191
private async void ClickMeOnClick(object sender, RoutedEventArgs e)

src/MahApps.Metro/MahApps.Metro.Shared/Behaviours/BorderlessWindowBehavior.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ private void HandleMaximize()
327327
var monitorInfo = new MONITORINFO();
328328
UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);
329329

330-
var x = monitorInfo.rcMonitor.left;
331-
var y = monitorInfo.rcMonitor.top;
332-
var cx = Math.Abs(monitorInfo.rcMonitor.right - x);
333-
var cy = Math.Abs(monitorInfo.rcMonitor.bottom - y);
330+
var desktopRect = ignoreTaskBar ? monitorInfo.rcMonitor : monitorInfo.rcWork;
331+
var x = desktopRect.left;
332+
var y = desktopRect.top;
333+
var cx = Math.Abs(desktopRect.right - x);
334+
var cy = Math.Abs(desktopRect.bottom - y);
334335

335336
if (ignoreTaskBar && this.isWindwos10OrHigher)
336337
{

src/MahApps.Metro/MahApps.Metro.Shared/Controls/GlowWindow.xaml.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,11 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
299299
case WM.LBUTTONDOWN:
300300
if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
301301
{
302-
var pt = WinApiHelper.GetRelativeMousePosition(this.handle);
303-
NativeMethods.PostMessage(this.ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)this.getHitTestValue(pt, rect), IntPtr.Zero);
302+
Point pt;
303+
if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
304+
{
305+
NativeMethods.PostMessage(this.ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)this.getHitTestValue(pt, rect), IntPtr.Zero);
306+
}
304307
}
305308
break;
306309
case WM.NCHITTEST:
@@ -313,8 +316,11 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
313316
{
314317
if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
315318
{
316-
var pt = WinApiHelper.GetRelativeMousePosition(this.handle);
317-
cursor = this.getCursor(pt, rect);
319+
Point pt;
320+
if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
321+
{
322+
cursor = this.getCursor(pt, rect);
323+
}
318324
}
319325
}
320326
if (cursor != null && cursor != this.Cursor)

src/MahApps.Metro/MahApps.Metro.Shared/Controls/MetroWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
12461246
// tage from DragMove internal code
12471247
window.VerifyAccess();
12481248

1249-
var cursorPos = WinApiHelper.GetPhysicalCursorPos();
1249+
//var cursorPos = WinApiHelper.GetPhysicalCursorPos();
12501250

12511251
// if the window is maximized dragging is only allowed on title bar (also if not visible)
12521252
var windowIsMaximized = window.WindowState == WindowState.Maximized;
@@ -1261,7 +1261,7 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
12611261

12621262
if (windowIsMaximized)
12631263
{
1264-
var cursorXPos = cursorPos.x;
1264+
//var cursorXPos = cursorPos.x;
12651265
EventHandler windowOnStateChanged = null;
12661266
windowOnStateChanged = (sender, args) =>
12671267
{

src/MahApps.Metro/MahApps.Metro.Shared/Controls/WinApiHelper.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,33 @@ public static System.Windows.Point GetRelativeMousePosition(IntPtr hWnd)
1919
return new System.Windows.Point(point.x, point.y);
2020
}
2121

22+
/// <summary>
23+
/// Try to get the relative mouse position to the given handle in client coordinates.
24+
/// </summary>
25+
/// <param name="hWnd">The handle for this method.</param>
26+
public static bool TryGetRelativeMousePosition(IntPtr hWnd, out System.Windows.Point point)
27+
{
28+
Standard.POINT pt = new Standard.POINT();
29+
var returnValue = hWnd != IntPtr.Zero && Standard.NativeMethods.TryGetPhysicalCursorPos(out pt);
30+
if (returnValue)
31+
{
32+
Standard.NativeMethods.ScreenToClient(hWnd, ref pt);
33+
point = new System.Windows.Point(pt.x, pt.y);
34+
}
35+
else
36+
{
37+
point = new System.Windows.Point();
38+
}
39+
return returnValue;
40+
}
41+
2242
internal static Standard.POINT GetPhysicalCursorPos()
2343
{
2444
try
2545
{
46+
// Sometimes Win32 will fail this call, such as if you are
47+
// not running in the interactive desktop. For example,
48+
// a secure screen saver may be running.
2649
return Standard.NativeMethods.GetPhysicalCursorPos();
2750
}
2851
catch (Exception exception)

0 commit comments

Comments
 (0)