mate-desktop 1.29.2
Library with common API for various MATE modules
Loading...
Searching...
No Matches
mate-rr-config.c File Reference
View source
#include <config.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <X11/Xlib.h>
#include <gdk/gdkx.h>
#include "mate-rr-config.h"
#include "edid.h"
#include "mate-rr-private.h"
Include dependency graph for mate-rr-config.c:

Data Structures

struct  Parser
 
struct  CrtcInfo
 
struct  CrtcAssignment
 
struct  ConfigureCrtcState
 

Macros

#define MATE_DESKTOP_USE_UNSTABLE_API
 
#define CONFIG_INTENDED_BASENAME   "monitors.xml"
 
#define CONFIG_BACKUP_BASENAME   "monitors.xml.backup"
 
#define TOPLEVEL_ELEMENT   (parser->config_file_version > 0 ? "monitors" : NULL)
 

Typedefs

typedef struct CrtcAssignment CrtcAssignment
 
typedef struct Parser Parser
 
typedef struct CrtcInfo CrtcInfo
 

Enumerations

enum  { PROP_0 , PROP_SCREEN , PROP_LAST }
 

Functions

static gboolean parse_file_gmarkup (const gchar *file, const GMarkupParser *parser, gpointer data, GError **err)
 
static gboolean crtc_assignment_apply (CrtcAssignment *assign, guint32 timestamp, GError **error)
 
static CrtcAssignment * crtc_assignment_new (MateRRScreen *screen, MateRROutputInfo **outputs, GError **error)
 
static void crtc_assignment_free (CrtcAssignment *assign)
 
static int parse_int (const char *text)
 
static guint parse_uint (const char *text)
 
static gboolean stack_is (Parser *parser, const char *s1,...)
 
static void handle_start_element (GMarkupParseContext *context, const gchar *name, const gchar **attr_names, const gchar **attr_values, gpointer user_data, GError **err)
 
static void handle_end_element (GMarkupParseContext *context, const gchar *name, gpointer user_data, GError **err)
 
static void handle_text (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **err)
 
static void parser_free (Parser *parser)
 
static MateRRConfig ** configurations_read_from_file (const gchar *filename, GError **error)
 
static void mate_rr_config_init (MateRRConfig *self)
 
static void mate_rr_config_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *property)
 
static void mate_rr_config_finalize (GObject *gobject)
 
gboolean mate_rr_config_load_current (MateRRConfig *config, GError **error)
 
gboolean mate_rr_config_load_filename (MateRRConfig *result, const char *filename, GError **error)
 
static void mate_rr_config_class_init (MateRRConfigClass *klass)
 
MateRRConfig * mate_rr_config_new_current (MateRRScreen *screen, GError **error)
 
MateRRConfig * mate_rr_config_new_stored (MateRRScreen *screen, GError **error)
 
static gboolean output_match (MateRROutputInfo *output1, MateRROutputInfo *output2)
 
static gboolean output_equal (MateRROutputInfo *output1, MateRROutputInfo *output2)
 
static MateRROutputInfo * find_output (MateRRConfig *config, const char *name)
 
gboolean mate_rr_config_match (MateRRConfig *c1, MateRRConfig *c2)
 
gboolean mate_rr_config_equal (MateRRConfig *c1, MateRRConfig *c2)
 
static MateRROutputInfo ** make_outputs (MateRRConfig *config)
 
gboolean mate_rr_config_applicable (MateRRConfig *configuration, MateRRScreen *screen, GError **error)
 
static void ensure_config_directory (void)
 
char * mate_rr_config_get_backup_filename (void)
 
char * mate_rr_config_get_intended_filename (void)
 
static const char * get_rotation_name (MateRRRotation r)
 
static const char * yes_no (int x)
 
static const char * get_reflect_x (MateRRRotation r)
 
static const char * get_reflect_y (MateRRRotation r)
 
static void emit_configuration (MateRRConfig *config, GString *string)
 
void mate_rr_config_sanitize (MateRRConfig *config)
 
gboolean mate_rr_config_ensure_primary (MateRRConfig *configuration)
 
gboolean mate_rr_config_save (MateRRConfig *configuration, GError **error)
 
gboolean mate_rr_config_apply_with_time (MateRRConfig *config, MateRRScreen *screen, guint32 timestamp, GError **error)
 
gboolean mate_rr_config_apply_from_filename_with_time (MateRRScreen *screen, const char *filename, guint32 timestamp, GError **error)
 
MateRROutputInfo ** mate_rr_config_get_outputs (MateRRConfig *self)
 mate_rr_config_get_outputs:
 
gboolean mate_rr_config_get_clone (MateRRConfig *self)
 mate_rr_config_get_clone:
 
void mate_rr_config_set_clone (MateRRConfig *self, gboolean clone)
 
static gboolean can_clone (CrtcInfo *info, MateRROutput *output)
 
static gboolean crtc_assignment_assign (CrtcAssignment *assign, MateRRCrtc *crtc, MateRRMode *mode, int x, int y, MateRRRotation rotation, gboolean primary, MateRROutput *output, GError **error)
 
static void crtc_assignment_unassign (CrtcAssignment *assign, MateRRCrtc *crtc, MateRROutput *output)
 
static void configure_crtc (gpointer key, gpointer value, gpointer data)
 
static gboolean mode_is_rotated (CrtcInfo *info)
 
static gboolean crtc_is_rotated (MateRRCrtc *crtc)
 
static void accumulate_error (GString *accumulated_error, GError *error)
 
static gboolean real_assign_crtcs (MateRRScreen *screen, MateRROutputInfo **outputs, CrtcAssignment *assignment, GError **error)
 
static void crtc_info_free (CrtcInfo *info)
 
static void get_required_virtual_size (CrtcAssignment *assign, int *width, int *height)
 

Macro Definition Documentation

◆ CONFIG_BACKUP_BASENAME

#define CONFIG_BACKUP_BASENAME   "monitors.xml.backup"

◆ CONFIG_INTENDED_BASENAME

#define CONFIG_INTENDED_BASENAME   "monitors.xml"

◆ MATE_DESKTOP_USE_UNSTABLE_API

#define MATE_DESKTOP_USE_UNSTABLE_API

◆ TOPLEVEL_ELEMENT

#define TOPLEVEL_ELEMENT   (parser->config_file_version > 0 ? "monitors" : NULL)

Typedef Documentation

◆ CrtcAssignment

◆ CrtcInfo

typedef struct CrtcInfo CrtcInfo

◆ Parser

typedef struct Parser Parser

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PROP_0 
PROP_SCREEN 
PROP_LAST 

Function Documentation

◆ accumulate_error()

static void accumulate_error ( GString *  accumulated_error,
GError *  error 
)
static

Referenced by real_assign_crtcs().

◆ can_clone()

static gboolean can_clone ( CrtcInfo *  info,
MateRROutput *  output 
)
static

References mate_rr_output_can_clone(), and CrtcInfo::outputs.

Referenced by crtc_assignment_assign().

Here is the call graph for this function:

◆ configurations_read_from_file()

static MateRRConfig ** configurations_read_from_file ( const gchar *  filename,
GError **  error 
)
static

References Parser::config_file_version, Parser::configurations, handle_end_element(), handle_start_element(), handle_text(), Parser::outputs, parse_file_gmarkup(), parser_free(), and Parser::stack.

Referenced by mate_rr_config_load_filename(), and mate_rr_config_save().

Here is the call graph for this function:

◆ configure_crtc()

static void configure_crtc ( gpointer  key,
gpointer  value,
gpointer  data 
)
static

References ConfigureCrtcState::error, ConfigureCrtcState::has_error, mate_rr_crtc_set_config_with_time(), CrtcInfo::mode, CrtcInfo::outputs, CrtcInfo::rotation, ConfigureCrtcState::timestamp, CrtcInfo::x, and CrtcInfo::y.

Referenced by crtc_assignment_apply().

Here is the call graph for this function:

◆ crtc_assignment_apply()

◆ crtc_assignment_assign()

static gboolean crtc_assignment_assign ( CrtcAssignment *  assign,
MateRRCrtc *  crtc,
MateRRMode *  mode,
int  x,
int  y,
MateRRRotation  rotation,
gboolean  primary,
MateRROutput *  output,
GError **  error 
)
static

◆ crtc_assignment_free()

static void crtc_assignment_free ( CrtcAssignment *  assign)
static

◆ crtc_assignment_new()

static CrtcAssignment * crtc_assignment_new ( MateRRScreen *  screen,
MateRROutputInfo **  outputs,
GError **  error 
)
static

References crtc_assignment_free(), crtc_info_free(), get_required_virtual_size(), CrtcAssignment::info, MATE_RR_ERROR, MATE_RR_ERROR_BOUNDS_ERROR, mate_rr_screen_get_ranges(), real_assign_crtcs(), and CrtcAssignment::screen.

Referenced by mate_rr_config_applicable(), and mate_rr_config_apply_with_time().

Here is the call graph for this function:

◆ crtc_assignment_unassign()

static void crtc_assignment_unassign ( CrtcAssignment *  assign,
MateRRCrtc *  crtc,
MateRROutput *  output 
)
static

◆ crtc_info_free()

static void crtc_info_free ( CrtcInfo *  info)
static

References CrtcInfo::outputs.

Referenced by crtc_assignment_new().

◆ crtc_is_rotated()

static gboolean crtc_is_rotated ( MateRRCrtc *  crtc)
static

References mate_rr_crtc_get_current_rotation(), MATE_RR_ROTATION_270, and MATE_RR_ROTATION_90.

Referenced by crtc_assignment_apply().

Here is the call graph for this function:

◆ emit_configuration()

◆ ensure_config_directory()

static void ensure_config_directory ( void  )
static

◆ find_output()

static MateRROutputInfo * find_output ( MateRRConfig *  config,
const char *  name 
)
static

◆ get_reflect_x()

static const char * get_reflect_x ( MateRRRotation  r)
static

References MATE_RR_REFLECT_X, and yes_no().

Referenced by emit_configuration().

Here is the call graph for this function:

◆ get_reflect_y()

static const char * get_reflect_y ( MateRRRotation  r)
static

References MATE_RR_REFLECT_Y, and yes_no().

Referenced by emit_configuration().

Here is the call graph for this function:

◆ get_required_virtual_size()

static void get_required_virtual_size ( CrtcAssignment *  assign,
int *  width,
int *  height 
)
static

References CrtcAssignment::info, mate_rr_mode_get_height(), mate_rr_mode_get_width(), CrtcInfo::mode, mode_is_rotated(), CrtcInfo::x, and CrtcInfo::y.

Referenced by crtc_assignment_apply(), and crtc_assignment_new().

Here is the call graph for this function:

◆ get_rotation_name()

static const char * get_rotation_name ( MateRRRotation  r)
static

◆ handle_end_element()

static void handle_end_element ( GMarkupParseContext *  context,
const gchar *  name,
gpointer  user_data,
GError **  err 
)
static

◆ handle_start_element()

static void handle_start_element ( GMarkupParseContext *  context,
const gchar *  name,
const gchar **  attr_names,
const gchar **  attr_values,
gpointer  user_data,
GError **  err 
)
static

◆ handle_text()

◆ make_outputs()

◆ mate_rr_config_applicable()

gboolean mate_rr_config_applicable ( MateRRConfig *  configuration,
MateRRScreen *  screen,
GError **  error 
)

References crtc_assignment_free(), crtc_assignment_new(), make_outputs(), MATE_IS_RR_CONFIG, MATE_IS_RR_SCREEN, and CrtcAssignment::screen.

Here is the call graph for this function:

◆ mate_rr_config_apply_from_filename_with_time()

gboolean mate_rr_config_apply_from_filename_with_time ( MateRRScreen *  screen,
const char *  filename,
guint32  timestamp,
GError **  error 
)

References MATE_IS_RR_SCREEN, mate_rr_config_apply_with_time(), mate_rr_config_ensure_primary(), mate_rr_config_load_filename(), mate_rr_screen_refresh(), MATE_TYPE_RR_CONFIG, and CrtcAssignment::screen.

Here is the call graph for this function:

◆ mate_rr_config_apply_with_time()

gboolean mate_rr_config_apply_with_time ( MateRRConfig *  config,
MateRRScreen *  screen,
guint32  timestamp,
GError **  error 
)

References crtc_assignment_apply(), crtc_assignment_free(), crtc_assignment_new(), make_outputs(), MATE_IS_RR_CONFIG, MATE_IS_RR_SCREEN, and CrtcAssignment::screen.

Referenced by mate_rr_config_apply_from_filename_with_time().

Here is the call graph for this function:

◆ mate_rr_config_class_init()

static void mate_rr_config_class_init ( MateRRConfigClass *  klass)
static

References mate_rr_config_finalize(), mate_rr_config_set_property(), MATE_TYPE_RR_SCREEN, and PROP_SCREEN.

Here is the call graph for this function:

◆ mate_rr_config_ensure_primary()

gboolean mate_rr_config_ensure_primary ( MateRRConfig *  configuration)

References _mate_rr_output_name_is_laptop(), CrtcAssignment::info, MATE_IS_RR_CONFIG, MateRRConfigPrivate::outputs, MateRROutputInfoPrivate::primary, MateRROutputInfo::priv, MateRRConfig::priv, MateRROutputInfoPrivate::x, and MateRROutputInfoPrivate::y.

Referenced by mate_rr_config_apply_from_filename_with_time().

Here is the call graph for this function:

◆ mate_rr_config_equal()

gboolean mate_rr_config_equal ( MateRRConfig *  c1,
MateRRConfig *  c2 
)

References find_output(), MATE_IS_RR_CONFIG, MateRROutputInfoPrivate::name, output_equal(), MateRRConfigPrivate::outputs, MateRROutputInfo::priv, and MateRRConfig::priv.

Here is the call graph for this function:

◆ mate_rr_config_finalize()

static void mate_rr_config_finalize ( GObject *  gobject)
static

◆ mate_rr_config_get_backup_filename()

char * mate_rr_config_get_backup_filename ( void  )

References CONFIG_BACKUP_BASENAME, and ensure_config_directory().

Referenced by mate_rr_config_save().

Here is the call graph for this function:

◆ mate_rr_config_get_clone()

gboolean mate_rr_config_get_clone ( MateRRConfig *  self)

mate_rr_config_get_clone:

Returns: whether at least two outputs are at (0, 0) offset and they have the same width/height. Those outputs are of course connected and on (i.e. they have a CRTC assigned).

References MateRRConfigPrivate::clone, MATE_IS_RR_CONFIG, and MateRRConfig::priv.

Referenced by create_label_window(), and create_label_windows().

◆ mate_rr_config_get_intended_filename()

char * mate_rr_config_get_intended_filename ( void  )

References CONFIG_INTENDED_BASENAME, and ensure_config_directory().

Referenced by mate_rr_config_load_filename(), mate_rr_config_new_stored(), and mate_rr_config_save().

Here is the call graph for this function:

◆ mate_rr_config_get_outputs()

MateRROutputInfo ** mate_rr_config_get_outputs ( MateRRConfig *  self)

mate_rr_config_get_outputs:

Returns: (array zero-terminated=1) (element-type MateDesktop.RROutputInfo) (transfer none): the output configuration for this MateRRConfig

References MATE_IS_RR_CONFIG, MateRRConfigPrivate::outputs, and MateRRConfig::priv.

Referenced by count_outputs(), create_label_windows(), and mate_rr_labeler_get_rgba_for_output().

◆ mate_rr_config_init()

static void mate_rr_config_init ( MateRRConfig *  self)
static

◆ mate_rr_config_load_current()

gboolean mate_rr_config_load_current ( MateRRConfig *  config,
GError **  error 
)

◆ mate_rr_config_load_filename()

gboolean mate_rr_config_load_filename ( MateRRConfig *  result,
const char *  filename,
GError **  error 
)

◆ mate_rr_config_match()

gboolean mate_rr_config_match ( MateRRConfig *  c1,
MateRRConfig *  c2 
)

References find_output(), MATE_IS_RR_CONFIG, MateRROutputInfoPrivate::name, output_match(), MateRRConfigPrivate::outputs, MateRROutputInfo::priv, and MateRRConfig::priv.

Referenced by mate_rr_config_load_current(), mate_rr_config_load_filename(), and mate_rr_config_save().

Here is the call graph for this function:

◆ mate_rr_config_new_current()

MateRRConfig * mate_rr_config_new_current ( MateRRScreen *  screen,
GError **  error 
)

References mate_rr_config_load_current(), MATE_TYPE_RR_CONFIG, and CrtcAssignment::screen.

Referenced by mate_rr_config_load_filename().

Here is the call graph for this function:

◆ mate_rr_config_new_stored()

MateRRConfig * mate_rr_config_new_stored ( MateRRScreen *  screen,
GError **  error 
)

References mate_rr_config_get_intended_filename(), mate_rr_config_load_filename(), MATE_TYPE_RR_CONFIG, and CrtcAssignment::screen.

Here is the call graph for this function:

◆ mate_rr_config_sanitize()

◆ mate_rr_config_save()

gboolean mate_rr_config_save ( MateRRConfig *  configuration,
GError **  error 
)

References configurations_read_from_file(), emit_configuration(), MATE_IS_RR_CONFIG, mate_rr_config_get_backup_filename(), mate_rr_config_get_intended_filename(), and mate_rr_config_match().

Here is the call graph for this function:

◆ mate_rr_config_set_clone()

void mate_rr_config_set_clone ( MateRRConfig *  self,
gboolean  clone 
)

◆ mate_rr_config_set_property()

static void mate_rr_config_set_property ( GObject *  gobject,
guint  property_id,
const GValue *  value,
GParamSpec *  property 
)
static

◆ mode_is_rotated()

static gboolean mode_is_rotated ( CrtcInfo *  info)
static

◆ output_equal()

static gboolean output_equal ( MateRROutputInfo *  output1,
MateRROutputInfo *  output2 
)
static

References MateRROutputInfoPrivate::height, MATE_IS_RR_OUTPUT_INFO, MateRROutputInfoPrivate::on, output_match(), MateRROutputInfo::priv, MateRROutputInfoPrivate::rate, MateRROutputInfoPrivate::rotation, MateRROutputInfoPrivate::width, MateRROutputInfoPrivate::x, and MateRROutputInfoPrivate::y.

Referenced by mate_rr_config_equal().

Here is the call graph for this function:

◆ output_match()

◆ parse_file_gmarkup()

static gboolean parse_file_gmarkup ( const gchar *  file,
const GMarkupParser *  parser,
gpointer  data,
GError **  err 
)
static

◆ parse_int()

static int parse_int ( const char *  text)
static

◆ parse_uint()

static guint parse_uint ( const char *  text)
static

Referenced by handle_text().

◆ parser_free()

static void parser_free ( Parser *  parser)
static

◆ real_assign_crtcs()

◆ stack_is()

static gboolean stack_is ( Parser *  parser,
const char *  s1,
  ... 
)
static

References Parser::stack.

Referenced by handle_text().

◆ yes_no()

static const char * yes_no ( int  x)
static