Linux force application to full screen on a specific display

时光毁灭记忆、已成空白 提交于 2019-12-11 19:09:13

问题


For work, I am developing a very specialized piece of software has needs to run two full screen applications, one on each monitor. For the sake of simplicity, I am currently using LUbuntu 64 bit, with an AMD Radeon HD graphics card (can't recall the exact version currrently, but it's fairly new).

I'd like to stick with SDL2 if possible, but if I need to do some hacking with that or move to a different library, I'm fairly comfortable with that.

So, my question is, is it possible to have two fullscreen applications running on different monitors in Linux (and if so, what sort of setup steps do I need to take)? What would be my best bet for enumerating the displays to get their top-left x/y position so I can tell SDL to move my window onto that monitor to fullscreen it?

Note: I did not post this to askubuntu because I'm not sure this question strictly revolves around the Ubuntu platform.

Update:

Here is the output from xrandr -q:

Screen 0: minimum 320 x 200, current 3200 x 1080, maximum 3200 x 3200
DFP1 disconnected (normal left inverted right x axis y axis)
DFP2 disconnected (normal left inverted right x axis y axis)
DFP3 disconnected (normal left inverted right x axis y axis)
DFP4 disconnected (normal left inverted right x axis y axis)
DFP5 disconnected (normal left inverted right x axis y axis)
DFP6 disconnected (normal left inverted right x axis y axis)
DFP7 disconnected (normal left inverted right x axis y axis)
DFP8 disconnected (normal left inverted right x axis y axis)
DFP9 connected 1920x1080+1280+0 (normal left inverted right x axis y axis) 533mm x 312mm
   1280x1024      50.0 +   75.0     60.0     30.0     24.0  
   1920x1080      60.0 +   50.0*    59.9     30.0     25.0     30.0     24.0     30.0     30.0     24.0  
   1776x1000      50.0     59.9     25.0     24.0     30.0     30.0  
   1680x1050      50.0     60.0     30.0     24.0  
   1400x1050      50.0     60.0     30.0     24.0  
   1600x900       50.0     60.0     30.0     24.0  
   1440x900       50.0     59.9     30.0     24.0  
   1280x960       50.0     60.0     30.0     24.0  
   1280x800       50.0     59.8     30.0     24.0  
   1152x864       50.0     59.9     75.0     30.0     24.0  
   1280x768       50.0     59.8     30.0     24.0  
   1280x720       60.0     50.0     59.9     30.0     24.0  
   1024x768       50.0     75.0     70.1     30.0     24.0     60.0  
   1152x648       50.0     59.9  
   800x600        50.0     30.0     24.0     72.2     75.0     60.3     56.2  
   720x576        59.9     30.0     24.0     50.0  
   720x480        50.0     30.0     24.0     60.0     59.9  
   640x480        50.0     30.0     24.0     75.0     72.8     67.0     60.0     59.9  
DFP10 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024      60.0*+   76.0     75.0     72.0  
   1280x960       76.0     75.0     72.0     60.0  
   1152x864       75.0     60.0  
   1280x768       76.0     75.0     72.0     60.0  
   1280x720       76.0     75.0     72.0     60.0  
   1024x768       75.0     70.1     60.0  
   800x600        72.2     75.0     60.3  
   640x480        75.0     72.8     67.0     59.9  
   640x350        60.0     70.1  
CRT1 disconnected (normal left inverted right x axis y axis)

I have tried searching some forums for a better explanation of what to do with this information, it seems I should do something like:

xrandr --output DFP9 --auto --output DFP10 --auto

When I do that, I still have only one display (":0").


回答1:


What's your setup? Do you actually have 2 separate X displays, or are you using Xinerama to combine the two?

If you're using 2 displays, they should have their own -display or DISPLAY env variable. You can use that to execute a new app.

$ echo $DISPLAY
:0.0
$ xterm -display :0.0

Open a shell in the other display to get your other display env variable.

There's also -geometry, in the format of [Wth,Ht+X+Y]

$ xterm -geometry 132x80+500+0

When Xinerama is enabled, your other display is usually a +X+Y offset.

Of course, this does require the app to process command line arguments. It then passes those off to X when initialising the window. For xterm, width and height are units of text characters, where X/Y are screen pixels.




回答2:


If you have control over the X configuration, and if other applications will not be shown on the production workstations, you might want to disable the "Xinerama" feature and set up two screens. Then you could just have your apps connect to :0.0 and :0.1 and get the screen size from each.



来源:https://stackoverflow.com/questions/15435870/linux-force-application-to-full-screen-on-a-specific-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!