Linux强制应用程序在特定显示器上全屏显示

Linux force application to full screen on a specific display

本文关键字:显示器 显示 应用程序 Linux      更新时间:2023-10-16

为了工作,我正在开发一款非常专业的软件。它需要运行两个全屏应用程序,每个监视器上一个。为了简单起见,我目前使用的是LUbuntu 64位,带有AMD Radeon HD显卡(目前无法回忆起确切的版本,但它相当新(。

如果可能的话,我想继续使用SDL2,但如果我需要用它进行一些黑客攻击或转移到另一个库,我对此相当满意。

所以,我的问题是,在Linux中,有可能在不同的监视器上运行两个全屏应用程序吗(如果有,我需要采取什么样的设置步骤(?枚举显示器以获得其左上角x/y位置,这样我就可以告诉SDL将我的窗口移动到监视器上以全屏显示它,我的最佳选择是什么?

注意:我没有把这个发布到askubuntu,因为我不确定这个问题是否严格围绕Ubuntu平台。

更新:

以下是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)

我试着在一些论坛上搜索,以更好地解释如何处理这些信息,似乎我应该做一些类似的事情:

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

当我这样做时,我仍然只有一个显示器(":0"(。

您的设置是什么?你真的有两个单独的X显示器吗,还是用Xinerama将两者结合起来?

如果使用两个显示器,它们应该有自己的-display或display env变量。你可以用它来执行一个新的应用程序。

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

在另一个显示器中打开一个shell以获取另一个显示环境变量。

还有几何体,格式为[Wth,Ht+X+Y]

$ xterm -geometry 132x80+500+0

启用Xinerama后,其他显示通常为+X+Y偏移。

当然,这确实需要应用程序处理命令行参数。然后,在初始化窗口时,它将这些值传递给X。对于xterm,宽度和高度是文本字符的单位,其中X/Y是屏幕像素。

如果您可以控制X配置,并且生产工作站上不会显示其他应用程序,则可能需要禁用"Xinerama"功能并设置两个屏幕。然后你可以让你的应用程序连接到:0.0:0.1,并从中获取屏幕大小。