2016-12-12 21:53:38 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Red Hat
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "backends/meta-monitor.h"
|
|
|
|
|
2016-12-13 05:58:22 -05:00
|
|
|
#include "backends/meta-backend-private.h"
|
2017-03-28 00:35:19 -04:00
|
|
|
#include "backends/meta-crtc.h"
|
2017-07-10 06:19:32 -04:00
|
|
|
#include "backends/meta-gpu.h"
|
2016-12-12 21:53:38 -05:00
|
|
|
#include "backends/meta-monitor-manager-private.h"
|
2017-04-21 05:28:22 -04:00
|
|
|
#include "backends/meta-settings-private.h"
|
2017-03-24 05:35:51 -04:00
|
|
|
#include "backends/meta-output.h"
|
2020-01-14 16:34:44 -05:00
|
|
|
#include "core/boxes-private.h"
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2017-08-09 12:41:13 -04:00
|
|
|
#define SCALE_FACTORS_PER_INTEGER 4
|
2017-06-08 23:18:14 -04:00
|
|
|
#define SCALE_FACTORS_STEPS (1.0 / (float) SCALE_FACTORS_PER_INTEGER)
|
2017-08-09 12:41:13 -04:00
|
|
|
#define MINIMUM_SCALE_FACTOR 1.0f
|
2017-06-05 23:27:58 -04:00
|
|
|
#define MAXIMUM_SCALE_FACTOR 4.0f
|
2019-08-12 04:52:48 -04:00
|
|
|
#define MINIMUM_LOGICAL_AREA (800 * 480)
|
2017-09-14 06:42:47 -04:00
|
|
|
#define MAXIMUM_REFRESH_RATE_DIFF 0.001
|
2017-06-05 23:27:58 -04:00
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
typedef struct _MetaMonitorMode
|
|
|
|
{
|
2019-08-12 04:54:18 -04:00
|
|
|
MetaMonitor *monitor;
|
2017-06-14 00:04:09 -04:00
|
|
|
char *id;
|
2016-12-17 09:29:33 -05:00
|
|
|
MetaMonitorModeSpec spec;
|
2016-12-14 04:22:07 -05:00
|
|
|
MetaMonitorCrtcMode *crtc_modes;
|
|
|
|
} MetaMonitorMode;
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
typedef struct _MetaMonitorModeTiled
|
|
|
|
{
|
|
|
|
MetaMonitorMode parent;
|
|
|
|
|
|
|
|
gboolean is_tiled;
|
|
|
|
} MetaMonitorModeTiled;
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
typedef struct _MetaMonitorPrivate
|
|
|
|
{
|
2021-01-26 08:49:25 -05:00
|
|
|
MetaBackend *backend;
|
2017-05-11 05:24:53 -04:00
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
GList *outputs;
|
2016-12-14 04:22:07 -05:00
|
|
|
GList *modes;
|
2017-06-14 00:04:09 -04:00
|
|
|
GHashTable *mode_ids;
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2016-12-17 09:32:05 -05:00
|
|
|
MetaMonitorMode *preferred_mode;
|
2016-12-22 02:22:13 -05:00
|
|
|
MetaMonitorMode *current_mode;
|
2016-12-17 09:32:05 -05:00
|
|
|
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitorSpec *spec;
|
|
|
|
|
2020-01-16 04:10:42 -05:00
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
/*
|
|
|
|
* The primary or first output for this monitor, 0 if we can't figure out.
|
|
|
|
* It can be matched to a winsys_id of a MetaOutput.
|
|
|
|
*
|
|
|
|
* This is used as an opaque token on reconfiguration when switching from
|
2020-08-26 05:49:50 -04:00
|
|
|
* clone to extended, to decide on what output the windows should go next
|
2016-12-12 21:53:38 -05:00
|
|
|
* (it's an attempt to keep windows on the same monitor, and preferably on
|
|
|
|
* the primary one).
|
|
|
|
*/
|
2018-10-17 10:55:18 -04:00
|
|
|
uint64_t winsys_id;
|
2019-06-26 05:24:19 -04:00
|
|
|
|
|
|
|
char *display_name;
|
2016-12-12 21:53:38 -05:00
|
|
|
} MetaMonitorPrivate;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaMonitor, meta_monitor, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
struct _MetaMonitorNormal
|
|
|
|
{
|
|
|
|
MetaMonitor parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaMonitorNormal, meta_monitor_normal, META_TYPE_MONITOR)
|
|
|
|
|
|
|
|
struct _MetaMonitorTiled
|
|
|
|
{
|
|
|
|
MetaMonitor parent;
|
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
MetaMonitorManager *monitor_manager;
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
uint32_t tile_group_id;
|
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
/* The tile (0, 0) output. */
|
|
|
|
MetaOutput *origin_output;
|
|
|
|
|
|
|
|
/* The output enabled even when a non-tiled mode is used. */
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaOutput *main_output;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaMonitorTiled, meta_monitor_tiled, META_TYPE_MONITOR)
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_mode_free (MetaMonitorMode *mode);
|
|
|
|
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitorSpec *
|
|
|
|
meta_monitor_spec_clone (MetaMonitorSpec *monitor_spec)
|
|
|
|
{
|
|
|
|
MetaMonitorSpec *new_monitor_spec;
|
|
|
|
|
|
|
|
new_monitor_spec = g_new0 (MetaMonitorSpec, 1);
|
|
|
|
*new_monitor_spec = (MetaMonitorSpec) {
|
|
|
|
.connector = g_strdup (monitor_spec->connector),
|
|
|
|
.vendor = g_strdup (monitor_spec->vendor),
|
|
|
|
.product = g_strdup (monitor_spec->product),
|
|
|
|
.serial = g_strdup (monitor_spec->serial),
|
|
|
|
};
|
|
|
|
|
|
|
|
return new_monitor_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_monitor_spec_equals (MetaMonitorSpec *monitor_spec,
|
|
|
|
MetaMonitorSpec *other_monitor_spec)
|
|
|
|
{
|
|
|
|
return (g_str_equal (monitor_spec->connector, other_monitor_spec->connector) &&
|
|
|
|
g_str_equal (monitor_spec->vendor, other_monitor_spec->vendor) &&
|
|
|
|
g_str_equal (monitor_spec->product, other_monitor_spec->product) &&
|
|
|
|
g_str_equal (monitor_spec->serial, other_monitor_spec->serial));
|
|
|
|
}
|
|
|
|
|
2017-01-12 03:13:48 -05:00
|
|
|
int
|
|
|
|
meta_monitor_spec_compare (MetaMonitorSpec *monitor_spec_a,
|
|
|
|
MetaMonitorSpec *monitor_spec_b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = strcmp (monitor_spec_a->connector, monitor_spec_b->connector);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = strcmp (monitor_spec_a->vendor, monitor_spec_b->vendor);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = strcmp (monitor_spec_a->product, monitor_spec_b->product);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return strcmp (monitor_spec_a->serial, monitor_spec_b->serial);
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:34:26 -05:00
|
|
|
void
|
|
|
|
meta_monitor_spec_free (MetaMonitorSpec *monitor_spec)
|
|
|
|
{
|
|
|
|
g_free (monitor_spec->connector);
|
|
|
|
g_free (monitor_spec->vendor);
|
|
|
|
g_free (monitor_spec->product);
|
|
|
|
g_free (monitor_spec->serial);
|
|
|
|
g_free (monitor_spec);
|
|
|
|
}
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
static const MetaOutputInfo *
|
|
|
|
meta_monitor_get_main_output_info (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaOutput *output = meta_monitor_get_main_output (monitor);
|
|
|
|
|
|
|
|
return meta_output_get_info (output);
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:34:26 -05:00
|
|
|
static void
|
2017-04-28 03:31:03 -04:00
|
|
|
meta_monitor_generate_spec (MetaMonitor *monitor)
|
2016-12-17 09:34:26 -05:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitorSpec *monitor_spec;
|
|
|
|
|
|
|
|
monitor_spec = g_new0 (MetaMonitorSpec, 1);
|
|
|
|
*monitor_spec = (MetaMonitorSpec) {
|
2020-02-26 03:45:07 -05:00
|
|
|
.connector = g_strdup (output_info->name),
|
|
|
|
.vendor = g_strdup (output_info->vendor),
|
|
|
|
.product = g_strdup (output_info->product),
|
|
|
|
.serial = g_strdup (output_info->serial),
|
2016-12-17 09:34:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
priv->spec = monitor_spec;
|
|
|
|
}
|
|
|
|
|
2019-06-26 05:24:19 -04:00
|
|
|
static const double known_diagonals[] = {
|
|
|
|
12.1,
|
|
|
|
13.3,
|
|
|
|
15.6
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *
|
|
|
|
diagonal_to_str (double d)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (known_diagonals); i++)
|
|
|
|
{
|
|
|
|
double delta;
|
|
|
|
|
|
|
|
delta = fabs(known_diagonals[i] - d);
|
|
|
|
if (delta < 0.1)
|
|
|
|
return g_strdup_printf ("%0.1lf\"", known_diagonals[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_strdup_printf ("%d\"", (int) (d + 0.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
meta_monitor_make_display_name (MetaMonitor *monitor,
|
|
|
|
MetaMonitorManager *monitor_manager)
|
|
|
|
{
|
|
|
|
g_autofree char *inches = NULL;
|
|
|
|
g_autofree char *vendor_name = NULL;
|
|
|
|
const char *vendor = NULL;
|
|
|
|
const char *product_name = NULL;
|
|
|
|
int width_mm;
|
|
|
|
int height_mm;
|
|
|
|
|
|
|
|
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm);
|
|
|
|
|
|
|
|
if (meta_monitor_is_laptop_panel (monitor))
|
|
|
|
return g_strdup (_("Built-in display"));
|
|
|
|
|
|
|
|
if (width_mm > 0 && height_mm > 0)
|
|
|
|
{
|
|
|
|
if (!meta_monitor_has_aspect_as_size (monitor))
|
|
|
|
{
|
|
|
|
double d = sqrt (width_mm * width_mm +
|
|
|
|
height_mm * height_mm);
|
|
|
|
inches = diagonal_to_str (d / 25.4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
product_name = meta_monitor_get_product (monitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vendor = meta_monitor_get_vendor (monitor);
|
|
|
|
|
|
|
|
if (g_strcmp0 (vendor, "unknown") != 0)
|
|
|
|
{
|
|
|
|
vendor_name = meta_monitor_manager_get_vendor_name (monitor_manager,
|
|
|
|
vendor);
|
|
|
|
|
|
|
|
if (!vendor_name)
|
|
|
|
vendor_name = g_strdup (vendor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inches != NULL)
|
|
|
|
vendor_name = g_strdup (_("Unknown"));
|
|
|
|
else
|
|
|
|
vendor_name = g_strdup (_("Unknown Display"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inches != NULL)
|
|
|
|
{
|
|
|
|
/**/
|
|
|
|
return g_strdup_printf (C_("This is a monitor vendor name, followed by a "
|
|
|
|
"size in inches, like 'Dell 15\"'",
|
|
|
|
"%s %s"),
|
|
|
|
vendor_name, inches);
|
|
|
|
}
|
|
|
|
else if (product_name != NULL)
|
|
|
|
{
|
|
|
|
return g_strdup_printf (C_("This is a monitor vendor name followed by "
|
|
|
|
"product/model name where size in inches "
|
|
|
|
"could not be calculated, e.g. Dell U2414H",
|
|
|
|
"%s %s"),
|
|
|
|
vendor_name, product_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return g_strdup (vendor_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-26 08:49:25 -05:00
|
|
|
MetaBackend *
|
|
|
|
meta_monitor_get_backend (MetaMonitor *monitor)
|
2017-07-24 05:16:38 -04:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
2021-01-26 08:49:25 -05:00
|
|
|
return priv->backend;
|
2017-07-24 05:16:38 -04:00
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
GList *
|
|
|
|
meta_monitor_get_outputs (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return priv->outputs;
|
|
|
|
}
|
|
|
|
|
2016-12-12 22:03:22 -05:00
|
|
|
MetaOutput *
|
2016-12-12 21:53:38 -05:00
|
|
|
meta_monitor_get_main_output (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
return META_MONITOR_GET_CLASS (monitor)->get_main_output (monitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_monitor_is_active (MetaMonitor *monitor)
|
|
|
|
{
|
monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.
An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.
Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.
https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 07:18:51 -04:00
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.
An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.
Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.
https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 07:18:51 -04:00
|
|
|
return !!priv->current_mode;
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
2016-12-12 22:03:22 -05:00
|
|
|
gboolean
|
|
|
|
meta_monitor_is_primary (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaOutput *output;
|
|
|
|
|
|
|
|
output = meta_monitor_get_main_output (monitor);
|
|
|
|
|
2020-02-25 12:37:21 -05:00
|
|
|
return meta_output_is_primary (output);
|
2016-12-12 22:03:22 -05:00
|
|
|
}
|
|
|
|
|
2017-01-23 04:59:43 -05:00
|
|
|
gboolean
|
|
|
|
meta_monitor_supports_underscanning (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2017-01-23 04:59:43 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->supports_underscanning;
|
2017-01-23 04:59:43 -05:00
|
|
|
}
|
|
|
|
|
2017-01-16 21:59:24 -05:00
|
|
|
gboolean
|
|
|
|
meta_monitor_is_underscanning (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaOutput *output;
|
|
|
|
|
|
|
|
output = meta_monitor_get_main_output (monitor);
|
|
|
|
|
2020-02-25 12:37:21 -05:00
|
|
|
return meta_output_is_underscanning (output);
|
2017-01-16 21:59:24 -05:00
|
|
|
}
|
|
|
|
|
2016-12-17 09:37:57 -05:00
|
|
|
gboolean
|
|
|
|
meta_monitor_is_laptop_panel (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-17 09:37:57 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
switch (output_info->connector_type)
|
2016-12-17 09:37:57 -05:00
|
|
|
{
|
|
|
|
case META_CONNECTOR_TYPE_eDP:
|
|
|
|
case META_CONNECTOR_TYPE_LVDS:
|
|
|
|
case META_CONNECTOR_TYPE_DSI:
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-21 05:58:46 -04:00
|
|
|
gboolean
|
|
|
|
meta_monitor_is_same_as (MetaMonitor *monitor,
|
|
|
|
MetaMonitor *other_monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaMonitorPrivate *other_priv =
|
|
|
|
meta_monitor_get_instance_private (other_monitor);
|
|
|
|
|
|
|
|
return priv->winsys_id == other_priv->winsys_id;
|
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
void
|
2017-03-06 23:34:38 -05:00
|
|
|
meta_monitor_get_current_resolution (MetaMonitor *monitor,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
2017-03-06 23:34:38 -05:00
|
|
|
MetaMonitorMode *mode = meta_monitor_get_current_mode (monitor);
|
|
|
|
|
|
|
|
*width = mode->spec.width;
|
|
|
|
*height = mode->spec.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-12 03:42:20 -04:00
|
|
|
meta_monitor_derive_layout (MetaMonitor *monitor,
|
|
|
|
MetaRectangle *layout)
|
2017-03-06 23:34:38 -05:00
|
|
|
{
|
2017-07-12 03:42:20 -04:00
|
|
|
META_MONITOR_GET_CLASS (monitor)->derive_layout (monitor, layout);
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_monitor_get_physical_dimensions (MetaMonitor *monitor,
|
|
|
|
int *width_mm,
|
|
|
|
int *height_mm)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
*width_mm = output_info->width_mm;
|
|
|
|
*height_mm = output_info->height_mm;
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
2016-12-22 02:16:48 -05:00
|
|
|
CoglSubpixelOrder
|
|
|
|
meta_monitor_get_subpixel_order (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-22 02:16:48 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->subpixel_order;
|
2016-12-22 02:16:48 -05:00
|
|
|
}
|
|
|
|
|
2017-04-06 01:14:43 -04:00
|
|
|
const char *
|
|
|
|
meta_monitor_get_connector (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2017-04-06 01:14:43 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->name;
|
2017-04-06 01:14:43 -04:00
|
|
|
}
|
|
|
|
|
2016-12-22 02:20:57 -05:00
|
|
|
const char *
|
|
|
|
meta_monitor_get_vendor (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-22 02:20:57 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->vendor;
|
2016-12-22 02:20:57 -05:00
|
|
|
}
|
|
|
|
|
2016-12-13 05:58:22 -05:00
|
|
|
const char *
|
|
|
|
meta_monitor_get_product (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-13 05:58:22 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->product;
|
2016-12-13 05:58:22 -05:00
|
|
|
}
|
|
|
|
|
2016-12-22 02:20:57 -05:00
|
|
|
const char *
|
|
|
|
meta_monitor_get_serial (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2016-12-22 02:20:57 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->serial;
|
2016-12-22 02:20:57 -05:00
|
|
|
}
|
|
|
|
|
2017-01-20 02:07:12 -05:00
|
|
|
MetaConnectorType
|
|
|
|
meta_monitor_get_connector_type (MetaMonitor *monitor)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2017-01-20 02:07:12 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
return output_info->connector_type;
|
2017-01-20 02:07:12 -05:00
|
|
|
}
|
|
|
|
|
2017-10-24 06:43:58 -04:00
|
|
|
MetaMonitorTransform
|
|
|
|
meta_monitor_logical_to_crtc_transform (MetaMonitor *monitor,
|
|
|
|
MetaMonitorTransform transform)
|
|
|
|
{
|
|
|
|
MetaOutput *output = meta_monitor_get_main_output (monitor);
|
|
|
|
|
2020-01-14 16:21:38 -05:00
|
|
|
return meta_output_logical_to_crtc_transform (output, transform);
|
2017-10-24 06:43:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaMonitorTransform
|
|
|
|
meta_monitor_crtc_to_logical_transform (MetaMonitor *monitor,
|
|
|
|
MetaMonitorTransform transform)
|
|
|
|
{
|
|
|
|
MetaOutput *output = meta_monitor_get_main_output (monitor);
|
|
|
|
|
2020-02-18 05:45:26 -05:00
|
|
|
return meta_output_crtc_to_logical_transform (output, transform);
|
2017-10-24 06:43:58 -04:00
|
|
|
}
|
|
|
|
|
2017-11-03 06:27:57 -04:00
|
|
|
static void
|
|
|
|
meta_monitor_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (object);
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
if (priv->outputs)
|
|
|
|
{
|
2021-01-27 17:16:05 -05:00
|
|
|
g_list_foreach (priv->outputs, (GFunc) meta_output_unset_monitor, NULL);
|
2017-11-03 06:27:57 -04:00
|
|
|
g_list_free_full (priv->outputs, g_object_unref);
|
|
|
|
priv->outputs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_monitor_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (object);
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
g_hash_table_destroy (priv->mode_ids);
|
2016-12-14 04:22:07 -05:00
|
|
|
g_list_free_full (priv->modes, (GDestroyNotify) meta_monitor_mode_free);
|
2016-12-17 09:34:26 -05:00
|
|
|
meta_monitor_spec_free (priv->spec);
|
2019-06-26 05:24:19 -04:00
|
|
|
g_free (priv->display_name);
|
2017-09-10 23:12:03 -04:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_monitor_parent_class)->finalize (object);
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_init (MetaMonitor *monitor)
|
|
|
|
{
|
2017-06-14 00:04:09 -04:00
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
priv->mode_ids = g_hash_table_new (g_str_hash, g_str_equal);
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_class_init (MetaMonitorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2017-11-03 06:27:57 -04:00
|
|
|
object_class->dispose = meta_monitor_dispose;
|
2016-12-12 21:53:38 -05:00
|
|
|
object_class->finalize = meta_monitor_finalize;
|
|
|
|
}
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
static char *
|
|
|
|
generate_mode_id (MetaMonitorModeSpec *monitor_mode_spec)
|
|
|
|
{
|
2017-06-14 02:41:13 -04:00
|
|
|
gboolean is_interlaced;
|
2017-06-14 00:04:09 -04:00
|
|
|
char refresh_rate_str[G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE);
|
2017-06-14 00:04:09 -04:00
|
|
|
g_ascii_dtostr (refresh_rate_str, G_ASCII_DTOSTR_BUF_SIZE,
|
|
|
|
monitor_mode_spec->refresh_rate);
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
return g_strdup_printf ("%dx%d%s@%s",
|
2017-06-14 00:04:09 -04:00
|
|
|
monitor_mode_spec->width,
|
|
|
|
monitor_mode_spec->height,
|
2017-06-14 02:41:13 -04:00
|
|
|
is_interlaced ? "i" : "",
|
2017-06-14 00:04:09 -04:00
|
|
|
refresh_rate_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_monitor_add_mode (MetaMonitor *monitor,
|
2017-10-18 11:22:01 -04:00
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
gboolean replace)
|
2017-06-14 00:04:09 -04:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
2017-10-18 11:22:01 -04:00
|
|
|
MetaMonitorMode *existing_mode;
|
2017-06-14 00:04:09 -04:00
|
|
|
|
2017-10-18 11:22:01 -04:00
|
|
|
existing_mode = g_hash_table_lookup (priv->mode_ids,
|
|
|
|
meta_monitor_mode_get_id (monitor_mode));
|
|
|
|
if (existing_mode && !replace)
|
2017-06-14 00:04:09 -04:00
|
|
|
return FALSE;
|
|
|
|
|
2017-10-18 11:22:01 -04:00
|
|
|
if (existing_mode)
|
|
|
|
priv->modes = g_list_remove (priv->modes, existing_mode);
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
priv->modes = g_list_append (priv->modes, monitor_mode);
|
2017-10-18 11:22:01 -04:00
|
|
|
g_hash_table_replace (priv->mode_ids, monitor_mode->id, monitor_mode);
|
2017-06-14 00:04:09 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-10-24 06:43:58 -04:00
|
|
|
static MetaMonitorModeSpec
|
|
|
|
meta_monitor_create_spec (MetaMonitor *monitor,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
MetaCrtcMode *crtc_mode)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *crtc_mode_info =
|
|
|
|
meta_crtc_mode_get_info (crtc_mode);
|
2017-10-24 06:43:58 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (meta_monitor_transform_is_rotated (output_info->panel_orientation_transform))
|
2017-10-24 06:43:58 -04:00
|
|
|
{
|
|
|
|
int temp = width;
|
|
|
|
width = height;
|
|
|
|
height = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (MetaMonitorModeSpec) {
|
|
|
|
.width = width,
|
|
|
|
.height = height,
|
2020-02-26 18:08:58 -05:00
|
|
|
.refresh_rate = crtc_mode_info->refresh_rate,
|
|
|
|
.flags = crtc_mode_info->flags & HANDLED_CRTC_MODE_FLAGS
|
2017-10-24 06:43:58 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_normal);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaOutput *output;
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info;
|
2020-02-26 18:08:58 -05:00
|
|
|
MetaCrtcMode *preferred_mode;
|
2017-10-18 11:22:01 -04:00
|
|
|
MetaCrtcModeFlag preferred_mode_flags;
|
2016-12-14 04:22:07 -05:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
output = meta_monitor_get_main_output (monitor);
|
2020-02-26 03:45:07 -05:00
|
|
|
output_info = meta_output_get_info (output);
|
2020-02-26 18:08:58 -05:00
|
|
|
preferred_mode = output_info->preferred_mode;
|
|
|
|
preferred_mode_flags = meta_crtc_mode_get_info (preferred_mode)->flags;
|
2017-10-18 11:22:01 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
for (i = 0; i < output_info->n_modes; i++)
|
2016-12-14 04:22:07 -05:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
MetaCrtcMode *crtc_mode = output_info->modes[i];
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *crtc_mode_info =
|
|
|
|
meta_crtc_mode_get_info (crtc_mode);
|
2017-11-03 06:25:30 -04:00
|
|
|
MetaCrtc *crtc;
|
2016-12-14 04:22:07 -05:00
|
|
|
MetaMonitorMode *mode;
|
2017-10-18 11:22:01 -04:00
|
|
|
gboolean replace;
|
2016-12-14 04:22:07 -05:00
|
|
|
|
|
|
|
mode = g_new0 (MetaMonitorMode, 1);
|
2019-08-12 04:54:18 -04:00
|
|
|
mode->monitor = monitor;
|
2017-10-24 06:43:58 -04:00
|
|
|
mode->spec = meta_monitor_create_spec (monitor,
|
2020-02-26 18:08:58 -05:00
|
|
|
crtc_mode_info->width,
|
|
|
|
crtc_mode_info->height,
|
2017-10-24 06:43:58 -04:00
|
|
|
crtc_mode);
|
2017-06-14 00:04:09 -04:00
|
|
|
mode->id = generate_mode_id (&mode->spec);
|
2016-12-14 04:22:07 -05:00
|
|
|
mode->crtc_modes = g_new (MetaMonitorCrtcMode, 1);
|
|
|
|
mode->crtc_modes[0] = (MetaMonitorCrtcMode) {
|
|
|
|
.output = output,
|
|
|
|
.crtc_mode = crtc_mode
|
|
|
|
};
|
|
|
|
|
2017-10-18 11:22:01 -04:00
|
|
|
/*
|
|
|
|
* We don't distinguish between all available mode flags, just the ones
|
|
|
|
* that are configurable. We still need to pick some mode though, so
|
|
|
|
* prefer ones that has the same set of flags as the preferred mode;
|
|
|
|
* otherwise take the first one in the list. This guarantees that the
|
|
|
|
* preferred mode is always added.
|
|
|
|
*/
|
2020-02-26 18:08:58 -05:00
|
|
|
replace = crtc_mode_info->flags == preferred_mode_flags;
|
2017-10-18 11:22:01 -04:00
|
|
|
|
|
|
|
if (!meta_monitor_add_mode (monitor, mode, replace))
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
g_assert (crtc_mode != output_info->preferred_mode);
|
2017-10-18 11:22:01 -04:00
|
|
|
meta_monitor_mode_free (mode);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (crtc_mode == output_info->preferred_mode)
|
2016-12-17 09:32:05 -05:00
|
|
|
monitor_priv->preferred_mode = mode;
|
2017-11-03 06:25:30 -04:00
|
|
|
|
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
2020-02-26 04:37:53 -05:00
|
|
|
if (crtc)
|
|
|
|
{
|
|
|
|
const MetaCrtcConfig *crtc_config;
|
|
|
|
|
|
|
|
crtc_config = meta_crtc_get_config (crtc);
|
|
|
|
if (crtc_config && crtc_mode == crtc_config->mode)
|
|
|
|
monitor_priv->current_mode = mode;
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorNormal *
|
2021-01-26 08:49:25 -05:00
|
|
|
meta_monitor_normal_new (MetaMonitorManager *monitor_manager,
|
2019-06-26 05:24:19 -04:00
|
|
|
MetaOutput *output)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
|
|
|
MetaMonitorNormal *monitor_normal;
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitor *monitor;
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorPrivate *monitor_priv;
|
|
|
|
|
|
|
|
monitor_normal = g_object_new (META_TYPE_MONITOR_NORMAL, NULL);
|
2016-12-17 09:34:26 -05:00
|
|
|
monitor = META_MONITOR (monitor_normal);
|
|
|
|
monitor_priv = meta_monitor_get_instance_private (monitor);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2021-01-26 08:49:25 -05:00
|
|
|
monitor_priv->backend = meta_monitor_manager_get_backend (monitor_manager);
|
2017-05-11 05:24:53 -04:00
|
|
|
|
2017-11-03 06:27:57 -04:00
|
|
|
monitor_priv->outputs = g_list_append (NULL, g_object_ref (output));
|
2020-10-08 11:34:57 -04:00
|
|
|
meta_output_set_monitor (output, monitor);
|
|
|
|
|
2020-02-25 10:13:52 -05:00
|
|
|
monitor_priv->winsys_id = meta_output_get_id (output);
|
2017-04-28 03:34:27 -04:00
|
|
|
meta_monitor_generate_spec (monitor);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
meta_monitor_normal_generate_modes (monitor_normal);
|
|
|
|
|
2019-06-26 05:24:19 -04:00
|
|
|
monitor_priv->display_name = meta_monitor_make_display_name (monitor,
|
|
|
|
monitor_manager);
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
return monitor_normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaOutput *
|
|
|
|
meta_monitor_normal_get_main_output (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return monitor_priv->outputs->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-07-12 03:42:20 -04:00
|
|
|
meta_monitor_normal_derive_layout (MetaMonitor *monitor,
|
|
|
|
MetaRectangle *layout)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
|
|
|
MetaOutput *output;
|
2017-11-03 06:25:30 -04:00
|
|
|
MetaCrtc *crtc;
|
2020-02-26 04:37:53 -05:00
|
|
|
const MetaCrtcConfig *crtc_config;
|
2016-12-12 21:53:38 -05:00
|
|
|
|
|
|
|
output = meta_monitor_get_main_output (monitor);
|
2017-11-03 06:25:30 -04:00
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
2020-02-26 04:37:53 -05:00
|
|
|
crtc_config = meta_crtc_get_config (crtc);
|
2020-01-14 16:34:44 -05:00
|
|
|
|
|
|
|
g_return_if_fail (crtc_config);
|
|
|
|
|
|
|
|
meta_rectangle_from_graphene_rect (&crtc_config->layout,
|
|
|
|
META_ROUNDING_STRATEGY_ROUND,
|
|
|
|
layout);
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
2017-04-30 23:55:10 -04:00
|
|
|
static gboolean
|
|
|
|
meta_monitor_normal_get_suggested_position (MetaMonitor *monitor,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info =
|
|
|
|
meta_monitor_get_main_output_info (monitor);
|
2017-04-30 23:55:10 -04:00
|
|
|
|
2020-02-26 10:44:28 -05:00
|
|
|
if (!output_info->hotplug_mode_update)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (output_info->suggested_x < 0 && output_info->suggested_y < 0)
|
2017-04-30 23:55:10 -04:00
|
|
|
return FALSE;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
*x = output_info->suggested_x;
|
|
|
|
*y = output_info->suggested_y;
|
2017-04-30 23:55:10 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
static void
|
2019-03-08 13:13:00 -05:00
|
|
|
meta_monitor_normal_calculate_crtc_pos (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
MetaOutput *output,
|
|
|
|
MetaMonitorTransform crtc_transform,
|
|
|
|
int *out_x,
|
|
|
|
int *out_y)
|
2017-03-17 05:21:10 -04:00
|
|
|
{
|
|
|
|
*out_x = 0;
|
|
|
|
*out_y = 0;
|
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_normal_init (MetaMonitorNormal *monitor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_normal_class_init (MetaMonitorNormalClass *klass)
|
|
|
|
{
|
|
|
|
MetaMonitorClass *monitor_class = META_MONITOR_CLASS (klass);
|
|
|
|
|
|
|
|
monitor_class->get_main_output = meta_monitor_normal_get_main_output;
|
2017-07-12 03:42:20 -04:00
|
|
|
monitor_class->derive_layout = meta_monitor_normal_derive_layout;
|
2017-03-17 05:21:10 -04:00
|
|
|
monitor_class->calculate_crtc_pos = meta_monitor_normal_calculate_crtc_pos;
|
2017-04-30 23:55:10 -04:00
|
|
|
monitor_class->get_suggested_position = meta_monitor_normal_get_suggested_position;
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
2016-12-13 05:58:22 -05:00
|
|
|
uint32_t
|
|
|
|
meta_monitor_tiled_get_tile_group_id (MetaMonitorTiled *monitor_tiled)
|
|
|
|
{
|
|
|
|
return monitor_tiled->tile_group_id;
|
|
|
|
}
|
|
|
|
|
2017-01-09 02:35:03 -05:00
|
|
|
gboolean
|
|
|
|
meta_monitor_get_suggested_position (MetaMonitor *monitor,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
2017-04-30 23:55:10 -04:00
|
|
|
return META_MONITOR_GET_CLASS (monitor)->get_suggested_position (monitor,
|
|
|
|
x, y);
|
2017-01-09 02:35:03 -05:00
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
static void
|
2017-07-10 06:19:32 -04:00
|
|
|
add_tiled_monitor_outputs (MetaGpu *gpu,
|
|
|
|
MetaMonitorTiled *monitor_tiled)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (META_MONITOR (monitor_tiled));
|
2017-03-24 05:35:51 -04:00
|
|
|
GList *outputs;
|
|
|
|
GList *l;
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2017-07-10 06:19:32 -04:00
|
|
|
outputs = meta_gpu_get_outputs (gpu);
|
2017-03-24 05:35:51 -04:00
|
|
|
for (l = outputs; l; l = l->next)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
2017-03-24 05:35:51 -04:00
|
|
|
MetaOutput *output = l->data;
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
|
|
|
const MetaOutputInfo *origin_output_info;
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (output_info->tile_info.group_id != monitor_tiled->tile_group_id)
|
2016-12-12 21:53:38 -05:00
|
|
|
continue;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
origin_output_info = meta_output_get_info (monitor_tiled->origin_output);
|
|
|
|
g_warn_if_fail (output_info->subpixel_order ==
|
|
|
|
origin_output_info->subpixel_order);
|
2016-12-22 02:16:48 -05:00
|
|
|
|
2017-11-03 06:27:57 -04:00
|
|
|
monitor_priv->outputs = g_list_append (monitor_priv->outputs,
|
|
|
|
g_object_ref (output));
|
2020-10-08 11:34:57 -04:00
|
|
|
|
|
|
|
meta_output_set_monitor (output, META_MONITOR (monitor_tiled));
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
static void
|
2017-03-17 05:21:10 -04:00
|
|
|
calculate_tile_coordinate (MetaMonitor *monitor,
|
|
|
|
MetaOutput *output,
|
2017-03-21 02:17:18 -04:00
|
|
|
MetaMonitorTransform crtc_transform,
|
2017-03-17 05:21:10 -04:00
|
|
|
int *out_x,
|
|
|
|
int *out_y)
|
2016-12-14 04:22:07 -05:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2016-12-14 04:22:07 -05:00
|
|
|
GList *l;
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
for (l = monitor_priv->outputs; l; l = l->next)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *other_output_info = meta_output_get_info (l->data);
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2017-03-21 02:17:18 -04:00
|
|
|
switch (crtc_transform)
|
|
|
|
{
|
|
|
|
case META_MONITOR_TRANSFORM_NORMAL:
|
|
|
|
case META_MONITOR_TRANSFORM_FLIPPED:
|
2020-02-26 03:45:07 -05:00
|
|
|
if ((other_output_info->tile_info.loc_v_tile ==
|
|
|
|
output_info->tile_info.loc_v_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_h_tile <
|
|
|
|
output_info->tile_info.loc_h_tile))
|
|
|
|
x += other_output_info->tile_info.tile_w;
|
|
|
|
if ((other_output_info->tile_info.loc_h_tile ==
|
|
|
|
output_info->tile_info.loc_h_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_v_tile <
|
|
|
|
output_info->tile_info.loc_v_tile))
|
|
|
|
y += other_output_info->tile_info.tile_h;
|
2017-03-21 02:17:18 -04:00
|
|
|
break;
|
|
|
|
case META_MONITOR_TRANSFORM_180:
|
|
|
|
case META_MONITOR_TRANSFORM_FLIPPED_180:
|
2020-02-26 03:45:07 -05:00
|
|
|
if ((other_output_info->tile_info.loc_v_tile ==
|
|
|
|
output_info->tile_info.loc_v_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_h_tile >
|
|
|
|
output_info->tile_info.loc_h_tile))
|
|
|
|
x += other_output_info->tile_info.tile_w;
|
|
|
|
if ((other_output_info->tile_info.loc_h_tile ==
|
|
|
|
output_info->tile_info.loc_h_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_v_tile >
|
|
|
|
output_info->tile_info.loc_v_tile))
|
|
|
|
y += other_output_info->tile_info.tile_h;
|
2017-03-21 02:17:18 -04:00
|
|
|
break;
|
|
|
|
case META_MONITOR_TRANSFORM_270:
|
|
|
|
case META_MONITOR_TRANSFORM_FLIPPED_270:
|
2020-02-26 03:45:07 -05:00
|
|
|
if ((other_output_info->tile_info.loc_v_tile ==
|
|
|
|
output_info->tile_info.loc_v_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_h_tile >
|
|
|
|
output_info->tile_info.loc_h_tile))
|
|
|
|
y += other_output_info->tile_info.tile_w;
|
|
|
|
if ((other_output_info->tile_info.loc_h_tile ==
|
|
|
|
output_info->tile_info.loc_h_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_v_tile >
|
|
|
|
output_info->tile_info.loc_v_tile))
|
|
|
|
x += other_output_info->tile_info.tile_h;
|
2017-03-21 02:17:18 -04:00
|
|
|
break;
|
|
|
|
case META_MONITOR_TRANSFORM_90:
|
|
|
|
case META_MONITOR_TRANSFORM_FLIPPED_90:
|
2020-02-26 03:45:07 -05:00
|
|
|
if ((other_output_info->tile_info.loc_v_tile ==
|
|
|
|
output_info->tile_info.loc_v_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_h_tile <
|
|
|
|
output_info->tile_info.loc_h_tile))
|
|
|
|
y += other_output_info->tile_info.tile_w;
|
|
|
|
if ((other_output_info->tile_info.loc_h_tile ==
|
|
|
|
output_info->tile_info.loc_h_tile) &&
|
|
|
|
(other_output_info->tile_info.loc_v_tile <
|
|
|
|
output_info->tile_info.loc_v_tile))
|
|
|
|
x += other_output_info->tile_info.tile_h;
|
2017-03-21 02:17:18 -04:00
|
|
|
break;
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
*out_x = x;
|
|
|
|
*out_y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_tiled_calculate_tiled_size (MetaMonitor *monitor,
|
|
|
|
int *out_width,
|
|
|
|
int *out_height)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
for (l = monitor_priv->outputs; l; l = l->next)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (l->data);
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (output_info->tile_info.loc_v_tile == 0)
|
|
|
|
width += output_info->tile_info.tile_w;
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
if (output_info->tile_info.loc_h_tile == 0)
|
|
|
|
height += output_info->tile_info.tile_h;
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
*out_width = width;
|
|
|
|
*out_height = height;
|
|
|
|
}
|
|
|
|
|
2017-03-06 00:09:56 -05:00
|
|
|
static gboolean
|
|
|
|
is_monitor_mode_assigned (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (l = priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l->data;
|
|
|
|
MetaMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
|
2017-11-03 06:25:30 -04:00
|
|
|
MetaCrtc *crtc;
|
2020-02-26 04:37:53 -05:00
|
|
|
const MetaCrtcConfig *crtc_config;
|
2017-03-06 00:09:56 -05:00
|
|
|
|
2017-11-03 06:25:30 -04:00
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
2020-02-26 04:37:53 -05:00
|
|
|
crtc_config = crtc ? meta_crtc_get_config (crtc) : NULL;
|
|
|
|
|
2017-03-06 00:09:56 -05:00
|
|
|
if (monitor_crtc_mode->crtc_mode &&
|
2020-02-26 04:37:53 -05:00
|
|
|
(!crtc || !crtc_config ||
|
|
|
|
crtc_config->mode != monitor_crtc_mode->crtc_mode))
|
2017-03-06 00:09:56 -05:00
|
|
|
return FALSE;
|
2017-11-03 06:25:30 -04:00
|
|
|
else if (!monitor_crtc_mode->crtc_mode && crtc)
|
2017-03-06 00:09:56 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-04-28 03:36:51 -04:00
|
|
|
static gboolean
|
|
|
|
is_crtc_mode_tiled (MetaOutput *output,
|
|
|
|
MetaCrtcMode *crtc_mode)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *crtc_mode_info = meta_crtc_mode_get_info (crtc_mode);
|
2020-02-26 03:45:07 -05:00
|
|
|
|
2020-02-26 18:08:58 -05:00
|
|
|
return (crtc_mode_info->width == (int) output_info->tile_info.tile_w &&
|
|
|
|
crtc_mode_info->height == (int) output_info->tile_info.tile_h);
|
2017-04-28 03:36:51 -04:00
|
|
|
}
|
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
static MetaCrtcMode *
|
2017-06-14 02:41:13 -04:00
|
|
|
find_tiled_crtc_mode (MetaOutput *output,
|
|
|
|
MetaCrtcMode *reference_crtc_mode)
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *reference_crtc_mode_info =
|
|
|
|
meta_crtc_mode_get_info (reference_crtc_mode);
|
2017-05-01 00:01:41 -04:00
|
|
|
MetaCrtcMode *crtc_mode;
|
|
|
|
unsigned int i;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
crtc_mode = output_info->preferred_mode;
|
2017-05-01 00:01:41 -04:00
|
|
|
if (is_crtc_mode_tiled (output, crtc_mode))
|
|
|
|
return crtc_mode;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
for (i = 0; i < output_info->n_modes; i++)
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *crtc_mode_info;
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
crtc_mode = output_info->modes[i];
|
2020-02-26 18:08:58 -05:00
|
|
|
crtc_mode_info = meta_crtc_mode_get_info (crtc_mode);
|
2017-05-01 00:01:41 -04:00
|
|
|
|
|
|
|
if (!is_crtc_mode_tiled (output, crtc_mode))
|
|
|
|
continue;
|
|
|
|
|
2020-02-26 18:08:58 -05:00
|
|
|
if (crtc_mode_info->refresh_rate != reference_crtc_mode_info->refresh_rate)
|
2017-06-14 02:41:13 -04:00
|
|
|
continue;
|
|
|
|
|
2020-02-26 18:08:58 -05:00
|
|
|
if (crtc_mode_info->flags != reference_crtc_mode_info->flags)
|
2017-05-01 00:01:41 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
return crtc_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-03-06 00:09:56 -05:00
|
|
|
static MetaMonitorMode *
|
2017-05-01 00:01:41 -04:00
|
|
|
create_tiled_monitor_mode (MetaMonitorTiled *monitor_tiled,
|
2017-06-14 02:41:13 -04:00
|
|
|
MetaCrtcMode *reference_crtc_mode,
|
2017-05-01 00:01:41 -04:00
|
|
|
gboolean *out_is_preferred)
|
2016-12-14 04:22:07 -05:00
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
2017-03-17 05:21:10 -04:00
|
|
|
MetaMonitorModeTiled *mode;
|
2017-06-14 00:04:09 -04:00
|
|
|
int width, height;
|
2016-12-14 04:22:07 -05:00
|
|
|
GList *l;
|
2017-05-01 00:01:41 -04:00
|
|
|
unsigned int i;
|
|
|
|
gboolean is_preferred = TRUE;
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
mode = g_new0 (MetaMonitorModeTiled, 1);
|
|
|
|
mode->is_tiled = TRUE;
|
2017-06-14 00:04:09 -04:00
|
|
|
meta_monitor_tiled_calculate_tiled_size (monitor, &width, &height);
|
2019-08-12 04:54:18 -04:00
|
|
|
mode->parent.monitor = monitor;
|
2017-10-24 06:43:58 -04:00
|
|
|
mode->parent.spec =
|
|
|
|
meta_monitor_create_spec (monitor, width, height, reference_crtc_mode);
|
2017-06-14 00:04:09 -04:00
|
|
|
mode->parent.id = generate_mode_id (&mode->parent.spec);
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
mode->parent.crtc_modes = g_new0 (MetaMonitorCrtcMode,
|
|
|
|
g_list_length (monitor_priv->outputs));
|
2016-12-14 04:22:07 -05:00
|
|
|
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l->data;
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2017-05-01 00:01:41 -04:00
|
|
|
MetaCrtcMode *tiled_crtc_mode;
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
tiled_crtc_mode = find_tiled_crtc_mode (output, reference_crtc_mode);
|
2017-05-01 00:01:41 -04:00
|
|
|
if (!tiled_crtc_mode)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
g_warning ("No tiled mode found on %s", meta_output_get_name (output));
|
2017-05-01 00:01:41 -04:00
|
|
|
meta_monitor_mode_free ((MetaMonitorMode *) mode);
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
mode->parent.crtc_modes[i] = (MetaMonitorCrtcMode) {
|
2016-12-14 04:22:07 -05:00
|
|
|
.output = output,
|
2017-05-01 00:01:41 -04:00
|
|
|
.crtc_mode = tiled_crtc_mode
|
2016-12-14 04:22:07 -05:00
|
|
|
};
|
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
is_preferred = (is_preferred &&
|
|
|
|
tiled_crtc_mode == output_info->preferred_mode);
|
2017-03-06 00:09:56 -05:00
|
|
|
}
|
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
*out_is_preferred = is_preferred;
|
|
|
|
|
|
|
|
return (MetaMonitorMode *) mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
generate_tiled_monitor_modes (MetaMonitorTiled *monitor_tiled)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaOutput *main_output;
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *main_output_info;
|
2017-05-01 00:01:41 -04:00
|
|
|
GList *tiled_modes = NULL;
|
|
|
|
unsigned int i;
|
2017-06-14 00:04:09 -04:00
|
|
|
MetaMonitorMode *best_mode = NULL;
|
|
|
|
GList *l;
|
2017-05-01 00:01:41 -04:00
|
|
|
|
|
|
|
main_output = meta_monitor_get_main_output (META_MONITOR (monitor_tiled));
|
2020-02-26 03:45:07 -05:00
|
|
|
main_output_info = meta_output_get_info (main_output);
|
2017-05-01 00:01:41 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
for (i = 0; i < main_output_info->n_modes; i++)
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
MetaCrtcMode *reference_crtc_mode = main_output_info->modes[i];
|
2017-05-01 00:01:41 -04:00
|
|
|
MetaMonitorMode *mode;
|
|
|
|
gboolean is_preferred;
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
if (!is_crtc_mode_tiled (main_output, reference_crtc_mode))
|
2017-05-01 00:01:41 -04:00
|
|
|
continue;
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
mode = create_tiled_monitor_mode (monitor_tiled, reference_crtc_mode,
|
2017-05-01 00:01:41 -04:00
|
|
|
&is_preferred);
|
|
|
|
if (!mode)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tiled_modes = g_list_append (tiled_modes, mode);
|
|
|
|
|
|
|
|
if (is_monitor_mode_assigned (monitor, mode))
|
|
|
|
monitor_priv->current_mode = mode;
|
|
|
|
|
|
|
|
if (is_preferred)
|
|
|
|
monitor_priv->preferred_mode = mode;
|
|
|
|
}
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
while ((l = tiled_modes))
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2017-06-14 00:04:09 -04:00
|
|
|
MetaMonitorMode *mode = l->data;
|
|
|
|
|
|
|
|
tiled_modes = g_list_remove_link (tiled_modes, l);
|
2017-05-01 00:01:41 -04:00
|
|
|
|
2017-10-18 11:22:01 -04:00
|
|
|
if (!meta_monitor_add_mode (monitor, mode, FALSE))
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2017-06-14 00:04:09 -04:00
|
|
|
meta_monitor_mode_free (mode);
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-01 00:01:41 -04:00
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
if (!monitor_priv->preferred_mode)
|
|
|
|
{
|
2017-05-01 00:01:41 -04:00
|
|
|
if (!best_mode ||
|
|
|
|
mode->spec.refresh_rate > best_mode->spec.refresh_rate)
|
|
|
|
best_mode = mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
if (best_mode)
|
|
|
|
monitor_priv->preferred_mode = best_mode;
|
2017-03-06 00:09:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static MetaMonitorMode *
|
|
|
|
create_untiled_monitor_mode (MetaMonitorTiled *monitor_tiled,
|
|
|
|
MetaOutput *main_output,
|
|
|
|
MetaCrtcMode *crtc_mode)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
2017-03-17 05:21:10 -04:00
|
|
|
MetaMonitorModeTiled *mode;
|
2020-02-26 18:08:58 -05:00
|
|
|
const MetaCrtcModeInfo *crtc_mode_info;
|
2017-03-06 00:09:56 -05:00
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
2017-04-28 03:36:51 -04:00
|
|
|
if (is_crtc_mode_tiled (main_output, crtc_mode))
|
2017-03-06 00:09:56 -05:00
|
|
|
return NULL;
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
mode = g_new0 (MetaMonitorModeTiled, 1);
|
|
|
|
mode->is_tiled = FALSE;
|
2019-08-12 04:54:18 -04:00
|
|
|
mode->parent.monitor = monitor;
|
2020-02-26 18:08:58 -05:00
|
|
|
|
|
|
|
crtc_mode_info = meta_crtc_mode_get_info (crtc_mode);
|
2017-10-24 06:43:58 -04:00
|
|
|
mode->parent.spec = meta_monitor_create_spec (monitor,
|
2020-02-26 18:08:58 -05:00
|
|
|
crtc_mode_info->width,
|
|
|
|
crtc_mode_info->height,
|
2017-10-24 06:43:58 -04:00
|
|
|
crtc_mode);
|
2017-06-14 00:04:09 -04:00
|
|
|
mode->parent.id = generate_mode_id (&mode->parent.spec);
|
2017-03-17 05:21:10 -04:00
|
|
|
mode->parent.crtc_modes = g_new0 (MetaMonitorCrtcMode,
|
2017-06-14 00:23:53 -04:00
|
|
|
g_list_length (monitor_priv->outputs));
|
2017-03-06 00:09:56 -05:00
|
|
|
|
|
|
|
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l->data;
|
2016-12-22 02:22:13 -05:00
|
|
|
|
2017-03-06 00:09:56 -05:00
|
|
|
if (output == main_output)
|
|
|
|
{
|
2017-03-17 05:21:10 -04:00
|
|
|
mode->parent.crtc_modes[i] = (MetaMonitorCrtcMode) {
|
2017-03-06 00:09:56 -05:00
|
|
|
.output = output,
|
|
|
|
.crtc_mode = crtc_mode
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-17 05:21:10 -04:00
|
|
|
mode->parent.crtc_modes[i] = (MetaMonitorCrtcMode) {
|
2017-03-06 00:09:56 -05:00
|
|
|
.output = output,
|
|
|
|
.crtc_mode = NULL
|
|
|
|
};
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
return &mode->parent;
|
2017-03-06 00:09:56 -05:00
|
|
|
}
|
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
static int
|
|
|
|
count_untiled_crtc_modes (MetaOutput *output)
|
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2017-05-01 00:01:41 -04:00
|
|
|
int count;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
count = 0;
|
2020-02-26 03:45:07 -05:00
|
|
|
for (i = 0; i < output_info->n_modes; i++)
|
2017-05-01 00:01:41 -04:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
MetaCrtcMode *crtc_mode = output_info->modes[i];
|
2017-05-01 00:01:41 -04:00
|
|
|
|
|
|
|
if (!is_crtc_mode_tiled (output, crtc_mode))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaOutput *
|
|
|
|
find_untiled_output (MetaMonitorTiled *monitor_tiled)
|
2017-03-06 00:09:56 -05:00
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
2017-05-01 00:01:41 -04:00
|
|
|
MetaOutput *best_output;
|
|
|
|
int best_untiled_crtc_mode_count;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
best_output = monitor_tiled->origin_output;
|
|
|
|
best_untiled_crtc_mode_count =
|
|
|
|
count_untiled_crtc_modes (monitor_tiled->origin_output);
|
|
|
|
|
|
|
|
for (l = monitor_priv->outputs; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l->data;
|
|
|
|
int untiled_crtc_mode_count;
|
|
|
|
|
|
|
|
if (output == monitor_tiled->origin_output)
|
|
|
|
continue;
|
2017-03-06 00:09:56 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
untiled_crtc_mode_count = count_untiled_crtc_modes (output);
|
|
|
|
if (untiled_crtc_mode_count > best_untiled_crtc_mode_count)
|
|
|
|
{
|
|
|
|
best_untiled_crtc_mode_count = untiled_crtc_mode_count;
|
|
|
|
best_output = output;
|
|
|
|
}
|
|
|
|
}
|
2017-03-06 00:09:56 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
return best_output;
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
static void
|
|
|
|
generate_untiled_monitor_modes (MetaMonitorTiled *monitor_tiled)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaOutput *main_output;
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *main_output_info;
|
2017-05-01 00:01:41 -04:00
|
|
|
unsigned int i;
|
2016-12-22 02:22:13 -05:00
|
|
|
|
2017-03-06 00:09:56 -05:00
|
|
|
main_output = meta_monitor_get_main_output (monitor);
|
2020-02-26 03:45:07 -05:00
|
|
|
main_output_info = meta_output_get_info (main_output);
|
2017-05-01 00:01:41 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
for (i = 0; i < main_output_info->n_modes; i++)
|
2017-03-06 00:09:56 -05:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
MetaCrtcMode *crtc_mode = main_output_info->modes[i];
|
2017-05-01 00:01:41 -04:00
|
|
|
MetaMonitorMode *mode;
|
2017-03-06 00:09:56 -05:00
|
|
|
|
|
|
|
mode = create_untiled_monitor_mode (monitor_tiled,
|
|
|
|
main_output,
|
|
|
|
crtc_mode);
|
2017-05-01 00:01:41 -04:00
|
|
|
if (!mode)
|
|
|
|
continue;
|
|
|
|
|
2017-10-18 11:22:01 -04:00
|
|
|
if (!meta_monitor_add_mode (monitor, mode, FALSE))
|
2017-06-14 00:04:09 -04:00
|
|
|
{
|
|
|
|
meta_monitor_mode_free (mode);
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-01 00:01:41 -04:00
|
|
|
|
|
|
|
if (is_monitor_mode_assigned (monitor, mode))
|
2017-03-06 00:09:56 -05:00
|
|
|
{
|
2017-05-01 00:01:41 -04:00
|
|
|
g_assert (!monitor_priv->current_mode);
|
|
|
|
monitor_priv->current_mode = mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!monitor_priv->preferred_mode &&
|
2020-02-26 03:45:07 -05:00
|
|
|
crtc_mode == main_output_info->preferred_mode)
|
2017-05-01 00:01:41 -04:00
|
|
|
monitor_priv->preferred_mode = mode;
|
|
|
|
}
|
|
|
|
}
|
2017-03-06 00:09:56 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
static MetaMonitorMode *
|
|
|
|
find_best_mode (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaMonitorMode *best_mode = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = monitor_priv->modes; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaMonitorMode *mode = l->data;
|
|
|
|
int area, best_area;
|
|
|
|
|
|
|
|
if (!best_mode)
|
|
|
|
{
|
|
|
|
best_mode = mode;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
area = mode->spec.width * mode->spec.height;
|
|
|
|
best_area = best_mode->spec.width * best_mode->spec.height;
|
|
|
|
if (area > best_area)
|
|
|
|
{
|
|
|
|
best_mode = mode;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode->spec.refresh_rate > best_mode->spec.refresh_rate)
|
|
|
|
{
|
|
|
|
best_mode = mode;
|
|
|
|
continue;
|
2017-03-06 00:09:56 -05:00
|
|
|
}
|
|
|
|
}
|
2017-05-01 00:01:41 -04:00
|
|
|
|
|
|
|
return best_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_tiled_generate_modes (MetaMonitorTiled *monitor_tiled)
|
|
|
|
{
|
|
|
|
MetaMonitor *monitor = META_MONITOR (monitor_tiled);
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tiled monitors may look a bit different from each other, depending on the
|
|
|
|
* monitor itself, the driver, etc.
|
|
|
|
*
|
|
|
|
* On some, the tiled modes will be the preferred CRTC modes, and running
|
|
|
|
* untiled is done by only enabling (0, 0) tile. In this case, things are
|
|
|
|
* pretty straight forward.
|
|
|
|
*
|
|
|
|
* Other times a monitor may have some bogus mode preferred on the main tile,
|
|
|
|
* and an untiled mode preferred on the non-main tile, and there seems to be
|
|
|
|
* no guarantee that the (0, 0) tile is the one that should drive the
|
|
|
|
* non-tiled mode.
|
|
|
|
*
|
|
|
|
* To handle both these cases, the following hueristics are implemented:
|
|
|
|
*
|
|
|
|
* 1) Find all the tiled CRTC modes of the (0, 0) tile, and create tiled
|
|
|
|
* monitor modes for all tiles based on these.
|
|
|
|
* 2) If there is any tiled monitor mode combination where all CRTC modes
|
|
|
|
* are the preferred ones, that one is marked as preferred.
|
|
|
|
* 3) If there is no preferred mode determined so far, assume the tiled
|
|
|
|
* monitor mode with the highest refresh rate is preferred.
|
|
|
|
* 4) Find the tile with highest number of untiled CRTC modes available,
|
|
|
|
* assume this is the one driving the monitor in untiled mode, and
|
|
|
|
* create monitor modes for all untiled CRTC modes of that tile. If
|
|
|
|
* there is still no preferred mode, set any untiled mode as preferred
|
|
|
|
* if the CRTC mode is marked as such.
|
|
|
|
* 5) If at this point there is still no preferred mode, just pick the one
|
|
|
|
* with the highest number of pixels and highest refresh rate.
|
|
|
|
*
|
|
|
|
* Note that this ignores the preference if the preference is a non-tiled
|
|
|
|
* mode. This seems to be the case on some systems, where the user tends to
|
|
|
|
* manually set up the tiled mode anyway.
|
|
|
|
*/
|
|
|
|
|
|
|
|
generate_tiled_monitor_modes (monitor_tiled);
|
|
|
|
|
|
|
|
if (!monitor_priv->preferred_mode)
|
|
|
|
g_warning ("Tiled monitor on %s didn't have any tiled modes",
|
|
|
|
monitor_priv->spec->connector);
|
|
|
|
|
|
|
|
generate_untiled_monitor_modes (monitor_tiled);
|
|
|
|
|
|
|
|
if (!monitor_priv->preferred_mode)
|
|
|
|
{
|
|
|
|
g_warning ("Tiled monitor on %s didn't have a valid preferred mode",
|
|
|
|
monitor_priv->spec->connector);
|
|
|
|
monitor_priv->preferred_mode = find_best_mode (monitor);
|
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorTiled *
|
2021-01-26 08:49:25 -05:00
|
|
|
meta_monitor_tiled_new (MetaMonitorManager *monitor_manager,
|
2019-01-11 09:35:42 -05:00
|
|
|
MetaOutput *output)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
2020-02-26 03:45:07 -05:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorTiled *monitor_tiled;
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitor *monitor;
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorPrivate *monitor_priv;
|
|
|
|
|
|
|
|
monitor_tiled = g_object_new (META_TYPE_MONITOR_TILED, NULL);
|
2016-12-17 09:34:26 -05:00
|
|
|
monitor = META_MONITOR (monitor_tiled);
|
|
|
|
monitor_priv = meta_monitor_get_instance_private (monitor);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2021-01-26 08:49:25 -05:00
|
|
|
monitor_priv->backend = meta_monitor_manager_get_backend (monitor_manager);
|
2017-05-11 05:24:53 -04:00
|
|
|
|
2020-02-26 03:45:07 -05:00
|
|
|
monitor_tiled->tile_group_id = output_info->tile_info.group_id;
|
2020-02-25 10:13:52 -05:00
|
|
|
monitor_priv->winsys_id = meta_output_get_id (output);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
monitor_tiled->origin_output = output;
|
2021-01-26 08:49:25 -05:00
|
|
|
add_tiled_monitor_outputs (meta_output_get_gpu (output), monitor_tiled);
|
2016-12-12 21:53:38 -05:00
|
|
|
|
2017-05-01 00:01:41 -04:00
|
|
|
monitor_tiled->main_output = find_untiled_output (monitor_tiled);
|
|
|
|
|
2017-04-28 03:34:27 -04:00
|
|
|
meta_monitor_generate_spec (monitor);
|
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
monitor_tiled->monitor_manager = monitor_manager;
|
2016-12-13 05:58:22 -05:00
|
|
|
meta_monitor_manager_tiled_monitor_added (monitor_manager,
|
|
|
|
META_MONITOR (monitor_tiled));
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
meta_monitor_tiled_generate_modes (monitor_tiled);
|
|
|
|
|
2019-06-26 05:24:19 -04:00
|
|
|
monitor_priv->display_name = meta_monitor_make_display_name (monitor,
|
|
|
|
monitor_manager);
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
return monitor_tiled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaOutput *
|
|
|
|
meta_monitor_tiled_get_main_output (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorTiled *monitor_tiled = META_MONITOR_TILED (monitor);
|
|
|
|
|
|
|
|
return monitor_tiled->main_output;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-10-24 03:54:54 -04:00
|
|
|
meta_monitor_tiled_derive_layout (MetaMonitor *monitor,
|
|
|
|
MetaRectangle *layout)
|
2016-12-12 21:53:38 -05:00
|
|
|
{
|
2017-03-06 23:34:38 -05:00
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
2020-01-14 16:34:44 -05:00
|
|
|
float min_x, min_y, max_x, max_y;
|
2017-03-06 23:34:38 -05:00
|
|
|
|
2020-01-14 16:34:44 -05:00
|
|
|
min_x = FLT_MAX;
|
|
|
|
min_y = FLT_MAX;
|
|
|
|
max_x = 0.0;
|
|
|
|
max_y = 0.0;
|
2017-03-06 23:34:38 -05:00
|
|
|
for (l = monitor_priv->outputs; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaOutput *output = l->data;
|
2017-11-03 06:25:30 -04:00
|
|
|
MetaCrtc *crtc;
|
2020-02-26 04:37:53 -05:00
|
|
|
const MetaCrtcConfig *crtc_config;
|
|
|
|
const graphene_rect_t *crtc_layout;
|
2017-03-06 23:34:38 -05:00
|
|
|
|
2017-11-03 06:25:30 -04:00
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
|
|
|
if (!crtc)
|
2017-03-06 23:34:38 -05:00
|
|
|
continue;
|
|
|
|
|
2020-02-26 04:37:53 -05:00
|
|
|
crtc_config = meta_crtc_get_config (crtc);
|
2020-01-14 16:34:44 -05:00
|
|
|
g_return_if_fail (crtc_config);
|
|
|
|
|
|
|
|
crtc_layout = &crtc_config->layout;
|
|
|
|
|
|
|
|
min_x = MIN (crtc_layout->origin.x, min_x);
|
|
|
|
min_y = MIN (crtc_layout->origin.y, min_y);
|
|
|
|
max_x = MAX (crtc_layout->origin.x + crtc_layout->size.width, max_x);
|
|
|
|
max_y = MAX (crtc_layout->origin.y + crtc_layout->size.height, max_y);
|
2017-03-06 23:34:38 -05:00
|
|
|
}
|
|
|
|
|
2017-07-12 03:42:20 -04:00
|
|
|
*layout = (MetaRectangle) {
|
2020-01-14 16:34:44 -05:00
|
|
|
.x = roundf (min_x),
|
|
|
|
.y = roundf (min_y),
|
|
|
|
.width = roundf (max_x - min_x),
|
|
|
|
.height = roundf (max_y - min_y)
|
2017-07-12 03:42:20 -04:00
|
|
|
};
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
|
|
|
|
2017-04-30 23:55:10 -04:00
|
|
|
static gboolean
|
|
|
|
meta_monitor_tiled_get_suggested_position (MetaMonitor *monitor,
|
|
|
|
int *x,
|
|
|
|
int *y)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
static void
|
2019-03-08 13:13:00 -05:00
|
|
|
meta_monitor_tiled_calculate_crtc_pos (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
MetaOutput *output,
|
|
|
|
MetaMonitorTransform crtc_transform,
|
|
|
|
int *out_x,
|
|
|
|
int *out_y)
|
2017-03-17 05:21:10 -04:00
|
|
|
{
|
|
|
|
MetaMonitorModeTiled *mode_tiled = (MetaMonitorModeTiled *) monitor_mode;
|
|
|
|
|
|
|
|
if (mode_tiled->is_tiled)
|
|
|
|
{
|
2017-03-21 02:17:18 -04:00
|
|
|
calculate_tile_coordinate (monitor, output, crtc_transform,
|
2017-03-17 05:21:10 -04:00
|
|
|
out_x, out_y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*out_x = 0;
|
|
|
|
*out_y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-13 05:58:22 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_tiled_finalize (GObject *object)
|
|
|
|
{
|
2019-01-11 09:35:42 -05:00
|
|
|
MetaMonitorTiled *monitor_tiled = META_MONITOR_TILED (object);
|
2016-12-13 05:58:22 -05:00
|
|
|
|
2019-01-11 09:35:42 -05:00
|
|
|
meta_monitor_manager_tiled_monitor_removed (monitor_tiled->monitor_manager,
|
|
|
|
META_MONITOR (monitor_tiled));
|
2017-09-10 23:12:03 -04:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_monitor_tiled_parent_class)->finalize (object);
|
2016-12-13 05:58:22 -05:00
|
|
|
}
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
static void
|
|
|
|
meta_monitor_tiled_init (MetaMonitorTiled *monitor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_tiled_class_init (MetaMonitorTiledClass *klass)
|
|
|
|
{
|
2016-12-13 05:58:22 -05:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2016-12-12 21:53:38 -05:00
|
|
|
MetaMonitorClass *monitor_class = META_MONITOR_CLASS (klass);
|
|
|
|
|
2016-12-13 05:58:22 -05:00
|
|
|
object_class->finalize = meta_monitor_tiled_finalize;
|
|
|
|
|
2016-12-12 21:53:38 -05:00
|
|
|
monitor_class->get_main_output = meta_monitor_tiled_get_main_output;
|
2017-10-24 03:54:54 -04:00
|
|
|
monitor_class->derive_layout = meta_monitor_tiled_derive_layout;
|
2017-03-17 05:21:10 -04:00
|
|
|
monitor_class->calculate_crtc_pos = meta_monitor_tiled_calculate_crtc_pos;
|
2017-04-30 23:55:10 -04:00
|
|
|
monitor_class->get_suggested_position = meta_monitor_tiled_get_suggested_position;
|
2016-12-12 21:53:38 -05:00
|
|
|
}
|
2016-12-14 04:22:07 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
meta_monitor_mode_free (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
2017-06-14 00:04:09 -04:00
|
|
|
g_free (monitor_mode->id);
|
2016-12-14 04:22:07 -05:00
|
|
|
g_free (monitor_mode->crtc_modes);
|
|
|
|
g_free (monitor_mode);
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:34:26 -05:00
|
|
|
MetaMonitorSpec *
|
|
|
|
meta_monitor_get_spec (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return priv->spec;
|
|
|
|
}
|
|
|
|
|
2017-01-09 01:31:18 -05:00
|
|
|
MetaLogicalMonitor *
|
|
|
|
meta_monitor_get_logical_monitor (MetaMonitor *monitor)
|
|
|
|
{
|
2020-01-16 04:10:42 -05:00
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
2017-01-09 01:31:18 -05:00
|
|
|
|
2020-01-16 04:10:42 -05:00
|
|
|
return priv->logical_monitor;
|
2017-01-09 01:31:18 -05:00
|
|
|
}
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
MetaMonitorMode *
|
|
|
|
meta_monitor_get_mode_from_id (MetaMonitor *monitor,
|
|
|
|
const char *monitor_mode_id)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return g_hash_table_lookup (priv->mode_ids, monitor_mode_id);
|
|
|
|
}
|
|
|
|
|
2016-12-21 00:03:35 -05:00
|
|
|
static gboolean
|
|
|
|
meta_monitor_mode_spec_equals (MetaMonitorModeSpec *monitor_mode_spec,
|
|
|
|
MetaMonitorModeSpec *other_monitor_mode_spec)
|
|
|
|
{
|
|
|
|
return (monitor_mode_spec->width == other_monitor_mode_spec->width &&
|
|
|
|
monitor_mode_spec->height == other_monitor_mode_spec->height &&
|
2017-09-14 06:42:47 -04:00
|
|
|
ABS (monitor_mode_spec->refresh_rate -
|
|
|
|
other_monitor_mode_spec->refresh_rate) < MAXIMUM_REFRESH_RATE_DIFF &&
|
2017-06-14 02:41:13 -04:00
|
|
|
monitor_mode_spec->flags == other_monitor_mode_spec->flags);
|
2016-12-21 00:03:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaMonitorMode *
|
|
|
|
meta_monitor_get_mode_from_spec (MetaMonitor *monitor,
|
|
|
|
MetaMonitorModeSpec *monitor_mode_spec)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = priv->modes; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaMonitorMode *monitor_mode = l->data;
|
|
|
|
|
|
|
|
if (meta_monitor_mode_spec_equals (monitor_mode_spec,
|
|
|
|
&monitor_mode->spec))
|
|
|
|
return monitor_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:32:05 -05:00
|
|
|
MetaMonitorMode *
|
|
|
|
meta_monitor_get_preferred_mode (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return priv->preferred_mode;
|
|
|
|
}
|
|
|
|
|
2016-12-22 02:22:13 -05:00
|
|
|
MetaMonitorMode *
|
|
|
|
meta_monitor_get_current_mode (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return priv->current_mode;
|
|
|
|
}
|
|
|
|
|
monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.
An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.
Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.
https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 07:18:51 -04:00
|
|
|
static gboolean
|
|
|
|
is_current_mode_known (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaOutput *output;
|
|
|
|
MetaCrtc *crtc;
|
|
|
|
|
|
|
|
output = meta_monitor_get_main_output (monitor);
|
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
|
|
|
|
2020-02-26 04:37:53 -05:00
|
|
|
return (meta_monitor_is_active (monitor) ==
|
|
|
|
(crtc && meta_crtc_get_config (crtc)));
|
monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.
An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.
Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.
https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 07:18:51 -04:00
|
|
|
}
|
|
|
|
|
2016-12-22 02:22:13 -05:00
|
|
|
void
|
|
|
|
meta_monitor_derive_current_mode (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
MetaMonitorMode *current_mode = NULL;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = priv->modes; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaMonitorMode *mode = l->data;
|
|
|
|
|
|
|
|
if (is_monitor_mode_assigned (monitor, mode))
|
|
|
|
{
|
|
|
|
current_mode = mode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->current_mode = current_mode;
|
monitor: Use current monitor mode to check whether active
For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.
An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.
Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.
https://gitlab.gnome.org/GNOME/mutter/issues/130
2018-07-31 07:18:51 -04:00
|
|
|
|
|
|
|
g_warn_if_fail (is_current_mode_known (monitor));
|
2016-12-22 02:22:13 -05:00
|
|
|
}
|
|
|
|
|
2017-01-09 01:31:18 -05:00
|
|
|
void
|
|
|
|
meta_monitor_set_current_mode (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
priv->current_mode = mode;
|
|
|
|
}
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
GList *
|
|
|
|
meta_monitor_get_modes (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return priv->modes;
|
|
|
|
}
|
|
|
|
|
2017-03-17 05:21:10 -04:00
|
|
|
void
|
2019-03-08 13:13:00 -05:00
|
|
|
meta_monitor_calculate_crtc_pos (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
MetaOutput *output,
|
|
|
|
MetaMonitorTransform crtc_transform,
|
|
|
|
int *out_x,
|
|
|
|
int *out_y)
|
2017-03-17 05:21:10 -04:00
|
|
|
{
|
|
|
|
META_MONITOR_GET_CLASS (monitor)->calculate_crtc_pos (monitor,
|
|
|
|
monitor_mode,
|
|
|
|
output,
|
2017-03-21 02:17:18 -04:00
|
|
|
crtc_transform,
|
2017-03-17 05:21:10 -04:00
|
|
|
out_x,
|
|
|
|
out_y);
|
|
|
|
}
|
|
|
|
|
2017-04-21 05:28:22 -04:00
|
|
|
/* The minimum resolution at which we turn on a window-scale of 2 */
|
|
|
|
#define HIDPI_LIMIT 192
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The minimum screen height at which we turn on a window-scale of 2;
|
|
|
|
* below this there just isn't enough vertical real estate for GNOME
|
|
|
|
* apps to work, and it's better to just be tiny
|
|
|
|
*/
|
|
|
|
#define HIDPI_MIN_HEIGHT 1200
|
|
|
|
|
|
|
|
/* From http://en.wikipedia.org/wiki/4K_resolution#Resolutions_of_common_formats */
|
|
|
|
#define SMALLEST_4K_WIDTH 3656
|
|
|
|
|
2017-05-25 04:12:51 -04:00
|
|
|
static float
|
2017-04-21 05:28:22 -04:00
|
|
|
calculate_scale (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
int resolution_width, resolution_height;
|
|
|
|
int width_mm, height_mm;
|
|
|
|
int scale;
|
|
|
|
|
2017-05-25 04:12:51 -04:00
|
|
|
scale = 1.0;
|
2017-04-21 05:28:22 -04:00
|
|
|
|
|
|
|
meta_monitor_mode_get_resolution (monitor_mode,
|
|
|
|
&resolution_width,
|
|
|
|
&resolution_height);
|
|
|
|
|
|
|
|
if (resolution_height < HIDPI_MIN_HEIGHT)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* 4K TV */
|
|
|
|
switch (meta_monitor_get_connector_type (monitor))
|
|
|
|
{
|
|
|
|
case META_CONNECTOR_TYPE_HDMIA:
|
|
|
|
case META_CONNECTOR_TYPE_HDMIB:
|
2017-05-19 12:58:49 -04:00
|
|
|
if (resolution_width < SMALLEST_4K_WIDTH)
|
2017-04-21 05:28:22 -04:00
|
|
|
goto out;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Somebody encoded the aspect ratio (16/9 or 16/10) instead of the physical
|
|
|
|
* size.
|
|
|
|
*/
|
2018-09-24 03:48:37 -04:00
|
|
|
if (meta_monitor_has_aspect_as_size (monitor))
|
2017-04-21 05:28:22 -04:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (width_mm > 0 && height_mm > 0)
|
|
|
|
{
|
|
|
|
double dpi_x, dpi_y;
|
|
|
|
|
|
|
|
dpi_x = (double) resolution_width / (width_mm / 25.4);
|
|
|
|
dpi_y = (double) resolution_height / (height_mm / 25.4);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't completely trust these values so both must be high, and never
|
|
|
|
* pick higher ratio than 2 automatically.
|
|
|
|
*/
|
|
|
|
if (dpi_x > HIDPI_LIMIT && dpi_y > HIDPI_LIMIT)
|
2017-05-25 04:12:51 -04:00
|
|
|
scale = 2.0;
|
2017-04-21 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
2017-05-25 04:12:51 -04:00
|
|
|
float
|
2017-04-21 05:28:22 -04:00
|
|
|
meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaSettings *settings = meta_backend_get_settings (backend);
|
|
|
|
int global_scaling_factor;
|
|
|
|
|
|
|
|
if (meta_settings_get_global_scaling_factor (settings,
|
|
|
|
&global_scaling_factor))
|
|
|
|
return global_scaling_factor;
|
|
|
|
|
|
|
|
return calculate_scale (monitor, monitor_mode);
|
|
|
|
}
|
|
|
|
|
2018-07-16 12:09:40 -04:00
|
|
|
static gboolean
|
2019-08-12 04:52:20 -04:00
|
|
|
is_logical_size_large_enough (int width,
|
|
|
|
int height)
|
2018-07-16 12:09:40 -04:00
|
|
|
{
|
2019-08-12 04:52:48 -04:00
|
|
|
return width * height >= MINIMUM_LOGICAL_AREA;
|
2018-07-16 12:09:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
2019-08-12 04:54:18 -04:00
|
|
|
MetaMonitorMode *preferred_mode;
|
|
|
|
|
2018-07-16 12:09:40 -04:00
|
|
|
g_return_val_if_fail (monitor_mode != NULL, FALSE);
|
|
|
|
|
2019-08-12 04:54:18 -04:00
|
|
|
preferred_mode = meta_monitor_get_preferred_mode (monitor_mode->monitor);
|
|
|
|
if (monitor_mode->spec.width == preferred_mode->spec.width &&
|
|
|
|
monitor_mode->spec.height == preferred_mode->spec.height)
|
|
|
|
return TRUE;
|
|
|
|
|
2018-07-16 12:09:40 -04:00
|
|
|
return is_logical_size_large_enough (monitor_mode->spec.width,
|
|
|
|
monitor_mode->spec.height);
|
|
|
|
}
|
|
|
|
|
2017-06-05 23:27:58 -04:00
|
|
|
static float
|
|
|
|
get_closest_scale_factor_for_resolution (float width,
|
|
|
|
float height,
|
2017-06-08 23:18:14 -04:00
|
|
|
float scale)
|
2017-06-05 23:27:58 -04:00
|
|
|
{
|
|
|
|
unsigned int i, j;
|
|
|
|
float scaled_h;
|
|
|
|
float scaled_w;
|
|
|
|
float best_scale;
|
|
|
|
int base_scaled_w;
|
|
|
|
gboolean found_one;
|
|
|
|
|
|
|
|
best_scale = 0;
|
|
|
|
scaled_w = width / scale;
|
|
|
|
scaled_h = height / scale;
|
|
|
|
|
2017-08-09 12:41:13 -04:00
|
|
|
if (scale < MINIMUM_SCALE_FACTOR ||
|
|
|
|
scale > MAXIMUM_SCALE_FACTOR ||
|
2018-07-16 12:09:40 -04:00
|
|
|
!is_logical_size_large_enough (floorf (scaled_w), floorf (scaled_h)))
|
2017-06-05 23:27:58 -04:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (floorf (scaled_w) == scaled_w && floorf (scaled_h) == scaled_h)
|
|
|
|
return scale;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
found_one = FALSE;
|
|
|
|
base_scaled_w = floorf (scaled_w);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
for (j = 0; j < 2; j++)
|
|
|
|
{
|
|
|
|
float current_scale;
|
|
|
|
int offset = i * (j ? 1 : -1);
|
|
|
|
|
|
|
|
scaled_w = base_scaled_w + offset;
|
|
|
|
current_scale = width / scaled_w;
|
|
|
|
scaled_h = height / current_scale;
|
|
|
|
|
2017-06-08 23:18:14 -04:00
|
|
|
if (current_scale >= scale + SCALE_FACTORS_STEPS ||
|
|
|
|
current_scale <= scale - SCALE_FACTORS_STEPS ||
|
2017-06-05 23:27:58 -04:00
|
|
|
current_scale < MINIMUM_SCALE_FACTOR ||
|
|
|
|
current_scale > MAXIMUM_SCALE_FACTOR)
|
|
|
|
{
|
2017-06-08 23:18:14 -04:00
|
|
|
goto out;
|
2017-06-05 23:27:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (floorf (scaled_h) == scaled_h)
|
|
|
|
{
|
|
|
|
found_one = TRUE;
|
|
|
|
|
|
|
|
if (fabsf (current_scale - scale) < fabsf (best_scale - scale))
|
|
|
|
best_scale = current_scale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2019-03-04 19:26:35 -05:00
|
|
|
while (!found_one);
|
2017-06-05 23:27:58 -04:00
|
|
|
|
|
|
|
out:
|
|
|
|
return best_scale;
|
|
|
|
}
|
|
|
|
|
2017-06-05 03:59:47 -04:00
|
|
|
float *
|
2019-03-08 13:03:57 -05:00
|
|
|
meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *monitor_mode,
|
|
|
|
MetaMonitorScalesConstraint constraints,
|
|
|
|
int *n_supported_scales)
|
2017-06-05 03:59:47 -04:00
|
|
|
{
|
2017-06-05 23:27:58 -04:00
|
|
|
unsigned int i, j;
|
2017-06-05 03:59:47 -04:00
|
|
|
int width, height;
|
|
|
|
GArray *supported_scales;
|
|
|
|
|
|
|
|
supported_scales = g_array_new (FALSE, FALSE, sizeof (float));
|
|
|
|
|
2017-06-05 23:27:58 -04:00
|
|
|
meta_monitor_mode_get_resolution (monitor_mode, &width, &height);
|
2017-06-05 03:59:47 -04:00
|
|
|
|
2017-06-05 23:27:58 -04:00
|
|
|
for (i = floorf (MINIMUM_SCALE_FACTOR);
|
|
|
|
i <= ceilf (MAXIMUM_SCALE_FACTOR);
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < SCALE_FACTORS_PER_INTEGER; j++)
|
|
|
|
{
|
|
|
|
float scale;
|
2017-06-08 23:18:14 -04:00
|
|
|
float scale_value = i + j * SCALE_FACTORS_STEPS;
|
2017-06-05 23:27:58 -04:00
|
|
|
|
|
|
|
if ((constraints & META_MONITOR_SCALES_CONSTRAINT_NO_FRAC) &&
|
|
|
|
fmodf (scale_value, 1.0) != 0.0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
scale = get_closest_scale_factor_for_resolution (width,
|
|
|
|
height,
|
2017-06-08 23:18:14 -04:00
|
|
|
scale_value);
|
2017-06-05 23:27:58 -04:00
|
|
|
|
|
|
|
if (scale > 0.0f)
|
|
|
|
g_array_append_val (supported_scales, scale);
|
|
|
|
}
|
2017-06-05 03:59:47 -04:00
|
|
|
}
|
|
|
|
|
2017-09-11 02:12:29 -04:00
|
|
|
if (supported_scales->len == 0)
|
|
|
|
{
|
|
|
|
float fallback_scale;
|
|
|
|
|
|
|
|
fallback_scale = 1.0;
|
|
|
|
g_array_append_val (supported_scales, fallback_scale);
|
|
|
|
}
|
|
|
|
|
2017-06-05 03:59:47 -04:00
|
|
|
*n_supported_scales = supported_scales->len;
|
|
|
|
return (float *) g_array_free (supported_scales, FALSE);
|
|
|
|
}
|
|
|
|
|
2016-12-17 09:29:33 -05:00
|
|
|
MetaMonitorModeSpec *
|
|
|
|
meta_monitor_mode_get_spec (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
return &monitor_mode->spec;
|
|
|
|
}
|
|
|
|
|
2017-06-14 00:04:09 -04:00
|
|
|
const char *
|
|
|
|
meta_monitor_mode_get_id (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
return monitor_mode->id;
|
|
|
|
}
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
void
|
|
|
|
meta_monitor_mode_get_resolution (MetaMonitorMode *monitor_mode,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
2016-12-17 09:29:33 -05:00
|
|
|
*width = monitor_mode->spec.width;
|
|
|
|
*height = monitor_mode->spec.height;
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
meta_monitor_mode_get_refresh_rate (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
2016-12-17 09:29:33 -05:00
|
|
|
return monitor_mode->spec.refresh_rate;
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
|
|
|
|
2017-06-14 02:41:13 -04:00
|
|
|
MetaCrtcModeFlag
|
|
|
|
meta_monitor_mode_get_flags (MetaMonitorMode *monitor_mode)
|
|
|
|
{
|
|
|
|
return monitor_mode->spec.flags;
|
|
|
|
}
|
|
|
|
|
2016-12-20 10:23:27 -05:00
|
|
|
gboolean
|
2019-03-08 13:17:40 -05:00
|
|
|
meta_monitor_mode_foreach_crtc (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode,
|
|
|
|
MetaMonitorModeFunc func,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
2016-12-14 04:22:07 -05:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
2017-08-18 02:04:02 -04:00
|
|
|
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
|
|
|
|
|
|
|
|
if (!monitor_crtc_mode->crtc_mode)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!func (monitor, mode, monitor_crtc_mode, user_data, error))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2019-03-08 13:17:40 -05:00
|
|
|
meta_monitor_mode_foreach_output (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode,
|
|
|
|
MetaMonitorModeFunc func,
|
|
|
|
gpointer user_data,
|
|
|
|
GError **error)
|
2017-08-18 02:04:02 -04:00
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
2016-12-14 04:22:07 -05:00
|
|
|
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
|
|
|
|
|
2016-12-20 10:23:27 -05:00
|
|
|
if (!func (monitor, mode, monitor_crtc_mode, user_data, error))
|
|
|
|
return FALSE;
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
2016-12-20 10:23:27 -05:00
|
|
|
|
|
|
|
return TRUE;
|
2016-12-14 04:22:07 -05:00
|
|
|
}
|
2019-06-26 05:24:19 -04:00
|
|
|
|
2020-10-09 19:02:28 -04:00
|
|
|
MetaMonitorCrtcMode *
|
|
|
|
meta_monitor_get_crtc_mode_for_output (MetaMonitor *monitor,
|
|
|
|
MetaMonitorMode *mode,
|
|
|
|
MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
GList *l;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (l = monitor_priv->outputs, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
MetaMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
|
|
|
|
|
|
|
|
if (monitor_crtc_mode->output == output)
|
|
|
|
return monitor_crtc_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warn_if_reached ();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-06-26 05:24:19 -04:00
|
|
|
const char *
|
|
|
|
meta_monitor_get_display_name (MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *monitor_priv =
|
|
|
|
meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
return monitor_priv->display_name;
|
|
|
|
}
|
2020-01-16 04:10:42 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_monitor_set_logical_monitor (MetaMonitor *monitor,
|
|
|
|
MetaLogicalMonitor *logical_monitor)
|
|
|
|
{
|
|
|
|
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
|
|
|
|
|
|
|
|
priv->logical_monitor = logical_monitor;
|
|
|
|
}
|