summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--libmate-desktop/mate-rr-config.c17
-rw-r--r--libmate-desktop/mate-rr-labeler.c2
-rw-r--r--libmate-desktop/mate-rr-output-info.c10
-rw-r--r--libmate-desktop/mate-rr-private.h2
-rw-r--r--libmate-desktop/mate-rr.c151
6 files changed, 107 insertions, 77 deletions
diff --git a/configure.ac b/configure.ac
index 13a45ed..d6ebc18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,7 +154,7 @@ esac
GDK_PIXBUF_REQUIRED=2.4.0
GLIB_REQUIRED=2.36.0
GIO_REQUIRED=2.26.0
-XRANDR_REQUIRED=1.2
+XRANDR_REQUIRED=1.3
AC_SUBST(GTK_API_VERSION)
AC_SUBST(GLIB_REQUIRED)
diff --git a/libmate-desktop/mate-rr-config.c b/libmate-desktop/mate-rr-config.c
index 5702b11..dfff1b6 100644
--- a/libmate-desktop/mate-rr-config.c
+++ b/libmate-desktop/mate-rr-config.c
@@ -1171,19 +1171,6 @@ mate_rr_config_sanitize (MateRRConfig *config)
}
}
-static gboolean
-output_info_is_laptop (MateRROutputInfo *info)
-{
- if (info->priv->name
- && (strstr (info->priv->name, "lvds") || /* Most drivers use an "LVDS" prefix... */
- strstr (info->priv->name, "LVDS") ||
- strstr (info->priv->name, "Lvds") ||
- strstr (info->priv->name, "LCD"))) /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
- return TRUE;
-
- return FALSE;
-}
-
gboolean
mate_rr_config_ensure_primary (MateRRConfig *configuration)
{
@@ -1223,9 +1210,7 @@ mate_rr_config_ensure_primary (MateRRConfig *configuration)
top_left = info;
}
if (laptop == NULL
- && output_info_is_laptop (info)) {
- /* shame we can't find the connector type
- as with gnome_rr_output_is_laptop */
+ && _mate_rr_output_name_is_laptop (info->priv->name)) {
laptop = info;
}
}
diff --git a/libmate-desktop/mate-rr-labeler.c b/libmate-desktop/mate-rr-labeler.c
index 673c03a..83357c6 100644
--- a/libmate-desktop/mate-rr-labeler.c
+++ b/libmate-desktop/mate-rr-labeler.c
@@ -523,7 +523,7 @@ setup_from_config (MateRRLabeler *labeler)
* for configuring multiple monitors.
* The labels will be shown by default, use mate_rr_labeler_hide to hide them.
*
- * Returns: A new #GnomeRRLabeler
+ * Returns: A new #MateRRLabeler
*/
MateRRLabeler *
mate_rr_labeler_new (MateRRConfig *config)
diff --git a/libmate-desktop/mate-rr-output-info.c b/libmate-desktop/mate-rr-output-info.c
index 7e5a8ee..02ea16a 100644
--- a/libmate-desktop/mate-rr-output-info.c
+++ b/libmate-desktop/mate-rr-output-info.c
@@ -116,6 +116,16 @@ void mate_rr_output_info_get_geometry (MateRROutputInfo *self, int *x, int *y, i
*height = self->priv->height;
}
+/**
+ * mate_rr_output_info_set_geometry:
+ * @self: a #MateRROutputInfo
+ * @x: x offset for monitor
+ * @y: y offset for monitor
+ * @width: monitor width
+ * @height: monitor height
+ *
+ * Set the geometry for the monitor connected to the specified output.
+ */
void mate_rr_output_info_set_geometry (MateRROutputInfo *self, int x, int y, int width, int height)
{
g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
diff --git a/libmate-desktop/mate-rr-private.h b/libmate-desktop/mate-rr-private.h
index b292a9d..d5410ca 100644
--- a/libmate-desktop/mate-rr-private.h
+++ b/libmate-desktop/mate-rr-private.h
@@ -79,4 +79,6 @@ struct MateRRConfigPrivate
MateRROutputInfo **outputs;
};
+gboolean _mate_rr_output_name_is_laptop (const char *name);
+
#endif
diff --git a/libmate-desktop/mate-rr.c b/libmate-desktop/mate-rr.c
index 921190a..a4f9afa 100644
--- a/libmate-desktop/mate-rr.c
+++ b/libmate-desktop/mate-rr.c
@@ -60,14 +60,6 @@ typedef int Rotation;
#define RR_Reflect_Y 32
#endif
-#ifdef HAVE_RANDR
-#define RANDR_LIBRARY_IS_AT_LEAST_1_3 (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3))
-#else
-#define RANDR_LIBRARY_IS_AT_LEAST_1_3 0
-#endif
-
-#define SERVERS_RANDR_IS_AT_LEAST_1_3(priv) (priv->rr_major_version > 1 || (priv->rr_major_version == 1 && priv->rr_minor_version >= 3))
-
enum {
SCREEN_PROP_0,
SCREEN_PROP_GDK_SCREEN,
@@ -445,32 +437,16 @@ fill_out_screen_info (Display *xdisplay,
{
#ifdef HAVE_RANDR
XRRScreenResources *resources;
- MateRRScreenPrivate *priv;
g_assert (xdisplay != NULL);
g_assert (info != NULL);
- priv = info->screen->priv;
-
/* First update the screen resources */
if (needs_reprobe)
resources = XRRGetScreenResources (xdisplay, xroot);
else
- {
- /* XRRGetScreenResourcesCurrent is less expensive than
- * XRRGetScreenResources, however it is available only
- * in RandR 1.3 or higher
- */
-#if RANDR_LIBRARY_IS_AT_LEAST_1_3
- if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv))
- resources = XRRGetScreenResourcesCurrent (xdisplay, xroot);
- else
- resources = XRRGetScreenResources (xdisplay, xroot);
-#else
- resources = XRRGetScreenResources (xdisplay, xroot);
-#endif
- }
+ resources = XRRGetScreenResourcesCurrent (xdisplay, xroot);
if (resources)
{
@@ -521,17 +497,13 @@ fill_out_screen_info (Display *xdisplay,
}
info->primary = None;
-#if RANDR_LIBRARY_IS_AT_LEAST_1_3
- if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv)) {
- gdk_error_trap_push ();
- info->primary = XRRGetOutputPrimary (xdisplay, xroot);
- #if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_error_trap_push ();
+ info->primary = XRRGetOutputPrimary (xdisplay, xroot);
+#if GTK_CHECK_VERSION (3, 0, 0)
gdk_error_trap_pop_ignored ();
- #else
+#else
gdk_flush ();
gdk_error_trap_pop (); /* ignore error */
- #endif
- }
#endif
return TRUE;
@@ -708,9 +680,9 @@ mate_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError **
priv->randr_event_base = event_base;
XRRQueryVersion (dpy, &priv->rr_major_version, &priv->rr_minor_version);
- if (priv->rr_major_version < 1 || (priv->rr_major_version == 1 && priv->rr_minor_version < 2)) {
+ if (priv->rr_major_version < 1 || (priv->rr_major_version == 1 && priv->rr_minor_version < 3)) {
g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_NO_RANDR_EXTENSION,
- "RANDR extension is too old (must be at least 1.2)");
+ "RANDR extension is too old (must be at least 1.3)");
return FALSE;
}
@@ -1451,6 +1423,11 @@ mate_rr_screen_get_output_by_name (MateRRScreen *screen,
return NULL;
}
+/**
+ * mate_rr_output_get_crtc:
+ * @output: a #MateRROutput
+ * Returns: (transfer none):
+ */
MateRRCrtc *
mate_rr_output_get_crtc (MateRROutput *output)
{
@@ -1459,6 +1436,19 @@ mate_rr_output_get_crtc (MateRROutput *output)
return output->current_crtc;
}
+/**
+ * mate_rr_output_get_possible_crtcs:
+ * @output: a #MateRROutput
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRRCrtc **
+mate_rr_output_get_possible_crtcs (MateRROutput *output)
+{
+ g_return_val_if_fail (output != NULL, NULL);
+
+ return output->possible_crtcs;
+}
+
/* Returns NULL if the ConnectorType property is not available */
const char *
mate_rr_output_get_connector_type (MateRROutput *output)
@@ -1469,36 +1459,41 @@ mate_rr_output_get_connector_type (MateRROutput *output)
}
gboolean
-mate_rr_output_is_laptop (MateRROutput *output)
+_mate_rr_output_name_is_laptop (const char *name)
{
- const char *connector_type;
-
- g_return_val_if_fail (output != NULL, FALSE);
+ if (!name)
+ return FALSE;
- if (!output->connected)
- return FALSE;
+ if (strstr (name, "lvds") || /* Most drivers use an "LVDS" prefix... */
+ strstr (name, "LVDS") ||
+ strstr (name, "Lvds") ||
+ strstr (name, "LCD") || /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
+ strstr (name, "eDP")) /* eDP is for internal laptop panel connections */
+ return TRUE;
- /* The ConnectorType property is present in RANDR 1.3 and greater */
+ return FALSE;
+}
- connector_type = mate_rr_output_get_connector_type (output);
- if (connector_type && strcmp (connector_type, MATE_RR_CONNECTOR_TYPE_PANEL) == 0)
- return TRUE;
+gboolean
+mate_rr_output_is_laptop (MateRROutput *output)
+{
+ g_return_val_if_fail (output != NULL, FALSE);
- /* Older versions of RANDR - this is a best guess, as @#$% RANDR doesn't have standard output names,
- * so drivers can use whatever they like.
- */
+ if (!output->connected)
+ return FALSE;
- if (output->name
- && (strstr (output->name, "lvds") || /* Most drivers use an "LVDS" prefix... */
- strstr (output->name, "LVDS") ||
- strstr (output->name, "Lvds") ||
- strstr (output->name, "LCD") || /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
- strstr (output->name, "eDP"))) /* eDP is for internal laptop panel connections */
- return TRUE;
+ if (g_strcmp0 (output->connector_type, MATE_RR_CONNECTOR_TYPE_PANEL) == 0)
+ return TRUE;
- return FALSE;
+ /* Fallback (see https://bugs.freedesktop.org/show_bug.cgi?id=26736) */
+ return _mate_rr_output_name_is_laptop (output->name);
}
+/**
+ * mate_rr_output_get_current_mode:
+ * @output: a #MateRROutput
+ * Returns: (transfer none): the current mode of this output
+ */
MateRRMode *
mate_rr_output_get_current_mode (MateRROutput *output)
{
@@ -1512,6 +1507,12 @@ mate_rr_output_get_current_mode (MateRROutput *output)
return NULL;
}
+/**
+ * mate_rr_output_get_position:
+ * @output: a #MateRROutput
+ * @x: (out) (allow-none):
+ * @y: (out) (allow-none):
+ */
void
mate_rr_output_get_position (MateRROutput *output,
int *x,
@@ -1546,6 +1547,11 @@ mate_rr_output_get_height_mm (MateRROutput *output)
return output->height_mm;
}
+/**
+ * mate_rr_output_get_preferred_mode:
+ * @output: a #MateRROutput
+ * Returns: (transfer none):
+ */
MateRRMode *
mate_rr_output_get_preferred_mode (MateRROutput *output)
{
@@ -1556,6 +1562,12 @@ mate_rr_output_get_preferred_mode (MateRROutput *output)
return NULL;
}
+/**
+ * mate_rr_output_list_modes:
+ * @output: a #MateRROutput
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+
MateRRMode **
mate_rr_output_list_modes (MateRROutput *output)
{
@@ -1620,13 +1632,13 @@ void
mate_rr_screen_set_primary_output (MateRRScreen *screen,
MateRROutput *output)
{
+#ifdef HAVE_RANDR
MateRRScreenPrivate *priv;
g_return_if_fail (MATE_IS_RR_SCREEN (screen));
priv = screen->priv;
-#if RANDR_LIBRARY_IS_AT_LEAST_1_3
RROutput id;
if (output)
@@ -1634,8 +1646,7 @@ mate_rr_screen_set_primary_output (MateRRScreen *screen,
else
id = None;
- if (SERVERS_RANDR_IS_AT_LEAST_1_3 (priv))
- XRRSetOutputPrimary (priv->xdisplay, priv->xroot, id);
+ XRRSetOutputPrimary (priv->xdisplay, priv->xroot, id);
#endif
}
@@ -1781,6 +1792,11 @@ mate_rr_crtc_set_config_with_time (MateRRCrtc *crtc,
#endif /* HAVE_RANDR */
}
+/**
+ * mate_rr_crtc_get_current_mode:
+ * @crtc: a #MateRRCrtc
+ * Returns: (transfer none): the current mode of this crtc
+ */
MateRRMode *
mate_rr_crtc_get_current_mode (MateRRCrtc *crtc)
{
@@ -1816,6 +1832,13 @@ mate_rr_crtc_can_drive_output (MateRRCrtc *crtc,
}
/* FIXME: merge with get_mode()? */
+
+/**
+ * mate_rr_crtc_get_position:
+ * @crtc: a #MateRRCrtc
+ * @x: (out) (allow-none):
+ * @y: (out) (allow-none):
+ */
void
mate_rr_crtc_get_position (MateRRCrtc *crtc,
int *x,
@@ -2082,6 +2105,16 @@ mate_rr_crtc_set_gamma (MateRRCrtc *crtc, int size,
#endif /* HAVE_RANDR */
}
+/**
+ * mate_rr_crtc_get_gamma:
+ * @crtc: a #MateRRCrtc
+ * @size:
+ * @red: (out): the minimum width
+ * @green: (out): the maximum width
+ * @blue: (out): the minimum height
+ *
+ * Returns: %TRUE for success
+ */
gboolean
mate_rr_crtc_get_gamma (MateRRCrtc *crtc, int *size,
unsigned short **red, unsigned short **green,