Debian Codegraph @

debian/patches/dynamic-outputs

raw
1 Submitted: https://gitlab.com/compiz/compiz-plugins-main/-/merge_requests/88
2
3 --- a/src/ezoom/ezoom.c
4 +++ b/src/ezoom/ezoom.c
5 @@ -224,6 +224,7 @@ typedef struct _ZoomScreen {
6 PreparePaintScreenProc preparePaintScreen;
7 DonePaintScreenProc donePaintScreen;
8 PaintOutputProc paintOutput;
9 + OutputChangeNotifyProc outputChangeNotify;
10 PositionPollingHandle pollMouseHandle;
11 PositionPollingHandle pollFocusHandle;
12 CompTimeoutHandle notificationTimeoutHandle;
13 @@ -445,6 +446,8 @@ isInMovement (CompScreen *s, int out)
14 {
15 const ZoomArea *za = outputZoomArea (s, out);
16
17 + if (! za)
18 + return FALSE;
19 if (za->currentZoom == 1.0f &&
20 za->newZoom == 1.0f &&
21 za->zVelocity == 0.0f)
22 @@ -764,7 +767,7 @@ setCenter (CompScreen *s, int x, int y,
23 ZoomArea *za = outputZoomArea (s, out);
24 ZOOM_SCREEN (s);
25
26 - if (za->locked)
27 + if (! za || za->locked)
28 return;
29
30 za->xTranslate = (float)
31 @@ -810,7 +813,7 @@ setZoomArea (CompScreen *s,
32 ZoomArea *za = outputZoomArea (s, out);
33 ZOOM_SCREEN (s);
34
35 - if (za->newZoom == 1.0f)
36 + if (! za || za->newZoom == 1.0f)
37 return;
38
39 if (za->locked)
40 @@ -907,7 +910,7 @@ setScale (CompScreen *s, int out, float
41 ZoomArea *za = outputZoomArea (s, out);
42 ZOOM_SCREEN(s);
43
44 - if (za->locked)
45 + if (! za || za->locked)
46 return;
47
48 if (value >= 1.0f)
49 @@ -1082,7 +1085,7 @@ ensureVisibility (CompScreen *s, int x,
50 o = outputDev (s, out);
51 convertToZoomedTarget (s, out, x, y, &zoomX, &zoomY);
52 ZoomArea *za = outputZoomArea (s, out);
53 - if (za->locked)
54 + if (! za || za->locked)
55 return FALSE;
56
57 #define FACTOR (za->newZoom / (1.0f - za->newZoom))
58 @@ -1134,6 +1137,8 @@ ensureVisibilityArea (CompScreen *s,
59 out = outputDeviceForPoint (s, x1 + (x2-x1/2), y1 + (y2-y1/2));
60 o = outputDev (s, out);
61 za = outputZoomArea (s, out);
62 + if (! za)
63 + return;
64
65 #define WIDTHOK (float)(x2-x1) / (float)o->width < za->newZoom
66 #define HEIGHTOK (float)(y2-y1) / (float)o->height < za->newZoom
67 @@ -1244,6 +1249,9 @@ restrainCursor (CompScreen *s, int out)
68 ZOOM_SCREEN (s);
69 ZOOM_DISPLAY (s->display);
70
71 + if (! za)
72 + return;
73 +
74 z = za->newZoom;
75 margin = zs->opt[SOPT_RESTRAIN_MARGIN].value.i;
76 north = distanceToEdge (s, out, NORTH);
77 @@ -1965,13 +1973,16 @@ zoomIn (CompDisplay *d,
78 const ZoomArea *za = outputZoomArea (s, out);
79 ZOOM_SCREEN (s);
80
81 - if (zs->opt[SOPT_SYNC_MOUSE].value.b && !isInMovement (s, out)
82 - && (!zs->nonMouseFocusTracking
83 - || za->currentZoom == 1.0f))
84 - setCenter (s, pointerX, pointerY, TRUE);
85 + if (za)
86 + {
87 + if (zs->opt[SOPT_SYNC_MOUSE].value.b && !isInMovement (s, out)
88 + && (!zs->nonMouseFocusTracking
89 + || za->currentZoom == 1.0f))
90 + setCenter (s, pointerX, pointerY, TRUE);
91
92 - setScale (s, out,
93 - za->newZoom / zs->opt[SOPT_ZOOM_FACTOR].value.f);
94 + setScale (s, out,
95 + za->newZoom / zs->opt[SOPT_ZOOM_FACTOR].value.f);
96 + }
97 }
98 return TRUE;
99 }
100 @@ -1995,7 +2006,9 @@ lockZoomAction (CompDisplay *d,
101 {
102 int out = outputDeviceForPoint (s, pointerX, pointerY);
103 ZoomArea *za = outputZoomArea (s, out);
104 - za->locked = !za->locked;
105 +
106 + if (za)
107 + za->locked = !za->locked;
108 }
109 return TRUE;
110 }
111 @@ -2026,9 +2039,12 @@ zoomSpecific (CompDisplay *d,
112 int x, y;
113 int out = outputDeviceForPoint (s, pointerX, pointerY);
114 CompWindow *w;
115 + const ZoomArea *za = outputZoomArea (s, out);
116 ZOOM_DISPLAY (d);
117
118 - if (target == 1.0f && outputZoomArea (s, out)->newZoom == 1.0f)
119 + if (! za)
120 + return FALSE;
121 + if (target == 1.0f && za->newZoom == 1.0f)
122 return FALSE;
123 if (otherScreenGrabExist (s, NULL))
124 return FALSE;
125 @@ -2220,6 +2236,9 @@ zoomCenterMouse (CompDisplay *d,
126 out = outputDeviceForPoint (s, pointerX, pointerY);
127 o = outputDev (s, out);
128 za = outputZoomArea (s, out);
129 + if (! za)
130 + return TRUE;
131 +
132 warpPointer (s,
133 (int) (o->width/2 +
134 o->region.extents.x1 - pointerX)
135 @@ -2262,6 +2281,9 @@ zoomFitWindowToZoom (CompDisplay *d,
136 out = outputDeviceForWindow (w);
137 o = outputDev (s, out);
138 za = outputZoomArea (s, out);
139 + if (! za)
140 + return TRUE;
141 +
142 xwc.x = w->serverX;
143 xwc.y = w->serverY;
144 xwc.width = (int) (o->width * za->currentZoom -
145 @@ -2303,11 +2325,11 @@ zoomOut (CompDisplay *d,
146 if (s)
147 {
148 int out = outputDeviceForPoint (s, pointerX, pointerY);
149 + const ZoomArea *za = outputZoomArea (s, out);
150 ZOOM_SCREEN (s);
151
152 - setScale (s, out,
153 - outputZoomArea (s, out)->newZoom *
154 - zs->opt[SOPT_ZOOM_FACTOR].value.f);
155 + if (za)
156 + setScale (s, out, za->newZoom * zs->opt[SOPT_ZOOM_FACTOR].value.f);
157 }
158
159 return TRUE;
160 @@ -2420,6 +2442,47 @@ zoomHandleEvent (CompDisplay *d,
161 WRAP (zd, d, handleEvent, zoomHandleEvent);
162 }
163
164 +static Bool
165 +updateZoomAreas (CompScreen *s)
166 +{
167 + int i;
168 + ZoomArea *zooms;
169 + ZOOM_SCREEN (s);
170 +
171 + if (zs->nZooms == s->nOutputDev)
172 + return TRUE;
173 +
174 + zooms = realloc (zs->zooms, sizeof (ZoomArea) * s->nOutputDev);
175 + if (! zooms)
176 + return s->nOutputDev == 0;
177 +
178 + zs->zooms = zooms;
179 +
180 + for (i = zs->nZooms; i < s->nOutputDev; i++)
181 + {
182 + /* zs->grabbed is a mask ... Thus this limit */
183 + if (i > sizeof (long int) * 8)
184 + break;
185 + initialiseZoomArea (&zs->zooms[i], i);
186 + }
187 + zs->nZooms = s->nOutputDev;
188 +
189 + return TRUE;
190 +}
191 +
192 +static void
193 +zoomOutputChangeNotify (CompScreen *s)
194 +{
195 + ZOOM_SCREEN (s);
196 +
197 + /* if there are new outputs, allocate & initialize zoom areas for them */
198 + updateZoomAreas (s);
199 +
200 + UNWRAP (zs, s, outputChangeNotify);
201 + (*s->outputChangeNotify) (s);
202 + WRAP (zs, s, outputChangeNotify, zoomOutputChangeNotify);
203 +}
204 +
205 /* Settings etc., boring stuff */
206 static const CompMetadataOptionInfo zoomDisplayOptionInfo[] = {
207 { "zoom_in_button", "button", 0, zoomIn, 0 },
208 @@ -2629,7 +2692,6 @@ static Bool
209 zoomInitScreen (CompPlugin *p,
210 CompScreen *s)
211 {
212 - int i;
213 ZoomScreen *zs;
214 ZOOM_DISPLAY (s->display);
215
216 @@ -2648,15 +2710,8 @@ zoomInitScreen (CompPlugin *p,
217 }
218
219 zs->grabIndex = 0;
220 - zs->nZooms = s->nOutputDev;
221 - zs->zooms = malloc (sizeof (ZoomArea) * zs->nZooms);
222 - for (i = 0; i < zs->nZooms; i ++ )
223 - {
224 - /* zs->grabbed is a mask ... Thus this limit */
225 - if (i > sizeof (long int) * 8)
226 - break;
227 - initialiseZoomArea (&zs->zooms[i], i);
228 - }
229 + zs->nZooms = 0;
230 + zs->zooms = NULL;
231 zs->lastMouseChange = 0;
232 zs->lastFocusChange = 0;
233 zs->lastNotificationChange = 0;
234 @@ -2676,8 +2731,12 @@ zoomInitScreen (CompPlugin *p,
235 WRAP (zs, s, preparePaintScreen, zoomPreparePaintScreen);
236 WRAP (zs, s, donePaintScreen, zoomDonePaintScreen);
237 WRAP (zs, s, paintOutput, zoomPaintOutput);
238 + WRAP (zs, s, outputChangeNotify, zoomOutputChangeNotify);
239
240 s->base.privates[zd->screenPrivateIndex].ptr = zs;
241 +
242 + updateZoomAreas (s);
243 +
244 return TRUE;
245 }
246
247 @@ -2691,6 +2750,7 @@ zoomFiniScreen (CompPlugin *p,
248 UNWRAP (zs, s, preparePaintScreen);
249 UNWRAP (zs, s, donePaintScreen);
250 UNWRAP (zs, s, paintOutput);
251 + UNWRAP (zs, s, outputChangeNotify);
252 if (zs->pollMouseHandle)
253 (*zd->mpFunc->removePositionPolling) (s, zs->pollMouseHandle);
254 if (zs->pollFocusHandle)