Xvfb - Browser window does not fit display
Asked Answered
E

3

8

I'm trying to run a web browser in a virtual display, using the Python library pyvirtualdisplay, which relies on Xvfb. The problem is that I need that browser to be maximized, something I'm not achieving. I start a display with a size of 1024x768, but the browser just takes a portion of the screen, and can't maximize it. I even tried to run the browser with flags that should open it maximized (google-chrome -start-maximized), with no success. As there is no button to maximize the window, I tried pressing F11 to enter in full screen mode, but just takes the same portion of the screen. The result can be seen in the image below:

enter image description here

The code I use to start the display:

from pyvirtualdisplay import Display

Display(visible=1, size=(1024,768)).start()
Eufemiaeugen answered 12/8, 2013 at 8:37 Comment(0)
E
3

Problem was that I was not using a window manager, so installing Fluxbox (a lightweight one) and running it after starting the virtual display did the trick.

Eufemiaeugen answered 13/8, 2013 at 6:45 Comment(0)
E
6

For your Chrome parameters, specify the size and position:

chromium browser --window-size=1280,720 --window-position=0,0
Ealasaid answered 9/3, 2017 at 23:45 Comment(2)
This really helped me in getting rid of a black border around the chromium-browser. I eventually ran "--window-position=0,0 --window-size=375,375" and that forced away the 10 pixel black border around the browser. Thanks alot, Brad!Stork
Outstanding- works like a charm, and no additional program to run and keep track of as with fluxbox.Rutger
E
3

Problem was that I was not using a window manager, so installing Fluxbox (a lightweight one) and running it after starting the virtual display did the trick.

Eufemiaeugen answered 13/8, 2013 at 6:45 Comment(0)
A
2

I ran into the same problem. If you don't want to use a full window manager, the following should work pretty well:

import Xlib
import Xlib.display

### Create virtual display and open the browser here ###

dpy = Xlib.display.Display()
root = dpy.screen().root
geometry = root.get_geometry()
for win in root.query_tree().children:
    win.configure(x = 0, y = 0,
        width = geometry.width, height = geometry.height)
dpy.sync()
Arbitral answered 16/7, 2014 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.