|
|
@ -47,6 +47,37 @@ struct resizor { |
|
|
|
} height; |
|
|
|
} height; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
frame_callback(void *data, uint32_t time) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct resizor *resizor = data; |
|
|
|
|
|
|
|
double force, height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
height = resizor->height.current; |
|
|
|
|
|
|
|
force = (resizor->height.target - height) / 10.0 + |
|
|
|
|
|
|
|
(resizor->height.previous - height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resizor->height.current = |
|
|
|
|
|
|
|
height + (height - resizor->height.previous) + force; |
|
|
|
|
|
|
|
resizor->height.previous = height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizor->height.current >= 400) { |
|
|
|
|
|
|
|
resizor->height.current = 400; |
|
|
|
|
|
|
|
resizor->height.previous = 400; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizor->height.current <= 200) { |
|
|
|
|
|
|
|
resizor->height.current = 200; |
|
|
|
|
|
|
|
resizor->height.previous = 200; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resizor->child_allocation.height = height + 0.5; |
|
|
|
|
|
|
|
window_set_child_size(resizor->window, |
|
|
|
|
|
|
|
&resizor->child_allocation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window_schedule_redraw(resizor->window); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
resizor_draw(struct resizor *resizor) |
|
|
|
resizor_draw(struct resizor *resizor) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -75,7 +106,7 @@ resizor_draw(struct resizor *resizor) |
|
|
|
|
|
|
|
|
|
|
|
window_flush(resizor->window); |
|
|
|
window_flush(resizor->window); |
|
|
|
|
|
|
|
|
|
|
|
if (fabs(resizor->height.previous - resizor->height.target) < 0.1) { |
|
|
|
if (fabs(resizor->height.previous - resizor->height.target) > 0.1) { |
|
|
|
wl_display_frame_callback(display_get_display(resizor->display), |
|
|
|
wl_display_frame_callback(display_get_display(resizor->display), |
|
|
|
frame_callback, resizor); |
|
|
|
frame_callback, resizor); |
|
|
|
} |
|
|
|
} |
|
|
@ -98,37 +129,6 @@ keyboard_focus_handler(struct window *window, |
|
|
|
window_schedule_redraw(resizor->window); |
|
|
|
window_schedule_redraw(resizor->window); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
frame_callback(void *data, uint32_t time) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct resizor *resizor = data; |
|
|
|
|
|
|
|
double force, height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
height = resizor->height.current; |
|
|
|
|
|
|
|
force = (resizor->height.target - height) / 10.0 + |
|
|
|
|
|
|
|
(resizor->height.previous - height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resizor->height.current = |
|
|
|
|
|
|
|
height + (height - resizor->height.previous) + force; |
|
|
|
|
|
|
|
resizor->height.previous = height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizor->height.current >= 400) { |
|
|
|
|
|
|
|
resizor->height.current = 400; |
|
|
|
|
|
|
|
resizor->height.previous = 400; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizor->height.current <= 200) { |
|
|
|
|
|
|
|
resizor->height.current = 200; |
|
|
|
|
|
|
|
resizor->height.previous = 200; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resizor->child_allocation.height = height + 0.5; |
|
|
|
|
|
|
|
window_set_child_size(resizor->window, |
|
|
|
|
|
|
|
&resizor->child_allocation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window_schedule_redraw(resizor->window); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
key_handler(struct window *window, uint32_t key, uint32_t sym, |
|
|
|
key_handler(struct window *window, uint32_t key, uint32_t sym, |
|
|
|
uint32_t state, uint32_t modifiers, void *data) |
|
|
|
uint32_t state, uint32_t modifiers, void *data) |
|
|
@ -139,12 +139,12 @@ key_handler(struct window *window, uint32_t key, uint32_t sym, |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
switch (sym) { |
|
|
|
switch (sym) { |
|
|
|
case XK_F1: |
|
|
|
case XK_Down: |
|
|
|
resizor->height.target = 400; |
|
|
|
resizor->height.target = 400; |
|
|
|
resizor->height.current = resizor->child_allocation.height; |
|
|
|
resizor->height.current = resizor->child_allocation.height; |
|
|
|
frame_callback(resizor, 0); |
|
|
|
frame_callback(resizor, 0); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case XK_F2: |
|
|
|
case XK_Up: |
|
|
|
resizor->height.target = 200; |
|
|
|
resizor->height.target = 200; |
|
|
|
resizor->height.current = resizor->child_allocation.height; |
|
|
|
resizor->height.current = resizor->child_allocation.height; |
|
|
|
frame_callback(resizor, 0); |
|
|
|
frame_callback(resizor, 0); |
|
|
|