2022-09-06 15:42:37 +02:00
|
|
|
#include "displayserver_linux.h"
|
2023-08-10 10:12:25 +08:00
|
|
|
#include "common/io/io.h"
|
2022-01-02 16:55:26 +01:00
|
|
|
|
2023-06-24 10:59:53 +08:00
|
|
|
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
|
2022-01-02 16:55:26 +01:00
|
|
|
{
|
2022-09-06 15:42:37 +02:00
|
|
|
ffStrbufInit(&ds->wmProcessName);
|
|
|
|
|
ffStrbufInit(&ds->wmPrettyName);
|
|
|
|
|
ffStrbufInit(&ds->wmProtocolName);
|
|
|
|
|
ffStrbufInit(&ds->deProcessName);
|
|
|
|
|
ffStrbufInit(&ds->dePrettyName);
|
2023-01-18 01:37:47 +08:00
|
|
|
ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4);
|
2022-01-02 16:55:26 +01:00
|
|
|
|
2023-12-11 13:25:58 +08:00
|
|
|
if (instance.config.general.dsForceDrm == FF_DS_FORCE_DRM_TYPE_FALSE)
|
2023-07-31 23:11:39 +08:00
|
|
|
{
|
2023-11-18 15:33:23 +01:00
|
|
|
//We try wayland as our preferred display server, as it supports the most features.
|
2023-07-31 23:11:39 +08:00
|
|
|
//This method can't detect the name of our WM / DE
|
|
|
|
|
ffdsConnectWayland(ds);
|
2022-01-02 16:55:26 +01:00
|
|
|
|
2023-08-01 16:19:58 +08:00
|
|
|
//Try the x11 libs, from most feature rich to least.
|
|
|
|
|
//We use the display list to detect if a connection is needed.
|
|
|
|
|
//They respect wmProtocolName, and only detect display if it is set.
|
2023-08-01 15:15:03 +08:00
|
|
|
|
2023-08-01 16:19:58 +08:00
|
|
|
if(ds->displays.length == 0)
|
2023-07-31 23:11:39 +08:00
|
|
|
ffdsConnectXcbRandr(ds);
|
2022-01-05 14:40:57 +01:00
|
|
|
|
2023-08-01 16:19:58 +08:00
|
|
|
if(ds->displays.length == 0)
|
|
|
|
|
ffdsConnectXrandr(ds);
|
2022-01-02 16:55:26 +01:00
|
|
|
|
2023-08-01 16:19:58 +08:00
|
|
|
if(ds->displays.length == 0)
|
|
|
|
|
ffdsConnectXcb(ds);
|
2022-01-05 14:40:57 +01:00
|
|
|
|
2023-08-01 16:19:58 +08:00
|
|
|
if(ds->displays.length == 0)
|
|
|
|
|
ffdsConnectXlib(ds);
|
2023-07-31 23:11:39 +08:00
|
|
|
}
|
2022-01-02 16:55:26 +01:00
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
//This display detection method is display server independent.
|
2022-01-02 16:55:26 +01:00
|
|
|
//Use it if all connections failed
|
2023-01-18 01:37:47 +08:00
|
|
|
if(ds->displays.length == 0)
|
2023-11-29 14:55:40 +08:00
|
|
|
ffdsConnectDrm(ds);
|
2022-01-02 16:55:26 +01:00
|
|
|
|
|
|
|
|
//This fills in missing information about WM / DE by using env vars and iterating processes
|
2023-06-24 10:59:53 +08:00
|
|
|
ffdsDetectWMDE(ds);
|
2022-01-02 16:55:26 +01:00
|
|
|
}
|