I've often been annoyed that randomly placed windows will be placed off-screen. I've specified DontMoveOff, so I think I've made my preference clear on this point.
The below patch will keep the old behavior if you have not specified DontMoveOff, or if the currently active random placement would put the window entirely in the current screen. If, on the other hand, the current random placement would place the window (partially) outside of the current screen, and DontMoveOff is specified, the placement will be re-calculated to put the window inside the screen, or if it's too big, aligned with the top of the screen. I've put up a page with all of my currently unapplied CTWM patches at http://www.cis.upenn.edu/~bjornk/ctwm/ /Björn Web: http://www.cis.upenn.edu/~bjornk/ -------------------------------------------------------------------------------- diff -rwc ctwm-3.6-orig/add_window.c ctwm-3.6/add_window.c *** ctwm-3.6-orig/add_window.c 2001-12-11 10:38:52.000000000 -0500 --- ctwm-3.6/add_window.c 2003-02-09 18:54:46.000000000 -0500 *************** *** 610,619 **** ((Scr->RandomPlacement == RP_UNMAPPED) && ((tmp_win->wmhints && (tmp_win->wmhints->initial_state == IconicState) ) || (! OCCUPY (tmp_win, Scr->workSpaceMgr.activeWSPC))))) { /* just stick it somewhere */ ! if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth) ! PlaceX = 50; ! if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight) ! PlaceY = 50; tmp_win->attr.x = PlaceX; tmp_win->attr.y = PlaceY; --- 610,637 ---- ((Scr->RandomPlacement == RP_UNMAPPED) && ((tmp_win->wmhints && (tmp_win->wmhints->initial_state == IconicState) ) || (! OCCUPY (tmp_win, Scr->workSpaceMgr.activeWSPC))))) { /* just stick it somewhere */ ! if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth) { ! if (!Scr->DontMoveOff) { /* Honor the user's wishes */ ! PlaceX = 50; /* Anything goes... */ ! } else { ! int available = Scr->MyDisplayWidth - tmp_win->attr.width; /* Availab le room */ ! if (available <= 0) /* Larger than the screen */ ! PlaceX = 0; /* Just stick it at the top */ ! else ! PlaceX = rand() % available; /* Anywhere's good... */ ! } ! } ! if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight) { ! if (!Scr->DontMoveOff) { /* Honor the user's wishes */ ! PlaceY = 50; /* Anything goes... */ ! } else { ! int available = Scr->MyDisplayHeight - tmp_win->attr.height; /* Avail able room */ ! if (available <= 0) /* Larger than the screen */ ! PlaceY = 0; /* Just stick it at the top */ ! else ! PlaceY = rand() % available; /* Anywhere's good... */ ! } ! } tmp_win->attr.x = PlaceX; tmp_win->attr.y = PlaceY;