Commit 393e3c08 authored by Jeremy Harris's avatar Jeremy Harris

Fix issue with zooming linked windows

parent 70f4a309
......@@ -1219,12 +1219,11 @@ undisplay_plotter(plotter * pl, int direction)
void
shrink_to_bbox(struct plotter *pl, int x, int y)
{
command *c;
command *c, *first, *final = NULL;
int nmapped = 0;
int ndots = 0;
int virgin = 1;
coord saved_x_left = pl_x_left;
coord saved_x_right = pl_x_right;
coord saved_y_bottom = pl_y_bottom;
......@@ -1240,7 +1239,21 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
for (c = pl->first_mapped_plain[pl->viewno];
c && c != pl->final_mapped_plain[pl->viewno];
c = c->next)
{
compute_window_coords(pl, c);
if (c->mapped) break;
}
first = c;
for (;
c && c != pl->final_mapped_plain[pl->viewno];
c = c->next)
{
compute_window_coords(pl, c);
if (c->mapped) final = c;
}
pl->first_mapped_plain[pl->viewno] = first;
pl->final_mapped_plain[pl->viewno] = final;
#ifdef LOTS_OF_DEBUGGING_PRINTS
fprintf(stderr, "C_S_P: view %d OLD %s %s %s %s\n",
......@@ -1251,7 +1264,14 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
unparse_coord(pl->y_type, pl_y_top));
#endif
for (c = pl->first_mapped_plain[pl->viewno]; c; c = c->next)
c = first;
if (c)
{
if (x) pl_x_left = pl_x_right = c->xa;
if (y) pl_y_bottom = pl_y_top = c->ya;
}
for (; c && c != final; c = c->next)
if (c->mapped)
{
nmapped++;
......@@ -1262,19 +1282,18 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
case BOX2:
if ( x )
{
if (virgin || ccmp(pl->x_type, c->xb, pl_x_left, <))
pl_x_left = c->xb;
if (virgin || ccmp(pl->x_type, c->xb, pl_x_right, >))
if (ccmp(pl->x_type, c->xa, pl_x_left, <))
pl_x_left = c->xa;
if (ccmp(pl->x_type, c->xb, pl_x_right, >))
pl_x_right = c->xb;
}
if ( y )
{
if (virgin || ccmp(pl->y_type, c->yb, pl_y_bottom, <))
pl_y_bottom = c->yb;
if (virgin || ccmp(pl->y_type, c->yb, pl_y_top, >))
if (ccmp(pl->y_type, c->ya, pl_y_bottom, <))
pl_y_bottom = c->ya;
if (ccmp(pl->y_type, c->yb, pl_y_top, >))
pl_y_top = c->yb;
}
virgin = 0;
case X:
case DOT:
......@@ -1296,19 +1315,18 @@ shrink_to_bbox(struct plotter *pl, int x, int y)
ndots++;
if ( x )
{
if (virgin || ccmp(pl->x_type, c->xa, pl_x_left, <))
if (ccmp(pl->x_type, c->xa, pl_x_left, <))
pl_x_left = c->xa;
if (virgin || ccmp(pl->x_type, c->xa, pl_x_right, >))
if (ccmp(pl->x_type, c->xa, pl_x_right, >))
pl_x_right = c->xa;
}
if ( y )
{
if (virgin || ccmp(pl->y_type, c->ya, pl_y_bottom, <))
if (ccmp(pl->y_type, c->ya, pl_y_bottom, <))
pl_y_bottom = c->ya;
if (virgin || ccmp(pl->y_type, c->ya, pl_y_top, >))
if (ccmp(pl->y_type, c->ya, pl_y_top, >))
pl_y_top = c->ya;
}
virgin = 0;
case INFO:
case AREA:
case TITLE:
......@@ -2370,8 +2388,7 @@ main(int argc, char *argv[])
if (x_synch && y_synch) {
plotter * savepl = pl;
for (ALLPLOTTERS) {
if (pl == savepl) continue;
for (ALLPLOTTERS) if (pl != savepl) {
if (pl->pointer_marks_on_screen) {
draw_pointer_marks(pl, pl->xorgc);
pl->pointer_marks_on_screen = FALSE;
......@@ -2489,9 +2506,7 @@ main(int argc, char *argv[])
if (x_synch && y_synch) {
plotter * savepl = pl;
for (ALLPLOTTERS) {
if (pl == savepl) continue;
for (ALLPLOTTERS) if (pl != savepl) {
if (pl -> state == NORMAL) {
pl->state = SLAVE;
pl->master = savepl;
......@@ -2540,9 +2555,7 @@ main(int argc, char *argv[])
if (x_synch && y_synch) {
plotter * savepl = pl;
for (ALLPLOTTERS) {
if (pl == savepl) continue;
for (ALLPLOTTERS) if (pl != savepl) {
draw_pointer_marks(pl, pl->xorgc);
pl->pointer_marks_on_screen = TRUE;
}
......@@ -2560,8 +2573,7 @@ main(int argc, char *argv[])
if (x_synch && y_synch) {
plotter * savepl = pl;
for (ALLPLOTTERS) {
if (pl == savepl) continue;
for (ALLPLOTTERS) if (pl != savepl) {
if (pl->pointer_marks_on_screen) {
draw_pointer_marks(pl, pl->xorgc);
pl->pointer_marks_on_screen = FALSE;
......@@ -2572,15 +2584,9 @@ main(int argc, char *argv[])
if (x_synch && y_synch) {
plotter * savepl = pl;
for (ALLPLOTTERS) {
if (pl == savepl) continue;
if (pl->state == SLAVE) {
if (pl->buttonsdown == 0)
pl->state = NORMAL;
else
pl->state = WEDGED;
}
}
for (ALLPLOTTERS) if (pl != savepl)
if (pl->state == SLAVE)
pl->state = pl->buttonsdown == 0 ? NORMAL : WEDGED;
pl = savepl;
}
......@@ -2657,8 +2663,9 @@ main(int argc, char *argv[])
dragstart = pl->dragstart;
dragend = pl->dragend;
/* Do the plotter in which the button was pressed first, then do
all the others if we are synchronizing (and need to). */
/* Do the plotter in which the button was pressed first,
("the pointed plotter") then do all the others if we are
synchronizing (and need to). */
if ((abs(pl->raw_dragstart.x - event.xbutton.x) > 7) ||
(abs(pl->raw_dragstart.y - event.xbutton.y) > 7)) {
......@@ -2733,52 +2740,51 @@ main(int argc, char *argv[])
pl->state = NORMAL;
/* If we need to, loop through all the plotters. */
if (do_x || do_y || must_pop_others)
for (ALLPLOTTERS)
for (ALLPLOTTERS) if (pl != savepl)
{
if (pl == savepl) continue;
if (must_pop_others)
{
if (pl->viewno > 1) pl->viewno--;
if (x_synch)
{
pl_x_left = savepl->x_left[savepl->viewno];
pl_x_right = savepl->x_right[savepl->viewno];
}
if (y_synch)
{
pl_y_top = savepl->y_top[savepl->viewno];
pl_y_bottom = savepl->y_bottom[savepl->viewno];
}
}
else
{
int newviewno;
newviewno = pl->viewno + 1;
if (newviewno == NUMVIEWS) newviewno -= 1;
if (do_x) {
pl->x_left[newviewno] = savepl->x_left[savepl->viewno];
pl->x_right[newviewno] = savepl->x_right[savepl->viewno];
} else {
pl->x_left[newviewno] = pl_x_left;
pl->x_right[newviewno] = pl_x_right;
if (must_pop_others)
{
if (pl->viewno > 1) pl->viewno--;
if (x_synch)
{
pl_x_left = savepl->x_left[savepl->viewno];
pl_x_right = savepl->x_right[savepl->viewno];
}
if (do_y) {
pl->y_bottom[newviewno] =
savepl->y_bottom[savepl->viewno];
pl->y_top[newviewno] = savepl->y_top[savepl->viewno];
} else {
pl->y_bottom[newviewno] = pl_y_bottom;
pl->y_top[newviewno] = pl_y_top;
if (y_synch)
{
pl_y_top = savepl->y_top[savepl->viewno];
pl_y_bottom = savepl->y_bottom[savepl->viewno];
}
pl->first_mapped_plain[newviewno] = pl->first_mapped_plain[pl->viewno];
pl->final_mapped_plain[newviewno] = pl->final_mapped_plain[pl->viewno];
pl->viewno = newviewno;
if (do_x && !y_synch)
shrink_to_bbox(pl,0,1);
}
pl->size_changed = TRUE;
}
else
{
int newviewno;
newviewno = pl->viewno + 1;
if (newviewno == NUMVIEWS) newviewno -= 1;
if (do_x) { /* winrange coupled in x; copy from the pointed plotter */
pl->x_left[newviewno] = savepl->x_left[savepl->viewno];
pl->x_right[newviewno] = savepl->x_right[savepl->viewno];
} else {
pl->x_left[newviewno] = pl_x_left;
pl->x_right[newviewno] = pl_x_right;
}
if (do_y) { /* winrange coupled in y; copy from the pointed plotter */
pl->y_bottom[newviewno] =
savepl->y_bottom[savepl->viewno];
pl->y_top[newviewno] = savepl->y_top[savepl->viewno];
} else {
pl->y_bottom[newviewno] = pl_y_bottom;
pl->y_top[newviewno] = pl_y_top;
}
pl->first_mapped_plain[newviewno] = pl->first_mapped_plain[pl->viewno];
pl->final_mapped_plain[newviewno] = pl->final_mapped_plain[pl->viewno];
pl->viewno = newviewno;
if (do_x && !y_synch) /*XXX why not duplicated for Y? */
shrink_to_bbox(pl,0,1); /* reevaluate just the y-limits */
}
pl->size_changed = TRUE;
}
G0093:
pl = savepl; /* Don't know if I have to do this, but... */
......@@ -2808,23 +2814,22 @@ main(int argc, char *argv[])
pl->size_changed = TRUE;
if (x_synch || y_synch)
for (ALLPLOTTERS)
for (ALLPLOTTERS) if (pl != savepl)
{
if (pl == savepl) continue;
if (x_synch && savepl->state != VDRAG)
{
pl_x_left = savepl->x_left[savepl->viewno];
pl_x_right = savepl->x_right[savepl->viewno];
if (!y_synch) shrink_to_bbox(pl,0,1);
pl->size_changed = TRUE;
}
if (y_synch && savepl->state != HDRAG)
{
pl_y_top = savepl->y_top[savepl->viewno];
pl_y_bottom = savepl->y_bottom[savepl->viewno];
if (!x_synch) shrink_to_bbox(pl,1,0);
pl->size_changed = TRUE;
}
if (x_synch && savepl->state != VDRAG)
{
pl_x_left = savepl->x_left[savepl->viewno];
pl_x_right = savepl->x_right[savepl->viewno];
if (!y_synch) shrink_to_bbox(pl,0,1);
pl->size_changed = TRUE;
}
if (y_synch && savepl->state != HDRAG)
{
pl_y_top = savepl->y_top[savepl->viewno];
pl_y_bottom = savepl->y_bottom[savepl->viewno];
if (!x_synch) shrink_to_bbox(pl,1,0);
pl->size_changed = TRUE;
}
}
pl = savepl;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment