commit a42aa95

Michael Forney  ·  2014-08-16 22:20:36 +0000 UTC
parent 443386e
window: Reorganize interaction functions
1 files changed,  +38, -39
+38, -39
 1@@ -58,6 +58,20 @@ struct wl_listener window_enter_listener = {
 2     .notify = &handle_window_enter
 3 };
 4 
 5+static void begin_interaction(struct window_pointer_interaction * interaction,
 6+                              struct button * button)
 7+{
 8+    if (button)
 9+    {
10+        interaction->original_handler = button->handler;
11+        button->handler = &interaction->handler;
12+    }
13+    else
14+        interaction->original_handler = NULL;
15+
16+    wl_list_insert(&swc.seat->pointer->handlers, &interaction->handler.link);
17+}
18+
19 EXPORT
20 void swc_window_set_handler(struct swc_window * base,
21                             const struct swc_window_handler * handler,
22@@ -185,45 +199,6 @@ void swc_window_set_border(struct swc_window * window,
23     compositor_view_set_border_width(view, border_width);
24 }
25 
26-static inline void window_begin_interaction
27-    (struct window * window, struct window_pointer_interaction * interaction,
28-     struct button * button)
29-{
30-    if (button)
31-    {
32-        interaction->original_handler = button->handler;
33-        button->handler = &interaction->handler;
34-    }
35-    else
36-        interaction->original_handler = NULL;
37-
38-    wl_list_insert(&swc.seat->pointer->handlers, &interaction->handler.link);
39-}
40-
41-void window_begin_move(struct window * window, struct button * button)
42-{
43-    struct swc_rectangle * geometry = &window->view->base.geometry;
44-    int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
45-            py = wl_fixed_to_int(swc.seat->pointer->y);
46-
47-    window_begin_interaction(window, &window->move.interaction, button);
48-    window->move.offset.x = geometry->x - px;
49-    window->move.offset.y = geometry->y - py;
50-}
51-
52-void window_begin_resize(struct window * window, uint32_t edges,
53-                         struct button * button)
54-{
55-    window_begin_interaction(window, &window->resize.interaction, button);
56-
57-    if (!edges)
58-    {
59-        /* TODO: Calculate edges to use */
60-    }
61-
62-    window->resize.edges = edges;
63-}
64-
65 EXPORT
66 void swc_window_begin_move(struct swc_window * base)
67 {
68@@ -385,3 +360,27 @@ void window_set_parent(struct window * window, struct window * parent)
69         window->handler->parent_changed(window->handler_data);
70 }
71 
72+void window_begin_move(struct window * window, struct button * button)
73+{
74+    struct swc_rectangle * geometry = &window->view->base.geometry;
75+    int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
76+            py = wl_fixed_to_int(swc.seat->pointer->y);
77+
78+    begin_interaction(&window->move.interaction, button);
79+    window->move.offset.x = geometry->x - px;
80+    window->move.offset.y = geometry->y - py;
81+}
82+
83+void window_begin_resize(struct window * window, uint32_t edges,
84+                         struct button * button)
85+{
86+    begin_interaction(&window->resize.interaction, button);
87+
88+    if (!edges)
89+    {
90+        /* TODO: Calculate edges to use */
91+    }
92+
93+    window->resize.edges = edges;
94+}
95+