Skip to content

Commit 7341cf5

Browse files
committed
Added a fix for #219, or so we hope. :) The thing is that we need to implement GetViewRect() and GetScreenRect() to force the popups to always be layouted inside the view; otherwise, we run into problems when the window is e.g. located close to the bottom screen border or similar.
1 parent aeed5f5 commit 7341cf5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CefSharp/RenderClientAdapter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,22 @@ namespace CefSharp
3737
{
3838
_renderBrowserControl->SetCursor((IntPtr)cursor);
3939
}
40+
41+
bool RenderClientAdapter::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect)
42+
{
43+
// The simulated screen and view rectangle are the same. This is necessary for popup menus to be located and sized inside
44+
// the view.
45+
int width, height;
46+
browser->GetSize(PET_VIEW, width, height);
47+
48+
rect.x = rect.y = 0;
49+
rect.width = width;
50+
rect.height = height;
51+
return true;
52+
}
53+
54+
bool RenderClientAdapter::GetScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect)
55+
{
56+
return GetViewRect(browser, rect);
57+
}
4058
}

CefSharp/RenderClientAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ namespace CefSharp
3030
virtual DECL void OnPopupSize(CefRefPtr<CefBrowser> browser,const CefRect& rect) OVERRIDE;
3131
virtual DECL void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer) OVERRIDE;
3232
virtual DECL void OnCursorChange(CefRefPtr<CefBrowser> browser, CefCursorHandle cursor) OVERRIDE;
33+
virtual DECL bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE;
34+
virtual DECL bool GetScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE;
3335
};
3436
}

0 commit comments

Comments
 (0)