Changeset 8edec53 in mainline
- Timestamp:
- 2021-10-25T17:51:10Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91ece11b
- Parents:
- 805a149
- Location:
- uspace
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/nav.c
r805a149 r8edec53 130 130 ui_wnd_params_t params; 131 131 gfx_rect_t rect; 132 gfx_rect_t arect; 133 gfx_coord_t pw; 132 134 unsigned i; 133 135 errno_t rc; … … 155 157 156 158 ui_window_set_cb(navigator->window, &window_cb, (void *) navigator); 159 ui_window_get_app_rect(navigator->window, &arect); 157 160 158 161 rc = ui_fixed_create(&navigator->fixed); … … 176 179 return rc; 177 180 } 181 182 /* Panel width */ 183 pw = (arect.p1.x - arect.p0.x) / 2; 178 184 179 185 for (i = 0; i < 2; i++) { … … 183 189 goto error; 184 190 185 rect.p0.x = 40* i;186 rect.p0.y = 1;187 rect.p1.x = 40* (i + 1);188 rect.p1.y = 24;191 rect.p0.x = arect.p0.x + pw * i; 192 rect.p0.y = arect.p0.y + 1; 193 rect.p1.x = arect.p0.x + pw * (i + 1); 194 rect.p1.y = arect.p1.y - 1; 189 195 panel_set_rect(navigator->panel[i], &rect); 190 196 -
uspace/app/nav/panel.c
r805a149 r8edec53 351 351 panel_activate_req(panel); 352 352 353 i f (event->type == POS_PRESS) {354 irect.p0.x = panel->rect.p0.x+ 1;355 irect.p0.y = panel->rect.p0.y +1;356 irect.p1.x = panel->rect.p1.x- 1;357 irect.p1.y = panel->rect.p1.y - 1; 358 353 irect.p0.x = panel->rect.p0.x + 1; 354 irect.p0.y = panel->rect.p0.y + 1; 355 irect.p1.x = panel->rect.p1.x - 1; 356 irect.p1.y = panel->rect.p1.y - 1; 357 358 if (event->type == POS_PRESS || event->type == POS_DCLICK) { 359 359 /* Did we click on one of the entries? */ 360 360 if (gfx_pix_inside_rect(&pos, &irect)) { … … 365 365 entry = panel_page_nth_entry(panel, n, &entry_idx); 366 366 367 /* Move to the entry found */ 368 panel_cursor_move(panel, entry, entry_idx); 367 if (event->type == POS_PRESS) { 368 /* Move to the entry found */ 369 panel_cursor_move(panel, entry, entry_idx); 370 } else { 371 /* event->type == POS_DCLICK */ 372 panel_open(panel, entry); 373 } 369 374 } else { 370 /* It's in the border. Top or bottom half? */ 371 if (pos.y >= (irect.p0.y + irect.p1.y) / 2) 372 panel_page_down(panel); 373 else 374 panel_page_up(panel); 375 /* It's in the border. */ 376 if (event->type == POS_PRESS) { 377 /* Top or bottom half? */ 378 if (pos.y >= (irect.p0.y + irect.p1.y) / 2) 379 panel_page_down(panel); 380 else 381 panel_page_up(panel); 382 } 375 383 } 376 384 } -
uspace/app/nav/panel.h
r805a149 r8edec53 83 83 extern void panel_activate_req(panel_t *); 84 84 85 86 85 #endif 87 86 -
uspace/app/terminal/terminal.c
r805a149 r8edec53 842 842 sysarg_t sy = -term->off.y; 843 843 844 if (event->type == POS_PRESS || event->type == POS_RELEASE) { 844 if (event->type == POS_PRESS || event->type == POS_RELEASE || 845 event->type == POS_DCLICK) { 845 846 cevent.type = CEV_POS; 846 847 cevent.ev.pos.type = event->type; -
uspace/lib/c/generic/io/input.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 164 164 } 165 165 166 static void input_ev_dclick(input_t *input, ipc_call_t *call) 167 { 168 int bnum; 169 errno_t rc; 170 171 bnum = ipc_get_arg1(call); 172 173 rc = input->ev_ops->dclick(input, bnum); 174 async_answer_0(call, rc); 175 } 176 166 177 static void input_cb_conn(ipc_call_t *icall, void *arg) 167 178 { … … 196 207 input_ev_button(input, &call); 197 208 break; 209 case INPUT_EVENT_DCLICK: 210 input_ev_dclick(input, &call); 211 break; 198 212 default: 199 213 async_answer_0(&call, ENOTSUP); -
uspace/lib/c/include/io/input.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 12Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 54 54 errno_t (*abs_move)(input_t *, unsigned, unsigned, unsigned, unsigned); 55 55 errno_t (*button)(input_t *, int, int); 56 errno_t (*dclick)(input_t *, int); 56 57 } input_ev_ops_t; 57 58 -
uspace/lib/c/include/io/pos_event.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2012 Petr Koupy 3 * Copyright (c) 2013 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 40 40 41 41 typedef enum { 42 /** Position update */ 42 43 POS_UPDATE, 44 /** Button press */ 43 45 POS_PRESS, 44 POS_RELEASE 46 /** Button release */ 47 POS_RELEASE, 48 /** Double click */ 49 POS_DCLICK 45 50 } pos_event_type_t; 46 51 -
uspace/lib/c/include/ipc/input.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 11 Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 INPUT_EVENT_MOVE, 49 49 INPUT_EVENT_ABS_MOVE, 50 INPUT_EVENT_BUTTON 50 INPUT_EVENT_BUTTON, 51 INPUT_EVENT_DCLICK 51 52 } input_notif_t; 52 53 -
uspace/lib/ui/src/checkbox.c
r805a149 r8edec53 397 397 } 398 398 break; 399 case POS_DCLICK: 400 break; 399 401 } 400 402 -
uspace/lib/ui/src/menuentry.c
r805a149 r8edec53 497 497 } 498 498 break; 499 case POS_DCLICK: 500 break; 499 501 } 500 502 -
uspace/lib/ui/src/pbutton.c
r805a149 r8edec53 521 521 } 522 522 break; 523 case POS_DCLICK: 524 break; 523 525 } 524 526 -
uspace/lib/ui/src/rbutton.c
r805a149 r8edec53 490 490 } 491 491 break; 492 case POS_DCLICK: 493 break; 492 494 } 493 495 -
uspace/lib/ui/src/slider.c
r805a149 r8edec53 522 522 ui_slider_update(slider, &pos); 523 523 break; 524 case POS_DCLICK: 525 break; 524 526 } 525 527 -
uspace/srv/hid/console/console.c
r805a149 r8edec53 124 124 static errno_t input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 125 125 static errno_t input_ev_button(input_t *, int, int); 126 static errno_t input_ev_dclick(input_t *, int); 126 127 127 128 static input_ev_ops_t input_ev_ops = { … … 131 132 .move = input_ev_move, 132 133 .abs_move = input_ev_abs_move, 133 .button = input_ev_button 134 .button = input_ev_button, 135 .dclick = input_ev_dclick 134 136 }; 135 137 … … 440 442 } 441 443 444 static errno_t input_ev_dclick(input_t *input, int bnum) 445 { 446 cons_event_t event; 447 448 event.type = CEV_POS; 449 event.ev.pos.type = POS_DCLICK; 450 event.ev.pos.btn_num = bnum; 451 event.ev.pos.hpos = pointer_x / mouse_scale_x; 452 event.ev.pos.vpos = pointer_y / mouse_scale_y; 453 454 console_queue_cons_event(active_console, &event); 455 return EOK; 456 } 457 442 458 /** Process a character from the client (TTY emulation). */ 443 459 static void cons_write_char(console_t *cons, char32_t ch) -
uspace/srv/hid/display/input.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 static errno_t ds_input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 50 50 static errno_t ds_input_ev_button(input_t *, int, int); 51 static errno_t ds_input_ev_dclick(input_t *, int); 51 52 52 53 static input_ev_ops_t ds_input_ev_ops = { … … 56 57 .move = ds_input_ev_move, 57 58 .abs_move = ds_input_ev_abs_move, 58 .button = ds_input_ev_button 59 .button = ds_input_ev_button, 60 .dclick = ds_input_ev_dclick 59 61 }; 60 62 … … 131 133 132 134 event.type = bpress ? PTD_PRESS : PTD_RELEASE; 135 event.btn_num = bnum; 136 event.dmove.x = 0; 137 event.dmove.y = 0; 138 139 ds_display_lock(disp); 140 rc = ds_display_post_ptd_event(disp, &event); 141 ds_display_unlock(disp); 142 return rc; 143 } 144 145 static errno_t ds_input_ev_dclick(input_t *input, int bnum) 146 { 147 ds_display_t *disp = (ds_display_t *) input->user; 148 ptd_event_t event; 149 errno_t rc; 150 151 event.type = PTD_DCLICK; 133 152 event.btn_num = bnum; 134 153 event.dmove.x = 0; -
uspace/srv/hid/display/seat.c
r805a149 r8edec53 362 362 } 363 363 364 if (event->type == PTD_PRESS || event->type == PTD_RELEASE) { 364 if (event->type == PTD_PRESS || event->type == PTD_RELEASE || 365 event->type == PTD_DCLICK) { 365 366 pevent.pos_id = 0; 366 pevent.type = (event->type == PTD_PRESS) ? 367 POS_PRESS : POS_RELEASE; 367 switch (event->type) { 368 case PTD_PRESS: 369 pevent.type = POS_PRESS; 370 break; 371 case PTD_RELEASE: 372 pevent.type = POS_RELEASE; 373 break; 374 case PTD_DCLICK: 375 pevent.type = POS_DCLICK; 376 break; 377 default: 378 assert(false); 379 } 380 368 381 pevent.btn_num = event->btn_num; 369 382 pevent.hpos = seat->pntpos.x; -
uspace/srv/hid/display/types/display/ptd_event.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 42 42 PTD_ABS_MOVE, 43 43 PTD_PRESS, 44 PTD_RELEASE 44 PTD_RELEASE, 45 PTD_DCLICK 45 46 } ptd_event_type_t; 46 47 -
uspace/srv/hid/input/input.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 311 311 } 312 312 313 /** Arbitrate client actiovation */ 313 /** Mouse button has been double-clicked. */ 314 void mouse_push_event_dclick(mouse_dev_t *mdev, int bnum) 315 { 316 list_foreach(clients, link, client_t, client) { 317 if (client->active) { 318 async_exch_t *exch = async_exchange_begin(client->sess); 319 async_msg_1(exch, INPUT_EVENT_DCLICK, bnum); 320 async_exchange_end(exch); 321 } 322 } 323 } 324 325 /** Arbitrate client activation */ 314 326 static void client_arbitration(void) 315 327 { -
uspace/srv/hid/input/mouse.h
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 20 11 Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 66 66 unsigned int, unsigned int); 67 67 extern void mouse_push_event_button(mouse_dev_t *, int, int); 68 extern void mouse_push_event_dclick(mouse_dev_t *, int); 68 69 69 70 #endif -
uspace/srv/hid/input/proto/mousedev.c
r805a149 r8edec53 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2011 Martin Decky 3 4 * All rights reserved. … … 43 44 #include <loc.h> 44 45 #include <stdlib.h> 46 #include <time.h> 45 47 #include "../mouse.h" 46 48 #include "../mouse_port.h" … … 48 50 #include "../input.h" 49 51 52 enum { 53 /** Default double-click speed in milliseconds */ 54 dclick_delay_ms = 500 55 }; 56 50 57 /** Mousedev softstate */ 51 58 typedef struct { 52 59 /** Link to generic mouse device */ 53 60 mouse_dev_t *mouse_dev; 61 /** Button number of last button pressed (or -1 if none) */ 62 int press_bnum; 63 /** Time at which button was last pressed */ 64 struct timespec press_time; 54 65 } mousedev_t; 55 66 … … 61 72 62 73 mousedev->mouse_dev = mdev; 74 mousedev->press_bnum = -1; 63 75 64 76 return mousedev; … … 68 80 { 69 81 free(mousedev); 82 } 83 84 static void mousedev_press(mousedev_t *mousedev, int bnum) 85 { 86 struct timespec now; 87 nsec_t ms_delay; 88 89 getuptime(&now); 90 91 /* Same button was pressed previously */ 92 if (mousedev->press_bnum == bnum) { 93 /* Compute milliseconds since previous press */ 94 ms_delay = ts_sub_diff(&now, &mousedev->press_time) / 1000000; 95 96 if (ms_delay <= dclick_delay_ms) { 97 mouse_push_event_dclick(mousedev->mouse_dev, bnum); 98 mousedev->press_bnum = -1; 99 return; 100 } 101 } 102 103 /* Record which button was last pressed and at what time */ 104 mousedev->press_bnum = bnum; 105 mousedev->press_time = now; 70 106 } 71 107 … … 103 139 mouse_push_event_button(mousedev->mouse_dev, 104 140 ipc_get_arg1(&call), ipc_get_arg2(&call)); 141 if (ipc_get_arg2(&call) != 0) 142 mousedev_press(mousedev, ipc_get_arg1(&call)); 105 143 retval = EOK; 106 144 break;
Note:
See TracChangeset
for help on using the changeset viewer.