Changes in uspace/app/viewer/viewer.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/viewer/viewer.c
r5a6cc679 ra35b458 44 44 #include <codec/tga.h> 45 45 #include <task.h> 46 #include <str.h> 46 47 47 48 #define NAME "viewer" … … 71 72 kbd_event_t *event = (kbd_event_t *) data; 72 73 bool update = false; 73 74 74 75 if ((event->type == KEY_PRESS) && (event->c == 'q')) 75 76 exit(0); 76 77 77 78 if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) { 78 79 if (imgs_current == imgs_count - 1) … … 80 81 else 81 82 imgs_current++; 82 83 83 84 update = true; 84 85 } 85 86 86 87 if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) { 87 88 if (imgs_current == 0) … … 89 90 else 90 91 imgs_current--; 91 92 92 93 update = true; 93 94 } 94 95 95 96 if (update) { 96 97 surface_t *lsface; … … 113 114 if (rc != EOK) 114 115 return false; 115 116 struct stat stat;116 117 vfs_stat_t stat; 117 118 rc = vfs_stat(fd, &stat); 118 119 if (rc != EOK) { … … 120 121 return false; 121 122 } 122 123 123 124 void *tga = malloc(stat.size); 124 125 if (tga == NULL) { … … 134 135 return false; 135 136 } 136 137 137 138 vfs_put(fd); 138 139 139 140 *p_local_surface = decode_tga(tga, stat.size, 0); 140 141 if (*p_local_surface == NULL) { … … 142 143 return false; 143 144 } 144 145 145 146 free(tga); 146 147 147 148 surface_get_resolution(*p_local_surface, &img_width, &img_height); 148 149 149 150 return true; 150 151 } … … 164 165 return false; 165 166 } 166 167 167 168 sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event); 168 169 } 169 170 170 171 if (surface != NULL) 171 172 surface_destroy(surface); 172 173 173 174 surface = local_surface; 174 175 return true; … … 187 188 return 1; 188 189 } 189 190 190 191 if (argc < 3) { 191 192 printf("No image files specified.\n"); … … 199 200 return 2; 200 201 } 201 202 202 203 for (int i = 0; i < argc - 2; i++) { 203 204 imgs[i] = str_dup(argv[i + 2]); … … 225 226 return 5; 226 227 } 227 228 228 229 229 230 if (!img_setup(lsface)) { 230 231 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); … … 243 244 img_height + dheight, WINDOW_PLACEMENT_ANY); 244 245 window_exec(main_window); 245 246 246 247 task_retval(0); 247 248 async_manager(); 248 249 249 250 return 0; 250 251 }
Note:
See TracChangeset
for help on using the changeset viewer.