mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
context: Move X11 display policy under the context
The context implementations already effectively dictate the policy, so let them do it more directly instead of going indirectly via global variables. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
@ -60,7 +60,6 @@
|
||||
#include "core/events.h"
|
||||
#include "core/frame.h"
|
||||
#include "core/keybindings-private.h"
|
||||
#include "core/main-private.h"
|
||||
#include "core/meta-clipboard-manager.h"
|
||||
#include "core/meta-workspace-manager-private.h"
|
||||
#include "core/util-private.h"
|
||||
@ -890,7 +889,10 @@ meta_display_new (MetaContext *context,
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
if (meta_get_x11_display_policy () == META_X11_DISPLAY_POLICY_MANDATORY)
|
||||
MetaX11DisplayPolicy x11_display_policy;
|
||||
|
||||
x11_display_policy = meta_context_get_x11_display_policy (context);
|
||||
if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY)
|
||||
{
|
||||
meta_display_init_x11 (display, NULL,
|
||||
(GAsyncReadyCallback) on_x11_initialized,
|
||||
|
@ -1,32 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 Red Hat, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef META_MAIN_PRIVATE_H
|
||||
#define META_MAIN_PRIVATE_H
|
||||
|
||||
#include "core/util-private.h"
|
||||
#include "core/meta-private-enums.h"
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaX11DisplayPolicy meta_get_x11_display_policy (void);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_override_x11_display_policy (MetaX11DisplayPolicy x11_display_policy);
|
||||
|
||||
#endif /* META_MAIN_PRIVATE_H */
|
@ -1,95 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/* Mutter main() */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
* Copyright (C) 2006 Elijah Newren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:main
|
||||
* @title: Main
|
||||
* @short_description: Program startup.
|
||||
*
|
||||
* Functions which parse the command-line arguments, create the display,
|
||||
* kick everything off and then close down Mutter when it's time to go.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Mutter - a boring window manager for the adult in you
|
||||
*
|
||||
* Many window managers are like Marshmallow Froot Loops; Mutter
|
||||
* is like Frosted Flakes: it's still plain old corn, but dusted
|
||||
* with some sugar.
|
||||
*
|
||||
* The best way to get a handle on how the whole system fits together
|
||||
* is discussed in doc/code-overview.txt; if you're looking for functions
|
||||
* to investigate, read main(), meta_display_open(), and event_callback().
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "meta/main.h"
|
||||
|
||||
#include "backends/x11/cm/meta-backend-x11-cm.h"
|
||||
#include "core/meta-context-private.h"
|
||||
#include "core/main-private.h"
|
||||
|
||||
#if defined(HAVE_NATIVE_BACKEND) && defined(HAVE_WAYLAND)
|
||||
#include <systemd/sd-login.h>
|
||||
#endif /* HAVE_WAYLAND && HAVE_NATIVE_BACKEND */
|
||||
|
||||
MetaContext *
|
||||
meta_get_context_temporary (void);
|
||||
|
||||
static MetaX11DisplayPolicy x11_display_policy_override = -1;
|
||||
|
||||
void
|
||||
meta_override_x11_display_policy (MetaX11DisplayPolicy x11_display_policy)
|
||||
{
|
||||
x11_display_policy_override = x11_display_policy;
|
||||
}
|
||||
|
||||
MetaX11DisplayPolicy
|
||||
meta_get_x11_display_policy (void)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
|
||||
if (META_IS_BACKEND_X11_CM (backend))
|
||||
return META_X11_DISPLAY_POLICY_MANDATORY;
|
||||
|
||||
if (x11_display_policy_override != -1)
|
||||
return x11_display_policy_override;
|
||||
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor ())
|
||||
{
|
||||
#ifdef HAVE_XWAYLAND_INITFD
|
||||
g_autofree char *unit = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XWAYLAND_INITFD
|
||||
if (sd_pid_get_user_unit (0, &unit) < 0)
|
||||
return META_X11_DISPLAY_POLICY_MANDATORY;
|
||||
else
|
||||
return META_X11_DISPLAY_POLICY_ON_DEMAND;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return META_X11_DISPLAY_POLICY_MANDATORY;
|
||||
}
|
@ -34,7 +34,6 @@
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "backends/meta-virtual-monitor.h"
|
||||
#include "backends/x11/cm/meta-backend-x11-cm.h"
|
||||
#include "core/main-private.h"
|
||||
#include "meta/meta-backend.h"
|
||||
#include "wayland/meta-wayland.h"
|
||||
#include "x11/session.h"
|
||||
@ -279,11 +278,6 @@ meta_context_main_configure (MetaContext *context,
|
||||
if (!check_configuration (context_main, error))
|
||||
return FALSE;
|
||||
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (context_main->options.no_x11)
|
||||
meta_override_x11_display_policy (META_X11_DISPLAY_POLICY_DISABLED);
|
||||
#endif
|
||||
|
||||
context_main->compositor_type = determine_compositor_type (context_main,
|
||||
error);
|
||||
if (context_main->compositor_type == -1)
|
||||
@ -305,6 +299,36 @@ meta_context_main_get_compositor_type (MetaContext *context)
|
||||
return context_main->compositor_type;
|
||||
}
|
||||
|
||||
static MetaX11DisplayPolicy
|
||||
meta_context_main_get_x11_display_policy (MetaContext *context)
|
||||
{
|
||||
MetaCompositorType compositor_type;
|
||||
#ifdef HAVE_WAYLAND
|
||||
MetaContextMain *context_main = META_CONTEXT_MAIN (context);
|
||||
char *unit;
|
||||
#endif
|
||||
|
||||
compositor_type = meta_context_get_compositor_type (context);
|
||||
switch (compositor_type)
|
||||
{
|
||||
case META_COMPOSITOR_TYPE_X11:
|
||||
return META_X11_DISPLAY_POLICY_MANDATORY;
|
||||
case META_COMPOSITOR_TYPE_WAYLAND:
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (context_main->options.no_x11)
|
||||
return META_X11_DISPLAY_POLICY_DISABLED;
|
||||
else if (sd_pid_get_user_unit (0, &unit) < 0)
|
||||
return META_X11_DISPLAY_POLICY_MANDATORY;
|
||||
else
|
||||
return META_X11_DISPLAY_POLICY_ON_DEMAND;
|
||||
#else /* HAVE_WAYLAND */
|
||||
g_assert_not_reached ();
|
||||
#endif /* HAVE_WAYLAND */
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
#ifdef HAVE_NATIVE_BACKEND
|
||||
static gboolean
|
||||
add_persistent_virtual_monitors (MetaContextMain *context_main,
|
||||
@ -656,6 +680,8 @@ meta_context_main_class_init (MetaContextMainClass *klass)
|
||||
|
||||
context_class->configure = meta_context_main_configure;
|
||||
context_class->get_compositor_type = meta_context_main_get_compositor_type;
|
||||
context_class->get_x11_display_policy =
|
||||
meta_context_main_get_x11_display_policy;
|
||||
context_class->setup = meta_context_main_setup;
|
||||
context_class->create_backend = meta_context_main_create_backend;
|
||||
context_class->notify_ready = meta_context_main_notify_ready;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef META_CONTEXT_PRIVATE_H
|
||||
#define META_CONTEXT_PRIVATE_H
|
||||
|
||||
#include "core/meta-private-enums.h"
|
||||
#include "meta/meta-backend.h"
|
||||
#include "meta/meta-context.h"
|
||||
#include "wayland/meta-wayland-types.h"
|
||||
@ -36,6 +37,8 @@ struct _MetaContextClass
|
||||
|
||||
MetaCompositorType (* get_compositor_type) (MetaContext *context);
|
||||
|
||||
MetaX11DisplayPolicy (* get_x11_display_policy) (MetaContext *context);
|
||||
|
||||
gboolean (* setup) (MetaContext *context,
|
||||
GError **error);
|
||||
|
||||
@ -51,4 +54,6 @@ const char * meta_context_get_gnome_wm_keybindings (MetaContext *context);
|
||||
|
||||
MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context);
|
||||
|
||||
MetaX11DisplayPolicy meta_context_get_x11_display_policy (MetaContext *context);
|
||||
|
||||
#endif /* META_CONTEXT_PRIVATE_H */
|
||||
|
@ -212,6 +212,12 @@ meta_context_get_compositor_type (MetaContext *context)
|
||||
return META_CONTEXT_GET_CLASS (context)->get_compositor_type (context);
|
||||
}
|
||||
|
||||
MetaX11DisplayPolicy
|
||||
meta_context_get_x11_display_policy (MetaContext *context)
|
||||
{
|
||||
return META_CONTEXT_GET_CLASS (context)->get_x11_display_policy (context);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_context_real_configure (MetaContext *context,
|
||||
int *argc,
|
||||
|
Reference in New Issue
Block a user