Skip to content

Commit 3d5133e

Browse files
committed
DisplayServer (Linux): remove support of xcb & xlib
They don't support multi-monitors. Prefer libdrm.
1 parent 4cbcd0f commit 3d5133e

File tree

6 files changed

+12
-157
lines changed

6 files changed

+12
-157
lines changed

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ include(CMakeDependentOption)
5757
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS" OFF)
5858
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD" OFF)
5959
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
60-
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
6160
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
62-
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
6361
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
6462
cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX" OFF)
6563
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR SunOS" OFF)
@@ -1277,18 +1275,10 @@ ff_lib_enable(XCB_RANDR
12771275
"xcb-randr"
12781276
"XcbRandr"
12791277
)
1280-
ff_lib_enable(XCB
1281-
"xcb"
1282-
"Xcb"
1283-
)
12841278
ff_lib_enable(XRANDR
12851279
"xrandr"
12861280
"XRandr"
12871281
)
1288-
ff_lib_enable(X11
1289-
"x11"
1290-
"X11"
1291-
)
12921282
ff_lib_enable(DRM
12931283
"libdrm"
12941284
"Libdrm"

src/common/init.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,9 @@ void ffListFeatures(void)
179179
#if FF_HAVE_XCB_RANDR
180180
"xcb-randr\n"
181181
#endif
182-
#if FF_HAVE_XCB
183-
"xcb\n"
184-
#endif
185182
#if FF_HAVE_XRANDR
186183
"xrandr\n"
187184
#endif
188-
#if FF_HAVE_X11
189-
"x11\n"
190-
#endif
191185
#if FF_HAVE_DRM
192186
"drm\n"
193187
#endif

src/detection/displayserver/linux/displayserver_linux.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,11 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds)
5454
//Try the x11 libs, from most feature rich to least.
5555
//We use the display list to detect if a connection is needed.
5656
//They respect wmProtocolName, and only detect display if it is set.
57-
5857
if(ds->displays.length == 0)
5958
ffdsConnectXcbRandr(ds);
6059

6160
if(ds->displays.length == 0)
6261
ffdsConnectXrandr(ds);
63-
64-
if(ds->displays.length == 0)
65-
ffdsConnectXcb(ds);
66-
67-
if(ds->displays.length == 0)
68-
ffdsConnectXlib(ds);
6962
}
7063

7164
//This display detection method is display server independent.

src/detection/displayserver/linux/displayserver_linux.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
const char* ffdsConnectWayland(FFDisplayServerResult* result);
66

77
const char* ffdsConnectXcbRandr(FFDisplayServerResult* result);
8-
const char* ffdsConnectXcb(FFDisplayServerResult* result);
9-
108
const char* ffdsConnectXrandr(FFDisplayServerResult* result);
11-
const char* ffdsConnectXlib(FFDisplayServerResult* result);
12-
139
const char* ffdsConnectDrm(FFDisplayServerResult* result);
1410

1511
void ffdsDetectWMDE(FFDisplayServerResult* result);

src/detection/displayserver/linux/xcb.c

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#include "displayserver_linux.h"
2-
#include "util/mallocHelper.h"
3-
#include "common/time.h"
42

5-
#ifdef FF_HAVE_XCB
3+
#ifdef FF_HAVE_XCB_RANDR
4+
65
#include "common/library.h"
6+
#include "common/time.h"
7+
#include "util/edidHelper.h"
8+
#include "util/mallocHelper.h"
9+
710
#include <stdlib.h>
811
#include <string.h>
12+
#include <xcb/randr.h>
913
#include <xcb/xcb.h>
1014

1115
typedef struct XcbPropertyData
@@ -82,72 +86,6 @@ static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connect
8286
ffStrbufSetS(&result->wmProcessName, wmName);
8387
}
8488

85-
const char* ffdsConnectXcb(FFDisplayServerResult* result)
86-
{
87-
FF_LIBRARY_LOAD(xcb, "dlopen lbxcb failed", "libxcb" FF_LIBRARY_EXTENSION, 2)
88-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_connect)
89-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_get_setup)
90-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_setup_roots_iterator)
91-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_screen_next)
92-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_disconnect)
93-
94-
XcbPropertyData propertyData;
95-
bool propertyDataInitialized = xcbInitPropertyData(xcb, &propertyData);
96-
97-
xcb_connection_t* connection = ffxcb_connect(NULL, NULL);
98-
if(connection == NULL)
99-
return "xcb_connect failed";
100-
101-
xcb_screen_iterator_t iterator = ffxcb_setup_roots_iterator(ffxcb_get_setup(connection));
102-
103-
if(iterator.rem > 0 && propertyDataInitialized)
104-
xcbDetectWMfromEWMH(&propertyData, connection, iterator.data->root, result);
105-
106-
while(iterator.rem > 0)
107-
{
108-
xcb_screen_t* screen = iterator.data;
109-
ffdsAppendDisplay(result,
110-
(uint32_t) screen->width_in_pixels,
111-
(uint32_t) screen->height_in_pixels,
112-
0,
113-
(uint32_t) screen->width_in_pixels,
114-
(uint32_t) screen->height_in_pixels,
115-
0,
116-
NULL,
117-
FF_DISPLAY_TYPE_UNKNOWN,
118-
false,
119-
0,
120-
(uint32_t) screen->width_in_millimeters,
121-
(uint32_t) screen->height_in_millimeters,
122-
"xcb"
123-
);
124-
ffxcb_screen_next(&iterator);
125-
}
126-
127-
ffxcb_disconnect(connection);
128-
129-
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
130-
if(result->wmProtocolName.length == 0)
131-
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
132-
133-
return NULL;
134-
}
135-
136-
#else
137-
138-
const char* ffdsConnectXcb(FFDisplayServerResult* result)
139-
{
140-
//Do nothing. There are other implementations coming
141-
FF_UNUSED(result)
142-
return "Fastfetch was compiled without XCB support";
143-
}
144-
145-
#endif
146-
147-
#ifdef FF_HAVE_XCB_RANDR
148-
#include "util/edidHelper.h"
149-
#include <xcb/randr.h>
150-
15189
typedef struct XcbRandrData
15290
{
15391
FF_LIBRARY_SYMBOL(xcb_randr_get_screen_resources_current)

src/detection/displayserver/linux/xlib.c

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#include "displayserver_linux.h"
22

3-
#ifdef FF_HAVE_X11
3+
#ifdef FF_HAVE_XRANDR
4+
45
#include "common/library.h"
56
#include "common/parsing.h"
7+
#include "util/edidHelper.h"
68
#include "util/stringUtils.h"
9+
10+
#include <X11/extensions/Xrandr.h>
711
#include <X11/Xlib.h>
812

913
typedef struct X11PropertyData
@@ -58,66 +62,6 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl
5862
data->ffXFree(wmWindow);
5963
}
6064

61-
const char* ffdsConnectXlib(FFDisplayServerResult* result)
62-
{
63-
FF_LIBRARY_LOAD(x11, "dlopen libX11 failed", "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2)
64-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XOpenDisplay)
65-
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XCloseDisplay)
66-
67-
X11PropertyData propertyData;
68-
bool propertyDataInitialized = x11InitPropertyData(x11, &propertyData);
69-
70-
Display* display = ffXOpenDisplay(x11);
71-
if(display == NULL)
72-
return "XOpenDisplay failed";
73-
74-
if(propertyDataInitialized && ScreenCount(display) > 0)
75-
x11DetectWMFromEWMH(&propertyData, display, result);
76-
77-
for(int i = 0; i < ScreenCount(display); i++)
78-
{
79-
Screen* screen = ScreenOfDisplay(display, i);
80-
ffdsAppendDisplay(result,
81-
(uint32_t) WidthOfScreen(screen),
82-
(uint32_t) HeightOfScreen(screen),
83-
0,
84-
(uint32_t) WidthOfScreen(screen),
85-
(uint32_t) HeightOfScreen(screen),
86-
0,
87-
NULL,
88-
FF_DISPLAY_TYPE_UNKNOWN,
89-
false,
90-
0,
91-
(uint32_t) WidthMMOfScreen(screen),
92-
(uint32_t) HeightMMOfScreen(screen),
93-
"xlib"
94-
);
95-
}
96-
97-
ffXCloseDisplay(display);
98-
99-
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
100-
if(result->wmProtocolName.length == 0)
101-
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
102-
103-
return NULL;
104-
}
105-
106-
#else
107-
108-
const char* ffdsConnectXlib(FFDisplayServerResult* result)
109-
{
110-
//Do nothing. WM / DE detection will use environment vars to detect as much as possible.
111-
FF_UNUSED(result);
112-
return "Fastfetch was compiled without libX11 support";
113-
}
114-
115-
#endif //FF_HAVE_X11
116-
117-
#ifdef FF_HAVE_XRANDR
118-
#include "util/edidHelper.h"
119-
#include <X11/extensions/Xrandr.h>
120-
12165
typedef struct XrandrData
12266
{
12367
FF_LIBRARY_SYMBOL(XInternAtom)

0 commit comments

Comments
 (0)