Changeset 19b3cc6 in mainline for uspace/lib


Ignore:
Timestamp:
2014-01-17T23:12:10Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e26a9d95
Parents:
fddffb2 (diff), facc34d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libdrv-cleanup branch (includes mainline changes)

Location:
uspace/lib
Files:
4 added
22 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    rfddffb2 r19b3cc6  
    101101        generic/io/log.c \
    102102        generic/io/logctl.c \
     103        generic/io/kio.c \
    103104        generic/io/klog.c \
    104105        generic/io/snprintf.c \
  • uspace/lib/c/generic/assert.c

    rfddffb2 r19b3cc6  
    3333#include <assert.h>
    3434#include <stdio.h>
    35 #include <io/klog.h>
     35#include <io/kio.h>
    3636#include <stdlib.h>
    3737#include <atomic.h>
     
    4444{
    4545        /*
    46          * Send the message safely to klog. Nested asserts should not occur.
     46         * Send the message safely to kio. Nested asserts should not occur.
    4747         */
    48         klog_printf("Assertion failed (%s) in file \"%s\", line %u.\n",
     48        kio_printf("Assertion failed (%s) in file \"%s\", line %u.\n",
    4949            cond, file, line);
    5050       
  • uspace/lib/c/generic/io/io.c

    rfddffb2 r19b3cc6  
    4242#include <malloc.h>
    4343#include <async.h>
    44 #include <io/klog.h>
     44#include <io/kio.h>
    4545#include <vfs/vfs.h>
    4646#include <vfs/vfs_sess.h>
     
    5757        .error = true,
    5858        .eof = true,
    59         .klog = false,
     59        .kio = false,
    6060        .sess = NULL,
    6161        .btype = _IONBF,
     
    6767};
    6868
    69 static FILE stdout_klog = {
     69static FILE stdout_kio = {
    7070        .fd = -1,
    7171        .error = false,
    7272        .eof = false,
    73         .klog = true,
     73        .kio = true,
    7474        .sess = NULL,
    7575        .btype = _IOLBF,
     
    8181};
    8282
    83 static FILE stderr_klog = {
     83static FILE stderr_kio = {
    8484        .fd = -1,
    8585        .error = false,
    8686        .eof = false,
    87         .klog = true,
     87        .kio = true,
    8888        .sess = NULL,
    8989        .btype = _IONBF,
     
    113113                stdout = fdopen(1, "w");
    114114        } else {
    115                 stdout = &stdout_klog;
     115                stdout = &stdout_kio;
    116116                list_append(&stdout->link, &files);
    117117        }
     
    120120                stderr = fdopen(2, "w");
    121121        } else {
    122                 stderr = &stderr_klog;
     122                stderr = &stderr_kio;
    123123                list_append(&stderr->link, &files);
    124124        }
     
    267267        stream->error = false;
    268268        stream->eof = false;
    269         stream->klog = false;
     269        stream->kio = false;
    270270        stream->sess = NULL;
    271271        stream->need_sync = false;
     
    289289        stream->error = false;
    290290        stream->eof = false;
    291         stream->klog = false;
     291        stream->kio = false;
    292292        stream->sess = NULL;
    293293        stream->need_sync = false;
     
    314314       
    315315        if ((stream != &stdin_null)
    316             && (stream != &stdout_klog)
    317             && (stream != &stderr_klog))
     316            && (stream != &stdout_kio)
     317            && (stream != &stderr_kio))
    318318                free(stream);
    319319       
     
    382382                ssize_t wr;
    383383               
    384                 if (stream->klog)
    385                         wr = klog_write(buf + done, left);
     384                if (stream->kio)
     385                        wr = kio_write(buf + done, left);
    386386                else
    387387                        wr = write(stream->fd, buf + done, left);
     
    705705        _fflushbuf(stream);
    706706       
    707         if (stream->klog) {
    708                 klog_update();
     707        if (stream->kio) {
     708                kio_update();
    709709                return EOK;
    710710        }
     
    740740int fileno(FILE *stream)
    741741{
    742         if (stream->klog) {
     742        if (stream->kio) {
    743743                errno = EBADF;
    744744                return -1;
  • uspace/lib/c/generic/io/klog.c

    rfddffb2 r19b3cc6  
    11/*
    2  * Copyright (c) 2006 Josef Cejka
    3  * Copyright (c) 2006 Jakub Vana
     2 * Copyright (c) 2013 Martin Sucha
    43 * All rights reserved.
    54 *
     
    4140#include <abi/klog.h>
    4241#include <io/klog.h>
    43 #include <io/printf_core.h>
     42#include <abi/log.h>
    4443
    45 size_t klog_write(const void *buf, size_t size)
     44size_t klog_write(log_level_t lvl, const void *buf, size_t size)
    4645{
    47         ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf, size);
     46        ssize_t ret = (ssize_t) __SYSCALL4(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf,
     47            size, lvl);
    4848       
    4949        if (ret >= 0)
     
    5353}
    5454
    55 void klog_update(void)
     55int klog_read(void *data, size_t size)
    5656{
    57         (void) __SYSCALL3(SYS_KLOG, KLOG_UPDATE, (uintptr_t) NULL, 0);
    58 }
    59 
    60 void klog_command(const void *buf, size_t size)
    61 {
    62         (void) __SYSCALL3(SYS_KLOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size);
    63 }
    64 
    65 /** Print formatted text to klog.
    66  *
    67  * @param fmt Format string
    68  *
    69  * \see For more details about format string see printf_core.
    70  *
    71  */
    72 int klog_printf(const char *fmt, ...)
    73 {
    74         va_list args;
    75         va_start(args, fmt);
    76        
    77         int ret = klog_vprintf(fmt, args);
    78        
    79         va_end(args);
    80        
    81         return ret;
    82 }
    83 
    84 static int klog_vprintf_str_write(const char *str, size_t size, void *data)
    85 {
    86         size_t wr = klog_write(str, size);
    87         return str_nlength(str, wr);
    88 }
    89 
    90 static int klog_vprintf_wstr_write(const wchar_t *str, size_t size, void *data)
    91 {
    92         size_t offset = 0;
    93         size_t chars = 0;
    94        
    95         while (offset < size) {
    96                 char buf[STR_BOUNDS(1)];
    97                 size_t sz = 0;
    98                
    99                 if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK)
    100                         klog_write(buf, sz);
    101                
    102                 chars++;
    103                 offset += sizeof(wchar_t);
    104         }
    105        
    106         return chars;
    107 }
    108 
    109 /** Print formatted text to klog.
    110  *
    111  * @param fmt Format string
    112  * @param ap  Format parameters
    113  *
    114  * \see For more details about format string see printf_core.
    115  *
    116  */
    117 int klog_vprintf(const char *fmt, va_list ap)
    118 {
    119         printf_spec_t ps = {
    120                 klog_vprintf_str_write,
    121                 klog_vprintf_wstr_write,
    122                 NULL
    123         };
    124        
    125         return printf_core(fmt, &ps, ap);
     57        return (int) __SYSCALL4(SYS_KLOG, KLOG_READ, (uintptr_t) data, size, 0);
    12658}
    12759
  • uspace/lib/c/generic/io/window.c

    rfddffb2 r19b3cc6  
    4040#include <stdio.h>
    4141
    42 int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out,
    43     sysarg_t x_offset, sysarg_t y_offset)
     42int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out)
    4443{
    4544        async_exch_t *exch = async_exchange_begin(sess);
    46         int ret = async_req_2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);
     45        int ret = async_req_0_2(exch, WINDOW_REGISTER, in, out);
    4746        async_exchange_end(exch);
    48 
     47       
    4948        return ret;
    5049}
     
    9291}
    9392
    94 int win_resize(async_sess_t *sess, sysarg_t width, sysarg_t height, void *cells)
     93int win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width,
     94    sysarg_t height, window_placement_flags_t placement_flags, void *cells)
    9595{
    9696        async_exch_t *exch = async_exchange_begin(sess);
    97 
     97       
    9898        ipc_call_t answer;
    99         aid_t req = async_send_2(exch, WINDOW_RESIZE, width, height, &answer);
    100 
     99        aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height,
     100            (sysarg_t) placement_flags, &answer);
     101       
    101102        int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
    102 
     103       
    103104        async_exchange_end(exch);
    104 
     105       
    105106        sysarg_t ret;
    106107        async_wait_for(req, &ret);
    107 
    108         if (rc != EOK) {
     108       
     109        if (rc != EOK)
    109110                return rc;
    110         } else if (ret != EOK) {
     111        else if (ret != EOK)
    111112                return ret;
    112         } else {
    113                 return EOK;
    114         }
     113       
     114        return EOK;
    115115}
    116116
  • uspace/lib/c/generic/private/stdio.h

    rfddffb2 r19b3cc6  
    5353        int eof;
    5454       
    55         /** Klog indicator */
    56         int klog;
     55        /** KIO indicator */
     56        int kio;
    5757       
    5858        /** Session to the file provider */
  • uspace/lib/c/include/io/klog.h

    rfddffb2 r19b3cc6  
    11/*
    2  * Copyright (c) 2006 Jakub Vana
     2 * Copyright (c) 2013 Martin Sucha
    33 * All rights reserved.
    44 *
     
    3939#include <stdarg.h>
    4040#include <io/verify.h>
     41#include <stdio.h>
     42#include <stdlib.h>
     43#include <str.h>
     44#include <abi/log.h>
    4145
    42 extern size_t klog_write(const void *, size_t);
    43 extern void klog_update(void);
    44 extern void klog_command(const void *, size_t);
    45 extern int klog_printf(const char *, ...)
    46     PRINTF_ATTRIBUTE(1, 2);
    47 extern int klog_vprintf(const char *, va_list);
     46extern size_t klog_write(log_level_t, const void *, size_t);
     47extern int klog_read(void *, size_t);
     48
     49#define KLOG_PRINTF(lvl, fmt, ...) ({ \
     50        char *_fmt = str_dup(fmt); \
     51        size_t _fmtsize = str_size(_fmt); \
     52        if (_fmtsize > 0 && _fmt[_fmtsize - 1] == '\n') \
     53                _fmt[_fmtsize - 1] = 0; \
     54        char *_s; \
     55        int _c = asprintf(&_s, _fmt, ##__VA_ARGS__); \
     56        free(_fmt); \
     57        if (_c >= 0) { \
     58                _c = klog_write((lvl), _s, str_size(_s)); \
     59                free(_s); \
     60        }; \
     61        (_c >= 0); \
     62})
    4863
    4964#endif
  • uspace/lib/c/include/io/log.h

    rfddffb2 r19b3cc6  
    3939#include <io/verify.h>
    4040
    41 /** Log message level. */
    42 typedef enum {
    43         /** Fatal error, program is not able to recover at all. */
    44         LVL_FATAL,
    45         /** Serious error but the program can recover from it. */
    46         LVL_ERROR,
    47         /** Easily recoverable problem. */
    48         LVL_WARN,
    49         /** Information message that ought to be printed by default. */
    50         LVL_NOTE,
    51         /** Debugging purpose message. */
    52         LVL_DEBUG,
    53         /** More detailed debugging message. */
    54         LVL_DEBUG2,
    55        
    56         /** For checking range of values */
    57         LVL_LIMIT
    58 } log_level_t;
     41#include <abi/log.h>
    5942
    6043/** Log itself (logging target). */
  • uspace/lib/c/include/io/window.h

    rfddffb2 r19b3cc6  
    4343#include <io/pos_event.h>
    4444
     45typedef enum {
     46        GF_EMPTY = 0,
     47        GF_MOVE_X = 1,
     48        GF_MOVE_Y = 2,
     49        GF_RESIZE_X = 4,
     50        GF_RESIZE_Y = 8,
     51        GF_SCALE_X = 16,
     52        GF_SCALE_Y = 32
     53} window_grab_flags_t;
     54
     55typedef enum {
     56        WINDOW_PLACEMENT_ANY = 0,
     57        WINDOW_PLACEMENT_CENTER_X = 1,
     58        WINDOW_PLACEMENT_CENTER_Y = 2,
     59        WINDOW_PLACEMENT_CENTER =
     60            WINDOW_PLACEMENT_CENTER_X | WINDOW_PLACEMENT_CENTER_Y,
     61        WINDOW_PLACEMENT_LEFT = 4,
     62        WINDOW_PLACEMENT_RIGHT = 8,
     63        WINDOW_PLACEMENT_TOP = 16,
     64        WINDOW_PLACEMENT_BOTTOM = 32,
     65        WINDOW_PLACEMENT_ABSOLUTE_X = 64,
     66        WINDOW_PLACEMENT_ABSOLUTE_Y = 128,
     67        WINDOW_PLACEMENT_ABSOLUTE =
     68            WINDOW_PLACEMENT_ABSOLUTE_X | WINDOW_PLACEMENT_ABSOLUTE_Y
     69} window_placement_flags_t;
     70
    4571typedef struct {
    4672        sysarg_t object;
    4773        sysarg_t slot;
    4874        sysarg_t argument;
    49 } sig_event_t;
     75} signal_event_t;
    5076
    5177typedef struct {
     78        sysarg_t offset_x;
     79        sysarg_t offset_y;
    5280        sysarg_t width;
    5381        sysarg_t height;
    54 } rsz_event_t;
     82        window_placement_flags_t placement_flags;
     83} resize_event_t;
    5584
    5685typedef enum {
     
    6998        kbd_event_t kbd;
    7099        pos_event_t pos;
    71         sig_event_t sig;
    72         rsz_event_t rsz;
     100        signal_event_t signal;
     101        resize_event_t resize;
    73102} window_event_data_t;
    74103
     
    79108} window_event_t;
    80109
    81 typedef enum {
    82         GF_EMPTY = 0,
    83         GF_MOVE_X = 1,
    84         GF_MOVE_Y = 2,
    85         GF_RESIZE_X = 4,
    86         GF_RESIZE_Y = 8,
    87         GF_SCALE_X = 16,
    88         GF_SCALE_Y = 32
    89 } window_grab_flags_t;
    90 
    91 extern int win_register(async_sess_t *, service_id_t *, service_id_t *, sysarg_t, sysarg_t);
     110extern int win_register(async_sess_t *, service_id_t *, service_id_t *);
    92111
    93112extern int win_get_event(async_sess_t *, window_event_t *);
     
    95114extern int win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    96115extern int win_grab(async_sess_t *, sysarg_t, sysarg_t);
    97 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, void *);
     116extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     117    window_placement_flags_t, void *);
    98118extern int win_close(async_sess_t *);
    99119extern int win_close_request(async_sess_t *);
  • uspace/lib/c/include/stdio.h

    rfddffb2 r19b3cc6  
    4040#include <str.h>
    4141#include <io/verify.h>
    42 #include <abi/klog.h>
     42#include <abi/kio.h>
    4343
    4444#define EOF  (-1)
     
    5252                int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
    5353                if (_n > 0) \
    54                         (void) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \
     54                        (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \
    5555        }
    5656
  • uspace/lib/draw/cursor/embedded.c

    rfddffb2 r19b3cc6  
    4646        assert(state_count);
    4747        assert(data);
    48 
     48       
    4949        (*state_count) = 1;
    5050        (*data) = NULL;
     
    5353static surface_t *cde_render(uint8_t state)
    5454{
    55         if (state != 0) {
     55        if (state != 0)
    5656                return NULL;
    57         }
    58 
     57       
    5958        surface_t *surface = surface_create(CURSOR_WIDTH, CURSOR_HEIGHT, NULL, 0);
    60 
    61         if (!surface) {
     59        if (!surface)
    6260                return NULL;
    63         }
    6461       
    6562        for (unsigned int y = 0; y < CURSOR_HEIGHT; ++y) {
     
    6966                        pixel_t pixel = (cursor_texture[offset] & (1 << (x % 8))) ?
    7067                            PIXEL(255, 0, 0, 0) : PIXEL(255, 255, 255, 255);
    71                         surface_put_pixel(surface, x, y, visible ? pixel : PIXEL(0, 0, 0, 0));
     68                       
     69                        if (visible)
     70                                surface_put_pixel(surface, x, y, pixel);
    7271                }
    7372        }
    74 
     73       
    7574        return surface;
    7675}
  • uspace/lib/drv/generic/driver.c

    rfddffb2 r19b3cc6  
    920920
    921921/** Set function ops. */
    922 void ddf_fun_set_ops(ddf_fun_t *fun, ddf_dev_ops_t *dev_ops)
     922void ddf_fun_set_ops(ddf_fun_t *fun, const ddf_dev_ops_t *dev_ops)
    923923{
    924924        assert(fun->conn_handler == NULL);
  • uspace/lib/drv/generic/private/driver.h

    rfddffb2 r19b3cc6  
    9393       
    9494        /** Implementation of operations provided by this function */
    95         ddf_dev_ops_t *ops;
     95        const ddf_dev_ops_t *ops;
    9696       
    9797        /** Connection handler or @c NULL to use the DDF default handler. */
  • uspace/lib/drv/include/ddf/driver.h

    rfddffb2 r19b3cc6  
    137137extern int ddf_fun_offline(ddf_fun_t *);
    138138extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
    139 extern void ddf_fun_set_ops(ddf_fun_t *, ddf_dev_ops_t *);
     139extern void ddf_fun_set_ops(ddf_fun_t *, const ddf_dev_ops_t *);
    140140extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_client_conn_t);
    141141extern int ddf_fun_add_to_category(ddf_fun_t *, const char *);
  • uspace/lib/gui/Makefile

    rfddffb2 r19b3cc6  
    3434
    3535SOURCES = \
     36        common.c \
    3637        button.c \
    3738        canvas.c \
  • uspace/lib/gui/button.c

    rfddffb2 r19b3cc6  
    3636#include <str.h>
    3737#include <malloc.h>
    38 
    3938#include <drawctx.h>
    4039#include <surface.h>
    41 
     40#include "common.h"
    4241#include "window.h"
    4342#include "button.h"
    4443
    45 static void paint_internal(widget_t *w)
    46 {
    47         button_t *btn = (button_t *) w;
    48 
     44static pixel_t color_highlight = PIXEL(255, 255, 255, 255);
     45static pixel_t color_shadow = PIXEL(255, 85, 85, 85);
     46
     47static void paint_internal(widget_t *widget)
     48{
     49        button_t *btn = (button_t *) widget;
     50       
    4951        surface_t *surface = window_claim(btn->widget.window);
    50         if (!surface) {
     52        if (!surface)
    5153                window_yield(btn->widget.window);
     54       
     55        source_t source;
     56        source_init(&source);
     57       
     58        drawctx_t drawctx;
     59        drawctx_init(&drawctx, surface);
     60       
     61        drawctx_set_source(&drawctx, &btn->background);
     62        drawctx_transfer(&drawctx, widget->hpos, widget->vpos,
     63            widget->width, widget->height);
     64       
     65        if ((widget->width >= 8) && (widget->height >= 8)) {
     66                drawctx_set_source(&drawctx, &source);
     67                draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3,
     68                    widget->width - 6, widget->height - 6, color_highlight,
     69                    color_shadow);
     70               
     71                drawctx_set_source(&drawctx, &btn->foreground);
     72                drawctx_transfer(&drawctx, widget->hpos + 4, widget->vpos + 4,
     73                    widget->width - 8, widget->height - 8);
    5274        }
    53 
    54         drawctx_t drawctx;
    55 
    56         drawctx_init(&drawctx, surface);
    57         drawctx_set_source(&drawctx, &btn->foreground);
    58         drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, w->height);
    59 
    60         if (w->width >= 6 && w->height >= 6) {
    61                 drawctx_set_source(&drawctx, &btn->background);
    62                 drawctx_transfer(&drawctx,
    63                     w->hpos + 3, w->vpos + 3, w->width - 6, w->height - 6);
    64         }
    65 
     75       
    6676        sysarg_t cpt_width;
    6777        sysarg_t cpt_height;
    6878        font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
    69         if (w->width >= cpt_width && w->height >= cpt_height) {
    70                 drawctx_set_source(&drawctx, &btn->foreground);
     79       
     80        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
     81                sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos;
     82                sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos;
     83               
     84                drawctx_set_source(&drawctx, &btn->text);
    7185                drawctx_set_font(&drawctx, &btn->font);
    72                 sysarg_t x = ((w->width - cpt_width) / 2) + w->hpos;
    73                 sysarg_t y = ((w->height - cpt_height) / 2) + w->vpos;
    74                 if (btn->caption) {
     86               
     87                if (btn->caption)
    7588                        drawctx_print(&drawctx, btn->caption, x, y);
    76                 }
    7789        }
    78 
     90       
    7991        window_yield(btn->widget.window);
    8092}
     
    90102{
    91103        button_t *btn = (button_t *) widget;
    92 
     104       
    93105        deinit_button(btn);
    94        
    95106        free(btn);
    96107}
     
    117128{
    118129        button_t *btn = (button_t *) widget;
    119         if (event.key == KC_ENTER && event.type == KEY_PRESS) {
     130       
     131        if (event.key == KC_ENTER && event.type == KEY_PRESS)
    120132                sig_send(&btn->clicked, NULL);
    121         }
    122133}
    123134
     
    126137        button_t *btn = (button_t *) widget;
    127138        widget->window->focus = widget;
    128 
     139       
    129140        // TODO make the click logic more robust (mouse grabbing, mouse moves)
    130141        if (event.btn_num == 1) {
    131                 if (event.type == POS_RELEASE) {
     142                if (event.type == POS_RELEASE)
    132143                        sig_send(&btn->clicked, NULL);
    133                 }
    134144        }
    135145}
    136146
    137 bool init_button(button_t *btn, widget_t *parent,
    138     const char *caption, uint16_t points, pixel_t background, pixel_t foreground)
     147bool init_button(button_t *btn, widget_t *parent, const char *caption,
     148    uint16_t points, pixel_t background, pixel_t foreground, pixel_t text)
    139149{
    140150        widget_init(&btn->widget, parent);
    141 
     151       
    142152        btn->widget.destroy = button_destroy;
    143153        btn->widget.reconfigure = button_reconfigure;
     
    146156        btn->widget.handle_keyboard_event = button_handle_keyboard_event;
    147157        btn->widget.handle_position_event = button_handle_position_event;
    148 
     158       
    149159        source_init(&btn->background);
    150160        source_set_color(&btn->background, background);
     161       
    151162        source_init(&btn->foreground);
    152163        source_set_color(&btn->foreground, foreground);
    153 
    154         if (caption == NULL) {
     164       
     165        source_init(&btn->text);
     166        source_set_color(&btn->text, text);
     167       
     168        if (caption == NULL)
    155169                btn->caption = NULL;
    156         } else {
     170        else
    157171                btn->caption = str_dup(caption);
    158         }
     172       
    159173        font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points);
    160 
     174       
    161175        sysarg_t cpt_width;
    162176        sysarg_t cpt_height;
    163177        font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
    164         btn->widget.width_min = cpt_width + 8;
    165         btn->widget.height_min = cpt_height + 8;
    166         btn->widget.width_ideal = cpt_width + 28;
    167         btn->widget.height_ideal = cpt_height + 8;
    168 
     178        btn->widget.width_min = cpt_width + 10;
     179        btn->widget.height_min = cpt_height + 10;
     180        btn->widget.width_ideal = cpt_width + 30;
     181        btn->widget.height_ideal = cpt_height + 10;
     182       
    169183        return true;
    170184}
    171185
    172 button_t *create_button(widget_t *parent,
    173     const char *caption, uint16_t points, pixel_t background, pixel_t foreground)
     186button_t *create_button(widget_t *parent, const char *caption, uint16_t points,
     187    pixel_t background, pixel_t foreground, pixel_t text)
    174188{
    175189        button_t *btn = (button_t *) malloc(sizeof(button_t));
    176         if (!btn) {
     190        if (!btn)
    177191                return NULL;
    178         }
    179 
    180         if (init_button(btn, parent, caption, points, background, foreground)) {
     192       
     193        if (init_button(btn, parent, caption, points, background, foreground,
     194            text))
    181195                return btn;
    182         } else {
    183                 free(btn);
    184                 return NULL;
    185         }
     196       
     197        free(btn);
     198        return NULL;
    186199}
    187200
  • uspace/lib/gui/button.h

    rfddffb2 r19b3cc6  
    5050        source_t background;
    5151        source_t foreground;
     52        source_t text;
    5253        char *caption;
    5354        font_t font;
     
    5556} button_t;
    5657
    57 extern bool init_button(button_t *, widget_t *, const char *, uint16_t, pixel_t, pixel_t);
    58 extern button_t *create_button(widget_t *, const char *, uint16_t, pixel_t, pixel_t);
     58extern bool init_button(button_t *, widget_t *, const char *, uint16_t, pixel_t,
     59    pixel_t, pixel_t);
     60extern button_t *create_button(widget_t *, const char *, uint16_t, pixel_t,
     61    pixel_t, pixel_t);
    5962extern void deinit_button(button_t *);
    6063
  • uspace/lib/gui/connection.c

    rfddffb2 r19b3cc6  
    210210                        link_initialize(&event->link);
    211211                        event->type = ET_SIGNAL_EVENT;
    212                         event->data.sig.object = (sysarg_t) cur->widget;
    213                         event->data.sig.slot = (sysarg_t) cur->slot;
    214                         event->data.sig.argument = (sysarg_t) data_copy;
     212                        event->data.signal.object = (sysarg_t) cur->widget;
     213                        event->data.signal.slot = (sysarg_t) cur->slot;
     214                        event->data.signal.argument = (sysarg_t) data_copy;
    215215                        prodcons_produce(&cur->widget->window->events, &event->link);
    216216                } else {
  • uspace/lib/gui/label.c

    rfddffb2 r19b3cc6  
    3636#include <str.h>
    3737#include <malloc.h>
    38 
    3938#include <drawctx.h>
    4039#include <surface.h>
    41 
    4240#include "window.h"
    4341#include "label.h"
    4442
    45 static void paint_internal(widget_t *w)
     43static void paint_internal(widget_t *widget)
    4644{
    47         label_t *lbl = (label_t *) w;
     45        label_t *lbl = (label_t *) widget;
    4846
    4947        surface_t *surface = window_claim(lbl->widget.window);
    50         if (!surface) {
     48        if (!surface)
    5149                window_yield(lbl->widget.window);
    52         }
    53 
     50       
    5451        drawctx_t drawctx;
    55 
    5652        drawctx_init(&drawctx, surface);
     53       
    5754        drawctx_set_source(&drawctx, &lbl->background);
    58         drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, w->height);
    59 
     55        drawctx_transfer(&drawctx, widget->hpos, widget->vpos, widget->width,
     56            widget->height);
     57       
    6058        sysarg_t cpt_width;
    6159        sysarg_t cpt_height;
    6260        font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
    63         if (w->width >= cpt_width && w->height >= cpt_height) {
    64                 drawctx_set_source(&drawctx, &lbl->foreground);
     61       
     62        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
     63                sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos;
     64                sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos;
     65               
     66                drawctx_set_source(&drawctx, &lbl->text);
    6567                drawctx_set_font(&drawctx, &lbl->font);
    66                 sysarg_t x = ((w->width - cpt_width) / 2) + w->hpos;
    67                 sysarg_t y = ((w->height - cpt_height) / 2) + w->vpos;
    68                 if (lbl->caption) {
     68               
     69                if (lbl->caption)
    6970                        drawctx_print(&drawctx, lbl->caption, x, y);
    70                 }
    7171        }
    72 
     72       
    7373        window_yield(lbl->widget.window);
    7474}
     
    7878        if (data != NULL) {
    7979                label_t *lbl = (label_t *) widget;
     80               
    8081                const char *new_caption = (const char *) data;
    8182                lbl->caption = str_dup(new_caption);
    82 
     83               
    8384                sysarg_t cpt_width;
    8485                sysarg_t cpt_height;
    8586                font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
     87               
    8688                lbl->widget.width_min = cpt_width + 4;
    8789                lbl->widget.height_min = cpt_height + 4;
    8890                lbl->widget.width_ideal = lbl->widget.width_min;
    8991                lbl->widget.height_ideal = lbl->widget.height_min;
    90 
     92               
    9193                window_refresh(lbl->widget.window);
    9294        }
     
    103105{
    104106        label_t *lbl = (label_t *) widget;
    105 
     107       
    106108        deinit_label(lbl);
    107        
    108109        free(lbl);
    109110}
     
    137138}
    138139
    139 bool init_label(label_t *lbl, widget_t *parent,
    140     const char *caption, uint16_t points, pixel_t background, pixel_t foreground)
     140bool init_label(label_t *lbl, widget_t *parent, const char *caption,
     141    uint16_t points, pixel_t background, pixel_t text)
    141142{
    142143        widget_init(&lbl->widget, parent);
    143 
     144       
    144145        lbl->widget.destroy = label_destroy;
    145146        lbl->widget.reconfigure = label_reconfigure;
     
    148149        lbl->widget.handle_keyboard_event = label_handle_keyboard_event;
    149150        lbl->widget.handle_position_event = label_handle_position_event;
    150 
     151       
    151152        source_init(&lbl->background);
    152153        source_set_color(&lbl->background, background);
    153         source_init(&lbl->foreground);
    154         source_set_color(&lbl->foreground, foreground);
    155 
    156         if (caption == NULL) {
     154       
     155        source_init(&lbl->text);
     156        source_set_color(&lbl->text, text);
     157       
     158        if (caption == NULL)
    157159                lbl->caption = NULL;
    158         } else {
     160        else
    159161                lbl->caption = str_dup(caption);
    160         }
     162       
    161163        font_init(&lbl->font, FONT_DECODER_EMBEDDED, NULL, points);
    162 
     164       
    163165        sysarg_t cpt_width;
    164166        sysarg_t cpt_height;
    165167        font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
     168       
    166169        lbl->widget.width_min = cpt_width + 4;
    167170        lbl->widget.height_min = cpt_height + 4;
    168171        lbl->widget.width_ideal = lbl->widget.width_min;
    169172        lbl->widget.height_ideal = lbl->widget.height_min;
    170 
     173       
    171174        lbl->rewrite = on_rewrite;
    172 
     175       
    173176        return true;
    174177}
    175178
    176 label_t *create_label(widget_t *parent,
    177     const char *caption, uint16_t points, pixel_t background, pixel_t foreground)
     179label_t *create_label(widget_t *parent, const char *caption, uint16_t points,
     180    pixel_t background, pixel_t text)
    178181{
    179182        label_t *lbl = (label_t *) malloc(sizeof(label_t));
    180         if (!lbl) {
     183        if (!lbl)
    181184                return NULL;
    182         }
    183 
    184         if (init_label(lbl, parent, caption, points, background, foreground)) {
     185       
     186        if (init_label(lbl, parent, caption, points, background, text))
    185187                return lbl;
    186         } else {
    187                 free(lbl);
    188                 return NULL;
    189         }
     188       
     189        free(lbl);
     190        return NULL;
    190191}
    191192
    192193/** @}
    193194 */
    194 
  • uspace/lib/gui/label.h

    rfddffb2 r19b3cc6  
    4949        widget_t widget;
    5050        source_t background;
    51         source_t foreground;
     51        source_t text;
    5252        char *caption;
    5353        font_t font;
     
    5555} label_t;
    5656
    57 extern bool init_label(label_t *, widget_t *, const char *, uint16_t, pixel_t, pixel_t);
    58 extern label_t *create_label(widget_t *, const char *, uint16_t, pixel_t, pixel_t);
     57extern bool init_label(label_t *, widget_t *, const char *, uint16_t, pixel_t,
     58    pixel_t);
     59extern label_t *create_label(widget_t *, const char *, uint16_t, pixel_t,
     60    pixel_t);
    5961extern void deinit_label(label_t *);
    6062
  • uspace/lib/gui/window.c

    rfddffb2 r19b3cc6  
    5656#include <surface.h>
    5757
     58#include "common.h"
    5859#include "connection.h"
    5960#include "widget.h"
    6061#include "window.h"
    6162
    62 static sysarg_t border_thickness = 5;
     63static sysarg_t border_thickness = 4;
     64static sysarg_t bevel_thickness = 1;
    6365static sysarg_t header_height = 20;
    6466static sysarg_t header_min_width = 40;
    65 static sysarg_t close_width = 20;
    66 
    67 static pixel_t border_color = PIXEL(255, 0, 0, 0);
    68 static pixel_t header_bg_focus_color = PIXEL(255, 88, 106, 196);
    69 static pixel_t header_fg_focus_color = PIXEL(255, 255, 255, 255);
    70 static pixel_t header_bg_unfocus_color = PIXEL(255, 12, 57, 92);
    71 static pixel_t header_fg_unfocus_color = PIXEL(255, 255, 255, 255);
    72 
    73 static void paint_internal(widget_t *w)
    74 {
    75         surface_t *surface = window_claim(w->window);
    76         if (!surface) {
    77                 window_yield(w->window);
    78         }
    79 
     67static sysarg_t close_thickness = 20;
     68
     69static pixel_t color_highlight = PIXEL(255, 255, 255, 255);
     70static pixel_t color_shadow = PIXEL(255, 85, 85, 85);
     71static pixel_t color_surface = PIXEL(255, 186, 186, 186);
     72
     73static pixel_t color_header_focus_highlight = PIXEL(255, 120, 145, 255);
     74static pixel_t color_header_focus_shadow = PIXEL(255, 40, 48, 89);
     75static pixel_t color_header_focus_surface = PIXEL(255, 88, 106, 196);
     76
     77static pixel_t color_header_unfocus_highlight = PIXEL(255, 16, 78, 126);
     78static pixel_t color_header_unfocus_shadow = PIXEL(255, 5, 26, 42);
     79static pixel_t color_header_unfocus_surface = PIXEL(255, 12, 57, 92);
     80
     81static pixel_t color_caption_focus = PIXEL(255, 255, 255, 255);
     82static pixel_t color_caption_unfocus = PIXEL(255, 207, 207, 207);
     83
     84static void paint_internal(widget_t *widget)
     85{
     86        surface_t *surface = window_claim(widget->window);
     87        if (!surface)
     88                window_yield(widget->window);
     89       
    8090        source_t source;
    81         font_t font;
     91        source_init(&source);
     92       
    8293        drawctx_t drawctx;
    83 
    84         source_init(&source);
    85         font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16);
    8694        drawctx_init(&drawctx, surface);
    8795        drawctx_set_source(&drawctx, &source);
     96       
     97        /* Window border outer bevel */
     98       
     99        draw_bevel(&drawctx, &source, widget->vpos, widget->hpos,
     100            widget->width, widget->height, color_highlight, color_shadow);
     101       
     102        /* Window border surface */
     103       
     104        source_set_color(&source, color_surface);
     105        drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1,
     106            widget->width - 2, 2);
     107        drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1,
     108            2, widget->height - 2);
     109        drawctx_transfer(&drawctx, widget->hpos + 1,
     110            widget->vpos + widget->height - 3, widget->width - 2, 2);
     111        drawctx_transfer(&drawctx, widget->hpos + widget->width - 3,
     112            widget->vpos + 1, 2, widget->height - 4);
     113       
     114        /* Window border inner bevel */
     115       
     116        draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3,
     117            widget->width - 6, widget->height - 6, color_shadow,
     118            color_highlight);
     119       
     120        /* Header bevel */
     121       
     122        sysarg_t header_hpos = widget->hpos + border_thickness;
     123        sysarg_t header_vpos = widget->vpos + border_thickness;
     124        sysarg_t header_width = widget->width - 2 * border_thickness -
     125            close_thickness;
     126       
     127        draw_bevel(&drawctx, &source, header_hpos, header_vpos,
     128            header_width, header_height, widget->window->is_focused ?
     129            color_header_focus_highlight : color_header_unfocus_highlight,
     130            widget->window->is_focused ?
     131            color_header_focus_shadow : color_header_unfocus_shadow);
     132       
     133        /* Header surface */
     134       
     135        source_set_color(&source, widget->window->is_focused ?
     136            color_header_focus_surface : color_header_unfocus_surface);
     137        drawctx_transfer(&drawctx, header_hpos + 1, header_vpos + 1,
     138            header_width - 2, header_height - 2);
     139       
     140        /* Close button bevel */
     141       
     142        sysarg_t close_hpos = widget->hpos + widget->width -
     143            border_thickness - close_thickness;
     144        sysarg_t close_vpos = widget->vpos + border_thickness;
     145       
     146        draw_bevel(&drawctx, &source, close_hpos, close_vpos,
     147            close_thickness, close_thickness, color_highlight, color_shadow);
     148       
     149        /* Close button surface */
     150       
     151        source_set_color(&source, color_surface);
     152        drawctx_transfer(&drawctx, close_hpos + 1, close_vpos + 1,
     153            close_thickness - 2, close_thickness - 2);
     154       
     155        /* Close button icon */
     156       
     157        draw_icon_cross(surface, close_hpos + 3, close_vpos + 3,
     158            color_highlight, color_shadow);
     159       
     160        /* Window caption */
     161       
     162        font_t font;
     163        font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16);
     164       
    88165        drawctx_set_font(&drawctx, &font);
    89 
    90         source_set_color(&source, border_color);
    91         drawctx_transfer(&drawctx, w->hpos, w->vpos, border_thickness, w->height);
    92         drawctx_transfer(&drawctx, w->hpos + w->width - border_thickness,
    93             w->vpos, border_thickness, w->height);
    94         drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, border_thickness);
    95         drawctx_transfer(&drawctx, w->hpos,
    96             w->vpos + w->height - border_thickness, w->width, border_thickness);
    97 
    98         source_set_color(&source,
    99             w->window->is_focused ? header_bg_focus_color : header_bg_unfocus_color);
    100         drawctx_transfer(&drawctx,
    101             w->hpos + border_thickness, w->vpos + border_thickness,
    102                 w->width - 2 * border_thickness, header_height);
    103 
     166        source_set_color(&source, widget->window->is_focused ?
     167            color_caption_focus : color_caption_unfocus);
     168       
    104169        sysarg_t cpt_width;
    105170        sysarg_t cpt_height;
    106         font_get_box(&font, w->window->caption, &cpt_width, &cpt_height);
    107         sysarg_t cls_width;
    108         sysarg_t cls_height;
    109         char cls_pict[] = "x";
    110         font_get_box(&font, cls_pict, &cls_width, &cls_height);
    111         source_set_color(&source,
    112             w->window->is_focused ? header_fg_focus_color : header_fg_unfocus_color);
    113         sysarg_t cls_x = ((close_width - cls_width) / 2) + w->hpos + w->width -
    114             border_thickness - close_width;
    115         sysarg_t cls_y = ((header_height - cls_height) / 2) + w->vpos + border_thickness;
    116         drawctx_print(&drawctx, cls_pict, cls_x, cls_y);
    117 
    118         bool draw_title = (w->width >= 2 * border_thickness + close_width + cpt_width);
     171        font_get_box(&font, widget->window->caption, &cpt_width, &cpt_height);
     172       
     173        bool draw_title =
     174            (widget->width >= 2 * border_thickness + 2 * bevel_thickness +
     175            close_thickness + cpt_width);
    119176        if (draw_title) {
    120                 sysarg_t cpt_x = ((w->width - cpt_width) / 2) + w->hpos;
    121                 sysarg_t cpt_y = ((header_height - cpt_height) / 2) + w->vpos + border_thickness;
    122                 if (w->window->caption) {
    123                         drawctx_print(&drawctx, w->window->caption, cpt_x, cpt_y);
    124                 }
    125         }
    126 
     177                sysarg_t cpt_x = ((widget->width - cpt_width) / 2) + widget->hpos;
     178                sysarg_t cpt_y = ((header_height - cpt_height) / 2) +
     179                    widget->vpos + border_thickness;
     180               
     181                if (widget->window->caption)
     182                        drawctx_print(&drawctx, widget->window->caption, cpt_x, cpt_y);
     183        }
     184       
    127185        font_release(&font);
    128         window_yield(w->window);
     186        window_yield(widget->window);
    129187}
    130188
     
    138196        if (widget->window->is_decorated) {
    139197                list_foreach(widget->children, link, widget_t, child) {
    140                         child->rearrange(child, 
     198                        child->rearrange(child,
    141199                            widget->hpos + border_thickness,
    142200                            widget->vpos + border_thickness + header_height,
     
    211269                    (event.vpos >= border_thickness) &&
    212270                    (event.vpos < border_thickness + header_height);
    213                 bool close = header && (event.hpos >= width - border_thickness - close_width);
     271                bool close = (header) &&
     272                    (event.hpos >= width - border_thickness - close_thickness);
    214273
    215274                if (top && left && allowed_button) {
     
    292351}
    293352
    294 static void handle_signal_event(window_t *win, sig_event_t event)
     353static void handle_signal_event(window_t *win, signal_event_t event)
    295354{
    296355        widget_t *widget = (widget_t *) event.object;
     
    303362}
    304363
    305 static void handle_resize(window_t *win, sysarg_t width, sysarg_t height)
    306 {
    307         int rc;
    308         surface_t *old_surface;
    309         surface_t *new_surface;
    310 
     364static void handle_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y,
     365    sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags)
     366{
    311367        if (width < 2 * border_thickness + header_min_width) {
    312368                win_damage(win->osess, 0, 0, 0, 0);
    313369                return;
    314370        }
    315 
     371       
    316372        if (height < 2 * border_thickness + header_height) {
    317373                win_damage(win->osess, 0, 0, 0, 0);
    318374                return;
    319375        }
    320 
     376       
    321377        /* Allocate resources for new surface. */
    322         new_surface = surface_create(width, height, NULL, SURFACE_FLAG_SHARED);
    323         if (!new_surface) {
     378        surface_t *new_surface = surface_create(width, height, NULL,
     379            SURFACE_FLAG_SHARED);
     380        if (!new_surface)
    324381                return;
    325         }
    326 
     382       
    327383        /* Switch new and old surface. */
    328384        fibril_mutex_lock(&win->guard);
    329         old_surface = win->surface;
     385        surface_t *old_surface = win->surface;
    330386        win->surface = new_surface;
    331387        fibril_mutex_unlock(&win->guard);
    332 
    333         /* Let all widgets in the tree alter their position and size. Widgets might
    334          * also paint themselves onto the new surface. */
     388       
     389        /*
     390         * Let all widgets in the tree alter their position and size.
     391         * Widgets might also paint themselves onto the new surface.
     392         */
    335393        win->root.rearrange(&win->root, 0, 0, width, height);
    336 
     394       
    337395        fibril_mutex_lock(&win->guard);
    338396        surface_reset_damaged_region(win->surface);
    339397        fibril_mutex_unlock(&win->guard);
    340 
     398       
    341399        /* Inform compositor about new surface. */
    342         rc = win_resize(win->osess,
    343                 width, height, surface_direct_access(new_surface));
    344 
     400        int rc = win_resize(win->osess, offset_x, offset_y, width, height,
     401            placement_flags, surface_direct_access(new_surface));
     402       
    345403        if (rc != EOK) {
    346404                /* Rollback to old surface. Reverse all changes. */
    347 
     405               
    348406                sysarg_t old_width = 0;
    349407                sysarg_t old_height = 0;
    350                 if (old_surface) {
     408                if (old_surface)
    351409                        surface_get_resolution(old_surface, &old_width, &old_height);
    352                 }
    353 
     410               
    354411                fibril_mutex_lock(&win->guard);
    355412                new_surface = win->surface;
    356413                win->surface = old_surface;
    357414                fibril_mutex_unlock(&win->guard);
    358 
     415               
    359416                win->root.rearrange(&win->root, 0, 0, old_width, old_height);
    360417               
     
    364421                        fibril_mutex_unlock(&win->guard);
    365422                }
    366 
     423               
    367424                surface_destroy(new_surface);
    368                 return;
    369         }
    370 
    371         /* Finally deallocate old surface. */
    372         if (old_surface) {
    373                 surface_destroy(old_surface);
     425        } else {
     426                /* Deallocate old surface. */
     427                if (old_surface)
     428                        surface_destroy(old_surface);
    374429        }
    375430}
     
    453508                        break;
    454509                case ET_SIGNAL_EVENT:
    455                         handle_signal_event(win, event->data.sig);
     510                        handle_signal_event(win, event->data.signal);
    456511                        break;
    457512                case ET_WINDOW_RESIZE:
    458                         handle_resize(win, event->data.rsz.width, event->data.rsz.height);
     513                        handle_resize(win, event->data.resize.offset_x,
     514                            event->data.resize.offset_y, event->data.resize.width,
     515                            event->data.resize.height, event->data.resize.placement_flags);
    459516                        break;
    460517                case ET_WINDOW_FOCUS:
     
    530587
    531588window_t *window_open(const char *winreg, bool is_main, bool is_decorated,
    532     const char *caption, sysarg_t x_offset, sysarg_t y_offset)
    533 {
    534         int rc;
    535 
     589    const char *caption)
     590{
    536591        window_t *win = (window_t *) malloc(sizeof(window_t));
    537         if (!win) {
     592        if (!win)
    538593                return NULL;
    539         }
    540 
     594       
    541595        win->is_main = is_main;
    542596        win->is_decorated = is_decorated;
     
    544598        prodcons_initialize(&win->events);
    545599        fibril_mutex_initialize(&win->guard);
     600       
    546601        widget_init(&win->root, NULL);
    547602        win->root.window = win;
     
    555610        win->focus = NULL;
    556611        win->surface = NULL;
    557 
     612       
    558613        service_id_t reg_dsid;
    559         async_sess_t *reg_sess;
    560 
    561         rc = loc_service_get_id(winreg, &reg_dsid, 0);
     614        int rc = loc_service_get_id(winreg, &reg_dsid, 0);
    562615        if (rc != EOK) {
    563616                free(win);
    564617                return NULL;
    565618        }
    566 
    567         reg_sess = loc_service_connect(EXCHANGE_SERIALIZE, reg_dsid, 0);
     619       
     620        async_sess_t *reg_sess = loc_service_connect(EXCHANGE_SERIALIZE,
     621            reg_dsid, 0);
    568622        if (reg_sess == NULL) {
    569623                free(win);
    570624                return NULL;
    571625        }
    572 
     626       
    573627        service_id_t in_dsid;
    574628        service_id_t out_dsid;
    575        
    576         rc = win_register(reg_sess, &in_dsid, &out_dsid, x_offset, y_offset);
     629        rc = win_register(reg_sess, &in_dsid, &out_dsid);
    577630        async_hangup(reg_sess);
    578631        if (rc != EOK) {
     
    580633                return NULL;
    581634        }
    582 
     635       
    583636        win->osess = loc_service_connect(EXCHANGE_SERIALIZE, out_dsid, 0);
    584637        if (win->osess == NULL) {
     
    586639                return NULL;
    587640        }
    588 
     641       
    589642        win->isess = loc_service_connect(EXCHANGE_SERIALIZE, in_dsid, 0);
    590643        if (win->isess == NULL) {
     
    593646                return NULL;
    594647        }
    595 
    596         if (caption == NULL) {
     648       
     649        if (caption == NULL)
    597650                win->caption = NULL;
    598         } else {
     651        else
    599652                win->caption = str_dup(caption);
    600         }
    601 
     653       
    602654        return win;
    603655}
    604656
    605 void window_resize(window_t *win, sysarg_t width, sysarg_t height)
     657void window_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y,
     658    sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags)
    606659{
    607660        window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
     
    609662                link_initialize(&event->link);
    610663                event->type = ET_WINDOW_RESIZE;
    611                 event->data.rsz.width = width;
    612                 event->data.rsz.height = height;
     664                event->data.resize.offset_x = offset_x;
     665                event->data.resize.offset_y = offset_y;
     666                event->data.resize.width = width;
     667                event->data.resize.height = height;
     668                event->data.resize.placement_flags = placement_flags;
    613669                prodcons_produce(&win->events, &event->link);
    614670        }
  • uspace/lib/gui/window.h

    rfddffb2 r19b3cc6  
    6666 * If the window is declared as main, its closure causes termination of the
    6767 * whole application. Note that opened window does not have any surface yet. */
    68 extern window_t *window_open(const char *, bool, bool, const char *, sysarg_t,
    69     sysarg_t);
     68extern window_t *window_open(const char *, bool, bool, const char *);
    7069
    7170/**
     
    7473 * and to paint themselves on the new surface (top-bottom order). Should be
    7574 * called also after opening new window to obtain surface. */
    76 extern void window_resize(window_t *, sysarg_t, sysarg_t);
     75extern void window_resize(window_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     76    window_placement_flags_t);
    7777
    7878/**
Note: See TracChangeset for help on using the changeset viewer.