static gboolean place_transient_splash(ObClient *client, Rect *area, gint *x, gint *y, Size frame_size) { if (client->type == OB_CLIENT_TYPE_DIALOG) { GSList *it; gboolean first = TRUE; gint l, r, t, b; ob_debug("placing dialog"); for (it = client->parents; it; it = g_slist_next(it)) { ObClient *m = it->data; if (!m->iconic) { if (first) { l = RECT_LEFT(m->frame->area); t = RECT_TOP(m->frame->area); r = RECT_RIGHT(m->frame->area); b = RECT_BOTTOM(m->frame->area); first = FALSE; } else { l = MIN(l, RECT_LEFT(m->frame->area)); t = MIN(t, RECT_TOP(m->frame->area)); r = MAX(r, RECT_RIGHT(m->frame->area)); b = MAX(b, RECT_BOTTOM(m->frame->area)); } } if (!first) { *x = ((r + 1 - l) - frame_size.width) / 2 + l; *y = ((b + 1 - t) - frame_size.height) / 2 + t; return TRUE; } } } if (client->type == OB_CLIENT_TYPE_DIALOG || client->type == OB_CLIENT_TYPE_SPLASH) { ob_debug("placing dialog or splash"); *x = (area->width - frame_size.width) / 2 + area->x; *y = (area->height - frame_size.height) / 2 + area->y; return TRUE; } return FALSE; }
static void do_edge_warp(gint x, gint y) { guint i; ObDirection dir; if (!config_mouse_screenedgetime) return; dir = -1; for (i = 0; i < screen_num_monitors; ++i) { const Rect *a = screen_physical_area_monitor(i); if (!RECT_CONTAINS(*a, x, y)) continue; if (x == RECT_LEFT(*a)) dir = OB_DIRECTION_WEST; if (x == RECT_RIGHT(*a)) dir = OB_DIRECTION_EAST; if (y == RECT_TOP(*a)) dir = OB_DIRECTION_NORTH; if (y == RECT_BOTTOM(*a)) dir = OB_DIRECTION_SOUTH; /* try check for xinerama boundaries */ if ((x + 1 == RECT_LEFT(*a) || x - 1 == RECT_RIGHT(*a)) && (dir == OB_DIRECTION_WEST || dir == OB_DIRECTION_EAST)) { dir = -1; } if ((y + 1 == RECT_TOP(*a) || y - 1 == RECT_BOTTOM(*a)) && (dir == OB_DIRECTION_NORTH || dir == OB_DIRECTION_SOUTH)) { dir = -1; } } if (dir != edge_warp_dir) { cancel_edge_warp(); if (dir != (ObDirection)-1) { edge_warp_odd = TRUE; /* switch on the first timeout */ edge_warp_timer = g_timeout_add(config_mouse_screenedgetime, edge_warp_delay_func, NULL); } edge_warp_dir = dir; } }
/** * uber_line_graph_render_fast: * @graph: A #UberGraph. * * XXX * * Returns: None. * Side effects: None. */ static void uber_line_graph_render_fast (UberGraph *graph, /* IN */ cairo_t *cr, /* IN */ GdkRectangle *rect, /* IN */ guint epoch, /* IN */ gfloat each) /* IN */ { UberLineGraphPrivate *priv; UberRange pixel_range; LineInfo *line; gdouble last_y; gdouble y; gint i; g_return_if_fail(UBER_IS_LINE_GRAPH(graph)); g_return_if_fail(cr != NULL); g_return_if_fail(rect != NULL); priv = UBER_LINE_GRAPH(graph)->priv; pixel_range.begin = rect->y + 1; pixel_range.end = rect->y + rect->height; pixel_range.range = pixel_range.end - pixel_range.begin; /* * Render most recent data point for each line. */ for (i = 0; i < priv->lines->len; i++) { line = &g_array_index(priv->lines, LineInfo, i); uber_line_graph_stylize_line(UBER_LINE_GRAPH(graph), line, cr); /* * Calculate positions. */ y = g_ring_get_index(line->raw_data, gdouble, 0); last_y = g_ring_get_index(line->raw_data, gdouble, 1); /* * Don't try to draw before we have real values. */ if ((isnan(y) || isinf(y)) || (isnan(last_y) || isinf(last_y))) { continue; } /* * Translate to coordinate scale. */ if (!priv->scale(&priv->range, &pixel_range, &y, priv->scale_data) || !priv->scale(&priv->range, &pixel_range, &last_y, priv->scale_data)) { continue; } /* * Translate position from bottom right corner. */ y = (gint)(RECT_BOTTOM(*rect) - y) - .5; last_y = (gint)(RECT_BOTTOM(*rect) - last_y) - .5; /* * Convert relative position to fixed from bottom pixel. */ cairo_new_path(cr); cairo_move_to(cr, epoch, y); cairo_curve_to(cr, epoch - (each / 2.), y, epoch - (each / 2.), last_y, epoch - each, last_y); cairo_stroke(cr); } }
/** * uber_line_graph_render_fast: * @graph: A #UberGraph. * * XXX * * Returns: None. * Side effects: None. */ static void uber_line_graph_render_fast (UberGraph *graph, /* IN */ cairo_t *cr, /* IN */ GdkRectangle *rect, /* IN */ guint epoch, /* IN */ gfloat each) /* IN */ { UberLineGraphPrivate *priv; LineInfo *line; gdouble last_y; gdouble y; gint i; g_return_if_fail(UBER_IS_LINE_GRAPH(graph)); g_return_if_fail(cr != NULL); g_return_if_fail(rect != NULL); priv = UBER_LINE_GRAPH(graph)->priv; /* * Prepare cairo line styling. */ cairo_set_line_width(cr, 1.0); cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT); /* * Render most recent data point for each line. */ for (i = 0; i < priv->lines->len; i++) { line = &g_array_index(priv->lines, LineInfo, i); gdk_cairo_set_source_color(cr, &line->color); /* * Calculate positions. */ y = g_ring_get_index(line->scaled_data, gdouble, 0); last_y = g_ring_get_index(line->scaled_data, gdouble, 1); /* * Don't try to draw before we have real values. */ if ((isnan(y) || isinf(y)) || (isnan(last_y) || isinf(last_y))) { continue; } /* * Translate position from bottom right corner. */ y = RECT_BOTTOM(*rect) - y; last_y = RECT_BOTTOM(*rect) - last_y; /* * Convert relative position to fixed from bottom pixel. */ cairo_new_path(cr); cairo_move_to(cr, epoch, y); cairo_curve_to(cr, epoch - (each / 2.), y, epoch - (each / 2.), last_y, epoch - each, last_y); cairo_stroke(cr); } }
/** * uber_line_graph_render: * @graph: A #UberGraph. * @cr: A #cairo_t context. * @area: Full area to render contents within. * @line: The line to render. * * Render a particular line to the graph. * * Returns: None. * Side effects: None. */ static void uber_line_graph_render_line (UberLineGraph *graph, /* IN */ cairo_t *cr, /* IN */ GdkRectangle *area, /* IN */ LineInfo *line, /* IN */ guint epoch, /* IN */ gfloat each) /* IN */ { UberLineGraphPrivate *priv; UberRange pixel_range; GdkRectangle vis; guint x; guint last_x; gdouble y; gdouble last_y; gdouble val; gint i; g_return_if_fail(UBER_IS_LINE_GRAPH(graph)); priv = graph->priv; uber_graph_get_content_area(UBER_GRAPH(graph), &vis); pixel_range.begin = area->y + 1; pixel_range.end = area->y + area->height; pixel_range.range = pixel_range.end - pixel_range.begin; /* * Prepare cairo settings. */ uber_line_graph_stylize_line(graph, line, cr); /* * Force a new path. */ cairo_new_path(cr); /* * Draw the line contents as bezier curves. */ for (i = 0; i < line->raw_data->len; i++) { /* * Retrieve data point. */ val = g_ring_get_index(line->raw_data, gdouble, i); /* * Once we get to -INFINITY, we must be at the end of the data * sequence. This may not always be true in the future. */ if (val == -INFINITY) { break; } /* * Translate value to coordinate system. */ if (!priv->scale(&priv->range, &pixel_range, &val, priv->scale_data)) { break; } /* * Calculate X/Y coordinate. */ y = (gint)(RECT_BOTTOM(*area) - val) - .5; x = epoch - (each * i); if (i == 0) { /* * Just move to the right position on first entry. */ cairo_move_to(cr, x, y); goto next; } else { /* * Draw curve to data point using the last X/Y positions as * control points. */ cairo_curve_to(cr, last_x - (each / 2.), last_y, last_x - (each / 2.), y, x, y); } next: last_y = y; last_x = x; } /* * Stroke the line content. */ cairo_stroke(cr); }