yutani: Apply rotation correctly in minimize animation
This commit is contained in:
parent
61f60f409d
commit
0e3d51a10a
@ -725,6 +725,30 @@ static inline int matrix_is_translation(gfx_matrix_t m) {
|
|||||||
return (m[0][0] == 1.0 && m[0][1] == 0.0 && m[1][0] == 0.0 && m[1][1] == 1.0);
|
return (m[0][0] == 1.0 && m[0][1] == 0.0 && m[1][0] == 0.0 && m[1][1] == 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void apply_rotation(yutani_globals_t * yg, yutani_server_window_t * window, gfx_matrix_t m) {
|
||||||
|
if (window == yg->resizing_window) {
|
||||||
|
if (window->rotation) {
|
||||||
|
gfx_matrix_translate(m, yg->resizing_init_w / 2, yg->resizing_init_h / 2);
|
||||||
|
gfx_matrix_rotate(m, (double)window->rotation * M_PI / 180.0);
|
||||||
|
gfx_matrix_translate(m, -yg->resizing_init_w / 2, -yg->resizing_init_h / 2);
|
||||||
|
}
|
||||||
|
double x_scale = (double)yg->resizing_w / (double)yg->resizing_window->width;
|
||||||
|
double y_scale = (double)yg->resizing_h / (double)yg->resizing_window->height;
|
||||||
|
if (x_scale < 0.00001) {
|
||||||
|
x_scale = 0.00001;
|
||||||
|
}
|
||||||
|
if (y_scale < 0.00001) {
|
||||||
|
y_scale = 0.00001;
|
||||||
|
}
|
||||||
|
gfx_matrix_translate(m, (int)yg->resizing_offset_x, (int)yg->resizing_offset_y);
|
||||||
|
gfx_matrix_scale(m, x_scale, y_scale);
|
||||||
|
} else if (window->rotation) {
|
||||||
|
gfx_matrix_translate(m, window->width / 2, window->height / 2);
|
||||||
|
gfx_matrix_rotate(m, (double)window->rotation * M_PI / 180.0);
|
||||||
|
gfx_matrix_translate(m, -window->width / 2, -window->height / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blit a window to the framebuffer.
|
* Blit a window to the framebuffer.
|
||||||
*
|
*
|
||||||
@ -753,29 +777,6 @@ static int yutani_blit_window(yutani_globals_t * yg, yutani_server_window_t * wi
|
|||||||
gfx_matrix_identity(m);
|
gfx_matrix_identity(m);
|
||||||
gfx_matrix_translate(m,x,y);
|
gfx_matrix_translate(m,x,y);
|
||||||
|
|
||||||
if (window == yg->resizing_window) {
|
|
||||||
if (window->rotation) {
|
|
||||||
gfx_matrix_translate(m, yg->resizing_init_w / 2, yg->resizing_init_h / 2);
|
|
||||||
gfx_matrix_rotate(m, (double)window->rotation * M_PI / 180.0);
|
|
||||||
gfx_matrix_translate(m, -yg->resizing_init_w / 2, -yg->resizing_init_h / 2);
|
|
||||||
}
|
|
||||||
double x_scale = (double)yg->resizing_w / (double)yg->resizing_window->width;
|
|
||||||
double y_scale = (double)yg->resizing_h / (double)yg->resizing_window->height;
|
|
||||||
if (x_scale < 0.00001) {
|
|
||||||
x_scale = 0.00001;
|
|
||||||
}
|
|
||||||
if (y_scale < 0.00001) {
|
|
||||||
y_scale = 0.00001;
|
|
||||||
}
|
|
||||||
gfx_matrix_translate(m, (int)yg->resizing_offset_x, (int)yg->resizing_offset_y);
|
|
||||||
gfx_matrix_scale(m, x_scale, y_scale);
|
|
||||||
} else if (window->rotation) {
|
|
||||||
gfx_matrix_translate(m, window->width / 2, window->height / 2);
|
|
||||||
gfx_matrix_rotate(m, (double)window->rotation * M_PI / 180.0);
|
|
||||||
gfx_matrix_translate(m, -window->width / 2, -window->height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (window->anim_mode) {
|
if (window->anim_mode) {
|
||||||
int frame = yutani_time_since(yg, window->anim_start);
|
int frame = yutani_time_since(yg, window->anim_start);
|
||||||
if (frame >= yutani_animation_lengths[window->anim_mode]) {
|
if (frame >= yutani_animation_lengths[window->anim_mode]) {
|
||||||
@ -790,6 +791,7 @@ static int yutani_blit_window(yutani_globals_t * yg, yutani_server_window_t * wi
|
|||||||
}
|
}
|
||||||
window->anim_mode = 0;
|
window->anim_mode = 0;
|
||||||
window->anim_start = 0;
|
window->anim_start = 0;
|
||||||
|
apply_rotation(yg, window, m);
|
||||||
} else {
|
} else {
|
||||||
switch (window->anim_mode) {
|
switch (window->anim_mode) {
|
||||||
case YUTANI_EFFECT_SQUEEZE_OUT:
|
case YUTANI_EFFECT_SQUEEZE_OUT:
|
||||||
@ -802,6 +804,8 @@ static int yutani_blit_window(yutani_globals_t * yg, yutani_server_window_t * wi
|
|||||||
{
|
{
|
||||||
double time_diff = ((double)frame / (float)yutani_animation_lengths[window->anim_mode]);
|
double time_diff = ((double)frame / (float)yutani_animation_lengths[window->anim_mode]);
|
||||||
|
|
||||||
|
apply_rotation(yg, window, m);
|
||||||
|
|
||||||
if (window->server_flags & YUTANI_WINDOW_FLAG_DIALOG_ANIMATION) {
|
if (window->server_flags & YUTANI_WINDOW_FLAG_DIALOG_ANIMATION) {
|
||||||
double x = time_diff;
|
double x = time_diff;
|
||||||
int t_y = (window->height * (1.0 -x)) / 2;
|
int t_y = (window->height * (1.0 -x)) / 2;
|
||||||
@ -833,12 +837,16 @@ static int yutani_blit_window(yutani_globals_t * yg, yutani_server_window_t * wi
|
|||||||
double s_y = 1.0 + (((float)window->icon_h / (float)(window->height ?: 1.0)) - 1.0) * (1.0 - time_diff);
|
double s_y = 1.0 + (((float)window->icon_h / (float)(window->height ?: 1.0)) - 1.0) * (1.0 - time_diff);
|
||||||
gfx_matrix_translate(m, t_x, t_y);
|
gfx_matrix_translate(m, t_x, t_y);
|
||||||
gfx_matrix_scale(m, s_x, s_y);
|
gfx_matrix_scale(m, s_x, s_y);
|
||||||
|
apply_rotation(yg, window, m);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
apply_rotation(yg, window, m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
apply_rotation(yg, window, m);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_BLUR_BEHIND
|
#ifdef ENABLE_BLUR_BEHIND
|
||||||
if (window->server_flags & YUTANI_WINDOW_FLAG_BLUR_BEHIND) {
|
if (window->server_flags & YUTANI_WINDOW_FLAG_BLUR_BEHIND) {
|
||||||
|
Loading…
Reference in New Issue
Block a user