HelenOS sources
This source file includes following definitions.
- dispwm_get_window_list
- dispwm_get_window_info
- dispwm_activate_window
- dispwm_close_window
- dispwm_get_event
#include <errno.h>
#include <io/log.h>
#include <stdlib.h>
#include <str.h>
#include <wndmgt_srv.h>
#include "display.h"
#include "seat.h"
#include "window.h"
#include "wmclient.h"
static errno_t dispwm_get_window_list(void *, wndmgt_window_list_t **);
static errno_t dispwm_get_window_info(void *, sysarg_t, wndmgt_window_info_t **);
static errno_t dispwm_activate_window(void *, sysarg_t, sysarg_t);
static errno_t dispwm_close_window(void *, sysarg_t);
static errno_t dispwm_get_event(void *, wndmgt_ev_t *);
wndmgt_ops_t wndmgt_srv_ops = {
.get_window_list = dispwm_get_window_list,
.get_window_info = dispwm_get_window_info,
.activate_window = dispwm_activate_window,
.close_window = dispwm_close_window,
.get_event = dispwm_get_event,
};
static errno_t dispwm_get_window_list(void *arg, wndmgt_window_list_t **rlist)
{
ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
wndmgt_window_list_t *list;
ds_window_t *wnd;
unsigned i;
log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_window_list()");
list = calloc(1, sizeof(wndmgt_window_list_t));
if (list == NULL)
return ENOMEM;
ds_display_lock(wmclient->display);
list->nwindows = 0;
wnd = ds_display_first_window(wmclient->display);
while (wnd != NULL) {
++list->nwindows;
wnd = ds_display_next_window(wnd);
}
list->windows = calloc(list->nwindows, sizeof(sysarg_t));
if (list->windows == NULL) {
ds_display_unlock(wmclient->display);
free(list);
return ENOMEM;
}
i = 0;
wnd = ds_display_first_window(wmclient->display);
while (wnd != NULL) {
list->windows[i++] = wnd->id;
wnd = ds_display_next_window(wnd);
}
ds_display_unlock(wmclient->display);
*rlist = list;
return EOK;
}
static errno_t dispwm_get_window_info(void *arg, sysarg_t wnd_id,
wndmgt_window_info_t **rinfo)
{
ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
ds_window_t *wnd;
wndmgt_window_info_t *info;
log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_window_info()");
ds_display_lock(wmclient->display);
wnd = ds_display_find_window(wmclient->display, wnd_id);
if (wnd == NULL) {
ds_display_unlock(wmclient->display);
return ENOENT;
}
info = calloc(1, sizeof(wndmgt_window_info_t));
if (info == NULL) {
ds_display_unlock(wmclient->display);
return ENOMEM;
}
info->caption = str_dup(wnd->caption);
if (info->caption == NULL) {
ds_display_unlock(wmclient->display);
free(info);
return ENOMEM;
}
info->flags = wnd->flags;
info->nfocus = wnd->nfocus;
ds_display_unlock(wmclient->display);
*rinfo = info;
return EOK;
}
static errno_t dispwm_activate_window(void *arg, sysarg_t dev_id,
sysarg_t wnd_id)
{
ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
ds_window_t *wnd;
ds_seat_t *seat;
log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_activate_window()");
ds_display_lock(wmclient->display);
wnd = ds_display_find_window(wmclient->display, wnd_id);
if (wnd == NULL) {
ds_display_unlock(wmclient->display);
return ENOENT;
}
seat = ds_display_seat_by_idev(wnd->display, dev_id);
if (seat == NULL) {
ds_display_unlock(wmclient->display);
return ENOENT;
}
ds_seat_set_focus(seat, wnd);
ds_display_unlock(wmclient->display);
return EOK;
}
static errno_t dispwm_close_window(void *arg, sysarg_t wnd_id)
{
log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_close_window()");
(void)arg;
(void)wnd_id;
return EOK;
}
static errno_t dispwm_get_event(void *arg, wndmgt_ev_t *ev)
{
ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
errno_t rc;
log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_get_event()");
ds_display_lock(wmclient->display);
rc = ds_wmclient_get_event(wmclient, ev);
ds_display_unlock(wmclient->display);
return rc;
}
HelenOS homepage, sources at GitHub