17
17
* You should have received a copy of the GNU Library General Public
18
18
* License along with the Gnome Library; see the file COPYING.LIB. If not,
19
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
19
* write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
22
22
* Author: Soren Sandmann <sandmann@redhat.com>
834
835
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
835
836
g_type_class_add_private (klass, sizeof (GnomeRRScreenPrivate));
838
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
839
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
837
841
gobject_class->set_property = gnome_rr_screen_set_property;
838
842
gobject_class->get_property = gnome_rr_screen_get_property;
839
843
gobject_class->finalize = gnome_rr_screen_finalize;
948
952
* gnome_rr_screen_new:
949
* Creates a unique #GnomeRRScreen instance for the specified @screen.
951
953
* @screen: the #GdkScreen on which to operate
952
954
* @error: will be set if XRandR is not supported
956
* Creates a unique #GnomeRRScreen instance for the specified @screen.
954
958
* Returns: a unique #GnomeRRScreen instance, specific to the @screen, or NULL
955
959
* if this could not be created, for instance if the driver does not support
956
960
* Xrandr 1.2. Each #GdkScreen thus has a single instance of #GnomeRRScreen.
969
973
g_object_ref (rr_screen);
971
_gnome_desktop_init_i18n ();
973
975
rr_screen = g_initable_new (GNOME_TYPE_RR_SCREEN, NULL, error, "gdk-screen", screen, NULL);
975
977
g_object_set_data (G_OBJECT (screen), "GnomeRRScreen", rr_screen);
999
1001
* gnome_rr_screen_get_ranges:
1001
* Get the ranges of the screen
1002
1002
* @screen: a #GnomeRRScreen
1003
1003
* @min_width: (out): the minimum width
1004
1004
* @max_width: (out): the maximum width
1005
1005
* @min_height: (out): the minimum height
1006
1006
* @max_height: (out): the maximum height
1008
* Get the ranges of the screen
1009
1011
gnome_rr_screen_get_ranges (GnomeRRScreen *screen,
1267
1270
gdk_error_trap_push ();
1268
1271
/* DPMSForceLevel() return value is often a lie, so ignore it */
1269
1272
DPMSForceLevel (screen->priv->xdisplay, state);
1273
XSync (screen->priv->xdisplay, False);
1270
1274
if (gdk_error_trap_pop ()) {
1272
1276
g_set_error_literal (error,
1462
1466
output->id, edid_atom, len);
1471
edid_atom = XInternAtom (DISPLAY (output), "XFree86_DDC_EDID1_RAWDATA", FALSE);
1472
result = get_property (DISPLAY (output),
1473
output->id, edid_atom, len);
1467
1478
if (*len % 128 == 0)
1574
1585
output->name = g_strdup (info->name); /* FIXME: what is nameLen used for? */
1586
output->display_name = NULL; /* set first time the getter is used */
1575
1587
output->current_crtc = crtc_by_id (output->info, info->crtc);
1576
1588
output->width_mm = info->mm_width;
1577
1589
output->height_mm = info->mm_height;
1685
1697
g_free (output->possible_crtcs);
1686
1698
g_free (output->edid_data);
1687
1699
g_free (output->name);
1700
g_free (output->display_name);
1688
1701
g_free (output->connector_type);
1689
1702
g_slice_free (GnomeRROutput, output);
1723
* gnome_rr_output_get_ids_from_edid:
1724
* @output: a #GnomeRROutput
1725
* @vendor: (out) (allow-none):
1726
* @product: (out) (allow-none):
1727
* @serial: (out) (allow-none):
1730
gnome_rr_output_get_ids_from_edid (GnomeRROutput *output,
1737
g_return_val_if_fail (output != NULL, FALSE);
1739
if (!output->edid_data)
1741
info = decode_edid (output->edid_data);
1745
*vendor = g_memdup (info->manufacturer_code, 4);
1747
*product = info->product_code;
1749
*serial = info->serial_number;
1758
ensure_display_name (GnomeRROutput *output)
1760
if (output->display_name != NULL)
1763
if (gnome_rr_output_is_laptop (output))
1764
output->display_name = g_strdup (_("Built-in Display"));
1766
if (output->display_name == NULL
1767
&& output->edid_data != NULL) {
1770
info = decode_edid (output->edid_data);
1772
output->display_name = make_display_name (info);
1777
if (output->display_name == NULL) {
1779
inches = make_display_size_string (output->width_mm, output->height_mm);
1780
if (inches != NULL) {
1781
/* Translators: %s is the size of the monitor in inches */
1782
output->display_name = g_strdup_printf (_("%s Display"), inches);
1787
/* last chance on the stairway */
1788
if (output->display_name == NULL) {
1789
output->display_name = g_strdup (_("Unknown Display"));
1794
gnome_rr_output_get_display_name (GnomeRROutput *output)
1796
g_return_val_if_fail (output != NULL, NULL);
1798
ensure_display_name (output);
1800
return output->display_name;
1710
1804
* gnome_rr_output_get_backlight_min:
1712
1806
* Returns: The mimimum backlight value, or -1 if not supported
1979
_gnome_rr_output_name_is_laptop (const char *name)
1984
if (strstr (name, "lvds") || /* Most drivers use an "LVDS" prefix... */
1985
strstr (name, "LVDS") ||
1986
strstr (name, "Lvds") ||
1987
strstr (name, "LCD") || /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
1988
strstr (name, "eDP") || /* eDP is for internal laptop panel connections */
1989
strstr (name, "default")) /* Finally, NVidia and all others that don't bother to do RANDR properly */
1885
1996
gnome_rr_output_is_laptop (GnomeRROutput *output)
1887
const char *connector_type;
1889
1998
g_return_val_if_fail (output != NULL, FALSE);
1891
2000
if (!output->connected)
1894
2003
/* The ConnectorType property is present in RANDR 1.3 and greater */
1896
connector_type = gnome_rr_output_get_connector_type (output);
1897
if (connector_type && strcmp (connector_type, GNOME_RR_CONNECTOR_TYPE_PANEL) == 0)
2004
if (g_strcmp0 (output->connector_type, GNOME_RR_CONNECTOR_TYPE_PANEL) == 0)
1900
2007
/* Older versions of RANDR - this is a best guess, as @#$% RANDR doesn't have standard output names,
1901
2008
* so drivers can use whatever they like.
1905
&& (strstr (output->name, "lvds") || /* Most drivers use an "LVDS" prefix... */
1906
strstr (output->name, "LVDS") ||
1907
strstr (output->name, "Lvds") ||
1908
strstr (output->name, "LCD") || /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
1909
strstr (output->name, "eDP") || /* eDP is for internal laptop panel connections */
1910
strstr (output->name, "DFP"))) /* DFP is also an internal laptop display */
2010
if (_gnome_rr_output_name_is_laptop (output->name))
2030
* gnome_rr_output_get_position:
2031
* @output: a #GnomeRROutput
2032
* @x: (out) (allow-none):
2033
* @y: (out) (allow-none):
1930
2036
gnome_rr_output_get_position (GnomeRROutput *output,
2205
2311
/* FIXME: merge with get_mode()? */
2313
* gnome_rr_crtc_get_position:
2314
* @crtc: a #GnomeRRCrtc
2315
* @x: (out) (allow-none):
2316
* @y: (out) (allow-none):
2207
2319
gnome_rr_crtc_get_position (GnomeRRCrtc *crtc,