Page 1 of 1

OSR Windows and Browser size

Posted: Tue Jul 03, 2018 8:37 am
by dilfich
Hi!
How can I specify the size of the browser and window? :?:
Test - https://browsersize.com/
OSR
Current:
Browser window size: 0 x 366
Screen size: 0 x 0
Real browser
Current:
Browser window size: 1488 x 751
Screen size: 1920 x 1080

Re: OSR Windows and Browser size

Posted: Tue Jul 03, 2018 8:45 am
by salvadordf
Hi,

If I remember correctly, you need to use the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

I would use all the events in the SimpleOSRBrowser demo and then take out what you don't really need.

Re: OSR Windows and Browser size

Posted: Tue Jul 03, 2018 9:50 am
by salvadordf
Demo
Current:
Browser window size: 366 x 366
Screen size: 366 x 366
Screen size not?
I tested this in the official CEF3 application (cefclient) and it has the same behavior when it uses the OSR mode.
The real screen size is ignored and it shows the window size instead... or almost the same if you resize the form violently.

Re: OSR Windows and Browser size

Posted: Sun Jul 08, 2018 7:44 pm
by dilfich
OSR is good.. And it is possible as that on visual to set the size of a window and the browser?

Re: OSR Windows and Browser size

Posted: Sun Jul 08, 2018 8:48 pm
by salvadordf
If you ignore the TChromium.OnPaint event or you replace TBufferPanel then you can set any size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

The window and browser sizes are not important if you give a custom size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

Re: OSR Windows and Browser size

Posted: Wed Jul 11, 2018 7:54 am
by dilfich
salvadordf wrote: Sun Jul 08, 2018 8:48 pm If you ignore the TChromium.OnPaint event or you replace TBufferPanel then you can set any size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

The window and browser sizes are not important if you give a custom size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

Code: Select all

procedure TFormGL.Chromium1GetScreenInfo(Sender: TObject; const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out Result: Boolean);
var
  TempRect : TCEFRect;
begin
  if (GlobalCEFApp <> nil) then
    begin
      TempRect.x      := 0;
      TempRect.y      := 0;
      TempRect.width  := 1080;
      TempRect.height := 1680;

      screenInfo.device_scale_factor := GlobalCEFApp.DeviceScaleFactor;
      screenInfo.depth               := 0;
      screenInfo.depth_per_component := 0;
      screenInfo.is_monochrome       := Ord(False);
      screenInfo.rect                := TempRect;
      screenInfo.available_rect      := TempRect;

      Result := True;
    end
   else
    Result := False;
end;

procedure TFormGL.Chromium1GetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean);
begin
  if (GlobalCEFApp <> nil) then
    begin
      rect.x      := 0;
      rect.y      := 0;
      rect.width  := 1000;
      rect.height := 600;
      Result      := True;
    end
   else
    Result := False;
end;
What's wrong with not working?
browsersize.com
Result
Browser window size: 531 x 409
Screen size: 1920 x 1080

Re: OSR Windows and Browser size

Posted: Wed Jul 11, 2018 8:35 am
by salvadordf
Those events are used in OSR mode only.
Remember that you need to convert the logical and device units with DeviceToLogical in case you have a high DPI monitor.

Use the SimpleOSRBrowser demo as a template for your application.