Add option to center new windows when desk is full (suggested by George L. Yermulnik).

SVN revision: 33987
This commit is contained in:
Kim Woelders 2008-03-11 22:03:57 +00:00
parent 82e0debd38
commit 6215bcb329
4 changed files with 38 additions and 14 deletions

View File

@ -344,13 +344,14 @@ typedef struct
{
char manual;
char manual_mouse_pointer;
char center_if_desk_full;
char ignore_struts;
char raise_fullscreen;
char slidein;
char cleanupslide;
int slidemode;
int slidespeedmap;
int slidespeedcleanup;
char ignore_struts;
char raise_fullscreen;
#ifdef HAVE_XINERAMA
char extra_head; /* Not used */
#endif

View File

@ -39,7 +39,7 @@ typedef struct
typedef struct
{
int x, y;
int p;
int p, q;
} RectInfo;
static int
@ -173,7 +173,7 @@ ArrangeFindSpace(const int *xarray, int xsize, const int *yarray, int ysize,
int wx, int wy, int ww, int wh)
{
int i, j, w, h, fw, fh, z1, z2;
int cost;
int cost, desk;
int num_spaces = *ns;
if (wx < xarray[0] || (wx != xarray[0] && wx + ww > xarray[xsize - 1]))
@ -181,7 +181,7 @@ ArrangeFindSpace(const int *xarray, int xsize, const int *yarray, int ysize,
if (wy < yarray[0] || (wy != yarray[0] && wy + wh > yarray[ysize - 1]))
return;
cost = 0;
cost = desk = 0;
fh = wh;
#if DEBUG_ARRANGE > 1
Eprintf("Check-A %d,%d %dx%d\n", wx, wy, ww, wh);
@ -208,7 +208,10 @@ ArrangeFindSpace(const int *xarray, int xsize, const int *yarray, int ysize,
#if DEBUG_ARRANGE > 1
Eprintf("Add [%d,%d] %3dx%3d: %2d\n", i, j, w, h, Filled(i, j));
#endif
cost += w * h * Filled(i, j);
if (Filled(i, j) == 0)
desk += w * h;
else
cost += w * h * Filled(i, j);
fw -= w;
if (fw <= 0)
break;
@ -219,11 +222,13 @@ ArrangeFindSpace(const int *xarray, int xsize, const int *yarray, int ysize,
}
#if DEBUG_ARRANGE
Eprintf("Check %4d,%4d %3dx%3d cost=%d\n", wx, wy, ww, wh, cost);
Eprintf("Check %4d,%4d %3dx%3d cost=%d desk=%d\n", wx, wy, ww, wh,
cost, desk);
#endif
spaces[num_spaces].x = wx;
spaces[num_spaces].y = wy;
spaces[num_spaces].p = cost;
spaces[num_spaces].q = desk;
num_spaces++;
*ns = num_spaces;
}
@ -393,17 +398,26 @@ ArrangeRects(const RectBox * fixed, int fixed_count, RectBox * floating,
/* find the first space that fits */
k = 0;
sort = 0x7fffffff; /* NB! Break at 0 == free space */
for (j = 0; j < num_spaces && sort; j++)
for (j = 0; j < num_spaces; j++)
{
if (spaces[j].p >= sort)
a1 = spaces[j].p - spaces[j].q * 4;
if (a1 >= sort)
continue;
sort = spaces[j].p;
sort = a1;
k = j;
if (sort == 0)
break;
}
sorted[num_sorted].x = spaces[k].x;
sorted[num_sorted].y = spaces[k].y;
if (spaces[k].q == 0 && Conf.place.center_if_desk_full)
{
sorted[num_sorted].x = (tx1 + tx2 - floating[i].w) / 2;
sorted[num_sorted].y = (ty1 + ty2 - floating[i].h) / 2;
}
else
{
sorted[num_sorted].x = spaces[k].x;
sorted[num_sorted].y = spaces[k].y;
}
sorted[num_sorted].data = floating[i].data;
sorted[num_sorted].w = floating[i].w;
sorted[num_sorted].h = floating[i].h;

View File

@ -167,13 +167,14 @@ static const CfgItem MiscCfgItems[] = {
CFG_ITEM_BOOL(Conf, place.manual, 0),
CFG_ITEM_BOOL(Conf, place.manual_mouse_pointer, 0),
CFG_ITEM_BOOL(Conf, place.center_if_desk_full, 0),
CFG_ITEM_BOOL(Conf, place.ignore_struts, 0),
CFG_ITEM_BOOL(Conf, place.raise_fullscreen, 0),
CFG_ITEM_BOOL(Conf, place.slidein, 0),
CFG_ITEM_BOOL(Conf, place.cleanupslide, 1),
CFG_ITEM_INT(Conf, place.slidemode, 0),
CFG_ITEM_INT(Conf, place.slidespeedmap, 6000),
CFG_ITEM_INT(Conf, place.slidespeedcleanup, 8000),
CFG_ITEM_BOOL(Conf, place.ignore_struts, 0),
CFG_ITEM_BOOL(Conf, place.raise_fullscreen, 0),
CFG_ITEM_BOOL(Conf, session.enable_script, 0),
CFG_ITEM_STR(Conf, session.script),

View File

@ -223,6 +223,7 @@ static char tmp_with_leader;
static char tmp_switch_popup;
static char tmp_manual_placement;
static char tmp_manual_placement_mouse_pointer;
static char tmp_center_if_desk_full;
static char tmp_map_slide;
static char tmp_cleanup_slide;
static int tmp_slide_mode;
@ -247,6 +248,7 @@ CB_ConfigurePlacement(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
Conf.place.manual = tmp_manual_placement;
Conf.place.manual_mouse_pointer = tmp_manual_placement_mouse_pointer;
Conf.place.center_if_desk_full = tmp_center_if_desk_full;
Conf.place.slidein = tmp_map_slide;
Conf.place.cleanupslide = tmp_cleanup_slide;
@ -277,6 +279,7 @@ _DlgFillPlacement(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
tmp_manual_placement = Conf.place.manual;
tmp_manual_placement_mouse_pointer = Conf.place.manual_mouse_pointer;
tmp_center_if_desk_full = Conf.place.center_if_desk_full;
tmp_map_slide = Conf.place.slidein;
tmp_cleanup_slide = Conf.place.cleanupslide;
@ -319,6 +322,11 @@ _DlgFillPlacement(Dialog * d __UNUSED__, DItem * table, void *data __UNUSED__)
DialogItemSetText(di, _("Place windows under mouse"));
DialogItemCheckButtonSetPtr(di, &tmp_manual_placement_mouse_pointer);
di = DialogAddItem(table, DITEM_CHECKBUTTON);
DialogItemSetColSpan(di, 2);
DialogItemSetText(di, _("Center windows when desk is full"));
DialogItemCheckButtonSetPtr(di, &tmp_center_if_desk_full);
di = DialogAddItem(table, DITEM_CHECKBUTTON);
DialogItemSetColSpan(di, 2);
DialogItemSetText(di, _("Slide windows in when they appear"));