-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring for CefWindowInfo. Use CefWindowInfo.Create() to create, …
…instead of default ctor!
- Loading branch information
1 parent
9e45ced
commit dba0059
Showing
18 changed files
with
544 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
namespace Xilium.CefGlue.Demo | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using WebBrowser = Xilium.CefGlue.Demo.Browser.WebBrowser; | ||
using System.Windows.Forms; | ||
using Xilium.CefGlue.Platform.Windows; | ||
using System.Runtime.InteropServices; | ||
|
||
public class CefWebView | ||
{ | ||
private bool _handleCreated; | ||
private WebBrowser _core; | ||
private IntPtr _browserWindowHandle; | ||
|
||
public CefWebView(string url, bool transparent = false) | ||
{ | ||
_core = new WebBrowser(this, new CefBrowserSettings(), url ?? "about:blank"); | ||
_core.Created += new EventHandler(BrowserCreated); | ||
|
||
var windowInfo = CefWindowInfo.Create(); | ||
windowInfo.SetAsPopup(IntPtr.Zero, null); | ||
windowInfo.Name = url; | ||
if (transparent) | ||
{ | ||
windowInfo.SetTransparentPainting(true); | ||
windowInfo.Width = 500; | ||
windowInfo.Height = 500; | ||
windowInfo.Style = WindowStyle.WS_POPUP | WindowStyle.WS_VISIBLE; | ||
} | ||
|
||
_core.Create(windowInfo); | ||
} | ||
|
||
private void BrowserCreated(object sender, EventArgs e) | ||
{ | ||
var handle = _core.CefBrowser.GetHost().GetWindowHandle(); | ||
|
||
//MARGINS mgMarInset = new MARGINS { leftWidth = -1, rightWidth = -1, topHeight = -1, bottomHeight = -1 }; | ||
//DwmExtendFrameIntoClientArea(handle, ref mgMarInset); | ||
} | ||
|
||
[DllImport("dwmapi.dll")] | ||
private static extern int DwmIsCompositionEnabled(out bool enabled); | ||
|
||
[DllImport("dwmapi.dll", PreserveSig = true)] | ||
private static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct MARGINS | ||
{ | ||
public int leftWidth; | ||
public int rightWidth; | ||
public int topHeight; | ||
public int bottomHeight; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
namespace Xilium.CefGlue.Platform | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xilium.CefGlue; | ||
using Xilium.CefGlue.Interop; | ||
using Xilium.CefGlue.Platform.Windows; | ||
|
||
internal unsafe sealed class CefWindowInfoLinuxImpl : CefWindowInfo | ||
{ | ||
private cef_window_info_t_linux* _self; | ||
|
||
public CefWindowInfoLinuxImpl() | ||
: base(true) | ||
{ | ||
_self = cef_window_info_t_linux.Alloc(); | ||
} | ||
|
||
public CefWindowInfoLinuxImpl(cef_window_info_t* ptr) | ||
: base(false) | ||
{ | ||
if (CefRuntime.Platform != CefRuntimePlatform.Linux) | ||
throw new InvalidOperationException(); | ||
|
||
_self = (cef_window_info_t_linux*)ptr; | ||
} | ||
|
||
internal override cef_window_info_t* GetNativePointer() | ||
{ | ||
return (cef_window_info_t*)_self; | ||
} | ||
|
||
protected internal override void DisposeNativePointer() | ||
{ | ||
cef_window_info_t_linux.Free(_self); | ||
_self = null; | ||
} | ||
|
||
public override IntPtr ParentHandle | ||
{ | ||
get { ThrowIfDisposed(); return _self->parent_widget; } | ||
set { ThrowIfDisposed(); _self->parent_widget = value; } | ||
} | ||
|
||
public override IntPtr Handle | ||
{ | ||
get { ThrowIfDisposed(); return _self->widget; } | ||
set { ThrowIfDisposed(); _self->widget = value; } | ||
} | ||
|
||
public override string Name | ||
{ | ||
get { return default(string); } | ||
set { } | ||
} | ||
|
||
public override int X | ||
{ | ||
get { return default(int); } | ||
set { } | ||
} | ||
|
||
public override int Y | ||
{ | ||
get { return default(int); } | ||
set { } | ||
} | ||
|
||
public override int Width | ||
{ | ||
get { return default(int); } | ||
set { } | ||
} | ||
|
||
public override int Height | ||
{ | ||
get { return default(int); } | ||
set { } | ||
} | ||
|
||
public override WindowStyle Style | ||
{ | ||
get { return default(WindowStyle); } | ||
set { } | ||
} | ||
|
||
public override WindowStyleEx StyleEx | ||
{ | ||
get { return default(WindowStyleEx); } | ||
set { } | ||
} | ||
|
||
public override IntPtr MenuHandle | ||
{ | ||
get { return default(IntPtr); } | ||
set { } | ||
} | ||
|
||
public override bool WindowRenderingDisabled | ||
{ | ||
get { return default(bool); } | ||
set { } | ||
} | ||
|
||
public override bool TransparentPainting | ||
{ | ||
get { return default(bool); } | ||
set { } | ||
} | ||
} | ||
} |
Oops, something went wrong.