1 /* gnome-rr.h 2 * 3 * Copyright 2007, 2008, Red Hat, Inc. 4 * 5 * This file is part of the Gnome Library. 6 * 7 * The Gnome Library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public License as 9 * published by the Free Software Foundation; either version 2 of the 10 * License, or (at your option) any later version. 11 * 12 * The Gnome Library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public 18 * License along with the Gnome Library; see the file COPYING.LIB. If not, 19 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 * Author: Soren Sandmann <sandmann@redhat.com> 23 */ 24 #ifndef GNOME_RR_H 25 #define GNOME_RR_H 26 27 #ifndef GNOME_DESKTOP_USE_UNSTABLE_API 28 #error GnomeRR is unstable API. You must define GNOME_DESKTOP_USE_UNSTABLE_API before including gnomerr.h 29 #endif 30 31 #include <glib.h> 32 #include <gdk/gdk.h> 33 34 typedef struct GnomeRRScreenPrivate GnomeRRScreenPrivate; 35 typedef struct GnomeRROutput GnomeRROutput; 36 typedef struct GnomeRRCrtc GnomeRRCrtc; 37 typedef struct GnomeRRMode GnomeRRMode; 38 39 typedef struct { 40 GObject parent; 41 42 GnomeRRScreenPrivate* priv; 43 } GnomeRRScreen; 44 45 typedef struct { 46 GObjectClass parent_class; 47 48 void (* changed) (void); 49 void (* output_connected) (GnomeRROutput *output); 50 void (* output_disconnected) (GnomeRROutput *output); 51 } GnomeRRScreenClass; 52 53 typedef enum 54 { 55 GNOME_RR_ROTATION_NEXT = 0, 56 GNOME_RR_ROTATION_0 = (1 << 0), 57 GNOME_RR_ROTATION_90 = (1 << 1), 58 GNOME_RR_ROTATION_180 = (1 << 2), 59 GNOME_RR_ROTATION_270 = (1 << 3), 60 GNOME_RR_REFLECT_X = (1 << 4), 61 GNOME_RR_REFLECT_Y = (1 << 5) 62 } GnomeRRRotation; 63 64 typedef enum { 65 GNOME_RR_DPMS_ON, 66 GNOME_RR_DPMS_STANDBY, 67 GNOME_RR_DPMS_SUSPEND, 68 GNOME_RR_DPMS_OFF, 69 GNOME_RR_DPMS_DISABLED, 70 GNOME_RR_DPMS_UNKNOWN 71 } GnomeRRDpmsMode; 72 73 /* Error codes */ 74 75 #define GNOME_RR_ERROR (gnome_rr_error_quark ()) 76 77 GQuark gnome_rr_error_quark (void); 78 79 typedef enum { 80 GNOME_RR_ERROR_UNKNOWN, /* generic "fail" */ 81 GNOME_RR_ERROR_NO_RANDR_EXTENSION, /* RANDR extension is not present */ 82 GNOME_RR_ERROR_RANDR_ERROR, /* generic/undescribed error from the underlying XRR API */ 83 GNOME_RR_ERROR_BOUNDS_ERROR, /* requested bounds of a CRTC are outside the maximum size */ 84 GNOME_RR_ERROR_CRTC_ASSIGNMENT, /* could not assign CRTCs to outputs */ 85 GNOME_RR_ERROR_NO_MATCHING_CONFIG, /* none of the saved configurations matched the current configuration */ 86 GNOME_RR_ERROR_NO_DPMS_EXTENSION /* DPMS extension is not present */ 87 } GnomeRRError; 88 89 #define GNOME_RR_CONNECTOR_TYPE_PANEL "Panel" /* This is a laptop's built-in LCD */ 90 91 #define GNOME_TYPE_RR_SCREEN (gnome_rr_screen_get_type()) 92 #define GNOME_RR_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_RR_SCREEN, GnomeRRScreen)) 93 #define GNOME_IS_RR_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_RR_SCREEN)) 94 #define GNOME_RR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_RR_SCREEN, GnomeRRScreenClass)) 95 #define GNOME_IS_RR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_RR_SCREEN)) 96 #define GNOME_RR_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_RR_SCREEN, GnomeRRScreenClass)) 97 98 #define GNOME_TYPE_RR_OUTPUT (gnome_rr_output_get_type()) 99 #define GNOME_TYPE_RR_CRTC (gnome_rr_crtc_get_type()) 100 #define GNOME_TYPE_RR_MODE (gnome_rr_mode_get_type()) 101 102 GType gnome_rr_screen_get_type (void); 103 GType gnome_rr_output_get_type (void); 104 GType gnome_rr_crtc_get_type (void); 105 GType gnome_rr_mode_get_type (void); 106 107 /* GnomeRRScreen */ 108 GnomeRRScreen * gnome_rr_screen_new (GdkScreen *screen, 109 GError **error); 110 GnomeRROutput **gnome_rr_screen_list_outputs (GnomeRRScreen *screen); 111 GnomeRRCrtc ** gnome_rr_screen_list_crtcs (GnomeRRScreen *screen); 112 GnomeRRMode ** gnome_rr_screen_list_modes (GnomeRRScreen *screen); 113 GnomeRRMode ** gnome_rr_screen_list_clone_modes (GnomeRRScreen *screen); 114 void gnome_rr_screen_set_size (GnomeRRScreen *screen, 115 int width, 116 int height, 117 int mm_width, 118 int mm_height); 119 GnomeRRCrtc * gnome_rr_screen_get_crtc_by_id (GnomeRRScreen *screen, 120 guint32 id); 121 gboolean gnome_rr_screen_refresh (GnomeRRScreen *screen, 122 GError **error); 123 GnomeRROutput * gnome_rr_screen_get_output_by_id (GnomeRRScreen *screen, 124 guint32 id); 125 GnomeRROutput * gnome_rr_screen_get_output_by_name (GnomeRRScreen *screen, 126 const char *name); 127 void gnome_rr_screen_get_ranges (GnomeRRScreen *screen, 128 int *min_width, 129 int *max_width, 130 int *min_height, 131 int *max_height); 132 void gnome_rr_screen_get_timestamps (GnomeRRScreen *screen, 133 guint32 *change_timestamp_ret, 134 guint32 *config_timestamp_ret); 135 136 void gnome_rr_screen_set_primary_output (GnomeRRScreen *screen, 137 GnomeRROutput *output); 138 139 GnomeRRMode **gnome_rr_screen_create_clone_modes (GnomeRRScreen *screen); 140 141 gboolean gnome_rr_screen_get_dpms_mode (GnomeRRScreen *screen, 142 GnomeRRDpmsMode *mode, 143 GError **error); 144 gboolean gnome_rr_screen_set_dpms_mode (GnomeRRScreen *screen, 145 GnomeRRDpmsMode mode, 146 GError **error); 147 guint gnome_rr_screen_get_global_scale (GnomeRRScreen *screen); 148 guint gnome_rr_screen_get_global_scale_setting (GnomeRRScreen *screen); 149 void gnome_rr_screen_set_global_scale_setting (GnomeRRScreen *screen, 150 guint scale_factor); 151 gboolean gnome_rr_screen_get_use_upscaling (GnomeRRScreen *screen); 152 float * gnome_rr_screen_calculate_supported_scales (GnomeRRScreen *screen, 153 int width, 154 int height, 155 int *n_supported_scales); 156 /* screen class method, used in csd-xsettings and here */ 157 guint gnome_rr_screen_calculate_best_global_scale (GnomeRRScreen *screen, gint index); 158 159 /* GnomeRROutput */ 160 guint32 gnome_rr_output_get_id (GnomeRROutput *output); 161 const char * gnome_rr_output_get_name (GnomeRROutput *output); 162 gboolean gnome_rr_output_is_connected (GnomeRROutput *output); 163 int gnome_rr_output_get_size_inches (GnomeRROutput *output); 164 int gnome_rr_output_get_width_mm (GnomeRROutput *outout); 165 int gnome_rr_output_get_height_mm (GnomeRROutput *output); 166 const guint8 * gnome_rr_output_get_edid_data (GnomeRROutput *output, 167 gsize *size); 168 gboolean gnome_rr_output_get_ids_from_edid (GnomeRROutput *output, 169 char **vendor, 170 int *product, 171 int *serial); 172 173 gint gnome_rr_output_get_backlight_min (GnomeRROutput *output); 174 gint gnome_rr_output_get_backlight_max (GnomeRROutput *output); 175 gint gnome_rr_output_get_backlight (GnomeRROutput *output, 176 GError **error); 177 gboolean gnome_rr_output_set_backlight (GnomeRROutput *output, 178 gint value, 179 GError **error); 180 181 GnomeRRCrtc ** gnome_rr_output_get_possible_crtcs (GnomeRROutput *output); 182 GnomeRRMode * gnome_rr_output_get_current_mode (GnomeRROutput *output); 183 GnomeRRCrtc * gnome_rr_output_get_crtc (GnomeRROutput *output); 184 const char * gnome_rr_output_get_connector_type (GnomeRROutput *output); 185 gboolean gnome_rr_output_is_laptop (GnomeRROutput *output); 186 void gnome_rr_output_get_position (GnomeRROutput *output, 187 int *x, 188 int *y); 189 gboolean gnome_rr_output_can_clone (GnomeRROutput *output, 190 GnomeRROutput *clone); 191 GnomeRRMode ** gnome_rr_output_list_modes (GnomeRROutput *output); 192 GnomeRRMode * gnome_rr_output_get_preferred_mode (GnomeRROutput *output); 193 gboolean gnome_rr_output_supports_mode (GnomeRROutput *output, 194 GnomeRRMode *mode); 195 gboolean gnome_rr_output_get_is_primary (GnomeRROutput *output); 196 197 /* GnomeRRMode */ 198 guint32 gnome_rr_mode_get_id (GnomeRRMode *mode); 199 guint gnome_rr_mode_get_width (GnomeRRMode *mode); 200 guint gnome_rr_mode_get_height (GnomeRRMode *mode); 201 int gnome_rr_mode_get_freq (GnomeRRMode *mode); 202 double gnome_rr_mode_get_freq_f (GnomeRRMode *mode); 203 void gnome_rr_mode_get_flags (GnomeRRMode *mode, 204 gboolean *doublescan, 205 gboolean *interlaced, 206 gboolean *vsync); 207 /* GnomeRRCrtc */ 208 guint32 gnome_rr_crtc_get_id (GnomeRRCrtc *crtc); 209 210 gboolean gnome_rr_crtc_set_config_with_time (GnomeRRCrtc *crtc, 211 guint32 timestamp, 212 int x, 213 int y, 214 GnomeRRMode *mode, 215 GnomeRRRotation rotation, 216 GnomeRROutput **outputs, 217 int n_outputs, 218 float scale, 219 guint global_scale, 220 GError **error); 221 gboolean gnome_rr_crtc_can_drive_output (GnomeRRCrtc *crtc, 222 GnomeRROutput *output); 223 GnomeRRMode * gnome_rr_crtc_get_current_mode (GnomeRRCrtc *crtc); 224 void gnome_rr_crtc_get_position (GnomeRRCrtc *crtc, 225 int *x, 226 int *y); 227 float gnome_rr_crtc_get_scale (GnomeRRCrtc *crtc); 228 GnomeRRRotation gnome_rr_crtc_get_current_rotation (GnomeRRCrtc *crtc); 229 GnomeRRRotation gnome_rr_crtc_get_rotations (GnomeRRCrtc *crtc); 230 gboolean gnome_rr_crtc_supports_rotation (GnomeRRCrtc *crtc, 231 GnomeRRRotation rotation); 232 233 gboolean gnome_rr_crtc_get_gamma (GnomeRRCrtc *crtc, 234 int *size, 235 unsigned short **red, 236 unsigned short **green, 237 unsigned short **blue); 238 void gnome_rr_crtc_set_gamma (GnomeRRCrtc *crtc, 239 int size, 240 unsigned short *red, 241 unsigned short *green, 242 unsigned short *blue); 243 #endif /* GNOME_RR_H */ 244