commit dbead1d

Michael Forney  ·  2014-02-18 23:39:23 +0000 UTC
parent 5ef6e78
window: Implement interactive moving
2 files changed,  +12, -1
+11, -1
 1@@ -130,7 +130,13 @@ static inline void window_begin_interaction
 2 void window_begin_interactive_move(struct window * window,
 3                                    struct button_press * button)
 4 {
 5+    struct swc_rectangle * geometry = &window->view->geometry;
 6+    int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
 7+            py = wl_fixed_to_int(swc.seat->pointer->y);
 8+
 9     window_begin_interaction(window, &window->move.interaction, button);
10+    window->move.offset.x = geometry->x - px;
11+    window->move.offset.y = geometry->y - py;
12 }
13 
14 void window_begin_interactive_resize(struct window * window, uint32_t edges,
15@@ -181,7 +187,11 @@ void swc_window_end_resize(struct swc_window * base)
16 static bool move_motion(struct pointer_handler * handler, uint32_t time,
17                         wl_fixed_t fx, wl_fixed_t fy)
18 {
19-    /* TODO: Implement interactive moving */
20+    struct window * window
21+        = CONTAINER_OF(handler, typeof(*window), move.interaction.handler);
22+
23+    swc_view_move(window->view, wl_fixed_to_int(fx) + window->move.offset.x,
24+                                wl_fixed_to_int(fy) + window->move.offset.y);
25 
26     return true;
27 }
+1, -0
1@@ -46,6 +46,7 @@ struct window
2     struct
3     {
4         struct window_pointer_interaction interaction;
5+        struct { int32_t x, y; } offset;
6     } move;
7 
8     struct