Add function "client_geometry_adjust_to_boundary"
This commit is contained in:
parent
bb17fab590
commit
86f72bc0d5
43
src/dwm.c
43
src/dwm.c
|
@ -915,46 +915,9 @@ void manage(Window w, XWindowAttributes *wa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
client_geometry_adjust_to_boundary(
|
||||||
const int total_width = client_geometry_total_width(&c->state.geometry);
|
&c->state.geometry,
|
||||||
|
&c->mon->screen_geometry
|
||||||
if (
|
|
||||||
c->state.geometry.basic.position.x + total_width
|
|
||||||
>
|
|
||||||
c->mon->screen_geometry.position.x + c->mon->screen_geometry.sizes.w
|
|
||||||
) {
|
|
||||||
c->state.geometry.basic.position.x =
|
|
||||||
c->mon->screen_geometry.position.x
|
|
||||||
+
|
|
||||||
c->mon->screen_geometry.sizes.w
|
|
||||||
-
|
|
||||||
total_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int total_height =
|
|
||||||
client_geometry_total_height(&c->state.geometry);
|
|
||||||
|
|
||||||
if (
|
|
||||||
c->state.geometry.basic.position.y + total_height
|
|
||||||
>
|
|
||||||
c->mon->screen_geometry.position.y + c->mon->screen_geometry.sizes.h
|
|
||||||
) {
|
|
||||||
c->state.geometry.basic.position.y =
|
|
||||||
c->mon->screen_geometry.position.y
|
|
||||||
+
|
|
||||||
c->mon->screen_geometry.sizes.h
|
|
||||||
-
|
|
||||||
total_height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c->state.geometry.basic.position.x = MAX(
|
|
||||||
c->state.geometry.basic.position.x,
|
|
||||||
c->mon->screen_geometry.position.x
|
|
||||||
);
|
|
||||||
c->state.geometry.basic.position.y = MAX(
|
|
||||||
c->state.geometry.basic.position.y,
|
|
||||||
c->mon->screen_geometry.position.y
|
|
||||||
);
|
);
|
||||||
|
|
||||||
c->state.geometry.border_width = settings_get_border_width();
|
c->state.geometry.border_width = settings_get_border_width();
|
||||||
|
|
42
src/state.c
42
src/state.c
|
@ -63,6 +63,48 @@ int client_geometry_total_height(
|
||||||
return client_geometry->basic.sizes.h + 2 * client_geometry->border_width;
|
return client_geometry->basic.sizes.h + 2 * client_geometry->border_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_geometry_adjust_to_boundary(
|
||||||
|
const ClientGeometry client_geometry,
|
||||||
|
const struct BasicGeometry *const boundary_geometry
|
||||||
|
) {
|
||||||
|
const int total_width = client_geometry_total_width(client_geometry);
|
||||||
|
const int total_height = client_geometry_total_height(client_geometry);
|
||||||
|
|
||||||
|
if (
|
||||||
|
client_geometry->basic.position.x + total_width
|
||||||
|
>
|
||||||
|
boundary_geometry->position.x + boundary_geometry->sizes.w
|
||||||
|
) {
|
||||||
|
client_geometry->basic.position.x =
|
||||||
|
boundary_geometry->position.x
|
||||||
|
+
|
||||||
|
boundary_geometry->sizes.w
|
||||||
|
-
|
||||||
|
total_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
client_geometry->basic.position.y + total_height
|
||||||
|
>
|
||||||
|
boundary_geometry->position.y + boundary_geometry->sizes.h
|
||||||
|
) {
|
||||||
|
client_geometry->basic.position.y =
|
||||||
|
boundary_geometry->position.y
|
||||||
|
+
|
||||||
|
boundary_geometry->sizes.h
|
||||||
|
-
|
||||||
|
total_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client_geometry->basic.position.x < boundary_geometry->position.x) {
|
||||||
|
client_geometry->basic.position.x = boundary_geometry->position.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client_geometry->basic.position.y < boundary_geometry->position.y) {
|
||||||
|
client_geometry->basic.position.y = boundary_geometry->position.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void client_size_hints_update(
|
void client_size_hints_update(
|
||||||
const ClientSizeHints size_hints,
|
const ClientSizeHints size_hints,
|
||||||
const XSizeHints *const size
|
const XSizeHints *const size
|
||||||
|
|
|
@ -62,6 +62,11 @@ void client_state_init(ClientState client_state);
|
||||||
int client_geometry_total_width(const struct ClientGeometry *client_geometry);
|
int client_geometry_total_width(const struct ClientGeometry *client_geometry);
|
||||||
int client_geometry_total_height(const struct ClientGeometry *client_geometry);
|
int client_geometry_total_height(const struct ClientGeometry *client_geometry);
|
||||||
|
|
||||||
|
void client_geometry_adjust_to_boundary(
|
||||||
|
ClientGeometry client_geometry,
|
||||||
|
const struct BasicGeometry *boundary_geometry
|
||||||
|
);
|
||||||
|
|
||||||
void client_size_hints_update(
|
void client_size_hints_update(
|
||||||
ClientSizeHints size_hints,
|
ClientSizeHints size_hints,
|
||||||
const XSizeHints *size
|
const XSizeHints *size
|
||||||
|
|
Loading…
Reference in New Issue