summaryrefslogtreecommitdiff
path: root/clients/resizor.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-12-16 21:11:10 -0500
committerKristian Høgsberg <krh@bitplanet.net>2010-12-16 21:11:10 -0500
commit53a7f2137b5aba32e97dbc3b964bdaf19a9099ef (patch)
tree46d4a689440f4c364cc5a8053c62ed446143cef2 /clients/resizor.c
parent5c4056e049ebb8735cd0be8c5a639a90a6dae8f6 (diff)
downloadweston-53a7f2137b5aba32e97dbc3b964bdaf19a9099ef.tar.gz
weston-53a7f2137b5aba32e97dbc3b964bdaf19a9099ef.tar.bz2
weston-53a7f2137b5aba32e97dbc3b964bdaf19a9099ef.zip
Fix the resizor
Diffstat (limited to 'clients/resizor.c')
-rw-r--r--clients/resizor.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/clients/resizor.c b/clients/resizor.c
index 687145a1..d5baf170 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -48,6 +48,37 @@ struct resizor {
};
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
resizor_draw(struct resizor *resizor)
{
cairo_surface_t *surface;
@@ -75,7 +106,7 @@ resizor_draw(struct resizor *resizor)
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),
frame_callback, resizor);
}
@@ -99,37 +130,6 @@ keyboard_focus_handler(struct window *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
key_handler(struct window *window, uint32_t key, uint32_t sym,
uint32_t state, uint32_t modifiers, void *data)
{
@@ -139,12 +139,12 @@ key_handler(struct window *window, uint32_t key, uint32_t sym,
return;
switch (sym) {
- case XK_F1:
+ case XK_Down:
resizor->height.target = 400;
resizor->height.current = resizor->child_allocation.height;
frame_callback(resizor, 0);
break;
- case XK_F2:
+ case XK_Up:
resizor->height.target = 200;
resizor->height.current = resizor->child_allocation.height;
frame_callback(resizor, 0);