1 | /*
|
---|
2 | * Copyright (c) 2022 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup display
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /**
|
---|
33 | * @file Display server window
|
---|
34 | */
|
---|
35 |
|
---|
36 | #include <gfx/bitmap.h>
|
---|
37 | #include <gfx/color.h>
|
---|
38 | #include <gfx/coord.h>
|
---|
39 | #include <gfx/context.h>
|
---|
40 | #include <gfx/render.h>
|
---|
41 | #include <io/log.h>
|
---|
42 | #include <io/pixelmap.h>
|
---|
43 | #include <macros.h>
|
---|
44 | #include <memgfx/memgc.h>
|
---|
45 | #include <stdlib.h>
|
---|
46 | #include <str.h>
|
---|
47 | #include <wndmgt.h>
|
---|
48 | #include "client.h"
|
---|
49 | #include "display.h"
|
---|
50 | #include "seat.h"
|
---|
51 | #include "window.h"
|
---|
52 | #include "wmclient.h"
|
---|
53 |
|
---|
54 | static void ds_window_invalidate_cb(void *, gfx_rect_t *);
|
---|
55 | static void ds_window_update_cb(void *);
|
---|
56 | static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *);
|
---|
57 |
|
---|
58 | static mem_gc_cb_t ds_window_mem_gc_cb = {
|
---|
59 | .invalidate = ds_window_invalidate_cb,
|
---|
60 | .update = ds_window_update_cb
|
---|
61 | };
|
---|
62 |
|
---|
63 | /** Create window.
|
---|
64 | *
|
---|
65 | * Create graphics context for rendering into a window.
|
---|
66 | *
|
---|
67 | * @param client Client owning the window
|
---|
68 | * @param params Window parameters
|
---|
69 | * @param rgc Place to store pointer to new GC.
|
---|
70 | *
|
---|
71 | * @return EOK on success or an error code
|
---|
72 | */
|
---|
73 | errno_t ds_window_create(ds_client_t *client, display_wnd_params_t *params,
|
---|
74 | ds_window_t **rgc)
|
---|
75 | {
|
---|
76 | ds_window_t *wnd = NULL;
|
---|
77 | ds_seat_t *seat;
|
---|
78 | gfx_context_t *dgc;
|
---|
79 | gfx_coord2_t dims;
|
---|
80 | gfx_bitmap_params_t bparams;
|
---|
81 | gfx_bitmap_alloc_t alloc;
|
---|
82 | errno_t rc;
|
---|
83 |
|
---|
84 | wnd = calloc(1, sizeof(ds_window_t));
|
---|
85 | if (wnd == NULL) {
|
---|
86 | rc = ENOMEM;
|
---|
87 | goto error;
|
---|
88 | }
|
---|
89 |
|
---|
90 | wnd->caption = str_dup(params->caption);
|
---|
91 | if (wnd->caption == NULL) {
|
---|
92 | rc = ENOMEM;
|
---|
93 | goto error;
|
---|
94 | }
|
---|
95 |
|
---|
96 | ds_client_add_window(client, wnd);
|
---|
97 | ds_display_add_window(client->display, wnd);
|
---|
98 |
|
---|
99 | gfx_bitmap_params_init(&bparams);
|
---|
100 | bparams.rect = params->rect;
|
---|
101 |
|
---|
102 | dgc = ds_display_get_gc(wnd->display);
|
---|
103 | if (dgc != NULL) {
|
---|
104 | rc = gfx_bitmap_create(dgc, &bparams, NULL, &wnd->bitmap);
|
---|
105 | if (rc != EOK)
|
---|
106 | goto error;
|
---|
107 |
|
---|
108 | rc = gfx_bitmap_get_alloc(wnd->bitmap, &alloc);
|
---|
109 | if (rc != EOK)
|
---|
110 | goto error;
|
---|
111 |
|
---|
112 | gfx_rect_dims(¶ms->rect, &dims);
|
---|
113 | wnd->pixelmap.width = dims.x;
|
---|
114 | wnd->pixelmap.height = dims.y;
|
---|
115 | wnd->pixelmap.data = alloc.pixels;
|
---|
116 | } else {
|
---|
117 | /* This is just for unit tests */
|
---|
118 | gfx_rect_dims(¶ms->rect, &dims);
|
---|
119 | alloc.pitch = dims.x * sizeof(uint32_t);
|
---|
120 | alloc.off0 = 0;
|
---|
121 | alloc.pixels = calloc(1, alloc.pitch * dims.y);
|
---|
122 | }
|
---|
123 |
|
---|
124 | rc = mem_gc_create(¶ms->rect, &alloc, &ds_window_mem_gc_cb,
|
---|
125 | (void *)wnd, &wnd->mgc);
|
---|
126 | if (rc != EOK)
|
---|
127 | goto error;
|
---|
128 |
|
---|
129 | wnd->rect = params->rect;
|
---|
130 | wnd->min_size = params->min_size;
|
---|
131 | wnd->gc = mem_gc_get_ctx(wnd->mgc);
|
---|
132 | wnd->cursor = wnd->display->cursor[dcurs_arrow];
|
---|
133 | wnd->flags = params->flags;
|
---|
134 |
|
---|
135 | if ((params->flags & wndf_setpos) != 0) {
|
---|
136 | /* Specific window position */
|
---|
137 | wnd->dpos = params->pos;
|
---|
138 | } else {
|
---|
139 | /* Automatic window placement */
|
---|
140 | wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
|
---|
141 | wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
|
---|
142 | }
|
---|
143 |
|
---|
144 | // TODO Multi-seat: which seat should own the new window?
|
---|
145 | seat = ds_display_first_seat(client->display);
|
---|
146 |
|
---|
147 | if ((params->flags & wndf_popup) != 0)
|
---|
148 | ds_seat_set_popup(seat, wnd);
|
---|
149 | else
|
---|
150 | ds_seat_set_focus(seat, wnd);
|
---|
151 |
|
---|
152 | if ((params->flags & wndf_avoid) != 0)
|
---|
153 | ds_display_update_max_rect(wnd->display);
|
---|
154 |
|
---|
155 | (void) ds_display_paint(wnd->display, NULL);
|
---|
156 |
|
---|
157 | *rgc = wnd;
|
---|
158 | return EOK;
|
---|
159 | error:
|
---|
160 | if (wnd != NULL) {
|
---|
161 | ds_client_remove_window(wnd);
|
---|
162 | ds_display_remove_window(wnd);
|
---|
163 | if (wnd->mgc != NULL)
|
---|
164 | mem_gc_delete(wnd->mgc);
|
---|
165 | if (wnd->bitmap != NULL)
|
---|
166 | gfx_bitmap_destroy(wnd->bitmap);
|
---|
167 | if (wnd->caption != NULL)
|
---|
168 | free(wnd->caption);
|
---|
169 | free(wnd);
|
---|
170 | }
|
---|
171 |
|
---|
172 | return rc;
|
---|
173 | }
|
---|
174 |
|
---|
175 | /** Destroy window.
|
---|
176 | *
|
---|
177 | * @param wnd Window
|
---|
178 | */
|
---|
179 | void ds_window_destroy(ds_window_t *wnd)
|
---|
180 | {
|
---|
181 | ds_display_t *disp;
|
---|
182 |
|
---|
183 | disp = wnd->display;
|
---|
184 |
|
---|
185 | ds_client_remove_window(wnd);
|
---|
186 | ds_display_remove_window(wnd);
|
---|
187 |
|
---|
188 | if ((wnd->flags & wndf_avoid) != 0)
|
---|
189 | ds_display_update_max_rect(disp);
|
---|
190 |
|
---|
191 | mem_gc_delete(wnd->mgc);
|
---|
192 |
|
---|
193 | if (wnd->bitmap != NULL)
|
---|
194 | gfx_bitmap_destroy(wnd->bitmap);
|
---|
195 |
|
---|
196 | free(wnd->caption);
|
---|
197 | free(wnd);
|
---|
198 |
|
---|
199 | (void) ds_display_paint(disp, NULL);
|
---|
200 | }
|
---|
201 |
|
---|
202 | /** Bring window to top.
|
---|
203 | *
|
---|
204 | * @param wnd Window
|
---|
205 | */
|
---|
206 | void ds_window_bring_to_top(ds_window_t *wnd)
|
---|
207 | {
|
---|
208 | ds_display_window_to_top(wnd);
|
---|
209 | (void) ds_display_paint(wnd->display, NULL);
|
---|
210 | }
|
---|
211 |
|
---|
212 | /** Get generic graphic context from window.
|
---|
213 | *
|
---|
214 | * @param wnd Window
|
---|
215 | * @return Graphic context
|
---|
216 | */
|
---|
217 | gfx_context_t *ds_window_get_ctx(ds_window_t *wnd)
|
---|
218 | {
|
---|
219 | return wnd->gc;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /** Determine if window is visible.
|
---|
223 | *
|
---|
224 | * @param wnd Window
|
---|
225 | * @return @c true iff window is visible
|
---|
226 | */
|
---|
227 | bool ds_window_is_visible(ds_window_t *wnd)
|
---|
228 | {
|
---|
229 | return (wnd->flags & wndf_minimized) == 0;
|
---|
230 | }
|
---|
231 |
|
---|
232 | /** Paint a window using its backing bitmap.
|
---|
233 | *
|
---|
234 | * @param wnd Window to paint
|
---|
235 | * @param rect Display rectangle to paint to
|
---|
236 | * @return EOK on success or an error code
|
---|
237 | */
|
---|
238 | errno_t ds_window_paint(ds_window_t *wnd, gfx_rect_t *rect)
|
---|
239 | {
|
---|
240 | gfx_rect_t srect;
|
---|
241 | gfx_rect_t *brect;
|
---|
242 | gfx_rect_t crect;
|
---|
243 |
|
---|
244 | log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_paint");
|
---|
245 |
|
---|
246 | /* Skip painting the window if not visible */
|
---|
247 | if (!ds_window_is_visible(wnd))
|
---|
248 | return EOK;
|
---|
249 |
|
---|
250 | if (rect != NULL) {
|
---|
251 | gfx_rect_rtranslate(&wnd->dpos, rect, &srect);
|
---|
252 |
|
---|
253 | /* Determine if we have anything to do */
|
---|
254 | gfx_rect_clip(&srect, &wnd->rect, &crect);
|
---|
255 | if (gfx_rect_is_empty(&crect))
|
---|
256 | return EOK;
|
---|
257 |
|
---|
258 | brect = &srect;
|
---|
259 | } else {
|
---|
260 | brect = NULL;
|
---|
261 | }
|
---|
262 |
|
---|
263 | /* This can happen in unit tests */
|
---|
264 | if (wnd->bitmap == NULL)
|
---|
265 | return EOK;
|
---|
266 |
|
---|
267 | return gfx_bitmap_render(wnd->bitmap, brect, &wnd->dpos);
|
---|
268 | }
|
---|
269 |
|
---|
270 | /** Get the preview rectangle for a window.
|
---|
271 | *
|
---|
272 | * Get the preview rectangle if the window is being resized or moved.
|
---|
273 | * If the window is not being resized or moved, return an empty rectangle.
|
---|
274 | *
|
---|
275 | * @param wnd Window
|
---|
276 | * @param rect Place to store preview rectangle
|
---|
277 | */
|
---|
278 | static void ds_window_get_preview_rect(ds_window_t *wnd, gfx_rect_t *rect)
|
---|
279 | {
|
---|
280 | switch (wnd->state) {
|
---|
281 | case dsw_idle:
|
---|
282 | break;
|
---|
283 | case dsw_moving:
|
---|
284 | gfx_rect_translate(&wnd->preview_pos, &wnd->rect, rect);
|
---|
285 | return;
|
---|
286 | case dsw_resizing:
|
---|
287 | gfx_rect_translate(&wnd->dpos, &wnd->preview_rect, rect);
|
---|
288 | return;
|
---|
289 | }
|
---|
290 |
|
---|
291 | rect->p0.x = 0;
|
---|
292 | rect->p0.y = 0;
|
---|
293 | rect->p1.x = 0;
|
---|
294 | rect->p1.y = 0;
|
---|
295 | }
|
---|
296 |
|
---|
297 | /** Paint window preview if the window is being moved or resized.
|
---|
298 | *
|
---|
299 | * If the window is not being resized or moved, take no action and return
|
---|
300 | * success.
|
---|
301 | *
|
---|
302 | * @param wnd Window for which to paint preview
|
---|
303 | * @param rect Clipping rectangle
|
---|
304 | * @return EOK on success or an error code
|
---|
305 | */
|
---|
306 | errno_t ds_window_paint_preview(ds_window_t *wnd, gfx_rect_t *rect)
|
---|
307 | {
|
---|
308 | errno_t rc;
|
---|
309 | gfx_color_t *color;
|
---|
310 | gfx_rect_t prect;
|
---|
311 | gfx_rect_t dr;
|
---|
312 | gfx_rect_t pr;
|
---|
313 | gfx_context_t *gc;
|
---|
314 |
|
---|
315 | /*
|
---|
316 | * Get preview rectangle. If the window is not being resized/moved,
|
---|
317 | * we should get an empty rectangle.
|
---|
318 | */
|
---|
319 | ds_window_get_preview_rect(wnd, &prect);
|
---|
320 | if (gfx_rect_is_empty(&prect)) {
|
---|
321 | /* There is nothing to paint */
|
---|
322 | return EOK;
|
---|
323 | }
|
---|
324 |
|
---|
325 | rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
|
---|
326 | if (rc != EOK)
|
---|
327 | return rc;
|
---|
328 |
|
---|
329 | gc = ds_display_get_gc(wnd->display);
|
---|
330 | if (gc != NULL) {
|
---|
331 | gfx_set_color(gc, color);
|
---|
332 |
|
---|
333 | /*
|
---|
334 | * TODO: Ideally we'd want XOR operation to make the preview
|
---|
335 | * frame visible on any background. If we wanted to get really
|
---|
336 | * fancy, we'd fill it with a pattern
|
---|
337 | */
|
---|
338 |
|
---|
339 | pr.p0.x = prect.p0.x;
|
---|
340 | pr.p0.y = prect.p0.y;
|
---|
341 | pr.p1.x = prect.p1.x;
|
---|
342 | pr.p1.y = prect.p0.y + 1;
|
---|
343 | gfx_rect_clip(&pr, rect, &dr);
|
---|
344 | gfx_fill_rect(gc, &dr);
|
---|
345 |
|
---|
346 | pr.p0.x = prect.p0.x;
|
---|
347 | pr.p0.y = prect.p1.y - 1;
|
---|
348 | pr.p1.x = prect.p1.x;
|
---|
349 | pr.p1.y = prect.p1.y;
|
---|
350 | gfx_rect_clip(&pr, rect, &dr);
|
---|
351 | gfx_fill_rect(gc, &dr);
|
---|
352 |
|
---|
353 | pr.p0.x = prect.p0.x;
|
---|
354 | pr.p0.y = prect.p0.y;
|
---|
355 | pr.p1.x = prect.p0.x + 1;
|
---|
356 | pr.p1.y = prect.p1.y;
|
---|
357 | gfx_rect_clip(&pr, rect, &dr);
|
---|
358 | gfx_fill_rect(gc, &dr);
|
---|
359 |
|
---|
360 | pr.p0.x = prect.p1.x - 1;
|
---|
361 | pr.p0.y = prect.p0.y;
|
---|
362 | pr.p1.x = prect.p1.x;
|
---|
363 | pr.p1.y = prect.p1.y;
|
---|
364 | gfx_rect_clip(&pr, rect, &dr);
|
---|
365 | gfx_fill_rect(gc, &dr);
|
---|
366 |
|
---|
367 | }
|
---|
368 |
|
---|
369 | gfx_color_delete(color);
|
---|
370 | return EOK;
|
---|
371 | }
|
---|
372 |
|
---|
373 | /** Repaint window preview when resizing or moving.
|
---|
374 | *
|
---|
375 | * Repaint the window preview wich was previously at rectangle @a old_rect.
|
---|
376 | * The current preview rectangle is determined from window state. If
|
---|
377 | * the window did not previously have a preview, @a old_rect should point
|
---|
378 | * to an empty rectangle or be NULL. When window has finished
|
---|
379 | * moving or resizing, the preview will be cleared.
|
---|
380 | *
|
---|
381 | * @param wnd Window for which to paint preview
|
---|
382 | * @param rect Clipping rectangle
|
---|
383 | * @return EOK on success or an error code
|
---|
384 | */
|
---|
385 | static errno_t ds_window_repaint_preview(ds_window_t *wnd, gfx_rect_t *old_rect)
|
---|
386 | {
|
---|
387 | errno_t rc;
|
---|
388 | gfx_rect_t prect;
|
---|
389 | gfx_rect_t envelope;
|
---|
390 | bool oldr;
|
---|
391 | bool newr;
|
---|
392 |
|
---|
393 | log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_repaint_preview");
|
---|
394 |
|
---|
395 | /*
|
---|
396 | * Get current preview rectangle. If the window is not being resized/moved,
|
---|
397 | * we should get an empty rectangle.
|
---|
398 | */
|
---|
399 | ds_window_get_preview_rect(wnd, &prect);
|
---|
400 |
|
---|
401 | oldr = (old_rect != NULL) && !gfx_rect_is_empty(old_rect);
|
---|
402 | newr = !gfx_rect_is_empty(&prect);
|
---|
403 |
|
---|
404 | if (oldr && newr && gfx_rect_is_incident(old_rect, &prect)) {
|
---|
405 | /*
|
---|
406 | * As an optimization, repaint both rectangles in a single
|
---|
407 | * operation.
|
---|
408 | */
|
---|
409 |
|
---|
410 | gfx_rect_envelope(old_rect, &prect, &envelope);
|
---|
411 |
|
---|
412 | rc = ds_display_paint(wnd->display, &envelope);
|
---|
413 | if (rc != EOK)
|
---|
414 | return rc;
|
---|
415 | } else {
|
---|
416 | /* Repaint each rectangle separately */
|
---|
417 | if (oldr) {
|
---|
418 | rc = ds_display_paint(wnd->display, old_rect);
|
---|
419 | if (rc != EOK)
|
---|
420 | return rc;
|
---|
421 | }
|
---|
422 |
|
---|
423 | if (newr) {
|
---|
424 | rc = ds_display_paint(wnd->display, &prect);
|
---|
425 | if (rc != EOK)
|
---|
426 | return rc;
|
---|
427 | }
|
---|
428 | }
|
---|
429 |
|
---|
430 | return EOK;
|
---|
431 | }
|
---|
432 |
|
---|
433 | /** Start moving a window by mouse drag.
|
---|
434 | *
|
---|
435 | * @param wnd Window
|
---|
436 | * @param pos Position where mouse button was pressed
|
---|
437 | */
|
---|
438 | static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
439 | {
|
---|
440 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)",
|
---|
441 | (int) pos->x, (int) pos->y);
|
---|
442 |
|
---|
443 | if (wnd->state != dsw_idle)
|
---|
444 | return;
|
---|
445 |
|
---|
446 | wnd->orig_pos = *pos;
|
---|
447 | wnd->state = dsw_moving;
|
---|
448 | wnd->preview_pos = wnd->dpos;
|
---|
449 |
|
---|
450 | (void) ds_window_repaint_preview(wnd, NULL);
|
---|
451 | }
|
---|
452 |
|
---|
453 | /** Finish moving a window by mouse drag.
|
---|
454 | *
|
---|
455 | * @param wnd Window
|
---|
456 | * @param pos Position where mouse button was released
|
---|
457 | */
|
---|
458 | static void ds_window_finish_move(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
459 | {
|
---|
460 | gfx_coord2_t dmove;
|
---|
461 | gfx_coord2_t nwpos;
|
---|
462 | gfx_rect_t old_rect;
|
---|
463 |
|
---|
464 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_move (%d, %d)",
|
---|
465 | (int) pos->x, (int) pos->y);
|
---|
466 |
|
---|
467 | assert(wnd->state == dsw_moving);
|
---|
468 |
|
---|
469 | gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
|
---|
470 | gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
|
---|
471 |
|
---|
472 | ds_window_get_preview_rect(wnd, &old_rect);
|
---|
473 |
|
---|
474 | wnd->dpos = nwpos;
|
---|
475 | wnd->state = dsw_idle;
|
---|
476 |
|
---|
477 | (void) ds_display_paint(wnd->display, NULL);
|
---|
478 | }
|
---|
479 |
|
---|
480 | /** Update window position when moving by mouse drag.
|
---|
481 | *
|
---|
482 | * @param wnd Window
|
---|
483 | * @param pos Current mouse position
|
---|
484 | */
|
---|
485 | static void ds_window_update_move(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
486 | {
|
---|
487 | gfx_coord2_t dmove;
|
---|
488 | gfx_coord2_t nwpos;
|
---|
489 | gfx_rect_t old_rect;
|
---|
490 |
|
---|
491 | log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_move (%d, %d)",
|
---|
492 | (int) pos->x, (int) pos->y);
|
---|
493 |
|
---|
494 | assert(wnd->state == dsw_moving);
|
---|
495 |
|
---|
496 | gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
|
---|
497 | gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
|
---|
498 |
|
---|
499 | ds_window_get_preview_rect(wnd, &old_rect);
|
---|
500 | wnd->preview_pos = nwpos;
|
---|
501 |
|
---|
502 | (void) ds_window_repaint_preview(wnd, &old_rect);
|
---|
503 | }
|
---|
504 |
|
---|
505 | /** Start resizing a window by mouse drag.
|
---|
506 | *
|
---|
507 | * @param wnd Window
|
---|
508 | * @param rsztype Resize type (which part of window is being dragged)
|
---|
509 | * @param pos Position where mouse button was pressed
|
---|
510 | */
|
---|
511 | static void ds_window_start_resize(ds_window_t *wnd,
|
---|
512 | display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
|
---|
513 | {
|
---|
514 | ds_seat_t *seat;
|
---|
515 | display_stock_cursor_t ctype;
|
---|
516 |
|
---|
517 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)",
|
---|
518 | (int) pos->x, (int) pos->y);
|
---|
519 |
|
---|
520 | if (wnd->state != dsw_idle)
|
---|
521 | return;
|
---|
522 |
|
---|
523 | wnd->orig_pos = *pos;
|
---|
524 | wnd->state = dsw_resizing;
|
---|
525 | wnd->rsztype = rsztype;
|
---|
526 | wnd->preview_rect = wnd->rect;
|
---|
527 |
|
---|
528 | // TODO Multi-seat: need client to tell us which seat started the resize!
|
---|
529 | seat = ds_display_first_seat(wnd->display);
|
---|
530 | ctype = display_cursor_from_wrsz(rsztype);
|
---|
531 | ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]);
|
---|
532 |
|
---|
533 | (void) ds_window_repaint_preview(wnd, NULL);
|
---|
534 | }
|
---|
535 |
|
---|
536 | /** Finish resizing a window by mouse drag.
|
---|
537 | *
|
---|
538 | * @param wnd Window
|
---|
539 | * @param pos Position where mouse button was released
|
---|
540 | */
|
---|
541 | static void ds_window_finish_resize(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
542 | {
|
---|
543 | gfx_coord2_t dresize;
|
---|
544 | gfx_rect_t nrect;
|
---|
545 | ds_seat_t *seat;
|
---|
546 |
|
---|
547 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)",
|
---|
548 | (int) pos->x, (int) pos->y);
|
---|
549 |
|
---|
550 | assert(wnd->state == dsw_resizing);
|
---|
551 | gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
|
---|
552 |
|
---|
553 | /* Compute new rectangle */
|
---|
554 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
555 |
|
---|
556 | wnd->state = dsw_idle;
|
---|
557 | ds_client_post_resize_event(wnd->client, wnd, &nrect);
|
---|
558 |
|
---|
559 | // TODO Multi-seat: Need to know which seat started the resize!
|
---|
560 | seat = ds_display_first_seat(wnd->display);
|
---|
561 | ds_seat_set_wm_cursor(seat, NULL);
|
---|
562 |
|
---|
563 | (void) ds_display_paint(wnd->display, NULL);
|
---|
564 | }
|
---|
565 |
|
---|
566 | /** Update window position when resizing by mouse drag.
|
---|
567 | *
|
---|
568 | * @param wnd Window
|
---|
569 | * @param pos Current mouse position
|
---|
570 | */
|
---|
571 | static void ds_window_update_resize(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
572 | {
|
---|
573 | gfx_coord2_t dresize;
|
---|
574 | gfx_rect_t nrect;
|
---|
575 | gfx_rect_t old_rect;
|
---|
576 |
|
---|
577 | log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_resize (%d, %d)",
|
---|
578 | (int) pos->x, (int) pos->y);
|
---|
579 |
|
---|
580 | assert(wnd->state == dsw_resizing);
|
---|
581 |
|
---|
582 | gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
|
---|
583 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
584 |
|
---|
585 | ds_window_get_preview_rect(wnd, &old_rect);
|
---|
586 | wnd->preview_rect = nrect;
|
---|
587 | (void) ds_window_repaint_preview(wnd, &old_rect);
|
---|
588 | }
|
---|
589 |
|
---|
590 | /** Post keyboard event to window.
|
---|
591 | *
|
---|
592 | * @param wnd Window
|
---|
593 | * @param event Event
|
---|
594 | *
|
---|
595 | * @return EOK on success or an error code
|
---|
596 | */
|
---|
597 | errno_t ds_window_post_kbd_event(ds_window_t *wnd, kbd_event_t *event)
|
---|
598 | {
|
---|
599 | bool alt_or_shift;
|
---|
600 |
|
---|
601 | alt_or_shift = event->mods & (KM_SHIFT | KM_ALT);
|
---|
602 |
|
---|
603 | if (event->type == KEY_PRESS && alt_or_shift && event->key == KC_F4) {
|
---|
604 | /* On Alt-F4 or Shift-F4 send close event to the window */
|
---|
605 | ds_client_post_close_event(wnd->client, wnd);
|
---|
606 | return EOK;
|
---|
607 | }
|
---|
608 |
|
---|
609 | return ds_client_post_kbd_event(wnd->client, wnd, event);
|
---|
610 | }
|
---|
611 |
|
---|
612 | /** Post position event to window.
|
---|
613 | *
|
---|
614 | * @param wnd Window
|
---|
615 | * @param event Position event
|
---|
616 | *
|
---|
617 | * @return EOK on success or an error code
|
---|
618 | */
|
---|
619 | errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event)
|
---|
620 | {
|
---|
621 | pos_event_t tevent;
|
---|
622 | gfx_coord2_t pos;
|
---|
623 | gfx_rect_t drect;
|
---|
624 | bool inside;
|
---|
625 |
|
---|
626 | log_msg(LOG_DEFAULT, LVL_DEBUG2,
|
---|
627 | "ds_window_post_pos_event type=%d pos=%d,%d", event->type,
|
---|
628 | (int) event->hpos, (int) event->vpos);
|
---|
629 |
|
---|
630 | pos.x = event->hpos;
|
---|
631 | pos.y = event->vpos;
|
---|
632 | gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
|
---|
633 | inside = gfx_pix_inside_rect(&pos, &drect);
|
---|
634 |
|
---|
635 | if (event->type == POS_PRESS && event->btn_num == 2 && inside &&
|
---|
636 | (wnd->flags & wndf_maximized) == 0) {
|
---|
637 | ds_window_start_move(wnd, &pos);
|
---|
638 | return EOK;
|
---|
639 | }
|
---|
640 |
|
---|
641 | if (event->type == POS_RELEASE) {
|
---|
642 | if (wnd->state == dsw_moving) {
|
---|
643 | ds_window_finish_move(wnd, &pos);
|
---|
644 | return EOK;
|
---|
645 | }
|
---|
646 |
|
---|
647 | if (wnd->state == dsw_resizing) {
|
---|
648 | ds_window_finish_resize(wnd, &pos);
|
---|
649 | return EOK;
|
---|
650 | }
|
---|
651 | }
|
---|
652 |
|
---|
653 | if (event->type == POS_UPDATE) {
|
---|
654 | if (wnd->state == dsw_moving) {
|
---|
655 | ds_window_update_move(wnd, &pos);
|
---|
656 | return EOK;
|
---|
657 | }
|
---|
658 |
|
---|
659 | if (wnd->state == dsw_resizing) {
|
---|
660 | ds_window_update_resize(wnd, &pos);
|
---|
661 | return EOK;
|
---|
662 | }
|
---|
663 | }
|
---|
664 |
|
---|
665 | /* Transform event coordinates to window-local */
|
---|
666 | tevent = *event;
|
---|
667 | tevent.hpos -= wnd->dpos.x;
|
---|
668 | tevent.vpos -= wnd->dpos.y;
|
---|
669 |
|
---|
670 | return ds_client_post_pos_event(wnd->client, wnd, &tevent);
|
---|
671 | }
|
---|
672 |
|
---|
673 | /** Post focus event to window.
|
---|
674 | *
|
---|
675 | * @param wnd Window
|
---|
676 | * @return EOK on success or an error code
|
---|
677 | */
|
---|
678 | errno_t ds_window_post_focus_event(ds_window_t *wnd)
|
---|
679 | {
|
---|
680 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event");
|
---|
681 |
|
---|
682 | return ds_client_post_focus_event(wnd->client, wnd);
|
---|
683 | }
|
---|
684 |
|
---|
685 | /** Post unfocus event to window.
|
---|
686 | *
|
---|
687 | * @param wnd Window
|
---|
688 | * @return EOK on success or an error code
|
---|
689 | */
|
---|
690 | errno_t ds_window_post_unfocus_event(ds_window_t *wnd)
|
---|
691 | {
|
---|
692 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event");
|
---|
693 |
|
---|
694 | return ds_client_post_unfocus_event(wnd->client, wnd);
|
---|
695 | }
|
---|
696 |
|
---|
697 | /** Start moving a window, detected by client.
|
---|
698 | *
|
---|
699 | * @param wnd Window
|
---|
700 | * @param pos Position where the pointer was when the move started
|
---|
701 | * relative to the window
|
---|
702 | * @param event Button press event
|
---|
703 | */
|
---|
704 | void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos)
|
---|
705 | {
|
---|
706 | gfx_coord2_t orig_pos;
|
---|
707 |
|
---|
708 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_move_req (%d, %d)",
|
---|
709 | (int) pos->x, (int) pos->y);
|
---|
710 |
|
---|
711 | gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
|
---|
712 | ds_window_start_move(wnd, &orig_pos);
|
---|
713 | }
|
---|
714 |
|
---|
715 | /** Move window.
|
---|
716 | *
|
---|
717 | * @param wnd Window
|
---|
718 | */
|
---|
719 | void ds_window_move(ds_window_t *wnd, gfx_coord2_t *dpos)
|
---|
720 | {
|
---|
721 | wnd->dpos = *dpos;
|
---|
722 | (void) ds_display_paint(wnd->display, NULL);
|
---|
723 | }
|
---|
724 |
|
---|
725 | /** Get window position.
|
---|
726 | *
|
---|
727 | * @param wnd Window
|
---|
728 | */
|
---|
729 | void ds_window_get_pos(ds_window_t *wnd, gfx_coord2_t *dpos)
|
---|
730 | {
|
---|
731 | *dpos = wnd->dpos;
|
---|
732 | }
|
---|
733 |
|
---|
734 | /** Get maximized window rectangle.
|
---|
735 | *
|
---|
736 | * @param wnd Window
|
---|
737 | */
|
---|
738 | void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect)
|
---|
739 | {
|
---|
740 | *rect = wnd->display->max_rect;
|
---|
741 | }
|
---|
742 |
|
---|
743 | /** Start resizing a window, detected by client.
|
---|
744 | *
|
---|
745 | * @param wnd Window
|
---|
746 | * @param rsztype Resize type (which part of window is being dragged)
|
---|
747 | * @param pos Position where the pointer was when the resize started
|
---|
748 | * relative to the window
|
---|
749 | * @param event Button press event
|
---|
750 | */
|
---|
751 | void ds_window_resize_req(ds_window_t *wnd, display_wnd_rsztype_t rsztype,
|
---|
752 | gfx_coord2_t *pos)
|
---|
753 | {
|
---|
754 | gfx_coord2_t orig_pos;
|
---|
755 |
|
---|
756 | log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d)",
|
---|
757 | (int) rsztype, (int) pos->x, (int) pos->y);
|
---|
758 |
|
---|
759 | gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
|
---|
760 | ds_window_start_resize(wnd, rsztype, &orig_pos);
|
---|
761 | }
|
---|
762 |
|
---|
763 | /** Resize window.
|
---|
764 | *
|
---|
765 | * @param wnd Window
|
---|
766 | * @return EOK on success or an error code
|
---|
767 | */
|
---|
768 | errno_t ds_window_resize(ds_window_t *wnd, gfx_coord2_t *offs,
|
---|
769 | gfx_rect_t *nrect)
|
---|
770 | {
|
---|
771 | gfx_context_t *dgc;
|
---|
772 | gfx_bitmap_params_t bparams;
|
---|
773 | gfx_bitmap_t *nbitmap;
|
---|
774 | pixelmap_t npixelmap;
|
---|
775 | gfx_coord2_t dims;
|
---|
776 | gfx_bitmap_alloc_t alloc;
|
---|
777 | gfx_coord2_t ndpos;
|
---|
778 | errno_t rc;
|
---|
779 |
|
---|
780 | dgc = ds_display_get_gc(wnd->display);
|
---|
781 | if (dgc != NULL) {
|
---|
782 | gfx_bitmap_params_init(&bparams);
|
---|
783 | bparams.rect = *nrect;
|
---|
784 |
|
---|
785 | rc = gfx_bitmap_create(dgc, &bparams, NULL, &nbitmap);
|
---|
786 | if (rc != EOK)
|
---|
787 | return ENOMEM;
|
---|
788 |
|
---|
789 | rc = gfx_bitmap_get_alloc(nbitmap, &alloc);
|
---|
790 | if (rc != EOK) {
|
---|
791 | gfx_bitmap_destroy(nbitmap);
|
---|
792 | return ENOMEM;
|
---|
793 | }
|
---|
794 |
|
---|
795 | gfx_rect_dims(nrect, &dims);
|
---|
796 | npixelmap.width = dims.x;
|
---|
797 | npixelmap.height = dims.y;
|
---|
798 | npixelmap.data = alloc.pixels;
|
---|
799 |
|
---|
800 | /* TODO: Transfer contents within overlap */
|
---|
801 |
|
---|
802 | if (wnd->bitmap != NULL)
|
---|
803 | gfx_bitmap_destroy(wnd->bitmap);
|
---|
804 |
|
---|
805 | wnd->bitmap = nbitmap;
|
---|
806 | wnd->pixelmap = npixelmap;
|
---|
807 |
|
---|
808 | /* Point memory GC to the new bitmap */
|
---|
809 | mem_gc_retarget(wnd->mgc, nrect, &alloc);
|
---|
810 | }
|
---|
811 |
|
---|
812 | gfx_coord2_add(&wnd->dpos, offs, &ndpos);
|
---|
813 |
|
---|
814 | wnd->dpos = ndpos;
|
---|
815 | wnd->rect = *nrect;
|
---|
816 |
|
---|
817 | if ((wnd->flags & wndf_avoid) != 0)
|
---|
818 | ds_display_update_max_rect(wnd->display);
|
---|
819 |
|
---|
820 | (void) ds_display_paint(wnd->display, NULL);
|
---|
821 | return EOK;
|
---|
822 | }
|
---|
823 |
|
---|
824 | /** Minimize window.
|
---|
825 | *
|
---|
826 | * @param wnd Window
|
---|
827 | * @return EOK on success or an error code
|
---|
828 | */
|
---|
829 | errno_t ds_window_minimize(ds_window_t *wnd)
|
---|
830 | {
|
---|
831 | /* If already minimized, do nothing and return success. */
|
---|
832 | if ((wnd->flags & wndf_minimized) != 0)
|
---|
833 | return EOK;
|
---|
834 |
|
---|
835 | wnd->flags |= wndf_minimized;
|
---|
836 | (void) ds_display_paint(wnd->display, NULL);
|
---|
837 | return EOK;
|
---|
838 | }
|
---|
839 |
|
---|
840 | /** Unminimize window.
|
---|
841 | *
|
---|
842 | * @param wnd Window
|
---|
843 | * @return EOK on success or an error code
|
---|
844 | */
|
---|
845 | errno_t ds_window_unminimize(ds_window_t *wnd)
|
---|
846 | {
|
---|
847 | /* If not minimized, do nothing and return success. */
|
---|
848 | if ((wnd->flags & wndf_minimized) == 0)
|
---|
849 | return EOK;
|
---|
850 |
|
---|
851 | wnd->flags &= ~wndf_minimized;
|
---|
852 | (void) ds_display_paint(wnd->display, NULL);
|
---|
853 | return EOK;
|
---|
854 | }
|
---|
855 |
|
---|
856 | /** Maximize window.
|
---|
857 | *
|
---|
858 | * @param wnd Window
|
---|
859 | * @return EOK on success or an error code
|
---|
860 | */
|
---|
861 | errno_t ds_window_maximize(ds_window_t *wnd)
|
---|
862 | {
|
---|
863 | gfx_coord2_t old_dpos;
|
---|
864 | gfx_rect_t old_rect;
|
---|
865 | gfx_coord2_t offs;
|
---|
866 | gfx_rect_t max_rect;
|
---|
867 | gfx_rect_t nrect;
|
---|
868 | errno_t rc;
|
---|
869 |
|
---|
870 | /* If already maximized, do nothing and return success. */
|
---|
871 | if ((wnd->flags & wndf_maximized) != 0)
|
---|
872 | return EOK;
|
---|
873 |
|
---|
874 | /* Remember the old window rectangle and display position */
|
---|
875 | old_rect = wnd->rect;
|
---|
876 | old_dpos = wnd->dpos;
|
---|
877 |
|
---|
878 | ds_window_get_max_rect(wnd, &max_rect);
|
---|
879 |
|
---|
880 | /* Keep window contents on the same position on the screen */
|
---|
881 | offs.x = max_rect.p0.x - wnd->dpos.x;
|
---|
882 | offs.y = max_rect.p0.y - wnd->dpos.y;
|
---|
883 |
|
---|
884 | /* Maximized window's coordinates will start at 0,0 */
|
---|
885 | gfx_rect_rtranslate(&max_rect.p0, &max_rect, &nrect);
|
---|
886 |
|
---|
887 | rc = ds_window_resize(wnd, &offs, &nrect);
|
---|
888 | if (rc != EOK)
|
---|
889 | return rc;
|
---|
890 |
|
---|
891 | /* Set window flags, remember normal rectangle */
|
---|
892 | wnd->flags |= wndf_maximized;
|
---|
893 | wnd->normal_rect = old_rect;
|
---|
894 | wnd->normal_dpos = old_dpos;
|
---|
895 |
|
---|
896 | return EOK;
|
---|
897 | }
|
---|
898 |
|
---|
899 | /** Unmaximize window.
|
---|
900 | *
|
---|
901 | * @param wnd Window
|
---|
902 | * @return EOK on success or an error code
|
---|
903 | */
|
---|
904 | errno_t ds_window_unmaximize(ds_window_t *wnd)
|
---|
905 | {
|
---|
906 | gfx_coord2_t offs;
|
---|
907 | errno_t rc;
|
---|
908 |
|
---|
909 | /* If not maximized, do nothing and return success. */
|
---|
910 | if ((wnd->flags & wndf_maximized) == 0)
|
---|
911 | return EOK;
|
---|
912 |
|
---|
913 | /* Keep window contents on the same position on the screen */
|
---|
914 | offs.x = wnd->normal_dpos.x - wnd->dpos.x;
|
---|
915 | offs.y = wnd->normal_dpos.y - wnd->dpos.y;
|
---|
916 |
|
---|
917 | rc = ds_window_resize(wnd, &offs, &wnd->normal_rect);
|
---|
918 | if (rc != EOK)
|
---|
919 | return rc;
|
---|
920 |
|
---|
921 | /* Clear maximized flag */
|
---|
922 | wnd->flags &= ~wndf_maximized;
|
---|
923 |
|
---|
924 | return EOK;
|
---|
925 | }
|
---|
926 |
|
---|
927 | /** Compute new window rectangle after resize operation.
|
---|
928 | *
|
---|
929 | * @param wnd Window which is being resized (in dsw_resizing state and thus
|
---|
930 | * has rsztype set)
|
---|
931 | * @param dresize Amount by which to resize
|
---|
932 | * @param nrect Place to store new rectangle
|
---|
933 | */
|
---|
934 | void ds_window_calc_resize(ds_window_t *wnd, gfx_coord2_t *dresize,
|
---|
935 | gfx_rect_t *nrect)
|
---|
936 | {
|
---|
937 | if ((wnd->rsztype & display_wr_top) != 0) {
|
---|
938 | nrect->p0.y = min(wnd->rect.p0.y + dresize->y,
|
---|
939 | wnd->rect.p1.y - wnd->min_size.y);
|
---|
940 | } else {
|
---|
941 | nrect->p0.y = wnd->rect.p0.y;
|
---|
942 | }
|
---|
943 |
|
---|
944 | if ((wnd->rsztype & display_wr_left) != 0) {
|
---|
945 | nrect->p0.x = min(wnd->rect.p0.x + dresize->x,
|
---|
946 | wnd->rect.p1.x - wnd->min_size.x);
|
---|
947 | } else {
|
---|
948 | nrect->p0.x = wnd->rect.p0.x;
|
---|
949 | }
|
---|
950 |
|
---|
951 | if ((wnd->rsztype & display_wr_bottom) != 0) {
|
---|
952 | nrect->p1.y = max(wnd->rect.p1.y + dresize->y,
|
---|
953 | wnd->rect.p0.y + wnd->min_size.y);
|
---|
954 | } else {
|
---|
955 | nrect->p1.y = wnd->rect.p1.y;
|
---|
956 | }
|
---|
957 |
|
---|
958 | if ((wnd->rsztype & display_wr_right) != 0) {
|
---|
959 | nrect->p1.x = max(wnd->rect.p1.x + dresize->x,
|
---|
960 | wnd->rect.p0.x + wnd->min_size.x);
|
---|
961 | } else {
|
---|
962 | nrect->p1.x = wnd->rect.p1.x;
|
---|
963 | }
|
---|
964 | }
|
---|
965 |
|
---|
966 | /** Set window cursor.
|
---|
967 | *
|
---|
968 | * @param wnd Window
|
---|
969 | * @param cursor New cursor
|
---|
970 | * @return EOK on success, EINVAL if @a cursor is invalid
|
---|
971 | */
|
---|
972 | errno_t ds_window_set_cursor(ds_window_t *wnd, display_stock_cursor_t cursor)
|
---|
973 | {
|
---|
974 | if (cursor >= dcurs_arrow &&
|
---|
975 | cursor < (display_stock_cursor_t) dcurs_limit) {
|
---|
976 | wnd->cursor = wnd->display->cursor[cursor];
|
---|
977 | return EOK;
|
---|
978 | } else {
|
---|
979 | return EINVAL;
|
---|
980 | }
|
---|
981 | }
|
---|
982 |
|
---|
983 | /** Set window caption.
|
---|
984 | *
|
---|
985 | * @param wnd Window
|
---|
986 | * @param caption New caption
|
---|
987 | *
|
---|
988 | * @return EOK on success, EINVAL if @a cursor is invalid
|
---|
989 | */
|
---|
990 | errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption)
|
---|
991 | {
|
---|
992 | char *dcaption;
|
---|
993 | ds_wmclient_t *wmclient;
|
---|
994 |
|
---|
995 | dcaption = str_dup(caption);
|
---|
996 | if (dcaption == NULL)
|
---|
997 | return ENOMEM;
|
---|
998 |
|
---|
999 | free(wnd->caption);
|
---|
1000 | wnd->caption = dcaption;
|
---|
1001 |
|
---|
1002 | /* Notify window managers about window information change */
|
---|
1003 | wmclient = ds_display_first_wmclient(wnd->display);
|
---|
1004 | while (wmclient != NULL) {
|
---|
1005 | ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
|
---|
1006 | wmclient = ds_display_next_wmclient(wmclient);
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | return EOK;
|
---|
1010 | }
|
---|
1011 |
|
---|
1012 | /** Window memory GC invalidate callback.
|
---|
1013 | *
|
---|
1014 | * This is called by the window's memory GC when a rectangle is modified.
|
---|
1015 | */
|
---|
1016 | static void ds_window_invalidate_cb(void *arg, gfx_rect_t *rect)
|
---|
1017 | {
|
---|
1018 | ds_window_t *wnd = (ds_window_t *)arg;
|
---|
1019 | gfx_rect_t drect;
|
---|
1020 |
|
---|
1021 | /* Repaint the corresponding part of the display */
|
---|
1022 |
|
---|
1023 | gfx_rect_translate(&wnd->dpos, rect, &drect);
|
---|
1024 | ds_display_lock(wnd->display);
|
---|
1025 | (void) ds_display_paint(wnd->display, &drect);
|
---|
1026 | ds_display_unlock(wnd->display);
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | /** Window memory GC update callback.
|
---|
1030 | *
|
---|
1031 | * This is called by the window's memory GC when it is to be updated.
|
---|
1032 | */
|
---|
1033 | static void ds_window_update_cb(void *arg)
|
---|
1034 | {
|
---|
1035 | ds_window_t *wnd = (ds_window_t *)arg;
|
---|
1036 |
|
---|
1037 | (void) wnd;
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | /** @}
|
---|
1041 | */
|
---|