Changeset db3895d in mainline for uspace/lib/ui/src/window.c


Ignore:
Timestamp:
2021-06-10T17:10:11Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af5d62eb
Parents:
90f1f19
Message:

Set cursor shape to I-beam when hovering over text entry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/window.c

    r90f1f19 rdb3895d  
    646646}
    647647
     648/** Set cursor when pointer is hovering over a control.
     649 *
     650 * @param window Window
     651 * @param cursor Cursor
     652 */
     653void ui_window_set_ctl_cursor(ui_window_t *window, ui_stock_cursor_t cursor)
     654{
     655        display_stock_cursor_t dcursor;
     656
     657        dcursor = wnd_dcursor_from_cursor(cursor);
     658
     659        if (window->dwindow != NULL)
     660                (void) display_window_set_cursor(window->dwindow, dcursor);
     661}
     662
    648663/** Paint window
    649664 *
     
    770785}
    771786
    772 /** Window decoration requested changing cursor.
    773  *
    774  * @param wdecor Window decoration
    775  * @param arg Argument (window)
    776  * @param cursor Cursor to set
    777  */
    778 static void wd_set_cursor(ui_wdecor_t *wdecor, void *arg,
    779     ui_stock_cursor_t cursor)
    780 {
    781         ui_window_t *window = (ui_window_t *) arg;
     787/** Get display stock cursor from UI stock cursor.
     788 *
     789 * @param cursor UI stock cursor
     790 * @return Display stock cursor
     791 */
     792display_stock_cursor_t wnd_dcursor_from_cursor(ui_stock_cursor_t cursor)
     793{
    782794        display_stock_cursor_t dcursor;
    783 
    784         if (cursor == window->cursor)
    785                 return;
    786795
    787796        dcursor = dcurs_arrow;
     
    803812                dcursor = dcurs_size_urdl;
    804813                break;
    805         }
     814        case ui_curs_ibeam:
     815                dcursor = dcurs_ibeam;
     816                break;
     817        }
     818
     819        return dcursor;
     820}
     821
     822/** Window decoration requested changing cursor.
     823 *
     824 * @param wdecor Window decoration
     825 * @param arg Argument (window)
     826 * @param cursor Cursor to set
     827 */
     828static void wd_set_cursor(ui_wdecor_t *wdecor, void *arg,
     829    ui_stock_cursor_t cursor)
     830{
     831        ui_window_t *window = (ui_window_t *) arg;
     832        display_stock_cursor_t dcursor;
     833
     834        if (cursor == window->cursor)
     835                return;
     836
     837        dcursor = wnd_dcursor_from_cursor(cursor);
    806838
    807839        if (window->dwindow != NULL)
    808840                (void) display_window_set_cursor(window->dwindow, dcursor);
     841
    809842        window->cursor = cursor;
    810843}
Note: See TracChangeset for help on using the changeset viewer.