swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit a950bc6999605bb21402778507cb8da6bc43c7ad
parent 75c98dc871905eb09c9ad0a4dcaea78bc1f46966
Author: Michael Forney <mforney@mforney.org>
Date:   Tue, 11 Feb 2014 23:49:01 -0800

window: Add parent and PARENT_CHANGED event

Diffstat:
Mlibswc/swc.h | 12+++++++++++-
Mlibswc/window.c | 10++++++++++
Mlibswc/window.h | 2++
3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/libswc/swc.h b/libswc/swc.h @@ -75,7 +75,15 @@ enum /** * Sent when the window's size has changed. */ - SWC_WINDOW_RESIZED + SWC_WINDOW_RESIZED, + + /** + * Sent when the window's parent changes. + * + * This can occur when the window becomes a transient for another window, + * or becomes a toplevel window. + */ + SWC_WINDOW_PARENT_CHANGED }; struct swc_window @@ -90,6 +98,8 @@ struct swc_window SWC_WINDOW_STATE_WITHDRAWN, SWC_WINDOW_STATE_TOPLEVEL } state; + + struct swc_window * parent; }; /** diff --git a/libswc/window.c b/libswc/window.c @@ -120,6 +120,7 @@ bool window_initialize(struct window * window, const struct window_impl * impl, window->base.title = NULL; window->base.class = NULL; window->base.state = SWC_WINDOW_STATE_WITHDRAWN; + window->base.parent = NULL; wl_signal_init(&window->base.event_signal); window->surface = surface; window->impl = impl; @@ -163,3 +164,12 @@ void window_set_state(struct window * window, uint32_t state) swc_send_event(&window->base.event_signal, SWC_WINDOW_STATE_CHANGED, NULL); } +void window_set_parent(struct window * window, struct window * parent) +{ + if (window->base.parent == &parent->base) + return; + + window->base.parent = &parent->base; + swc_send_event(&window->base.event_signal, SWC_WINDOW_PARENT_CHANGED, NULL); +} + diff --git a/libswc/window.h b/libswc/window.h @@ -58,5 +58,7 @@ void window_set_class(struct window * window, const char * class); void window_set_state(struct window * window, uint32_t state); +void window_set_parent(struct window * window, struct window * parent); + #endif