Changeset c11ee605 in mainline
- Timestamp:
- 2020-05-11T15:36:46Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 83cb672
- Parents:
- e49b7997
- Location:
- uspace/srv/hid/display
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
re49b7997 rc11ee605 65 65 } 66 66 67 fibril_mutex_initialize(&disp->lock); 67 68 list_initialize(&disp->clients); 68 69 disp->next_wnd_id = 1; … … 84 85 gfx_color_delete(disp->bg_color); 85 86 free(disp); 87 } 88 89 /** Lock display. 90 * 91 * This should be called in any thread that wishes to access the display 92 * or its child objects (e.g. windows). 93 * 94 * @param disp Display 95 */ 96 void ds_display_lock(ds_display_t *disp) 97 { 98 fibril_mutex_lock(&disp->lock); 99 } 100 101 /** Unlock display. 102 * 103 * @param disp Display 104 */ 105 void ds_display_unlock(ds_display_t *disp) 106 { 107 fibril_mutex_unlock(&disp->lock); 86 108 } 87 109 -
uspace/srv/hid/display/display.h
re49b7997 rc11ee605 50 50 extern errno_t ds_display_create(gfx_context_t *, ds_display_t **); 51 51 extern void ds_display_destroy(ds_display_t *); 52 extern void ds_display_lock(ds_display_t *); 53 extern void ds_display_unlock(ds_display_t *); 52 54 extern void ds_display_get_info(ds_display_t *, display_info_t *); 53 55 extern void ds_display_add_client(ds_display_t *, ds_client_t *); -
uspace/srv/hid/display/dsops.c
re49b7997 rc11ee605 76 76 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()"); 77 77 78 ds_display_lock(client->display); 79 78 80 rc = ds_window_create(client, params, &wnd); 79 81 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc); 80 if (rc != EOK) 82 if (rc != EOK) { 83 ds_display_unlock(client->display); 81 84 return rc; 85 } 82 86 83 87 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu", … … 92 96 (void) ds_display_paint(wnd->display, NULL); 93 97 98 ds_display_unlock(client->display); 99 94 100 *rwnd_id = wnd->id; 95 101 return EOK; … … 101 107 ds_window_t *wnd; 102 108 103 wnd = ds_client_find_window(client, wnd_id); 104 if (wnd == NULL) 105 return ENOENT; 109 ds_display_lock(client->display); 110 111 wnd = ds_client_find_window(client, wnd_id); 112 if (wnd == NULL) { 113 ds_display_unlock(client->display); 114 return ENOENT; 115 } 106 116 107 117 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()"); 108 118 ds_client_remove_window(wnd); 109 119 ds_window_destroy(wnd); 120 ds_display_unlock(client->display); 110 121 return EOK; 111 122 } … … 117 128 ds_window_t *wnd; 118 129 119 wnd = ds_client_find_window(client, wnd_id); 120 if (wnd == NULL) 121 return ENOENT; 130 ds_display_lock(client->display); 131 132 wnd = ds_client_find_window(client, wnd_id); 133 if (wnd == NULL) { 134 ds_display_unlock(client->display); 135 return ENOENT; 136 } 122 137 123 138 log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_move_req()"); 124 139 ds_window_move_req(wnd, pos); 140 ds_display_unlock(client->display); 125 141 return EOK; 126 142 } … … 131 147 ds_window_t *wnd; 132 148 133 wnd = ds_client_find_window(client, wnd_id); 134 if (wnd == NULL) 135 return ENOENT; 149 ds_display_lock(client->display); 150 151 wnd = ds_client_find_window(client, wnd_id); 152 if (wnd == NULL) { 153 ds_display_unlock(client->display); 154 return ENOENT; 155 } 136 156 137 157 log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_move()"); 138 158 ds_window_move(wnd, pos); 159 ds_display_unlock(client->display); 139 160 return EOK; 140 161 } … … 146 167 ds_window_t *wnd; 147 168 148 wnd = ds_client_find_window(client, wnd_id); 149 if (wnd == NULL) 150 return ENOENT; 169 ds_display_lock(client->display); 170 171 wnd = ds_client_find_window(client, wnd_id); 172 if (wnd == NULL) { 173 ds_display_unlock(client->display); 174 return ENOENT; 175 } 151 176 152 177 log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_resize_req()"); 153 178 ds_window_resize_req(wnd, rsztype, pos); 179 ds_display_unlock(client->display); 154 180 return EOK; 155 181 } … … 160 186 ds_client_t *client = (ds_client_t *) arg; 161 187 ds_window_t *wnd; 162 163 wnd = ds_client_find_window(client, wnd_id); 164 if (wnd == NULL) 165 return ENOENT; 188 errno_t rc; 189 190 ds_display_lock(client->display); 191 192 wnd = ds_client_find_window(client, wnd_id); 193 if (wnd == NULL) { 194 ds_display_unlock(client->display); 195 return ENOENT; 196 } 166 197 167 198 log_msg(LOG_DEFAULT, LVL_NOTE, "disp_window_resize()"); 168 return ds_window_resize(wnd, offs, nbound); 199 rc = ds_window_resize(wnd, offs, nbound); 200 ds_display_unlock(client->display); 201 return rc; 169 202 } 170 203 … … 178 211 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_event()"); 179 212 213 ds_display_lock(client->display); 214 180 215 rc = ds_client_get_event(client, &wnd, event); 181 if (rc != EOK) 216 if (rc != EOK) { 217 ds_display_unlock(client->display); 182 218 return rc; 219 } 183 220 184 221 *wnd_id = wnd->id; 222 ds_display_unlock(client->display); 185 223 return EOK; 186 224 } … … 192 230 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()"); 193 231 232 ds_display_lock(client->display); 194 233 ds_display_get_info(client->display, info); 234 ds_display_unlock(client->display); 195 235 return EOK; 196 236 } -
uspace/srv/hid/display/input.c
re49b7997 rc11ee605 73 73 ds_display_t *disp = (ds_display_t *) input->user; 74 74 kbd_event_t event; 75 errno_t rc; 75 76 76 77 event.type = type; … … 79 80 event.c = c; 80 81 81 return ds_display_post_kbd_event(disp, &event); 82 ds_display_lock(disp); 83 rc = ds_display_post_kbd_event(disp, &event); 84 ds_display_unlock(disp); 85 return rc; 82 86 } 83 87 … … 86 90 ds_display_t *disp = (ds_display_t *) input->user; 87 91 ptd_event_t event; 92 errno_t rc; 88 93 89 94 event.type = PTD_MOVE; … … 91 96 event.dmove.y = dy; 92 97 93 return ds_display_post_ptd_event(disp, &event); 98 ds_display_lock(disp); 99 rc = ds_display_post_ptd_event(disp, &event); 100 ds_display_unlock(disp); 101 return rc; 94 102 } 95 103 … … 99 107 ds_display_t *disp = (ds_display_t *) input->user; 100 108 ptd_event_t event; 109 errno_t rc; 101 110 102 111 event.type = PTD_ABS_MOVE; … … 108 117 event.abounds.p1.y = max_y + 1; 109 118 110 return ds_display_post_ptd_event(disp, &event); 119 ds_display_lock(disp); 120 rc = ds_display_post_ptd_event(disp, &event); 121 ds_display_unlock(disp); 122 return rc; 111 123 } 112 124 … … 115 127 ds_display_t *disp = (ds_display_t *) input->user; 116 128 ptd_event_t event; 129 errno_t rc; 117 130 118 131 event.type = bpress ? PTD_PRESS : PTD_RELEASE; … … 121 134 event.dmove.y = 0; 122 135 123 return ds_display_post_ptd_event(disp, &event); 136 ds_display_lock(disp); 137 rc = ds_display_post_ptd_event(disp, &event); 138 ds_display_unlock(disp); 139 return rc; 124 140 } 125 141 -
uspace/srv/hid/display/types/display/display.h
re49b7997 rc11ee605 38 38 39 39 #include <adt/list.h> 40 #include <fibril_synch.h> 40 41 #include <gfx/color.h> 41 42 #include <gfx/coord.h> … … 45 46 /** Display server display */ 46 47 typedef struct ds_display { 48 /** Synchronize access to display */ 49 fibril_mutex_t lock; 47 50 /** Clients (of ds_client_t) */ 48 51 list_t clients;
Note:
See TracChangeset
for help on using the changeset viewer.