summaryrefslogtreecommitdiff
path: root/0001-Don-t-increase-leave-pendingMaps-at-a-non-zero-numbe.patch
blob: 5d3b13525142cf8e0092a69f498bbe5946e307dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
From b235dc3c42c56fb4737a884672ab178eaede4154 Mon Sep 17 00:00:00 2001
From: Sam Spilsbury <smspillaz@gmail.com>
Date: Sat, 6 Nov 2010 14:27:50 +0800
Subject: [PATCH] Don't increase leave pendingMaps at a non-zero number once the window is mapped.

We used to assume that for every MapRequest event that we got for which we also sent an XMapWindow that we would get a MapNotify.

According to the man XMapWindow this doesn't make any sense since trying calling XMapWindow on an already mapped window for which we have SubstructureRedirectMask set results in a NoOp anyways (so we'll only ever get one MapNotify and multiple MapRequests).

This fixes a case where no input focus would be set on closing windows with multiple remaining pendingMaps since we don't move the input focus if this is the case
---
 src/event.cpp  |   10 +++++-----
 src/window.cpp |   40 +++++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/event.cpp b/src/event.cpp
index 15768d1..c779efb 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -764,7 +764,7 @@ PrivateScreen::handleActionEvent (XEvent *event)
 
 		o[6].setName ("time", CompOption::TypeInt);
 		o[6].value ().set ((int) event->xcrossing.time);
-		
+
 		o.resize (7);
 
 		foreach (CompPlugin *p, CompPlugin::getPlugins ())
@@ -801,7 +801,7 @@ PrivateScreen::handleActionEvent (XEvent *event)
 
 		o[6].setName ("time", CompOption::TypeInt);
 		o[6].value ().set ((int) event->xcrossing.time);
-		
+
 		o.resize (7);
 
 		if (triggerEdgeEnter (edge, state, o))
@@ -849,7 +849,7 @@ PrivateScreen::handleActionEvent (XEvent *event)
 		o[3].value ().set ((int) 0); /* fixme */
 		o[4].value ().set ((int) 0); /* fixme */
 		o[5].value ().set ((int) root);
-		
+
 		o.resize (6);
 
 		foreach (CompPlugin *p, CompPlugin::getPlugins ())
@@ -895,7 +895,7 @@ PrivateScreen::handleActionEvent (XEvent *event)
 		o[3].value ().set ((int) event->xclient.data.l[2] >> 16);
 		o[4].value ().set ((int) event->xclient.data.l[2] & 0xffff);
 		o[5].value ().set ((int) root);
-		
+
 		o.resize (6);
 
 		if (triggerEdgeEnter (edge, state, o))
@@ -1734,7 +1734,7 @@ CompScreen::handleEvent (XEvent *event)
 	{
 	    w = findWindow (((XShapeEvent *) event)->window);
 	    if (w)
-	    {	      
+	    {
 		if (w->mapNum ())
 		    w->priv->updateRegion ();
 	    }
diff --git a/src/window.cpp b/src/window.cpp
index 6f58335..623192f 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -803,7 +803,7 @@ PrivateWindow::updateFrameWindow ()
     {
 	int	   x, y, width, height;
 	int	   bw = serverGeometry.border () * 2;
-	
+
 	x      = serverGeometry.x ();
 	y      = serverGeometry.y ();
 	width  = serverGeometry.width () + bw;
@@ -1279,7 +1279,9 @@ CompWindow::map ()
     if (!isViewable ())
     {
 	if (priv->pendingMaps > 0)
-	    priv->pendingMaps--;
+	{
+	    priv->pendingMaps = 0;
+	}
 
 	priv->mapNum = screen->priv->mapNum++;
 
@@ -2836,7 +2838,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
     bool placed = false;
 
     xwcm &= (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
-    
+
     if (xwcm & (CWX | CWY))
 	if (priv->sizeHints.flags & (USPosition | PPosition))
 	    placed = true;
@@ -2882,7 +2884,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
 
 	    min = screen->workArea ().y () + priv->input.top;
 	    max = screen->workArea ().bottom ();
-	    
+
 	    if (priv->state & CompWindowStateStickyMask &&
 	    	 (xwc->y < min || xwc->y > max))
 	    {
@@ -2893,7 +2895,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
 		min -= screen->vp ().y () * screen->height ();
 		max += (screen->vpSize ().height () - screen->vp ().y () - 1) *
 			screen->height ();
-			
+
 		if (xwc->y < min)
 		    xwc->y = min;
 		else if (xwc->y > max)
@@ -2907,7 +2909,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
 
 	    min = screen->workArea ().x () + priv->input.left;
 	    max = screen->workArea ().right ();
-	    
+
 	    if (priv->state & CompWindowStateStickyMask &&
 		(xwc->x < min || xwc->x > max))
 	    {
@@ -3106,7 +3108,7 @@ PrivateScreen::focusTopMostWindow ()
     for (; it != windows.rend (); it++)
     {
 	CompWindow *w = *it;
-    
+
 	if (w->type () & CompWindowTypeDockMask)
 	    continue;
 
@@ -3134,12 +3136,12 @@ CompWindow::lower ()
 {
     XWindowChanges xwc;
     int		   mask;
-    
+
     mask = priv->addWindowStackChanges (&xwc,
 	PrivateWindow::findLowestSiblingBelow (this));
     if (mask)
 	configureXWindow (mask, &xwc);
-    
+
     /* when lowering a window, focus the topmost window if
        the click-to-focus option is on */
     if ((screen->getOption ("click_to_focus")->value ().b ()))
@@ -3698,7 +3700,7 @@ void
 CompWindow::minimize ()
 {
     WRAPABLE_HND_FUNC (13, minimize);
-    
+
     if (!priv->managed)
 	return;
 
@@ -4902,7 +4904,7 @@ PrivateWindow::updateStartupId ()
     {
 	if (strcmp (startupId, oldId) == 0)
 	    newId = false;
-	
+
 	free (oldId);
     }
 
@@ -5439,7 +5441,7 @@ CompWindow::updateFrameRegion ()
 
 	x = priv->geometry.x () - priv->input.left;
 	y = priv->geometry.y () - priv->input.top;
-	
+
 	XShapeCombineRegion (screen->dpy (), priv->frame,
 			     ShapeBounding, -x, -y,
 			     priv->frameRegion.united (priv->region).handle (),
@@ -5492,7 +5494,7 @@ CompWindow::updateFrameRegion (CompRegion& region)
 
 bool
 PrivateWindow::reparent ()
-{  
+{
     XSetWindowAttributes attr;
     XWindowAttributes    wa;
     XWindowChanges       xwc;
@@ -5589,7 +5591,7 @@ PrivateWindow::reparent ()
 		  ExposureMask);
 
     XUngrabServer (dpy);
-    
+
     XMoveResizeWindow (dpy, frame, sg.x (), sg.y (), sg.width (), sg.height ());
 
     /* Try to use a relative window as a stacking anchor point */
@@ -5608,7 +5610,7 @@ PrivateWindow::reparent ()
 
 void
 PrivateWindow::unreparent ()
-{  
+{
     Display        *dpy = screen->dpy ();
     XEvent         e;
     bool           alive = true;
@@ -5634,13 +5636,13 @@ PrivateWindow::unreparent ()
 	XSelectInput (dpy, id, NoEventMask);
 	XSelectInput (dpy, screen->root (), NoEventMask);
         XReparentWindow (dpy, id, screen->root (), 0, 0);
-	
+
 	xwc.stack_mode = Below;
 	xwc.sibling    = frame;
 	XConfigureWindow (dpy, id, CWSibling | CWStackMode, &xwc);
 
         XUnmapWindow (dpy, frame);
-	
+
 	XSelectInput (dpy, id, PropertyChangeMask | EnterWindowMask |
 		      FocusChangeMask);
 
@@ -5657,9 +5659,9 @@ PrivateWindow::unreparent ()
 		  ButtonReleaseMask        |
 		  FocusChangeMask          |
 		  ExposureMask);
-	
+
 	XUngrabServer (dpy);
-	
+
 	XMoveWindow (dpy, id, serverGeometry.x (), serverGeometry.y ());
     }
 
-- 
1.7.1