Replace macros WIDTH and HEIGHT
This commit is contained in:
parent
36fa61060f
commit
a3deb9b029
70
src/dwm.c
70
src/dwm.c
|
@ -39,11 +39,6 @@
|
|||
#define LENGTH(X) (sizeof(X) / sizeof(X[0]))
|
||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||
|
||||
#define WIDTH(X) \
|
||||
((X)->state.geometry.basic.w + 2 * (X)->state.geometry.border_width)
|
||||
#define HEIGHT(X) \
|
||||
((X)->state.geometry.basic.h + 2 * (X)->state.geometry.border_width)
|
||||
|
||||
#define CLEANMASK(mask) ( \
|
||||
(mask) & \
|
||||
~(numlockmask | LockMask) & \
|
||||
|
@ -308,10 +303,10 @@ int applysizehints(
|
|||
|
||||
if (interact) {
|
||||
if (*x > sw) {
|
||||
*x = sw - WIDTH(c);
|
||||
*x = sw - client_geometry_total_width(&c->state.geometry);
|
||||
}
|
||||
if (*y > sh) {
|
||||
*y = sh - HEIGHT(c);
|
||||
*y = sh - client_geometry_total_height(&c->state.geometry);
|
||||
}
|
||||
if (*x + *w + 2 * bw < 0) {
|
||||
*x = 0;
|
||||
|
@ -326,7 +321,7 @@ int applysizehints(
|
|||
+
|
||||
m->window_area_geometry.w
|
||||
-
|
||||
WIDTH(c);
|
||||
client_geometry_total_width(&c->state.geometry);
|
||||
}
|
||||
if (*y >= m->window_area_geometry.y + m->window_area_geometry.h) {
|
||||
*y =
|
||||
|
@ -334,7 +329,7 @@ int applysizehints(
|
|||
+
|
||||
m->window_area_geometry.h
|
||||
-
|
||||
HEIGHT(c);
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
}
|
||||
if (*x + *w + 2 * bw <= m->window_area_geometry.x) {
|
||||
*x = m->window_area_geometry.x;
|
||||
|
@ -889,22 +884,37 @@ void manage(Window w, XWindowAttributes *wa)
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
const int total_width = client_geometry_total_width(&c->state.geometry);
|
||||
|
||||
if (
|
||||
c->state.geometry.basic.x + WIDTH(c)
|
||||
c->state.geometry.basic.x + total_width
|
||||
>
|
||||
c->mon->screen_geometry.x + c->mon->screen_geometry.w
|
||||
) {
|
||||
c->state.geometry.basic.x =
|
||||
c->mon->screen_geometry.x + c->mon->screen_geometry.w - WIDTH(c);
|
||||
c->mon->screen_geometry.x
|
||||
+
|
||||
c->mon->screen_geometry.w
|
||||
-
|
||||
total_width;
|
||||
}
|
||||
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
if (
|
||||
c->state.geometry.basic.y + HEIGHT(c)
|
||||
c->state.geometry.basic.y + total_height
|
||||
>
|
||||
c->mon->screen_geometry.y + c->mon->screen_geometry.h
|
||||
) {
|
||||
c->state.geometry.basic.y =
|
||||
c->mon->screen_geometry.y + c->mon->screen_geometry.h - HEIGHT(c);
|
||||
c->mon->screen_geometry.y
|
||||
+
|
||||
c->mon->screen_geometry.h
|
||||
-
|
||||
total_height;
|
||||
}
|
||||
}
|
||||
|
||||
c->state.geometry.basic.x =
|
||||
|
@ -927,10 +937,20 @@ void manage(Window w, XWindowAttributes *wa)
|
|||
updatesizehints(c);
|
||||
updatewmhints(c);
|
||||
|
||||
{
|
||||
const int total_width = client_geometry_total_width(&c->state.geometry);
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
c->state.geometry.basic.x =
|
||||
c->mon->screen_geometry.x + (c->mon->screen_geometry.w - WIDTH(c)) / 2;
|
||||
c->mon->screen_geometry.x
|
||||
+
|
||||
(c->mon->screen_geometry.w - total_width) / 2;
|
||||
c->state.geometry.basic.y =
|
||||
c->mon->screen_geometry.y + (c->mon->screen_geometry.h - HEIGHT(c)) / 2;
|
||||
c->mon->screen_geometry.y
|
||||
+
|
||||
(c->mon->screen_geometry.h - total_height) / 2;
|
||||
}
|
||||
|
||||
XSelectInput(
|
||||
dpy,
|
||||
|
@ -1044,12 +1064,17 @@ void movemouse(__attribute__((unused)) const Arg *arg)
|
|||
selmon->window_area_geometry.w
|
||||
)
|
||||
-
|
||||
(nx + WIDTH(c))
|
||||
(nx + client_geometry_total_width(&c->state.geometry))
|
||||
)
|
||||
<
|
||||
snap_distance
|
||||
) {
|
||||
nx = selmon->window_area_geometry.x + selmon->window_area_geometry.w - WIDTH(c);
|
||||
nx =
|
||||
selmon->window_area_geometry.x
|
||||
+
|
||||
selmon->window_area_geometry.w
|
||||
-
|
||||
client_geometry_total_width(&c->state.geometry);
|
||||
}
|
||||
|
||||
if (abs(selmon->window_area_geometry.y - ny) < snap_distance) {
|
||||
|
@ -1060,7 +1085,7 @@ void movemouse(__attribute__((unused)) const Arg *arg)
|
|||
selmon->window_area_geometry.y
|
||||
+
|
||||
selmon->window_area_geometry.h
|
||||
) - (ny + HEIGHT(c))
|
||||
) - (ny + client_geometry_total_height(&c->state.geometry))
|
||||
)
|
||||
<
|
||||
snap_distance
|
||||
|
@ -1070,7 +1095,7 @@ void movemouse(__attribute__((unused)) const Arg *arg)
|
|||
+
|
||||
selmon->window_area_geometry.h
|
||||
-
|
||||
HEIGHT(c);
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
}
|
||||
|
||||
if (!c->state.is_floating &&
|
||||
|
@ -1710,7 +1735,12 @@ void showhide(Client *c)
|
|||
} else {
|
||||
/* hide clients bottom up */
|
||||
showhide(c->snext);
|
||||
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->state.geometry.basic.y);
|
||||
XMoveWindow(
|
||||
dpy,
|
||||
c->win,
|
||||
client_geometry_total_width(&c->state.geometry) * -2,
|
||||
c->state.geometry.basic.y
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,11 @@ void on_configure_request(XEvent *e)
|
|||
c->state.geometry.basic.x =
|
||||
m->screen_geometry.x
|
||||
+
|
||||
(m->screen_geometry.w / 2 - WIDTH(c) / 2);
|
||||
(
|
||||
m->screen_geometry.w / 2
|
||||
-
|
||||
client_geometry_total_width(&c->state.geometry) / 2
|
||||
);
|
||||
}
|
||||
if (
|
||||
(c->state.geometry.basic.y + c->state.geometry.basic.h)
|
||||
|
@ -112,7 +116,11 @@ void on_configure_request(XEvent *e)
|
|||
c->state.geometry.basic.y =
|
||||
m->screen_geometry.y
|
||||
+
|
||||
(m->screen_geometry.h / 2 - HEIGHT(c) / 2);
|
||||
(
|
||||
m->screen_geometry.h / 2
|
||||
-
|
||||
client_geometry_total_height(&c->state.geometry) / 2
|
||||
);
|
||||
}
|
||||
if ((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) {
|
||||
configure(c);
|
||||
|
|
|
@ -57,7 +57,10 @@ void centeredmaster(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
my += HEIGHT(c) + top_gap + bottom_gap;
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
my += total_height + top_gap + bottom_gap;
|
||||
} else {
|
||||
// stack clients are stacked vertically
|
||||
if ((i - m->nmaster) % 2) {
|
||||
|
@ -79,7 +82,10 @@ void centeredmaster(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
ety += HEIGHT(c) + top_gap + bottom_gap;
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
ety += total_height + top_gap + bottom_gap;
|
||||
} else {
|
||||
const unsigned int h =
|
||||
(m->window_area_geometry.h - oty) / ((1 + n - i) / 2);
|
||||
|
@ -99,7 +105,10 @@ void centeredmaster(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
oty += HEIGHT(c) + top_gap + bottom_gap;
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
oty += total_height + top_gap + bottom_gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +178,12 @@ void horizontile(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
const int total_width =
|
||||
client_geometry_total_width(&c->state.geometry);
|
||||
|
||||
// FIXME: maybe need + left_gap + right_gap
|
||||
if (mx + WIDTH(c) < m->window_area_geometry.w) {
|
||||
mx += WIDTH(c) + left_gap + right_gap;
|
||||
if (mx + total_width < m->window_area_geometry.w) {
|
||||
mx += total_width + left_gap + right_gap;
|
||||
}
|
||||
} else {
|
||||
const unsigned int w = (m->window_area_geometry.w - tx) / (n - i);
|
||||
|
@ -191,9 +203,12 @@ void horizontile(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
const int total_width =
|
||||
client_geometry_total_width(&c->state.geometry);
|
||||
|
||||
// FIXME: maybe need + left_gap + right_gap
|
||||
if (tx + WIDTH(c) < m->window_area_geometry.w) {
|
||||
tx += WIDTH(c) + left_gap + right_gap;
|
||||
if (tx + total_width < m->window_area_geometry.w) {
|
||||
tx += total_width + left_gap + right_gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,9 +284,12 @@ void tile(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
// FIXME: maybe need + top_gap + bottom_gap
|
||||
if (my + HEIGHT(c) < m->window_area_geometry.h) {
|
||||
my += HEIGHT(c) + top_gap + bottom_gap;
|
||||
if (my + total_height < m->window_area_geometry.h) {
|
||||
my += total_height + top_gap + bottom_gap;
|
||||
}
|
||||
} else {
|
||||
const unsigned int h = (m->window_area_geometry.h - ty) / (n - i);
|
||||
|
@ -291,9 +309,12 @@ void tile(Monitor *m)
|
|||
0
|
||||
);
|
||||
|
||||
const int total_height =
|
||||
client_geometry_total_height(&c->state.geometry);
|
||||
|
||||
// FIXME: maybe need + top_gap + bottom_gap
|
||||
if (ty + HEIGHT(c) < m->window_area_geometry.h) {
|
||||
ty += HEIGHT(c) + top_gap + bottom_gap;
|
||||
if (ty + total_height < m->window_area_geometry.h) {
|
||||
ty += total_height + top_gap + bottom_gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
src/state.c
12
src/state.c
|
@ -41,6 +41,18 @@ void client_state_init(const ClientState client_state)
|
|||
client_state->is_fullscreen = false;
|
||||
}
|
||||
|
||||
int client_geometry_total_width(
|
||||
const struct ClientGeometry *const client_geometry
|
||||
) {
|
||||
return client_geometry->basic.w + 2 * client_geometry->border_width;
|
||||
}
|
||||
|
||||
int client_geometry_total_height(
|
||||
const struct ClientGeometry *const client_geometry
|
||||
) {
|
||||
return client_geometry->basic.h + 2 * client_geometry->border_width;
|
||||
}
|
||||
|
||||
void client_size_hints_update(
|
||||
const ClientSizeHints size_hints,
|
||||
const XSizeHints *const size
|
||||
|
|
|
@ -44,6 +44,9 @@ void client_geometry_init(ClientGeometry client_geometry);
|
|||
void client_size_hints_init(ClientSizeHints client_size_hints);
|
||||
void client_state_init(ClientState client_state);
|
||||
|
||||
int client_geometry_total_width(const struct ClientGeometry *client_geometry);
|
||||
int client_geometry_total_height(const struct ClientGeometry *client_geometry);
|
||||
|
||||
void client_size_hints_update(
|
||||
ClientSizeHints size_hints,
|
||||
const XSizeHints *size
|
||||
|
|
Loading…
Reference in New Issue