diff --git a/config.h.meson b/config.h.meson index 5ad68d839..42144b222 100644 --- a/config.h.meson +++ b/config.h.meson @@ -42,3 +42,6 @@ /* Define to 1 if the and header file exist. */ #mesondefine HAVE_EXE_INTROSPECTION + +/* Whether GNOME Shell is built with X11 support */ +#mesondefine HAVE_X11 \ No newline at end of file diff --git a/data/meson.build b/data/meson.build index 0307613e7..8654dfeca 100644 --- a/data/meson.build +++ b/data/meson.build @@ -101,13 +101,16 @@ install_data('00_org.gnome.shell.gschema.override', install_dir: schemadir) if have_systemd unitconf = configuration_data() unitconf.set('bindir', bindir) - - configure_file( - input: 'org.gnome.Shell@x11.service.in', - output: 'org.gnome.Shell@x11.service', - configuration: unitconf, - install_dir: systemduserunitdir - ) + supported_sessions = ['wayland'] + if have_x11 + configure_file( + input: 'org.gnome.Shell@x11.service.in', + output: 'org.gnome.Shell@x11.service', + configuration: unitconf, + install_dir: systemduserunitdir + ) + supported_sessions += ['x11'] + endif configure_file( input: 'org.gnome.Shell@wayland.service.in', @@ -116,8 +119,20 @@ if have_systemd 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) endif diff --git a/data/org.gnome.Shell.target b/data/org.gnome.Shell.target.in similarity index 71% rename from data/org.gnome.Shell.target rename to data/org.gnome.Shell.target.in index 55f9539e9..bb65fa0e6 100644 --- a/data/org.gnome.Shell.target +++ b/data/org.gnome.Shell.target.in @@ -6,5 +6,4 @@ Requisite=gnome-session-initialized.target PartOf=gnome-session-initialized.target Before=gnome-session-initialized.target -Wants=org.gnome.Shell@wayland.service -Wants=org.gnome.Shell@x11.service +Wants=@SUPPORTED_SESSIONS@ \ No newline at end of file diff --git a/js/ui/layout.js b/js/ui/layout.js index 3b54960f8..5fbeddc5c 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -1111,7 +1111,7 @@ export const LayoutManager = GObject.registerClass({ } } - if (wantsInputRegion) + if (!Meta.is_wayland_compositor() && wantsInputRegion) global.set_stage_input_region(rects); this._isPopupWindowVisible = isPopupMenuVisible; diff --git a/js/ui/main.js b/js/ui/main.js index ad0ea962f..2c3e4924f 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -1039,7 +1039,8 @@ class AnimationsSettings { if (!backend.is_rendering_hardware_accelerated()) return false; - if (Shell.util_has_x11_display_extension( + if (!Meta.is_wayland_compositor() && + Shell.util_has_x11_display_extension( global.display, 'VNC-EXTENSION')) return false; diff --git a/meson.build b/meson.build index d3e5a461b..625391521 100644 --- a/meson.build +++ b/meson.build @@ -87,10 +87,15 @@ cogl_pango_dep = dependency(cogl_pango_pc, version: mutter_req) mutter_dep = dependency(libmutter_pc, version: mutter_req) polkit_dep = dependency('polkit-agent-1', version: polkit_req) ibus_dep = dependency('ibus-1.0', version: ibus_req) -x11_dep = dependency('x11') schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_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 = [] if get_option('networkmanager') 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_PIPEWIRE', have_pipewire) cdata.set('HAVE_SYSTEMD', have_systemd) +cdata.set('HAVE_X11', have_x11) # New API added in glib-2.57.2 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') summary_options = { + 'x11': have_x11, 'camera_monitor': get_option('camera_monitor'), 'networkmanager': get_option('networkmanager'), 'systemd': get_option('systemd'), diff --git a/meson_options.txt b/meson_options.txt index 6e83d92f2..708e81079 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -45,3 +45,9 @@ option('systemd', value: true, description: 'Enable systemd integration' ) + +option('x11', + type: 'boolean', + value: true, + description: 'Enable X11 support' +) diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c index 76f2045b4..f978aba8d 100644 --- a/src/gnome-shell-plugin.c +++ b/src/gnome-shell-plugin.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/src/meson.build b/src/meson.build index f99b341b9..52e2a1ef3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,7 +13,9 @@ introspection_common = { subdir('calendar-server') subdir('hotplug-sniffer') subdir('st') -subdir('tray') +if have_x11 + subdir('tray') +endif script_data = configuration_data() script_data.set('bindir', bindir) @@ -77,9 +79,12 @@ gnome_shell_deps = [ gcr_dep, libsystemd_dep, libpipewire_dep, - x11_dep, ] +if have_x11 + gnome_shell_deps += x11_dep +endif + gnome_shell_deps += nm_deps tools_cflags = '-DLOCALEDIR="@0@"'.format(localedir) @@ -121,8 +126,6 @@ libshell_public_headers = [ 'shell-screenshot.h', 'shell-square-bin.h', 'shell-stack.h', - 'shell-tray-icon.h', - 'shell-tray-manager.h', 'shell-util.h', 'shell-window-preview.h', 'shell-window-preview-layout.h', @@ -131,6 +134,13 @@ libshell_public_headers = [ 'shell-workspace-background.h' ] +if have_x11 + libshell_public_headers += [ + 'shell-tray-icon.h', + 'shell-tray-manager.h', + ] +endif + if have_networkmanager libshell_public_headers += 'shell-network-agent.h' endif @@ -140,11 +150,16 @@ libshell_private_headers = [ 'shell-app-cache-private.h', 'shell-app-system-private.h', 'shell-global-private.h', - 'shell-tray-icon-private.h', 'shell-window-tracker-private.h', 'shell-wm-private.h' ] +if have_x11 + libshell_private_headers += [ + 'shell-tray-icon-private.h', + ] +endif + libshell_sources = [ 'gnome-shell-plugin.c', 'shell-app.c', @@ -166,8 +181,6 @@ libshell_sources = [ 'shell-secure-text-buffer.h', 'shell-square-bin.c', 'shell-stack.c', - 'shell-tray-icon.c', - 'shell-tray-manager.c', 'shell-util.c', 'shell-window-preview.c', 'shell-window-preview-layout.c', @@ -176,6 +189,13 @@ libshell_sources = [ 'shell-workspace-background.c' ] +if have_x11 + libshell_sources += [ + 'shell-tray-icon.c', + 'shell-tray-manager.c', + ] +endif + if have_networkmanager libshell_sources += 'shell-network-agent.c' endif @@ -212,12 +232,17 @@ dbus_generated += gnome.gdbus_codegen('switcheroo-control', libshell_no_gir_sources += dbus_generated +libshell_link_with = [] +if have_x11 + libshell_link_with += [libtray] +endif + libshell = library('shell-' + mutter_api_version, sources: libshell_gir_sources + libshell_no_gir_sources, 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')], c_args: gnome_shell_cflags, - link_with: [libtray], + link_with: libshell_link_with, build_rpath: mutter_typelibdir, install_rpath: install_rpath, install_dir: pkglibdir, diff --git a/src/shell-app.c b/src/shell-app.c index dcebc97da..708ccd047 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "shell-app-private.h" #include "shell-enum-types.h" diff --git a/src/shell-global.c b/src/shell-global.c index c2589fda8..1a1e7b68c 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -15,7 +15,6 @@ #endif #include -#include #include #include #include @@ -26,9 +25,13 @@ #include #include #include -#include #include +#ifdef HAVE_X11 +#include +#include +#endif + #define GNOME_DESKTOP_USE_UNSTABLE_API #include @@ -59,11 +62,14 @@ struct _ShellGlobal { MetaDisplay *meta_display; MetaCompositor *compositor; MetaWorkspaceManager *workspace_manager; +#ifdef HAVE_X11 Display *xdisplay; - char *session_mode; XserverRegion input_region; +#endif + + char *session_mode; GjsContext *js_context; MetaPlugin *plugin; @@ -424,7 +430,7 @@ shell_global_init (ShellGlobal *global) path = g_strdup_printf ("%s/gnome-shell/runtime-state-%s.%s", g_get_user_runtime_dir (), byteorder_string, - XDisplayName (NULL)); + g_getenv ("DISPLAY")); (void) g_mkdir_with_parents (path, 0700); global->runtime_state_path = g_file_new_for_path (path); g_free (path); @@ -766,6 +772,7 @@ _shell_global_destroy_gjs_context (ShellGlobal *self) g_clear_object (&self->js_context); } +#ifdef HAVE_X11 static void sync_input_region (ShellGlobal *global) { @@ -817,6 +824,7 @@ shell_global_set_stage_input_region (ShellGlobal *global, sync_input_region (global); } +#endif /** * shell_global_get_context: @@ -1009,12 +1017,14 @@ entry_cursor_func (StEntry *entry, use_ibeam ? META_CURSOR_IBEAM : META_CURSOR_DEFAULT); } +#ifdef HAVE_X11 static void on_x11_display_closed (MetaDisplay *display, ShellGlobal *global) { g_signal_handlers_disconnect_by_data (global->stage, global); } +#endif void _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)); +#ifdef HAVE_X11 if (!meta_is_wayland_compositor ()) { MetaX11Display *x11_display = meta_display_get_x11_display (display); global->xdisplay = meta_x11_display_get_xdisplay (x11_display); } +#endif st_entry_set_cursor_func (entry_cursor_func, global); 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", ""); +#ifdef HAVE_X11 if (global->xdisplay) g_signal_connect_object (global->meta_display, "x11-display-closing", G_CALLBACK (on_x11_display_closed), global, 0); +#endif backend = meta_context_get_backend (shell_global_get_context (global)); settings = meta_backend_get_settings (backend); @@ -1192,10 +1206,10 @@ pre_exec_close_fds(void) /** * shell_global_reexec_self: * @global: A #ShellGlobal - * - * Restart the current process. Only intended for development purposes. + * + * Restart the current process. Only intended for development purposes. */ -void +void shell_global_reexec_self (ShellGlobal *global) { GPtrArray *arr; diff --git a/src/shell-global.h b/src/shell-global.h index 839933023..febecc2f5 100644 --- a/src/shell-global.h +++ b/src/shell-global.h @@ -28,8 +28,10 @@ MetaWorkspaceManager *shell_global_get_workspace_manager (ShellGlobal *globa /* Input/event handling */ +#ifdef HAVE_X11 void shell_global_set_stage_input_region (ShellGlobal *global, GSList *rectangles); +#endif void shell_global_get_pointer (ShellGlobal *global, int *x, diff --git a/src/shell-util.c b/src/shell-util.c index 311576c0e..1b6b4c7c6 100644 --- a/src/shell-util.c +++ b/src/shell-util.c @@ -23,7 +23,9 @@ #include #include #include +#ifdef HAVE_X11 #include +#endif #include #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, * otherwise %FALSE. If there is no X11 display, %FALSE is passed. */ +#ifdef HAVE_X11 gboolean shell_util_has_x11_display_extension (MetaDisplay *display, const char *extension) @@ -797,6 +800,7 @@ shell_util_has_x11_display_extension (MetaDisplay *display, xdisplay = meta_x11_display_get_xdisplay (x11_display); return XQueryExtension (xdisplay, extension, &op, &event, &error); } +#endif /** * shell_util_get_translated_folder_name: diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c index 548a3f1ce..fe9423201 100644 --- a/src/shell-window-tracker.c +++ b/src/shell-window-tracker.c @@ -299,6 +299,7 @@ get_app_from_sandboxed_app_id (MetaWindow *window) * * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL */ +#ifdef HAVE_X11 static ShellApp* get_app_from_window_group (ShellWindowTracker *tracker, MetaWindow *window) @@ -336,6 +337,7 @@ get_app_from_window_group (ShellWindowTracker *tracker, return result; } +#endif /* * 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 * any other windows in the group. */ +#ifdef HAVE_X11 if (result == NULL && meta_window_get_client_type (window) == META_WINDOW_CLIENT_TYPE_X11) result = get_app_from_window_group (tracker, window); +#endif /* Our last resort - we create a fake app from the window */ if (result == NULL)