DPI change support for offscreen rendering.

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

DPI change support for offscreen rendering.

Postby sat » Mon Apr 10, 2017 4:02 am

I have windows app using cef (2704) to render page into the buffer. What exact steps must be made on WM_DPICHANGED message ?
I am doing next:
1. Calc new scale factor (float(HIWORD(wParam)) / USER_DEFAULT_SCREEN_DPI);
2. Call Browser->Host->NotifyScreenInfoChanged()
3. And my GetScreenInfo function is:
Code: Select all
bool
CefClientHandler::GetScreenInfo(
   CefRefPtr<CefBrowser> browser, CefScreenInfo& screen_info)
{
   screen_info.device_scale_factor = myScaleFactor;
   return true;
}

It seems to work, but I am not sure if this a right way to go ? Any suggestions/advises ?
sat
Techie
 
Posts: 20
Joined: Thu Mar 26, 2015 8:59 am

Re: DPI change support for offscreen rendering.

Postby magreenblatt » Mon Apr 10, 2017 10:47 am

Seems fine.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: DPI change support for offscreen rendering.

Postby sat » Tue Apr 18, 2017 5:08 am

Render works well but mouse event is weird.
E.g. I have a window with sized 100x100. After I change scale factor to 1.5 the window is resized to 150x150.
In JS windows.screen has same new size (150x150) and mouse events has right coords (0-150) but any HTML element inside has old coords/sizes. div at 50,50 with size 10,10 will render perfectly at 75,75 as 15,15 but it's mouseover event will be toggled only when mouse is at 50,50,10,10 and div.getBoundingClientRect() returns not scaled size/coords.
How this shall be handled ? anything beside dividing mouse coords on scale factor ?
sat
Techie
 
Posts: 20
Joined: Thu Mar 26, 2015 8:59 am

Re: DPI change support for offscreen rendering.

Postby magreenblatt » Tue Apr 18, 2017 9:40 am

Scale factor affects device coordinates. Browser content still operates at standard logical coordinates. If you want larger browser content you should use the zoom function.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 70 guests