HelenOS sources
This source file includes following definitions.
- ds_window_create
- ds_window_destroy
- ds_window_bring_to_top
- ds_window_get_ctx
- ds_window_is_visible
- ds_window_paint
- ds_window_get_preview_rect
- ds_window_paint_preview
- ds_window_repaint_preview
- ds_window_start_move
- ds_window_finish_move
- ds_window_update_move
- ds_window_start_resize
- ds_window_finish_resize
- ds_window_update_resize
- ds_window_post_kbd_event
- ds_window_post_pos_event
- ds_window_post_focus_event
- ds_window_post_unfocus_event
- ds_window_move_req
- ds_window_move
- ds_window_get_pos
- ds_window_get_max_rect
- ds_window_resize_req
- ds_window_resize
- ds_window_minimize
- ds_window_unminimize
- ds_window_maximize
- ds_window_unmaximize
- ds_window_calc_resize
- ds_window_set_cursor
- ds_window_set_caption
- ds_window_find_prev
- ds_window_find_next
- ds_window_unfocus
- ds_window_orig_seat
- ds_window_invalidate_cb
- ds_window_update_cb
#include <gfx/bitmap.h>
#include <gfx/color.h>
#include <gfx/coord.h>
#include <gfx/context.h>
#include <gfx/render.h>
#include <io/log.h>
#include <io/pixelmap.h>
#include <macros.h>
#include <memgfx/memgc.h>
#include <stdlib.h>
#include <str.h>
#include <wndmgt.h>
#include "client.h"
#include "display.h"
#include "seat.h"
#include "window.h"
#include "wmclient.h"
static void ds_window_invalidate_cb(void *, gfx_rect_t *);
static void ds_window_update_cb(void *);
static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *);
static mem_gc_cb_t ds_window_mem_gc_cb = {
.invalidate = ds_window_invalidate_cb,
.update = ds_window_update_cb
};
errno_t ds_window_create(ds_client_t *client, display_wnd_params_t *params,
ds_window_t **rwnd)
{
ds_window_t *wnd = NULL;
ds_seat_t *seat;
gfx_context_t *dgc;
gfx_coord2_t dims;
gfx_bitmap_params_t bparams;
gfx_bitmap_alloc_t alloc;
errno_t rc;
wnd = calloc(1, sizeof(ds_window_t));
if (wnd == NULL) {
rc = ENOMEM;
goto error;
}
wnd->caption = str_dup(params->caption);
if (wnd->caption == NULL) {
rc = ENOMEM;
goto error;
}
wnd->flags = params->flags;
ds_client_add_window(client, wnd);
ds_display_add_window(client->display, wnd);
gfx_bitmap_params_init(&bparams);
bparams.rect = params->rect;
dgc = ds_display_get_gc(wnd->display);
if (dgc != NULL) {
rc = gfx_bitmap_create(dgc, &bparams, NULL, &wnd->bitmap);
if (rc != EOK)
goto error;
rc = gfx_bitmap_get_alloc(wnd->bitmap, &alloc);
if (rc != EOK)
goto error;
gfx_rect_dims(¶ms->rect, &dims);
wnd->pixelmap.width = dims.x;
wnd->pixelmap.height = dims.y;
wnd->pixelmap.data = alloc.pixels;
} else {
gfx_rect_dims(¶ms->rect, &dims);
alloc.pitch = dims.x * sizeof(uint32_t);
alloc.off0 = 0;
alloc.pixels = calloc(1, alloc.pitch * dims.y);
}
rc = mem_gc_create(¶ms->rect, &alloc, &ds_window_mem_gc_cb,
(void *)wnd, &wnd->mgc);
if (rc != EOK)
goto error;
wnd->rect = params->rect;
wnd->min_size = params->min_size;
wnd->gc = mem_gc_get_ctx(wnd->mgc);
wnd->cursor = wnd->display->cursor[dcurs_arrow];
if ((params->flags & wndf_setpos) != 0) {
wnd->dpos = params->pos;
} else {
wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
}
if (params->idev_id != 0)
seat = ds_display_seat_by_idev(wnd->display, params->idev_id);
else
seat = ds_display_default_seat(wnd->display);
if ((params->flags & wndf_popup) != 0) {
ds_seat_set_popup(seat, wnd);
} else {
if ((params->flags & wndf_nofocus) == 0)
ds_seat_set_focus(seat, wnd);
}
if ((params->flags & wndf_avoid) != 0)
ds_display_update_max_rect(wnd->display);
(void) ds_display_paint(wnd->display, NULL);
*rwnd = wnd;
return EOK;
error:
if (wnd != NULL) {
ds_client_remove_window(wnd);
ds_display_remove_window(wnd);
if (wnd->mgc != NULL)
mem_gc_delete(wnd->mgc);
if (wnd->bitmap != NULL)
gfx_bitmap_destroy(wnd->bitmap);
if (wnd->caption != NULL)
free(wnd->caption);
free(wnd);
}
return rc;
}
void ds_window_destroy(ds_window_t *wnd)
{
ds_display_t *disp;
disp = wnd->display;
ds_window_unfocus(wnd);
ds_client_remove_window(wnd);
ds_display_remove_window(wnd);
if ((wnd->flags & wndf_avoid) != 0)
ds_display_update_max_rect(disp);
mem_gc_delete(wnd->mgc);
if (wnd->bitmap != NULL)
gfx_bitmap_destroy(wnd->bitmap);
free(wnd->caption);
free(wnd);
(void) ds_display_paint(disp, NULL);
}
void ds_window_bring_to_top(ds_window_t *wnd)
{
ds_display_window_to_top(wnd);
(void) ds_display_paint(wnd->display, NULL);
}
gfx_context_t *ds_window_get_ctx(ds_window_t *wnd)
{
return wnd->gc;
}
bool ds_window_is_visible(ds_window_t *wnd)
{
return (wnd->flags & wndf_minimized) == 0;
}
errno_t ds_window_paint(ds_window_t *wnd, gfx_rect_t *rect)
{
gfx_rect_t srect;
gfx_rect_t *brect;
gfx_rect_t crect;
log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_paint");
if (!ds_window_is_visible(wnd))
return EOK;
if (rect != NULL) {
gfx_rect_rtranslate(&wnd->dpos, rect, &srect);
gfx_rect_clip(&srect, &wnd->rect, &crect);
if (gfx_rect_is_empty(&crect))
return EOK;
brect = &srect;
} else {
brect = NULL;
}
if (wnd->bitmap == NULL)
return EOK;
return gfx_bitmap_render(wnd->bitmap, brect, &wnd->dpos);
}
static void ds_window_get_preview_rect(ds_window_t *wnd, gfx_rect_t *rect)
{
switch (wnd->state) {
case dsw_idle:
break;
case dsw_moving:
gfx_rect_translate(&wnd->preview_pos, &wnd->rect, rect);
return;
case dsw_resizing:
gfx_rect_translate(&wnd->dpos, &wnd->preview_rect, rect);
return;
}
rect->p0.x = 0;
rect->p0.y = 0;
rect->p1.x = 0;
rect->p1.y = 0;
}
errno_t ds_window_paint_preview(ds_window_t *wnd, gfx_rect_t *rect)
{
errno_t rc;
gfx_color_t *color;
gfx_rect_t prect;
gfx_rect_t dr;
gfx_rect_t pr;
gfx_context_t *gc;
ds_window_get_preview_rect(wnd, &prect);
if (gfx_rect_is_empty(&prect)) {
return EOK;
}
rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
if (rc != EOK)
return rc;
gc = ds_display_get_gc(wnd->display);
if (gc != NULL) {
gfx_set_color(gc, color);
pr.p0.x = prect.p0.x;
pr.p0.y = prect.p0.y;
pr.p1.x = prect.p1.x;
pr.p1.y = prect.p0.y + 1;
gfx_rect_clip(&pr, rect, &dr);
gfx_fill_rect(gc, &dr);
pr.p0.x = prect.p0.x;
pr.p0.y = prect.p1.y - 1;
pr.p1.x = prect.p1.x;
pr.p1.y = prect.p1.y;
gfx_rect_clip(&pr, rect, &dr);
gfx_fill_rect(gc, &dr);
pr.p0.x = prect.p0.x;
pr.p0.y = prect.p0.y;
pr.p1.x = prect.p0.x + 1;
pr.p1.y = prect.p1.y;
gfx_rect_clip(&pr, rect, &dr);
gfx_fill_rect(gc, &dr);
pr.p0.x = prect.p1.x - 1;
pr.p0.y = prect.p0.y;
pr.p1.x = prect.p1.x;
pr.p1.y = prect.p1.y;
gfx_rect_clip(&pr, rect, &dr);
gfx_fill_rect(gc, &dr);
}
gfx_color_delete(color);
return EOK;
}
static errno_t ds_window_repaint_preview(ds_window_t *wnd, gfx_rect_t *old_rect)
{
errno_t rc;
gfx_rect_t prect;
gfx_rect_t envelope;
bool oldr;
bool newr;
log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_repaint_preview");
ds_window_get_preview_rect(wnd, &prect);
oldr = (old_rect != NULL) && !gfx_rect_is_empty(old_rect);
newr = !gfx_rect_is_empty(&prect);
if (oldr && newr && gfx_rect_is_incident(old_rect, &prect)) {
gfx_rect_envelope(old_rect, &prect, &envelope);
rc = ds_display_paint(wnd->display, &envelope);
if (rc != EOK)
return rc;
} else {
if (oldr) {
rc = ds_display_paint(wnd->display, old_rect);
if (rc != EOK)
return rc;
}
if (newr) {
rc = ds_display_paint(wnd->display, &prect);
if (rc != EOK)
return rc;
}
}
return EOK;
}
static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos,
sysarg_t pos_id)
{
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)",
(int) pos->x, (int) pos->y);
if (wnd->state != dsw_idle)
return;
wnd->orig_pos = *pos;
wnd->orig_pos_id = pos_id;
wnd->state = dsw_moving;
wnd->preview_pos = wnd->dpos;
(void) ds_window_repaint_preview(wnd, NULL);
}
static void ds_window_finish_move(ds_window_t *wnd, gfx_coord2_t *pos)
{
gfx_coord2_t dmove;
gfx_coord2_t nwpos;
gfx_rect_t old_rect;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_move (%d, %d)",
(int) pos->x, (int) pos->y);
assert(wnd->state == dsw_moving);
gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
ds_window_get_preview_rect(wnd, &old_rect);
wnd->dpos = nwpos;
wnd->state = dsw_idle;
wnd->orig_pos_id = 0;
(void) ds_display_paint(wnd->display, NULL);
}
static void ds_window_update_move(ds_window_t *wnd, gfx_coord2_t *pos)
{
gfx_coord2_t dmove;
gfx_coord2_t nwpos;
gfx_rect_t old_rect;
log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_move (%d, %d)",
(int) pos->x, (int) pos->y);
assert(wnd->state == dsw_moving);
gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
ds_window_get_preview_rect(wnd, &old_rect);
wnd->preview_pos = nwpos;
(void) ds_window_repaint_preview(wnd, &old_rect);
}
static void ds_window_start_resize(ds_window_t *wnd,
display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
{
ds_seat_t *seat;
display_stock_cursor_t ctype;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)",
(int) pos->x, (int) pos->y);
if (wnd->state != dsw_idle)
return;
seat = ds_display_seat_by_idev(wnd->display, pos_id);
if (seat == NULL)
return;
wnd->orig_pos = *pos;
wnd->orig_pos_id = pos_id;
wnd->state = dsw_resizing;
wnd->rsztype = rsztype;
wnd->preview_rect = wnd->rect;
ctype = display_cursor_from_wrsz(rsztype);
ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]);
(void) ds_window_repaint_preview(wnd, NULL);
}
static void ds_window_finish_resize(ds_window_t *wnd, gfx_coord2_t *pos)
{
gfx_coord2_t dresize;
gfx_rect_t nrect;
ds_seat_t *seat;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)",
(int) pos->x, (int) pos->y);
assert(wnd->state == dsw_resizing);
gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
ds_window_calc_resize(wnd, &dresize, &nrect);
wnd->state = dsw_idle;
ds_client_post_resize_event(wnd->client, wnd, &nrect);
seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
if (seat != NULL)
ds_seat_set_wm_cursor(seat, NULL);
wnd->orig_pos_id = 0;
(void) ds_display_paint(wnd->display, NULL);
}
static void ds_window_update_resize(ds_window_t *wnd, gfx_coord2_t *pos)
{
gfx_coord2_t dresize;
gfx_rect_t nrect;
gfx_rect_t old_rect;
log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_resize (%d, %d)",
(int) pos->x, (int) pos->y);
assert(wnd->state == dsw_resizing);
gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
ds_window_calc_resize(wnd, &dresize, &nrect);
ds_window_get_preview_rect(wnd, &old_rect);
wnd->preview_rect = nrect;
(void) ds_window_repaint_preview(wnd, &old_rect);
}
errno_t ds_window_post_kbd_event(ds_window_t *wnd, kbd_event_t *event)
{
bool alt_or_shift;
alt_or_shift = event->mods & (KM_SHIFT | KM_ALT);
if (event->type == KEY_PRESS && alt_or_shift && event->key == KC_F4) {
ds_client_post_close_event(wnd->client, wnd);
return EOK;
}
return ds_client_post_kbd_event(wnd->client, wnd, event);
}
errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event)
{
pos_event_t tevent;
gfx_coord2_t pos;
sysarg_t pos_id;
gfx_rect_t drect;
bool inside;
log_msg(LOG_DEFAULT, LVL_DEBUG2,
"ds_window_post_pos_event type=%d pos=%d,%d", event->type,
(int) event->hpos, (int) event->vpos);
pos.x = event->hpos;
pos.y = event->vpos;
pos_id = event->pos_id;
gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
inside = gfx_pix_inside_rect(&pos, &drect);
if (event->type == POS_PRESS && event->btn_num == 2 && inside &&
(wnd->flags & wndf_maximized) == 0) {
ds_window_start_move(wnd, &pos, pos_id);
return EOK;
}
if (event->type == POS_RELEASE) {
if (wnd->state == dsw_moving &&
ds_window_orig_seat(wnd, pos_id)) {
ds_window_finish_move(wnd, &pos);
return EOK;
}
if (wnd->state == dsw_resizing &&
ds_window_orig_seat(wnd, pos_id)) {
ds_window_finish_resize(wnd, &pos);
return EOK;
}
}
if (event->type == POS_UPDATE) {
if (wnd->state == dsw_moving &&
ds_window_orig_seat(wnd, pos_id)) {
ds_window_update_move(wnd, &pos);
return EOK;
}
if (wnd->state == dsw_resizing &&
ds_window_orig_seat(wnd, pos_id)) {
ds_window_update_resize(wnd, &pos);
return EOK;
}
}
tevent = *event;
tevent.hpos -= wnd->dpos.x;
tevent.vpos -= wnd->dpos.y;
return ds_client_post_pos_event(wnd->client, wnd, &tevent);
}
errno_t ds_window_post_focus_event(ds_window_t *wnd)
{
display_wnd_focus_ev_t efocus;
errno_t rc;
ds_wmclient_t *wmclient;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event");
++wnd->nfocus;
efocus.nfocus = wnd->nfocus;
rc = ds_client_post_focus_event(wnd->client, wnd, &efocus);
if (rc != EOK)
return rc;
wmclient = ds_display_first_wmclient(wnd->display);
while (wmclient != NULL) {
ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
wmclient = ds_display_next_wmclient(wmclient);
}
return EOK;
}
errno_t ds_window_post_unfocus_event(ds_window_t *wnd)
{
display_wnd_unfocus_ev_t eunfocus;
errno_t rc;
ds_wmclient_t *wmclient;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event");
--wnd->nfocus;
eunfocus.nfocus = wnd->nfocus;
rc = ds_client_post_unfocus_event(wnd->client, wnd, &eunfocus);
if (rc != EOK)
return rc;
wmclient = ds_display_first_wmclient(wnd->display);
while (wmclient != NULL) {
ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
wmclient = ds_display_next_wmclient(wmclient);
}
return EOK;
}
void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos, sysarg_t pos_id)
{
gfx_coord2_t orig_pos;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_move_req (%d, %d)",
(int) pos->x, (int) pos->y);
gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
ds_window_start_move(wnd, &orig_pos, pos_id);
}
void ds_window_move(ds_window_t *wnd, gfx_coord2_t *dpos)
{
wnd->dpos = *dpos;
(void) ds_display_paint(wnd->display, NULL);
}
void ds_window_get_pos(ds_window_t *wnd, gfx_coord2_t *dpos)
{
*dpos = wnd->dpos;
}
void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect)
{
*rect = wnd->display->max_rect;
}
void ds_window_resize_req(ds_window_t *wnd, display_wnd_rsztype_t rsztype,
gfx_coord2_t *pos, sysarg_t pos_id)
{
gfx_coord2_t orig_pos;
log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d, %d)",
(int)rsztype, (int)pos->x, (int)pos->y, (int)pos_id);
gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
ds_window_start_resize(wnd, rsztype, &orig_pos, pos_id);
}
errno_t ds_window_resize(ds_window_t *wnd, gfx_coord2_t *offs,
gfx_rect_t *nrect)
{
gfx_context_t *dgc;
gfx_bitmap_params_t bparams;
gfx_bitmap_t *nbitmap;
pixelmap_t npixelmap;
gfx_coord2_t dims;
gfx_bitmap_alloc_t alloc;
gfx_coord2_t ndpos;
errno_t rc;
dgc = ds_display_get_gc(wnd->display);
if (dgc != NULL) {
gfx_bitmap_params_init(&bparams);
bparams.rect = *nrect;
rc = gfx_bitmap_create(dgc, &bparams, NULL, &nbitmap);
if (rc != EOK)
return ENOMEM;
rc = gfx_bitmap_get_alloc(nbitmap, &alloc);
if (rc != EOK) {
gfx_bitmap_destroy(nbitmap);
return ENOMEM;
}
gfx_rect_dims(nrect, &dims);
npixelmap.width = dims.x;
npixelmap.height = dims.y;
npixelmap.data = alloc.pixels;
if (wnd->bitmap != NULL)
gfx_bitmap_destroy(wnd->bitmap);
wnd->bitmap = nbitmap;
wnd->pixelmap = npixelmap;
mem_gc_retarget(wnd->mgc, nrect, &alloc);
}
gfx_coord2_add(&wnd->dpos, offs, &ndpos);
wnd->dpos = ndpos;
wnd->rect = *nrect;
if ((wnd->flags & wndf_avoid) != 0)
ds_display_update_max_rect(wnd->display);
(void) ds_display_paint(wnd->display, NULL);
return EOK;
}
errno_t ds_window_minimize(ds_window_t *wnd)
{
if ((wnd->flags & wndf_minimized) != 0)
return EOK;
ds_window_unfocus(wnd);
wnd->flags |= wndf_minimized;
(void) ds_display_paint(wnd->display, NULL);
return EOK;
}
errno_t ds_window_unminimize(ds_window_t *wnd)
{
if ((wnd->flags & wndf_minimized) == 0)
return EOK;
wnd->flags &= ~wndf_minimized;
(void) ds_display_paint(wnd->display, NULL);
return EOK;
}
errno_t ds_window_maximize(ds_window_t *wnd)
{
gfx_coord2_t old_dpos;
gfx_rect_t old_rect;
gfx_coord2_t offs;
gfx_rect_t max_rect;
gfx_rect_t nrect;
errno_t rc;
if ((wnd->flags & wndf_maximized) != 0)
return EOK;
old_rect = wnd->rect;
old_dpos = wnd->dpos;
ds_window_get_max_rect(wnd, &max_rect);
offs.x = max_rect.p0.x - wnd->dpos.x;
offs.y = max_rect.p0.y - wnd->dpos.y;
gfx_rect_rtranslate(&max_rect.p0, &max_rect, &nrect);
rc = ds_window_resize(wnd, &offs, &nrect);
if (rc != EOK)
return rc;
wnd->flags |= wndf_maximized;
wnd->normal_rect = old_rect;
wnd->normal_dpos = old_dpos;
return EOK;
}
errno_t ds_window_unmaximize(ds_window_t *wnd)
{
gfx_coord2_t offs;
errno_t rc;
if ((wnd->flags & wndf_maximized) == 0)
return EOK;
offs.x = wnd->normal_dpos.x - wnd->dpos.x;
offs.y = wnd->normal_dpos.y - wnd->dpos.y;
rc = ds_window_resize(wnd, &offs, &wnd->normal_rect);
if (rc != EOK)
return rc;
wnd->flags &= ~wndf_maximized;
return EOK;
}
void ds_window_calc_resize(ds_window_t *wnd, gfx_coord2_t *dresize,
gfx_rect_t *nrect)
{
if ((wnd->rsztype & display_wr_top) != 0) {
nrect->p0.y = min(wnd->rect.p0.y + dresize->y,
wnd->rect.p1.y - wnd->min_size.y);
} else {
nrect->p0.y = wnd->rect.p0.y;
}
if ((wnd->rsztype & display_wr_left) != 0) {
nrect->p0.x = min(wnd->rect.p0.x + dresize->x,
wnd->rect.p1.x - wnd->min_size.x);
} else {
nrect->p0.x = wnd->rect.p0.x;
}
if ((wnd->rsztype & display_wr_bottom) != 0) {
nrect->p1.y = max(wnd->rect.p1.y + dresize->y,
wnd->rect.p0.y + wnd->min_size.y);
} else {
nrect->p1.y = wnd->rect.p1.y;
}
if ((wnd->rsztype & display_wr_right) != 0) {
nrect->p1.x = max(wnd->rect.p1.x + dresize->x,
wnd->rect.p0.x + wnd->min_size.x);
} else {
nrect->p1.x = wnd->rect.p1.x;
}
}
errno_t ds_window_set_cursor(ds_window_t *wnd, display_stock_cursor_t cursor)
{
if (cursor >= dcurs_arrow &&
cursor < (display_stock_cursor_t) dcurs_limit) {
wnd->cursor = wnd->display->cursor[cursor];
return EOK;
} else {
return EINVAL;
}
}
errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption)
{
char *dcaption;
ds_wmclient_t *wmclient;
dcaption = str_dup(caption);
if (dcaption == NULL)
return ENOMEM;
free(wnd->caption);
wnd->caption = dcaption;
wmclient = ds_display_first_wmclient(wnd->display);
while (wmclient != NULL) {
ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
wmclient = ds_display_next_wmclient(wmclient);
}
return EOK;
}
ds_window_t *ds_window_find_prev(ds_window_t *wnd,
display_wnd_flags_t allowed_flags)
{
ds_window_t *nwnd;
nwnd = ds_display_next_window(wnd);
while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
nwnd = ds_display_next_window(nwnd);
}
if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
return nwnd;
}
nwnd = ds_display_first_window(wnd->display);
while (nwnd != NULL && nwnd != wnd &&
(nwnd->flags & ~allowed_flags) != 0) {
nwnd = ds_display_next_window(nwnd);
}
if (nwnd == wnd)
return NULL;
return nwnd;
}
ds_window_t *ds_window_find_next(ds_window_t *wnd,
display_wnd_flags_t allowed_flags)
{
ds_window_t *nwnd;
nwnd = ds_display_prev_window(wnd);
while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
nwnd = ds_display_prev_window(nwnd);
}
if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
return nwnd;
}
nwnd = ds_display_last_window(wnd->display);
while (nwnd != NULL && nwnd != wnd &&
(nwnd->flags & ~allowed_flags) != 0) {
nwnd = ds_display_prev_window(nwnd);
}
if (nwnd == wnd)
return NULL;
return nwnd;
}
void ds_window_unfocus(ds_window_t *wnd)
{
ds_seat_t *seat;
seat = ds_display_first_seat(wnd->display);
while (seat != NULL) {
ds_seat_unfocus_wnd(seat, wnd);
seat = ds_display_next_seat(seat);
}
}
bool ds_window_orig_seat(ds_window_t *wnd, sysarg_t idev_id)
{
ds_seat_t *orig_seat;
ds_seat_t *seat;
assert(wnd->state == dsw_moving || wnd->state == dsw_resizing);
orig_seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
seat = ds_display_seat_by_idev(wnd->display, idev_id);
return seat == orig_seat;
}
static void ds_window_invalidate_cb(void *arg, gfx_rect_t *rect)
{
ds_window_t *wnd = (ds_window_t *)arg;
gfx_rect_t drect;
gfx_rect_translate(&wnd->dpos, rect, &drect);
ds_display_lock(wnd->display);
(void) ds_display_paint(wnd->display, &drect);
ds_display_unlock(wnd->display);
}
static void ds_window_update_cb(void *arg)
{
ds_window_t *wnd = (ds_window_t *)arg;
(void) wnd;
}
HelenOS homepage, sources at GitHub