Changeset 9901f267 in mainline


Ignore:
Timestamp:
2020-05-22T10:38:52Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef20a91
Parents:
9242ad9
git-author:
Jiri Svoboda <jiri@…> (2020-05-21 17:38:41)
git-committer:
Jiri Svoboda <jiri@…> (2020-05-22 10:38:52)
Message:

Display server needs to override cursor when resizing windows

Although the pointer moves, the window is not resized until button
is released. Therefore we need override the cursor from what it
would be just based on where the pointer is located.

Location:
uspace
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/include/display/wndresize.h

    r9242ad9 r9901f267  
    3636#define _LIBDISPLAY_DISPLAY_WNDRESIZE_H_
    3737
     38#include <stdbool.h>
     39#include "../types/display/cursor.h"
    3840#include "../types/display/wndresize.h"
     41
     42extern display_stock_cursor_t display_cursor_from_wrsz(display_wnd_rsztype_t);
     43extern bool display_wndrsz_valid(display_wnd_rsztype_t);
    3944
    4045#endif
  • uspace/lib/display/meson.build

    r9242ad9 r9901f267  
    3131        'src/display.c',
    3232        'src/disp_srv.c',
     33        'src/wndresize.c',
    3334)
    3435
     
    3637        'test/display.c',
    3738        'test/main.c',
     39        'test/wndresize.c',
    3840)
  • uspace/lib/display/test/main.c

    r9242ad9 r9901f267  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2020 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3232
    3333PCUT_IMPORT(display);
     34PCUT_IMPORT(wndresize);
    3435
    3536PCUT_MAIN();
  • uspace/srv/hid/display/dsops.c

    r9242ad9 r9901f267  
    169169        ds_window_t *wnd;
    170170
     171        if (!display_wndrsz_valid(rsztype))
     172                return EINVAL;
     173
    171174        ds_display_lock(client->display);
    172175
  • uspace/srv/hid/display/seat.c

    r9242ad9 r9901f267  
    4545#include "window.h"
    4646
     47static errno_t ds_seat_clear_pointer(ds_seat_t *);
     48static errno_t ds_seat_draw_pointer(ds_seat_t *);
     49
    4750/** Create seat.
    4851 *
     
    6366        seat->pntpos.y = 0;
    6467
    65         seat->cursor = display->cursor[dcurs_arrow];
     68        seat->client_cursor = display->cursor[dcurs_arrow];
     69        seat->wm_cursor = NULL;
    6670
    6771        *rseat = seat;
     
    145149}
    146150
     151/** Get current cursor used by seat.
     152 *
     153 * @param wmcurs WM curor
     154 * @param ccurs Client cursor
     155 * @return
     156 */
     157static ds_cursor_t *ds_seat_compute_cursor(ds_cursor_t *wmcurs, ds_cursor_t *ccurs)
     158{
     159        if (wmcurs != NULL)
     160                return wmcurs;
     161
     162        return ccurs;
     163}
     164
     165/** Get current cursor used by seat.
     166 *
     167 * @param seat Seat
     168 * @return Current cursor
     169 */
     170static ds_cursor_t *ds_seat_get_cursor(ds_seat_t *seat)
     171{
     172        return ds_seat_compute_cursor(seat->wm_cursor, seat->client_cursor);
     173}
     174
     175/** Set client cursor.
     176 *
     177 * Set cursor selected by client. This may update the actual cursor
     178 * if WM is not overriding the cursor.
     179 *
     180 * @param seat Seat
     181 * @param cursor Client cursor
     182 */
     183static void ds_seat_set_client_cursor(ds_seat_t *seat, ds_cursor_t *cursor)
     184{
     185        ds_cursor_t *old_cursor;
     186        ds_cursor_t *new_cursor;
     187
     188        old_cursor = ds_seat_get_cursor(seat);
     189        new_cursor = ds_seat_compute_cursor(seat->wm_cursor, cursor);
     190
     191        if (new_cursor != old_cursor)
     192                ds_seat_clear_pointer(seat);
     193
     194        seat->client_cursor = cursor;
     195
     196        if (new_cursor != old_cursor)
     197                ds_seat_draw_pointer(seat);
     198}
     199
     200/** Set WM cursor.
     201 *
     202 * Set cursor override for window management.
     203 *
     204 * @param seat Seat
     205 * @param cursor WM cursor override or @c NULL not to override the cursor
     206 */
     207void ds_seat_set_wm_cursor(ds_seat_t *seat, ds_cursor_t *cursor)
     208{
     209        ds_cursor_t *old_cursor;
     210        ds_cursor_t *new_cursor;
     211
     212        old_cursor = ds_seat_get_cursor(seat);
     213        new_cursor = ds_seat_compute_cursor(cursor, seat->client_cursor);
     214
     215        if (new_cursor != old_cursor)
     216                ds_seat_clear_pointer(seat);
     217
     218        seat->wm_cursor = cursor;
     219
     220        if (new_cursor != old_cursor)
     221                ds_seat_draw_pointer(seat);
     222}
     223
    147224/** Draw seat pointer
    148225 *
     
    153230static errno_t ds_seat_draw_pointer(ds_seat_t *seat)
    154231{
    155         return ds_cursor_paint(seat->cursor, &seat->pntpos);
     232        ds_cursor_t *cursor;
     233
     234        cursor = ds_seat_get_cursor(seat);
     235        return ds_cursor_paint(cursor, &seat->pntpos);
    156236}
    157237
     
    165245{
    166246        gfx_rect_t rect;
     247        ds_cursor_t *cursor;
     248
     249        cursor = ds_seat_get_cursor(seat);
    167250
    168251        /* Get rectangle covered by cursor */
    169         ds_cursor_get_rect(seat->cursor, &seat->pntpos, &rect);
     252        ds_cursor_get_rect(cursor, &seat->pntpos, &rect);
    170253
    171254        /* Repaint it */
     
    182265 * @return EOK on success or an error code
    183266 */
    184 #include <stdio.h>
    185267errno_t ds_seat_post_ptd_event(ds_seat_t *seat, ptd_event_t *event)
    186268{
     
    279361        if (wnd != NULL) {
    280362                /* Moving over a window */
    281                 seat->cursor = wnd->cursor;
     363                ds_seat_set_client_cursor(seat, wnd->cursor);
    282364
    283365                rc = ds_window_post_pos_event(wnd, event);
     
    286368        } else {
    287369                /* Not over a window */
    288                 seat->cursor = seat->display->cursor[dcurs_arrow];
     370                ds_seat_set_client_cursor(seat, seat->display->cursor[dcurs_arrow]);
    289371        }
    290372
  • uspace/srv/hid/display/seat.h

    r9242ad9 r9901f267  
    5252extern errno_t ds_seat_post_ptd_event(ds_seat_t *, ptd_event_t *);
    5353extern errno_t ds_seat_post_pos_event(ds_seat_t *, pos_event_t *);
     54extern void ds_seat_set_wm_cursor(ds_seat_t *, ds_cursor_t *);
    5455
    5556#endif
  • uspace/srv/hid/display/test/seat.c

    r9242ad9 r9901f267  
    353353}
    354354
     355/** Set WM cursor */
     356PCUT_TEST(set_wm_cursor)
     357{
     358        ds_display_t *disp;
     359        ds_client_t *client;
     360        ds_seat_t *seat;
     361        bool called_cb = false;
     362        errno_t rc;
     363
     364        rc = ds_display_create(NULL, &disp);
     365        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     366
     367        rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
     368        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     369
     370        rc = ds_seat_create(disp, &seat);
     371        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     372
     373        ds_seat_set_wm_cursor(seat, disp->cursor[dcurs_size_ud]);
     374        ds_seat_set_wm_cursor(seat, NULL);
     375
     376        ds_seat_destroy(seat);
     377        ds_client_destroy(client);
     378        ds_display_destroy(disp);
     379}
     380
    355381PCUT_EXPORT(seat);
  • uspace/srv/hid/display/test/window.c

    r9242ad9 r9901f267  
    3636#include "../client.h"
    3737#include "../display.h"
     38#include "../seat.h"
    3839#include "../window.h"
    3940
     
    5556        ds_display_t *disp;
    5657        ds_client_t *client;
     58        ds_seat_t *seat;
    5759        ds_window_t *wnd;
    5860        display_wnd_params_t params;
     
    6567
    6668        rc = ds_client_create(disp, NULL, NULL, &client);
     69        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     70
     71        rc = ds_seat_create(disp, &seat);
    6772        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    6873
     
    8994
    9095        ds_window_destroy(wnd);
     96        ds_seat_destroy(seat);
    9197        ds_client_destroy(client);
    9298        ds_display_destroy(disp);
     
    288294        ds_display_t *disp;
    289295        ds_client_t *client;
     296        ds_seat_t *seat;
    290297        ds_window_t *wnd;
    291298        display_wnd_params_t params;
     
    300307
    301308        rc = ds_client_create(disp, NULL, NULL, &client);
     309        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     310
     311        rc = ds_seat_create(disp, &seat);
    302312        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    303313
     
    321331
    322332        ds_window_destroy(wnd);
     333        ds_seat_destroy(seat);
    323334        ds_client_destroy(client);
    324335        ds_display_destroy(disp);
     
    639650}
    640651
    641 
    642652static errno_t dummy_set_color(void *arg, gfx_color_t *color)
    643653{
  • uspace/srv/hid/display/types/display/seat.h

    r9242ad9 r9901f267  
    4848        /** Window this seat is focused on */
    4949        struct ds_window *focus;
    50         /** Current seat cursor */
    51         struct ds_cursor *cursor;
     50        /** Cursor selected by client */
     51        struct ds_cursor *client_cursor;
     52        /** Cursor override for window management or @c NULL */
     53        struct ds_cursor *wm_cursor;
    5254        /** Pointer position */
    5355        gfx_coord2_t pntpos;
  • uspace/srv/hid/display/window.c

    r9242ad9 r9901f267  
    4545#include "client.h"
    4646#include "display.h"
     47#include "seat.h"
    4748#include "window.h"
    4849
     
    515516    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
    516517{
     518        ds_seat_t *seat;
     519        display_stock_cursor_t ctype;
     520
    517521        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)",
    518522            (int) pos->x, (int) pos->y);
     
    525529        wnd->rsztype = rsztype;
    526530        wnd->preview_rect = wnd->rect;
     531
     532        // XXX Need client to tell us which seat started the resize!
     533        seat = ds_display_first_seat(wnd->display);
     534        ctype = display_cursor_from_wrsz(rsztype);
     535        ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]);
    527536}
    528537
     
    536545        gfx_coord2_t dresize;
    537546        gfx_rect_t nrect;
     547        ds_seat_t *seat;
    538548
    539549        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)",
     
    552562        wnd->state = dsw_idle;
    553563        ds_client_post_resize_event(wnd->client, wnd, &nrect);
     564
     565        // XXX Need to know which seat started the resize!
     566        seat = ds_display_first_seat(wnd->display);
     567        ds_seat_set_wm_cursor(seat, NULL);
    554568}
    555569
Note: See TracChangeset for help on using the changeset viewer.