[Xfce4-commits] [apps/xfce4-screensaver] 337/425: Tidy up xfce-rr-{config, output-info}.{c, h}
noreply at xfce.org
noreply at xfce.org
Mon Oct 15 01:53:04 CEST 2018
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screensaver.
commit 3a56a7be210f0c9f85b21faeca855288319c790e
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Mon Oct 1 22:00:46 2018 -0400
Tidy up xfce-rr-{config,output-info}.{c,h}
---
src/xfce-rr-config.c | 326 +++-------------------------------------------
src/xfce-rr-config.h | 67 ----------
src/xfce-rr-output-info.c | 190 ---------------------------
3 files changed, 19 insertions(+), 564 deletions(-)
diff --git a/src/xfce-rr-config.c b/src/xfce-rr-config.c
index 92ded8d..697e79c 100644
--- a/src/xfce-rr-config.c
+++ b/src/xfce-rr-config.c
@@ -84,12 +84,17 @@ static CrtcAssignment *crtc_assignment_new (XfceRRScreen *screen,
XfceRROutputInfo **outputs,
GError **error);
static void crtc_assignment_free (CrtcAssignment *assign);
-
-enum {
- PROP_0,
- PROP_SCREEN,
- PROP_LAST
-};
+static XfceRRConfig * xfce_rr_config_new_current(XfceRRScreen *screen,
+ GError **error);
+static gboolean xfce_rr_config_match (XfceRRConfig *c1,
+ XfceRRConfig *c2);
+static char * xfce_rr_config_get_intended_filename(void);
+
+ enum {
+ PROP_0,
+ PROP_SCREEN,
+ PROP_LAST
+ };
G_DEFINE_TYPE (XfceRRConfig, xfce_rr_config, G_TYPE_OBJECT)
@@ -491,7 +496,7 @@ xfce_rr_config_finalize (GObject *gobject)
G_OBJECT_CLASS (xfce_rr_config_parent_class)->finalize (gobject);
}
-gboolean
+static gboolean
xfce_rr_config_load_current (XfceRRConfig *config, GError **error)
{
GPtrArray *a;
@@ -663,7 +668,7 @@ xfce_rr_config_load_current (XfceRRConfig *config, GError **error)
return TRUE;
}
-gboolean
+static gboolean
xfce_rr_config_load_filename (XfceRRConfig *result, const char *filename, GError **error)
{
XfceRRConfig *current;
@@ -732,7 +737,7 @@ xfce_rr_config_class_init (XfceRRConfigClass *klass)
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
}
-XfceRRConfig *
+static XfceRRConfig *
xfce_rr_config_new_current (XfceRRScreen *screen, GError **error)
{
XfceRRConfig *self = g_object_new (XFCE_TYPE_RR_CONFIG, "screen", screen, NULL);
@@ -746,28 +751,6 @@ xfce_rr_config_new_current (XfceRRScreen *screen, GError **error)
}
}
-XfceRRConfig *
-xfce_rr_config_new_stored (XfceRRScreen *screen, GError **error)
-{
- XfceRRConfig *self = g_object_new (XFCE_TYPE_RR_CONFIG, "screen", screen, NULL);
- char *filename;
- gboolean success;
-
- filename = xfce_rr_config_get_intended_filename ();
-
- success = xfce_rr_config_load_filename (self, filename, error);
-
- g_free (filename);
-
- if (success)
- return self;
- else
- {
- g_object_unref (self);
- return NULL;
- }
-}
-
static gboolean
parse_file_gmarkup (const gchar *filename,
const GMarkupParser *parser,
@@ -888,7 +871,7 @@ find_output (XfceRRConfig *config, const char *name)
/* Match means "these configurations apply to the same hardware
* setups"
*/
-gboolean
+static gboolean
xfce_rr_config_match (XfceRRConfig *c1, XfceRRConfig *c2)
{
int i;
@@ -908,30 +891,6 @@ xfce_rr_config_match (XfceRRConfig *c1, XfceRRConfig *c2)
return TRUE;
}
-/* Equal means "the configurations will result in the same
- * modes being set on the outputs"
- */
-gboolean
-xfce_rr_config_equal (XfceRRConfig *c1,
- XfceRRConfig *c2)
-{
- int i;
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (c1), FALSE);
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (c2), FALSE);
-
- for (i = 0; c1->priv->outputs[i] != NULL; ++i)
- {
- XfceRROutputInfo *output1 = c1->priv->outputs[i];
- XfceRROutputInfo *output2;
-
- output2 = find_output (c2, output1->priv->name);
- if (!output2 || !output_equal (output1, output2))
- return FALSE;
- }
-
- return TRUE;
-}
-
static XfceRROutputInfo **
make_outputs (XfceRRConfig *config)
{
@@ -975,40 +934,6 @@ make_outputs (XfceRRConfig *config)
return (XfceRROutputInfo **)g_ptr_array_free (outputs, FALSE);
}
-gboolean
-xfce_rr_config_applicable (XfceRRConfig *configuration,
- XfceRRScreen *screen,
- GError **error)
-{
- XfceRROutputInfo **outputs;
- CrtcAssignment *assign;
- gboolean result;
- int i;
-
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (configuration), FALSE);
- g_return_val_if_fail (XFCE_IS_RR_SCREEN (screen), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- outputs = make_outputs (configuration);
- assign = crtc_assignment_new (screen, outputs, error);
-
- if (assign)
- {
- result = TRUE;
- crtc_assignment_free (assign);
- }
- else
- {
- result = FALSE;
- }
-
- for (i = 0; outputs[i] != NULL; i++) {
- g_object_unref (outputs[i]);
- }
-
- return result;
-}
-
/* Database management */
static void
@@ -1017,14 +942,14 @@ ensure_config_directory (void)
g_mkdir_with_parents (g_get_user_config_dir (), 0700);
}
-char *
+static char *
xfce_rr_config_get_backup_filename (void)
{
ensure_config_directory ();
return g_build_filename (g_get_user_config_dir (), CONFIG_BACKUP_BASENAME, NULL);
}
-char *
+static char *
xfce_rr_config_get_intended_filename (void)
{
ensure_config_directory ();
@@ -1120,58 +1045,7 @@ emit_configuration (XfceRRConfig *config,
g_string_append_printf (string, " </configuration>\n");
}
-void
-xfce_rr_config_sanitize (XfceRRConfig *config)
-{
- int i;
- int x_offset, y_offset;
- gboolean found;
-
- /* Offset everything by the top/left-most coordinate to
- * make sure the configuration starts at (0, 0)
- */
- x_offset = y_offset = G_MAXINT;
- for (i = 0; config->priv->outputs[i]; ++i)
- {
- XfceRROutputInfo *output = config->priv->outputs[i];
-
- if (output->priv->on)
- {
- x_offset = MIN (x_offset, output->priv->x);
- y_offset = MIN (y_offset, output->priv->y);
- }
- }
-
- for (i = 0; config->priv->outputs[i]; ++i)
- {
- XfceRROutputInfo *output = config->priv->outputs[i];
-
- if (output->priv->on)
- {
- output->priv->x -= x_offset;
- output->priv->y -= y_offset;
- }
- }
-
- /* Only one primary, please */
- found = FALSE;
- for (i = 0; config->priv->outputs[i]; ++i)
- {
- if (config->priv->outputs[i]->priv->primary)
- {
- if (found)
- {
- config->priv->outputs[i]->priv->primary = FALSE;
- }
- else
- {
- found = TRUE;
- }
- }
- }
-}
-
-gboolean
+static gboolean
xfce_rr_config_ensure_primary (XfceRRConfig *configuration)
{
int i;
@@ -1227,60 +1101,7 @@ xfce_rr_config_ensure_primary (XfceRRConfig *configuration)
return !found;
}
-gboolean
-xfce_rr_config_save (XfceRRConfig *configuration, GError **error)
-{
- XfceRRConfig **configurations;
- GString *output;
- int i;
- gchar *intended_filename;
- gchar *backup_filename;
- gboolean result;
-
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (configuration), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- output = g_string_new ("");
-
- backup_filename = xfce_rr_config_get_backup_filename ();
- intended_filename = xfce_rr_config_get_intended_filename ();
-
- configurations = configurations_read_from_file (intended_filename, NULL); /* NULL-GError */
-
- g_string_append_printf (output, "<monitors version=\"1\">\n");
-
- if (configurations)
- {
- for (i = 0; configurations[i] != NULL; ++i)
- {
- if (!xfce_rr_config_match (configurations[i], configuration))
- emit_configuration (configurations[i], output);
- g_object_unref (configurations[i]);
- }
-
- g_free (configurations);
- }
-
- emit_configuration (configuration, output);
-
- g_string_append_printf (output, "</monitors>\n");
-
- /* backup the file first */
- rename (intended_filename, backup_filename); /* no error checking because the intended file may not even exist */
-
- result = g_file_set_contents (intended_filename, output->str, -1, error);
-
- if (!result)
- rename (backup_filename, intended_filename); /* no error checking because the backup may not even exist */
-
- g_free (backup_filename);
- g_free (intended_filename);
- g_string_free (output, TRUE);
-
- return result;
-}
-
-gboolean
+static gboolean
xfce_rr_config_apply_with_time (XfceRRConfig *config,
XfceRRScreen *screen,
guint32 timestamp,
@@ -1317,115 +1138,6 @@ xfce_rr_config_apply_with_time (XfceRRConfig *config,
return result;
}
-/* xfce_rr_config_apply_from_filename_with_time:
- * @screen: A #XfceRRScreen
- * @filename: Path of the file to look in for stored RANDR configurations.
- * @timestamp: X server timestamp from the event that causes the screen configuration to change (a user's button press, for example)
- * @error: Location to store error, or %NULL
- *
- * First, this function refreshes the @screen to match the current RANDR
- * configuration from the X server. Then, it tries to load the file in
- * @filename and looks for suitable matching RANDR configurations in the file;
- * if one is found, that configuration will be applied to the current set of
- * RANDR outputs.
- *
- * Typically, @filename is the result of xfce_rr_config_get_intended_filename() or
- * xfce_rr_config_get_backup_filename().
- *
- * Returns: TRUE if the RANDR configuration was loaded and applied from
- * $(XDG_CONFIG_HOME)/monitors.xml, or FALSE otherwise:
- *
- * If the current RANDR configuration could not be refreshed, the @error will
- * have a domain of #XFCE_RR_ERROR and a corresponding error code.
- *
- * If the file in question is loaded successfully but the configuration cannot
- * be applied, the @error will have a domain of #XFCE_RR_ERROR. Note that an
- * error code of #XFCE_RR_ERROR_NO_MATCHING_CONFIG is not a real error; it
- * simply means that there were no stored configurations that match the current
- * set of RANDR outputs.
- *
- * If the file in question cannot be loaded, the @error will have a domain of
- * #G_FILE_ERROR. Note that an error code of G_FILE_ERROR_NOENT is not really
- * an error, either; it means that there was no stored configuration file and so
- * nothing is changed.
- */
-gboolean
-xfce_rr_config_apply_from_filename_with_time (XfceRRScreen *screen, const char *filename, guint32 timestamp, GError **error)
-{
- XfceRRConfig *stored;
- GError *my_error;
-
- g_return_val_if_fail (XFCE_IS_RR_SCREEN (screen), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- my_error = NULL;
- if (!xfce_rr_screen_refresh (screen, &my_error)) {
- if (my_error) {
- g_propagate_error (error, my_error);
- return FALSE; /* This is a genuine error */
- }
-
- /* This means the screen didn't change, so just proceed */
- }
-
- stored = g_object_new (XFCE_TYPE_RR_CONFIG, "screen", screen, NULL);
-
- if (xfce_rr_config_load_filename (stored, filename, error))
- {
- gboolean result;
-
- xfce_rr_config_ensure_primary (stored);
- result = xfce_rr_config_apply_with_time (stored, screen, timestamp, error);
-
- g_object_unref (stored);
-
- return result;
- }
- else
- {
- g_object_unref (stored);
- return FALSE;
- }
-}
-
-/**
- * xfce_rr_config_get_outputs:
- *
- * Returns: (array zero-terminated=1) (element-type MateDesktop.RROutputInfo) (transfer none): the output configuration for this #XfceRRConfig
- */
-XfceRROutputInfo **
-xfce_rr_config_get_outputs (XfceRRConfig *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (self), NULL);
-
- return self->priv->outputs;
-}
-
-/**
- * xfce_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).
- */
-gboolean
-xfce_rr_config_get_clone (XfceRRConfig *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_CONFIG (self), FALSE);
-
- return self->priv->clone;
-}
-
-void
-xfce_rr_config_set_clone (XfceRRConfig *self, gboolean clone)
-{
- g_return_if_fail (XFCE_IS_RR_CONFIG (self));
-
- self->priv->clone = clone;
-}
-
-
/*
* CRTC assignment
*/
diff --git a/src/xfce-rr-config.h b/src/xfce-rr-config.h
index 7bf17a2..29b20b4 100644
--- a/src/xfce-rr-config.h
+++ b/src/xfce-rr-config.h
@@ -55,34 +55,6 @@ typedef struct
GType xfce_rr_output_info_get_type (void);
-char *xfce_rr_output_info_get_name (XfceRROutputInfo *self);
-
-gboolean xfce_rr_output_info_is_active (XfceRROutputInfo *self);
-void xfce_rr_output_info_set_active (XfceRROutputInfo *self, gboolean active);
-
-
-void xfce_rr_output_info_get_geometry (XfceRROutputInfo *self, int *x, int *y, int *width, int *height);
-void xfce_rr_output_info_set_geometry (XfceRROutputInfo *self, int x, int y, int width, int height);
-
-int xfce_rr_output_info_get_refresh_rate (XfceRROutputInfo *self);
-void xfce_rr_output_info_set_refresh_rate (XfceRROutputInfo *self, int rate);
-
-XfceRRRotation xfce_rr_output_info_get_rotation (XfceRROutputInfo *self);
-void xfce_rr_output_info_set_rotation (XfceRROutputInfo *self, XfceRRRotation rotation);
-
-gboolean xfce_rr_output_info_is_connected (XfceRROutputInfo *self);
-void xfce_rr_output_info_get_vendor (XfceRROutputInfo *self, gchar* vendor);
-guint xfce_rr_output_info_get_product (XfceRROutputInfo *self);
-guint xfce_rr_output_info_get_serial (XfceRROutputInfo *self);
-double xfce_rr_output_info_get_aspect_ratio (XfceRROutputInfo *self);
-char *xfce_rr_output_info_get_display_name (XfceRROutputInfo *self);
-
-gboolean xfce_rr_output_info_get_primary (XfceRROutputInfo *self);
-void xfce_rr_output_info_set_primary (XfceRROutputInfo *self, gboolean primary);
-
-int xfce_rr_output_info_get_preferred_width (XfceRROutputInfo *self);
-int xfce_rr_output_info_get_preferred_height (XfceRROutputInfo *self);
-
typedef struct
{
GObject parent;
@@ -105,43 +77,4 @@ typedef struct
GType xfce_rr_config_get_type (void);
-XfceRRConfig *xfce_rr_config_new_current (XfceRRScreen *screen,
- GError **error);
-XfceRRConfig *xfce_rr_config_new_stored (XfceRRScreen *screen,
- GError **error);
-gboolean xfce_rr_config_load_current (XfceRRConfig *self,
- GError **error);
-gboolean xfce_rr_config_load_filename (XfceRRConfig *self,
- const gchar *filename,
- GError **error);
-gboolean xfce_rr_config_match (XfceRRConfig *config1,
- XfceRRConfig *config2);
-gboolean xfce_rr_config_equal (XfceRRConfig *config1,
- XfceRRConfig *config2);
-gboolean xfce_rr_config_save (XfceRRConfig *configuration,
- GError **error);
-void xfce_rr_config_sanitize (XfceRRConfig *configuration);
-gboolean xfce_rr_config_ensure_primary (XfceRRConfig *configuration);
-
-gboolean xfce_rr_config_apply_with_time (XfceRRConfig *configuration,
- XfceRRScreen *screen,
- guint32 timestamp,
- GError **error);
-
-gboolean xfce_rr_config_apply_from_filename_with_time (XfceRRScreen *screen,
- const char *filename,
- guint32 timestamp,
- GError **error);
-
-gboolean xfce_rr_config_applicable (XfceRRConfig *configuration,
- XfceRRScreen *screen,
- GError **error);
-
-gboolean xfce_rr_config_get_clone (XfceRRConfig *configuration);
-void xfce_rr_config_set_clone (XfceRRConfig *configuration, gboolean clone);
-XfceRROutputInfo **xfce_rr_config_get_outputs (XfceRRConfig *configuration);
-
-char *xfce_rr_config_get_backup_filename (void);
-char *xfce_rr_config_get_intended_filename (void);
-
#endif
diff --git a/src/xfce-rr-output-info.c b/src/xfce-rr-output-info.c
index c17e9db..7baaf6b 100644
--- a/src/xfce-rr-output-info.c
+++ b/src/xfce-rr-output-info.c
@@ -62,193 +62,3 @@ xfce_rr_output_info_class_init (XfceRROutputInfoClass *klass)
gobject_class->finalize = xfce_rr_output_info_finalize;
}
-
-/**
- * xfce_rr_output_info_get_name:
- *
- * Returns: (transfer none): the output name
- */
-char *xfce_rr_output_info_get_name (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), NULL);
-
- return self->priv->name;
-}
-
-/**
- * xfce_rr_output_info_is_active:
- *
- * Returns: whether there is a CRTC assigned to this output (i.e. a signal is being sent to it)
- */
-gboolean xfce_rr_output_info_is_active (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), FALSE);
-
- return self->priv->on;
-}
-
-void xfce_rr_output_info_set_active (XfceRROutputInfo *self, gboolean active)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- self->priv->on = active;
-}
-
-/**
- * xfce_rr_output_info_get_geometry:
- * @self: a #XfceRROutputInfo
- * @x: (out) (allow-none):
- * @y: (out) (allow-none):
- * @width: (out) (allow-none):
- * @height: (out) (allow-none):
- */
-void xfce_rr_output_info_get_geometry (XfceRROutputInfo *self, int *x, int *y, int *width, int *height)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- if (x)
- *x = self->priv->x;
- if (y)
- *y = self->priv->y;
- if (width)
- *width = self->priv->width;
- if (height)
- *height = self->priv->height;
-}
-
-/**
- * xfce_rr_output_info_set_geometry:
- * @self: a #XfceRROutputInfo
- * @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 xfce_rr_output_info_set_geometry (XfceRROutputInfo *self, int x, int y, int width, int height)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- self->priv->x = x;
- self->priv->y = y;
- self->priv->width = width;
- self->priv->height = height;
-}
-
-int xfce_rr_output_info_get_refresh_rate (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->rate;
-}
-
-void xfce_rr_output_info_set_refresh_rate (XfceRROutputInfo *self, int rate)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- self->priv->rate = rate;
-}
-
-XfceRRRotation xfce_rr_output_info_get_rotation (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), XFCE_RR_ROTATION_0);
-
- return self->priv->rotation;
-}
-
-void xfce_rr_output_info_set_rotation (XfceRROutputInfo *self, XfceRRRotation rotation)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- self->priv->rotation = rotation;
-}
-
-/**
- * xfce_rr_output_info_is_connected:
- *
- * Returns: whether the output is physically connected to a monitor
- */
-gboolean xfce_rr_output_info_is_connected (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), FALSE);
-
- return self->priv->connected;
-}
-
-/**
- * xfce_rr_output_info_get_vendor:
- * @self: a #XfceRROutputInfo
- * @vendor: (out caller-allocates) (array fixed-size=4):
- */
-void xfce_rr_output_info_get_vendor (XfceRROutputInfo *self, gchar* vendor)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
- g_return_if_fail (vendor != NULL);
-
- vendor[0] = self->priv->vendor[0];
- vendor[1] = self->priv->vendor[1];
- vendor[2] = self->priv->vendor[2];
- vendor[3] = self->priv->vendor[3];
-}
-
-guint xfce_rr_output_info_get_product (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->product;
-}
-
-guint xfce_rr_output_info_get_serial (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->serial;
-}
-
-double xfce_rr_output_info_get_aspect_ratio (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->aspect;
-}
-
-/**
- * xfce_rr_output_info_get_display_name:
- *
- * Returns: (transfer none): the display name of this output
- */
-char *xfce_rr_output_info_get_display_name (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), NULL);
-
- return self->priv->display_name;
-}
-
-gboolean xfce_rr_output_info_get_primary (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), FALSE);
-
- return self->priv->primary;
-}
-
-void xfce_rr_output_info_set_primary (XfceRROutputInfo *self, gboolean primary)
-{
- g_return_if_fail (XFCE_IS_RR_OUTPUT_INFO (self));
-
- self->priv->primary = primary;
-}
-
-int xfce_rr_output_info_get_preferred_width (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->pref_width;
-}
-
-int xfce_rr_output_info_get_preferred_height (XfceRROutputInfo *self)
-{
- g_return_val_if_fail (XFCE_IS_RR_OUTPUT_INFO (self), 0);
-
- return self->priv->pref_height;
-}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list