diff options
-rw-r--r-- | apps/wm.c | 52 | ||||
-rw-r--r-- | kernel/features/event.c | 10 | ||||
-rw-r--r-- | kernel/features/proc.c | 10 |
3 files changed, 42 insertions, 30 deletions
@@ -12,7 +12,8 @@ #include <sys.h> #include <vesa.h> -#define MOUSE_SKIP 2 // => Every move % n != 0 gets skipped +static int MOUSE_SKIP = 0; // => Every move % n != 0 gets skipped +static int window_count; static struct vbe vbe; static struct window direct; // Direct video memory window @@ -34,40 +35,47 @@ static struct window *new_window(struct window *win, int x, int y, u16 width, u1 win->bpp = vbe.bpp; win->pitch = win->width * (win->bpp >> 3); win->fb = malloc(height * win->pitch); + memset(win->fb, 0, height * win->pitch); win->flags = flags; + window_count++; + if (window_count % 2 == 1) + MOUSE_SKIP++; return win; } static struct window *window_at(int x, int y) { - if (windows->head && windows->head->data) { - struct node *iterator = windows->head; - do { - struct window *win = iterator->data; - if (win != &root && x >= win->x && x <= win->x + (int)win->width && - y >= win->y && y <= win->y + (int)win->height) { - return win; - } - } while ((iterator = iterator->next) != NULL); + if (!windows->head || !windows->head->data) + return NULL; + + struct node *iterator = windows->head; + while (iterator != NULL) { + struct window *win = iterator->data; + if (win != &root && x >= win->x && x <= win->x + (int)win->width && y >= win->y && + y <= win->y + (int)win->height) + return win; + iterator = iterator->next; } return NULL; } static void redraw_all() { - if (windows->head && windows->head->data) { - struct node *iterator = windows->head; - do { - struct window *win = iterator->data; - if (win != focused) - gui_win_on_win(&exchange, win, win->x, win->y); - } while ((iterator = iterator->next) != NULL); - - if (focused) - gui_win_on_win(&exchange, focused, focused->x, focused->y); - - memcpy(direct.fb, exchange.fb, exchange.pitch * exchange.height); + if (!windows->head || !windows->head->data) + return; + + struct node *iterator = windows->head; + while (iterator != NULL) { + struct window *win = iterator->data; + if (win != focused) + gui_win_on_win(&exchange, win, win->x, win->y); + iterator = iterator->next; } + + if (focused) + gui_win_on_win(&exchange, focused, focused->x, focused->y); + + memcpy(direct.fb, exchange.fb, exchange.pitch * exchange.height); } static int mouse_skip = 0; diff --git a/kernel/features/event.c b/kernel/features/event.c index 71c0ad9..1aa0cd0 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -34,11 +34,12 @@ void event_unregister(enum message_type id, struct proc *proc) desc.proc = proc; struct node *iterator = event_table[id]->head; - do { + while (iterator != NULL) { struct event_descriptor *desc_comp = iterator->data; if (desc_comp->id == desc.id && desc_comp->proc == desc.proc) list_remove(event_table[id], iterator); - } while ((iterator = iterator->next) != NULL); + iterator = iterator->next; + } } u32 event_trigger(enum message_type id, void *data) @@ -51,9 +52,10 @@ u32 event_trigger(enum message_type id, void *data) } struct node *iterator = event_table[id]->head; - do { + while (iterator != NULL) { proc_send(kernel_proc, ((struct event_descriptor *)iterator->data)->proc, id, data); - } while ((iterator = iterator->next) != NULL); + iterator = iterator->next; + } return 0; } diff --git a/kernel/features/proc.c b/kernel/features/proc.c index aab4fec..3f8dcf1 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -111,10 +111,11 @@ struct proc_message *proc_receive(struct proc *proc) struct proc *proc_from_pid(u32 pid) { struct node *iterator = proc_list->head; - do { + while (iterator != NULL) { if (((struct proc *)iterator->data)->pid == pid) return iterator->data; - } while ((iterator = iterator->next) != NULL); + iterator = iterator->next; + } return NULL; } @@ -124,13 +125,14 @@ void proc_exit(struct proc *proc, int status) int res = 0; struct node *iterator = proc_list->head; - do { + while (iterator != NULL) { if (iterator->data == proc) { res = 1; list_remove(proc_list, iterator); break; } - } while ((iterator = iterator->next) != NULL); + iterator = iterator->next; + } if (memcmp(proc, current->data, sizeof(*proc)) == 0) current = NULL; |