mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

Let x11docker set the best resolution for the container. #432

Closed hongyi-zhao closed 2 years ago

hongyi-zhao commented 2 years ago

See the following screenshot, I want to know if x11docker will pick the best resolution of the container automatically:

image

Regards, HZ

mviereck commented 2 years ago

x11docker automatically sets a window size size that is a bit smaller than your monitor. Use option --size if you prefer another window size.

hongyi-zhao commented 2 years ago

Will this option set a fixed size, as shown below?

$ x11docker|grep -- --size
     --size=WxH        Screen size of new X server (e.g. 800x600).

Based on the following results from xrandr, which one should I use as the best configuration?

$ xrandr 
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 598mm x 336mm
   1920x1080     60.00*+  74.97    59.96    50.00    59.94    59.93  
   1920x1080i    60.00    50.00    59.94  
   1680x1050     69.88    59.95    59.88  
   1600x1024     60.17  
   1400x1050     74.76    70.00    59.98  
   1600x900      59.95    60.00    59.82  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1440x810      59.97  
   1368x768      59.88    59.85  
   1360x768      59.80    59.96  
   1280x800      59.99    59.97    59.81    59.91  
   1152x864      75.00    75.00    70.00    60.00  
   1280x720      60.00    59.99    59.86    60.00    50.00    59.94    59.74  
   1024x768      75.05    60.04    75.03    70.07    60.00  
   960x720       75.00    60.00  
   928x696       75.00    60.05  
   896x672       75.05    60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   832x624       74.55  
   960x540       59.96    59.99    59.63    59.82  
   800x600       75.00    70.00    65.00    60.00    72.19    75.00    60.32    56.25  
   840x525       74.96    69.88    60.01    59.88  
   864x486       59.92    59.57  
   720x576       50.00  
   800x512       60.17  
   700x525       74.76    70.06    59.98  
   800x450       59.95    59.82  
   720x480       60.00    59.94  
   640x512       75.02    60.02  
   720x450       59.89  
   700x450       59.96    59.88  
   640x480       60.00    75.00    72.81    75.00    60.00    59.94  
   720x405       59.51    58.99  
   720x400       70.08  
   684x384       59.88    59.85  
   680x384       59.80    59.96  
   640x400       59.88    59.98  
   576x432       75.00    75.00    70.00    60.06  
   640x360       59.86    59.83    59.84    59.32  
   512x384       75.03    70.07    60.00  
   512x288       60.00    59.92  
   416x312       74.66  
   480x270       59.63    59.82  
   400x300       72.19    75.12    60.32    56.34  
   432x243       59.92    59.57  
   320x240       72.81    75.00    60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32  
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
mviereck commented 2 years ago

Just set one one that fits your needs. The best size is a question of personal preference. The Xephyr window will be resizeable, not fixed.

hongyi-zhao commented 2 years ago

What's the relationship between the size/dimension and the resolution/dpi, as shown below?

$ xdpyinfo | grep -E 'dimensions|resolution'
  dimensions:    1920x1080 pixels (508x285 millimeters)
  resolution:    96x96 dots per inch
mviereck commented 2 years ago

Please just use the options and try out. You'll see the effect.

hongyi-zhao commented 2 years ago

I have found some explanation here:

Screen Resolution and Screen Size are two dimensions that are very confusing. The Screen Resolution of a display device is the number of distinct pixels in each dimension that can be displayed. Screen Size is measured in inches and is the physical size of the screen, knowing both of these is required to figure out the PPI (Pixels Per Inch). The PPI is slightly complicated which I hopefully can simplify below.

Using The iPhone 3GS and iPhone 4 for examples. Both devices have a screen size of 3.5 inches. The iPhone 4 has a resolution of 960 x 640 pixels where as the iPhone 3GS is 320 x 480 pixels.

To determine the PPI the following steps must be followed:

Take the sum of the squares of the resolution (960² + 640² = 1,331,200)
Take the square root of the previous answer (√1,331,200 = 1,153.78)
Finally, divide the previous answer by the diagonal size of the screen (1,153.78/3.5=329.65)

The iPhone 4 advertises at 326 PPI, so we weren't far off. Feel free to figure out the PPI for the iPhone 3GS or, if your brain is hurting like mine is now, you can just look it up and discover that the 3GS has it's PPI at 165. No big surprise why the iPhones 4 retina display is so crisp and clean.

Screen Resolution is not the only factor in determining how good an image is displayed. If you take the iPhone 4's retina display resolution and apply it to an iPad the PPI would be only 118 or a 15 Inch mac book pro would have 76 PPI, both of these would result in a miserable computing experience.

tripzero commented 1 year ago

Is it possible to use a resolution larger than the display? For example, if I want to test a game at 4k but only have a 1080p monitor?

Right now, it seems like the max size I can use is limited to my actual display resolution. I tried with xwayland and weston-xwayland.

mviereck commented 1 year ago

I've answered here: https://github.com/mviereck/x11docker/issues/502