From 0e6abdc9eb4f144e014faa9211fc238727d89ac5 Mon Sep 17 00:00:00 2001 From: Mandrake Date: Fri, 1 Oct 1999 21:38:22 +0000 Subject: [PATCH] Fri Oct 1 17:01:44 PDT 1999 (Mandrake) let us place dialog boxes arranged like the rest of the windows in the world SVN revision: 555 --- src/ChangeLog | 7 +++ src/E.h | 2 + src/arrange.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/borders.c | 4 -- src/dialog.c | 4 +- 5 files changed, 138 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ce0274dc..7b24ad7d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2689,3 +2689,10 @@ Fri Oct 1 16:19:08 PDT 1999 (Raster) commit updated TODO + +------------------------------------------------------------------------------- + +Fri Oct 1 17:01:44 PDT 1999 +(Mandrake) + +let us place dialog boxes arranged like the rest of the windows in the world diff --git a/src/E.h b/src/E.h index a9038417..227fbc58 100644 --- a/src/E.h +++ b/src/E.h @@ -2526,6 +2526,8 @@ void MoveEwinLinearAreaBy(EWin * ewin, int a); int Emkstemp(char *template); void SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy); +void ArrangeEwin(EWin * ewin); + void SessionInit(void); void SessionSave(int shutdown); void doSMExit(void *params); diff --git a/src/arrange.c b/src/arrange.c index eed30c1a..aa360011 100644 --- a/src/arrange.c +++ b/src/arrange.c @@ -728,3 +728,130 @@ SnapEwin(EWin * ewin, int dx, int dy, int *new_dx, int *new_dy) *new_dy = dy; EDBUG_RETURN_; } + +void +ArrangeEwin(EWin * ewin) +{ + + EWin **lst; + Button **blst; + int i, j, num; + RectBox *fixed, *ret, newrect; + + ewin->client.already_placed = 1; + lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN); + if ((lst) && (num > 0)) + { + fixed = Emalloc(sizeof(RectBox) * num); + ret = Emalloc(sizeof(RectBox) * (num + 1)); + j = 0; + for (i = 0; i < num; i++) + { + if ((lst[i] != ewin) && (!lst[i]->iconified) && + (!lst[i]->ignorearrange) && (lst[i]->layer != 0) && + (((lst[i]->area_x == desks.desk[ewin->desktop].current_area_x) && + (lst[i]->area_y == desks.desk[ewin->desktop].current_area_y) && + (lst[i]->desktop == ewin->desktop)) || + (lst[i]->sticky))) + { + fixed[j].data = lst[i]; + fixed[j].x = (lst[i])->x; + fixed[j].y = (lst[i])->y; + fixed[j].w = (lst[i])->w; + fixed[j].h = (lst[i])->h; + if (fixed[j].x < 0) + { + fixed[j].x += fixed[j].w; + fixed[j].x = 0; + } + if ((fixed[j].x + fixed[j].w) > root.w) + fixed[j].w = root.w - fixed[j].x; + if (fixed[j].y < 0) + { + fixed[j].y += fixed[j].h; + fixed[j].y = 0; + } + if ((fixed[j].y + fixed[j].h) > root.h) + fixed[j].h = root.h - fixed[j].y; + if ((fixed[j].w > 0) && (fixed[j].h > 0)) + { + if (!(lst[i])->never_use_area) + fixed[j].p = (lst[i])->layer; + else + fixed[j].p = 50; + j++; + } + } + } + blst = (Button **) ListItemType(&num, LIST_TYPE_BUTTON); + if (blst) + { + fixed = Erealloc(fixed, sizeof(RectBox) * (num + j)); + ret = Erealloc(ret, sizeof(RectBox) * ((num + j) + 1)); + for (i = 0; i < num; i++) + { + if (((blst[i]->desktop == ewin->desktop) || + ((blst[i]->desktop == 0) && (blst[i]->sticky))) && + (blst[i]->visible)) + { + fixed[j].data = NULL; + fixed[j].x = blst[i]->x; + fixed[j].y = blst[i]->y; + fixed[j].w = blst[i]->w; + fixed[j].h = blst[i]->h; + if (fixed[j].x < 0) + { + fixed[j].x += fixed[j].w; + fixed[j].x = 0; + } + if ((fixed[j].x + fixed[j].w) > root.w) + fixed[j].w = root.w - fixed[j].x; + if (fixed[j].y < 0) + { + fixed[j].y += fixed[j].h; + fixed[j].y = 0; + } + if ((fixed[j].y + fixed[j].h) > root.h) + fixed[j].h = root.h - fixed[j].y; + if ((fixed[j].w > 0) && (fixed[j].h > 0)) + { + if (blst[i]->sticky) + fixed[j].p = 50; + else + fixed[j].p = 0; + j++; + } + } + } + Efree(blst); + } + newrect.data = ewin; + newrect.x = 0; + newrect.y = 0; + newrect.w = ewin->w; + newrect.h = ewin->h; + newrect.p = ewin->layer; + ArrangeRects(fixed, j, &newrect, 1, ret, root.w, root.h, ARRANGE_BY_SIZE); + for (i = 0; i < j + 1; i++) + { + if (ret[i].data == ewin) + { + ewin->x = ret[i].x; + ewin->y = ret[i].y; + i = j + 1; + } + } + Efree(lst); + if (ret) + Efree(ret); + if (fixed) + Efree(fixed); + } + else + { + ewin->x = (root.w - ewin->w) >> 1; + ewin->y = (root.h - ewin->h) >> 1; + } + MoveEwin(ewin, ewin->x, ewin->y); + +} diff --git a/src/borders.c b/src/borders.c index 3cbc64eb..03d88521 100644 --- a/src/borders.c +++ b/src/borders.c @@ -142,7 +142,6 @@ GetFocusEwin(void) } EDBUG_RETURN(mode.realfocuswin); } - if (mode.borderpartpress) { if (mode.context_ewin) @@ -154,7 +153,6 @@ GetFocusEwin(void) EDBUG_RETURN(mode.realfocuswin); } } - if (mode.mode != MODE_NONE) EDBUG_RETURN(GetEwin()); @@ -1295,7 +1293,6 @@ AdoptInternal(Window win, Border * border, int type, void *ptr) else SetEwinBorder(ewin); } - b = ewin->border; ewin->border = NULL; ewin->border_new = 1; @@ -1558,7 +1555,6 @@ FreeEwin(EWin * ewin) for (i = 0; i < num_groups; i++) RemoveEwinFromGroup(ewin, ewin->groups[0]); } - Efree(ewin); EDBUG_RETURN_; diff --git a/src/dialog.c b/src/dialog.c index 07d55e03..72dc6c79 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -590,11 +590,11 @@ ShowDialog(Dialog * d) } else { - MoveEwin(ewin, (root.w - ewin->w) / 2, (root.h - ewin->h) / 2); + ArrangeEwin(ewin); } } else - MoveEwin(ewin, (root.w - ewin->w) / 2, (root.h - ewin->h) / 2); + ArrangeEwin(ewin); RestackEwin(ewin); ShowEwin(ewin); ewin->dialog = d;