feat(policy): 调整窗口大小时遵循窗口的 max/min size hints
This commit is contained in:
@@ -517,6 +517,7 @@ static void route_pointer_motion(
|
|||||||
command_buffer_t *out
|
command_buffer_t *out
|
||||||
) {
|
) {
|
||||||
auto interaction = ctx->interaction;
|
auto interaction = ctx->interaction;
|
||||||
|
auto window_id = interaction->window;
|
||||||
|
|
||||||
switch (interaction->mode) {
|
switch (interaction->mode) {
|
||||||
case ZDWM_WINDOW_INTERACTION_NONE:
|
case ZDWM_WINDOW_INTERACTION_NONE:
|
||||||
@@ -538,14 +539,23 @@ static void route_pointer_motion(
|
|||||||
command_buffer_push(out, &configure);
|
command_buffer_push(out, &configure);
|
||||||
} break;
|
} break;
|
||||||
case ZDWM_WINDOW_INTERACTION_RESIZE: {
|
case ZDWM_WINDOW_INTERACTION_RESIZE: {
|
||||||
|
auto window = state_window_get(ctx->state, window_id);
|
||||||
|
|
||||||
auto rect = interaction->origin_rect;
|
auto rect = interaction->origin_rect;
|
||||||
auto start = interaction->start_coordinate;
|
auto start = interaction->start_coordinate;
|
||||||
auto end = data->root;
|
auto end = data->root;
|
||||||
|
|
||||||
|
auto min_size = window->min_size;
|
||||||
|
auto max_size = window->max_size;
|
||||||
|
|
||||||
auto width = rect.width + (end.x - start.x);
|
auto width = rect.width + (end.x - start.x);
|
||||||
auto height = rect.height + (end.y - start.y);
|
auto height = rect.height + (end.y - start.y);
|
||||||
width = MAX(width, 10);
|
width = MAX(width, min_size.width);
|
||||||
height = MAX(height, 10);
|
height = MAX(height, min_size.height);
|
||||||
|
width = MIN(width, max_size.width);
|
||||||
|
height = MIN(height, max_size.height);
|
||||||
|
|
||||||
|
if (!window_need_resize(window, width, height)) break;
|
||||||
|
|
||||||
command_t configure_cmd = {
|
command_t configure_cmd = {
|
||||||
.type = ZDWM_COMMAND_CONFIGURE_WINDOW,
|
.type = ZDWM_COMMAND_CONFIGURE_WINDOW,
|
||||||
|
|||||||
Reference in New Issue
Block a user