示例#1
0
文件: Window.cs 项目: nikku/dawsome
 internal WindowBase(WindowBase window)
 {
     this.hWnd = window.hWnd;
     this.rootOwner = window.rootOwner;
 }
示例#2
0
文件: Dawsome.cs 项目: nikku/dawsome
        private void ForceForegroundWindow(WindowBase window)
        {
            var hWnd = NativeMethods.GetLastActivePopup(window.rootOwner);

            if (Utilities.WindowIsNotHung(hWnd))
            {
                var foregroundWindow = NativeMethods.GetForegroundWindow();
                if (foregroundWindow != hWnd)
                {
                    if (foregroundWindow == IntPtr.Zero)
                    {
                        TrySetForegroundWindow(hWnd);
                    }
                    else if (Utilities.WindowIsNotHung(foregroundWindow))
                    {
                        var foregroundWindowThreadId = NativeMethods.GetWindowThreadProcessId(foregroundWindow, IntPtr.Zero);
                        if (NativeMethods.AttachThreadInput(this.dawsomeThreadId, foregroundWindowThreadId, true))
                        {
                            var targetWindowThreadId = NativeMethods.GetWindowThreadProcessId(hWnd, IntPtr.Zero);
                            var successfullyAttached = foregroundWindowThreadId != targetWindowThreadId &&
                                NativeMethods.AttachThreadInput(foregroundWindowThreadId, targetWindowThreadId, true);

                            TrySetForegroundWindow(hWnd);

                            if (successfullyAttached)
                            {
                                NativeMethods.AttachThreadInput(foregroundWindowThreadId, targetWindowThreadId, false);
                            }
                            NativeMethods.AttachThreadInput(this.dawsomeThreadId, foregroundWindowThreadId, false);
                        }
                    }
                }
                else
                {
                    NativeMethods.BringWindowToTop(hWnd);
                }
            }
        }
示例#3
0
文件: Dawsome.cs 项目: nikku/dawsome
        private void ActivateWindow(WindowBase window)
        {
            if (NativeMethods.IsIconic(window.hWnd))
            {
                // OpenIcon does not restore the window to its previous size (e.g. maximized)
                // ShowWindow(SW_RESTORE) doesn't redraw some windows correctly (like TortoiseHG commit window)
                Utilities.RestoreApplication(window.hWnd);
                System.Threading.Thread.Sleep(NativeMethods.minimizeRestoreDelay);
            }

            ForceForegroundWindow(window);
            CurrentWorkspace.WindowActivated(window.hWnd);
        }
示例#4
0
文件: Dawsome.cs 项目: nikku/dawsome
 private void FollowWindow(Workspace fromWorkspace, Workspace toWorkspace, bool follow, WindowBase window)
 {
     if (follow)
     {
         SwitchToWorkspace(toWorkspace.id, false);
         ActivateWindow(window);
     }
     else if (fromWorkspace.IsCurrentWorkspace)
     {
         DoForTopmostWindowForWorkspace(CurrentWorkspace, ActivateWindow);
     }
 }