Changeset 913add60 in mainline for uspace/srv/hid/display/display.c


Ignore:
Timestamp:
2022-10-31T10:53:53Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b92d4b
Parents:
7cc30e9
git-author:
Jiri Svoboda <jiri@…> (2022-10-30 10:53:48)
git-committer:
Jiri Svoboda <jiri@…> (2022-10-31 10:53:53)
Message:

Deliver WM events for windows being added and removed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/display.c

    r7cc30e9 r913add60  
    4545#include "cursimg.h"
    4646#include "cursor.h"
     47#include "display.h"
    4748#include "seat.h"
    4849#include "window.h"
    49 #include "display.h"
     50#include "wmclient.h"
    5051
    5152static gfx_context_t *ds_display_get_unbuf_gc(ds_display_t *);
     
    9697        fibril_mutex_initialize(&disp->lock);
    9798        list_initialize(&disp->clients);
     99        list_initialize(&disp->wmclients);
    98100        disp->next_wnd_id = 1;
    99101        list_initialize(&disp->ddevs);
     
    115117{
    116118        assert(list_empty(&disp->clients));
     119        assert(list_empty(&disp->wmclients));
    117120        assert(list_empty(&disp->seats));
    118121        /* XXX destroy cursors */
     
    203206
    204207        return list_get_instance(link, ds_client_t, lclients);
     208}
     209
     210/** Add WM client to display.
     211 *
     212 * @param disp Display
     213 * @param wmclient WM client
     214 */
     215void ds_display_add_wmclient(ds_display_t *disp, ds_wmclient_t *wmclient)
     216{
     217        assert(wmclient->display == NULL);
     218        assert(!link_used(&wmclient->lwmclients));
     219
     220        wmclient->display = disp;
     221        list_append(&wmclient->lwmclients, &disp->wmclients);
     222}
     223
     224/** Remove WM client from display.
     225 *
     226 * @param wmclient WM client
     227 */
     228void ds_display_remove_wmclient(ds_wmclient_t *wmclient)
     229{
     230        list_remove(&wmclient->lwmclients);
     231        wmclient->display = NULL;
     232}
     233
     234/** Get first WM client in display.
     235 *
     236 * @param disp Display
     237 * @return First WM client or @c NULL if there is none
     238 */
     239ds_wmclient_t *ds_display_first_wmclient(ds_display_t *disp)
     240{
     241        link_t *link = list_first(&disp->wmclients);
     242
     243        if (link == NULL)
     244                return NULL;
     245
     246        return list_get_instance(link, ds_wmclient_t, lwmclients);
     247}
     248
     249/** Get next WM client in display.
     250 *
     251 * @param wmclient Current WM client
     252 * @return Next WM client or @c NULL if there is none
     253 */
     254ds_wmclient_t *ds_display_next_wmclient(ds_wmclient_t *wmclient)
     255{
     256        link_t *link = list_next(&wmclient->lwmclients,
     257            &wmclient->display->wmclients);
     258
     259        if (link == NULL)
     260                return NULL;
     261
     262        return list_get_instance(link, ds_wmclient_t, lwmclients);
    205263}
    206264
     
    262320void ds_display_add_window(ds_display_t *display, ds_window_t *wnd)
    263321{
     322        ds_wmclient_t *wmclient;
     323
    264324        assert(wnd->display == NULL);
    265325        assert(!link_used(&wnd->ldwindows));
     
    267327        wnd->display = display;
    268328        list_prepend(&wnd->ldwindows, &display->windows);
     329
     330        /* Notify window managers about the new window */
     331        wmclient = ds_display_first_wmclient(display);
     332        while (wmclient != NULL) {
     333                ds_wmclient_post_wnd_added_event(wmclient, wnd->id);
     334                wmclient = ds_display_next_wmclient(wmclient);
     335        }
    269336}
    270337
     
    275342void ds_display_remove_window(ds_window_t *wnd)
    276343{
     344        ds_wmclient_t *wmclient;
     345        ds_display_t *display;
     346
     347        display = wnd->display;
     348
    277349        list_remove(&wnd->ldwindows);
    278350        wnd->display = NULL;
     351
     352        /* Notify window managers about the removed window */
     353        wmclient = ds_display_first_wmclient(display);
     354        while (wmclient != NULL) {
     355                ds_wmclient_post_wnd_removed_event(wmclient, wnd->id);
     356                wmclient = ds_display_next_wmclient(wmclient);
     357        }
     358}
     359
     360/** Move window to top.
     361 *
     362 * @param display Display
     363 * @param wnd Window
     364 */
     365void ds_display_window_to_top(ds_window_t *wnd)
     366{
     367        assert(wnd->display != NULL);
     368        assert(link_used(&wnd->ldwindows));
     369
     370        list_remove(&wnd->ldwindows);
     371        list_prepend(&wnd->ldwindows, &wnd->display->windows);
    279372}
    280373
Note: See TracChangeset for help on using the changeset viewer.