Ignore:
File:
1 edited

Legend:

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

    rbe0ec50 r90f1f19  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444#include <memgfx/memgc.h>
    4545#include <stdlib.h>
    46 #include <str.h>
    47 #include <wndmgt.h>
    4846#include "client.h"
    4947#include "display.h"
    5048#include "seat.h"
    5149#include "window.h"
    52 #include "wmclient.h"
    5350
    5451static void ds_window_invalidate_cb(void *, gfx_rect_t *);
     
    5653static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *);
    5754
    58 static mem_gc_cb_t ds_window_mem_gc_cb = {
    59         .invalidate = ds_window_invalidate_cb,
    60         .update = ds_window_update_cb
    61 };
    62 
    6355/** Create window.
    6456 *
     
    6759 * @param client Client owning the window
    6860 * @param params Window parameters
    69  * @param rwnd Place to store pointer to new window.
     61 * @param rgc Place to store pointer to new GC.
    7062 *
    7163 * @return EOK on success or an error code
    7264 */
    7365errno_t ds_window_create(ds_client_t *client, display_wnd_params_t *params,
    74     ds_window_t **rwnd)
     66    ds_window_t **rgc)
    7567{
    7668        ds_window_t *wnd = NULL;
     
    8880        }
    8981
    90         /* Caption */
    91         wnd->caption = str_dup(params->caption);
    92         if (wnd->caption == NULL) {
    93                 rc = ENOMEM;
    94                 goto error;
    95         }
    96 
    97         wnd->flags = params->flags;
    98 
    9982        ds_client_add_window(client, wnd);
    10083        ds_display_add_window(client->display, wnd);
     
    10285        gfx_bitmap_params_init(&bparams);
    10386        bparams.rect = params->rect;
    104 
    105         /* Allocate window bitmap */
    10687
    10788        dgc = ds_display_get_gc(wnd->display);
     
    127108        }
    128109
    129         rc = mem_gc_create(&params->rect, &alloc, &ds_window_mem_gc_cb,
    130             (void *)wnd, &wnd->mgc);
     110        rc = mem_gc_create(&params->rect, &alloc, ds_window_invalidate_cb,
     111            ds_window_update_cb, (void *)wnd, &wnd->mgc);
    131112        if (rc != EOK)
    132113                goto error;
     
    136117        wnd->gc = mem_gc_get_ctx(wnd->mgc);
    137118        wnd->cursor = wnd->display->cursor[dcurs_arrow];
     119        wnd->flags = params->flags;
    138120
    139121        if ((params->flags & wndf_setpos) != 0) {
     
    146128        }
    147129
    148         /* Determine which seat should own the window */
    149         if (params->idev_id != 0)
    150                 seat = ds_display_seat_by_idev(wnd->display, params->idev_id);
    151         else
    152                 seat = ds_display_default_seat(wnd->display);
    153 
    154         /* Is this a popup window? */
     130        seat = ds_display_first_seat(client->display);
     131
    155132        if ((params->flags & wndf_popup) != 0)
    156133                ds_seat_set_popup(seat, wnd);
     
    158135                ds_seat_set_focus(seat, wnd);
    159136
    160         /* Is this window a panel? */
    161         if ((params->flags & wndf_avoid) != 0)
    162                 ds_display_update_max_rect(wnd->display);
    163 
    164137        (void) ds_display_paint(wnd->display, NULL);
    165138
    166         *rwnd = wnd;
     139        *rgc = wnd;
    167140        return EOK;
    168141error:
    169142        if (wnd != NULL) {
    170                 ds_client_remove_window(wnd);
    171                 ds_display_remove_window(wnd);
    172                 if (wnd->mgc != NULL)
    173                         mem_gc_delete(wnd->mgc);
    174143                if (wnd->bitmap != NULL)
    175144                        gfx_bitmap_destroy(wnd->bitmap);
    176                 if (wnd->caption != NULL)
    177                         free(wnd->caption);
    178145                free(wnd);
    179146        }
     
    191158
    192159        disp = wnd->display;
    193 
    194         ds_window_unfocus(wnd);
    195160
    196161        ds_client_remove_window(wnd);
    197162        ds_display_remove_window(wnd);
    198163
    199         if ((wnd->flags & wndf_avoid) != 0)
    200                 ds_display_update_max_rect(disp);
    201 
    202164        mem_gc_delete(wnd->mgc);
    203165
     
    205167                gfx_bitmap_destroy(wnd->bitmap);
    206168
    207         free(wnd->caption);
    208169        free(wnd);
    209170
     
    217178void ds_window_bring_to_top(ds_window_t *wnd)
    218179{
    219         ds_display_window_to_top(wnd);
     180        ds_display_t *disp = wnd->display;
     181
     182        ds_display_remove_window(wnd);
     183        ds_display_add_window(disp, wnd);
    220184        (void) ds_display_paint(wnd->display, NULL);
    221185}
     
    229193{
    230194        return wnd->gc;
    231 }
    232 
    233 /** Determine if window is visible.
    234  *
    235  * @param wnd Window
    236  * @return @c true iff window is visible
    237  */
    238 bool ds_window_is_visible(ds_window_t *wnd)
    239 {
    240         return (wnd->flags & wndf_minimized) == 0;
    241195}
    242196
     
    253207        gfx_rect_t crect;
    254208
    255         log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_paint");
    256 
    257         /* Skip painting the window if not visible */
    258         if (!ds_window_is_visible(wnd))
    259                 return EOK;
     209        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_paint");
    260210
    261211        if (rect != NULL) {
     
    402352        bool newr;
    403353
    404         log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_repaint_preview");
     354        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_repaint_preview");
    405355
    406356        /*
     
    446396 * @param wnd Window
    447397 * @param pos Position where mouse button was pressed
    448  * @param pos_id Positioning device ID
    449  */
    450 static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos,
    451     sysarg_t pos_id)
     398 */
     399static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos)
    452400{
    453401        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)",
     
    458406
    459407        wnd->orig_pos = *pos;
    460         wnd->orig_pos_id = pos_id;
    461408        wnd->state = dsw_moving;
    462409        wnd->preview_pos = wnd->dpos;
     
    488435        wnd->dpos = nwpos;
    489436        wnd->state = dsw_idle;
    490         wnd->orig_pos_id = 0;
    491437
    492438        (void) ds_display_paint(wnd->display, NULL);
     
    504450        gfx_rect_t old_rect;
    505451
    506         log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_move (%d, %d)",
     452        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_move (%d, %d)",
    507453            (int) pos->x, (int) pos->y);
    508454
     
    523469 * @param rsztype Resize type (which part of window is being dragged)
    524470 * @param pos Position where mouse button was pressed
    525  * @param pos_id Positioning device ID
    526471 */
    527472static void ds_window_start_resize(ds_window_t *wnd,
    528     display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)
     473    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
    529474{
    530475        ds_seat_t *seat;
     
    537482                return;
    538483
    539         /* Determine which seat started the resize */
    540         seat = ds_display_seat_by_idev(wnd->display, pos_id);
    541         if (seat == NULL)
    542                 return;
    543 
    544484        wnd->orig_pos = *pos;
    545         wnd->orig_pos_id = pos_id;
    546485        wnd->state = dsw_resizing;
    547486        wnd->rsztype = rsztype;
    548487        wnd->preview_rect = wnd->rect;
    549488
     489        // XXX Need client to tell us which seat started the resize!
     490        seat = ds_display_first_seat(wnd->display);
    550491        ctype = display_cursor_from_wrsz(rsztype);
    551492        ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]);
     
    577518        ds_client_post_resize_event(wnd->client, wnd, &nrect);
    578519
    579         /* Determine which seat started the resize */
    580         seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
    581         if (seat != NULL)
    582                 ds_seat_set_wm_cursor(seat, NULL);
    583 
    584         wnd->orig_pos_id = 0;
     520        // XXX Need to know which seat started the resize!
     521        seat = ds_display_first_seat(wnd->display);
     522        ds_seat_set_wm_cursor(seat, NULL);
    585523
    586524        (void) ds_display_paint(wnd->display, NULL);
     
    598536        gfx_rect_t old_rect;
    599537
    600         log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_update_resize (%d, %d)",
     538        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_resize (%d, %d)",
    601539            (int) pos->x, (int) pos->y);
    602540
     
    637575 * @param wnd Window
    638576 * @param event Position event
    639  *
    640  * @return EOK on success or an error code
    641577 */
    642578errno_t ds_window_post_pos_event(ds_window_t *wnd, pos_event_t *event)
     
    644580        pos_event_t tevent;
    645581        gfx_coord2_t pos;
    646         sysarg_t pos_id;
    647582        gfx_rect_t drect;
    648583        bool inside;
    649584
    650         log_msg(LOG_DEFAULT, LVL_DEBUG2,
     585        log_msg(LOG_DEFAULT, LVL_DEBUG,
    651586            "ds_window_post_pos_event type=%d pos=%d,%d", event->type,
    652587            (int) event->hpos, (int) event->vpos);
     
    654589        pos.x = event->hpos;
    655590        pos.y = event->vpos;
    656         pos_id = event->pos_id;
    657591        gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
    658592        inside = gfx_pix_inside_rect(&pos, &drect);
    659593
    660         if (event->type == POS_PRESS && event->btn_num == 2 && inside &&
    661             (wnd->flags & wndf_maximized) == 0) {
    662                 ds_window_start_move(wnd, &pos, pos_id);
     594        if (event->type == POS_PRESS && event->btn_num == 2 && inside) {
     595                ds_window_start_move(wnd, &pos);
    663596                return EOK;
    664597        }
    665598
    666599        if (event->type == POS_RELEASE) {
    667                 /* Finish move/resize if they were started by the same seat */
    668                 if (wnd->state == dsw_moving &&
    669                     ds_window_orig_seat(wnd, pos_id)) {
     600                if (wnd->state == dsw_moving) {
    670601                        ds_window_finish_move(wnd, &pos);
    671602                        return EOK;
    672603                }
    673604
    674                 if (wnd->state == dsw_resizing &&
    675                     ds_window_orig_seat(wnd, pos_id)) {
     605                if (wnd->state == dsw_resizing) {
    676606                        ds_window_finish_resize(wnd, &pos);
    677607                        return EOK;
     
    680610
    681611        if (event->type == POS_UPDATE) {
    682                 /* Update move/resize if they were started by the same seat */
    683                 if (wnd->state == dsw_moving &&
    684                     ds_window_orig_seat(wnd, pos_id)) {
     612                if (wnd->state == dsw_moving) {
    685613                        ds_window_update_move(wnd, &pos);
    686614                        return EOK;
    687615                }
    688616
    689                 if (wnd->state == dsw_resizing &&
    690                     ds_window_orig_seat(wnd, pos_id)) {
     617                if (wnd->state == dsw_resizing) {
    691618                        ds_window_update_resize(wnd, &pos);
    692619                        return EOK;
     
    705632 *
    706633 * @param wnd Window
    707  * @return EOK on success or an error code
    708634 */
    709635errno_t ds_window_post_focus_event(ds_window_t *wnd)
    710636{
    711         display_wnd_focus_ev_t efocus;
    712         errno_t rc;
    713         ds_wmclient_t *wmclient;
    714 
    715637        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event");
    716638
    717         /* Increase focus counter */
    718         ++wnd->nfocus;
    719         efocus.nfocus = wnd->nfocus;
    720 
    721         rc = ds_client_post_focus_event(wnd->client, wnd, &efocus);
    722         if (rc != EOK)
    723                 return rc;
    724 
    725         /* Notify window managers about window information change */
    726         wmclient = ds_display_first_wmclient(wnd->display);
    727         while (wmclient != NULL) {
    728                 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
    729                 wmclient = ds_display_next_wmclient(wmclient);
    730         }
    731 
    732         return EOK;
     639        return ds_client_post_focus_event(wnd->client, wnd);
    733640}
    734641
     
    736643 *
    737644 * @param wnd Window
    738  * @return EOK on success or an error code
    739645 */
    740646errno_t ds_window_post_unfocus_event(ds_window_t *wnd)
    741647{
    742         display_wnd_unfocus_ev_t eunfocus;
    743         errno_t rc;
    744         ds_wmclient_t *wmclient;
    745 
    746648        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event");
    747649
    748         /* Decrease focus counter */
    749         --wnd->nfocus;
    750         eunfocus.nfocus = wnd->nfocus;
    751 
    752         rc = ds_client_post_unfocus_event(wnd->client, wnd, &eunfocus);
    753         if (rc != EOK)
    754                 return rc;
    755 
    756         /* Notify window managers about window information change */
    757         wmclient = ds_display_first_wmclient(wnd->display);
    758         while (wmclient != NULL) {
    759                 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
    760                 wmclient = ds_display_next_wmclient(wmclient);
    761         }
    762 
    763         return EOK;
     650        return ds_client_post_unfocus_event(wnd->client, wnd);
    764651}
    765652
     
    769656 * @param pos Position where the pointer was when the move started
    770657 *            relative to the window
    771  * @param pos_id Positioning device ID
    772658 * @param event Button press event
    773659 */
    774 void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos, sysarg_t pos_id)
     660void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos)
    775661{
    776662        gfx_coord2_t orig_pos;
     
    780666
    781667        gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
    782         ds_window_start_move(wnd, &orig_pos, pos_id);
     668        ds_window_start_move(wnd, &orig_pos);
    783669}
    784670
     
    800686{
    801687        *dpos = wnd->dpos;
    802 }
    803 
    804 /** Get maximized window rectangle.
    805  *
    806  * @param wnd Window
    807  */
    808 void ds_window_get_max_rect(ds_window_t *wnd, gfx_rect_t *rect)
    809 {
    810         *rect = wnd->display->max_rect;
    811688}
    812689
     
    817694 * @param pos Position where the pointer was when the resize started
    818695 *            relative to the window
    819  * @param pos_id Positioning device ID
    820696 * @param event Button press event
    821697 */
    822698void ds_window_resize_req(ds_window_t *wnd, display_wnd_rsztype_t rsztype,
    823     gfx_coord2_t *pos, sysarg_t pos_id)
     699    gfx_coord2_t *pos)
    824700{
    825701        gfx_coord2_t orig_pos;
    826702
    827         log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d, %d)",
    828             (int)rsztype, (int)pos->x, (int)pos->y, (int)pos_id);
     703        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_resize_req (%d, %d, %d)",
     704            (int) rsztype, (int) pos->x, (int) pos->y);
    829705
    830706        gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
    831         ds_window_start_resize(wnd, rsztype, &orig_pos, pos_id);
     707        ds_window_start_resize(wnd, rsztype, &orig_pos);
    832708}
    833709
     
    835711 *
    836712 * @param wnd Window
    837  * @return EOK on success or an error code
    838713 */
    839714errno_t ds_window_resize(ds_window_t *wnd, gfx_coord2_t *offs,
     
    886761        wnd->rect = *nrect;
    887762
    888         if ((wnd->flags & wndf_avoid) != 0)
    889                 ds_display_update_max_rect(wnd->display);
    890 
    891763        (void) ds_display_paint(wnd->display, NULL);
    892         return EOK;
    893 }
    894 
    895 /** Minimize window.
    896  *
    897  * @param wnd Window
    898  * @return EOK on success or an error code
    899  */
    900 errno_t ds_window_minimize(ds_window_t *wnd)
    901 {
    902         /* If already minimized, do nothing and return success. */
    903         if ((wnd->flags & wndf_minimized) != 0)
    904                 return EOK;
    905 
    906         ds_window_unfocus(wnd);
    907 
    908         wnd->flags |= wndf_minimized;
    909         (void) ds_display_paint(wnd->display, NULL);
    910         return EOK;
    911 }
    912 
    913 /** Unminimize window.
    914  *
    915  * @param wnd Window
    916  * @return EOK on success or an error code
    917  */
    918 errno_t ds_window_unminimize(ds_window_t *wnd)
    919 {
    920         /* If not minimized, do nothing and return success. */
    921         if ((wnd->flags & wndf_minimized) == 0)
    922                 return EOK;
    923 
    924         wnd->flags &= ~wndf_minimized;
    925         (void) ds_display_paint(wnd->display, NULL);
    926         return EOK;
    927 }
    928 
    929 /** Maximize window.
    930  *
    931  * @param wnd Window
    932  * @return EOK on success or an error code
    933  */
    934 errno_t ds_window_maximize(ds_window_t *wnd)
    935 {
    936         gfx_coord2_t old_dpos;
    937         gfx_rect_t old_rect;
    938         gfx_coord2_t offs;
    939         gfx_rect_t max_rect;
    940         gfx_rect_t nrect;
    941         errno_t rc;
    942 
    943         /* If already maximized, do nothing and return success. */
    944         if ((wnd->flags & wndf_maximized) != 0)
    945                 return EOK;
    946 
    947         /* Remember the old window rectangle and display position */
    948         old_rect = wnd->rect;
    949         old_dpos = wnd->dpos;
    950 
    951         ds_window_get_max_rect(wnd, &max_rect);
    952 
    953         /* Keep window contents on the same position on the screen */
    954         offs.x = max_rect.p0.x - wnd->dpos.x;
    955         offs.y = max_rect.p0.y - wnd->dpos.y;
    956 
    957         /* Maximized window's coordinates will start at 0,0 */
    958         gfx_rect_rtranslate(&max_rect.p0, &max_rect, &nrect);
    959 
    960         rc = ds_window_resize(wnd, &offs, &nrect);
    961         if (rc != EOK)
    962                 return rc;
    963 
    964         /* Set window flags, remember normal rectangle */
    965         wnd->flags |= wndf_maximized;
    966         wnd->normal_rect = old_rect;
    967         wnd->normal_dpos = old_dpos;
    968 
    969         return EOK;
    970 }
    971 
    972 /** Unmaximize window.
    973  *
    974  * @param wnd Window
    975  * @return EOK on success or an error code
    976  */
    977 errno_t ds_window_unmaximize(ds_window_t *wnd)
    978 {
    979         gfx_coord2_t offs;
    980         errno_t rc;
    981 
    982         /* If not maximized, do nothing and return success. */
    983         if ((wnd->flags & wndf_maximized) == 0)
    984                 return EOK;
    985 
    986         /* Keep window contents on the same position on the screen */
    987         offs.x = wnd->normal_dpos.x - wnd->dpos.x;
    988         offs.y = wnd->normal_dpos.y - wnd->dpos.y;
    989 
    990         rc = ds_window_resize(wnd, &offs, &wnd->normal_rect);
    991         if (rc != EOK)
    992                 return rc;
    993 
    994         /* Clear maximized flag */
    995         wnd->flags &= ~wndf_maximized;
    996 
    997764        return EOK;
    998765}
     
    1040807 *
    1041808 * @param wnd Window
    1042  * @param cursor New cursor
    1043809 * @return EOK on success, EINVAL if @a cursor is invalid
    1044810 */
     
    1054820}
    1055821
    1056 /** Set window caption.
    1057  *
    1058  * @param wnd Window
    1059  * @param caption New caption
    1060  *
    1061  * @return EOK on success, EINVAL if @a cursor is invalid
    1062  */
    1063 errno_t ds_window_set_caption(ds_window_t *wnd, const char *caption)
    1064 {
    1065         char *dcaption;
    1066         ds_wmclient_t *wmclient;
    1067 
    1068         dcaption = str_dup(caption);
    1069         if (dcaption == NULL)
    1070                 return ENOMEM;
    1071 
    1072         free(wnd->caption);
    1073         wnd->caption = dcaption;
    1074 
    1075         /* Notify window managers about window information change */
    1076         wmclient = ds_display_first_wmclient(wnd->display);
    1077         while (wmclient != NULL) {
    1078                 ds_wmclient_post_wnd_changed_event(wmclient, wnd->id);
    1079                 wmclient = ds_display_next_wmclient(wmclient);
    1080         }
    1081 
    1082         return EOK;
    1083 }
    1084 
    1085 /** Find alternate window with the allowed flags.
    1086  *
    1087  * An alternate window is a *different* window that is preferably previous
    1088  * in the display order and only has the @a allowed flags.
    1089  *
    1090  * @param wnd Window
    1091  * @param allowed_flags Bitmask of flags that the window is allowed to have
    1092  *
    1093  * @return Alternate window matching the criteria or @c NULL if there is none
    1094  */
    1095 ds_window_t *ds_window_find_prev(ds_window_t *wnd,
    1096     display_wnd_flags_t allowed_flags)
    1097 {
    1098         ds_window_t *nwnd;
    1099 
    1100         /* Try preceding windows in display order */
    1101         nwnd = ds_display_next_window(wnd);
    1102         while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
    1103                 nwnd = ds_display_next_window(nwnd);
    1104         }
    1105 
    1106         /* Do we already have a matching window? */
    1107         if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
    1108                 return nwnd;
    1109         }
    1110 
    1111         /* Try succeeding windows in display order */
    1112         nwnd = ds_display_first_window(wnd->display);
    1113         while (nwnd != NULL && nwnd != wnd &&
    1114             (nwnd->flags & ~allowed_flags) != 0) {
    1115                 nwnd = ds_display_next_window(nwnd);
    1116         }
    1117 
    1118         if (nwnd == wnd)
    1119                 return NULL;
    1120 
    1121         return nwnd;
    1122 }
    1123 
    1124 /** Find alternate window with the allowed flags.
    1125  *
    1126  * An alternate window is a *different* window that is preferably previous
    1127  * in the display order and only has the @a allowed flags.
    1128  *
    1129  * @param wnd Window
    1130  * @param allowed_flags Bitmask of flags that the window is allowed to have
    1131  *
    1132  * @return Alternate window matching the criteria or @c NULL if there is none
    1133  */
    1134 ds_window_t *ds_window_find_next(ds_window_t *wnd,
    1135     display_wnd_flags_t allowed_flags)
    1136 {
    1137         ds_window_t *nwnd;
    1138 
    1139         /* Try preceding windows in display order */
    1140         nwnd = ds_display_prev_window(wnd);
    1141         while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
    1142                 nwnd = ds_display_prev_window(nwnd);
    1143         }
    1144 
    1145         /* Do we already have a matching window? */
    1146         if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
    1147                 return nwnd;
    1148         }
    1149 
    1150         /* Try succeeding windows in display order */
    1151         nwnd = ds_display_last_window(wnd->display);
    1152         while (nwnd != NULL && nwnd != wnd &&
    1153             (nwnd->flags & ~allowed_flags) != 0) {
    1154                 nwnd = ds_display_prev_window(nwnd);
    1155         }
    1156 
    1157         if (nwnd == wnd)
    1158                 return NULL;
    1159 
    1160         return nwnd;
    1161 }
    1162 
    1163 /** Remove focus from window.
    1164  *
    1165  * Used to switch focus to another window when closing or minimizing window.
    1166  *
    1167  * @param wnd Window
    1168  */
    1169 void ds_window_unfocus(ds_window_t *wnd)
    1170 {
    1171         ds_seat_t *seat;
    1172 
    1173         /* Make sure window is no longer focused in any seat */
    1174         seat = ds_display_first_seat(wnd->display);
    1175         while (seat != NULL) {
    1176                 ds_seat_unfocus_wnd(seat, wnd);
    1177                 seat = ds_display_next_seat(seat);
    1178         }
    1179 }
    1180 
    1181 /** Determine if input device belongs to the same seat as the original device.
    1182  *
    1183  * Compare the seat ownning @a idev_id with the seat owning @a wnd->orig_pos_id
    1184  * (the device that started the window move or resize).
    1185  *
    1186  * This is used to make sure that, when two seats focus the same window,
    1187  * only devices owned by the seat that started the resize or move can
    1188  * affect it. Otherwise moving the other pointer(s) would disrupt the
    1189  * resize or move operation.
    1190  *
    1191  * @param wnd Window (that is currently being resized or moved)
    1192  * @param idev_id Input device ID
    1193  * @return @c true iff idev_id is owned by the same seat as the input
    1194  *         device that started the resize or move
    1195  */
    1196 bool ds_window_orig_seat(ds_window_t *wnd, sysarg_t idev_id)
    1197 {
    1198         ds_seat_t *orig_seat;
    1199         ds_seat_t *seat;
    1200 
    1201         /* Window must be in state such that wnd->orig_pos_id is valid */
    1202         assert(wnd->state == dsw_moving || wnd->state == dsw_resizing);
    1203 
    1204         orig_seat = ds_display_seat_by_idev(wnd->display, wnd->orig_pos_id);
    1205         seat = ds_display_seat_by_idev(wnd->display, idev_id);
    1206 
    1207         return seat == orig_seat;
    1208 }
    1209 
    1210822/** Window memory GC invalidate callback.
    1211823 *
Note: See TracChangeset for help on using the changeset viewer.