# HG changeset patch # User Patrick Mezard # Date 2010-01-10 17:13:34 # Node ID 3af4b39afe2a6dca181722b7e876d69a6973596f # Parent 8e4be44a676ff64c924949464ad451d48d141061 cmdutil: hide child window created by win32 spawndetached() Hiding the child process window is not strictly necessary but it avoids opening an empty shell window when running hg serve as well as a task in the task bar. The window is hidden after the process is already started causing a single flicker. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -613,6 +613,7 @@ def service(opts, parentfn=None, initfn= except AttributeError: pass os.unlink(lockpath) + util.hidewindow() sys.stdout.flush() sys.stderr.flush() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -529,6 +529,14 @@ else: def lookup_reg(key, name=None, scope=None): return None +def hidewindow(): + """Hide current shell window. + + Used to hide the window opened when starting asynchronous + child process under Windows, unneeded on other systems. + """ + pass + if os.name == 'nt': from windows import * else: diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -16,7 +16,7 @@ used. import win32api import errno, os, sys, pywintypes, win32con, win32file, win32process -import winerror +import winerror, win32gui import osutil, encoding from win32com.shell import shell, shellcon @@ -172,3 +172,12 @@ def set_signal_handler_win32(): win32process.ExitProcess(1) win32api.SetConsoleCtrlHandler(handler) +def hidewindow(): + def callback(*args, **kwargs): + hwnd, pid = args + wpid = win32process.GetWindowThreadProcessId(hwnd)[1] + if pid == wpid: + win32gui.ShowWindow(hwnd, win32con.SW_HIDE) + + pid = win32process.GetCurrentProcessId() + win32gui.EnumWindows(callback, pid)