Changeset 17c0f5d in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2023-01-05T19:28:22Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ededdc4
Parents:
5d86797
Message:

Switch to another window when window is minimized

And do it properly. Never switch to a minimized window. Only switch to
a system window (Task bar) when no other is available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/window.c

    r5d86797 r17c0f5d  
    6767 * @param client Client owning the window
    6868 * @param params Window parameters
    69  * @param rgc Place to store pointer to new GC.
     69 * @param rwnd Place to store pointer to new window.
    7070 *
    7171 * @return EOK on success or an error code
    7272 */
    7373errno_t ds_window_create(ds_client_t *client, display_wnd_params_t *params,
    74     ds_window_t **rgc)
     74    ds_window_t **rwnd)
    7575{
    7676        ds_window_t *wnd = NULL;
     
    155155        (void) ds_display_paint(wnd->display, NULL);
    156156
    157         *rgc = wnd;
     157        *rwnd = wnd;
    158158        return EOK;
    159159error:
     
    867867                return EOK;
    868868
     869        ds_window_unfocus(wnd);
     870
    869871        wnd->flags |= wndf_minimized;
    870872        (void) ds_display_paint(wnd->display, NULL);
     
    10441046}
    10451047
     1048/** Find alternate window with the allowed flags.
     1049 *
     1050 * An alternate window is a *different* window that is preferably previous
     1051 * in the display order and only has the @a allowed flags.
     1052 *
     1053 * @param wnd Window
     1054 * @param allowed_flags Bitmask of flags that the window is allowed to have
     1055 *
     1056 * @return Alternate window matching the criteria or @c NULL if there is none
     1057 */
     1058ds_window_t *ds_window_find_alt(ds_window_t *wnd,
     1059    display_wnd_flags_t allowed_flags)
     1060{
     1061        ds_window_t *nwnd;
     1062
     1063        /* Try preceding windows in display order */
     1064        nwnd = ds_display_prev_window(wnd);
     1065        while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
     1066                nwnd = ds_display_prev_window(nwnd);
     1067        }
     1068
     1069        /* Do we already have a matching window? */
     1070        if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
     1071                return nwnd;
     1072        }
     1073
     1074        /* Try succeeding windows in display order */
     1075        nwnd = ds_display_last_window(wnd->display);
     1076        while (nwnd != NULL && nwnd != wnd &&
     1077            (nwnd->flags & ~allowed_flags) != 0) {
     1078                nwnd = ds_display_prev_window(nwnd);
     1079        }
     1080
     1081        if (nwnd == wnd)
     1082                return NULL;
     1083
     1084        return nwnd;
     1085}
     1086
     1087/** Remove focus from window.
     1088 *
     1089 * Used to switch focus to another window when closing or minimizing window.
     1090 *
     1091 * @param wnd Window
     1092 */
     1093void ds_window_unfocus(ds_window_t *wnd)
     1094{
     1095        ds_seat_t *seat;
     1096
     1097        /* Make sure window is no longer focused in any seat */
     1098        seat = ds_display_first_seat(wnd->display);
     1099        while (seat != NULL) {
     1100                ds_seat_unfocus_wnd(seat, wnd);
     1101                seat = ds_display_next_seat(seat);
     1102        }
     1103}
     1104
    10461105/** Window memory GC invalidate callback.
    10471106 *
Note: See TracChangeset for help on using the changeset viewer.