RainbowMage / OverlayPlugin

Other
132 stars 182 forks source link

WS_EX_LAYERED #44

Open manbeardgames opened 8 years ago

manbeardgames commented 8 years ago

In OverlayForm.cs you have the following

        protected override System.Windows.Forms.CreateParams CreateParams
        {
            get
            {
                const int WS_EX_TOPMOST = 0x00000008;
                const int WS_EX_LAYERED = 0x00080000;
                const int CP_NOCLOSE_BUTTON = 0x200;

                var cp = base.CreateParams;
                cp.ExStyle = cp.ExStyle | WS_EX_TOPMOST | WS_EX_LAYERED;
                cp.ClassStyle = cp.ClassStyle | CP_NOCLOSE_BUTTON;

                return cp;
            }
        }

Using the WS_EX_LAYERED Extended Window Style causes issues for users who would like to capture the plugin with OBS on their stream, but can't disable Windows Aero. This isn't a huge issue for Windows 7 users, but Windows 8 and Windows 10 users can't disable Aero so easily.

I forked the code last night to see if I could get a proper stream version going. The solution I discovered was to have the Renderer's BeginRender method use .SetAsPopup instead of SetAsWindowless

        public void BeginRender(int width, int height, string url, int maxFrameRate = 30)
        {
            EndRender();

            var cefWindowInfo = CefWindowInfo.Create();
            cefWindowInfo.SetAsPopup(IntPtr.Zero, "MiniParse OBS Window");
            cefWindowInfo.StyleEx = Xilium.CefGlue.Platform.Windows.WindowStyleEx.WS_EX_TOPMOST;

            var cefBrowserSettings = new CefBrowserSettings();
            cefBrowserSettings.WindowlessFrameRate = maxFrameRate;

            this.Client = new Client(this, width, height);

            CefBrowserHost.CreateBrowser(
                cefWindowInfo,
                this.Client,
                cefBrowserSettings,
                url);
        }

However, this causes multiple popup windows to open when the plugin is first loaded. The easy solution to those is to just close them all out and click Reload Overlay. After this, everything is good to go, overlay is shown in a popup window, and it can be added to OBS as a window capture with no issues.

So, this issues is really to describe what happens when using this with OBS, but to also request a feature in the plugin. I currently do not have the available time to implement this. If possible, someone with access to write to the master, add the following changes:

Add a checkbox on the MiniParseConfigPanel to "Enable OBS Support". When a user clicks this, it reloads the overlay as a PopupWindow instead of a Windowless window within the OverlayForm.

Here is the link to my fork/branch for reference: https://github.com/dartvalince/OverlayPlugin

Thank you for taking the time to read this and hopefully make the changes.

fredgalvao commented 8 years ago

@dartvalince Is there any change you make a pull request for that? Also, do you know of any workaround to get the overlay working on OBS as a window capture on Windows 10? I appreciate any help!