/**
 * cc_rr_labeler_get_rgba_for_output:
 * @labeler: A #CcRRLabeler
 * @output: Output device (i.e. monitor) to query
 * @rgba_out: (out): Color of selected monitor.
 *
 * Get the color used for the label on a given output (monitor).
 */
void
cc_rr_labeler_get_rgba_for_output (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba_out)
{
	int i;
	GnomeRROutputInfo **outputs;

	g_return_if_fail (GNOME_IS_RR_LABELER (labeler));
	g_return_if_fail (GNOME_IS_RR_OUTPUT_INFO (output));
	g_return_if_fail (rgba_out != NULL);

	outputs = gnome_rr_config_get_outputs (labeler->priv->config);

	for (i = 0; i < labeler->priv->num_outputs; i++)
		if (outputs[i] == output) {
			*rgba_out = labeler->priv->palette[i];
			return;
		}

	g_warning ("trying to get the color for unknown GnomeOutputInfo %p; returning magenta!", output);

	rgba_out->red   = 1.0;
	rgba_out->green = 0;
	rgba_out->blue  = 1.0;
	rgba_out->alpha  = 1.0;
}
/**
 * cc_rr_labeler_show:
 * @labeler: A #CcRRLabeler
 *
 * Show the labels.
 */
void
cc_rr_labeler_show (CcRRLabeler *labeler)
{
	int i;
	gboolean created_window_for_clone;
	GnomeRROutputInfo **outputs;

	g_return_if_fail (GNOME_IS_RR_LABELER (labeler));

	if (labeler->priv->windows != NULL)
		return;

	labeler->priv->windows = g_new (GtkWidget *, labeler->priv->num_outputs);

	created_window_for_clone = FALSE;

	outputs = gnome_rr_config_get_outputs (labeler->priv->config);

	for (i = 0; i < labeler->priv->num_outputs; i++) {
		if (!created_window_for_clone && gnome_rr_output_info_is_active (outputs[i])) {
			labeler->priv->windows[i] = create_label_window (labeler, outputs[i], labeler->priv->palette + i);

			if (gnome_rr_config_get_clone (labeler->priv->config))
				created_window_for_clone = TRUE;
		} else
			labeler->priv->windows[i] = NULL;
	}
}
static int
count_outputs (GnomeRRConfig *config)
{
	int i;
	GnomeRROutputInfo **outputs = gnome_rr_config_get_outputs (config);

	for (i = 0; outputs[i] != NULL; i++)
		;

	return i;
}
Exemplo n.º 4
0
static void gnome_rr_output_info_get_tiled_geometry (GnomeRROutputInfo *self,
                                                     int *x,
                                                     int *y,
                                                     int *width,
                                                     int *height)
{
    GnomeRROutputInfo **outputs;
    gboolean active;
    int i;
    int ht, vt;
    int total_w = 0, total_h = 0;

    outputs = gnome_rr_config_get_outputs (self->priv->config);

    /*
     * iterate over all the outputs from 0,0 -> h,v
     * find the output for each tile,
     * if it is the 0 tile, store the x/y offsets.
     * if the tile is active, add the tile to the total w/h
     * for the output if the tile is in the 0 row or 0 column.
     */
    for (ht = 0; ht < self->priv->tile.max_horiz_tiles; ht++)
    {
        for (vt = 0; vt < self->priv->tile.max_vert_tiles; vt++)
        {
            for (i = 0; outputs[i]; i++)
            {
                GnomeRRTile *this_tile = &outputs[i]->priv->tile;

                if (!outputs[i]->priv->is_tiled)
                    continue;

                if (this_tile->group_id != self->priv->tile.group_id)
                    continue;

                if (this_tile->loc_horiz != ht ||
                    this_tile->loc_vert != vt)
                    continue;

                if (vt == 0 && ht == 0)
                {
                    if (x)
                        *x = outputs[i]->priv->x;
                    if (y)
                        *y = outputs[i]->priv->y;
                }

                active = gnome_rr_output_info_is_active (outputs[i]);
                if (!active)
                    continue;

                if (this_tile->loc_horiz == 0)
                    total_h += outputs[i]->priv->height;

                if (this_tile->loc_vert == 0)
                    total_w += outputs[i]->priv->width;
            }
        }
    }

    if (width)
        *width = total_w;
    if (height)
        *height = total_h;
}
Exemplo n.º 5
0
static void gnome_rr_output_info_set_tiled_rotation (GnomeRROutputInfo *self, GnomeRRRotation rotation)
{
    GnomeRROutputInfo **outputs;
    int x_off;
    int base_x = 0, base_y = 0;
    int ht, vt;
    int i;

    outputs = gnome_rr_config_get_outputs (self->priv->config);
    x_off = 0;
    /*
     * iterate over all the outputs from 0,0 -> h,v
     * find the output for each tile,
     * for all tiles set the rotation,
     * for the 0 tile use the base X/Y offsets
     * for non-0 tile, rotate the offsets of each
     * tile so things display correctly.
     */
    for (ht = 0; ht < self->priv->tile.max_horiz_tiles; ht++)
    {
        int y_off = 0;
        int addx = 0;
        for (vt = 0; vt < self->priv->tile.max_vert_tiles; vt++)
        {
            for (i = 0; outputs[i] != NULL; i++)
            {
                GnomeRRTile *this_tile = &outputs[i]->priv->tile;
                int new_x, new_y;

                if (!outputs[i]->priv->is_tiled)
                    continue;

                if (this_tile->group_id != self->priv->tile.group_id)
                    continue;

                if (this_tile->loc_horiz != ht ||
                    this_tile->loc_vert != vt)
                    continue;

                /* set tile rotation */
                outputs[i]->priv->rotation = rotation;

                /* for non-zero tiles - change the offsets */
                if (ht == 0 && vt == 0)
                {
                    base_x = outputs[i]->priv->x;
                    base_y = outputs[i]->priv->y;
                }
                else
                {
                    if ((rotation & GNOME_RR_ROTATION_90) || (rotation & GNOME_RR_ROTATION_270))
                    {
                        new_x = base_x + y_off;
                        new_y = base_y + x_off;
                    }
                    else
                    {
                        new_x = base_x + x_off;
                        new_y = base_y + y_off;
                    }
                    outputs[i]->priv->x = new_x;
                    outputs[i]->priv->y = new_y;
                    outputs[i]->priv->width = this_tile->width;
                    outputs[i]->priv->height = this_tile->height;
                }

                y_off += this_tile->height;
                if (vt == 0)
                    addx = this_tile->width;
            }
        }
        x_off += addx;
    }
}
Exemplo n.º 6
0
static void gnome_rr_output_info_set_tiled_geometry (GnomeRROutputInfo *self, int x, int y, int width, int height)
{
    GnomeRROutputInfo **outputs;
    gboolean primary_tile_only = FALSE;
    int ht, vt, i;
    int x_off;

    primary_tile_only = TRUE;

    if (width == self->priv->total_tiled_width &&
        height == self->priv->total_tiled_height)
        primary_tile_only = FALSE;

    outputs = gnome_rr_config_get_outputs (self->priv->config);
    /*
     * iterate over all the outputs from 0,0 -> h,v
     * find the output for each tile,
     * if only the primary tile is being set, disable
     * the non-primary tiles, and set the output up
     * for tile 0 only.
     * if all tiles are being set, then store the
     * dimensions for this tile, and increase the offsets.
     * y_off is reset per column of tiles,
     * addx is incremented for the first row of tiles
     * to set the correct x offset.
     */
    x_off = 0;
    for (ht = 0; ht < self->priv->tile.max_horiz_tiles; ht++)
    {
        int y_off = 0;
        int addx = 0;
        for (vt = 0; vt < self->priv->tile.max_vert_tiles; vt++)
        {
            for (i = 0; outputs[i]; i++)
            {
                GnomeRRTile *this_tile = &outputs[i]->priv->tile;

                if (!outputs[i]->priv->is_tiled)
                    continue;

                if (this_tile->group_id != self->priv->tile.group_id)
                    continue;

                if (this_tile->loc_horiz != ht ||
                    this_tile->loc_vert != vt)
                    continue;

                /* for primary tile only configs turn off non-primary
                   tiles - turn them on for tiled ones */
                if (ht != 0 || vt != 0)
                {
                    if (self->priv->on == FALSE)
                        outputs[i]->priv->on = FALSE;
                    else
                        outputs[i]->priv->on = !primary_tile_only;
                }

                if (primary_tile_only)
                {
                        if (ht == 0 && vt == 0)
                        {
                            outputs[i]->priv->x = x;
                            outputs[i]->priv->y = y;
                            outputs[i]->priv->width = width;
                            outputs[i]->priv->height = height;
                        }
                }
                else
                {
                    outputs[i]->priv->x = x + x_off;
                    outputs[i]->priv->y = y + y_off;
                    outputs[i]->priv->width = this_tile->width;
                    outputs[i]->priv->height = this_tile->height;

                    y_off += this_tile->height;
                    if (vt == 0)
                        addx = this_tile->width;
                }
            }
        }
        x_off += addx;
    }
}