diff options
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++) |