| 71 static void free_node(gpointer data); |
69 static void free_node(gpointer data); |
| 72 static void draw_taskbar(gboolean reposition); |
70 static void draw_taskbar(gboolean reposition); |
| 73 static void bring_on_top(GntWidget *widget); |
71 static void bring_on_top(GntWidget *widget); |
| 74 |
72 |
| 75 static gboolean refresh_screen(); |
73 static gboolean refresh_screen(); |
| |
74 static const GList *list_all_windows(); |
| |
75 |
| |
76 static GntWM wm = |
| |
77 { |
| |
78 NULL, /* new_window */ |
| |
79 NULL, /* close_window */ |
| |
80 NULL, /* key_pressed */ |
| |
81 NULL, /* mouse clicked */ |
| |
82 bring_on_top, /* give_focus */ |
| |
83 NULL, /* uninit */ |
| |
84 list_all_windows, /* window_list */ |
| |
85 }; |
| |
86 |
| |
87 static const GList *list_all_windows() |
| |
88 { |
| |
89 return focus_list; |
| |
90 } |
| 76 |
91 |
| 77 static GList * |
92 static GList * |
| 78 g_list_bring_to_front(GList *list, gpointer data) |
93 g_list_bring_to_front(GList *list, gpointer data) |
| 79 { |
94 { |
| 80 list = g_list_remove(list, data); |
95 list = g_list_remove(list, data); |
| 137 { |
152 { |
| 138 GntNode *node = g_hash_table_lookup(nodes, widget); |
153 GntNode *node = g_hash_table_lookup(nodes, widget); |
| 139 |
154 |
| 140 if (!node) |
155 if (!node) |
| 141 return; |
156 return; |
| |
157 |
| |
158 if (ordered->data != widget) { |
| |
159 GntWidget *w = ordered->data; |
| |
160 ordered = g_list_bring_to_front(ordered, widget); |
| |
161 gnt_widget_set_focus(w, FALSE); |
| |
162 } |
| 142 |
163 |
| 143 gnt_widget_set_focus(widget, TRUE); |
164 gnt_widget_set_focus(widget, TRUE); |
| 144 gnt_widget_draw(widget); |
165 gnt_widget_draw(widget); |
| 145 top_panel(node->panel); |
166 top_panel(node->panel); |
| 146 |
167 |
| 245 else if (pos >= 0) |
266 else if (pos >= 0) |
| 246 wid = g_list_nth_data(focus_list, pos); |
267 wid = g_list_nth_data(focus_list, pos); |
| 247 |
268 |
| 248 ordered = g_list_bring_to_front(ordered, wid); |
269 ordered = g_list_bring_to_front(ordered, wid); |
| 249 |
270 |
| 250 bring_on_top(ordered->data); |
271 wm.give_focus(ordered->data); |
| 251 |
272 |
| 252 if (w != wid) |
273 if (w != wid) |
| 253 { |
274 { |
| 254 gnt_widget_set_focus(w, FALSE); |
275 gnt_widget_set_focus(w, FALSE); |
| 255 } |
276 } |
| 267 w = ordered->data; |
288 w = ordered->data; |
| 268 |
289 |
| 269 if ((l = g_list_nth(focus_list, n)) != NULL) |
290 if ((l = g_list_nth(focus_list, n)) != NULL) |
| 270 { |
291 { |
| 271 ordered = g_list_bring_to_front(ordered, l->data); |
292 ordered = g_list_bring_to_front(ordered, l->data); |
| 272 bring_on_top(ordered->data); |
293 wm.give_focus(ordered->data); |
| 273 } |
294 } |
| 274 |
295 |
| 275 if (l && w != l->data) |
296 if (l && w != l->data) |
| 276 { |
297 { |
| 277 gnt_widget_set_focus(w, FALSE); |
298 gnt_widget_set_focus(w, FALSE); |
| 539 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) { |
561 if (x >= wid->priv.x && x < wid->priv.x + wid->priv.width) { |
| 540 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) { |
562 if (y >= wid->priv.y && y < wid->priv.y + wid->priv.height) { |
| 541 if (iter != ordered) { |
563 if (iter != ordered) { |
| 542 GntWidget *w = ordered->data; |
564 GntWidget *w = ordered->data; |
| 543 ordered = g_list_bring_to_front(ordered, iter->data); |
565 ordered = g_list_bring_to_front(ordered, iter->data); |
| 544 bring_on_top(ordered->data); |
566 wm.give_focus(ordered->data); |
| 545 gnt_widget_set_focus(w, FALSE); |
567 gnt_widget_set_focus(w, FALSE); |
| 546 } |
568 } |
| 547 if (y == wid->priv.y) { |
569 if (y == wid->priv.y) { |
| 548 offset = x - wid->priv.x; |
570 offset = x - wid->priv.x; |
| 549 remember = wid; |
571 remember = wid; |
| 551 } |
573 } |
| 552 break; |
574 break; |
| 553 } |
575 } |
| 554 } |
576 } |
| 555 } |
577 } |
| |
578 event = GNT_LEFT_MOUSE_DOWN; |
| 556 } else if (strncmp(buffer, "[M\"", 3) == 0) { |
579 } else if (strncmp(buffer, "[M\"", 3) == 0) { |
| 557 /* right button down */ |
580 /* right button down */ |
| |
581 event = GNT_RIGHT_MOUSE_DOWN; |
| 558 } else if (strncmp(buffer, "[M!", 3) == 0) { |
582 } else if (strncmp(buffer, "[M!", 3) == 0) { |
| 559 /* middle button down */ |
583 /* middle button down */ |
| |
584 event = GNT_MIDDLE_MOUSE_DOWN; |
| 560 } else if (strncmp(buffer, "[M`", 3) == 0) { |
585 } else if (strncmp(buffer, "[M`", 3) == 0) { |
| 561 /* wheel up*/ |
586 /* wheel up*/ |
| |
587 event = GNT_MOUSE_SCROLL_UP; |
| 562 } else if (strncmp(buffer, "[Ma", 3) == 0) { |
588 } else if (strncmp(buffer, "[Ma", 3) == 0) { |
| 563 /* wheel down */ |
589 /* wheel down */ |
| |
590 event = GNT_MOUSE_SCROLL_DOWN; |
| 564 } else if (strncmp(buffer, "[M#", 3) == 0) { |
591 } else if (strncmp(buffer, "[M#", 3) == 0) { |
| 565 /* button up */ |
592 /* button up */ |
| 566 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) { |
593 if (button == MOUSE_NONE && y == getmaxy(stdscr) - 1) { |
| 567 int n = g_list_length(focus_list); |
594 int n = g_list_length(focus_list); |
| 568 if (n) { |
595 if (n) { |
| 577 refresh_node(remember, NULL, NULL); |
604 refresh_node(remember, NULL, NULL); |
| 578 } |
605 } |
| 579 button = MOUSE_NONE; |
606 button = MOUSE_NONE; |
| 580 remember = NULL; |
607 remember = NULL; |
| 581 offset = 0; |
608 offset = 0; |
| |
609 event = GNT_MOUSE_UP; |
| 582 } else |
610 } else |
| 583 return FALSE; |
611 return FALSE; |
| |
612 |
| |
613 gnt_widget_clicked(ordered->data, event, x, y); |
| 584 return FALSE; /* XXX: this should be TRUE */ |
614 return FALSE; /* XXX: this should be TRUE */ |
| 585 } |
615 } |
| 586 |
616 |
| 587 static gboolean |
617 static gboolean |
| 588 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
618 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null) |
| 589 { |
619 { |
| 590 char buffer[256]; |
620 char keys[256]; |
| 591 gboolean ret = FALSE; |
621 gboolean ret = FALSE; |
| 592 static GntKeyPressMode mode = GNT_KP_MODE_NORMAL; |
622 static GntKeyPressMode mode = GNT_KP_MODE_NORMAL; |
| 593 |
623 const char *buffer; |
| 594 int rd = read(STDIN_FILENO, buffer, sizeof(buffer) - 1); |
624 |
| |
625 int rd = read(STDIN_FILENO, keys, sizeof(keys) - 1); |
| 595 if (rd < 0) |
626 if (rd < 0) |
| 596 { |
627 { |
| 597 endwin(); |
628 endwin(); |
| 598 printf("ERROR!\n"); |
629 printf("ERROR!\n"); |
| 599 exit(1); |
630 exit(1); |
| 603 endwin(); |
634 endwin(); |
| 604 printf("EOF\n"); |
635 printf("EOF\n"); |
| 605 exit(1); |
636 exit(1); |
| 606 } |
637 } |
| 607 |
638 |
| 608 buffer[rd] = 0; |
639 keys[rd] = 0; |
| 609 |
640 |
| 610 if (buffer[0] == 27 && buffer[1] == 'd' && buffer[2] == 0) |
641 if (keys[0] == 27 && keys[1] == 'd' && keys[2] == 0) |
| 611 { |
642 { |
| 612 /* This dumps the screen contents in an html file */ |
643 /* This dumps the screen contents in an html file */ |
| 613 dump_screen(); |
644 dump_screen(); |
| 614 } |
645 } |
| 615 |
646 |
| 616 gnt_keys_refine(buffer); |
647 gnt_keys_refine(keys); |
| 617 |
648 |
| 618 if (mouse_enabled && detect_mouse_action(buffer)) |
649 if (mouse_enabled && detect_mouse_action(keys)) |
| 619 return TRUE; |
650 return TRUE; |
| |
651 |
| |
652 if (wm.key_pressed) { |
| |
653 buffer = wm.key_pressed(keys); |
| |
654 if (buffer == NULL) |
| |
655 return TRUE; |
| |
656 } else |
| |
657 buffer = keys; |
| 620 |
658 |
| 621 if (mode == GNT_KP_MODE_NORMAL) |
659 if (mode == GNT_KP_MODE_NORMAL) |
| 622 { |
660 { |
| 623 if (ordered) |
661 if (ordered) |
| 624 { |
662 { |