- attached context menu.png
- changed component to Framework
-
assigned issue to
Windows: Add per monitor DPI support
Cef3 currently only support PROCESS_SYSTEM_DPI_AWARE, which has one issue in my current project, if I set my PROCESS_SYSTEM_DPI_AWARE in the application manually with windows API , instead of CefEnableHighDPISupport (PROCESS_SYSTEM_DPI_AWARE), then the right click context menu is always far away from the mouse pointer, eg. menu shows on the first monitor
int RunMain(HINSTANCE hInstance, int nCmdShow) { // Enable High-DPI support on Windows 7 or newer. //CefEnableHighDPISupport();
typedef HRESULT(__stdcall *SetProcessDPIAwareFunc)(PROCESS_DPI_AWARENESS); HMODULE hUser32 = LoadLibrary(L"Shcore.dll"); if (hUser32) { SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDpiAwareness"); setDPIAware(PROCESS_PER_MONITOR_DPI_AWARE); FreeLibrary(hUser32); }
CefMainArgs main_args(hInstance);
Comments (14)
-
reporter -
- changed status to wontfix
This needs to be supported by Chromium. You can star https://crbug.com/426656.
-
reporter https://bugs.chromium.org/p/chromium/issues/detail?id=426656#c101
Comment 101 by robliao@chromium.org, Nov 30 (3 days ago) ⚐ Labels: Restrict-AddIssueComment-EditIssue Hello everyone! Thanks for your feedback.
Chrome has been per-monitor DPI aware since http://crrev.com/23364eecc5d1bb1770f8c22a7c0a320154e3eac7.
Implementing per-monitor DPI is very tricky, and it's not surprising that there may be some issues floating around within Chrome or third-party extensions.
If you do encounter issues, please create a new issue for that. This issue is intended to track the overall progress of per-monitor DPI awareness.
-
- changed status to open
Re-opening this issue because per-monitor is now supported by Chromium.
Someone will need to examine the Chromium implementation in detail and propose the correct way to implement support in CEF.
-
Issue
#2320was marked as a duplicate of this issue. -
Chrome still has some issues with per-monitor dpi support as of M64. For example: https://bugs.chromium.org/p/chromium/issues/detail?id=656730#c15
-
Per-monitor dpi support has been added in master revision 57b9cf9, 3325 branch revision 2e7b0e4 and 3282 branch revision 8f26fe0.
Per-monitor dpi support will be enabled automatically when you call the CefEnableHighDPISupport() function if your Windows version supports it. When using the Views framework all controls will be scaled correctly without additional code changes. When embedding a CEF browser window (HWND) in another application you must:
- Test if per-monitor dpi is supported by calling the GetProcessDpiAwareness function if it exists.
- If your top-level HWND has a frame then call the EnableChildWindowDpiMessage or EnableNonClientDpiScaling function if they exist. This causes Windows to automatically scale the non-client area of the top-level HWND when the WM_DPICHANGED message is received.
- Resize child controls when the WM_DPICHANGED message is received by the top-level HWND.
- If using OSR, call NotifyScreenInfoChanged from WM_DPICHANGED and return the new scale factor from GetScreenInfo.
See the changes to cefclient for example usage.
There are some known issues with per-monitor dpi when the primary display is high-dpi and the application is launched on an external low-dpi monitor:
- Scroll bar are too thick (see https://bugs.chromium.org/p/chromium/issues/detail?id=656730#c15).
- Default JS dialog implementations (created internally using CreateDialogParam) are too large.
-
- changed title to Windows: Add per monitor DPI support
-
New functions for scaling dialogs are described here: https://blogs.windows.com/buildingapps/2017/04/04/high-dpi-scaling-improvements-desktop-applications-windows-10-creators-update/
-
-
Issue
#2232was marked as a duplicate of this issue. -
@Marshall Greenblatt can i just change the menu pos params?
-
Seems that this part covers the "resize child controls when WM_DPICHANGED message is received by top-level HWND":
cef_window_handle_t hWnd = m_cef_browser->GetHost()->GetWindowHandle();
#ifdef WIN32 ::SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(width(), height())); #endif
-
- changed status to resolved
I believe everything is working as expected with currently supported CEF versions. If anyone is aware of an existing problem with those versions we can re-open this issue.
- Log in to comment