Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xvfb - Browser window does not fit display

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()
like image 938
davids Avatar asked Aug 12 '13 08:08

davids


3 Answers

For your Chrome parameters, specify the size and position:

chromium browser --window-size=1280,720 --window-position=0,0
like image 121
Brad Avatar answered Oct 22 '22 22:10

Brad


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.

like image 3
davids Avatar answered Oct 22 '22 22:10

davids


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()
like image 1
Talia Avatar answered Oct 22 '22 21:10

Talia