Somewhat sane default canvas positions for clients

This commit is contained in:
Nedko Arnaudov 2009-10-05 00:15:53 +03:00
parent 9f21a69786
commit 7f21faa728
3 changed files with 23 additions and 0 deletions

View File

@ -173,6 +173,16 @@ canvas_clear(
}
}
void
canvas_get_size(
canvas_handle canvas,
double * width_ptr,
double * height_ptr)
{
*width_ptr = canvas_ptr->get()->width();
*height_ptr = canvas_ptr->get()->height();
}
void
canvas_scroll_to_center(
canvas_handle canvas)

View File

@ -65,6 +65,12 @@ void
canvas_clear(
canvas_handle canvas);
void
canvas_get_size(
canvas_handle canvas,
double * width_ptr,
double * height_ptr);
void
canvas_scroll_to_center(
canvas_handle canvas);

View File

@ -222,9 +222,14 @@ client_appeared(
double x;
double y;
char * locale;
double width;
double height;
log_info("canvas::client_appeared(%"PRIu64", \"%s\")", id, name);
canvas_get_size(graph_canvas_ptr->canvas, &width, &height);
//log_debug("width %f, height %f", width, height);
client_ptr = malloc(sizeof(struct client));
if (client_ptr == NULL)
{
@ -247,6 +252,7 @@ client_appeared(
&x_str))
{
x_str = NULL;
x = width / 2 - 100 + rand() % 400;
}
if (!graph_proxy_dict_entry_get(
@ -257,6 +263,7 @@ client_appeared(
&y_str))
{
y_str = NULL;
y = height / 2 - 100 + rand() % 400;
}
if (x_str != NULL || y_str != NULL)