Changeset 7cc30e9 in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2022-10-24T17:50:46Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
913add60
Parents:
7a05d924
Message:

Display server needs to store window caption

Even though it does not use it itself, it needs to provide it to
window managers (e.g. Task bar). We need to be able to set caption
for a new window and to change it for an existing window.

File:
1 edited

Legend:

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

    r7a05d924 r7cc30e9  
    4444#include <memgfx/memgc.h>
    4545#include <stdlib.h>
     46#include <str.h>
    4647#include "client.h"
    4748#include "display.h"
     
    8182        wnd = calloc(1, sizeof(ds_window_t));
    8283        if (wnd == NULL) {
     84                rc = ENOMEM;
     85                goto error;
     86        }
     87
     88        wnd->caption = str_dup(params->caption);
     89        if (wnd->caption == NULL) {
    8390                rc = ENOMEM;
    8491                goto error;
     
    152159                if (wnd->bitmap != NULL)
    153160                        gfx_bitmap_destroy(wnd->bitmap);
     161                if (wnd->caption != NULL)
     162                        free(wnd->caption);
    154163                free(wnd);
    155164        }
     
    176185                gfx_bitmap_destroy(wnd->bitmap);
    177186
     187        free(wnd->caption);
    178188        free(wnd);
    179189
     
    902912 *
    903913 * @param wnd Window
     914 * @param cursor New cursor
    904915 * @return EOK on success, EINVAL if @a cursor is invalid
    905916 */
     
    915926}
    916927
     928/** Set window caption.
     929 *
     930 * @param wnd Window
     931 * @param caption New caption
     932 *
     933 * @return EOK on success, EINVAL if @a cursor is invalid
     934 */
     935errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption)
     936{
     937        char *dcaption;
     938
     939        dcaption = str_dup(caption);
     940        if (dcaption == NULL)
     941                return ENOMEM;
     942
     943        free(wnd->caption);
     944        wnd->caption = dcaption;
     945
     946        return EOK;
     947}
     948
    917949/** Window memory GC invalidate callback.
    918950 *
Note: See TracChangeset for help on using the changeset viewer.