swc

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

commit 533d15f0207be6debc2f14c7bbe6c50c8ba2ceef
parent b9f6dd5120b4b7d80e1d51f0598f39a3dfc7555b
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 30 Jun 2013 22:12:21 -0700

Add focus change signal

Diffstat:
Minput_focus.c | 13+++++++++++++
Minput_focus.h | 12++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/input_focus.c b/input_focus.c @@ -24,6 +24,7 @@ #include "input_focus.h" #include "surface.h" #include "util.h" +#include "event.h" static inline void focus(struct swc_input_focus * input_focus, struct swc_surface * surface, @@ -55,6 +56,7 @@ bool swc_input_focus_initialize(struct swc_input_focus * input_focus, input_focus->handler = handler; wl_list_init(&input_focus->resources); + wl_signal_init(&input_focus->event_signal); return true; } @@ -102,10 +104,17 @@ void swc_input_focus_set(struct swc_input_focus * input_focus, struct wl_display * display; struct wl_resource * resource; uint32_t serial; + struct swc_input_focus_event_data data; + struct swc_event event; + + event.type = SWC_INPUT_FOCUS_EVENT_CHANGED; + event.data = &data; if (surface == input_focus->surface) return; + data.old = input_focus->surface; + /* Unfocus previously focused surface. */ unfocus(input_focus); @@ -123,6 +132,10 @@ void swc_input_focus_set(struct swc_input_focus * input_focus, input_focus->resource = NULL; } + data.new = input_focus->surface; + + wl_signal_emit(&input_focus->event_signal, &event); + return; } diff --git a/input_focus.h b/input_focus.h @@ -29,6 +29,16 @@ struct swc_surface; +enum swc_input_focus_event_type +{ + SWC_INPUT_FOCUS_EVENT_CHANGED +}; + +struct swc_input_focus_event_data +{ + struct swc_surface * old, * new; +}; + struct swc_input_focus_handler { void (* enter)(struct swc_input_focus_handler * handler, @@ -46,6 +56,8 @@ struct swc_input_focus struct swc_input_focus_handler * handler; struct wl_list resources; + + struct wl_signal event_signal; }; bool swc_input_focus_initialize(struct swc_input_focus * input_focus,