Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions CefSharp.Wpf/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,31 +226,6 @@ namespace Wpf
type, mouseUp, e->ClickCount);
}

void WebView::OnVisualParentChanged(DependencyObject^ oldParent)
{
EventHandler^ _handler = gcnew EventHandler(this, &WebView::OnHidePopup);
Window^ window;

if (oldParent != nullptr)
{
window = Window::GetWindow(oldParent);
if (window != nullptr)
{
window->LocationChanged -= _handler;
window->Deactivated -= _handler;
}
}

window = Window::GetWindow(this);
if (window != nullptr)
{
window->LocationChanged += _handler;
window->Deactivated += _handler;
}

ContentControl::OnVisualParentChanged(oldParent);
}

Size WebView::ArrangeOverride(Size size)
{
CefRefPtr<CefBrowser> browser;
Expand Down Expand Up @@ -814,10 +789,27 @@ namespace Wpf
void WebView::OnLoaded(Object^ sender, RoutedEventArgs^ e)
{
AddSourceHook();

EventHandler^ _handler = gcnew EventHandler(this, &WebView::OnHidePopup);

currentWindow = Window::GetWindow(this);
if (currentWindow != nullptr)
{
currentWindow->LocationChanged += _handler;
currentWindow->Deactivated += _handler;
}
}

void WebView::OnUnloaded(Object^ sender, RoutedEventArgs^ e)
{
EventHandler^ _handler = gcnew EventHandler(this, &WebView::OnHidePopup);

if (currentWindow != nullptr)
{
currentWindow->LocationChanged -= _handler;
currentWindow->Deactivated -= _handler;
}

if (_source && _hook)
{
_source->RemoveHook(_hook);
Expand Down
2 changes: 1 addition & 1 deletion CefSharp.Wpf/WebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace Wpf
BrowserCore^ _browserCore;
MCefRefPtr<ScriptCore> _scriptCore;

Window^ currentWindow;
Object^ _sync;
HwndSource^ _source;
Matrix^ _matrix;
Expand Down Expand Up @@ -90,7 +91,6 @@ namespace Wpf
void AddSourceHook();

protected:
virtual void OnVisualParentChanged(DependencyObject^ oldParent) override;
virtual Size ArrangeOverride(Size size) override;
virtual void OnGotFocus(RoutedEventArgs^ e) override;
virtual void OnLostFocus(RoutedEventArgs^ e) override;
Expand Down