Beispiel #1
0
        private void ResizeEventCallback(IntPtr hWinEventHook, uint eventType, IntPtr hWnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            if (hWnd != IntPtr.Zero && idObject == 0 && idChild == 0)
            {
                NativeMethods.RECT rect;
                NativeMethods.GetWindowRect(hWnd, out rect);
                FullScreenApp     existingApp = null;
                ApplicationWindow window      = new ApplicationWindow(hWnd, tasksSvc);

                if (tasksSvc.Windows.Contains(window))
                {
                    // first check if this window is already in our list. if so, remove it if necessary
                    foreach (FullScreenApp app in FullScreenApps)
                    {
                        if (hWnd == app.hWnd)
                        {
                            if (rect.top == app.rect.top && rect.left == app.rect.left && rect.bottom == app.rect.bottom && rect.right == app.rect.right)
                            {
                                // no change, do nothing
                                return;
                            }
                            else
                            {
                                // there was a change
                                existingApp = app;
                            }
                            break;
                        }
                    }

                    // remove any changed windows we found
                    if (existingApp != null)
                    {
                        CairoLogger.Instance.Debug("Removing full screen app");
                        FullScreenApps.Remove(existingApp);
                        return;
                    }

                    // check if this is a new full screen app
                    foreach (Screen screen in Startup.screenState)
                    {
                        if (rect.top == screen.Bounds.Top && rect.left == screen.Bounds.Left && rect.bottom == screen.Bounds.Bottom && rect.right == screen.Bounds.Right)
                        {
                            // this is a full screen app on this screen
                            CairoLogger.Instance.Debug("Adding full screen app");
                            FullScreenApps.Add(new FullScreenApp {
                                hWnd = hWnd, screen = screen, rect = rect
                            });
                            break;
                        }
                    }
                }
            }
        }
        private void FullscreenCheck_Tick(object sender, EventArgs e)
        {
            IntPtr hWnd = GetForegroundWindow();

            List <FullScreenApp> removeApps = new List <FullScreenApp>();
            bool skipAdd = false;

            // first check if this window is already in our list. if so, remove it if necessary
            foreach (FullScreenApp app in FullScreenApps)
            {
                FullScreenApp appCurrentState = getFullScreenApp(app.hWnd);

                if (app.hWnd == hWnd && appCurrentState != null && app.screen == appCurrentState.screen)
                {
                    // this window, still same screen, do nothing
                    skipAdd = true;
                    continue;
                }

                if (appCurrentState == null || app.screen != appCurrentState.screen)
                {
                    removeApps.Add(app);
                }
            }

            // remove any changed windows we found
            if (removeApps.Count > 0)
            {
                CairoLogger.Instance.Debug("Removing full screen app(s)");
                foreach (FullScreenApp existingApp in removeApps)
                {
                    FullScreenApps.Remove(existingApp);
                }
            }

            // check if this is a new full screen app
            if (!skipAdd)
            {
                FullScreenApp appNew = getFullScreenApp(hWnd);
                if (appNew != null)
                {
                    CairoLogger.Instance.Debug("Adding full screen app");
                    FullScreenApps.Add(appNew);
                }
            }
        }