summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2017-03-24 22:15:37 -0700
committerVito Caputo <vcaputo@gnugeneration.com>2017-03-25 00:39:18 -0700
commite17db88db54aafd9298c6db48a48569840acd328 (patch)
tree2adc6f4cf91ed6ccfcee0abe5eef2dd4b6ecaa0d
parent4ef11bae3fa16cdf7551816d711c38fe063965a7 (diff)
xevent: use vwm_win_map() instead of XMapWindow()
In vwm_xevent_handle_map_request() XMapWindow was always directly being called. When we have a vwin, we really shouldn't be calling XMapWindow() since we can't detect the generated MapNotify like we can with vwm_win_map().
-rw-r--r--src/xevent.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/xevent.c b/src/xevent.c
index fcbb551..d082f9a 100644
--- a/src/xevent.c
+++ b/src/xevent.c
@@ -176,32 +176,40 @@ void vwm_xevent_handle_map_request(vwm_t *vwm, XMapRequestEvent *ev)
vwm_window_t *vwin = NULL;
int domap = 1;
- if ((xwin = vwm_xwin_lookup(vwm, ev->window)) && !(vwin = xwin->managed)) {
- /* Basically all managed windows become managed on the map request,
- * even previously managed ones are unmanaged on unmap, then remanaged
- * on subsequent map request. Exceptions are preexisting windows that
- * are already mapped at create time, those won't generate map requests
- * but are managed at create.
- */
- vwin = vwm_win_manage_xwin(vwm, xwin);
- VWM_TRACE("managed xwin \"%s\" at map request", xwin->name);
- }
-
- /* XXX: note that _normally_ both xwin and vwin should be non-NULL here, and
- * the care being taken WRT !xwin or !vwin is purely defensive to permit the
- * default of simply mapping windows on request when things are broken.
- */
-
+ xwin = vwm_xwin_lookup(vwm, ev->window);
if (xwin) {
xwin->mapped = 1;
+
+ if (!(vwin = xwin->managed)) {
+ /* Basically all managed windows become managed on the map request,
+ * even previously managed ones are unmanaged on unmap, then remanaged
+ * on subsequent map request. Exceptions are preexisting windows that
+ * are already mapped at create time, those won't generate map requests
+ * but are managed at create.
+ */
+ vwin = vwm_win_manage_xwin(vwm, xwin);
+ VWM_TRACE("managed xwin \"%s\" at map request", xwin->name);
+ }
+
+ /* XXX: note that _normally_ both xwin and vwin should be non-NULL here, and
+ * the care being taken WRT !xwin or !vwin is purely defensive to permit the
+ * default of simply mapping windows on request when things are broken.
+ */
+
domap = vwm_xwin_is_mapped(vwm, xwin);
}
if (domap) {
- XMapWindow(VWM_XDISPLAY(vwm), ev->window);
- if (vwin && vwin->desktop->focused_window == vwin) {
- XSync(VWM_XDISPLAY(vwm), False);
- XSetInputFocus(VWM_XDISPLAY(vwm), vwin->xwindow->id, RevertToPointerRoot, CurrentTime);
+ if (vwin) {
+ vwm_win_map(vwm, vwin);
+
+ /* XSetInputFocus() must to happen after XMapWindow(), so do it here. */
+ if (vwm_win_focused(vwm) == vwin)
+ XSetInputFocus(VWM_XDISPLAY(vwm), vwin->xwindow->id, RevertToPointerRoot, CurrentTime);
+ } else {
+ /* this is unexpected */
+ XMapWindow(VWM_XDISPLAY(vwm), ev->window);
+ VWM_BUG("handled map request of unmanaged window vwin=%p xwin=%p id=%u", vwin, xwin, ev->window);
}
}
}
© All Rights Reserved