- Timestamp:
- 2014-01-17T17:02:59Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 476f62c, facc34d
- Parents:
- 2e80321 (diff), 61b5b73d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 6 added
- 1 deleted
- 29 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r2e80321 r66be0288 50 50 app/kill \ 51 51 app/killall \ 52 app/k log\52 app/kio \ 53 53 app/loc \ 54 54 app/logset \ … … 92 92 srv/locsrv \ 93 93 srv/logger \ 94 srv/klog \ 94 95 srv/devman \ 95 96 srv/loader \ -
uspace/app/init/init.c
r2e80321 r66be0288 336 336 srv_start("/srv/tmpfs"); 337 337 338 srv_start("/srv/klog"); 338 339 srv_start("/srv/locfs"); 339 340 srv_start("/srv/taskmon"); -
uspace/app/kio/Makefile
r2e80321 r66be0288 31 31 LIBS = $(LIBCLUI_PREFIX)/libclui.a 32 32 EXTRA_CFLAGS = -I$(LIBCLUI_PREFIX) 33 BINARY = k log33 BINARY = kio 34 34 35 35 SOURCES = \ 36 k log.c36 kio.c 37 37 38 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/kio/kio.c
r2e80321 r66be0288 27 27 */ 28 28 29 /** @addtogroup k log KLog30 * @brief HelenOS K Log29 /** @addtogroup kio KIO 30 * @brief HelenOS KIO 31 31 * @{ 32 32 */ … … 42 42 #include <errno.h> 43 43 #include <str_error.h> 44 #include <io/k log.h>44 #include <io/kio.h> 45 45 #include <sysinfo.h> 46 46 #include <malloc.h> … … 50 50 #include <tinput.h> 51 51 52 #define NAME "k log"53 #define LOG_FNAME "/log/k log"52 #define NAME "kio" 53 #define LOG_FNAME "/log/kio" 54 54 55 55 /* Producer/consumer buffers */ … … 62 62 static prodcons_t pc; 63 63 64 /* Pointer to k logarea */65 static wchar_t *k log;66 static size_t k log_length;64 /* Pointer to kio area */ 65 static wchar_t *kio; 66 static size_t kio_length; 67 67 68 68 /* Notification mutex */ … … 75 75 * 76 76 * @param length Number of characters to copy. 77 * @param data Pointer to the kernel k logbuffer.77 * @param data Pointer to the kernel kio buffer. 78 78 * 79 79 */ … … 142 142 /** Kernel notification handler 143 143 * 144 * Receives kernel k lognotifications.144 * Receives kernel kio notifications. 145 145 * 146 146 * @param callid IPC call ID … … 156 156 * starving. 157 157 * 158 * Note: Usually the automatic masking of the k log158 * Note: Usually the automatic masking of the kio 159 159 * notifications on the kernel side does the trick 160 160 * of limiting the chance of accidentally copying 161 161 * the same data multiple times. However, due to 162 * the non-blocking architecture of k lognotifications,162 * the non-blocking architecture of kio notifications, 163 163 * this possibility cannot be generally avoided. 164 164 */ … … 166 166 fibril_mutex_lock(&mtx); 167 167 168 size_t k log_start = (size_t) IPC_GET_ARG1(*call);169 size_t k log_len = (size_t) IPC_GET_ARG2(*call);170 size_t k log_stored = (size_t) IPC_GET_ARG3(*call);171 172 size_t offset = (k log_start + klog_len - klog_stored) % klog_length;168 size_t kio_start = (size_t) IPC_GET_ARG1(*call); 169 size_t kio_len = (size_t) IPC_GET_ARG2(*call); 170 size_t kio_stored = (size_t) IPC_GET_ARG3(*call); 171 172 size_t offset = (kio_start + kio_len - kio_stored) % kio_length; 173 173 174 174 /* Copy data from the ring buffer */ 175 if (offset + k log_stored >= klog_length) {176 size_t split = k log_length - offset;177 178 producer(split, k log+ offset);179 producer(k log_stored - split, klog);175 if (offset + kio_stored >= kio_length) { 176 size_t split = kio_length - offset; 177 178 producer(split, kio + offset); 179 producer(kio_stored - split, kio); 180 180 } else 181 producer(k log_stored, klog+ offset);182 183 event_unmask(EVENT_K LOG);181 producer(kio_stored, kio + offset); 182 183 event_unmask(EVENT_KIO); 184 184 fibril_mutex_unlock(&mtx); 185 185 } … … 188 188 { 189 189 size_t pages; 190 int rc = sysinfo_get_value("k log.pages", &pages);191 if (rc != EOK) { 192 fprintf(stderr, "%s: Unable to get number of k logpages\n",190 int rc = sysinfo_get_value("kio.pages", &pages); 191 if (rc != EOK) { 192 fprintf(stderr, "%s: Unable to get number of kio pages\n", 193 193 NAME); 194 194 return rc; … … 196 196 197 197 uintptr_t faddr; 198 rc = sysinfo_get_value("k log.faddr", &faddr);199 if (rc != EOK) { 200 fprintf(stderr, "%s: Unable to get k logphysical address\n",198 rc = sysinfo_get_value("kio.faddr", &faddr); 199 if (rc != EOK) { 200 fprintf(stderr, "%s: Unable to get kio physical address\n", 201 201 NAME); 202 202 return rc; … … 204 204 205 205 size_t size = pages * PAGE_SIZE; 206 k log_length = size / sizeof(wchar_t);206 kio_length = size / sizeof(wchar_t); 207 207 208 208 rc = physmem_map(faddr, pages, AS_AREA_READ | AS_AREA_CACHEABLE, 209 (void *) &k log);210 if (rc != EOK) { 211 fprintf(stderr, "%s: Unable to map k log\n", NAME);209 (void *) &kio); 210 if (rc != EOK) { 211 fprintf(stderr, "%s: Unable to map kio\n", NAME); 212 212 return rc; 213 213 } … … 215 215 prodcons_initialize(&pc); 216 216 async_set_interrupt_received(notification_received); 217 rc = event_subscribe(EVENT_K LOG, 0);218 if (rc != EOK) { 219 fprintf(stderr, "%s: Unable to register k lognotifications\n",217 rc = event_subscribe(EVENT_KIO, 0); 218 if (rc != EOK) { 219 fprintf(stderr, "%s: Unable to register kio notifications\n", 220 220 NAME); 221 221 return rc; … … 236 236 237 237 fibril_add_ready(fid); 238 event_unmask(EVENT_K LOG);239 k log_update();240 241 tinput_set_prompt(input, "k log> ");238 event_unmask(EVENT_KIO); 239 kio_update(); 240 241 tinput_set_prompt(input, "kio> "); 242 242 243 243 char *str; … … 248 248 } 249 249 250 k log_command(str, str_size(str));250 kio_command(str, str_size(str)); 251 251 free(str); 252 252 } -
uspace/app/trace/syscalls.c
r2e80321 r66be0288 38 38 39 39 const sc_desc_t syscall_desc[] = { 40 [SYS_K LOG] ={ "klog",3, V_INT_ERRNO },40 [SYS_KIO] ={ "kio", 3, V_INT_ERRNO }, 41 41 [SYS_TLS_SET] = { "tls_set", 1, V_ERRNO }, 42 42 -
uspace/app/vdemo/vdemo.c
r2e80321 r66be0288 110 110 { 111 111 if (argc >= 2) { 112 window_t *main_window = window_open(argv[1], true, true, "vdemo" , 0, 0);112 window_t *main_window = window_open(argv[1], true, true, "vdemo"); 113 113 if (!main_window) { 114 114 printf("Cannot open main window.\n"); … … 117 117 118 118 pixel_t grd_bg = PIXEL(255, 240, 240, 240); 119 pixel_t btn_bg = PIXEL(255, 0, 0, 0); 120 pixel_t btn_fg = PIXEL(255, 240, 240, 240); 119 120 pixel_t btn_bg = PIXEL(255, 240, 240, 240); 121 pixel_t btn_fg = PIXEL(255, 186, 186, 186); 122 pixel_t btn_text = PIXEL(255, 0, 0, 0); 123 121 124 pixel_t lbl_bg = PIXEL(255, 240, 240, 240); 122 pixel_t lbl_ fg= PIXEL(255, 0, 0, 0);125 pixel_t lbl_text = PIXEL(255, 0, 0, 0); 123 126 124 my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16, lbl_bg, lbl_fg); 125 button_t *btn_confirm = create_button(NULL, "Confirm", 16, btn_bg, btn_fg); 126 button_t *btn_cancel = create_button(NULL, "Cancel", 16, btn_bg, btn_fg); 127 my_label_t *lbl_action = create_my_label(NULL, "Hello there!", 16, 128 lbl_bg, lbl_text); 129 button_t *btn_confirm = create_button(NULL, "Confirm", 16, btn_bg, 130 btn_fg, btn_text); 131 button_t *btn_cancel = create_button(NULL, "Cancel", 16, btn_bg, 132 btn_fg, btn_text); 127 133 grid_t *grid = create_grid(window_root(main_window), 2, 2, grd_bg); 128 134 if (!lbl_action || !btn_confirm || !btn_cancel || !grid) { … … 144 150 grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1); 145 151 grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1); 146 window_resize(main_window, 200, 76); 152 window_resize(main_window, 0, 0, 200, 76, 153 WINDOW_PLACEMENT_CENTER); 147 154 148 155 window_exec(main_window); -
uspace/app/viewer/viewer.c
r2e80321 r66be0288 166 166 } 167 167 168 main_window = window_open(argv[1], true, false, "viewer" , 0, 0);168 main_window = window_open(argv[1], true, false, "viewer"); 169 169 if (!main_window) { 170 170 printf("Cannot open main window.\n"); … … 192 192 } 193 193 194 window_resize(main_window, WINDOW_WIDTH, WINDOW_HEIGHT); 194 window_resize(main_window, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 195 WINDOW_PLACEMENT_ABSOLUTE); 195 196 window_exec(main_window); 196 197 -
uspace/app/vlaunch/vlaunch.c
r2e80321 r66be0288 115 115 116 116 winreg = argv[1]; 117 window_t *main_window = window_open(argv[1], true, true, "vlaunch" , 0, 0);117 window_t *main_window = window_open(argv[1], true, true, "vlaunch"); 118 118 if (!main_window) { 119 119 printf("Cannot open main window.\n"); … … 122 122 123 123 pixel_t grd_bg = PIXEL(255, 255, 255, 255); 124 pixel_t btn_bg = PIXEL(255, 0, 0, 0); 125 pixel_t btn_fg = PIXEL(255, 240, 240, 240); 124 125 pixel_t btn_bg = PIXEL(255, 255, 255, 255); 126 pixel_t btn_fg = PIXEL(255, 186, 186, 186); 127 pixel_t btn_text = PIXEL(255, 0, 0, 0); 128 126 129 pixel_t lbl_bg = PIXEL(255, 255, 255, 255); 127 pixel_t lbl_ fg= PIXEL(255, 0, 0, 0);130 pixel_t lbl_text = PIXEL(255, 0, 0, 0); 128 131 129 132 canvas_t *logo_canvas = create_canvas(NULL, LOGO_WIDTH, LOGO_HEIGHT, 130 133 logo); 131 134 label_t *lbl_caption = create_label(NULL, "Launch application:", 16, 132 lbl_bg, lbl_ fg);135 lbl_bg, lbl_text); 133 136 button_t *btn_vterm = create_button(NULL, "vterm", 16, btn_bg, 134 btn_fg );137 btn_fg, btn_text); 135 138 button_t *btn_vdemo = create_button(NULL, "vdemo", 16, btn_bg, 136 btn_fg );139 btn_fg, btn_text); 137 140 button_t *btn_vlaunch = create_button(NULL, "vlaunch", 16, btn_bg, 138 btn_fg );141 btn_fg, btn_text); 139 142 grid_t *grid = create_grid(window_root(main_window), 1, 5, grd_bg); 140 143 … … 156 159 grid->add(grid, &btn_vlaunch->widget, 0, 4, 1, 1); 157 160 158 window_resize(main_window, 210, 130 + LOGO_HEIGHT); 161 window_resize(main_window, 0, 0, 210, 130 + LOGO_HEIGHT, 162 WINDOW_PLACEMENT_RIGHT | WINDOW_PLACEMENT_TOP); 159 163 window_exec(main_window); 160 164 -
uspace/app/vterm/vterm.c
r2e80321 r66be0288 49 49 } 50 50 51 window_t *main_window = window_open(argv[1], true, true, "vterm" , 0, 0);51 window_t *main_window = window_open(argv[1], true, true, "vterm"); 52 52 if (!main_window) { 53 53 printf("%s: Cannot open main window.\n", NAME); … … 55 55 } 56 56 57 window_resize(main_window, 650, 510);57 window_resize(main_window, 0, 0, 648, 508, WINDOW_PLACEMENT_ANY); 58 58 terminal_t *terminal_widget = 59 59 create_terminal(window_root(main_window), 640, 480); -
uspace/lib/c/Makefile
r2e80321 r66be0288 101 101 generic/io/log.c \ 102 102 generic/io/logctl.c \ 103 generic/io/kio.c \ 103 104 generic/io/klog.c \ 104 105 generic/io/snprintf.c \ -
uspace/lib/c/generic/assert.c
r2e80321 r66be0288 33 33 #include <assert.h> 34 34 #include <stdio.h> 35 #include <io/k log.h>35 #include <io/kio.h> 36 36 #include <stdlib.h> 37 37 #include <atomic.h> … … 44 44 { 45 45 /* 46 * Send the message safely to k log. Nested asserts should not occur.46 * Send the message safely to kio. Nested asserts should not occur. 47 47 */ 48 k log_printf("Assertion failed (%s) in file \"%s\", line %u.\n",48 kio_printf("Assertion failed (%s) in file \"%s\", line %u.\n", 49 49 cond, file, line); 50 50 -
uspace/lib/c/generic/io/io.c
r2e80321 r66be0288 42 42 #include <malloc.h> 43 43 #include <async.h> 44 #include <io/k log.h>44 #include <io/kio.h> 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> … … 57 57 .error = true, 58 58 .eof = true, 59 .k log= false,59 .kio = false, 60 60 .sess = NULL, 61 61 .btype = _IONBF, … … 67 67 }; 68 68 69 static FILE stdout_k log= {69 static FILE stdout_kio = { 70 70 .fd = -1, 71 71 .error = false, 72 72 .eof = false, 73 .k log= true,73 .kio = true, 74 74 .sess = NULL, 75 75 .btype = _IOLBF, … … 81 81 }; 82 82 83 static FILE stderr_k log= {83 static FILE stderr_kio = { 84 84 .fd = -1, 85 85 .error = false, 86 86 .eof = false, 87 .k log= true,87 .kio = true, 88 88 .sess = NULL, 89 89 .btype = _IONBF, … … 113 113 stdout = fdopen(1, "w"); 114 114 } else { 115 stdout = &stdout_k log;115 stdout = &stdout_kio; 116 116 list_append(&stdout->link, &files); 117 117 } … … 120 120 stderr = fdopen(2, "w"); 121 121 } else { 122 stderr = &stderr_k log;122 stderr = &stderr_kio; 123 123 list_append(&stderr->link, &files); 124 124 } … … 267 267 stream->error = false; 268 268 stream->eof = false; 269 stream->k log= false;269 stream->kio = false; 270 270 stream->sess = NULL; 271 271 stream->need_sync = false; … … 289 289 stream->error = false; 290 290 stream->eof = false; 291 stream->k log= false;291 stream->kio = false; 292 292 stream->sess = NULL; 293 293 stream->need_sync = false; … … 314 314 315 315 if ((stream != &stdin_null) 316 && (stream != &stdout_k log)317 && (stream != &stderr_k log))316 && (stream != &stdout_kio) 317 && (stream != &stderr_kio)) 318 318 free(stream); 319 319 … … 382 382 ssize_t wr; 383 383 384 if (stream->k log)385 wr = k log_write(buf + done, left);384 if (stream->kio) 385 wr = kio_write(buf + done, left); 386 386 else 387 387 wr = write(stream->fd, buf + done, left); … … 705 705 _fflushbuf(stream); 706 706 707 if (stream->k log) {708 k log_update();707 if (stream->kio) { 708 kio_update(); 709 709 return EOK; 710 710 } … … 740 740 int fileno(FILE *stream) 741 741 { 742 if (stream->k log) {742 if (stream->kio) { 743 743 errno = EBADF; 744 744 return -1; -
uspace/lib/c/generic/io/klog.c
r2e80321 r66be0288 1 1 /* 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2006 Jakub Vana 2 * Copyright (c) 2013 Martin Sucha 4 3 * All rights reserved. 5 4 * … … 41 40 #include <abi/klog.h> 42 41 #include <io/klog.h> 43 #include < io/printf_core.h>42 #include <abi/log.h> 44 43 45 size_t klog_write( const void *buf, size_t size)44 size_t klog_write(log_level_t lvl, const void *buf, size_t size) 46 45 { 47 ssize_t ret = (ssize_t) __SYSCALL3(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf, size); 46 ssize_t ret = (ssize_t) __SYSCALL4(SYS_KLOG, KLOG_WRITE, (sysarg_t) buf, 47 size, lvl); 48 48 49 49 if (ret >= 0) … … 53 53 } 54 54 55 void klog_update(void)55 int klog_read(void *data, size_t size) 56 56 { 57 (void) __SYSCALL3(SYS_KLOG, KLOG_UPDATE, (uintptr_t) NULL, 0); 58 } 59 60 void klog_command(const void *buf, size_t size) 61 { 62 (void) __SYSCALL3(SYS_KLOG, KLOG_COMMAND, (sysarg_t) buf, (sysarg_t) size); 63 } 64 65 /** Print formatted text to klog. 66 * 67 * @param fmt Format string 68 * 69 * \see For more details about format string see printf_core. 70 * 71 */ 72 int klog_printf(const char *fmt, ...) 73 { 74 va_list args; 75 va_start(args, fmt); 76 77 int ret = klog_vprintf(fmt, args); 78 79 va_end(args); 80 81 return ret; 82 } 83 84 static int klog_vprintf_str_write(const char *str, size_t size, void *data) 85 { 86 size_t wr = klog_write(str, size); 87 return str_nlength(str, wr); 88 } 89 90 static int klog_vprintf_wstr_write(const wchar_t *str, size_t size, void *data) 91 { 92 size_t offset = 0; 93 size_t chars = 0; 94 95 while (offset < size) { 96 char buf[STR_BOUNDS(1)]; 97 size_t sz = 0; 98 99 if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK) 100 klog_write(buf, sz); 101 102 chars++; 103 offset += sizeof(wchar_t); 104 } 105 106 return chars; 107 } 108 109 /** Print formatted text to klog. 110 * 111 * @param fmt Format string 112 * @param ap Format parameters 113 * 114 * \see For more details about format string see printf_core. 115 * 116 */ 117 int klog_vprintf(const char *fmt, va_list ap) 118 { 119 printf_spec_t ps = { 120 klog_vprintf_str_write, 121 klog_vprintf_wstr_write, 122 NULL 123 }; 124 125 return printf_core(fmt, &ps, ap); 57 return (int) __SYSCALL4(SYS_KLOG, KLOG_READ, (uintptr_t) data, size, 0); 126 58 } 127 59 -
uspace/lib/c/generic/io/window.c
r2e80321 r66be0288 40 40 #include <stdio.h> 41 41 42 int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out, 43 sysarg_t x_offset, sysarg_t y_offset) 42 int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out) 44 43 { 45 44 async_exch_t *exch = async_exchange_begin(sess); 46 int ret = async_req_ 2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);45 int ret = async_req_0_2(exch, WINDOW_REGISTER, in, out); 47 46 async_exchange_end(exch); 48 47 49 48 return ret; 50 49 } … … 92 91 } 93 92 94 int win_resize(async_sess_t *sess, sysarg_t width, sysarg_t height, void *cells) 93 int win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width, 94 sysarg_t height, window_placement_flags_t placement_flags, void *cells) 95 95 { 96 96 async_exch_t *exch = async_exchange_begin(sess); 97 97 98 98 ipc_call_t answer; 99 aid_t req = async_send_2(exch, WINDOW_RESIZE, width, height, &answer); 100 99 aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height, 100 (sysarg_t) placement_flags, &answer); 101 101 102 int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE); 102 103 103 104 async_exchange_end(exch); 104 105 105 106 sysarg_t ret; 106 107 async_wait_for(req, &ret); 107 108 if (rc != EOK) {108 109 if (rc != EOK) 109 110 return rc; 110 } else if (ret != EOK) {111 else if (ret != EOK) 111 112 return ret; 112 } else { 113 return EOK; 114 } 113 114 return EOK; 115 115 } 116 116 -
uspace/lib/c/generic/private/stdio.h
r2e80321 r66be0288 53 53 int eof; 54 54 55 /** K logindicator */56 int k log;55 /** KIO indicator */ 56 int kio; 57 57 58 58 /** Session to the file provider */ -
uspace/lib/c/include/io/klog.h
r2e80321 r66be0288 1 1 /* 2 * Copyright (c) 20 06 Jakub Vana2 * Copyright (c) 2013 Martin Sucha 3 3 * All rights reserved. 4 4 * … … 39 39 #include <stdarg.h> 40 40 #include <io/verify.h> 41 #include <stdio.h> 42 #include <stdlib.h> 43 #include <str.h> 44 #include <abi/log.h> 41 45 42 extern size_t klog_write(const void *, size_t); 43 extern void klog_update(void); 44 extern void klog_command(const void *, size_t); 45 extern int klog_printf(const char *, ...) 46 PRINTF_ATTRIBUTE(1, 2); 47 extern int klog_vprintf(const char *, va_list); 46 extern size_t klog_write(log_level_t, const void *, size_t); 47 extern int klog_read(void *, size_t); 48 49 #define KLOG_PRINTF(lvl, fmt, ...) ({ \ 50 char *_fmt = str_dup(fmt); \ 51 size_t _fmtsize = str_size(_fmt); \ 52 if (_fmtsize > 0 && _fmt[_fmtsize - 1] == '\n') \ 53 _fmt[_fmtsize - 1] = 0; \ 54 char *_s; \ 55 int _c = asprintf(&_s, _fmt, ##__VA_ARGS__); \ 56 free(_fmt); \ 57 if (_c >= 0) { \ 58 _c = klog_write((lvl), _s, str_size(_s)); \ 59 free(_s); \ 60 }; \ 61 (_c >= 0); \ 62 }) 48 63 49 64 #endif -
uspace/lib/c/include/io/log.h
r2e80321 r66be0288 39 39 #include <io/verify.h> 40 40 41 /** Log message level. */ 42 typedef enum { 43 /** Fatal error, program is not able to recover at all. */ 44 LVL_FATAL, 45 /** Serious error but the program can recover from it. */ 46 LVL_ERROR, 47 /** Easily recoverable problem. */ 48 LVL_WARN, 49 /** Information message that ought to be printed by default. */ 50 LVL_NOTE, 51 /** Debugging purpose message. */ 52 LVL_DEBUG, 53 /** More detailed debugging message. */ 54 LVL_DEBUG2, 55 56 /** For checking range of values */ 57 LVL_LIMIT 58 } log_level_t; 41 #include <abi/log.h> 59 42 60 43 /** Log itself (logging target). */ -
uspace/lib/c/include/io/window.h
r2e80321 r66be0288 43 43 #include <io/pos_event.h> 44 44 45 typedef enum { 46 GF_EMPTY = 0, 47 GF_MOVE_X = 1, 48 GF_MOVE_Y = 2, 49 GF_RESIZE_X = 4, 50 GF_RESIZE_Y = 8, 51 GF_SCALE_X = 16, 52 GF_SCALE_Y = 32 53 } window_grab_flags_t; 54 55 typedef enum { 56 WINDOW_PLACEMENT_ANY = 0, 57 WINDOW_PLACEMENT_CENTER_X = 1, 58 WINDOW_PLACEMENT_CENTER_Y = 2, 59 WINDOW_PLACEMENT_CENTER = 60 WINDOW_PLACEMENT_CENTER_X | WINDOW_PLACEMENT_CENTER_Y, 61 WINDOW_PLACEMENT_LEFT = 4, 62 WINDOW_PLACEMENT_RIGHT = 8, 63 WINDOW_PLACEMENT_TOP = 16, 64 WINDOW_PLACEMENT_BOTTOM = 32, 65 WINDOW_PLACEMENT_ABSOLUTE_X = 64, 66 WINDOW_PLACEMENT_ABSOLUTE_Y = 128, 67 WINDOW_PLACEMENT_ABSOLUTE = 68 WINDOW_PLACEMENT_ABSOLUTE_X | WINDOW_PLACEMENT_ABSOLUTE_Y 69 } window_placement_flags_t; 70 45 71 typedef struct { 46 72 sysarg_t object; 47 73 sysarg_t slot; 48 74 sysarg_t argument; 49 } sig _event_t;75 } signal_event_t; 50 76 51 77 typedef struct { 78 sysarg_t offset_x; 79 sysarg_t offset_y; 52 80 sysarg_t width; 53 81 sysarg_t height; 54 } rsz_event_t; 82 window_placement_flags_t placement_flags; 83 } resize_event_t; 55 84 56 85 typedef enum { … … 69 98 kbd_event_t kbd; 70 99 pos_event_t pos; 71 sig _event_t sig;72 r sz_event_t rsz;100 signal_event_t signal; 101 resize_event_t resize; 73 102 } window_event_data_t; 74 103 … … 79 108 } window_event_t; 80 109 81 typedef enum { 82 GF_EMPTY = 0, 83 GF_MOVE_X = 1, 84 GF_MOVE_Y = 2, 85 GF_RESIZE_X = 4, 86 GF_RESIZE_Y = 8, 87 GF_SCALE_X = 16, 88 GF_SCALE_Y = 32 89 } window_grab_flags_t; 90 91 extern int win_register(async_sess_t *, service_id_t *, service_id_t *, sysarg_t, sysarg_t); 110 extern int win_register(async_sess_t *, service_id_t *, service_id_t *); 92 111 93 112 extern int win_get_event(async_sess_t *, window_event_t *); … … 95 114 extern int win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t); 96 115 extern int win_grab(async_sess_t *, sysarg_t, sysarg_t); 97 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, void *); 116 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 117 window_placement_flags_t, void *); 98 118 extern int win_close(async_sess_t *); 99 119 extern int win_close_request(async_sess_t *); -
uspace/lib/c/include/stdio.h
r2e80321 r66be0288 40 40 #include <str.h> 41 41 #include <io/verify.h> 42 #include <abi/k log.h>42 #include <abi/kio.h> 43 43 44 44 #define EOF (-1) … … 52 52 int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \ 53 53 if (_n > 0) \ 54 (void) __SYSCALL3(SYS_K LOG, KLOG_WRITE, (sysarg_t) _buf, str_size(_buf)); \54 (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \ 55 55 } 56 56 -
uspace/lib/draw/cursor/embedded.c
r2e80321 r66be0288 46 46 assert(state_count); 47 47 assert(data); 48 48 49 49 (*state_count) = 1; 50 50 (*data) = NULL; … … 53 53 static surface_t *cde_render(uint8_t state) 54 54 { 55 if (state != 0) {55 if (state != 0) 56 56 return NULL; 57 } 58 57 59 58 surface_t *surface = surface_create(CURSOR_WIDTH, CURSOR_HEIGHT, NULL, 0); 60 61 if (!surface) { 59 if (!surface) 62 60 return NULL; 63 }64 61 65 62 for (unsigned int y = 0; y < CURSOR_HEIGHT; ++y) { … … 69 66 pixel_t pixel = (cursor_texture[offset] & (1 << (x % 8))) ? 70 67 PIXEL(255, 0, 0, 0) : PIXEL(255, 255, 255, 255); 71 surface_put_pixel(surface, x, y, visible ? pixel : PIXEL(0, 0, 0, 0)); 68 69 if (visible) 70 surface_put_pixel(surface, x, y, pixel); 72 71 } 73 72 } 74 73 75 74 return surface; 76 75 } -
uspace/lib/gui/Makefile
r2e80321 r66be0288 34 34 35 35 SOURCES = \ 36 common.c \ 36 37 button.c \ 37 38 canvas.c \ -
uspace/lib/gui/button.c
r2e80321 r66be0288 36 36 #include <str.h> 37 37 #include <malloc.h> 38 39 38 #include <drawctx.h> 40 39 #include <surface.h> 41 40 #include "common.h" 42 41 #include "window.h" 43 42 #include "button.h" 44 43 45 static void paint_internal(widget_t *w) 46 { 47 button_t *btn = (button_t *) w; 48 44 static pixel_t color_highlight = PIXEL(255, 255, 255, 255); 45 static pixel_t color_shadow = PIXEL(255, 85, 85, 85); 46 47 static void paint_internal(widget_t *widget) 48 { 49 button_t *btn = (button_t *) widget; 50 49 51 surface_t *surface = window_claim(btn->widget.window); 50 if (!surface) {52 if (!surface) 51 53 window_yield(btn->widget.window); 54 55 source_t source; 56 source_init(&source); 57 58 drawctx_t drawctx; 59 drawctx_init(&drawctx, surface); 60 61 drawctx_set_source(&drawctx, &btn->background); 62 drawctx_transfer(&drawctx, widget->hpos, widget->vpos, 63 widget->width, widget->height); 64 65 if ((widget->width >= 8) && (widget->height >= 8)) { 66 drawctx_set_source(&drawctx, &source); 67 draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3, 68 widget->width - 6, widget->height - 6, color_highlight, 69 color_shadow); 70 71 drawctx_set_source(&drawctx, &btn->foreground); 72 drawctx_transfer(&drawctx, widget->hpos + 4, widget->vpos + 4, 73 widget->width - 8, widget->height - 8); 52 74 } 53 54 drawctx_t drawctx; 55 56 drawctx_init(&drawctx, surface); 57 drawctx_set_source(&drawctx, &btn->foreground); 58 drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, w->height); 59 60 if (w->width >= 6 && w->height >= 6) { 61 drawctx_set_source(&drawctx, &btn->background); 62 drawctx_transfer(&drawctx, 63 w->hpos + 3, w->vpos + 3, w->width - 6, w->height - 6); 64 } 65 75 66 76 sysarg_t cpt_width; 67 77 sysarg_t cpt_height; 68 78 font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height); 69 if (w->width >= cpt_width && w->height >= cpt_height) { 70 drawctx_set_source(&drawctx, &btn->foreground); 79 80 if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) { 81 sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos; 82 sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos; 83 84 drawctx_set_source(&drawctx, &btn->text); 71 85 drawctx_set_font(&drawctx, &btn->font); 72 sysarg_t x = ((w->width - cpt_width) / 2) + w->hpos; 73 sysarg_t y = ((w->height - cpt_height) / 2) + w->vpos; 74 if (btn->caption) { 86 87 if (btn->caption) 75 88 drawctx_print(&drawctx, btn->caption, x, y); 76 }77 89 } 78 90 79 91 window_yield(btn->widget.window); 80 92 } … … 90 102 { 91 103 button_t *btn = (button_t *) widget; 92 104 93 105 deinit_button(btn); 94 95 106 free(btn); 96 107 } … … 117 128 { 118 129 button_t *btn = (button_t *) widget; 119 if (event.key == KC_ENTER && event.type == KEY_PRESS) { 130 131 if (event.key == KC_ENTER && event.type == KEY_PRESS) 120 132 sig_send(&btn->clicked, NULL); 121 }122 133 } 123 134 … … 126 137 button_t *btn = (button_t *) widget; 127 138 widget->window->focus = widget; 128 139 129 140 // TODO make the click logic more robust (mouse grabbing, mouse moves) 130 141 if (event.btn_num == 1) { 131 if (event.type == POS_RELEASE) {142 if (event.type == POS_RELEASE) 132 143 sig_send(&btn->clicked, NULL); 133 }134 144 } 135 145 } 136 146 137 bool init_button(button_t *btn, widget_t *parent, 138 const char *caption, uint16_t points, pixel_t background, pixel_t foreground)147 bool init_button(button_t *btn, widget_t *parent, const char *caption, 148 uint16_t points, pixel_t background, pixel_t foreground, pixel_t text) 139 149 { 140 150 widget_init(&btn->widget, parent); 141 151 142 152 btn->widget.destroy = button_destroy; 143 153 btn->widget.reconfigure = button_reconfigure; … … 146 156 btn->widget.handle_keyboard_event = button_handle_keyboard_event; 147 157 btn->widget.handle_position_event = button_handle_position_event; 148 158 149 159 source_init(&btn->background); 150 160 source_set_color(&btn->background, background); 161 151 162 source_init(&btn->foreground); 152 163 source_set_color(&btn->foreground, foreground); 153 154 if (caption == NULL) { 164 165 source_init(&btn->text); 166 source_set_color(&btn->text, text); 167 168 if (caption == NULL) 155 169 btn->caption = NULL; 156 } else {170 else 157 171 btn->caption = str_dup(caption); 158 }172 159 173 font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points); 160 174 161 175 sysarg_t cpt_width; 162 176 sysarg_t cpt_height; 163 177 font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height); 164 btn->widget.width_min = cpt_width + 8;165 btn->widget.height_min = cpt_height + 8;166 btn->widget.width_ideal = cpt_width + 28;167 btn->widget.height_ideal = cpt_height + 8;168 178 btn->widget.width_min = cpt_width + 10; 179 btn->widget.height_min = cpt_height + 10; 180 btn->widget.width_ideal = cpt_width + 30; 181 btn->widget.height_ideal = cpt_height + 10; 182 169 183 return true; 170 184 } 171 185 172 button_t *create_button(widget_t *parent, 173 const char *caption, uint16_t points, pixel_t background, pixel_t foreground)186 button_t *create_button(widget_t *parent, const char *caption, uint16_t points, 187 pixel_t background, pixel_t foreground, pixel_t text) 174 188 { 175 189 button_t *btn = (button_t *) malloc(sizeof(button_t)); 176 if (!btn) {190 if (!btn) 177 191 return NULL; 178 }179 180 if (init_button(btn, parent, caption, points, background, foreground)) {192 193 if (init_button(btn, parent, caption, points, background, foreground, 194 text)) 181 195 return btn; 182 } else { 183 free(btn); 184 return NULL; 185 } 196 197 free(btn); 198 return NULL; 186 199 } 187 200 -
uspace/lib/gui/button.h
r2e80321 r66be0288 50 50 source_t background; 51 51 source_t foreground; 52 source_t text; 52 53 char *caption; 53 54 font_t font; … … 55 56 } button_t; 56 57 57 extern bool init_button(button_t *, widget_t *, const char *, uint16_t, pixel_t, pixel_t); 58 extern button_t *create_button(widget_t *, const char *, uint16_t, pixel_t, pixel_t); 58 extern bool init_button(button_t *, widget_t *, const char *, uint16_t, pixel_t, 59 pixel_t, pixel_t); 60 extern button_t *create_button(widget_t *, const char *, uint16_t, pixel_t, 61 pixel_t, pixel_t); 59 62 extern void deinit_button(button_t *); 60 63 -
uspace/lib/gui/connection.c
r2e80321 r66be0288 210 210 link_initialize(&event->link); 211 211 event->type = ET_SIGNAL_EVENT; 212 event->data.sig .object = (sysarg_t) cur->widget;213 event->data.sig .slot = (sysarg_t) cur->slot;214 event->data.sig .argument = (sysarg_t) data_copy;212 event->data.signal.object = (sysarg_t) cur->widget; 213 event->data.signal.slot = (sysarg_t) cur->slot; 214 event->data.signal.argument = (sysarg_t) data_copy; 215 215 prodcons_produce(&cur->widget->window->events, &event->link); 216 216 } else { -
uspace/lib/gui/label.c
r2e80321 r66be0288 36 36 #include <str.h> 37 37 #include <malloc.h> 38 39 38 #include <drawctx.h> 40 39 #include <surface.h> 41 42 40 #include "window.h" 43 41 #include "label.h" 44 42 45 static void paint_internal(widget_t *w )43 static void paint_internal(widget_t *widget) 46 44 { 47 label_t *lbl = (label_t *) w ;45 label_t *lbl = (label_t *) widget; 48 46 49 47 surface_t *surface = window_claim(lbl->widget.window); 50 if (!surface) {48 if (!surface) 51 49 window_yield(lbl->widget.window); 52 } 53 50 54 51 drawctx_t drawctx; 55 56 52 drawctx_init(&drawctx, surface); 53 57 54 drawctx_set_source(&drawctx, &lbl->background); 58 drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, w->height); 59 55 drawctx_transfer(&drawctx, widget->hpos, widget->vpos, widget->width, 56 widget->height); 57 60 58 sysarg_t cpt_width; 61 59 sysarg_t cpt_height; 62 60 font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height); 63 if (w->width >= cpt_width && w->height >= cpt_height) { 64 drawctx_set_source(&drawctx, &lbl->foreground); 61 62 if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) { 63 sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos; 64 sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos; 65 66 drawctx_set_source(&drawctx, &lbl->text); 65 67 drawctx_set_font(&drawctx, &lbl->font); 66 sysarg_t x = ((w->width - cpt_width) / 2) + w->hpos; 67 sysarg_t y = ((w->height - cpt_height) / 2) + w->vpos; 68 if (lbl->caption) { 68 69 if (lbl->caption) 69 70 drawctx_print(&drawctx, lbl->caption, x, y); 70 }71 71 } 72 72 73 73 window_yield(lbl->widget.window); 74 74 } … … 78 78 if (data != NULL) { 79 79 label_t *lbl = (label_t *) widget; 80 80 81 const char *new_caption = (const char *) data; 81 82 lbl->caption = str_dup(new_caption); 82 83 83 84 sysarg_t cpt_width; 84 85 sysarg_t cpt_height; 85 86 font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height); 87 86 88 lbl->widget.width_min = cpt_width + 4; 87 89 lbl->widget.height_min = cpt_height + 4; 88 90 lbl->widget.width_ideal = lbl->widget.width_min; 89 91 lbl->widget.height_ideal = lbl->widget.height_min; 90 92 91 93 window_refresh(lbl->widget.window); 92 94 } … … 103 105 { 104 106 label_t *lbl = (label_t *) widget; 105 107 106 108 deinit_label(lbl); 107 108 109 free(lbl); 109 110 } … … 137 138 } 138 139 139 bool init_label(label_t *lbl, widget_t *parent, 140 const char *caption, uint16_t points, pixel_t background, pixel_t foreground)140 bool init_label(label_t *lbl, widget_t *parent, const char *caption, 141 uint16_t points, pixel_t background, pixel_t text) 141 142 { 142 143 widget_init(&lbl->widget, parent); 143 144 144 145 lbl->widget.destroy = label_destroy; 145 146 lbl->widget.reconfigure = label_reconfigure; … … 148 149 lbl->widget.handle_keyboard_event = label_handle_keyboard_event; 149 150 lbl->widget.handle_position_event = label_handle_position_event; 150 151 151 152 source_init(&lbl->background); 152 153 source_set_color(&lbl->background, background); 153 source_init(&lbl->foreground); 154 source_set_color(&lbl->foreground, foreground); 155 156 if (caption == NULL) { 154 155 source_init(&lbl->text); 156 source_set_color(&lbl->text, text); 157 158 if (caption == NULL) 157 159 lbl->caption = NULL; 158 } else {160 else 159 161 lbl->caption = str_dup(caption); 160 }162 161 163 font_init(&lbl->font, FONT_DECODER_EMBEDDED, NULL, points); 162 164 163 165 sysarg_t cpt_width; 164 166 sysarg_t cpt_height; 165 167 font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height); 168 166 169 lbl->widget.width_min = cpt_width + 4; 167 170 lbl->widget.height_min = cpt_height + 4; 168 171 lbl->widget.width_ideal = lbl->widget.width_min; 169 172 lbl->widget.height_ideal = lbl->widget.height_min; 170 173 171 174 lbl->rewrite = on_rewrite; 172 175 173 176 return true; 174 177 } 175 178 176 label_t *create_label(widget_t *parent, 177 const char *caption, uint16_t points, pixel_t background, pixel_t foreground)179 label_t *create_label(widget_t *parent, const char *caption, uint16_t points, 180 pixel_t background, pixel_t text) 178 181 { 179 182 label_t *lbl = (label_t *) malloc(sizeof(label_t)); 180 if (!lbl) {183 if (!lbl) 181 184 return NULL; 182 } 183 184 if (init_label(lbl, parent, caption, points, background, foreground)) { 185 186 if (init_label(lbl, parent, caption, points, background, text)) 185 187 return lbl; 186 } else { 187 free(lbl); 188 return NULL; 189 } 188 189 free(lbl); 190 return NULL; 190 191 } 191 192 192 193 /** @} 193 194 */ 194 -
uspace/lib/gui/label.h
r2e80321 r66be0288 49 49 widget_t widget; 50 50 source_t background; 51 source_t foreground;51 source_t text; 52 52 char *caption; 53 53 font_t font; … … 55 55 } label_t; 56 56 57 extern bool init_label(label_t *, widget_t *, const char *, uint16_t, pixel_t, pixel_t); 58 extern label_t *create_label(widget_t *, const char *, uint16_t, pixel_t, pixel_t); 57 extern bool init_label(label_t *, widget_t *, const char *, uint16_t, pixel_t, 58 pixel_t); 59 extern label_t *create_label(widget_t *, const char *, uint16_t, pixel_t, 60 pixel_t); 59 61 extern void deinit_label(label_t *); 60 62 -
uspace/lib/gui/window.c
r2e80321 r66be0288 56 56 #include <surface.h> 57 57 58 #include "common.h" 58 59 #include "connection.h" 59 60 #include "widget.h" 60 61 #include "window.h" 61 62 62 static sysarg_t border_thickness = 5; 63 static sysarg_t border_thickness = 4; 64 static sysarg_t bevel_thickness = 1; 63 65 static sysarg_t header_height = 20; 64 66 static sysarg_t header_min_width = 40; 65 static sysarg_t close_width = 20; 66 67 static pixel_t border_color = PIXEL(255, 0, 0, 0); 68 static pixel_t header_bg_focus_color = PIXEL(255, 88, 106, 196); 69 static pixel_t header_fg_focus_color = PIXEL(255, 255, 255, 255); 70 static pixel_t header_bg_unfocus_color = PIXEL(255, 12, 57, 92); 71 static pixel_t header_fg_unfocus_color = PIXEL(255, 255, 255, 255); 72 73 static void paint_internal(widget_t *w) 74 { 75 surface_t *surface = window_claim(w->window); 76 if (!surface) { 77 window_yield(w->window); 78 } 79 67 static sysarg_t close_thickness = 20; 68 69 static pixel_t color_highlight = PIXEL(255, 255, 255, 255); 70 static pixel_t color_shadow = PIXEL(255, 85, 85, 85); 71 static pixel_t color_surface = PIXEL(255, 186, 186, 186); 72 73 static pixel_t color_header_focus_highlight = PIXEL(255, 120, 145, 255); 74 static pixel_t color_header_focus_shadow = PIXEL(255, 40, 48, 89); 75 static pixel_t color_header_focus_surface = PIXEL(255, 88, 106, 196); 76 77 static pixel_t color_header_unfocus_highlight = PIXEL(255, 16, 78, 126); 78 static pixel_t color_header_unfocus_shadow = PIXEL(255, 5, 26, 42); 79 static pixel_t color_header_unfocus_surface = PIXEL(255, 12, 57, 92); 80 81 static pixel_t color_caption_focus = PIXEL(255, 255, 255, 255); 82 static pixel_t color_caption_unfocus = PIXEL(255, 207, 207, 207); 83 84 static void paint_internal(widget_t *widget) 85 { 86 surface_t *surface = window_claim(widget->window); 87 if (!surface) 88 window_yield(widget->window); 89 80 90 source_t source; 81 font_t font; 91 source_init(&source); 92 82 93 drawctx_t drawctx; 83 84 source_init(&source);85 font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16);86 94 drawctx_init(&drawctx, surface); 87 95 drawctx_set_source(&drawctx, &source); 96 97 /* Window border outer bevel */ 98 99 draw_bevel(&drawctx, &source, widget->vpos, widget->hpos, 100 widget->width, widget->height, color_highlight, color_shadow); 101 102 /* Window border surface */ 103 104 source_set_color(&source, color_surface); 105 drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1, 106 widget->width - 2, 2); 107 drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1, 108 2, widget->height - 2); 109 drawctx_transfer(&drawctx, widget->hpos + 1, 110 widget->vpos + widget->height - 3, widget->width - 2, 2); 111 drawctx_transfer(&drawctx, widget->hpos + widget->width - 3, 112 widget->vpos + 1, 2, widget->height - 4); 113 114 /* Window border inner bevel */ 115 116 draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3, 117 widget->width - 6, widget->height - 6, color_shadow, 118 color_highlight); 119 120 /* Header bevel */ 121 122 sysarg_t header_hpos = widget->hpos + border_thickness; 123 sysarg_t header_vpos = widget->vpos + border_thickness; 124 sysarg_t header_width = widget->width - 2 * border_thickness - 125 close_thickness; 126 127 draw_bevel(&drawctx, &source, header_hpos, header_vpos, 128 header_width, header_height, widget->window->is_focused ? 129 color_header_focus_highlight : color_header_unfocus_highlight, 130 widget->window->is_focused ? 131 color_header_focus_shadow : color_header_unfocus_shadow); 132 133 /* Header surface */ 134 135 source_set_color(&source, widget->window->is_focused ? 136 color_header_focus_surface : color_header_unfocus_surface); 137 drawctx_transfer(&drawctx, header_hpos + 1, header_vpos + 1, 138 header_width - 2, header_height - 2); 139 140 /* Close button bevel */ 141 142 sysarg_t close_hpos = widget->hpos + widget->width - 143 border_thickness - close_thickness; 144 sysarg_t close_vpos = widget->vpos + border_thickness; 145 146 draw_bevel(&drawctx, &source, close_hpos, close_vpos, 147 close_thickness, close_thickness, color_highlight, color_shadow); 148 149 /* Close button surface */ 150 151 source_set_color(&source, color_surface); 152 drawctx_transfer(&drawctx, close_hpos + 1, close_vpos + 1, 153 close_thickness - 2, close_thickness - 2); 154 155 /* Close button icon */ 156 157 draw_icon_cross(surface, close_hpos + 3, close_vpos + 3, 158 color_highlight, color_shadow); 159 160 /* Window caption */ 161 162 font_t font; 163 font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16); 164 88 165 drawctx_set_font(&drawctx, &font); 89 90 source_set_color(&source, border_color); 91 drawctx_transfer(&drawctx, w->hpos, w->vpos, border_thickness, w->height); 92 drawctx_transfer(&drawctx, w->hpos + w->width - border_thickness, 93 w->vpos, border_thickness, w->height); 94 drawctx_transfer(&drawctx, w->hpos, w->vpos, w->width, border_thickness); 95 drawctx_transfer(&drawctx, w->hpos, 96 w->vpos + w->height - border_thickness, w->width, border_thickness); 97 98 source_set_color(&source, 99 w->window->is_focused ? header_bg_focus_color : header_bg_unfocus_color); 100 drawctx_transfer(&drawctx, 101 w->hpos + border_thickness, w->vpos + border_thickness, 102 w->width - 2 * border_thickness, header_height); 103 166 source_set_color(&source, widget->window->is_focused ? 167 color_caption_focus : color_caption_unfocus); 168 104 169 sysarg_t cpt_width; 105 170 sysarg_t cpt_height; 106 font_get_box(&font, w->window->caption, &cpt_width, &cpt_height); 107 sysarg_t cls_width; 108 sysarg_t cls_height; 109 char cls_pict[] = "x"; 110 font_get_box(&font, cls_pict, &cls_width, &cls_height); 111 source_set_color(&source, 112 w->window->is_focused ? header_fg_focus_color : header_fg_unfocus_color); 113 sysarg_t cls_x = ((close_width - cls_width) / 2) + w->hpos + w->width - 114 border_thickness - close_width; 115 sysarg_t cls_y = ((header_height - cls_height) / 2) + w->vpos + border_thickness; 116 drawctx_print(&drawctx, cls_pict, cls_x, cls_y); 117 118 bool draw_title = (w->width >= 2 * border_thickness + close_width + cpt_width); 171 font_get_box(&font, widget->window->caption, &cpt_width, &cpt_height); 172 173 bool draw_title = 174 (widget->width >= 2 * border_thickness + 2 * bevel_thickness + 175 close_thickness + cpt_width); 119 176 if (draw_title) { 120 sysarg_t cpt_x = ((w->width - cpt_width) / 2) + w->hpos; 121 sysarg_t cpt_y = ((header_height - cpt_height) / 2) + w->vpos + border_thickness; 122 if (w->window->caption) { 123 drawctx_print(&drawctx, w->window->caption, cpt_x, cpt_y); 124 } 125 } 126 177 sysarg_t cpt_x = ((widget->width - cpt_width) / 2) + widget->hpos; 178 sysarg_t cpt_y = ((header_height - cpt_height) / 2) + 179 widget->vpos + border_thickness; 180 181 if (widget->window->caption) 182 drawctx_print(&drawctx, widget->window->caption, cpt_x, cpt_y); 183 } 184 127 185 font_release(&font); 128 window_yield(w ->window);186 window_yield(widget->window); 129 187 } 130 188 … … 138 196 if (widget->window->is_decorated) { 139 197 list_foreach(widget->children, link, widget_t, child) { 140 child->rearrange(child, 198 child->rearrange(child, 141 199 widget->hpos + border_thickness, 142 200 widget->vpos + border_thickness + header_height, … … 211 269 (event.vpos >= border_thickness) && 212 270 (event.vpos < border_thickness + header_height); 213 bool close = header && (event.hpos >= width - border_thickness - close_width); 271 bool close = (header) && 272 (event.hpos >= width - border_thickness - close_thickness); 214 273 215 274 if (top && left && allowed_button) { … … 292 351 } 293 352 294 static void handle_signal_event(window_t *win, sig _event_t event)353 static void handle_signal_event(window_t *win, signal_event_t event) 295 354 { 296 355 widget_t *widget = (widget_t *) event.object; … … 303 362 } 304 363 305 static void handle_resize(window_t *win, sysarg_t width, sysarg_t height) 306 { 307 int rc; 308 surface_t *old_surface; 309 surface_t *new_surface; 310 364 static void handle_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 365 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 366 { 311 367 if (width < 2 * border_thickness + header_min_width) { 312 368 win_damage(win->osess, 0, 0, 0, 0); 313 369 return; 314 370 } 315 371 316 372 if (height < 2 * border_thickness + header_height) { 317 373 win_damage(win->osess, 0, 0, 0, 0); 318 374 return; 319 375 } 320 376 321 377 /* Allocate resources for new surface. */ 322 new_surface = surface_create(width, height, NULL, SURFACE_FLAG_SHARED); 323 if (!new_surface) { 378 surface_t *new_surface = surface_create(width, height, NULL, 379 SURFACE_FLAG_SHARED); 380 if (!new_surface) 324 381 return; 325 } 326 382 327 383 /* Switch new and old surface. */ 328 384 fibril_mutex_lock(&win->guard); 329 old_surface = win->surface;385 surface_t *old_surface = win->surface; 330 386 win->surface = new_surface; 331 387 fibril_mutex_unlock(&win->guard); 332 333 /* Let all widgets in the tree alter their position and size. Widgets might 334 * also paint themselves onto the new surface. */ 388 389 /* 390 * Let all widgets in the tree alter their position and size. 391 * Widgets might also paint themselves onto the new surface. 392 */ 335 393 win->root.rearrange(&win->root, 0, 0, width, height); 336 394 337 395 fibril_mutex_lock(&win->guard); 338 396 surface_reset_damaged_region(win->surface); 339 397 fibril_mutex_unlock(&win->guard); 340 398 341 399 /* Inform compositor about new surface. */ 342 rc = win_resize(win->osess,343 width, height, surface_direct_access(new_surface));344 400 int rc = win_resize(win->osess, offset_x, offset_y, width, height, 401 placement_flags, surface_direct_access(new_surface)); 402 345 403 if (rc != EOK) { 346 404 /* Rollback to old surface. Reverse all changes. */ 347 405 348 406 sysarg_t old_width = 0; 349 407 sysarg_t old_height = 0; 350 if (old_surface) {408 if (old_surface) 351 409 surface_get_resolution(old_surface, &old_width, &old_height); 352 } 353 410 354 411 fibril_mutex_lock(&win->guard); 355 412 new_surface = win->surface; 356 413 win->surface = old_surface; 357 414 fibril_mutex_unlock(&win->guard); 358 415 359 416 win->root.rearrange(&win->root, 0, 0, old_width, old_height); 360 417 … … 364 421 fibril_mutex_unlock(&win->guard); 365 422 } 366 423 367 424 surface_destroy(new_surface); 368 return; 369 } 370 371 /* Finally deallocate old surface. */ 372 if (old_surface) { 373 surface_destroy(old_surface); 425 } else { 426 /* Deallocate old surface. */ 427 if (old_surface) 428 surface_destroy(old_surface); 374 429 } 375 430 } … … 453 508 break; 454 509 case ET_SIGNAL_EVENT: 455 handle_signal_event(win, event->data.sig );510 handle_signal_event(win, event->data.signal); 456 511 break; 457 512 case ET_WINDOW_RESIZE: 458 handle_resize(win, event->data.rsz.width, event->data.rsz.height); 513 handle_resize(win, event->data.resize.offset_x, 514 event->data.resize.offset_y, event->data.resize.width, 515 event->data.resize.height, event->data.resize.placement_flags); 459 516 break; 460 517 case ET_WINDOW_FOCUS: … … 530 587 531 588 window_t *window_open(const char *winreg, bool is_main, bool is_decorated, 532 const char *caption, sysarg_t x_offset, sysarg_t y_offset) 533 { 534 int rc; 535 589 const char *caption) 590 { 536 591 window_t *win = (window_t *) malloc(sizeof(window_t)); 537 if (!win) {592 if (!win) 538 593 return NULL; 539 } 540 594 541 595 win->is_main = is_main; 542 596 win->is_decorated = is_decorated; … … 544 598 prodcons_initialize(&win->events); 545 599 fibril_mutex_initialize(&win->guard); 600 546 601 widget_init(&win->root, NULL); 547 602 win->root.window = win; … … 555 610 win->focus = NULL; 556 611 win->surface = NULL; 557 612 558 613 service_id_t reg_dsid; 559 async_sess_t *reg_sess; 560 561 rc = loc_service_get_id(winreg, ®_dsid, 0); 614 int rc = loc_service_get_id(winreg, ®_dsid, 0); 562 615 if (rc != EOK) { 563 616 free(win); 564 617 return NULL; 565 618 } 566 567 reg_sess = loc_service_connect(EXCHANGE_SERIALIZE, reg_dsid, 0); 619 620 async_sess_t *reg_sess = loc_service_connect(EXCHANGE_SERIALIZE, 621 reg_dsid, 0); 568 622 if (reg_sess == NULL) { 569 623 free(win); 570 624 return NULL; 571 625 } 572 626 573 627 service_id_t in_dsid; 574 628 service_id_t out_dsid; 575 576 rc = win_register(reg_sess, &in_dsid, &out_dsid, x_offset, y_offset); 629 rc = win_register(reg_sess, &in_dsid, &out_dsid); 577 630 async_hangup(reg_sess); 578 631 if (rc != EOK) { … … 580 633 return NULL; 581 634 } 582 635 583 636 win->osess = loc_service_connect(EXCHANGE_SERIALIZE, out_dsid, 0); 584 637 if (win->osess == NULL) { … … 586 639 return NULL; 587 640 } 588 641 589 642 win->isess = loc_service_connect(EXCHANGE_SERIALIZE, in_dsid, 0); 590 643 if (win->isess == NULL) { … … 593 646 return NULL; 594 647 } 595 596 if (caption == NULL) {648 649 if (caption == NULL) 597 650 win->caption = NULL; 598 } else {651 else 599 652 win->caption = str_dup(caption); 600 } 601 653 602 654 return win; 603 655 } 604 656 605 void window_resize(window_t *win, sysarg_t width, sysarg_t height) 657 void window_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 658 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 606 659 { 607 660 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); … … 609 662 link_initialize(&event->link); 610 663 event->type = ET_WINDOW_RESIZE; 611 event->data.rsz.width = width; 612 event->data.rsz.height = height; 664 event->data.resize.offset_x = offset_x; 665 event->data.resize.offset_y = offset_y; 666 event->data.resize.width = width; 667 event->data.resize.height = height; 668 event->data.resize.placement_flags = placement_flags; 613 669 prodcons_produce(&win->events, &event->link); 614 670 } -
uspace/lib/gui/window.h
r2e80321 r66be0288 66 66 * If the window is declared as main, its closure causes termination of the 67 67 * whole application. Note that opened window does not have any surface yet. */ 68 extern window_t *window_open(const char *, bool, bool, const char *, sysarg_t, 69 sysarg_t); 68 extern window_t *window_open(const char *, bool, bool, const char *); 70 69 71 70 /** … … 74 73 * and to paint themselves on the new surface (top-bottom order). Should be 75 74 * called also after opening new window to obtain surface. */ 76 extern void window_resize(window_t *, sysarg_t, sysarg_t); 75 extern void window_resize(window_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 76 window_placement_flags_t); 77 77 78 78 /** -
uspace/srv/hid/compositor/Makefile
r2e80321 r66be0288 42 42 43 43 SOURCES = \ 44 compositor.c \ 45 images.c 46 47 IMAGES = \ 48 gfx/nameic.tga 49 50 PRE_DEPEND = images.c images.h 51 EXTRA_CLEAN = images.c images.h 44 compositor.c 52 45 53 46 include $(USPACE_PREFIX)/Makefile.common 54 55 images.c images.h: $(IMAGES)56 $(ROOT_PATH)/tools/mkarray.py images COMPOSITOR_IMAGES $^ -
uspace/srv/hid/compositor/compositor.c
r2e80321 r66be0288 72 72 #include <codec/tga.h> 73 73 74 #include "images.h"75 74 #include "compositor.h" 76 75 … … 162 161 static void input_disconnect(void); 163 162 164 165 163 static pointer_t *input_pointer(input_t *input) 166 164 { … … 168 166 } 169 167 170 static pointer_t *pointer_create( )168 static pointer_t *pointer_create(void) 171 169 { 172 170 pointer_t *p = (pointer_t *) malloc(sizeof(pointer_t)); 173 if (!p) {171 if (!p) 174 172 return NULL; 175 } 176 173 177 174 link_initialize(&p->link); 178 175 p->pos.x = coord_origin; … … 186 183 p->state = 0; 187 184 cursor_init(&p->cursor, CURSOR_DECODER_EMBEDDED, NULL); 188 185 189 186 /* Ghost window for transformation animation. */ 190 187 transform_identity(&p->ghost.transform); … … 199 196 p->accum_ghost.x = 0; 200 197 p->accum_ghost.y = 0; 201 198 202 199 return p; 203 200 } … … 211 208 } 212 209 213 static window_t *window_create( sysarg_t x_offset, sysarg_t y_offset)210 static window_t *window_create(void) 214 211 { 215 212 window_t *win = (window_t *) malloc(sizeof(window_t)); 216 if (!win) {213 if (!win) 217 214 return NULL; 218 } 219 215 220 216 link_initialize(&win->link); 221 217 atomic_set(&win->ref_cnt, 0); 222 218 prodcons_initialize(&win->queue); 223 219 transform_identity(&win->transform); 224 transform_translate(&win->transform, 225 coord_origin + x_offset, coord_origin + y_offset); 226 win->dx = coord_origin + x_offset; 227 win->dy = coord_origin + y_offset; 220 transform_translate(&win->transform, coord_origin, coord_origin); 221 win->dx = coord_origin; 222 win->dy = coord_origin; 228 223 win->fx = 1; 229 224 win->fy = 1; … … 231 226 win->opacity = 255; 232 227 win->surface = NULL; 233 228 234 229 return win; 235 230 } … … 294 289 sysarg_t *x_out, sysarg_t *y_out, sysarg_t *w_out, sysarg_t *h_out) 295 290 { 296 if ( w_in > 0 && h_in > 0) {291 if ((w_in > 0) && (h_in > 0)) { 297 292 sysarg_t x[4]; 298 293 sysarg_t y[4]; 294 299 295 comp_coord_from_client(x_in, y_in, win_trans, &x[0], &y[0]); 300 296 comp_coord_from_client(x_in + w_in - 1, y_in, win_trans, &x[1], &y[1]); 301 297 comp_coord_from_client(x_in + w_in - 1, y_in + h_in - 1, win_trans, &x[2], &y[2]); 302 298 comp_coord_from_client(x_in, y_in + h_in - 1, win_trans, &x[3], &y[3]); 299 303 300 (*x_out) = x[0]; 304 301 (*y_out) = y[0]; 305 302 (*w_out) = x[0]; 306 303 (*h_out) = y[0]; 307 for (int i = 1; i < 4; ++i) { 304 305 for (unsigned int i = 1; i < 4; ++i) { 308 306 (*x_out) = (x[i] < (*x_out)) ? x[i] : (*x_out); 309 307 (*y_out) = (y[i] < (*y_out)) ? y[i] : (*y_out); … … 311 309 (*h_out) = (y[i] > (*h_out)) ? y[i] : (*h_out); 312 310 } 311 313 312 (*w_out) = (*w_out) - (*x_out) + 1; 314 313 (*h_out) = (*h_out) - (*y_out) + 1; … … 321 320 } 322 321 323 static void comp_ restrict_pointers(void)322 static void comp_update_viewport_bound_rect(void) 324 323 { 325 324 fibril_mutex_lock(&viewport_list_mtx); 326 325 327 326 sysarg_t x_res = coord_origin; 328 327 sysarg_t y_res = coord_origin; 329 328 sysarg_t w_res = 0; 330 329 sysarg_t h_res = 0; 331 330 332 331 if (!list_empty(&viewport_list)) { 333 332 viewport_t *vp = (viewport_t *) list_first(&viewport_list); … … 336 335 surface_get_resolution(vp->surface, &w_res, &h_res); 337 336 } 338 337 339 338 list_foreach(viewport_list, link, viewport_t, vp) { 340 339 sysarg_t w_vp, h_vp; 341 340 surface_get_resolution(vp->surface, &w_vp, &h_vp); 342 rectangle_union( 343 x_res, y_res, w_res, h_res, 341 rectangle_union(x_res, y_res, w_res, h_res, 344 342 vp->pos.x, vp->pos.y, w_vp, h_vp, 345 343 &x_res, &y_res, &w_res, &h_res); 346 344 } 347 345 348 346 viewport_bound_rect.x = x_res; 349 347 viewport_bound_rect.y = y_res; 350 348 viewport_bound_rect.w = w_res; 351 349 viewport_bound_rect.h = h_res; 352 350 353 351 fibril_mutex_unlock(&viewport_list_mtx); 354 352 } 353 354 static void comp_restrict_pointers(void) 355 { 356 comp_update_viewport_bound_rect(); 357 355 358 fibril_mutex_lock(&pointer_list_mtx); 356 359 357 360 list_foreach(pointer_list, link, pointer_t, ptr) { 358 361 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x; … … 363 366 ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h; 364 367 } 365 368 366 369 fibril_mutex_unlock(&pointer_list_mtx); 367 370 } … … 642 645 } 643 646 647 static void comp_recalc_transform(window_t *win) 648 { 649 transform_t translate; 650 transform_identity(&translate); 651 transform_translate(&translate, win->dx, win->dy); 652 653 transform_t scale; 654 transform_identity(&scale); 655 if ((win->fx != 1) || (win->fy != 1)) 656 transform_scale(&scale, win->fx, win->fy); 657 658 transform_t rotate; 659 transform_identity(&rotate); 660 if (win->angle != 0) 661 transform_rotate(&rotate, win->angle); 662 663 transform_t transform; 664 transform_t temp; 665 transform_identity(&transform); 666 temp = transform; 667 transform_multiply(&transform, &temp, &translate); 668 temp = transform; 669 transform_multiply(&transform, &temp, &rotate); 670 temp = transform; 671 transform_multiply(&transform, &temp, &scale); 672 673 win->transform = transform; 674 } 675 644 676 static void comp_window_resize(window_t *win, ipc_callid_t iid, ipc_call_t *icall) 645 677 { 646 int rc;647 648 678 ipc_callid_t callid; 649 679 size_t size; 650 680 unsigned int flags; 651 681 652 682 /* Start sharing resized window with client. */ 653 683 if (!async_share_out_receive(&callid, &size, &flags)) { … … 655 685 return; 656 686 } 687 657 688 void *new_cell_storage; 658 rc = async_share_out_finalize(callid, &new_cell_storage);689 int rc = async_share_out_finalize(callid, &new_cell_storage); 659 690 if ((rc != EOK) || (new_cell_storage == AS_MAP_FAILED)) { 660 691 async_answer_0(iid, ENOMEM); 661 692 return; 662 693 } 663 694 664 695 /* Create new surface for the resized window. */ 665 surface_t *new_surface = surface_create( 666 IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall), 667 new_cell_storage, SURFACE_FLAG_SHARED); 696 surface_t *new_surface = surface_create(IPC_GET_ARG3(*icall), 697 IPC_GET_ARG4(*icall), new_cell_storage, SURFACE_FLAG_SHARED); 668 698 if (!new_surface) { 669 699 as_area_destroy(new_cell_storage); … … 671 701 return; 672 702 } 673 703 704 sysarg_t offset_x = IPC_GET_ARG1(*icall); 705 sysarg_t offset_y = IPC_GET_ARG2(*icall); 706 window_placement_flags_t placement_flags = 707 (window_placement_flags_t) IPC_GET_ARG5(*icall); 708 709 comp_update_viewport_bound_rect(); 710 674 711 /* Switch new surface with old surface and calculate damage. */ 675 712 fibril_mutex_lock(&window_list_mtx); 676 713 677 714 sysarg_t old_width = 0; 678 715 sysarg_t old_height = 0; 716 679 717 if (win->surface) { 680 718 surface_get_resolution(win->surface, &old_width, &old_height); 681 719 surface_destroy(win->surface); 682 720 } 683 721 684 722 win->surface = new_surface; 685 723 686 724 sysarg_t new_width = 0; 687 725 sysarg_t new_height = 0; 688 726 surface_get_resolution(win->surface, &new_width, &new_height); 689 690 sysarg_t x, y; 691 sysarg_t width = old_width > new_width ? old_width : new_width; 692 sysarg_t height = old_height > new_height ? old_height : new_height; 693 comp_coord_bounding_rect(0, 0, width, height, win->transform, &x, &y, &width, &height); 694 727 728 if (placement_flags & WINDOW_PLACEMENT_CENTER_X) 729 win->dx = viewport_bound_rect.x + viewport_bound_rect.w / 2 - 730 new_width / 2; 731 732 if (placement_flags & WINDOW_PLACEMENT_CENTER_Y) 733 win->dy = viewport_bound_rect.y + viewport_bound_rect.h / 2 - 734 new_height / 2; 735 736 if (placement_flags & WINDOW_PLACEMENT_LEFT) 737 win->dx = viewport_bound_rect.x; 738 739 if (placement_flags & WINDOW_PLACEMENT_TOP) 740 win->dy = viewport_bound_rect.y; 741 742 if (placement_flags & WINDOW_PLACEMENT_RIGHT) 743 win->dx = viewport_bound_rect.x + viewport_bound_rect.w - 744 new_width; 745 746 if (placement_flags & WINDOW_PLACEMENT_BOTTOM) 747 win->dy = viewport_bound_rect.y + viewport_bound_rect.h - 748 new_height; 749 750 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_X) 751 win->dx = coord_origin + offset_x; 752 753 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_Y) 754 win->dy = coord_origin + offset_y; 755 756 /* Transform the window and calculate damage. */ 757 sysarg_t x1; 758 sysarg_t y1; 759 sysarg_t width1; 760 sysarg_t height1; 761 762 comp_coord_bounding_rect(0, 0, old_width, old_height, win->transform, 763 &x1, &y1, &width1, &height1); 764 765 comp_recalc_transform(win); 766 767 sysarg_t x2; 768 sysarg_t y2; 769 sysarg_t width2; 770 sysarg_t height2; 771 772 comp_coord_bounding_rect(0, 0, new_width, new_height, win->transform, 773 &x2, &y2, &width2, &height2); 774 775 sysarg_t x; 776 sysarg_t y; 777 sysarg_t width; 778 sysarg_t height; 779 780 rectangle_union(x1, y1, width1, height1, x2, y2, width2, height2, 781 &x, &y, &width, &height); 782 695 783 fibril_mutex_unlock(&window_list_mtx); 696 784 697 785 comp_damage(x, y, width, height); 698 786 699 787 async_answer_0(iid, EOK); 700 788 } … … 703 791 { 704 792 fibril_mutex_lock(&window_list_mtx); 705 793 706 794 list_foreach(window_list, link, window_t, window) { 707 795 if (window == target) { … … 711 799 } 712 800 } 713 801 714 802 fibril_mutex_unlock(&window_list_mtx); 715 803 free(event); … … 719 807 { 720 808 fibril_mutex_lock(&window_list_mtx); 809 721 810 window_t *win = (window_t *) list_first(&window_list); 722 if (win) {811 if (win) 723 812 prodcons_produce(&win->queue, &event->link); 724 } else {813 else 725 814 free(event); 726 }815 727 816 fibril_mutex_unlock(&window_list_mtx); 728 817 } … … 801 890 fibril_mutex_lock(&window_list_mtx); 802 891 803 window_t *win = window_create( IPC_GET_ARG1(call), IPC_GET_ARG2(call));892 window_t *win = window_create(); 804 893 if (!win) { 805 894 async_answer_2(callid, ENOMEM, 0, 0); … … 1173 1262 } 1174 1263 1175 static void comp_recalc_transform(window_t *win)1176 {1177 transform_t translate;1178 transform_identity(&translate);1179 transform_translate(&translate, win->dx, win->dy);1180 1181 transform_t scale;1182 transform_identity(&scale);1183 if (win->fx != 1 || win->fy != 1) {1184 transform_scale(&scale, win->fx, win->fy);1185 }1186 1187 transform_t rotate;1188 transform_identity(&rotate);1189 if (win->angle != 0) {1190 transform_rotate(&rotate, win->angle);1191 }1192 1193 transform_t transform;1194 transform_t temp;1195 transform_identity(&transform);1196 temp = transform;1197 transform_multiply(&transform, &temp, &translate);1198 temp = transform;1199 transform_multiply(&transform, &temp, &rotate);1200 temp = transform;1201 transform_multiply(&transform, &temp, &scale);1202 1203 1204 win->transform = transform;1205 }1206 1207 1264 static void comp_window_animate(pointer_t *pointer, window_t *win, 1208 1265 sysarg_t *dmg_x, sysarg_t *dmg_y, sysarg_t *dmg_width, sysarg_t *dmg_height) … … 1226 1283 double cx = 0; 1227 1284 double cy = 0; 1228 if (pointer->grab_flags & GF_MOVE_X) { 1285 1286 if (pointer->grab_flags & GF_MOVE_X) 1229 1287 cx = 1; 1230 }1231 if (pointer->grab_flags & GF_MOVE_Y) {1288 1289 if (pointer->grab_flags & GF_MOVE_Y) 1232 1290 cy = 1; 1233 } 1234 1235 if ((scale || resize) && (win->angle != 0)) { 1291 1292 if (((scale) || (resize)) && (win->angle != 0)) { 1236 1293 transform_t rotate; 1237 1294 transform_identity(&rotate); 1295 1238 1296 transform_rotate(&rotate, win->angle); 1239 1297 transform_apply_linear(&rotate, &cx, &cy); 1240 1298 } 1241 1299 1242 cx = (cx < 0) ? (-1 * cx) : cx; 1300 cx = (cx < 0) ? (-1 * cx) : cx; 1243 1301 cy = (cy < 0) ? (-1 * cy) : cy; 1244 1302 1245 1303 win->dx += (cx * dx); 1246 1304 win->dy += (cy * dy); 1247 1305 } 1248 1306 1249 if ( scale || resize) {1307 if ((scale) || (resize)) { 1250 1308 double _dx = dx; 1251 1309 double _dy = dy; … … 1263 1321 if (fx > 0) { 1264 1322 #if ANIMATE_WINDOW_TRANSFORMS == 0 1265 if (scale) win->fx *= fx; 1323 if (scale) 1324 win->fx *= fx; 1266 1325 #endif 1267 1326 #if ANIMATE_WINDOW_TRANSFORMS == 1 … … 1444 1503 { 1445 1504 pointer_t *pointer = input_pointer(input); 1446 1505 1506 comp_update_viewport_bound_rect(); 1507 1447 1508 /* Update pointer position. */ 1448 1509 fibril_mutex_lock(&pointer_list_mtx); 1510 1449 1511 desktop_point_t old_pos = pointer->pos; 1512 1450 1513 sysarg_t cursor_width; 1451 1514 sysarg_t cursor_height; 1452 surface_get_resolution(pointer->cursor.states[pointer->state], 1515 surface_get_resolution(pointer->cursor.states[pointer->state], 1453 1516 &cursor_width, &cursor_height); 1454 if (pointer->pos.x + dx < viewport_bound_rect.x) { 1517 1518 if (pointer->pos.x + dx < viewport_bound_rect.x) 1455 1519 dx = -1 * (pointer->pos.x - viewport_bound_rect.x); 1456 }1457 if (pointer->pos.y + dy < viewport_bound_rect.y) {1520 1521 if (pointer->pos.y + dy < viewport_bound_rect.y) 1458 1522 dy = -1 * (pointer->pos.y - viewport_bound_rect.y); 1459 }1460 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) {1523 1524 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) 1461 1525 dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x); 1462 }1463 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) {1526 1527 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) 1464 1528 dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y); 1465 }1529 1466 1530 pointer->pos.x += dx; 1467 1531 pointer->pos.y += dy; … … 1469 1533 comp_damage(old_pos.x, old_pos.y, cursor_width, cursor_height); 1470 1534 comp_damage(old_pos.x + dx, old_pos.y + dy, cursor_width, cursor_height); 1471 1535 1472 1536 fibril_mutex_lock(&window_list_mtx); 1473 1537 fibril_mutex_lock(&pointer_list_mtx); … … 1630 1694 1631 1695 #if ANIMATE_WINDOW_TRANSFORMS == 0 1632 sysarg_t pre_x = 0; 1696 sysarg_t pre_x = 0; 1633 1697 sysarg_t pre_y = 0; 1634 1698 sysarg_t pre_width = 0; … … 1662 1726 link_initialize(&event_top->link); 1663 1727 event_top->type = ET_WINDOW_RESIZE; 1664 1728 1729 event_top->data.resize.offset_x = 0; 1730 event_top->data.resize.offset_y = 0; 1731 1665 1732 int dx = (int) (((double) width) * (scale_back_x - 1.0)); 1666 1733 int dy = (int) (((double) height) * (scale_back_y - 1.0)); 1667 1668 if (pointer->grab_flags & GF_RESIZE_X) { 1669 event_top->data.rsz.width = 1670 ((((int) width) + dx) >= 0) ? (width + dx) : 0; 1671 } else { 1672 event_top->data.rsz.width = width; 1673 } 1674 1675 if (pointer->grab_flags & GF_RESIZE_Y) { 1676 event_top->data.rsz.height = 1677 ((((int) height) + dy) >= 0) ? (height + dy) : 0; 1678 } else { 1679 event_top->data.rsz.height = height; 1680 } 1734 1735 if (pointer->grab_flags & GF_RESIZE_X) 1736 event_top->data.resize.width = 1737 ((((int) width) + dx) >= 0) ? (width + dx) : 0; 1738 else 1739 event_top->data.resize.width = width; 1740 1741 if (pointer->grab_flags & GF_RESIZE_Y) 1742 event_top->data.resize.height = 1743 ((((int) height) + dy) >= 0) ? (height + dy) : 0; 1744 else 1745 event_top->data.resize.height = height; 1746 1747 event_top->data.resize.placement_flags = 1748 WINDOW_PLACEMENT_ANY; 1681 1749 } 1682 1750 … … 1746 1814 key == KC_O || key == KC_P); 1747 1815 bool kconsole_switch = (mods & KM_ALT) && (key == KC_M); 1748 bool compositor_test = (mods & KM_ALT) && (key == KC_H);1749 1816 1750 1817 bool filter = (type == KEY_RELEASE) && (win_transform || win_resize || 1751 1818 win_opacity || win_close || win_switch || viewport_move || 1752 viewport_change || kconsole_switch || compositor_test);1819 viewport_change || kconsole_switch); 1753 1820 1754 1821 if (filter) { … … 1816 1883 return ENOMEM; 1817 1884 } 1818 1885 1819 1886 sysarg_t width, height; 1820 1887 surface_get_resolution(win->surface, &width, &height); 1821 1888 1822 1889 link_initialize(&event->link); 1823 1890 event->type = ET_WINDOW_RESIZE; 1824 1891 1892 event->data.resize.offset_x = 0; 1893 event->data.resize.offset_y = 0; 1894 1825 1895 switch (key) { 1826 1896 case KC_T: 1827 event->data.r sz.width = width;1828 event->data.r sz.height = (height >= 20) ? height - 20 : 0;1897 event->data.resize.width = width; 1898 event->data.resize.height = (height >= 20) ? height - 20 : 0; 1829 1899 break; 1830 1900 case KC_G: 1831 event->data.r sz.width = width;1832 event->data.r sz.height = height + 20;1901 event->data.resize.width = width; 1902 event->data.resize.height = height + 20; 1833 1903 break; 1834 1904 case KC_B: 1835 event->data.r sz.width = (width >= 20) ? width - 20 : 0;;1836 event->data.r sz.height = height;1905 event->data.resize.width = (width >= 20) ? width - 20 : 0;; 1906 event->data.resize.height = height; 1837 1907 break; 1838 1908 case KC_N: 1839 event->data.r sz.width = width + 20;1840 event->data.r sz.height = height;1909 event->data.resize.width = width + 20; 1910 event->data.resize.height = height; 1841 1911 break; 1842 1912 default: 1843 event->data.rsz.width = 0; 1844 event->data.rsz.height = 0; 1845 break; 1846 } 1847 1913 event->data.resize.width = 0; 1914 event->data.resize.height = 0; 1915 break; 1916 } 1917 1918 event->data.resize.placement_flags = WINDOW_PLACEMENT_ANY; 1919 1848 1920 fibril_mutex_unlock(&window_list_mtx); 1849 1921 comp_post_event_top(event); … … 2014 2086 } else if (kconsole_switch) { 2015 2087 __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE); 2016 } else if (compositor_test) {2017 fibril_mutex_lock(&window_list_mtx);2018 2019 window_t *red_win = window_create(0, 0);2020 red_win->surface = surface_create(250, 150, NULL, 0);2021 pixel_t red_pix = PIXEL(255, 240, 0, 0);2022 for (sysarg_t y = 0; y < 150; ++y) {2023 for (sysarg_t x = 0; x < 250; ++x) {2024 surface_put_pixel(red_win->surface, x, y, red_pix);2025 }2026 }2027 list_prepend(&red_win->link, &window_list);2028 2029 window_t *blue_win = window_create(0, 0);2030 blue_win->surface = surface_create(200, 100, NULL, 0);2031 pixel_t blue_pix = PIXEL(255, 0, 0, 240);2032 for (sysarg_t y = 0; y < 100; ++y) {2033 for (sysarg_t x = 0; x < 200; ++x) {2034 surface_put_pixel(blue_win->surface, x, y, blue_pix);2035 }2036 }2037 list_prepend(&blue_win->link, &window_list);2038 2039 window_t *nameic_win = window_create(0, 0);2040 nameic_win->surface = decode_tga((void *) nameic_tga, nameic_tga_size, 0);2041 list_prepend(&nameic_win->link, &window_list);2042 2043 fibril_mutex_unlock(&window_list_mtx);2044 comp_damage(0, 0, UINT32_MAX, UINT32_MAX);2045 2088 } else { 2046 2089 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); -
uspace/srv/logger/writer.c
r2e80321 r66be0288 40 40 #include <io/log.h> 41 41 #include <io/logctl.h> 42 #include <io/klog.h> 42 43 #include <ns.h> 43 44 #include <async.h> … … 79 80 } 80 81 81 printf("[%s] %s: %s\n",82 KLOG_PRINTF(level, "[%s] %s: %s\n", 82 83 log->full_name, log_level_str(level), 83 84 (const char *) message);
Note:
See TracChangeset
for help on using the changeset viewer.