Changeset a35b458 in mainline for uspace/lib/gui/window.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/window.c

    r3061bc1 ra35b458  
    8989        if (!surface)
    9090                window_yield(widget->window);
    91        
     91
    9292        source_t source;
    9393        source_init(&source);
    94        
     94
    9595        drawctx_t drawctx;
    9696        drawctx_init(&drawctx, surface);
    9797        drawctx_set_source(&drawctx, &source);
    98        
     98
    9999        /* Window border outer bevel */
    100        
     100
    101101        draw_bevel(&drawctx, &source, widget->vpos, widget->hpos,
    102102            widget->width, widget->height, color_highlight, color_shadow);
    103        
     103
    104104        /* Window border surface */
    105        
     105
    106106        source_set_color(&source, color_surface);
    107107        drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1,
     
    113113        drawctx_transfer(&drawctx, widget->hpos + widget->width - 3,
    114114            widget->vpos + 1, 2, widget->height - 4);
    115        
     115
    116116        /* Window border inner bevel */
    117        
     117
    118118        draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3,
    119119            widget->width - 6, widget->height - 6, color_shadow,
    120120            color_highlight);
    121        
     121
    122122        /* Header bevel */
    123        
     123
    124124        sysarg_t header_hpos = widget->hpos + border_thickness;
    125125        sysarg_t header_vpos = widget->vpos + border_thickness;
    126126        sysarg_t header_width = widget->width - 2 * border_thickness -
    127127            close_thickness;
    128        
     128
    129129        draw_bevel(&drawctx, &source, header_hpos, header_vpos,
    130130            header_width, header_height, widget->window->is_focused ?
     
    132132            widget->window->is_focused ?
    133133            color_header_focus_shadow : color_header_unfocus_shadow);
    134        
     134
    135135        /* Header surface */
    136        
     136
    137137        source_set_color(&source, widget->window->is_focused ?
    138138            color_header_focus_surface : color_header_unfocus_surface);
    139139        drawctx_transfer(&drawctx, header_hpos + 1, header_vpos + 1,
    140140            header_width - 2, header_height - 2);
    141        
     141
    142142        /* Close button bevel */
    143        
     143
    144144        sysarg_t close_hpos = widget->hpos + widget->width -
    145145            border_thickness - close_thickness;
    146146        sysarg_t close_vpos = widget->vpos + border_thickness;
    147        
     147
    148148        draw_bevel(&drawctx, &source, close_hpos, close_vpos,
    149149            close_thickness, close_thickness, color_highlight, color_shadow);
    150        
     150
    151151        /* Close button surface */
    152        
     152
    153153        source_set_color(&source, color_surface);
    154154        drawctx_transfer(&drawctx, close_hpos + 1, close_vpos + 1,
    155155            close_thickness - 2, close_thickness - 2);
    156        
     156
    157157        /* Close button icon */
    158        
     158
    159159        draw_icon_cross(surface, close_hpos + 3, close_vpos + 3,
    160160            color_highlight, color_shadow);
    161        
     161
    162162        /* Window caption */
    163        
     163
    164164        font_t *font;
    165165        errno_t rc = embedded_font_create(&font, 16);
     
    168168                return;
    169169        }
    170        
     170
    171171        drawctx_set_font(&drawctx, font);
    172172        source_set_color(&source, widget->window->is_focused ?
    173173            color_caption_focus : color_caption_unfocus);
    174        
     174
    175175        sysarg_t cpt_width;
    176176        sysarg_t cpt_height;
    177177        font_get_box(font, widget->window->caption, &cpt_width, &cpt_height);
    178        
     178
    179179        bool draw_title =
    180180            (widget->width >= 2 * border_thickness + 2 * bevel_thickness +
     
    184184                sysarg_t cpt_y = ((header_height - cpt_height) / 2) +
    185185                    widget->vpos + border_thickness;
    186                
     186
    187187                if (widget->window->caption)
    188188                        drawctx_print(&drawctx, widget->window->caption, cpt_x, cpt_y);
    189189        }
    190        
     190
    191191        font_release(font);
    192192        window_yield(widget->window);
     
    375375                return;
    376376        }
    377        
     377
    378378        if (height < 2 * border_thickness + header_height) {
    379379                win_damage(win->osess, 0, 0, 0, 0);
    380380                return;
    381381        }
    382        
     382
    383383        /* Allocate resources for new surface. */
    384384        surface_t *new_surface = surface_create(width, height, NULL,
     
    386386        if (!new_surface)
    387387                return;
    388        
     388
    389389        /* Switch new and old surface. */
    390390        fibril_mutex_lock(&win->guard);
     
    392392        win->surface = new_surface;
    393393        fibril_mutex_unlock(&win->guard);
    394        
     394
    395395        /*
    396396         * Let all widgets in the tree alter their position and size.
     
    398398         */
    399399        win->root.rearrange(&win->root, 0, 0, width, height);
    400        
     400
    401401        fibril_mutex_lock(&win->guard);
    402402        surface_reset_damaged_region(win->surface);
    403403        fibril_mutex_unlock(&win->guard);
    404        
     404
    405405        /* Inform compositor about new surface. */
    406406        errno_t rc = win_resize(win->osess, offset_x, offset_y, width, height,
    407407            placement_flags, surface_direct_access(new_surface));
    408        
     408
    409409        if (rc != EOK) {
    410410                /* Rollback to old surface. Reverse all changes. */
    411                
     411
    412412                sysarg_t old_width = 0;
    413413                sysarg_t old_height = 0;
    414414                if (old_surface)
    415415                        surface_get_resolution(old_surface, &old_width, &old_height);
    416                
     416
    417417                fibril_mutex_lock(&win->guard);
    418418                new_surface = win->surface;
    419419                win->surface = old_surface;
    420420                fibril_mutex_unlock(&win->guard);
    421                
     421
    422422                win->root.rearrange(&win->root, 0, 0, old_width, old_height);
    423                
     423
    424424                if (win->surface) {
    425425                        fibril_mutex_lock(&win->guard);
     
    427427                        fibril_mutex_unlock(&win->guard);
    428428                }
    429                
     429
    430430                surface_destroy(new_surface);
    431431        } else {
     
    569569        while (true) {
    570570                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
    571                
     571
    572572                if (event) {
    573573                        rc = win_get_event(win->isess, event);
     
    598598        if (!win)
    599599                return NULL;
    600        
     600
    601601        win->is_main = flags & WINDOW_MAIN;
    602602        win->is_decorated = flags & WINDOW_DECORATED;
     
    604604        prodcons_initialize(&win->events);
    605605        fibril_mutex_initialize(&win->guard);
    606        
     606
    607607        widget_init(&win->root, NULL, data);
    608608        win->root.window = win;
     
    616616        win->focus = NULL;
    617617        win->surface = NULL;
    618        
     618
    619619        service_id_t reg_dsid;
    620620        errno_t rc = loc_service_get_id(winreg, &reg_dsid, 0);
     
    623623                return NULL;
    624624        }
    625        
     625
    626626        async_sess_t *reg_sess =
    627627            loc_service_connect(reg_dsid, INTERFACE_COMPOSITOR, 0);
     
    630630                return NULL;
    631631        }
    632        
     632
    633633        service_id_t in_dsid;
    634634        service_id_t out_dsid;
     
    639639                return NULL;
    640640        }
    641        
     641
    642642        win->osess = loc_service_connect(out_dsid, INTERFACE_COMPOSITOR, 0);
    643643        if (win->osess == NULL) {
     
    645645                return NULL;
    646646        }
    647        
     647
    648648        win->isess = loc_service_connect(in_dsid, INTERFACE_COMPOSITOR, 0);
    649649        if (win->isess == NULL) {
     
    652652                return NULL;
    653653        }
    654        
     654
    655655        if (caption == NULL)
    656656                win->caption = NULL;
    657657        else
    658658                win->caption = str_dup(caption);
    659        
     659
    660660        return win;
    661661}
     
    680680{
    681681        char *cap;
    682        
     682
    683683        if (caption == NULL) {
    684684                win->caption = NULL;
     
    690690                win->caption = cap;
    691691        }
    692        
     692
    693693        win->is_focused = false;
    694694        handle_refresh(win);
    695        
     695
    696696        return EOK;
    697697}
Note: See TracChangeset for help on using the changeset viewer.