internal void hideIfNotHovering() { Point cursorPos = Cursor.Position; if (!DesktopBounds.Contains(cursorPos)) { moveAway(); } }
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { int eventType = wParam.ToInt32(); if (eventType == NativeMethods.WM_MOUSEWHEEL && IsCursorOverBrowser) { browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Program.UserConfig.NotificationScrollSpeed * 0.01), CefEventFlags.None); return(NativeMethods.HOOK_HANDLED); } else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)) { int extraButton = NativeMethods.GetMouseHookData(lParam); if (extraButton == 2) // forward button { this.InvokeAsyncSafe(FinishCurrentNotification); } else if (extraButton == 1) // back button { this.InvokeAsyncSafe(Close); } blockXButtonUp = true; this.InvokeAsyncSafe(() => TriggerAnalyticsEvent(AnalyticsFile.Event.NotificationExtraMouseButton)); return(NativeMethods.HOOK_HANDLED); } else if (eventType == NativeMethods.WM_XBUTTONUP && blockXButtonUp) { blockXButtonUp = false; if (!Visible) { StopMouseHook(false); } return(NativeMethods.HOOK_HANDLED); } } return(NativeMethods.CallNextHookEx(mouseHook, nCode, wParam, lParam)); }
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode == 0) { int eventType = wParam.ToInt32(); if (eventType == NativeMethods.WM_MOUSEWHEEL && browser.Bounds.Contains(PointToClient(Cursor.Position)) && !ContainsFocus && !owner.ContainsFocus) { browser.SendMouseWheelEvent(0, 0, 0, NativeMethods.GetMouseHookData(lParam), CefEventFlags.None); return(NativeMethods.HOOK_HANDLED); } else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)) { int extraButton = NativeMethods.GetMouseHookData(lParam); if (extraButton == 2) // forward button { this.InvokeAsyncSafe(FinishCurrentNotification); } else if (extraButton == 1) // back button { this.InvokeAsyncSafe(Close); } blockXButtonUp = true; return(NativeMethods.HOOK_HANDLED); } else if (eventType == NativeMethods.WM_XBUTTONUP && blockXButtonUp) { blockXButtonUp = false; if (!Visible) { StopMouseHook(false); } return(NativeMethods.HOOK_HANDLED); } } return(NativeMethods.CallNextHookEx(mouseHook, nCode, wParam, lParam)); }