Changeset 3a6d44b7 in mainline


Ignore:
Timestamp:
2022-11-07T17:42:51Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60ebe63
Parents:
f1f433d
Message:

Activate window by pushing window button on taskbar

Note that with multiple seats, one would need to know which seat pushed
the button and set the appropriate focus.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar/wndlist.c

    rf1f433d r3a6d44b7  
    5050static void wndlist_wm_window_changed(void *, sysarg_t);
    5151
     52/** Window list WM callbacks */
    5253static wndmgt_cb_t wndlist_wndmgt_cb = {
    5354        .window_added = wndlist_wm_window_added,
    5455        .window_removed = wndlist_wm_window_removed,
    5556        .window_changed = wndlist_wm_window_changed
     57};
     58
     59static void wndlist_button_clicked(ui_pbutton_t *, void *);
     60
     61/** Window list button callbacks */
     62static ui_pbutton_cb_t wndlist_button_cb = {
     63        .clicked = wndlist_button_clicked
    5664};
    5765
     
    186194        /* Set the button rectangle */
    187195        wndlist_set_entry_rect(wndlist, entry);
     196
     197        /* Set button callbacks */
     198        ui_pbutton_set_cb(entry->button, &wndlist_button_cb, (void *)entry);
    188199
    189200        rc = ui_fixed_add(wndlist->fixed, ui_pbutton_ctl(entry->button));
     
    340351        wndlist_entry_t *entry;
    341352
    342         printf("wm_window_removed: wndlist=%p wnd_id=%zu\n",
    343             (void *)wndlist, wnd_id);
    344 
    345353        entry = wndlist_entry_by_id(wndlist, wnd_id);
    346354        if (entry == NULL)
     
    361369        wndlist_entry_t *entry;
    362370        errno_t rc;
    363 
    364         printf("wm_window_changed: wndlist=%p wnd_id=%zu\n",
    365             (void *)wndlist, wnd_id);
    366371
    367372        entry = wndlist_entry_by_id(wndlist, wnd_id);
     
    440445}
    441446
     447/** Window button was clicked.
     448 *
     449 * @param pbutton Push button
     450 * @param arg Argument (wdnlist_entry_t *)
     451 */
     452static void wndlist_button_clicked(ui_pbutton_t *pbutton, void *arg)
     453{
     454        wndlist_entry_t *entry = (wndlist_entry_t *)arg;
     455        sysarg_t seat_id;
     456
     457        seat_id = 0; // TODO Multi-seat
     458
     459        (void) wndmgt_activate_window(entry->wndlist->wndmgt,
     460            seat_id, entry->wnd_id);
     461}
     462
    442463/** @}
    443464 */
  • uspace/lib/wndmgt/include/wndmgt.h

    rf1f433d r3a6d44b7  
    4747    wndmgt_window_info_t **);
    4848extern void wndmgt_free_window_info(wndmgt_window_info_t *);
    49 extern errno_t wndmgt_activate_window(wndmgt_t *, sysarg_t);
     49extern errno_t wndmgt_activate_window(wndmgt_t *, sysarg_t, sysarg_t);
    5050extern errno_t wndmgt_close_window(wndmgt_t *, sysarg_t);
    5151
  • uspace/lib/wndmgt/include/wndmgt_srv.h

    rf1f433d r3a6d44b7  
    5252        errno_t (*get_window_list)(void *, wndmgt_window_list_t **);
    5353        errno_t (*get_window_info)(void *, sysarg_t, wndmgt_window_info_t **);
    54         errno_t (*activate_window)(void *, sysarg_t);
     54        errno_t (*activate_window)(void *, sysarg_t, sysarg_t);
    5555        errno_t (*close_window)(void *, sysarg_t);
    5656        errno_t (*get_event)(void *, wndmgt_ev_t *);
  • uspace/lib/wndmgt/src/wndmgt.c

    rf1f433d r3a6d44b7  
    287287 *
    288288 * @param wndmgt Window management session
     289 * @param seat_id Seat ID
    289290 * @param wnd_id Window ID
    290291 * @return EOK on success or an error code
    291292 */
    292 errno_t wndmgt_activate_window(wndmgt_t *wndmgt, sysarg_t wnd_id)
     293errno_t wndmgt_activate_window(wndmgt_t *wndmgt, sysarg_t seat_id,
     294    sysarg_t wnd_id)
    293295{
    294296        async_exch_t *exch;
     
    296298
    297299        exch = async_exchange_begin(wndmgt->sess);
    298         rc = async_req_1_0(exch, WNDMGT_ACTIVATE_WINDOW, wnd_id);
     300        rc = async_req_2_0(exch, WNDMGT_ACTIVATE_WINDOW, seat_id,
     301            wnd_id);
    299302
    300303        async_exchange_end(exch);
  • uspace/lib/wndmgt/src/wndmgt_srv.c

    rf1f433d r3a6d44b7  
    204204static void wndmgt_activate_window_srv(wndmgt_srv_t *srv, ipc_call_t *icall)
    205205{
     206        sysarg_t seat_id;
    206207        sysarg_t wnd_id;
    207208        errno_t rc;
    208209
    209         wnd_id = ipc_get_arg1(icall);
     210        seat_id = ipc_get_arg1(icall);
     211        wnd_id = ipc_get_arg2(icall);
    210212
    211213        if (srv->ops->activate_window == NULL) {
     
    214216        }
    215217
    216         rc = srv->ops->activate_window(srv->arg, wnd_id);
     218        rc = srv->ops->activate_window(srv->arg, seat_id, wnd_id);
    217219        async_answer_0(icall, rc);
    218220}
  • uspace/lib/wndmgt/test/wndmgt.c

    rf1f433d r3a6d44b7  
    4848static errno_t test_get_window_list(void *, wndmgt_window_list_t **);
    4949static errno_t test_get_window_info(void *, sysarg_t, wndmgt_window_info_t **);
    50 static errno_t test_activate_window(void *, sysarg_t);
     50static errno_t test_activate_window(void *, sysarg_t, sysarg_t);
    5151static errno_t test_close_window(void *, sysarg_t);
    5252static errno_t test_get_event(void *, wndmgt_ev_t *);
     
    8888
    8989        bool activate_window_called;
     90        sysarg_t activate_window_seat_id;
    9091        sysarg_t activate_window_wnd_id;
    9192
     
    302303        service_id_t sid;
    303304        wndmgt_t *wndmgt = NULL;
     305        sysarg_t seat_id;
    304306        sysarg_t wnd_id;
    305307        test_response_t resp;
     
    318320        PCUT_ASSERT_NOT_NULL(wndmgt);
    319321
     322        seat_id = 13;
    320323        wnd_id = 42;
    321324        resp.rc = ENOMEM;
    322325        resp.activate_window_called = false;
    323326
    324         rc = wndmgt_activate_window(wndmgt, wnd_id);
     327        rc = wndmgt_activate_window(wndmgt, seat_id, wnd_id);
    325328        PCUT_ASSERT_TRUE(resp.activate_window_called);
     329        PCUT_ASSERT_INT_EQUALS(seat_id, resp.activate_window_seat_id);
    326330        PCUT_ASSERT_INT_EQUALS(wnd_id, resp.activate_window_wnd_id);
    327331        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     
    338342        service_id_t sid;
    339343        wndmgt_t *wndmgt = NULL;
     344        sysarg_t seat_id;
    340345        sysarg_t wnd_id;
    341346        test_response_t resp;
     
    354359        PCUT_ASSERT_NOT_NULL(wndmgt);
    355360
     361        seat_id = 13;
    356362        wnd_id = 42;
    357363        resp.rc = EOK;
    358364        resp.activate_window_called = false;
    359365
    360         rc = wndmgt_activate_window(wndmgt, wnd_id);
     366        rc = wndmgt_activate_window(wndmgt, seat_id, wnd_id);
    361367        PCUT_ASSERT_TRUE(resp.activate_window_called);
     368        PCUT_ASSERT_INT_EQUALS(seat_id, resp.activate_window_seat_id);
    362369        PCUT_ASSERT_INT_EQUALS(wnd_id, resp.activate_window_wnd_id);
    363370        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     
    666673}
    667674
    668 static errno_t test_activate_window(void *arg, sysarg_t wnd_id)
     675static errno_t test_activate_window(void *arg, sysarg_t seat_id,
     676    sysarg_t wnd_id)
    669677{
    670678        test_response_t *resp = (test_response_t *) arg;
    671679
    672680        resp->activate_window_called = true;
     681        resp->activate_window_seat_id = seat_id;
    673682        resp->activate_window_wnd_id = wnd_id;
    674683        return resp->rc;
  • uspace/srv/hid/display/wmops.c

    rf1f433d r3a6d44b7  
    4040#include <wndmgt_srv.h>
    4141#include "display.h"
     42#include "seat.h"
    4243#include "wmclient.h"
    4344
    4445static errno_t dispwm_get_window_list(void *, wndmgt_window_list_t **);
    4546static errno_t dispwm_get_window_info(void *, sysarg_t, wndmgt_window_info_t **);
    46 static errno_t dispwm_activate_window(void *, sysarg_t);
     47static errno_t dispwm_activate_window(void *, sysarg_t, sysarg_t);
    4748static errno_t dispwm_close_window(void *, sysarg_t);
    4849static errno_t dispwm_get_event(void *, wndmgt_ev_t *);
     
    150151 *
    151152 * @param arg Argument (WM client)
     153 * @param seat_id Seat ID
    152154 * @param wnd_id Window ID
    153155 * @return EOK on success or an error code
    154156 */
    155 static errno_t dispwm_activate_window(void *arg, sysarg_t wnd_id)
    156 {
     157static errno_t dispwm_activate_window(void *arg, sysarg_t seat_id,
     158    sysarg_t wnd_id)
     159{
     160        ds_wmclient_t *wmclient = (ds_wmclient_t *)arg;
     161        ds_window_t *wnd;
     162        ds_seat_t *seat;
     163
    157164        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispwm_activate_window()");
    158         (void)arg;
    159         (void)wnd_id;
     165
     166        ds_display_lock(wmclient->display);
     167        wnd = ds_display_find_window(wmclient->display, wnd_id);
     168        if (wnd == NULL) {
     169                ds_display_unlock(wmclient->display);
     170                return ENOENT;
     171        }
     172
     173        // TODO Multi-seat
     174        (void) seat_id;
     175        seat = ds_display_first_seat(wnd->display);
     176
     177        /* Switch focus */
     178        ds_seat_set_focus(seat, wnd);
     179
     180        ds_display_unlock(wmclient->display);
    160181        return EOK;
    161182}
Note: See TracChangeset for help on using the changeset viewer.