diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-15 20:05:53 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-15 20:05:53 -0400 |
commit | ac802fe10221ef3c6426ac1ebf4a250f189d1228 (patch) | |
tree | 6c0afe15659f8ba11b7aba48adef9b1165022229 /src | |
parent | c2859ef3eb3b9ab2747d74c7a5d0235f8622d23e (diff) |
issue #1: twm random window placement handles large windows poorly
report/patch by Preston Crow for improved window placement
(reindented to fit with current sources)
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/add_window.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/add_window.c b/src/add_window.c index 154a369..f919b77 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -402,10 +402,21 @@ AddWindow(Window w, int iconm, IconMgr *iconp) */ if (HandlingEvents && ask_user && !restoredFromPrevSession) { if (Scr->RandomPlacement) { /* just stick it somewhere */ - if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth) - PlaceX = 50; - if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight) - PlaceY = 50; + /* Avoid putting the new window off-screen */ + if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth) { + PlaceX = Scr->MyDisplayWidth - tmp_win->attr.width; + if (PlaceX < 0) + PlaceX = 0; + if (PlaceX > 50) + PlaceX = 50; + } + if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight) { + PlaceY = Scr->MyDisplayHeight - tmp_win->attr.height; + if (PlaceY < 0) + PlaceY = 0; + if (PlaceY > 50) + PlaceY = 50; + } tmp_win->attr.x = PlaceX; tmp_win->attr.y = PlaceY; @@ -1521,10 +1532,11 @@ FetchWmColormapWindows(TwmWindow *tmp) if (j == tmp->cmaps.number_cwins) { if (XFindContext(dpy, cmap_windows[i], ColormapContext, (XPointer *) &cwins[i]) == XCNOENT) { - if ((cwins[i] = CreateColormapWindow(cmap_windows[i], - (Bool) tmp->cmaps. - number_cwins == 0, - True)) == NULL) { + if ((cwins[i] = + CreateColormapWindow(cmap_windows[i], + (tmp->cmaps.number_cwins == 0 + ? True + : False), True)) == NULL) { int k; for (k = i + 1; k < number_cmap_windows; k++) |