static void ReadProps(Client* c);
static void Redraw(Client* c);
static void LayerWindows(void);
+static int MonitorOverlap(Monitor* mon, Client* c);
void* ecalloc(size_t n, size_t sz)
{
return c;
}
-static int MonitorOverlap(Monitor* mon, Client* c)
-{
- /* calculate client boundaries */
- int cleft = (c->x - BORDER_WIDTH);
- int cright = (c->x + c->w + 2*BORDER_WIDTH);
- int ctop = (c->y - BORDER_WIDTH);
- int cbot = (c->y + c->h + 2*BORDER_WIDTH + TITLE_HEIGHT);
-
- /* calculate monitor boundaries */
- int left = max(cleft, mon->x);
- int right = min(cright, mon->x + mon->w);
- int top = max(ctop, mon->y);
- int bot = min(cbot, mon->y + mon->h);
-
-
- /* return the overlapped area */
- int area = 0;
- if (left < right && top < bot)
- {
- area = (right - left) * (bot - top);
- }
- return area;
-}
void Client_Place(Client* c)
{
- (void)c;
- /* calculate client boundaries */
- int cleft = (c->x - BORDER_WIDTH);
- int cright = (c->x + c->w + 2*BORDER_WIDTH);
- int ctop = (c->y - BORDER_WIDTH);
- int cbot = (c->y + c->h + 2*BORDER_WIDTH + TITLE_HEIGHT);
-
/* now find the most appropriate monitor to own it */
int maxarea = 0;
int monitor = 0;
for (int i = 0; i < Num_Monitors; i++)
{
Monitor* mon = &Monitors[i];
- int left = max(cleft, mon->x);
- int right = min(cright, mon->x + mon->w);
- int top = max(ctop, mon->y);
- int bot = min(cbot, mon->y + mon->h);
- if (left < right && top < bot)
+ int area = MonitorOverlap(mon, c);
+ if (area > maxarea)
{
- int area = (right - left) * (bot - top);
- if (area > maxarea)
- {
- maxarea = area;
- monitor = i;
- }
+ maxarea = area;
+ monitor = i;
}
}
}
+static int MonitorOverlap(Monitor* mon, Client* c)
+{
+ /* calculate client boundaries */
+ int cleft = (c->x - BORDER_WIDTH);
+ int cright = (c->x + c->w + 2*BORDER_WIDTH);
+ int ctop = (c->y - BORDER_WIDTH);
+ int cbot = (c->y + c->h + 2*BORDER_WIDTH + TITLE_HEIGHT);
+
+ /* calculate monitor boundaries */
+ int left = max(cleft, mon->x);
+ int right = min(cright, mon->x + mon->w);
+ int top = max(ctop, mon->y);
+ int bot = min(cbot, mon->y + mon->h);
+
+
+ /* return the overlapped area */
+ int area = 0;
+ if (left < right && top < bot)
+ {
+ area = (right - left) * (bot - top);
+ }
+ return area;
+}