commit a950bc6
Michael Forney
·
2014-02-12 07:49:01 +0000 UTC
parent 75c98dc
window: Add parent and PARENT_CHANGED event
3 files changed,
+23,
-1
+11,
-1
1@@ -75,7 +75,15 @@ enum
2 /**
3 * Sent when the window's size has changed.
4 */
5- SWC_WINDOW_RESIZED
6+ SWC_WINDOW_RESIZED,
7+
8+ /**
9+ * Sent when the window's parent changes.
10+ *
11+ * This can occur when the window becomes a transient for another window,
12+ * or becomes a toplevel window.
13+ */
14+ SWC_WINDOW_PARENT_CHANGED
15 };
16
17 struct swc_window
18@@ -90,6 +98,8 @@ struct swc_window
19 SWC_WINDOW_STATE_WITHDRAWN,
20 SWC_WINDOW_STATE_TOPLEVEL
21 } state;
22+
23+ struct swc_window * parent;
24 };
25
26 /**
+10,
-0
1@@ -120,6 +120,7 @@ bool window_initialize(struct window * window, const struct window_impl * impl,
2 window->base.title = NULL;
3 window->base.class = NULL;
4 window->base.state = SWC_WINDOW_STATE_WITHDRAWN;
5+ window->base.parent = NULL;
6 wl_signal_init(&window->base.event_signal);
7 window->surface = surface;
8 window->impl = impl;
9@@ -163,3 +164,12 @@ void window_set_state(struct window * window, uint32_t state)
10 swc_send_event(&window->base.event_signal, SWC_WINDOW_STATE_CHANGED, NULL);
11 }
12
13+void window_set_parent(struct window * window, struct window * parent)
14+{
15+ if (window->base.parent == &parent->base)
16+ return;
17+
18+ window->base.parent = &parent->base;
19+ swc_send_event(&window->base.event_signal, SWC_WINDOW_PARENT_CHANGED, NULL);
20+}
21+
+2,
-0
1@@ -58,5 +58,7 @@ void window_set_class(struct window * window, const char * class);
2
3 void window_set_state(struct window * window, uint32_t state);
4
5+void window_set_parent(struct window * window, struct window * parent);
6+
7 #endif
8