public Handler(StreamWriter BarInput, StreamReader BarOutput) { HwndBlackList = new List <IntPtr>(); workspaces = new Dictionary <string, Workspace>(); handledWindows = new List <IntPtr>(); shellHookHelp = new shellHookHelper(this); Running = true; screens = new List <Screen>(Screen.AllScreens); sortScreenList(ref screens); openedWorkspace = "0"; RECT surface = screens[0].Bounds; //TODO: read from config int barHeight = 17; surface.Top = surface.Top + barHeight; workspaces.Add(openedWorkspace, new Workspace(this, surface)); Configuration = new Config.Configuration(); barInput = BarInput; barOutput = BarOutput; /* * JsonStructures.Workspace[] testws = new JsonStructures.Workspace[1]; * testws[0] = new JsonStructures.Workspace("lol"); * Workspaces test = new Workspaces(testws,1); */ titles = new Dictionary <IntPtr, string>(); winHook = new WinEventHook(WinEvents.EVENT_SYSTEM_FOREGROUND, WinEvents.EVENT_OBJECT_NAMECHANGE); winHook.Handle += eventReceiver; }
static void Main() { Console.WriteLine("BTWM is starting..."); // Base this on this executable's path string barCommand = Path.GetDirectoryName(Application.ExecutablePath) + "\\btwmbar.exe"; Config.Configuration config = new Config.Configuration(); string arguments = config.Bar.ToCommand(); Process barProcess = new Process(); ProcessStartInfo startInfo = barProcess.StartInfo; startInfo.FileName = barCommand; startInfo.Arguments = arguments; startInfo.UseShellExecute = false; startInfo.RedirectStandardInput = true; // send info to bar through stdin startInfo.RedirectStandardOutput = true; // receive info from bar through stdout barProcess.StartInfo = startInfo; barProcess.Start(); barProcess.WaitForInputIdle(); Handler mainHandler = new Handler(barProcess.StandardInput, barProcess.StandardOutput); while (mainHandler.Running) { //! This lets Windows know that the application is running and //! responding. (Without this it is impossible to receive any //! kind of native hook). Application.DoEvents(); } if (!barProcess.HasExited) { barProcess.Kill(); } }