192 |
layer->absolute_x = layer->absolute_y = -1; |
layer->absolute_x = layer->absolute_y = -1; |
193 |
} |
} |
194 |
|
|
|
|
|
195 |
/* Checks if we have to recalculate the absolute coordinates for |
/* Checks if we have to recalculate the absolute coordinates for |
196 |
LAYER. We return true if we have to. */ |
LAYER. We return true if we have to. */ |
197 |
static __inline__ bool |
static __inline__ bool |
212 |
} |
} |
213 |
|
|
214 |
|
|
215 |
|
/* Used by mouse functions to find the current focused surface. |
216 |
|
Returns the surface with the highest level that contain (X, Y). */ |
217 |
|
struct surface * |
218 |
|
locate_surface_at_point (int x, int y) |
219 |
|
{ |
220 |
|
struct surface *surface; |
221 |
|
struct layer *layer; |
222 |
|
|
223 |
|
pthread_mutex_lock (&all_layers_lock); |
224 |
|
|
225 |
|
layer = (struct layer *) queue_first (&all_layers); |
226 |
|
for (; !queue_end (&all_layers, (struct queue_entry *)layer); |
227 |
|
layer = (struct layer *) queue_next (&layer->ri.generic_link)) |
228 |
|
{ |
229 |
|
if (queue_empty (&layer->surfaces) || layer->map_count |
230 |
|
|| layer->flag_focus == false) |
231 |
|
continue; |
232 |
|
|
233 |
|
/* If LAYER is not every near to our point, we continue to the |
234 |
|
next one. */ |
235 |
|
if (x >= (layer->absolute_x + layer->width) |
236 |
|
|| y >= (layer->absolute_y + layer->height) |
237 |
|
|| x < layer->absolute_x |
238 |
|
|| y < layer->absolute_y) |
239 |
|
continue; |
240 |
|
|
241 |
|
if (need_recalc_absolute (layer)) |
242 |
|
recalc_absolute (layer, false); |
243 |
|
|
244 |
|
/* At this point we have a layer (that contains any number |
245 |
|
of surfaces) that overlaps our area. */ |
246 |
|
queue_iterate (&layer->surfaces, surface, struct surface *, layer_link) |
247 |
|
{ |
248 |
|
if (surface->map_count || surface->opaque == 0.0) |
249 |
|
continue; |
250 |
|
|
251 |
|
if (x >= (layer->absolute_x + surface->x) |
252 |
|
&& y >= (layer->absolute_y + surface->y) |
253 |
|
&& x < (layer->absolute_x + surface->x + surface->width) |
254 |
|
&& y < (layer->absolute_y + surface->y + surface->height)) |
255 |
|
{ |
256 |
|
pthread_mutex_unlock (&all_layers_lock); |
257 |
|
return surface; |
258 |
|
} |
259 |
|
} |
260 |
|
} |
261 |
|
pthread_mutex_unlock (&all_layers_lock); |
262 |
|
return 0; |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
/* This function tries to fetch all surfaces that has to be redrawn |
/* This function tries to fetch all surfaces that has to be redrawn |
267 |
when updating area (X, Y, WIDTH, HEIGHT). CLEAR_P is if we area |
when updating area (X, Y, WIDTH, HEIGHT). CLEAR_P is if we area |
268 |
clearing an area, or exposing it. SUD is a array of update regions |
clearing an area, or exposing it. SUD is a array of update regions |