swc

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

commit 0494b4c7edf84ebb8d392022989d64a9ad733dfb
parent debb5202cdfd643a31133f23c1c4945ff3656e57
Author: Michael Forney <mforney@mforney.org>
Date:   Tue,  3 Dec 2013 23:53:00 -0800

Handle NULL window in swc_window_focus

Diffstat:
Mlibswc/window.c | 18++++++++++++++++--
Mlibswc/xwm.c | 7++++---
2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/libswc/window.c b/libswc/window.c @@ -70,10 +70,24 @@ void swc_window_hide(struct swc_window * window) EXPORT void swc_window_focus(struct swc_window * window) { - if (INTERNAL(window)->impl->focus) + struct swc_surface * new_focus = window ? INTERNAL(window)->surface : NULL, + * old_focus = swc.seat->keyboard->focus.surface; + + /* If the keyboard already has a focused window, and we are changing the + * focus to either NULL, or a window with a different implementation, set + * the focus of the previous focus window's implementation to NULL. */ + if (old_focus && old_focus->window + && !(window && INTERNAL(window)->impl + == INTERNAL(old_focus->window)->impl) + && INTERNAL(old_focus->window)->impl->focus) + { + INTERNAL(old_focus->window)->impl->focus(NULL); + } + + if (window && INTERNAL(window)->impl->focus) INTERNAL(window)->impl->focus(window); - swc_keyboard_set_focus(swc.seat->keyboard, INTERNAL(window)->surface); + swc_keyboard_set_focus(swc.seat->keyboard, new_focus); } EXPORT diff --git a/libswc/xwm.c b/libswc/xwm.c @@ -281,11 +281,12 @@ static void configure(struct swc_window * window, static void focus(struct swc_window * window) { - struct xwl_window * xwl_window - = CONTAINER_OF(window, typeof(*xwl_window), window.base); + xcb_window_t id = window ? CONTAINER_OF(window, struct xwl_window, + window.base)->id + : XCB_NONE; xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, - xwl_window->id, XCB_CURRENT_TIME); + id, XCB_CURRENT_TIME); xcb_flush(xwm.connection); }