Changeset aa2b32c in mainline


Ignore:
Timestamp:
2013-04-29T12:44:05Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a269d05
Parents:
06b0211b (diff), 9e7898e (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 mainline changes

Files:
4 added
2 deleted
39 edited
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/Makefile.inc

    r06b0211b raa2b32c  
    6666        GENARCH_SOURCES += \
    6767                genarch/src/fb/font-8x16.c \
    68                 genarch/src/fb/logo-196x66.c \
    6968                genarch/src/fb/fb.c \
    7069                genarch/src/fb/bfb.c
  • kernel/genarch/src/fb/fb.c

    r06b0211b raa2b32c  
    3535
    3636#include <genarch/fb/font-8x16.h>
    37 #include <genarch/fb/logo-196x66.h>
    3837#include <genarch/fb/fb.h>
    3938#include <console/chardev.h>
     
    5352#include <byteorder.h>
    5453
    55 #define BG_COLOR     0x000080
    56 #define FG_COLOR     0xffff00
     54#define BG_COLOR     0x001620
     55#define FG_COLOR     0xf3cf65
    5756#define INV_COLOR    0xaaaaaa
    5857
     
    9392        unsigned int yres;
    9493       
    95         unsigned int ylogo;
    96         unsigned int ytrim;
    9794        unsigned int rowtrim;
    9895       
     
    213210}
    214211
    215 /** Hide logo and refresh screen
    216  *
    217  */
    218 static void logo_hide(fb_instance_t *instance)
    219 {
    220         instance->ylogo = 0;
    221         instance->ytrim = instance->yres;
    222         instance->rowtrim = instance->rows;
    223        
    224         if ((!instance->parea.mapped) || (console_override))
    225                 fb_redraw_internal(instance);
    226 }
    227 
    228212/** Draw character at given position
    229213 *
     
    236220        unsigned int yd;
    237221       
    238         if (y >= instance->ytrim)
    239                 logo_hide(instance);
    240        
    241222        if (!overlay)
    242223                instance->backbuf[BB_POS(instance, col, row)] = glyph;
     
    244225        if ((!instance->parea.mapped) || (console_override)) {
    245226                for (yd = 0; yd < FONT_SCANLINES; yd++)
    246                         memcpy(&instance->addr[FB_POS(instance, x, y + yd + instance->ylogo)],
     227                        memcpy(&instance->addr[FB_POS(instance, x, y + yd)],
    247228                            &instance->glyphs[GLYPH_POS(instance, glyph, yd)],
    248229                            instance->glyphscanline);
     
    256237static void screen_scroll(fb_instance_t *instance)
    257238{
    258         if (instance->ylogo > 0) {
    259                 logo_hide(instance);
    260                 return;
    261         }
    262        
    263239        if ((!instance->parea.mapped) || (console_override)) {
    264240                unsigned int row;
     
    412388static void fb_redraw_internal(fb_instance_t *instance)
    413389{
    414         if (instance->ylogo > 0) {
    415                 unsigned int y;
    416                
    417                 for (y = 0; y < LOGO_HEIGHT; y++) {
    418                         unsigned int x;
    419                        
    420                         for (x = 0; x < instance->xres; x++)
    421                                 instance->rgb_conv(&instance->addr[FB_POS(instance, x, y)],
    422                                     (x < LOGO_WIDTH) ?
    423                                     fb_logo[y * LOGO_WIDTH + x] :
    424                                     LOGO_COLOR);
    425                 }
    426         }
    427        
    428390        unsigned int row;
    429391       
    430392        for (row = 0; row < instance->rowtrim; row++) {
    431                 unsigned int y = instance->ylogo + ROW2Y(row);
     393                unsigned int y = ROW2Y(row);
    432394                unsigned int yd;
    433395               
     
    452414                    (instance->xres - COL2X(instance->cols)) * instance->pixelbytes;
    453415               
    454                 for (y = instance->ylogo; y < instance->yres; y++)
     416                for (y = 0; y < instance->yres; y++)
    455417                        memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)],
    456418                            instance->bgscan, size);
    457419        }
    458420       
    459         if (ROW2Y(instance->rowtrim) + instance->ylogo < instance->yres) {
     421        if (ROW2Y(instance->rowtrim) < instance->yres) {
    460422                unsigned int y;
    461423               
    462                 for (y = ROW2Y(instance->rowtrim) + instance->ylogo;
    463                     y < instance->yres; y++)
     424                for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++)
    464425                        memcpy(&instance->addr[FB_POS(instance, 0, y)],
    465426                            instance->bgscan, instance->bgscanbytes);
     
    567528        instance->rows = Y2ROW(instance->yres);
    568529       
    569         if (instance->yres > LOGO_HEIGHT) {
    570                 instance->ylogo = LOGO_HEIGHT;
    571                 instance->rowtrim = instance->rows - Y2ROW(instance->ylogo);
    572                 if (instance->ylogo % FONT_SCANLINES > 0)
    573                         instance->rowtrim--;
    574                 instance->ytrim = ROW2Y(instance->rowtrim);
    575         } else {
    576                 instance->ylogo = 0;
    577                 instance->ytrim = instance->yres;
    578                 instance->rowtrim = instance->rows;
    579         }
     530        instance->rowtrim = instance->rows;
    580531       
    581532        instance->glyphscanline = FONT_WIDTH * instance->pixelbytes;
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r06b0211b raa2b32c  
    117117static void waitkey()
    118118{
    119         kbd_event_t ev;
     119        cons_event_t ev;
     120        kbd_event_t *kev;
    120121       
    121122        while (true) {
    122                 if (!console_get_kbd_event(console, &ev)) {
     123                if (!console_get_event(console, &ev)) {
    123124                        return;
    124125                }
    125                 if (ev.type == KEY_PRESS) {
    126                         if (ev.key == KC_ESCAPE || ev.key == KC_Q) {
     126                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     127                        kev = &ev.ev.key;
     128                       
     129                        if (kev->key == KC_ESCAPE || kev->key == KC_Q) {
    127130                                should_quit = true;
    128131                                return;
    129132                        }
    130                         if (ev.key == KC_C) {
     133                        if (kev->key == KC_C) {
    131134                                paging_enabled = false;
    132135                                return;
    133136                        }
    134                         if (ev.key == KC_ENTER || ev.key == KC_SPACE ||
    135                             ev.key == KC_PAGE_DOWN) {
     137                        if (kev->key == KC_ENTER || kev->key == KC_SPACE ||
     138                            kev->key == KC_PAGE_DOWN) {
    136139                                return;
    137140                        }
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r06b0211b raa2b32c  
    152152
    153153        while (true) {
    154                 kbd_event_t ev;
     154                cons_event_t ev;
    155155                console_flush(con);
    156                 console_get_kbd_event(con, &ev);
    157                 if ((ev.type != KEY_PRESS)
    158                     || (ev.mods & (KM_CTRL | KM_ALT)) != 0) {
     156                console_get_event(con, &ev);
     157                if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS ||
     158                    (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) {
    159159                        continue;
    160160                }
    161161
    162                 switch(ev.key) {
     162                switch(ev.ev.key.key) {
    163163                case KC_Y:
    164164                        printf("y\n");
  • uspace/app/edit/edit.c

    r06b0211b raa2b32c  
    8080        tag_t sel_start;
    8181
     82        /** Active keyboard modifiers */
     83        keymod_t keymod;
     84
    8285        /**
    8386         * Ideal column where the caret should try to get. This is used
     
    119122static void cursor_setvis(bool visible);
    120123
     124static void key_handle_press(kbd_event_t *ev);
    121125static void key_handle_unmod(kbd_event_t const *ev);
    122126static void key_handle_ctrl(kbd_event_t const *ev);
     
    124128static void key_handle_shift_ctrl(kbd_event_t const *ev);
    125129static void key_handle_movement(unsigned int key, bool shift);
     130
     131static void pos_handle(pos_event_t *ev);
    126132
    127133static int file_save(char const *fname);
     
    182188int main(int argc, char *argv[])
    183189{
    184         kbd_event_t ev;
     190        cons_event_t ev;
    185191        bool new_file;
    186192        int rc;
     
    245251
    246252        while (!done) {
    247                 console_get_kbd_event(con, &ev);
     253                console_get_event(con, &ev);
    248254                pane.rflags = 0;
    249255
    250                 if (ev.type == KEY_PRESS) {
    251                         /* Handle key press. */
    252                         if (((ev.mods & KM_ALT) == 0) &&
    253                             ((ev.mods & KM_SHIFT) == 0) &&
    254                              (ev.mods & KM_CTRL) != 0) {
    255                                 key_handle_ctrl(&ev);
    256                         } else if (((ev.mods & KM_ALT) == 0) &&
    257                             ((ev.mods & KM_CTRL) == 0) &&
    258                              (ev.mods & KM_SHIFT) != 0) {
    259                                 key_handle_shift(&ev);
    260                         } else if (((ev.mods & KM_ALT) == 0) &&
    261                             ((ev.mods & KM_CTRL) != 0) &&
    262                              (ev.mods & KM_SHIFT) != 0) {
    263                                 key_handle_shift_ctrl(&ev);
    264                         } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
    265                                 key_handle_unmod(&ev);
    266                         }
     256                switch (ev.type) {
     257                case CEV_KEY:
     258                        pane.keymod = ev.ev.key.mods;
     259                        if (ev.ev.key.type == KEY_PRESS)
     260                                key_handle_press(&ev.ev.key);
     261                        break;
     262                case CEV_POS:
     263                        pos_handle(&ev.ev.pos);
     264                        break;
    267265                }
    268266
     
    286284
    287285        return 0;
     286}
     287
     288/* Handle key press. */
     289static void key_handle_press(kbd_event_t *ev)
     290{
     291        if (((ev->mods & KM_ALT) == 0) &&
     292            ((ev->mods & KM_SHIFT) == 0) &&
     293             (ev->mods & KM_CTRL) != 0) {
     294                key_handle_ctrl(ev);
     295        } else if (((ev->mods & KM_ALT) == 0) &&
     296            ((ev->mods & KM_CTRL) == 0) &&
     297             (ev->mods & KM_SHIFT) != 0) {
     298                key_handle_shift(ev);
     299        } else if (((ev->mods & KM_ALT) == 0) &&
     300            ((ev->mods & KM_CTRL) != 0) &&
     301             (ev->mods & KM_SHIFT) != 0) {
     302                key_handle_shift_ctrl(ev);
     303        } else if ((ev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
     304                key_handle_unmod(ev);
     305        }
    288306}
    289307
     
    462480}
    463481
     482static void pos_handle(pos_event_t *ev)
     483{
     484        coord_t bc;
     485        spt_t pt;
     486        bool select;
     487
     488        if (ev->type == POS_PRESS && ev->vpos < (unsigned)pane.rows) {
     489                bc.row = pane.sh_row + ev->vpos;
     490                bc.column = pane.sh_column + ev->hpos;
     491                sheet_get_cell_pt(doc.sh, &bc, dir_before, &pt);
     492
     493                select = (pane.keymod & KM_SHIFT) != 0;
     494
     495                caret_move(pt, select, true);
     496        }
     497}
     498
    464499/** Move caret while preserving or resetting selection. */
    465500static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column)
     
    592627static char *prompt(char const *prompt, char const *init_value)
    593628{
    594         kbd_event_t ev;
     629        cons_event_t ev;
     630        kbd_event_t *kev;
    595631        char *str;
    596632        wchar_t buffer[INFNAME_MAX_LEN + 1];
     
    612648
    613649        while (!done) {
    614                 console_get_kbd_event(con, &ev);
    615 
    616                 if (ev.type == KEY_PRESS) {
     650                console_get_event(con, &ev);
     651
     652                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     653                        kev = &ev.ev.key;
     654
    617655                        /* Handle key press. */
    618                         if (((ev.mods & KM_ALT) == 0) &&
    619                              (ev.mods & KM_CTRL) != 0) {
     656                        if (((kev->mods & KM_ALT) == 0) &&
     657                             (kev->mods & KM_CTRL) != 0) {
    620658                                ;
    621                         } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) {
    622                                 switch (ev.key) {
     659                        } else if ((kev->mods & (KM_CTRL | KM_ALT)) == 0) {
     660                                switch (kev->key) {
    623661                                case KC_ESCAPE:
    624662                                        return NULL;
     
    634672                                        break;
    635673                                default:
    636                                         if (ev.c >= 32 && nc < max_len) {
    637                                                 putchar(ev.c);
     674                                        if (kev->c >= 32 && nc < max_len) {
     675                                                putchar(kev->c);
    638676                                                console_flush(con);
    639                                                 buffer[nc++] = ev.c;
     677                                                buffer[nc++] = kev->c;
    640678                                        }
    641679                                        break;
  • uspace/app/mkbd/main.c

    r06b0211b raa2b32c  
    178178
    179179        while (1) {
    180                 kbd_event_t ev;
    181                 bool ok = console_get_kbd_event(con, &ev);
     180                cons_event_t ev;
     181                bool ok = console_get_event(con, &ev);
    182182                if (!ok) {
    183183                        printf("Connection with console broken: %s.\n",
     
    186186                }
    187187
    188                 if (ev.key == KC_ESCAPE) {
     188                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
     189                    ev.ev.key.key == KC_ESCAPE) {
    189190                        break;
    190191                }
  • uspace/app/msim/arch_helenos/input.c

    r06b0211b raa2b32c  
    9191bool stdin_poll(char *key)
    9292{
    93         kbd_event_t ev;
     93        cons_event_t ev;
    9494        suseconds_t timeout = 0;
    9595        errno = EOK;
    9696        console_flush(input_prompt->console);
    97         bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
     97        bool has_input = console_get_event_timeout(input_prompt->console, &ev, &timeout);
    9898        if (!has_input) {
    9999                return false;
    100100        }
    101101
    102         if (ev.type != KEY_PRESS)
     102        if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS)
    103103                return false;
    104104
    105         *key = ev.c;
     105        *key = ev.ev.key.c;
    106106
    107107        return true;
  • uspace/app/nterm/nterm.c

    r06b0211b raa2b32c  
    109109int main(int argc, char *argv[])
    110110{
    111         kbd_event_t ev;
     111        cons_event_t ev;
    112112        int rc;
    113113
     
    129129        done = false;
    130130        while (!done) {
    131                 console_get_kbd_event(con, &ev);
    132                 if (ev.type == KEY_PRESS)
    133                         key_handle(&ev);
     131                console_get_event(con, &ev);
     132                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS)
     133                        key_handle(&ev.ev.key);
    134134        }
    135135
  • uspace/app/ping/ping.c

    r06b0211b raa2b32c  
    188188{
    189189        console_ctrl_t *con;
    190         kbd_event_t ev;
     190        cons_event_t ev;
    191191
    192192        con = console_init(stdin, stdout);
     
    194194
    195195        while (true) {
    196                 if (!console_get_kbd_event(con, &ev))
     196                if (!console_get_event(con, &ev))
    197197                        break;
    198198
    199                 if (ev.type == KEY_PRESS && (ev.mods & (KM_ALT | KM_SHIFT)) ==
    200                     0 && (ev.mods & KM_CTRL) != 0) {
     199                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
     200                    (ev.ev.key.mods & (KM_ALT | KM_SHIFT)) ==
     201                    0 && (ev.ev.key.mods & KM_CTRL) != 0) {
    201202                        /* Ctrl+key */
    202                         if (ev.key == KC_Q) {
     203                        if (ev.ev.key.key == KC_Q) {
    203204                                ping_signal_done();
    204205                                return 0;
  • uspace/app/taskdump/symtab.c

    r06b0211b raa2b32c  
    267267                        continue;
    268268
    269                 if (best_name == NULL || (saddr <= addr && saddr > best_addr)) {
     269                if (saddr <= addr && (best_name == NULL || saddr > best_addr)) {
    270270                        best_name = sname;
    271271                        best_addr = saddr;
  • uspace/app/tester/ipc/starve.c

    r06b0211b raa2b32c  
    6262                        break;
    6363               
    64                 kbd_event_t ev;
     64                cons_event_t ev;
    6565                suseconds_t timeout = 0;
    66                 bool has_event = console_get_kbd_event_timeout(console, &ev, &timeout);
    67                 if (has_event && (ev.type == KEY_PRESS)) {
    68                         TPRINTF("Key %d pressed, terminating.\n", ev.key);
     66                bool has_event = console_get_event_timeout(console, &ev, &timeout);
     67                if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
     68                        TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key);
    6969                        break;
    7070                }
  • uspace/app/tetris/scores.c

    r06b0211b raa2b32c  
    125125        int j;
    126126        size_t off;
    127         kbd_event_t ev;
     127        cons_event_t ev;
     128        kbd_event_t *kev;
    128129       
    129130        clear_screen();
     
    141142        while (1) {
    142143                console_flush(console);
    143                 if (!console_get_kbd_event(console, &ev))
     144                if (!console_get_event(console, &ev))
    144145                        exit(1);
    145146               
    146                 if (ev.type == KEY_RELEASE)
     147                if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE)
    147148                        continue;
    148149               
    149                 if (ev.key == KC_ENTER || ev.key == KC_NENTER)
     150                kev = &ev.ev.key;
     151               
     152                if (kev->key == KC_ENTER || kev->key == KC_NENTER)
    150153                        break;
    151154               
    152                 if (ev.key == KC_BACKSPACE) {
     155                if (kev->key == KC_BACKSPACE) {
    153156                        if (i > 0) {
    154157                                wchar_t uc;
     
    166169                                scores[NUMSPOTS - 1].hs_name[off] = '\0';
    167170                        }
    168                 } else if (ev.c != '\0') {
     171                } else if (kev->c != '\0') {
    169172                        if (i < (MAXLOGNAME - 1)) {
    170                                 if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
     173                                if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name,
    171174                                    &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
    172175                                        ++i;
  • uspace/app/tetris/screen.c

    r06b0211b raa2b32c  
    344344       
    345345        while (timeout > 0) {
    346                 kbd_event_t event;
    347                
    348                 if (!console_get_kbd_event_timeout(console, &event, &timeout))
     346                cons_event_t event;
     347               
     348                if (!console_get_event_timeout(console, &event, &timeout))
    349349                        break;
    350350        }
     
    376376       
    377377        while (c == 0) {
    378                 kbd_event_t event;
    379                
    380                 if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     378                cons_event_t event;
     379               
     380                if (!console_get_event_timeout(console, &event, &timeleft)) {
    381381                        timeleft = 0;
    382382                        return -1;
    383383                }
    384384               
    385                 if (event.type == KEY_PRESS)
    386                         c = event.c;
     385                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     386                        c = event.ev.key.c;
    387387        }
    388388       
     
    398398       
    399399        while (c == 0) {
    400                 kbd_event_t event;
    401                
    402                 if (!console_get_kbd_event(console, &event))
     400                cons_event_t event;
     401               
     402                if (!console_get_event(console, &event))
    403403                        return -1;
    404404               
    405                 if (event.type == KEY_PRESS)
    406                         c = event.c;
     405                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     406                        c = event.ev.key.c;
    407407        }
    408408       
  • uspace/app/top/screen.c

    r06b0211b raa2b32c  
    556556       
    557557        while (c == 0) {
    558                 kbd_event_t event;
     558                cons_event_t event;
    559559               
    560560                warning_timeleft -= timeleft;
    561                 if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     561                if (!console_get_event_timeout(console, &event, &timeleft)) {
    562562                        timeleft = 0;
    563563                        return -1;
     
    565565                warning_timeleft += timeleft;
    566566               
    567                 if (event.type == KEY_PRESS)
    568                         c = event.c;
     567                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     568                        c = event.ev.key.c;
    569569        }
    570570       
  • uspace/app/trace/trace.c

    r06b0211b raa2b32c  
    565565static int cev_fibril(void *arg)
    566566{
     567        cons_event_t event;
     568
    567569        (void) arg;
    568570       
     
    575577                fibril_mutex_unlock(&state_lock);
    576578               
    577                 if (!console_get_kbd_event(console, &cev))
     579                if (!console_get_event(console, &event))
    578580                        return -1;
    579581               
    580                 fibril_mutex_lock(&state_lock);
    581                 cev_valid = true;
    582                 fibril_condvar_broadcast(&state_cv);
    583                 fibril_mutex_unlock(&state_lock);
     582                if (event.type == CEV_KEY) {
     583                        fibril_mutex_lock(&state_lock);
     584                        cev = event.ev.key;
     585                        cev_valid = true;
     586                        fibril_condvar_broadcast(&state_cv);
     587                        fibril_mutex_unlock(&state_lock);
     588                }
    584589        }
    585590}
  • uspace/app/vdemo/vdemo.c

    r06b0211b raa2b32c  
    141141                    lbl_action->cancel);
    142142
    143                 grid->add(grid, &lbl_action->label.widget, 0, 0, 1, 2);
    144                 grid->add(grid, &btn_confirm->widget, 1, 0, 1, 1);
     143                grid->add(grid, &lbl_action->label.widget, 0, 0, 2, 1);
     144                grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1);
    145145                grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1);
    146                 window_resize(main_window, 200, 70);
     146                window_resize(main_window, 200, 76);
    147147
    148148                window_exec(main_window);
  • uspace/app/vlaunch/Makefile

    r06b0211b raa2b32c  
    3535
    3636SOURCES = \
    37         vlaunch.c
     37        vlaunch.c \
     38        images.c
     39
     40IMAGES = \
     41        gfx/helenos.tga
     42
     43PRE_DEPEND = images.c images.h
     44EXTRA_CLEAN = images.c images.h
    3845
    3946include $(USPACE_PREFIX)/Makefile.common
     47
     48images.c images.h: $(IMAGES)
     49        $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES $^
  • uspace/app/vlaunch/vlaunch.c

    r06b0211b raa2b32c  
    4646#include <button.h>
    4747#include <label.h>
     48#include <canvas.h>
    4849
    49 #define NAME "vlaunch"
     50#include <surface.h>
     51#include <source.h>
     52#include <drawctx.h>
     53#include <codec/tga.h>
     54
     55#include "images.h"
     56
     57#define NAME  "vlaunch"
     58
     59#define LOGO_WIDTH   196
     60#define LOGO_HEIGHT  66
    5061
    5162static char *winreg = NULL;
     
    97108        }
    98109       
     110        surface_t *logo = decode_tga((void *) helenos_tga, helenos_tga_size, 0);
     111        if (!logo) {
     112                printf("Unable to decode logo.\n");
     113                return 1;
     114        }
     115       
    99116        winreg = argv[1];
    100117        window_t *main_window = window_open(argv[1], true, true, "vlaunch", 0, 0);
     
    104121        }
    105122       
    106         pixel_t grd_bg = PIXEL(255, 240, 240, 240);
     123        pixel_t grd_bg = PIXEL(255, 255, 255, 255);
    107124        pixel_t btn_bg = PIXEL(255, 0, 0, 0);
    108125        pixel_t btn_fg = PIXEL(255, 240, 240, 240);
    109         pixel_t lbl_bg = PIXEL(255, 240, 240, 240);
     126        pixel_t lbl_bg = PIXEL(255, 255, 255, 255);
    110127        pixel_t lbl_fg = PIXEL(255, 0, 0, 0);
    111128       
     129        canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT,
     130            logo);
    112131        label_t *lbl_caption = create_label(NULL, "Launch application:", 16,
    113132            lbl_bg, lbl_fg);
     
    118137        button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg,
    119138            btn_fg);
    120         grid_t *grid = create_grid(window_root(main_window), 4, 1, grd_bg);
     139        grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg);
    121140       
    122         if ((!lbl_caption) || (!btn_vterm) || (!btn_vdemo) ||
    123             (!btn_vlaunch) || (!grid)) {
     141        if ((!logo_canvas) || (!lbl_caption) || (!btn_vterm) ||
     142            (!btn_vdemo) || (!btn_vlaunch) || (!grid)) {
    124143                window_close(main_window);
    125144                printf("Cannot create widgets.\n");
     
    131150        sig_connect(&btn_vlaunch->clicked, NULL, on_vlaunch);
    132151       
    133         grid->add(grid, &lbl_caption->widget, 0, 0, 1, 1);
    134         grid->add(grid, &btn_vterm->widget, 1, 0, 1, 1);
    135         grid->add(grid, &btn_vdemo->widget, 2, 0, 1, 1);
    136         grid->add(grid, &btn_vlaunch->widget, 3, 0, 1, 1);
     152        grid->add(grid, &logo_canvas->widget, 0, 0, 1, 1);
     153        grid->add(grid, &lbl_caption->widget, 0, 1, 1, 1);
     154        grid->add(grid, &btn_vterm->widget, 0, 2, 1, 1);
     155        grid->add(grid, &btn_vdemo->widget, 0, 3, 1, 1);
     156        grid->add(grid, &btn_vlaunch->widget, 0, 4, 1, 1);
    137157       
    138         window_resize(main_window, 180, 130);
     158        window_resize(main_window, 210, 130 + LOGO_HEIGHT);
    139159        window_exec(main_window);
     160       
    140161        task_retval(0);
    141162        async_manager();
  • uspace/dist/src/c/demos/tetris/scores.c

    r06b0211b raa2b32c  
    125125        int j;
    126126        size_t off;
    127         kbd_event_t ev;
     127        cons_event_t ev;
     128        kbd_event_t *kev;
    128129       
    129130        clear_screen();
     
    141142        while (1) {
    142143                console_flush(console);
    143                 if (!console_get_kbd_event(console, &ev))
     144                if (!console_get_event(console, &ev))
    144145                        exit(1);
    145146               
    146                 if (ev.type == KEY_RELEASE)
     147                if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE)
    147148                        continue;
    148149               
    149                 if (ev.key == KC_ENTER || ev.key == KC_NENTER)
     150                kev = &ev.ev.key;
     151               
     152                if (kev->key == KC_ENTER || kev->key == KC_NENTER)
    150153                        break;
    151154               
    152                 if (ev.key == KC_BACKSPACE) {
     155                if (kev->key == KC_BACKSPACE) {
    153156                        if (i > 0) {
    154157                                wchar_t uc;
     
    166169                                scores[NUMSPOTS - 1].hs_name[off] = '\0';
    167170                        }
    168                 } else if (ev.c != '\0') {
     171                } else if (kev->c != '\0') {
    169172                        if (i < (MAXLOGNAME - 1)) {
    170                                 if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
     173                                if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name,
    171174                                    &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
    172175                                        ++i;
  • uspace/dist/src/c/demos/top/screen.c

    r06b0211b raa2b32c  
    553553       
    554554        while (c == 0) {
    555                 kbd_event_t event;
    556                
    557                 if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     555                cons_event_t event;
     556               
     557                if (!console_get_event_timeout(console, &event, &timeleft)) {
    558558                        timeleft = 0;
    559559                        return -1;
    560560                }
    561561               
    562                 if (event.type == KEY_PRESS)
    563                         c = event.c;
     562                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
     563                        c = event.ev.key.c;
    564564        }
    565565       
  • uspace/drv/char/ns8250/ns8250.c

    r06b0211b raa2b32c  
    160160        /** I/O registers **/
    161161        ns8250_regs_t *regs;
    162         /** Is there any client conntected to the device? */
     162        /** Is there any client connected to the device? */
    163163        bool client_connected;
    164164        /** The irq assigned to this device. */
     
    168168        /** The i/o port used to access the serial ports registers. */
    169169        ioport8_t *port;
    170         /** The buffer for incomming data. */
     170        /** The buffer for incoming data. */
    171171        cyclic_buffer_t input_buffer;
    172172        /** The fibril mutex for synchronizing the access to the device. */
     
    190190}
    191191
    192 /** Find out if there is some incomming data available on the serial port.
     192/** Find out if there is some incoming data available on the serial port.
    193193 *
    194194 * @param port          The base address of the serial port device's ports.
  • uspace/lib/c/generic/io/con_srv.c

    r06b0211b raa2b32c  
    3535 */
    3636#include <errno.h>
     37#include <io/cons_event.h>
    3738#include <ipc/console.h>
    3839#include <stdlib.h>
     
    4041
    4142#include <io/con_srv.h>
     43
     44static int console_ev_encode(cons_event_t *event, ipc_call_t *call)
     45{
     46        IPC_SET_ARG1(*call, event->type);
     47
     48        switch (event->type) {
     49        case CEV_KEY:
     50                IPC_SET_ARG2(*call, event->ev.key.type);
     51                IPC_SET_ARG3(*call, event->ev.key.key);
     52                IPC_SET_ARG4(*call, event->ev.key.mods);
     53                IPC_SET_ARG5(*call, event->ev.key.c);
     54                break;
     55        case CEV_POS:
     56                IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff));
     57                IPC_SET_ARG3(*call, event->ev.pos.btn_num);
     58                IPC_SET_ARG4(*call, event->ev.pos.hpos);
     59                IPC_SET_ARG5(*call, event->ev.pos.vpos);
     60                break;
     61        default:
     62                return EIO;
     63        }
     64
     65        return EOK;
     66}
    4267
    4368static void con_read_srv(con_srv_t *srv, ipc_callid_t callid,
     
    273298{
    274299        int rc;
    275         kbd_event_t event;
     300        cons_event_t event;
     301        ipc_call_t result;
    276302
    277303        if (srv->srvs->ops->get_event == NULL) {
     
    281307
    282308        rc = srv->srvs->ops->get_event(srv, &event);
    283         async_answer_4(callid, rc, event.type, event.key, event.mods, event.c);
     309        if (rc != EOK) {
     310                async_answer_0(callid, rc);
     311                return;
     312        }
     313
     314        rc = console_ev_encode(&event, &result);
     315        if (rc != EOK) {
     316                async_answer_0(callid, rc);
     317                return;
     318        }
     319
     320        async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result),
     321            IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result));
    284322}
    285323
  • uspace/lib/c/generic/io/console.c

    r06b0211b raa2b32c  
    154154}
    155155
    156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)
     156static int console_ev_decode(ipc_call_t *call, cons_event_t *event)
     157{
     158        event->type = IPC_GET_ARG1(*call);
     159
     160        switch (event->type) {
     161        case CEV_KEY:
     162                event->ev.key.type = IPC_GET_ARG2(*call);
     163                event->ev.key.key = IPC_GET_ARG3(*call);
     164                event->ev.key.mods = IPC_GET_ARG4(*call);
     165                event->ev.key.c = IPC_GET_ARG5(*call);
     166                break;
     167        case CEV_POS:
     168                event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16;
     169                event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff;
     170                event->ev.pos.btn_num = IPC_GET_ARG3(*call);
     171                event->ev.pos.hpos = IPC_GET_ARG4(*call);
     172                event->ev.pos.vpos = IPC_GET_ARG5(*call);
     173                break;
     174        default:
     175                return EIO;
     176        }
     177
     178        return EOK;
     179}
     180
     181bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
    157182{
    158183        if (ctrl->input_aid == 0) {
    159                 sysarg_t type;
    160                 sysarg_t key;
    161                 sysarg_t mods;
    162                 sysarg_t c;
     184                ipc_call_t result;
    163185               
    164186                async_exch_t *exch = async_exchange_begin(ctrl->input_sess);
    165                 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
     187                aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result);
    166188                async_exchange_end(exch);
     189               
     190                sysarg_t rc;
     191                async_wait_for(aid, &rc);
    167192               
    168193                if (rc != EOK) {
     
    171196                }
    172197               
    173                 event->type = type;
    174                 event->key = key;
    175                 event->mods = mods;
    176                 event->c = c;
     198                rc = console_ev_decode(&result, event);
     199                if (rc != EOK) {
     200                        errno = rc;
     201                        return false;
     202                }
    177203        } else {
    178204                sysarg_t retval;
     
    186212                }
    187213               
    188                 event->type = IPC_GET_ARG1(ctrl->input_call);
    189                 event->key = IPC_GET_ARG2(ctrl->input_call);
    190                 event->mods = IPC_GET_ARG3(ctrl->input_call);
    191                 event->c = IPC_GET_ARG4(ctrl->input_call);
     214                int rc = console_ev_decode(&ctrl->input_call, event);
     215                if (rc != EOK) {
     216                        errno = rc;
     217                        return false;
     218                }
    192219        }
    193220       
     
    195222}
    196223
    197 bool console_get_kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,
     224bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
    198225    suseconds_t *timeout)
    199226{
     
    223250        }
    224251       
    225         event->type = IPC_GET_ARG1(ctrl->input_call);
    226         event->key = IPC_GET_ARG2(ctrl->input_call);
    227         event->mods = IPC_GET_ARG3(ctrl->input_call);
    228         event->c = IPC_GET_ARG4(ctrl->input_call);
     252        rc = console_ev_decode(&ctrl->input_call, event);
     253        if (rc != EOK) {
     254                errno = rc;
     255                return false;
     256        }
    229257       
    230258        /* Update timeout */
  • uspace/lib/c/include/io/con_srv.h

    r06b0211b raa2b32c  
    4141#include <io/color.h>
    4242#include <io/concaps.h>
    43 #include <io/kbd_event.h>
     43#include <io/cons_event.h>
    4444#include <io/pixel.h>
    4545#include <io/style.h>
     
    8282        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8383        void (*set_cursor_visibility)(con_srv_t *, bool);
    84         int (*get_event)(con_srv_t *, kbd_event_t *);
     84        int (*get_event)(con_srv_t *, cons_event_t *);
    8585} con_ops_t;
    8686
  • uspace/lib/c/include/io/console.h

    r06b0211b raa2b32c  
    3939#include <io/concaps.h>
    4040#include <io/kbd_event.h>
     41#include <io/cons_event.h>
    4142#include <io/keycode.h>
    4243#include <async.h>
     
    8283extern void console_cursor_visibility(console_ctrl_t *, bool);
    8384extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
    84 extern bool console_get_kbd_event(console_ctrl_t *, kbd_event_t *);
    85 extern bool console_get_kbd_event_timeout(console_ctrl_t *, kbd_event_t *,
     85extern bool console_get_event(console_ctrl_t *, cons_event_t *);
     86extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
    8687    suseconds_t *);
    8788
  • uspace/lib/c/include/io/pos_event.h

    r06b0211b raa2b32c  
    11/*
    2  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2012 Petr Koupy
     3 * Copyright (c) 2013 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup genarch
     30/** @addtogroup libc
    3031 * @{
    3132 */
     
    3334 */
    3435
    35 #ifndef KERN_LOGO_196X66_H_
    36 #define KERN_LOGO_196X66_H_
     36#ifndef LIBC_IO_POS_EVENT_H_
     37#define LIBC_IO_POS_EVENT_H_
    3738
    38 #define LOGO_WIDTH   196
    39 #define LOGO_HEIGHT  66
    40 #define LOGO_COLOR   0xffffff
     39#include <sys/types.h>
    4140
    42 #include <typedefs.h>
     41typedef enum {
     42        POS_UPDATE,
     43        POS_PRESS,
     44        POS_RELEASE
     45} pos_event_type_t;
    4346
    44 extern uint32_t fb_logo[LOGO_WIDTH * LOGO_HEIGHT];
     47/** Positioning device event */
     48typedef struct {
     49        sysarg_t pos_id;
     50        pos_event_type_t type;
     51        sysarg_t btn_num;
     52        sysarg_t hpos;
     53        sysarg_t vpos;
     54} pos_event_t;
    4555
    4656#endif
  • uspace/lib/c/include/io/window.h

    r06b0211b raa2b32c  
    4040#include <async.h>
    4141#include <loc.h>
    42 #include <io/console.h>
    43 
    44 typedef enum {
    45         POS_UPDATE,
    46         POS_PRESS,
    47         POS_RELEASE
    48 } pos_event_type_t;
    49 
    50 typedef struct {
    51         sysarg_t pos_id;
    52         pos_event_type_t type;
    53         sysarg_t btn_num;
    54         sysarg_t hpos;
    55         sysarg_t vpos;
    56 } pos_event_t;
     42#include <io/kbd_event.h>
     43#include <io/pos_event.h>
    5744
    5845typedef struct {
  • uspace/lib/clui/tinput.c

    r06b0211b raa2b32c  
    4545#define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols))
    4646#define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols))
     47#define LIN_POS(ti, col, row) ((col) + (row) * (ti)->con_cols)
    4748
    4849/** Seek direction */
     
    383384}
    384385
     386static void tinput_seek_scrpos(tinput_t *ti, int col, int line, bool shift_held)
     387{
     388        unsigned lpos;
     389        tinput_pre_seek(ti, shift_held);
     390
     391        lpos = LIN_POS(ti, col, line);
     392
     393        if (lpos > ti->text_coord)
     394                ti->pos = lpos -  ti->text_coord;
     395        else
     396                ti->pos = 0;
     397        if (ti->pos > ti->nc)
     398                ti->pos = ti->nc;
     399
     400        tinput_post_seek(ti, shift_held);
     401}
     402
    385403static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held)
    386404{
     
    787805}
    788806
     807/** Handle key press event. */
     808static void tinput_key_press(tinput_t *ti, kbd_event_t *kev)
     809{
     810        if (kev->key == KC_LSHIFT)
     811                ti->lshift_held = true;
     812        if (kev->key == KC_RSHIFT)
     813                ti->rshift_held = true;
     814
     815        if (((kev->mods & KM_CTRL) != 0) &&
     816            ((kev->mods & (KM_ALT | KM_SHIFT)) == 0))
     817                tinput_key_ctrl(ti, kev);
     818       
     819        if (((kev->mods & KM_SHIFT) != 0) &&
     820            ((kev->mods & (KM_CTRL | KM_ALT)) == 0))
     821                tinput_key_shift(ti, kev);
     822       
     823        if (((kev->mods & KM_CTRL) != 0) &&
     824            ((kev->mods & KM_SHIFT) != 0) &&
     825            ((kev->mods & KM_ALT) == 0))
     826                tinput_key_ctrl_shift(ti, kev);
     827       
     828        if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
     829                tinput_key_unmod(ti, kev);
     830       
     831        if (kev->c >= ' ') {
     832                tinput_sel_delete(ti);
     833                tinput_insert_char(ti, kev->c);
     834        }
     835}
     836
     837/** Handle key release event. */
     838static void tinput_key_release(tinput_t *ti, kbd_event_t *kev)
     839{
     840        if (kev->key == KC_LSHIFT)
     841                ti->lshift_held = false;
     842        if (kev->key == KC_RSHIFT)
     843                ti->rshift_held = false;
     844}
     845
     846/** Position event */
     847static void tinput_pos(tinput_t *ti, pos_event_t *ev)
     848{
     849        if (ev->type == POS_PRESS) {
     850                tinput_seek_scrpos(ti, ev->hpos, ev->vpos,
     851                    ti->lshift_held || ti->rshift_held);
     852        }
     853}
     854
    789855/** Read in one line of input.
    790856 *
     
    816882                console_flush(ti->console);
    817883               
    818                 kbd_event_t ev;
    819                 if (!console_get_kbd_event(ti->console, &ev))
     884                cons_event_t ev;
     885                if (!console_get_event(ti->console, &ev))
    820886                        return EIO;
    821887               
    822                 if (ev.type != KEY_PRESS)
    823                         continue;
    824                
    825                 if (((ev.mods & KM_CTRL) != 0) &&
    826                     ((ev.mods & (KM_ALT | KM_SHIFT)) == 0))
    827                         tinput_key_ctrl(ti, &ev);
    828                
    829                 if (((ev.mods & KM_SHIFT) != 0) &&
    830                     ((ev.mods & (KM_CTRL | KM_ALT)) == 0))
    831                         tinput_key_shift(ti, &ev);
    832                
    833                 if (((ev.mods & KM_CTRL) != 0) &&
    834                     ((ev.mods & KM_SHIFT) != 0) &&
    835                     ((ev.mods & KM_ALT) == 0))
    836                         tinput_key_ctrl_shift(ti, &ev);
    837                
    838                 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
    839                         tinput_key_unmod(ti, &ev);
    840                
    841                 if (ev.c >= ' ') {
    842                         tinput_sel_delete(ti);
    843                         tinput_insert_char(ti, ev.c);
     888                switch (ev.type) {
     889                case CEV_KEY:
     890                        if (ev.ev.key.type == KEY_PRESS)
     891                                tinput_key_press(ti, &ev.ev.key);
     892                        else
     893                                tinput_key_release(ti, &ev.ev.key);
     894                        break;
     895                case CEV_POS:
     896                        tinput_pos(ti, &ev.ev.pos);
     897                        break;
    844898                }
    845899        }
  • uspace/lib/clui/tinput.h

    r06b0211b raa2b32c  
    146146        /** @c true if user requested to abort interactive loop */
    147147        bool exit_clui;
     148
     149        /** @c true if left shift key is currently held */
     150        bool lshift_held;
     151
     152        /** @c true if right shift key is currently held */
     153        bool rshift_held;
    148154} tinput_t;
    149155
  • uspace/lib/gui/Makefile

    r06b0211b raa2b32c  
    3535SOURCES = \
    3636        button.c \
     37        canvas.c \
    3738        connection.c \
    3839        grid.c \
  • uspace/lib/gui/grid.c

    r06b0211b raa2b32c  
    11/*
    22 * Copyright (c) 2012 Petr Koupy
     3 * Copyright (c) 2013 Martin Decky
    34 * All rights reserved.
    45 *
     
    3839#include <malloc.h>
    3940#include <surface.h>
    40 
    4141#include "window.h"
    4242#include "grid.h"
    4343
    44 static void paint_internal(widget_t *w)
    45 {
    46         grid_t *grid = (grid_t *) w;
    47 
     44typedef struct {
     45        sysarg_t min;
     46        sysarg_t max;
     47        sysarg_t val;
     48} constraints_t;
     49
     50static void paint_internal(widget_t *widget)
     51{
     52        grid_t *grid = (grid_t *) widget;
     53       
    4854        surface_t *surface = window_claim(grid->widget.window);
    4955        if (!surface) {
    5056                window_yield(grid->widget.window);
    51         }
    52 
    53         for (sysarg_t y = w->vpos; y <  w->vpos + w->height; ++y) {
    54                 for (sysarg_t x = w->hpos; x < w->hpos + w->width; ++x) {
     57                return;
     58        }
     59       
     60        // FIXME: Replace with (accelerated) rectangle fill
     61        for (sysarg_t y = widget->vpos; y < widget->vpos + widget->height; y++) {
     62                for (sysarg_t x = widget->hpos; x < widget->hpos + widget->width; x++)
    5563                        surface_put_pixel(surface, x, y, grid->background);
    56                 }
    57         }
    58 
     64        }
     65       
    5966        window_yield(grid->widget.window);
    6067}
    6168
    62 static widget_t **widget_at(grid_t *grid, size_t row, size_t col)
    63 {
    64         if (row < grid->rows && col < grid->cols) {
     69static grid_cell_t *grid_cell_at(grid_t *grid, size_t col, size_t row)
     70{
     71        if ((col < grid->cols) && (row < grid->rows))
    6572                return grid->layout + (row * grid->cols + col);
    66         } else {
    67                 return NULL;
    68         }
     73       
     74        return NULL;
     75}
     76
     77static grid_cell_t *grid_coords_at(grid_t *grid, sysarg_t hpos, sysarg_t vpos)
     78{
     79        for (size_t c = 0; c < grid->cols; c++) {
     80                for (size_t r = 0; r < grid->rows; r++) {
     81                        grid_cell_t *cell = grid_cell_at(grid, c, r);
     82                        if (cell) {
     83                                widget_t *widget = cell->widget;
     84                               
     85                                if ((widget) && (hpos >= widget->hpos) &&
     86                                    (vpos >= widget->vpos) &&
     87                                    (hpos < widget->hpos + widget->width) &&
     88                                    (vpos < widget->vpos + widget->height))
     89                                        return cell;
     90                        }
     91                }
     92        }
     93       
     94        return NULL;
    6995}
    7096
     
    78104{
    79105        grid_t *grid = (grid_t *) widget;
    80 
     106       
    81107        deinit_grid(grid);
    82 
    83108        free(grid);
    84109}
     
    86111static void grid_reconfigure(widget_t *widget)
    87112{
    88         /* no-op */
     113        /* No-op */
     114}
     115
     116static void adjust_constraints(constraints_t *cons, size_t run,
     117    sysarg_t dim_min, sysarg_t dim_max)
     118{
     119        assert(run > 0);
     120       
     121        sysarg_t dim_min_part = dim_min / run;
     122        sysarg_t dim_min_rem = dim_min % run;
     123       
     124        sysarg_t dim_max_part = dim_max / run;
     125        sysarg_t dim_max_rem = dim_max % run;
     126       
     127        for (size_t i = 0; i < run; i++) {
     128                sysarg_t dim_min_cur = dim_min_part;
     129                sysarg_t dim_max_cur = dim_max_part;
     130               
     131                if (i == run - 1) {
     132                        dim_min_cur += dim_min_rem;
     133                        dim_max_cur += dim_max_rem;
     134                }
     135               
     136                /*
     137                 * We want the strongest constraint
     138                 * for the minimum.
     139                 */
     140                if (cons[i].min < dim_min_cur)
     141                        cons[i].min = dim_min_cur;
     142               
     143                /*
     144                 * The comparison is correct, we want
     145                 * the weakest constraint for the
     146                 * maximum.
     147                 */
     148                if (cons[i].max < dim_max_cur)
     149                        cons[i].max = dim_max_cur;
     150        }
     151}
     152
     153static void solve_constraints(constraints_t *cons, size_t run, sysarg_t sum)
     154{
     155        /* Initial solution */
     156        sysarg_t cur_sum = 0;
     157       
     158        for (size_t i = 0; i < run; i++) {
     159                cons[i].val = cons[i].min;
     160                cur_sum += cons[i].val;
     161        }
     162       
     163        /* Iterative improvement */
     164        while (cur_sum < sum) {
     165                sysarg_t delta = (sum - cur_sum) / run;
     166                if (delta == 0)
     167                        break;
     168               
     169                cur_sum = 0;
     170               
     171                for (size_t i = 0; i < run; i++) {
     172                        if (cons[i].val + delta < cons[i].max)
     173                                cons[i].val += delta;
     174                       
     175                        cur_sum += cons[i].val;
     176                }
     177        }
    89178}
    90179
     
    93182{
    94183        grid_t *grid = (grid_t *) widget;
    95 
     184       
    96185        widget_modify(widget, hpos, vpos, width, height);
    97186        paint_internal(widget);
    98 
    99         sysarg_t cell_width = width / grid->cols;
    100         sysarg_t cell_height = height / grid->rows;
    101 
    102         list_foreach(widget->children, link) {
    103                 widget_t *child = list_get_instance(link, widget_t, link);
    104 
    105                 sysarg_t widget_hpos = 0;
    106                 sysarg_t widget_vpos = 0;
    107                 sysarg_t widget_width = 0;
    108                 sysarg_t widget_height = 0;
    109 
    110                 size_t r = 0;
    111                 size_t c = 0;
    112                 for (r = 0; r < grid->rows; ++r) {
    113                         bool found = false;
    114                         for (c = 0; c < grid->cols; ++c) {
    115                                 widget_t **cell = widget_at(grid, r, c);
    116                                 if (cell && *cell == child) {
    117                                         found = true;
    118                                         break;
     187       
     188        /* Compute column widths */
     189        constraints_t *widths =
     190            (constraints_t *) calloc(grid->cols, sizeof(constraints_t));
     191        if (widths) {
     192                /* Constrain widths */
     193                for (size_t c = 0; c < grid->cols; c++) {
     194                        widths[c].min = 0;
     195                       
     196                        for (size_t r = 0; r < grid->rows; r++) {
     197                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     198                                if (!cell)
     199                                        continue;
     200                               
     201                                widget_t *widget = cell->widget;
     202                                if (widget)
     203                                        adjust_constraints(&widths[c], cell->cols,
     204                                            widget->width_min, widget->width_max);
     205                        }
     206                }
     207               
     208                solve_constraints(widths, grid->cols, width);
     209        }
     210       
     211        /* Compute row heights */
     212        constraints_t *heights =
     213            (constraints_t *) calloc(grid->rows, sizeof(constraints_t));
     214        if (heights) {
     215                /* Constrain heights */
     216                for (size_t r = 0; r < grid->rows; r++) {
     217                        heights[r].min = 0;
     218                       
     219                        for (size_t c = 0; c < grid->cols; c++) {
     220                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     221                                if (!cell)
     222                                        continue;
     223                               
     224                                widget_t *widget = cell->widget;
     225                                if (widget) {
     226                                        adjust_constraints(&heights[r], cell->rows,
     227                                            widget->height_min, widget->height_max);
    119228                                }
    120229                        }
    121                         if (found) {
    122                                 break;
     230                }
     231               
     232                solve_constraints(heights, grid->rows, height);
     233        }
     234       
     235        /* Rearrange widgets */
     236        if ((widths) && (heights)) {
     237                sysarg_t cur_vpos = vpos;
     238               
     239                for (size_t r = 0; r < grid->rows; r++) {
     240                        sysarg_t cur_hpos = hpos;
     241                       
     242                        for (size_t c = 0; c < grid->cols; c++) {
     243                                grid_cell_t *cell = grid_cell_at(grid, c, r);
     244                                if (!cell)
     245                                        continue;
     246                               
     247                                widget_t *widget = cell->widget;
     248                                if (widget) {
     249                                        sysarg_t cur_width = 0;
     250                                        sysarg_t cur_height = 0;
     251                                       
     252                                        for (size_t cd = 0; cd < cell->cols; cd++)
     253                                                cur_width += widths[c + cd].val;
     254                                       
     255                                        for (size_t rd = 0; rd < cell->rows; rd++)
     256                                                cur_height += heights[r + rd].val;
     257                                       
     258                                        if ((cur_width > 0) && (cur_height > 0)) {
     259                                                sysarg_t wwidth = cur_width;
     260                                                sysarg_t wheight = cur_height;
     261                                               
     262                                                /*
     263                                                 * Make sure the widget is respects its
     264                                                 * maximal constrains.
     265                                                 */
     266                                               
     267                                                if ((widget->width_max > 0) &&
     268                                                    (wwidth > widget->width_max))
     269                                                        wwidth = widget->width_max;
     270                                               
     271                                                if ((widget->height_max > 0) &&
     272                                                    (wheight > widget->height_max))
     273                                                        wheight = widget->height_max;
     274                                               
     275                                                widget->rearrange(widget, cur_hpos, cur_vpos,
     276                                                    wwidth, wheight);
     277                                        }
     278                                       
     279                                       
     280                                }
     281                               
     282                                cur_hpos += widths[c].val;
    123283                        }
    124                 }
    125 
    126                 widget_hpos = cell_width * c + hpos;
    127                 widget_vpos = cell_height * r + vpos;
    128 
    129                 for (size_t _c = c; _c < grid->cols; ++_c) {
    130                         widget_t **cell = widget_at(grid, r, _c);
    131                         if (cell && *cell == child) {
    132                                 widget_width += cell_width;
    133                         } else {
    134                                 break;
    135                         }
    136                 }
    137 
    138                 for (size_t _r = r; _r < grid->rows; ++_r) {
    139                         widget_t **cell = widget_at(grid, _r, c);
    140                         if (cell && *cell == child) {
    141                                 widget_height += cell_height;
    142                         } else {
    143                                 break;
    144                         }
    145                 }
    146 
    147                 if (widget_width > 0 && widget_height > 0) {
    148                         child->rearrange(child,
    149                             widget_hpos, widget_vpos, widget_width, widget_height);
    150                 }
    151         }
     284                       
     285                        cur_vpos += heights[r].val;
     286                }
     287        }
     288       
     289        if (widths)
     290                free(widths);
     291       
     292        if (heights)
     293                free(heights);
    152294}
    153295
     
    155297{
    156298        paint_internal(widget);
     299       
    157300        list_foreach(widget->children, link) {
    158301                widget_t *child = list_get_instance(link, widget_t, link);
    159302                child->repaint(child);
    160303        }
     304       
    161305        window_damage(widget->window);
    162306}
     
    164308static void grid_handle_keyboard_event(widget_t *widget, kbd_event_t event)
    165309{
    166         /* no-op */
     310        /* No-op */
    167311}
    168312
     
    170314{
    171315        grid_t *grid = (grid_t *) widget;
    172 
    173         if ((widget->height / grid->rows) == 0) {
    174                 return;
    175         }
    176         if ((widget->width / grid->cols) == 0) {
    177                 return;
    178         }
    179 
    180         sysarg_t row = (event.vpos - widget->vpos) / (widget->height / grid->rows);
    181         sysarg_t col = (event.hpos - widget->hpos) / (widget->width / grid->cols);
    182 
    183         widget_t **cell = widget_at(grid, row, col);
    184         if (cell && *cell) {
    185                 (*cell)->handle_position_event(*cell, event);
    186         }
    187 }
    188 
    189 static void grid_add(grid_t *grid, widget_t *widget,
    190     size_t row, size_t col, size_t rows, size_t cols)
    191 {
    192         assert(row + rows <= grid->rows);
    193         assert(col + cols <= grid->cols);
    194 
     316       
     317        grid_cell_t *cell = grid_coords_at(grid, event.hpos, event.vpos);
     318        if ((cell) && (cell->widget))
     319                cell->widget->handle_position_event(cell->widget, event);
     320}
     321
     322static bool grid_add(struct grid *grid, widget_t *widget, size_t col,
     323    size_t row, size_t cols, size_t rows)
     324{
     325        if ((cols == 0) || (rows == 0) || (col + cols > grid->cols) ||
     326            (row + rows > grid->rows))
     327                return false;
     328       
     329        grid_cell_t *cell = grid_cell_at(grid, col, row);
     330        if (!cell)
     331                return false;
     332       
     333        /*
     334         * Check whether the cell is not occupied by an
     335         * extension of a different cell.
     336         */
     337        if ((!cell->widget) && (cell->cols > 0) && (cell->rows > 0))
     338                return false;
     339       
    195340        widget->parent = (widget_t *) grid;
     341       
    196342        list_append(&widget->link, &grid->widget.children);
    197343        widget->window = grid->widget.window;
    198 
    199         for (size_t r = row; r < row + rows; ++r) {
    200                 for (size_t c = col; c < col + cols; ++c) {
    201                         widget_t **cell = widget_at(grid, r, c);
    202                         if (cell) {
    203                                 *cell = widget;
     344       
     345        /* Mark cells in layout */
     346        for (size_t r = row; r < row + rows; r++) {
     347                for (size_t c = col; c < col + cols; c++) {
     348                        if ((r == row) && (c == col)) {
     349                                cell->widget = widget;
     350                                cell->cols = cols;
     351                                cell->rows = rows;
     352                        } else {
     353                                grid_cell_t *extension = grid_cell_at(grid, c, r);
     354                                if (extension) {
     355                                        extension->widget = NULL;
     356                                        extension->cols = 1;
     357                                        extension->rows = 1;
     358                                }
    204359                        }
    205360                }
    206361        }
    207 }
    208 
    209 bool init_grid(grid_t *grid,
    210     widget_t *parent, size_t rows, size_t cols, pixel_t background)
    211 {
    212         assert(rows > 0);
    213         assert(cols > 0);
    214 
    215         widget_t **layout = (widget_t **) malloc(rows * cols * sizeof(widget_t *));
    216         if (!layout) {
     362       
     363        return true;
     364}
     365
     366bool init_grid(grid_t *grid, widget_t *parent, size_t cols, size_t rows,
     367    pixel_t background)
     368{
     369        if ((cols == 0) || (rows == 0))
    217370                return false;
    218         }
    219         memset(layout, 0, rows * cols * sizeof(widget_t *));
    220 
     371       
     372        grid->layout =
     373            (grid_cell_t *) calloc(cols * rows, sizeof(grid_cell_t));
     374        if (!grid->layout)
     375                return false;
     376       
     377        memset(grid->layout, 0, cols * rows * sizeof(grid_cell_t));
     378       
    221379        widget_init(&grid->widget, parent);
    222 
     380       
    223381        grid->widget.destroy = grid_destroy;
    224382        grid->widget.reconfigure = grid_reconfigure;
     
    227385        grid->widget.handle_keyboard_event = grid_handle_keyboard_event;
    228386        grid->widget.handle_position_event = grid_handle_position_event;
    229 
     387       
    230388        grid->add = grid_add;
    231389        grid->background = background;
     390        grid->cols = cols;
    232391        grid->rows = rows;
    233         grid->cols = cols;
    234         grid->layout = layout;
    235 
     392       
    236393        return true;
    237394}
    238395
    239 grid_t *create_grid(widget_t *parent, size_t rows, size_t cols, pixel_t background)
     396grid_t *create_grid(widget_t *parent, size_t cols, size_t rows, pixel_t background)
    240397{
    241398        grid_t *grid = (grid_t *) malloc(sizeof(grid_t));
    242         if (!grid) {
     399        if (!grid)
    243400                return NULL;
    244         }
    245 
    246         if (init_grid(grid, parent, rows, cols, background)) {
     401       
     402        if (init_grid(grid, parent, cols, rows, background))
    247403                return grid;
    248         } else {
    249                 free(grid);
    250                 return NULL;
    251         }
     404       
     405        free(grid);
     406        return NULL;
    252407}
    253408
  • uspace/lib/gui/grid.h

    r06b0211b raa2b32c  
    3939#include <sys/types.h>
    4040#include <io/pixel.h>
    41 
    4241#include "widget.h"
    4342
    44 struct grid;
    45 typedef struct grid grid_t;
     43typedef struct {
     44        widget_t *widget;
     45        size_t cols;
     46        size_t rows;
     47} grid_cell_t;
    4648
    4749typedef struct grid {
    4850        widget_t widget;
    4951        pixel_t background;
     52        size_t cols;
    5053        size_t rows;
    51         size_t cols;
    52         widget_t **layout;
    53         void (*add)(grid_t *, widget_t *, size_t, size_t, size_t, size_t);
     54        grid_cell_t *layout;
     55        bool (*add)(struct grid *, widget_t *, size_t, size_t, size_t, size_t);
    5456} grid_t;
    5557
  • uspace/lib/gui/terminal.c

    r06b0211b raa2b32c  
    7777static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    7878static void term_set_cursor_visibility(con_srv_t *, bool);
    79 static int term_get_event(con_srv_t *, kbd_event_t *);
     79static int term_get_event(con_srv_t *, cons_event_t *);
    8080
    8181static con_ops_t con_ops = {
     
    420420                if (pos < size) {
    421421                        link_t *link = prodcons_consume(&term->input_pc);
    422                         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     422                        cons_event_t *event = list_get_instance(link, cons_event_t, link);
    423423                       
    424424                        /* Accept key presses of printable chars only. */
    425                         if ((event->type == KEY_PRESS) && (event->c != 0)) {
     425                        if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
     426                            event->ev.key.c != 0) {
    426427                                wchar_t tmp[2] = {
    427                                         event->c,
     428                                        event->ev.key.c,
    428429                                        0
    429430                                };
     
    579580}
    580581
    581 static int term_get_event(con_srv_t *srv, kbd_event_t *event)
     582static int term_get_event(con_srv_t *srv, cons_event_t *event)
    582583{
    583584        terminal_t *term = srv_to_terminal(srv);
    584585        link_t *link = prodcons_consume(&term->input_pc);
    585         kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    586        
    587         *event = *kevent;
    588         free(kevent);
     586        cons_event_t *ev = list_get_instance(link, cons_event_t, link);
     587       
     588        *event = *ev;
     589        free(ev);
    589590        return EOK;
    590591}
     
    634635}
    635636
     637static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev)
     638{
     639        /* Got key press/release event */
     640        cons_event_t *event =
     641            (cons_event_t *) malloc(sizeof(cons_event_t));
     642        if (event == NULL)
     643                return;
     644       
     645        *event = *ev;
     646        link_initialize(&event->link);
     647       
     648        prodcons_produce(&term->input_pc, &event->link);
     649}
     650
     651/* Got key press/release event */
    636652static void terminal_handle_keyboard_event(widget_t *widget,
    637653    kbd_event_t kbd_event)
    638654{
    639655        terminal_t *term = (terminal_t *) widget;
    640        
    641         /* Got key press/release event */
    642         kbd_event_t *event =
    643             (kbd_event_t *) malloc(sizeof(kbd_event_t));
    644         if (event == NULL)
    645                 return;
    646        
    647         link_initialize(&event->link);
    648         event->type = kbd_event.type;
    649         event->key = kbd_event.key;
    650         event->mods = kbd_event.mods;
    651         event->c = kbd_event.c;
    652        
    653         prodcons_produce(&term->input_pc, &event->link);
    654 }
    655 
    656 static void terminal_handle_position_event(widget_t *widget, pos_event_t event)
    657 {
    658         /*
    659          * Mouse events are ignored so far.
    660          * There is no consumer for it.
    661          */
     656        cons_event_t event;
     657       
     658        event.type = CEV_KEY;
     659        event.ev.key = kbd_event;
     660       
     661        terminal_queue_cons_event(term, &event);
     662}
     663
     664static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event)
     665{
     666        cons_event_t event;
     667        terminal_t *term = (terminal_t *) widget;
     668        sysarg_t sx = term->widget.hpos;
     669        sysarg_t sy = term->widget.vpos;
     670
     671        if (pos_event.type == POS_PRESS) {
     672                event.type = CEV_POS;
     673                event.ev.pos.type = pos_event.type;
     674                event.ev.pos.pos_id = pos_event.pos_id;
     675                event.ev.pos.btn_num = pos_event.btn_num;
     676
     677                event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH;
     678                event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES;
     679                terminal_queue_cons_event(term, &event);
     680        }
    662681}
    663682
  • uspace/lib/gui/window.c

    r06b0211b raa2b32c  
    424424
    425425        while (!list_empty(&win->events.list)) {
    426                 list_remove(list_first(&win->events.list));
     426                window_event_t *event = (window_event_t *) list_first(&win->events.list);
     427                list_remove(&event->link);
     428                free(event);
    427429        }
    428430
  • uspace/srv/hid/compositor/Makefile

    r06b0211b raa2b32c  
    3838
    3939IMAGES = \
    40         gfx/helenos.tga \
    4140        gfx/nameic.tga
    4241
  • uspace/srv/hid/compositor/compositor.c

    r06b0211b raa2b32c  
    9090typedef struct {
    9191        link_t link;
     92        atomic_t ref_cnt;
    9293        service_id_t in_dsid;
    9394        service_id_t out_dsid;
     
    138139} viewport_t;
    139140
     141static desktop_rect_t viewport_bound_rect;
    140142static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx);
    141143static LIST_INITIALIZE(viewport_list);
     
    215217
    216218        link_initialize(&win->link);
     219        atomic_set(&win->ref_cnt, 0);
    217220        prodcons_initialize(&win->queue);
    218221        transform_identity(&win->transform);
     
    232235static void window_destroy(window_t *win)
    233236{
    234         if (win) {
     237        if (win && atomic_get(&win->ref_cnt) == 0) {
     238                while (!list_empty(&win->queue.list)) {
     239                        window_event_t *event = (window_event_t *) list_first(&win->queue.list);
     240                        list_remove(&event->link);
     241                        free(event);
     242                }
     243
    235244                if (win->surface) {
    236245                        surface_destroy(win->surface);
     
    310319}
    311320
     321static void comp_restrict_pointers(void)
     322{
     323        fibril_mutex_lock(&viewport_list_mtx);
     324
     325        sysarg_t x_res = coord_origin;
     326        sysarg_t y_res = coord_origin;
     327        sysarg_t w_res = 0;
     328        sysarg_t h_res = 0;
     329
     330        if (!list_empty(&viewport_list)) {
     331                viewport_t *vp = (viewport_t *) list_first(&viewport_list);
     332                x_res = vp->pos.x;
     333                y_res = vp->pos.y;
     334                surface_get_resolution(vp->surface, &w_res, &h_res);
     335        }
     336
     337        list_foreach(viewport_list, link) {
     338                viewport_t *vp = list_get_instance(link, viewport_t, link);
     339                sysarg_t w_vp, h_vp;
     340                surface_get_resolution(vp->surface, &w_vp, &h_vp);
     341                rectangle_union(
     342                    x_res, y_res, w_res, h_res,
     343                    vp->pos.x, vp->pos.y, w_vp, h_vp,
     344                    &x_res, &y_res, &w_res, &h_res);
     345        }
     346
     347        viewport_bound_rect.x = x_res;
     348        viewport_bound_rect.y = y_res;
     349        viewport_bound_rect.w = w_res;
     350        viewport_bound_rect.h = h_res;
     351
     352        fibril_mutex_unlock(&viewport_list_mtx);
     353
     354        fibril_mutex_lock(&pointer_list_mtx);
     355
     356        list_foreach(pointer_list, link) {
     357                pointer_t *ptr = list_get_instance(link, pointer_t, link);
     358                ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x;
     359                ptr->pos.y = ptr->pos.y > viewport_bound_rect.y ? ptr->pos.y : viewport_bound_rect.y;
     360                ptr->pos.x = ptr->pos.x < viewport_bound_rect.x + viewport_bound_rect.w ?
     361                    ptr->pos.x : viewport_bound_rect.x + viewport_bound_rect.w;
     362                ptr->pos.y = ptr->pos.y < viewport_bound_rect.y + viewport_bound_rect.h ?
     363                    ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h;
     364        }
     365
     366        fibril_mutex_unlock(&pointer_list_mtx);
     367}
     368
    312369static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob,
    313370    sysarg_t w_dmg_glob, sysarg_t h_dmg_glob)
     
    695752        }
    696753
     754        loc_service_unregister(win->in_dsid);
     755        loc_service_unregister(win->out_dsid);
     756
     757        /* In case the client was killed, input fibril of the window might be
     758         * still blocked on the condition within comp_window_get_event. */
     759        window_event_t *event_dummy = (window_event_t *) malloc(sizeof(window_event_t));
     760        if (event_dummy) {
     761                link_initialize(&event_dummy->link);
     762                prodcons_produce(&win->queue, &event_dummy->link);
     763        }
     764
    697765        /* Calculate damage. */
    698766        sysarg_t x = 0;
     
    706774        }
    707775
    708         /* Release window resources. */
    709         loc_service_unregister(win->in_dsid);
    710         loc_service_unregister(win->out_dsid);
    711         while (!list_empty(&win->queue.list)) {
    712                 list_remove(list_first(&win->queue.list));
    713         }
    714         window_destroy(win);
    715 
    716776        comp_damage(x, y, width, height);
    717777
     
    813873
    814874        if (win) {
     875                atomic_inc(&win->ref_cnt);
    815876                async_answer_0(iid, EOK);
    816877        } else {
     
    825886
    826887                        if (!IPC_GET_IMETHOD(call)) {
    827                                 async_answer_0(callid, EINVAL);
     888                                async_answer_0(callid, EOK);
     889                                atomic_dec(&win->ref_cnt);
     890                                window_destroy(win);
    828891                                return;
    829892                        }
     
    842905
    843906                        if (!IPC_GET_IMETHOD(call)) {
    844                                 async_answer_0(callid, EINVAL);
     907                                comp_window_close(win, callid, &call);
     908                                atomic_dec(&win->ref_cnt);
     909                                window_destroy(win);
    845910                                return;
    846911                        }
     
    857922                                break;
    858923                        case WINDOW_CLOSE:
    859                                 comp_window_close(win, callid, &call);
     924                                /* Postpone the closing until the phone is hung up to cover
     925                                 * the case when the client is killed abruptly. */
     926                                async_answer_0(callid, EOK);
    860927                                break;
    861928                        case WINDOW_CLOSE_REQUEST:
     
    911978        async_answer_0(iid, EOK);
    912979
     980        comp_restrict_pointers();
    913981        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    914982}
     
    9561024                fibril_mutex_unlock(&viewport_list_mtx);
    9571025                async_answer_0(iid, EOK);
     1026
     1027                comp_restrict_pointers();
     1028                comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    9581029        }
    9591030}
     
    13911462        surface_get_resolution(pointer->cursor.states[pointer->state],
    13921463             &cursor_width, &cursor_height);
     1464        if (pointer->pos.x + dx < viewport_bound_rect.x) {
     1465                dx = -1 * (pointer->pos.x - viewport_bound_rect.x);
     1466        }
     1467        if (pointer->pos.y + dy < viewport_bound_rect.y) {
     1468                dy = -1 * (pointer->pos.y - viewport_bound_rect.y);
     1469        }
     1470        if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) {
     1471                dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x);
     1472        }
     1473        if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) {
     1474                dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y);
     1475        }
    13931476        pointer->pos.x += dx;
    13941477        pointer->pos.y += dy;
     
    19101993                        fibril_mutex_unlock(&viewport_list_mtx);
    19111994
     1995                        comp_restrict_pointers();
    19121996                        comp_damage(x, y, width, height);
    19131997                } else {
     
    19622046                }
    19632047                list_prepend(&blue_win->link, &window_list);
    1964 
    1965                 window_t *helenos_win = window_create(0, 0);
    1966                 helenos_win->surface = decode_tga((void *) helenos_tga, helenos_tga_size, 0);
    1967                 list_prepend(&helenos_win->link, &window_list);
    1968 
     2048               
    19692049                window_t *nameic_win = window_create(0, 0);
    19702050                nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0);
     
    21262206                return -1;
    21272207        }
    2128        
     2208
     2209        comp_restrict_pointers();
    21292210        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    21302211       
  • uspace/srv/hid/console/console.c

    r06b0211b raa2b32c  
    129129static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    130130static void cons_set_cursor_visibility(con_srv_t *, bool);
    131 static int cons_get_event(con_srv_t *, kbd_event_t *);
     131static int cons_get_event(con_srv_t *, cons_event_t *);
    132132
    133133static con_ops_t con_ops = {
     
    490490}
    491491
    492 static int cons_get_event(con_srv_t *srv, kbd_event_t *event)
     492static int cons_get_event(con_srv_t *srv, cons_event_t *event)
    493493{
    494494        console_t *cons = srv_to_console(srv);
     
    496496        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    497497       
    498         *event = *kevent;
     498        event->type = CEV_KEY;
     499        event->ev.key = *kevent;
    499500        free(kevent);
    500501        return EOK;
  • uspace/srv/hid/remcons/remcons.c

    r06b0211b raa2b32c  
    8080static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
    8181static int remcons_get_color_cap(con_srv_t *, console_caps_t *);
    82 static int remcons_get_event(con_srv_t *, kbd_event_t *);
     82static int remcons_get_event(con_srv_t *, cons_event_t *);
    8383
    8484static con_ops_t con_ops = {
     
    185185}
    186186
    187 static int remcons_get_event(con_srv_t *srv, kbd_event_t *event)
    188 {
    189         telnet_user_t *user = srv_to_user(srv);
     187static int remcons_get_event(con_srv_t *srv, cons_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
     190        kbd_event_t kevent;
    190191        int rc;
    191192
    192         rc = telnet_user_get_next_keyboard_event(user, event);
     193        rc = telnet_user_get_next_keyboard_event(user, &kevent);
    193194        if (rc != EOK) {
    194195                /* XXX What? */
     
    196197                return EOK;
    197198        }
     199
     200        event->type = CEV_KEY;
     201        event->ev.key = kevent;
    198202
    199203        return EOK;
  • uspace/srv/net/ethip/ethip.c

    r06b0211b raa2b32c  
    221221        case ETYPE_IP:
    222222                log_msg(LOG_DEFAULT, LVL_DEBUG, " - construct SDU");
    223                 sdu.lsrc.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1;
    224                 sdu.ldest.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 4;
     223                sdu.lsrc.ipv4 = 0;
     224                sdu.ldest.ipv4 = 0;
    225225                sdu.data = frame.data;
    226226                sdu.size = frame.size;
  • uspace/srv/ns/task.c

    r06b0211b raa2b32c  
    208208        sysarg_t retval;
    209209        task_exit_t texit;
     210        bool remove = false;
    210211       
    211212        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     
    235236        }
    236237       
    237         hash_table_remove_item(&task_hash_table, link);
     238        remove = true;
    238239        retval = EOK;
    239240       
     
    243244                ipc_answer_2(callid, retval, texit, ht->retval);
    244245        }
     246        if (remove)
     247                hash_table_remove_item(&task_hash_table, link);
    245248}
    246249
Note: See TracChangeset for help on using the changeset viewer.