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