From 3f168827c40352c07bf91e8a1d15fc6b49b094cf Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 23 Mar 2017 21:59:34 -0700 Subject: xwindow: cleanup vwm_xwin_is_mapped() No functional changes here. --- src/xwindow.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/xwindow.c b/src/xwindow.c index 57fa06d..4b52b3b 100644 --- a/src/xwindow.c +++ b/src/xwindow.c @@ -66,33 +66,27 @@ vwm_xwindow_t * vwm_xwin_lookup(vwm_t *vwm, Window win) /* determine if a window is mapped (vwm-mapped) according to the current context */ int vwm_xwin_is_mapped(vwm_t *vwm, vwm_xwindow_t *xwin) { - int ret = 0; + vwm_window_t *vwin = xwin->managed; + int ret = 0; - if (!xwin->mapped) return 0; + if (!xwin->mapped || !vwin) + return xwin->mapped; - if (xwin->managed) { - switch (vwm->focused_context) { - case VWM_CONTEXT_SHELF: - if (vwm->focused_shelf == xwin->managed) - ret = xwin->mapped; - break; + switch (vwm->focused_context) { + case VWM_CONTEXT_SHELF: + if (vwm->focused_shelf == vwin) + ret = 1; + break; - case VWM_CONTEXT_DESKTOP: - if (vwm->focused_desktop == xwin->managed->desktop && !xwin->managed->shelved) - ret = xwin->mapped; - break; + case VWM_CONTEXT_DESKTOP: + if (vwm->focused_desktop == vwin->desktop && !vwin->shelved) + ret = 1; + break; - default: - VWM_BUG("Unsupported context"); - break; - } - } else { /* unmanaged xwins like popup dialogs when mapped are always visible */ - ret = 1; + default: + VWM_BUG("Unsupported context"); } - /* annoyingly, Xorg stops delivering VisibilityNotify events for redirected windows, so we don't conveniently know if a window is obscured or not :( */ - /* I could maintain my own data structure for answering this question, but that's pretty annoying when Xorg already has that knowledge. */ - return ret; } -- cgit v1.2.3