Page 1 of 1

Toggle Device Bar

Posted: Thu Dec 03, 2020 5:13 pm
by thefunkyjoint
Is it possible to simulate Devtools 'Toggle Device Toolbar', using CEF4Delphi ? If so, how ?

I mean that button on Chrome Devtools where you can simulate other devices, like phones.

Re: Toggle Device Bar

Posted: Thu Dec 03, 2020 5:21 pm
by salvadordf

Re: Toggle Device Bar

Posted: Thu Dec 03, 2020 5:23 pm
by thefunkyjoint
:|

Re: Toggle Device Bar

Posted: Thu Dec 03, 2020 5:24 pm
by thefunkyjoint
Besides change the user agent, what else this option does ? It seems there are more things involved that simply changing the user agent, as i could not replicate 100% this feature by only changing the user agent... :?:

Re: Toggle Device Bar

Posted: Thu Dec 03, 2020 6:22 pm
by salvadordf
I'm not an expert but I guess the browser resolution and browser scale should be different too.

I haven't tried but --device-scale-factor seems to be used to force the renderer to use a fixed scale factor.

If that factor is calculated using the same formula as the scale factor in OSR mode then you have to do this : new_scale_factor = custom_DPI / 96

Re: Toggle Device Bar

Posted: Fri Dec 04, 2020 11:28 am
by thefunkyjoint
Thank you, will try this !

Re: Toggle Device Bar

Posted: Fri Dec 04, 2020 11:52 am
by salvadordf
Instead of a normal browser that would get the real screen resolution in your PC, try a browser in OSR mode.

Set the fake screen resolution in the TChromium.OnGetScreenInfo event and use the same size in the TChromium.OnGetViewRect event.
You can set the fake scale in those events too.

You will need to modify the TChromium.OnGetScreenPoint event too to use the fake resolution and scale.

Other events would have to be modified too. For example, you would need to convert the mouse coordinates to the new fake scale.