Changeset 9901f267 in mainline for uspace/srv/hid/display/seat.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.