build: Allow to disable x11

This commit is contained in:
Bilal Elmoussaoui 2024-05-24 17:08:26 +02:00
parent 4e449536f8
commit 2426dbf8cf
14 changed files with 109 additions and 31 deletions

View file

@ -42,3 +42,6 @@
/* Define to 1 if the <elf.h> and <link.h> header file exist. */ /* Define to 1 if the <elf.h> and <link.h> header file exist. */
#mesondefine HAVE_EXE_INTROSPECTION #mesondefine HAVE_EXE_INTROSPECTION
/* Whether GNOME Shell is built with X11 support */
#mesondefine HAVE_X11

View file

@ -101,13 +101,16 @@ install_data('00_org.gnome.shell.gschema.override', install_dir: schemadir)
if have_systemd if have_systemd
unitconf = configuration_data() unitconf = configuration_data()
unitconf.set('bindir', bindir) unitconf.set('bindir', bindir)
supported_sessions = ['wayland']
if have_x11
configure_file( configure_file(
input: 'org.gnome.Shell@x11.service.in', input: 'org.gnome.Shell@x11.service.in',
output: 'org.gnome.Shell@x11.service', output: 'org.gnome.Shell@x11.service',
configuration: unitconf, configuration: unitconf,
install_dir: systemduserunitdir install_dir: systemduserunitdir
) )
supported_sessions += ['x11']
endif
configure_file( configure_file(
input: 'org.gnome.Shell@wayland.service.in', input: 'org.gnome.Shell@wayland.service.in',
@ -116,8 +119,20 @@ if have_systemd
install_dir: systemduserunitdir install_dir: systemduserunitdir
) )
units = files('org.gnome.Shell.target',
'org.gnome.Shell-disable-extensions.service') units = files('org.gnome.Shell-disable-extensions.service')
targetconf = configuration_data()
sessions_wants = []
foreach session: supported_sessions
sessions_wants += 'org.gnome.Shell@' + session + '.service'
endforeach
targetconf.set('SUPPORTED_SESSIONS', ' '.join(sessions_wants))
target = configure_file(
input: 'org.gnome.Shell.target.in',
output: 'org.gnome.Shell.target',
configuration: targetconf
)
units += target
install_data(units, install_dir: systemduserunitdir) install_data(units, install_dir: systemduserunitdir)
endif endif

View file

@ -6,5 +6,4 @@ Requisite=gnome-session-initialized.target
PartOf=gnome-session-initialized.target PartOf=gnome-session-initialized.target
Before=gnome-session-initialized.target Before=gnome-session-initialized.target
Wants=org.gnome.Shell@wayland.service Wants=@SUPPORTED_SESSIONS@
Wants=org.gnome.Shell@x11.service

View file

@ -1111,7 +1111,7 @@ export const LayoutManager = GObject.registerClass({
} }
} }
if (wantsInputRegion) if (!Meta.is_wayland_compositor() && wantsInputRegion)
global.set_stage_input_region(rects); global.set_stage_input_region(rects);
this._isPopupWindowVisible = isPopupMenuVisible; this._isPopupWindowVisible = isPopupMenuVisible;

View file

@ -1039,7 +1039,8 @@ class AnimationsSettings {
if (!backend.is_rendering_hardware_accelerated()) if (!backend.is_rendering_hardware_accelerated())
return false; return false;
if (Shell.util_has_x11_display_extension( if (!Meta.is_wayland_compositor() &&
Shell.util_has_x11_display_extension(
global.display, 'VNC-EXTENSION')) global.display, 'VNC-EXTENSION'))
return false; return false;

View file

@ -87,10 +87,15 @@ cogl_pango_dep = dependency(cogl_pango_pc, version: mutter_req)
mutter_dep = dependency(libmutter_pc, version: mutter_req) mutter_dep = dependency(libmutter_pc, version: mutter_req)
polkit_dep = dependency('polkit-agent-1', version: polkit_req) polkit_dep = dependency('polkit-agent-1', version: polkit_req)
ibus_dep = dependency('ibus-1.0', version: ibus_req) ibus_dep = dependency('ibus-1.0', version: ibus_req)
x11_dep = dependency('x11')
schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_req) schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_req)
gnome_desktop_dep = dependency('gnome-desktop-4', version: gnome_desktop_req) gnome_desktop_dep = dependency('gnome-desktop-4', version: gnome_desktop_req)
have_x11 = get_option('x11')
if have_x11
x11_dep = dependency('x11')
endif
nm_deps = [] nm_deps = []
if get_option('networkmanager') if get_option('networkmanager')
nm_deps += dependency('libnm', version: nm_req) nm_deps += dependency('libnm', version: nm_req)
@ -145,6 +150,7 @@ cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
cdata.set('HAVE_NETWORKMANAGER', have_networkmanager) cdata.set('HAVE_NETWORKMANAGER', have_networkmanager)
cdata.set('HAVE_PIPEWIRE', have_pipewire) cdata.set('HAVE_PIPEWIRE', have_pipewire)
cdata.set('HAVE_SYSTEMD', have_systemd) cdata.set('HAVE_SYSTEMD', have_systemd)
cdata.set('HAVE_X11', have_x11)
# New API added in glib-2.57.2 # New API added in glib-2.57.2
cdata.set('HAVE_GIO_DESKTOP_LAUNCH_URIS_WITH_FDS', cdata.set('HAVE_GIO_DESKTOP_LAUNCH_URIS_WITH_FDS',
@ -323,6 +329,7 @@ meson.add_dist_script('meson/generate-stylesheets.py')
meson.add_dist_script('meson/check-version.py', meson.project_version(), 'NEWS') meson.add_dist_script('meson/check-version.py', meson.project_version(), 'NEWS')
summary_options = { summary_options = {
'x11': have_x11,
'camera_monitor': get_option('camera_monitor'), 'camera_monitor': get_option('camera_monitor'),
'networkmanager': get_option('networkmanager'), 'networkmanager': get_option('networkmanager'),
'systemd': get_option('systemd'), 'systemd': get_option('systemd'),

View file

@ -45,3 +45,9 @@ option('systemd',
value: true, value: true,
description: 'Enable systemd integration' description: 'Enable systemd integration'
) )
option('x11',
type: 'boolean',
value: true,
description: 'Enable X11 support'
)

View file

@ -40,7 +40,6 @@
#include <gjs/gjs.h> #include <gjs/gjs.h>
#include <meta/display.h> #include <meta/display.h>
#include <meta/meta-plugin.h> #include <meta/meta-plugin.h>
#include <meta/meta-x11-display.h>
#include <meta/util.h> #include <meta/util.h>
#include <mtk/mtk.h> #include <mtk/mtk.h>

View file

@ -13,7 +13,9 @@ introspection_common = {
subdir('calendar-server') subdir('calendar-server')
subdir('hotplug-sniffer') subdir('hotplug-sniffer')
subdir('st') subdir('st')
subdir('tray') if have_x11
subdir('tray')
endif
script_data = configuration_data() script_data = configuration_data()
script_data.set('bindir', bindir) script_data.set('bindir', bindir)
@ -77,9 +79,12 @@ gnome_shell_deps = [
gcr_dep, gcr_dep,
libsystemd_dep, libsystemd_dep,
libpipewire_dep, libpipewire_dep,
x11_dep,
] ]
if have_x11
gnome_shell_deps += x11_dep
endif
gnome_shell_deps += nm_deps gnome_shell_deps += nm_deps
tools_cflags = '-DLOCALEDIR="@0@"'.format(localedir) tools_cflags = '-DLOCALEDIR="@0@"'.format(localedir)
@ -121,8 +126,6 @@ libshell_public_headers = [
'shell-screenshot.h', 'shell-screenshot.h',
'shell-square-bin.h', 'shell-square-bin.h',
'shell-stack.h', 'shell-stack.h',
'shell-tray-icon.h',
'shell-tray-manager.h',
'shell-util.h', 'shell-util.h',
'shell-window-preview.h', 'shell-window-preview.h',
'shell-window-preview-layout.h', 'shell-window-preview-layout.h',
@ -131,6 +134,13 @@ libshell_public_headers = [
'shell-workspace-background.h' 'shell-workspace-background.h'
] ]
if have_x11
libshell_public_headers += [
'shell-tray-icon.h',
'shell-tray-manager.h',
]
endif
if have_networkmanager if have_networkmanager
libshell_public_headers += 'shell-network-agent.h' libshell_public_headers += 'shell-network-agent.h'
endif endif
@ -140,11 +150,16 @@ libshell_private_headers = [
'shell-app-cache-private.h', 'shell-app-cache-private.h',
'shell-app-system-private.h', 'shell-app-system-private.h',
'shell-global-private.h', 'shell-global-private.h',
'shell-tray-icon-private.h',
'shell-window-tracker-private.h', 'shell-window-tracker-private.h',
'shell-wm-private.h' 'shell-wm-private.h'
] ]
if have_x11
libshell_private_headers += [
'shell-tray-icon-private.h',
]
endif
libshell_sources = [ libshell_sources = [
'gnome-shell-plugin.c', 'gnome-shell-plugin.c',
'shell-app.c', 'shell-app.c',
@ -166,8 +181,6 @@ libshell_sources = [
'shell-secure-text-buffer.h', 'shell-secure-text-buffer.h',
'shell-square-bin.c', 'shell-square-bin.c',
'shell-stack.c', 'shell-stack.c',
'shell-tray-icon.c',
'shell-tray-manager.c',
'shell-util.c', 'shell-util.c',
'shell-window-preview.c', 'shell-window-preview.c',
'shell-window-preview-layout.c', 'shell-window-preview-layout.c',
@ -176,6 +189,13 @@ libshell_sources = [
'shell-workspace-background.c' 'shell-workspace-background.c'
] ]
if have_x11
libshell_sources += [
'shell-tray-icon.c',
'shell-tray-manager.c',
]
endif
if have_networkmanager if have_networkmanager
libshell_sources += 'shell-network-agent.c' libshell_sources += 'shell-network-agent.c'
endif endif
@ -212,12 +232,17 @@ dbus_generated += gnome.gdbus_codegen('switcheroo-control',
libshell_no_gir_sources += dbus_generated libshell_no_gir_sources += dbus_generated
libshell_link_with = []
if have_x11
libshell_link_with += [libtray]
endif
libshell = library('shell-' + mutter_api_version, libshell = library('shell-' + mutter_api_version,
sources: libshell_gir_sources + libshell_no_gir_sources, sources: libshell_gir_sources + libshell_no_gir_sources,
dependencies: gnome_shell_deps + [libshell_menu_dep, libst_dep, mutter_dep, gnome_desktop_dep, m_dep], dependencies: gnome_shell_deps + [libshell_menu_dep, libst_dep, mutter_dep, gnome_desktop_dep, m_dep],
include_directories: [conf_inc, st_inc, include_directories('tray')], include_directories: [conf_inc, st_inc, include_directories('tray')],
c_args: gnome_shell_cflags, c_args: gnome_shell_cflags,
link_with: [libtray], link_with: libshell_link_with,
build_rpath: mutter_typelibdir, build_rpath: mutter_typelibdir,
install_rpath: install_rpath, install_rpath: install_rpath,
install_dir: pkglibdir, install_dir: pkglibdir,

View file

@ -9,7 +9,6 @@
#include <meta/display.h> #include <meta/display.h>
#include <meta/meta-context.h> #include <meta/meta-context.h>
#include <meta/meta-workspace-manager.h> #include <meta/meta-workspace-manager.h>
#include <meta/meta-x11-display.h>
#include "shell-app-private.h" #include "shell-app-private.h"
#include "shell-enum-types.h" #include "shell-enum-types.h"

View file

@ -15,7 +15,6 @@
#endif #endif
#include <locale.h> #include <locale.h>
#include <X11/extensions/Xfixes.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <girepository.h> #include <girepository.h>
#include <meta/meta-backend.h> #include <meta/meta-backend.h>
@ -26,9 +25,13 @@
#include <meta/meta-cursor-tracker.h> #include <meta/meta-cursor-tracker.h>
#include <meta/meta-settings.h> #include <meta/meta-settings.h>
#include <meta/meta-workspace-manager.h> #include <meta/meta-workspace-manager.h>
#include <meta/meta-x11-display.h>
#include <mtk/mtk.h> #include <mtk/mtk.h>
#ifdef HAVE_X11
#include <meta/meta-x11-display.h>
#include <X11/extensions/Xfixes.h>
#endif
#define GNOME_DESKTOP_USE_UNSTABLE_API #define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-systemd.h> #include <libgnome-desktop/gnome-systemd.h>
@ -59,11 +62,14 @@ struct _ShellGlobal {
MetaDisplay *meta_display; MetaDisplay *meta_display;
MetaCompositor *compositor; MetaCompositor *compositor;
MetaWorkspaceManager *workspace_manager; MetaWorkspaceManager *workspace_manager;
#ifdef HAVE_X11
Display *xdisplay; Display *xdisplay;
char *session_mode;
XserverRegion input_region; XserverRegion input_region;
#endif
char *session_mode;
GjsContext *js_context; GjsContext *js_context;
MetaPlugin *plugin; MetaPlugin *plugin;
@ -424,7 +430,7 @@ shell_global_init (ShellGlobal *global)
path = g_strdup_printf ("%s/gnome-shell/runtime-state-%s.%s", path = g_strdup_printf ("%s/gnome-shell/runtime-state-%s.%s",
g_get_user_runtime_dir (), g_get_user_runtime_dir (),
byteorder_string, byteorder_string,
XDisplayName (NULL)); g_getenv ("DISPLAY"));
(void) g_mkdir_with_parents (path, 0700); (void) g_mkdir_with_parents (path, 0700);
global->runtime_state_path = g_file_new_for_path (path); global->runtime_state_path = g_file_new_for_path (path);
g_free (path); g_free (path);
@ -766,6 +772,7 @@ _shell_global_destroy_gjs_context (ShellGlobal *self)
g_clear_object (&self->js_context); g_clear_object (&self->js_context);
} }
#ifdef HAVE_X11
static void static void
sync_input_region (ShellGlobal *global) sync_input_region (ShellGlobal *global)
{ {
@ -817,6 +824,7 @@ shell_global_set_stage_input_region (ShellGlobal *global,
sync_input_region (global); sync_input_region (global);
} }
#endif
/** /**
* shell_global_get_context: * shell_global_get_context:
@ -1009,12 +1017,14 @@ entry_cursor_func (StEntry *entry,
use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT); use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT);
} }
#ifdef HAVE_X11
static void static void
on_x11_display_closed (MetaDisplay *display, on_x11_display_closed (MetaDisplay *display,
ShellGlobal *global) ShellGlobal *global)
{ {
g_signal_handlers_disconnect_by_data (global->stage, global); g_signal_handlers_disconnect_by_data (global->stage, global);
} }
#endif
void void
_shell_global_set_plugin (ShellGlobal *global, _shell_global_set_plugin (ShellGlobal *global,
@ -1042,11 +1052,13 @@ _shell_global_set_plugin (ShellGlobal *global,
global->stage = CLUTTER_STAGE (meta_get_stage_for_display (display)); global->stage = CLUTTER_STAGE (meta_get_stage_for_display (display));
#ifdef HAVE_X11
if (!meta_is_wayland_compositor ()) if (!meta_is_wayland_compositor ())
{ {
MetaX11Display *x11_display = meta_display_get_x11_display (display); MetaX11Display *x11_display = meta_display_get_x11_display (display);
global->xdisplay = meta_x11_display_get_xdisplay (x11_display); global->xdisplay = meta_x11_display_get_xdisplay (x11_display);
} }
#endif
st_entry_set_cursor_func (entry_cursor_func, global); st_entry_set_cursor_func (entry_cursor_func, global);
st_clipboard_set_selection (meta_display_get_selection (display)); st_clipboard_set_selection (meta_display_get_selection (display));
@ -1080,9 +1092,11 @@ _shell_global_set_plugin (ShellGlobal *global,
"End of frame, possibly including swap time", "End of frame, possibly including swap time",
""); "");
#ifdef HAVE_X11
if (global->xdisplay) if (global->xdisplay)
g_signal_connect_object (global->meta_display, "x11-display-closing", g_signal_connect_object (global->meta_display, "x11-display-closing",
G_CALLBACK (on_x11_display_closed), global, 0); G_CALLBACK (on_x11_display_closed), global, 0);
#endif
backend = meta_context_get_backend (shell_global_get_context (global)); backend = meta_context_get_backend (shell_global_get_context (global));
settings = meta_backend_get_settings (backend); settings = meta_backend_get_settings (backend);

View file

@ -28,8 +28,10 @@ MetaWorkspaceManager *shell_global_get_workspace_manager (ShellGlobal *globa
/* Input/event handling */ /* Input/event handling */
#ifdef HAVE_X11
void shell_global_set_stage_input_region (ShellGlobal *global, void shell_global_set_stage_input_region (ShellGlobal *global,
GSList *rectangles); GSList *rectangles);
#endif
void shell_global_get_pointer (ShellGlobal *global, void shell_global_get_pointer (ShellGlobal *global,
int *x, int *x,

View file

@ -23,7 +23,9 @@
#include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf.h>
#include <meta/meta-context.h> #include <meta/meta-context.h>
#include <meta/display.h> #include <meta/display.h>
#ifdef HAVE_X11
#include <meta/meta-x11-display.h> #include <meta/meta-x11-display.h>
#endif
#include <locale.h> #include <locale.h>
#ifdef HAVE__NL_TIME_FIRST_WEEKDAY #ifdef HAVE__NL_TIME_FIRST_WEEKDAY
@ -782,6 +784,7 @@ shell_util_sd_notify (void)
* If the corresponding X11 display provides the passed extension, return %TRUE, * If the corresponding X11 display provides the passed extension, return %TRUE,
* otherwise %FALSE. If there is no X11 display, %FALSE is passed. * otherwise %FALSE. If there is no X11 display, %FALSE is passed.
*/ */
#ifdef HAVE_X11
gboolean gboolean
shell_util_has_x11_display_extension (MetaDisplay *display, shell_util_has_x11_display_extension (MetaDisplay *display,
const char *extension) const char *extension)
@ -797,6 +800,7 @@ shell_util_has_x11_display_extension (MetaDisplay *display,
xdisplay = meta_x11_display_get_xdisplay (x11_display); xdisplay = meta_x11_display_get_xdisplay (x11_display);
return XQueryExtension (xdisplay, extension, &op, &event, &error); return XQueryExtension (xdisplay, extension, &op, &event, &error);
} }
#endif
/** /**
* shell_util_get_translated_folder_name: * shell_util_get_translated_folder_name:

View file

@ -299,6 +299,7 @@ get_app_from_sandboxed_app_id (MetaWindow *window)
* *
* Return value: (transfer full): A newly-referenced #ShellApp, or %NULL * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL
*/ */
#ifdef HAVE_X11
static ShellApp* static ShellApp*
get_app_from_window_group (ShellWindowTracker *tracker, get_app_from_window_group (ShellWindowTracker *tracker,
MetaWindow *window) MetaWindow *window)
@ -336,6 +337,7 @@ get_app_from_window_group (ShellWindowTracker *tracker,
return result; return result;
} }
#endif
/* /*
* get_app_from_window_pid: * get_app_from_window_pid:
@ -458,8 +460,10 @@ get_app_for_window (ShellWindowTracker *tracker,
/* If we didn't get a startup-notification match, see if we matched /* If we didn't get a startup-notification match, see if we matched
* any other windows in the group. * any other windows in the group.
*/ */
#ifdef HAVE_X11
if (result == NULL && meta_window_get_client_type (window) == META_WINDOW_CLIENT_TYPE_X11) if (result == NULL && meta_window_get_client_type (window) == META_WINDOW_CLIENT_TYPE_X11)
result = get_app_from_window_group (tracker, window); result = get_app_from_window_group (tracker, window);
#endif
/* Our last resort - we create a fake app from the window */ /* Our last resort - we create a fake app from the window */
if (result == NULL) if (result == NULL)