|
|
ff08c5 |
From f5b0e165c71d5114ba5221eea6ac9ec68b8ced94 Mon Sep 17 00:00:00 2001
|
|
|
ff08c5 |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
ff08c5 |
Date: Wed, 3 Oct 2018 10:50:47 +0200
|
|
|
ff08c5 |
Subject: [PATCH 2/2] monitor-manager/xrandr: Create dummy screen sized monitor
|
|
|
ff08c5 |
if no RANDR
|
|
|
ff08c5 |
|
|
|
ff08c5 |
When there is no RANDR support enabled in the X server, we wont get
|
|
|
ff08c5 |
notified of any monitors, resulting in mutter believing we're being
|
|
|
ff08c5 |
headless. To get at least something working, although with no way
|
|
|
ff08c5 |
configuration ability, lets pretend the whole screen is just a single
|
|
|
ff08c5 |
monitor with a single output, crtc and mode.
|
|
|
ff08c5 |
---
|
|
|
ff08c5 |
src/backends/x11/meta-gpu-xrandr.c | 60 +++++++++++++++++++
|
|
|
ff08c5 |
.../x11/meta-monitor-manager-xrandr.c | 20 +++++++
|
|
|
ff08c5 |
.../x11/meta-monitor-manager-xrandr.h | 2 +
|
|
|
ff08c5 |
3 files changed, 82 insertions(+)
|
|
|
ff08c5 |
|
|
|
ff08c5 |
diff --git a/src/backends/x11/meta-gpu-xrandr.c b/src/backends/x11/meta-gpu-xrandr.c
|
|
|
ff08c5 |
index a4e187a49..9397c1f64 100644
|
|
|
ff08c5 |
--- a/src/backends/x11/meta-gpu-xrandr.c
|
|
|
ff08c5 |
+++ b/src/backends/x11/meta-gpu-xrandr.c
|
|
|
ff08c5 |
@@ -147,6 +147,63 @@ update_screen_size (MetaMonitorManagerXrandr *monitor_manager_xrandr)
|
|
|
ff08c5 |
monitor_manager->screen_height = HeightOfScreen (screen);
|
|
|
ff08c5 |
}
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+static gboolean
|
|
|
ff08c5 |
+read_current_fallback (MetaGpuXrandr *gpu_xrandr,
|
|
|
ff08c5 |
+ MetaMonitorManagerXrandr *monitor_manager_xrandr)
|
|
|
ff08c5 |
+{
|
|
|
ff08c5 |
+ MetaGpu *gpu = META_GPU (gpu_xrandr);
|
|
|
ff08c5 |
+ MetaMonitorManager *monitor_manager =
|
|
|
ff08c5 |
+ META_MONITOR_MANAGER (monitor_manager_xrandr);
|
|
|
ff08c5 |
+ MetaCrtcMode *mode;
|
|
|
ff08c5 |
+ MetaCrtc *crtc;
|
|
|
ff08c5 |
+ MetaOutput *output;
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ update_dpms_state (monitor_manager_xrandr);
|
|
|
ff08c5 |
+ update_screen_size (monitor_manager_xrandr);
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ mode = g_object_new (META_TYPE_CRTC_MODE, NULL);
|
|
|
ff08c5 |
+ mode->mode_id = 0;
|
|
|
ff08c5 |
+ mode->width = monitor_manager->screen_width;
|
|
|
ff08c5 |
+ mode->height = monitor_manager->screen_height;
|
|
|
ff08c5 |
+ mode->refresh_rate = 60.0;
|
|
|
ff08c5 |
+ mode->name = g_strdup_printf ("%dx%d", mode->width, mode->height);
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ meta_gpu_take_modes (gpu, g_list_prepend (NULL, mode));
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ crtc = g_object_new (META_TYPE_CRTC, NULL);
|
|
|
ff08c5 |
+ crtc->gpu = gpu;
|
|
|
ff08c5 |
+ crtc->crtc_id = 0;
|
|
|
ff08c5 |
+ crtc->rect = (MetaRectangle) { .width = mode->width, .height = mode->height };
|
|
|
ff08c5 |
+ crtc->current_mode = mode;
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ meta_gpu_take_crtcs (gpu, g_list_prepend (NULL, crtc));
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ output = g_object_new (META_TYPE_OUTPUT, NULL);
|
|
|
ff08c5 |
+ output->gpu = gpu;
|
|
|
ff08c5 |
+ output->winsys_id = 0;
|
|
|
ff08c5 |
+ output->name = g_strdup ("X11 Screen");
|
|
|
ff08c5 |
+ output->vendor = g_strdup ("unknown");
|
|
|
ff08c5 |
+ output->product = g_strdup ("unknown");
|
|
|
ff08c5 |
+ output->serial = g_strdup ("unknown");
|
|
|
ff08c5 |
+ output->hotplug_mode_update = TRUE;
|
|
|
ff08c5 |
+ output->suggested_x = -1;
|
|
|
ff08c5 |
+ output->suggested_y = -1;
|
|
|
ff08c5 |
+ output->connector_type = META_CONNECTOR_TYPE_Unknown;
|
|
|
ff08c5 |
+ output->modes = g_new0 (MetaCrtcMode *, 1);
|
|
|
ff08c5 |
+ output->modes[0] = mode;
|
|
|
ff08c5 |
+ output->n_modes = 1;
|
|
|
ff08c5 |
+ output->preferred_mode = mode;
|
|
|
ff08c5 |
+ output->possible_crtcs = g_new0 (MetaCrtc *, 1);
|
|
|
ff08c5 |
+ output->possible_crtcs[0] = crtc;
|
|
|
ff08c5 |
+ output->n_possible_crtcs = 1;
|
|
|
ff08c5 |
+ meta_output_assign_crtc (output, crtc);
|
|
|
ff08c5 |
+ output->is_primary = TRUE;
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ meta_gpu_take_outputs (gpu, g_list_prepend (NULL, output));
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ return TRUE;
|
|
|
ff08c5 |
+}
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
static gboolean
|
|
|
ff08c5 |
meta_gpu_xrandr_read_current (MetaGpu *gpu,
|
|
|
ff08c5 |
GError **error)
|
|
|
ff08c5 |
@@ -166,6 +223,9 @@ meta_gpu_xrandr_read_current (MetaGpu *gpu,
|
|
|
ff08c5 |
GList *modes = NULL;
|
|
|
ff08c5 |
GList *crtcs = NULL;
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+ if (!meta_monitor_manager_xrandr_has_randr (monitor_manager_xrandr))
|
|
|
ff08c5 |
+ return read_current_fallback (gpu_xrandr, monitor_manager_xrandr);
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
if (gpu_xrandr->resources)
|
|
|
ff08c5 |
XRRFreeScreenResources (gpu_xrandr->resources);
|
|
|
ff08c5 |
gpu_xrandr->resources = NULL;
|
|
|
ff08c5 |
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
|
|
|
ff08c5 |
index d0da2c539..26b057a55 100644
|
|
|
ff08c5 |
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
|
|
|
ff08c5 |
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
|
|
|
ff08c5 |
@@ -64,6 +64,7 @@ struct _MetaMonitorManagerXrandr
|
|
|
ff08c5 |
guint logind_watch_id;
|
|
|
ff08c5 |
guint logind_signal_sub_id;
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+ gboolean has_randr;
|
|
|
ff08c5 |
gboolean has_randr15;
|
|
|
ff08c5 |
|
|
|
ff08c5 |
/*
|
|
|
ff08c5 |
@@ -107,6 +108,12 @@ meta_monitor_manager_xrandr_get_xdisplay (MetaMonitorManagerXrandr *manager_xran
|
|
|
ff08c5 |
return manager_xrandr->xdisplay;
|
|
|
ff08c5 |
}
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+gboolean
|
|
|
ff08c5 |
+meta_monitor_manager_xrandr_has_randr (MetaMonitorManagerXrandr *manager_xrandr)
|
|
|
ff08c5 |
+{
|
|
|
ff08c5 |
+ return manager_xrandr->has_randr;
|
|
|
ff08c5 |
+}
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
gboolean
|
|
|
ff08c5 |
meta_monitor_manager_xrandr_has_randr15 (MetaMonitorManagerXrandr *manager_xrandr)
|
|
|
ff08c5 |
{
|
|
|
ff08c5 |
@@ -577,9 +584,18 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
|
|
|
ff08c5 |
MetaMonitorsConfigMethod method,
|
|
|
ff08c5 |
GError **error)
|
|
|
ff08c5 |
{
|
|
|
ff08c5 |
+ MetaMonitorManagerXrandr *manager_xrandr =
|
|
|
ff08c5 |
+ META_MONITOR_MANAGER_XRANDR (manager);
|
|
|
ff08c5 |
GPtrArray *crtc_infos;
|
|
|
ff08c5 |
GPtrArray *output_infos;
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+ if (!manager_xrandr->has_randr)
|
|
|
ff08c5 |
+ {
|
|
|
ff08c5 |
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
ff08c5 |
+ "Tried to change configuration without XRANDR support");
|
|
|
ff08c5 |
+ return FALSE;
|
|
|
ff08c5 |
+ }
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
if (!config)
|
|
|
ff08c5 |
{
|
|
|
ff08c5 |
meta_monitor_manager_xrandr_rebuild_derived (manager, NULL);
|
|
|
ff08c5 |
@@ -1046,11 +1062,15 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
|
|
|
ff08c5 |
&manager_xrandr->rr_event_base,
|
|
|
ff08c5 |
&manager_xrandr->rr_error_base))
|
|
|
ff08c5 |
{
|
|
|
ff08c5 |
+ g_warning ("No RANDR support, monitor configuration disabled");
|
|
|
ff08c5 |
return;
|
|
|
ff08c5 |
}
|
|
|
ff08c5 |
else
|
|
|
ff08c5 |
{
|
|
|
ff08c5 |
int major_version, minor_version;
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
+ manager_xrandr->has_randr = TRUE;
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
/* We only use ScreenChangeNotify, but GDK uses the others,
|
|
|
ff08c5 |
and we don't want to step on its toes */
|
|
|
ff08c5 |
XRRSelectInput (manager_xrandr->xdisplay,
|
|
|
ff08c5 |
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.h b/src/backends/x11/meta-monitor-manager-xrandr.h
|
|
|
ff08c5 |
index f09cbfd83..343c8131e 100644
|
|
|
ff08c5 |
--- a/src/backends/x11/meta-monitor-manager-xrandr.h
|
|
|
ff08c5 |
+++ b/src/backends/x11/meta-monitor-manager-xrandr.h
|
|
|
ff08c5 |
@@ -33,6 +33,8 @@ G_DECLARE_FINAL_TYPE (MetaMonitorManagerXrandr, meta_monitor_manager_xrandr,
|
|
|
ff08c5 |
|
|
|
ff08c5 |
Display * meta_monitor_manager_xrandr_get_xdisplay (MetaMonitorManagerXrandr *manager_xrandr);
|
|
|
ff08c5 |
|
|
|
ff08c5 |
+gboolean meta_monitor_manager_xrandr_has_randr (MetaMonitorManagerXrandr *manager_xrandr);
|
|
|
ff08c5 |
+
|
|
|
ff08c5 |
gboolean meta_monitor_manager_xrandr_has_randr15 (MetaMonitorManagerXrandr *manager_xrandr);
|
|
|
ff08c5 |
|
|
|
ff08c5 |
gboolean meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager,
|
|
|
ff08c5 |
--
|
|
|
ff08c5 |
2.21.0
|
|
|
ff08c5 |
|