comparison finch/libgnt/gntwm.c @ 18069:08776fc5c06f

propagate from branch 'im.pidgin.finch.workspaces' (head 76cfc9565a5cdde8d2e1f2efc3282b309a55a110) to branch 'im.pidgin.pidgin.2.1.0' (head 7369e1bc964aa300a73670872d34129642b3ec49)
author Richard Nelson <wabz@pidgin.im>
date Fri, 08 Jun 2007 10:21:50 +0000
parents 1cedd520cd18 4d4a396a478c
children 2b757aadddc9
comparison
equal deleted inserted replaced
18068:0b3d6ea61760 18069:08776fc5c06f
26 #endif 26 #endif
27 27
28 #include "config.h" 28 #include "config.h"
29 29
30 #include <ctype.h> 30 #include <ctype.h>
31 #include <glib/gprintf.h>
32 #include <gmodule.h>
31 #include <stdlib.h> 33 #include <stdlib.h>
32 #include <string.h> 34 #include <string.h>
33 #include <time.h> 35 #include <time.h>
34 36
35 #include "gntwm.h" 37 #include "gntwm.h"
67 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); 69 static void gnt_wm_win_resized(GntWM *wm, GntNode *node);
68 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); 70 static void gnt_wm_win_moved(GntWM *wm, GntNode *node);
69 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); 71 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget);
70 static void update_window_in_list(GntWM *wm, GntWidget *wid); 72 static void update_window_in_list(GntWM *wm, GntWidget *wid);
71 static void shift_window(GntWM *wm, GntWidget *widget, int dir); 73 static void shift_window(GntWM *wm, GntWidget *widget, int dir);
74 static gboolean workspace_next(GntBindable *wm, GList *n);
75 static gboolean workspace_prev(GntBindable *wm, GList *n);
72 76
73 #ifndef NO_WIDECHAR 77 #ifndef NO_WIDECHAR
74 static int widestringwidth(wchar_t *wide); 78 static int widestringwidth(wchar_t *wide);
75 #endif 79 #endif
76 80
77 static gboolean write_already(gpointer data); 81 static gboolean write_already(gpointer data);
78 static int write_timeout; 82 static int write_timeout;
79 static time_t last_active_time; 83 static time_t last_active_time;
80 static gboolean idle_update; 84 static gboolean idle_update;
85 static GList *act = NULL; /* list of WS with unseen activitiy */
81 86
82 static GList * 87 static GList *
83 g_list_bring_to_front(GList *list, gpointer data) 88 g_list_bring_to_front(GList *list, gpointer data)
84 { 89 {
85 list = g_list_remove(list, data); 90 list = g_list_remove(list, data);
94 hide_panel(node->panel); 99 hide_panel(node->panel);
95 del_panel(node->panel); 100 del_panel(node->panel);
96 g_free(node); 101 g_free(node);
97 } 102 }
98 103
99 static void 104 void
100 draw_taskbar(GntWM *wm, gboolean reposition) 105 gnt_wm_copy_win(GntWidget *widget, GntNode *node)
101 {
102 static WINDOW *taskbar = NULL;
103 GList *iter;
104 int n, width = 0;
105 int i;
106
107 if (taskbar == NULL) {
108 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0);
109 } else if (reposition) {
110 int Y_MAX = getmaxy(stdscr) - 1;
111 mvwin(taskbar, Y_MAX, 0);
112 }
113
114 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL));
115 werase(taskbar);
116
117 n = g_list_length(wm->list);
118 if (n)
119 width = getmaxx(stdscr) / n;
120
121 for (i = 0, iter = wm->list; iter; iter = iter->next, i++)
122 {
123 GntWidget *w = iter->data;
124 int color;
125 const char *title;
126
127 if (w == wm->ordered->data) {
128 /* This is the current window in focus */
129 color = GNT_COLOR_TITLE;
130 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) {
131 /* This is a window with the URGENT hint set */
132 color = GNT_COLOR_URGENT;
133 } else {
134 color = GNT_COLOR_NORMAL;
135 }
136 wbkgdset(taskbar, '\0' | COLOR_PAIR(color));
137 if (iter->next)
138 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width);
139 else
140 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), getmaxx(stdscr) - width * i);
141 title = GNT_BOX(w)->title;
142 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>");
143 if (i)
144 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL));
145
146 update_window_in_list(wm, w);
147 }
148
149 wrefresh(taskbar);
150 }
151
152 static void
153 copy_win(GntWidget *widget, GntNode *node)
154 { 106 {
155 WINDOW *src, *dst; 107 WINDOW *src, *dst;
156 int shadow; 108 int shadow;
157 if (!node) 109 if (!node)
158 return; 110 return;
219 } 171 }
220 } 172 }
221 #endif 173 #endif
222 } 174 }
223 175
176 static void
177 update_act_msg()
178 {
179 GntWidget *label;
180 GList *iter;
181 static GntWidget *message = NULL;
182 GString *text = g_string_new("act: ");
183 if (message)
184 gnt_widget_destroy(message);
185 if (g_list_length(act) == 0)
186 return;
187 for (iter = act; iter; iter = iter->next) {
188 GntWS *ws = iter->data;
189 g_string_sprintfa(text, "%s, ", gnt_ws_get_name(ws));
190 }
191 g_string_erase(text, text->len - 2, 2);
192 message = gnt_vbox_new(FALSE);
193 label = gnt_label_new_with_format(text->str, GNT_TEXT_FLAG_BOLD | GNT_TEXT_FLAG_HIGHLIGHT);
194 GNT_WIDGET_UNSET_FLAGS(GNT_BOX(message), GNT_WIDGET_CAN_TAKE_FOCUS);
195 GNT_WIDGET_SET_FLAGS(GNT_BOX(message), GNT_WIDGET_TRANSIENT);
196 gnt_box_add_widget(GNT_BOX(message), label);
197 gnt_widget_set_name(message, "wm-message");
198 gnt_widget_set_position(message, 0, 0);
199 gnt_widget_draw(message);
200 g_string_free(text, TRUE);
201 }
202
224 static gboolean 203 static gboolean
225 update_screen(GntWM *wm) 204 update_screen(GntWM *wm)
226 { 205 {
227 if (wm->menu) { 206 if (wm->menu) {
228 GntMenu *top = wm->menu; 207 GntMenu *top = wm->menu;
349 328
350 static void 329 static void
351 gnt_wm_init(GTypeInstance *instance, gpointer class) 330 gnt_wm_init(GTypeInstance *instance, gpointer class)
352 { 331 {
353 GntWM *wm = GNT_WM(instance); 332 GntWM *wm = GNT_WM(instance);
354 wm->list = NULL; 333 wm->workspaces = NULL;
355 wm->ordered = NULL; 334 wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
335 wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
336 gnt_style_read_workspaces(wm);
337 if (wm->workspaces == NULL) {
338 wm->cws = g_object_new(GNT_TYPE_WS, NULL);
339 gnt_ws_set_name(wm->cws, "default");
340 gnt_wm_add_workspace(wm, wm->cws);
341 } else {
342 wm->cws = wm->workspaces->data;
343 }
356 wm->event_stack = FALSE; 344 wm->event_stack = FALSE;
345 wm->tagged = NULL;
357 wm->windows = NULL; 346 wm->windows = NULL;
358 wm->actions = NULL; 347 wm->actions = NULL;
359 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); 348 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node);
360 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 349 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
361 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) 350 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE))
362 read_window_positions(wm); 351 read_window_positions(wm);
363 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); 352 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL);
364 time(&last_active_time); 353 time(&last_active_time);
354 gnt_wm_switch_workspace(wm, 0);
365 } 355 }
366 356
367 static void 357 static void
368 switch_window(GntWM *wm, int direction) 358 switch_window(GntWM *wm, int direction)
369 { 359 {
371 int pos; 361 int pos;
372 362
373 if (wm->_list.window || wm->menu) 363 if (wm->_list.window || wm->menu)
374 return; 364 return;
375 365
376 if (!wm->ordered || !wm->ordered->next) 366 if (!wm->cws->ordered || !wm->cws->ordered->next)
377 return; 367 return;
378 368
379 w = wm->ordered->data; 369 w = wm->cws->ordered->data;
380 pos = g_list_index(wm->list, w); 370 pos = g_list_index(wm->cws->list, w);
381 pos += direction; 371 pos += direction;
382 372
383 if (pos < 0) 373 if (pos < 0)
384 wid = g_list_last(wm->list)->data; 374 wid = g_list_last(wm->cws->list)->data;
385 else if (pos >= g_list_length(wm->list)) 375 else if (pos >= g_list_length(wm->cws->list))
386 wid = wm->list->data; 376 wid = wm->cws->list->data;
387 else if (pos >= 0) 377 else if (pos >= 0)
388 wid = g_list_nth_data(wm->list, pos); 378 wid = g_list_nth_data(wm->cws->list, pos);
389 379
390 wm->ordered = g_list_bring_to_front(wm->ordered, wid); 380 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, wid);
391 381
392 gnt_wm_raise_window(wm, wm->ordered->data); 382 gnt_wm_raise_window(wm, wm->cws->ordered->data);
393 383
394 if (w != wid) { 384 if (w != wid) {
395 gnt_widget_set_focus(w, FALSE); 385 gnt_widget_set_focus(w, FALSE);
396 } 386 }
397 } 387 }
418 GntWM *wm = GNT_WM(bind); 408 GntWM *wm = GNT_WM(bind);
419 GntWidget *w = NULL; 409 GntWidget *w = NULL;
420 GList *l; 410 GList *l;
421 int n; 411 int n;
422 412
423 if (!wm->ordered) 413 if (!wm->cws->ordered)
424 return TRUE; 414 return TRUE;
425 415
426 if (list) 416 if (list)
427 n = GPOINTER_TO_INT(list->data); 417 n = GPOINTER_TO_INT(list->data);
428 else 418 else
429 n = 0; 419 n = 0;
430 420
431 w = wm->ordered->data; 421 w = wm->cws->ordered->data;
432 422
433 if ((l = g_list_nth(wm->list, n)) != NULL) 423 if ((l = g_list_nth(wm->cws->list, n)) != NULL)
434 { 424 {
435 gnt_wm_raise_window(wm, l->data); 425 gnt_wm_raise_window(wm, l->data);
436 } 426 }
437 427
438 if (l && w != l->data) 428 if (l && w != l->data)
447 { 437 {
448 GntWM *wm = GNT_WM(bindable); 438 GntWM *wm = GNT_WM(bindable);
449 GntWidget *window; 439 GntWidget *window;
450 GntNode *node; 440 GntNode *node;
451 441
452 if (!wm->ordered) 442 if (!wm->cws->ordered)
453 return TRUE; 443 return TRUE;
454 444
455 window = wm->ordered->data; 445 window = wm->cws->ordered->data;
456 node = g_hash_table_lookup(wm->nodes, window); 446 node = g_hash_table_lookup(wm->nodes, window);
457 if (!node) 447 if (!node)
458 return TRUE; 448 return TRUE;
459 449
460 if (node->scroll) { 450 if (node->scroll) {
461 node->scroll--; 451 node->scroll--;
462 copy_win(window, node); 452 gnt_wm_copy_win(window, node);
463 update_screen(wm); 453 update_screen(wm);
464 } 454 }
465 return TRUE; 455 return TRUE;
466 } 456 }
467 457
471 GntWM *wm = GNT_WM(bindable); 461 GntWM *wm = GNT_WM(bindable);
472 GntWidget *window; 462 GntWidget *window;
473 GntNode *node; 463 GntNode *node;
474 int w, h; 464 int w, h;
475 465
476 if (!wm->ordered) 466 if (!wm->cws->ordered)
477 return TRUE; 467 return TRUE;
478 468
479 window = wm->ordered->data; 469 window = wm->cws->ordered->data;
480 node = g_hash_table_lookup(wm->nodes, window); 470 node = g_hash_table_lookup(wm->nodes, window);
481 if (!node) 471 if (!node)
482 return TRUE; 472 return TRUE;
483 473
484 gnt_widget_get_size(window, &w, &h); 474 gnt_widget_get_size(window, &w, &h);
485 if (h - node->scroll > getmaxy(node->window)) { 475 if (h - node->scroll > getmaxy(node->window)) {
486 node->scroll++; 476 node->scroll++;
487 copy_win(window, node); 477 gnt_wm_copy_win(window, node);
488 update_screen(wm); 478 update_screen(wm);
489 } 479 }
490 return TRUE; 480 return TRUE;
491 } 481 }
492 482
496 GntWM *wm = GNT_WM(bindable); 486 GntWM *wm = GNT_WM(bindable);
497 487
498 if (wm->_list.window) 488 if (wm->_list.window)
499 return TRUE; 489 return TRUE;
500 490
501 if (wm->ordered) { 491 if (wm->cws->ordered) {
502 gnt_widget_destroy(wm->ordered->data); 492 gnt_widget_destroy(wm->cws->ordered->data);
503 } 493 }
504 494
505 return TRUE; 495 return TRUE;
506 } 496 }
507 497
510 { 500 {
511 GntWM *wm = GNT_WM(bindable); 501 GntWM *wm = GNT_WM(bindable);
512 GntWidget *widget, *tree, *win, *active; 502 GntWidget *widget, *tree, *win, *active;
513 char *title; 503 char *title;
514 504
515 if (!wm->ordered) 505 if (!wm->cws->ordered)
516 return TRUE; 506 return TRUE;
517 507
518 widget = wm->ordered->data; 508 widget = wm->cws->ordered->data;
519 if (!GNT_IS_BOX(widget)) 509 if (!GNT_IS_BOX(widget))
520 return TRUE; 510 return TRUE;
521 active = GNT_BOX(widget)->active; 511 active = GNT_BOX(widget)->active;
522 512
523 tree = gnt_widget_bindings_view(active); 513 tree = gnt_widget_bindings_view(active);
560 } 550 }
561 551
562 static void 552 static void
563 window_list_activate(GntTree *tree, GntWM *wm) 553 window_list_activate(GntTree *tree, GntWM *wm)
564 { 554 {
565 GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree)); 555 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree));
566 556
567 if (!wm->ordered || !widget) 557 gnt_widget_destroy(wm->_list.window);
558
559 if (!sel)
568 return; 560 return;
569 561
570 gnt_widget_destroy(wm->_list.window); 562 if (GNT_IS_WS(sel)) {
571 gnt_wm_raise_window(wm, widget); 563 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, sel));
572 } 564 } else {
573 565 GntNode *node = g_hash_table_lookup(wm->nodes, sel);
574 static void 566 if (node && node->ws != wm->cws)
575 populate_window_list(GntWM *wm) 567 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, node->ws));
568 gnt_wm_raise_window(wm, GNT_WIDGET(sel));
569 }
570 }
571
572 static void
573 populate_window_list(GntWM *wm, gboolean workspace)
576 { 574 {
577 GList *iter; 575 GList *iter;
578 GntTree *tree = GNT_TREE(wm->windows->tree); 576 GntTree *tree = GNT_TREE(wm->windows->tree);
579 for (iter = wm->list; iter; iter = iter->next) { 577 if (!workspace) {
580 GntBox *box = GNT_BOX(iter->data); 578 for (iter = wm->cws->list; iter; iter = iter->next) {
581 579 GntBox *box = GNT_BOX(iter->data);
582 gnt_tree_add_row_last(tree, box, 580
583 gnt_tree_create_row(tree, box->title), NULL); 581 gnt_tree_add_row_last(tree, box,
584 update_window_in_list(wm, GNT_WIDGET(box)); 582 gnt_tree_create_row(tree, box->title), NULL);
583 update_window_in_list(wm, GNT_WIDGET(box));
584 }
585 } else {
586 GList *ws = wm->workspaces;
587 for (; ws; ws = ws->next) {
588 gnt_tree_add_row_last(tree, ws->data,
589 gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL);
590 for (iter = GNT_WS(ws->data)->list; iter; iter = iter->next) {
591 GntBox *box = GNT_BOX(iter->data);
592
593 gnt_tree_add_row_last(tree, box,
594 gnt_tree_create_row(tree, box->title), ws->data);
595 update_window_in_list(wm, GNT_WIDGET(box));
596 }
597 }
585 } 598 }
586 } 599 }
587 600
588 static gboolean 601 static gboolean
589 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) 602 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm)
590 { 603 {
591 if (text[1] == 0 && wm->ordered) { 604 if (text[1] == 0 && wm->cws->ordered) {
592 GntWidget *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); 605 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget));
593 switch (text[0]) { 606 switch (text[0]) {
594 case '-': 607 case '-':
595 case ',': 608 case ',':
596 shift_window(wm, sel, -1); 609 if (GNT_IS_WS(sel)) {
610 /* reorder the workspace. */
611 } else
612 shift_window(wm, GNT_WIDGET(sel), -1);
597 break; 613 break;
598 case '=': 614 case '=':
599 case '.': 615 case '.':
600 shift_window(wm, sel, 1); 616 if (GNT_IS_WS(sel)) {
617 /* reorder the workspace. */
618 } else
619 shift_window(wm, GNT_WIDGET(sel), 1);
601 break; 620 break;
602 default: 621 default:
603 return FALSE; 622 return FALSE;
604 } 623 }
605 gnt_tree_remove_all(GNT_TREE(widget)); 624 gnt_tree_remove_all(GNT_TREE(widget));
606 populate_window_list(wm); 625 populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace")));
607 gnt_tree_set_selected(GNT_TREE(widget), sel); 626 gnt_tree_set_selected(GNT_TREE(widget), sel);
608 return TRUE; 627 return TRUE;
609 } 628 }
610 return FALSE; 629 return FALSE;
611 } 630 }
612 631
613 static gboolean 632 static void
614 window_list(GntBindable *bindable, GList *null) 633 list_of_windows(GntWM *wm, gboolean workspace)
615 { 634 {
616 GntWM *wm = GNT_WM(bindable);
617 GntWidget *tree, *win; 635 GntWidget *tree, *win;
618
619 if (wm->_list.window || wm->menu)
620 return TRUE;
621
622 if (!wm->ordered)
623 return TRUE;
624
625 setup__list(wm); 636 setup__list(wm);
626 wm->windows = &wm->_list; 637 wm->windows = &wm->_list;
627 638
628 win = wm->windows->window; 639 win = wm->windows->window;
629 tree = wm->windows->tree; 640 tree = wm->windows->tree;
630 641
631 gnt_box_set_title(GNT_BOX(win), "Window List"); 642 gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List");
632 643
633 populate_window_list(wm); 644 populate_window_list(wm, workspace);
634 645
635 gnt_tree_set_selected(GNT_TREE(tree), wm->ordered->data); 646 if (wm->cws->ordered)
647 gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data);
648 else if (workspace)
649 gnt_tree_set_selected(GNT_TREE(tree), wm->cws);
650
636 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); 651 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm);
637 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); 652 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm);
653 g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace));
638 654
639 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); 655 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3);
640 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); 656 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2);
641 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); 657 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4);
642 658
643 gnt_widget_show(win); 659 gnt_widget_show(win);
660 }
661
662 static gboolean
663 window_list(GntBindable *bindable, GList *null)
664 {
665 GntWM *wm = GNT_WM(bindable);
666
667 if (wm->_list.window || wm->menu)
668 return TRUE;
669
670 if (!wm->cws->ordered)
671 return TRUE;
672
673 list_of_windows(wm, FALSE);
674
644 return TRUE; 675 return TRUE;
645 } 676 }
646 677
647 static gboolean 678 static gboolean
648 dump_screen(GntBindable *bindable, GList *null) 679 dump_screen(GntBindable *bindable, GList *null)
778 } 809 }
779 810
780 static void 811 static void
781 shift_window(GntWM *wm, GntWidget *widget, int dir) 812 shift_window(GntWM *wm, GntWidget *widget, int dir)
782 { 813 {
783 GList *all = wm->list; 814 GList *all = wm->cws->list;
784 GList *list = g_list_find(all, widget); 815 GList *list = g_list_find(all, widget);
785 int length, pos; 816 int length, pos;
786 if (!list) 817 if (!list)
787 return; 818 return;
788 819
798 else if (pos > length) 829 else if (pos > length)
799 pos = 0; 830 pos = 0;
800 831
801 all = g_list_insert(all, widget, pos); 832 all = g_list_insert(all, widget, pos);
802 all = g_list_delete_link(all, list); 833 all = g_list_delete_link(all, list);
803 wm->list = all; 834 wm->cws->list = all;
804 draw_taskbar(wm, FALSE); 835 gnt_ws_draw_taskbar(wm->cws, FALSE);
805 } 836 }
806 837
807 static gboolean 838 static gboolean
808 shift_left(GntBindable *bindable, GList *null) 839 shift_left(GntBindable *bindable, GList *null)
809 { 840 {
810 GntWM *wm = GNT_WM(bindable); 841 GntWM *wm = GNT_WM(bindable);
811 if (wm->_list.window) 842 if (wm->_list.window)
812 return TRUE; 843 return TRUE;
813 844
814 shift_window(wm, wm->ordered->data, -1); 845 shift_window(wm, wm->cws->ordered->data, -1);
815 return TRUE; 846 return TRUE;
816 } 847 }
817 848
818 static gboolean 849 static gboolean
819 shift_right(GntBindable *bindable, GList *null) 850 shift_right(GntBindable *bindable, GList *null)
820 { 851 {
821 GntWM *wm = GNT_WM(bindable); 852 GntWM *wm = GNT_WM(bindable);
822 if (wm->_list.window) 853 if (wm->_list.window)
823 return TRUE; 854 return TRUE;
824 855
825 shift_window(wm, wm->ordered->data, 1); 856 shift_window(wm, wm->cws->ordered->data, 1);
826 return TRUE; 857 return TRUE;
827 } 858 }
828 859
829 static void 860 static void
830 action_list_activate(GntTree *tree, GntWM *wm) 861 action_list_activate(GntTree *tree, GntWM *wm)
944 975
945 /* the left and right */ 976 /* the left and right */
946 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); 977 for (i = 0; i < h; i += reverse_char(d, i, 0, set));
947 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); 978 for (i = 0; i < h; i += reverse_char(d, i, w-1, set));
948 979
949 copy_win(win, g_hash_table_lookup(wm->nodes, win)); 980 gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win));
950 update_screen(wm); 981 update_screen(wm);
951 } 982 }
952 983
953 static gboolean 984 static gboolean
954 start_move(GntBindable *bindable, GList *null) 985 start_move(GntBindable *bindable, GList *null)
955 { 986 {
956 GntWM *wm = GNT_WM(bindable); 987 GntWM *wm = GNT_WM(bindable);
957 if (wm->_list.window || wm->menu) 988 if (wm->_list.window || wm->menu)
958 return TRUE; 989 return TRUE;
959 if (!wm->ordered) 990 if (!wm->cws->ordered)
960 return TRUE; 991 return TRUE;
961 992
962 wm->mode = GNT_KP_MODE_MOVE; 993 wm->mode = GNT_KP_MODE_MOVE;
963 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE, wm); 994 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm);
964 995
965 return TRUE; 996 return TRUE;
966 } 997 }
967 998
968 static gboolean 999 static gboolean
969 start_resize(GntBindable *bindable, GList *null) 1000 start_resize(GntBindable *bindable, GList *null)
970 { 1001 {
971 GntWM *wm = GNT_WM(bindable); 1002 GntWM *wm = GNT_WM(bindable);
972 if (wm->_list.window || wm->menu) 1003 if (wm->_list.window || wm->menu)
973 return TRUE; 1004 return TRUE;
974 if (!wm->ordered) 1005 if (!wm->cws->ordered)
975 return TRUE; 1006 return TRUE;
976 1007
977 wm->mode = GNT_KP_MODE_RESIZE; 1008 wm->mode = GNT_KP_MODE_RESIZE;
978 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE, wm); 1009 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm);
979 1010
980 return TRUE; 1011 return TRUE;
981 } 1012 }
982 1013
983 static gboolean 1014 static gboolean
1000 refresh_screen(GntBindable *bindable, GList *null) 1031 refresh_screen(GntBindable *bindable, GList *null)
1001 { 1032 {
1002 GntWM *wm = GNT_WM(bindable); 1033 GntWM *wm = GNT_WM(bindable);
1003 1034
1004 endwin(); 1035 endwin();
1036 refresh();
1037 curs_set(0); /* endwin resets the cursor to normal */
1005 1038
1006 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); 1039 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL);
1007 update_screen(wm); 1040 update_screen(wm);
1008 draw_taskbar(wm, TRUE); 1041 gnt_ws_draw_taskbar(wm->cws, TRUE);
1009 curs_set(0); /* endwin resets the cursor to normal */
1010 1042
1011 return FALSE; 1043 return FALSE;
1012 } 1044 }
1013 1045
1014 static gboolean 1046 static gboolean
1032 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); 1064 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text));
1033 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); 1065 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" "));
1034 gnt_widget_set_position(clip, 0, 0); 1066 gnt_widget_set_position(clip, 0, 0);
1035 gnt_widget_draw(clip); 1067 gnt_widget_draw(clip);
1036 g_free(text); 1068 g_free(text);
1069 return TRUE;
1070 }
1071
1072 static void remove_tag(gpointer wid, gpointer wim)
1073 {
1074 GntWM *wm = GNT_WM(wim);
1075 GntWidget *w = GNT_WIDGET(wid);
1076 wm->tagged = g_list_remove(wm->tagged, w);
1077 mvwhline(w->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), 3);
1078 gnt_widget_draw(w);
1079 }
1080
1081 static gboolean
1082 tag_widget(GntBindable *b, GList *params)
1083 {
1084 GntWM *wm = GNT_WM(b);
1085 GntWidget *widget;
1086
1087 if (!wm->cws->ordered)
1088 return FALSE;
1089 widget = wm->cws->ordered->data;
1090
1091 if (g_list_find(wm->tagged, widget)) {
1092 remove_tag(widget, wm);
1093 return TRUE;
1094 }
1095
1096 wm->tagged = g_list_prepend(wm->tagged, widget);
1097 wbkgdset(widget->window, ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT));
1098 mvwprintw(widget->window, 0, 1, "[T]");
1099 gnt_widget_draw(widget);
1100 return TRUE;
1101 }
1102
1103 static void
1104 widget_move_ws(gpointer wid, gpointer w)
1105 {
1106 GntWM *wm = GNT_WM(w);
1107 gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid));
1108 }
1109
1110 static gboolean
1111 place_tagged(GntBindable *b, GList *params)
1112 {
1113 GntWM *wm = GNT_WM(b);
1114 g_list_foreach(wm->tagged, widget_move_ws, wm);
1115 g_list_foreach(wm->tagged, remove_tag, wm);
1116 g_list_free(wm->tagged);
1117 wm->tagged = NULL;
1118 return TRUE;
1119 }
1120
1121 static gboolean
1122 workspace_list(GntBindable *b, GList *params)
1123 {
1124 GntWM *wm = GNT_WM(b);
1125
1126 if (wm->_list.window || wm->menu)
1127 return TRUE;
1128
1129 list_of_windows(wm, TRUE);
1130
1037 return TRUE; 1131 return TRUE;
1038 } 1132 }
1039 1133
1040 static void 1134 static void
1041 gnt_wm_class_init(GntWMClass *klass) 1135 gnt_wm_class_init(GntWMClass *klass)
1169 "\033" GNT_KEY_CTRL_J, NULL); 1263 "\033" GNT_KEY_CTRL_J, NULL);
1170 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, 1264 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up,
1171 "\033" GNT_KEY_CTRL_K, NULL); 1265 "\033" GNT_KEY_CTRL_K, NULL);
1172 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, 1266 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget,
1173 "\033" "/", NULL); 1267 "\033" "/", NULL);
1268 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-next", workspace_next,
1269 "\033" ">", NULL);
1270 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-prev", workspace_prev,
1271 "\033" "<", NULL);
1272 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-tag", tag_widget,
1273 "\033" "t", NULL);
1274 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "place-tagged", place_tagged,
1275 "\033" "T", NULL);
1276 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list,
1277 "\033" "s", NULL);
1174 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", 1278 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard",
1175 toggle_clipboard, "\033" "C", NULL); 1279 toggle_clipboard, "\033" "C", NULL);
1176 1280
1177 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); 1281 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));
1178 1282
1213 &info, 0); 1317 &info, 0);
1214 } 1318 }
1215 1319
1216 return type; 1320 return type;
1217 } 1321 }
1322 void
1323 gnt_wm_add_workspace(GntWM *wm, GntWS *ws)
1324 {
1325 wm->workspaces = g_list_append(wm->workspaces, ws);
1326 }
1327
1328 gboolean
1329 gnt_wm_switch_workspace(GntWM *wm, gint n)
1330 {
1331 GntWS *s = g_list_nth_data(wm->workspaces, n);
1332 if (!s)
1333 return FALSE;
1334
1335 if (wm->_list.window) {
1336 gnt_widget_destroy(wm->_list.window);
1337 }
1338 gnt_ws_hide(wm->cws, wm->nodes);
1339 wm->cws = s;
1340 gnt_ws_show(wm->cws, wm->nodes);
1341
1342 gnt_ws_draw_taskbar(wm->cws, TRUE);
1343 update_screen(wm);
1344 if (wm->cws->ordered) {
1345 gnt_widget_set_focus(wm->cws->ordered->data, TRUE);
1346 gnt_wm_raise_window(wm, wm->cws->ordered->data);
1347 }
1348
1349 if (act && g_list_find(act, wm->cws)) {
1350 act = g_list_remove(act, wm->cws);
1351 update_act_msg();
1352 }
1353 return TRUE;
1354 }
1355
1356 gboolean
1357 gnt_wm_switch_workspace_prev(GntWM *wm)
1358 {
1359 int n = g_list_index(wm->workspaces, wm->cws);
1360 return gnt_wm_switch_workspace(wm, --n);
1361 }
1362
1363 gboolean
1364 gnt_wm_switch_workspace_next(GntWM *wm)
1365 {
1366 int n = g_list_index(wm->workspaces, wm->cws);
1367 return gnt_wm_switch_workspace(wm, ++n);
1368 }
1369
1370 static gboolean
1371 workspace_next(GntBindable *wm, GList *n)
1372 {
1373 return gnt_wm_switch_workspace_next(GNT_WM(wm));
1374 }
1375
1376 static gboolean
1377 workspace_prev(GntBindable *wm, GList *n)
1378 {
1379 return gnt_wm_switch_workspace_prev(GNT_WM(wm));
1380 }
1381
1382 void
1383 gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget)
1384 {
1385 GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget);
1386 GntNode *node;
1387 if (!oldw || oldw == neww)
1388 return;
1389 node = g_hash_table_lookup(wm->nodes, widget);
1390 if (node && node->ws == neww)
1391 return;
1392
1393 if (node)
1394 node->ws = neww;
1395
1396 gnt_ws_remove_widget(oldw, widget);
1397 gnt_ws_add_widget(neww, widget);
1398 if (neww == wm->cws) {
1399 gnt_ws_widget_show(widget, wm->nodes);
1400 } else {
1401 gnt_ws_widget_hide(widget, wm->nodes);
1402 }
1403 }
1404
1405 static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid)
1406 {
1407 GntWS *s = (GntWS *)workspace;
1408 if (s->list && g_list_find(s->list, wid))
1409 return 0;
1410 return 1;
1411 }
1412
1413 GntWS *gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget)
1414 {
1415 GList *l = g_list_find_custom(wm->workspaces, widget, widget_in_workspace);
1416 if (l)
1417 return l->data;
1418 return NULL;
1419 }
1420
1421 static void free_workspaces(gpointer data, gpointer n)
1422 {
1423 GntWS *s = data;
1424 g_free(s->name);
1425 }
1426
1427 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces)
1428 {
1429 g_list_foreach(wm->workspaces, free_workspaces, NULL);
1430 wm->workspaces = workspaces;
1431 gnt_wm_switch_workspace(wm, 0);
1432 }
1433
1218 static void 1434 static void
1219 update_window_in_list(GntWM *wm, GntWidget *wid) 1435 update_window_in_list(GntWM *wm, GntWidget *wid)
1220 { 1436 {
1221 GntTextFormatFlags flag = 0; 1437 GntTextFormatFlags flag = 0;
1222 1438
1223 if (wm->windows == NULL) 1439 if (wm->windows == NULL)
1224 return; 1440 return;
1225 1441
1226 if (wid == wm->ordered->data) 1442 if (wm->cws->ordered && wid == wm->cws->ordered->data)
1227 flag |= GNT_TEXT_FLAG_DIM; 1443 flag |= GNT_TEXT_FLAG_DIM;
1228 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) 1444 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT))
1229 flag |= GNT_TEXT_FLAG_BOLD; 1445 flag |= GNT_TEXT_FLAG_BOLD;
1230 1446
1231 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); 1447 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag);
1448 }
1449
1450 static gboolean
1451 match_title(gpointer title, gpointer n, gpointer wid_title)
1452 {
1453 /* maybe check for regex.h? */
1454 if (g_strrstr((gchar *)wid_title, (gchar *)title))
1455 return TRUE;
1456 return FALSE;
1457 }
1458
1459 static GntWS *
1460 new_widget_find_workspace(GntWM *wm, GntWidget *widget, gchar *wid_title)
1461 {
1462 GntWS *ret;
1463 const gchar *name;
1464 ret = g_hash_table_find(wm->title_places, match_title, wid_title);
1465 if (ret)
1466 return ret;
1467 name = gnt_widget_get_name(widget);
1468 if (name)
1469 ret = g_hash_table_lookup(wm->name_places, name);
1470 return ret ? ret : wm->cws;
1232 } 1471 }
1233 1472
1234 static void 1473 static void
1235 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) 1474 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget)
1236 { 1475 {
1275 y = MAX(0, maxy - h); 1514 y = MAX(0, maxy - h);
1276 1515
1277 w = MIN(w, maxx); 1516 w = MIN(w, maxx);
1278 h = MIN(h, maxy); 1517 h = MIN(h, maxy);
1279 node->window = newwin(h + shadow, w + shadow, y, x); 1518 node->window = newwin(h + shadow, w + shadow, y, x);
1280 copy_win(widget, node); 1519 gnt_wm_copy_win(widget, node);
1281 } 1520 }
1282 #endif 1521 #endif
1283 1522
1284 node->panel = new_panel(node->window); 1523 node->panel = new_panel(node->window);
1285 set_panel_userptr(node->panel, node); 1524 set_panel_userptr(node->panel, node);
1286 1525
1287 if (!transient) { 1526 if (!transient) {
1527 GntWS *ws = wm->cws;
1288 if (node->me != wm->_list.window) { 1528 if (node->me != wm->_list.window) {
1289 GntWidget *w = NULL; 1529 GntWidget *w = NULL;
1290 1530
1291 if (wm->ordered) 1531 if (GNT_IS_BOX(widget)) {
1292 w = wm->ordered->data; 1532 char *title = GNT_BOX(widget)->title;
1293 1533 ws = new_widget_find_workspace(wm, widget, title);
1294 wm->list = g_list_append(wm->list, widget); 1534 }
1535
1536 if (ws->ordered)
1537 w = ws->ordered->data;
1538
1539 node->ws = ws;
1540 ws->list = g_list_append(ws->list, widget);
1295 1541
1296 if (wm->event_stack) 1542 if (wm->event_stack)
1297 wm->ordered = g_list_prepend(wm->ordered, widget); 1543 ws->ordered = g_list_prepend(ws->ordered, widget);
1298 else 1544 else
1299 wm->ordered = g_list_append(wm->ordered, widget); 1545 ws->ordered = g_list_append(ws->ordered, widget);
1300 1546
1301 gnt_widget_set_focus(widget, TRUE); 1547 gnt_widget_set_focus(widget, TRUE);
1302 if (w) 1548 if (w)
1303 gnt_widget_set_focus(w, FALSE); 1549 gnt_widget_set_focus(w, FALSE);
1304 } 1550 }
1305 1551
1306 if (wm->event_stack || node->me == wm->_list.window) { 1552 if (wm->event_stack || node->me == wm->_list.window) {
1553 if (wm->cws != ws)
1554 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws));
1307 gnt_wm_raise_window(wm, node->me); 1555 gnt_wm_raise_window(wm, node->me);
1308 } else { 1556 } else {
1309 bottom_panel(node->panel); /* New windows should not grab focus */ 1557 bottom_panel(node->panel); /* New windows should not grab focus */
1310 gnt_widget_set_urgent(node->me); 1558 gnt_widget_set_urgent(node->me);
1559 if (wm->cws != ws)
1560 gnt_ws_widget_hide(widget, wm->nodes);
1311 } 1561 }
1312 } 1562 }
1313 } 1563 }
1314 1564
1315 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) 1565 void gnt_wm_new_window(GntWM *wm, GntWidget *widget)
1339 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { 1589 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
1340 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget 1590 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget
1341 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { 1591 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) {
1342 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, 1592 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget,
1343 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), 1593 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title),
1344 NULL); 1594 g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL);
1345 update_window_in_list(wm, widget); 1595 update_window_in_list(wm, widget);
1346 } 1596 }
1347 } 1597 }
1348 1598
1349 update_screen(wm); 1599 update_screen(wm);
1350 draw_taskbar(wm, FALSE); 1600 gnt_ws_draw_taskbar(wm->cws, FALSE);
1351 } 1601 }
1352 1602
1353 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) 1603 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget)
1354 { 1604 {
1355 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); 1605 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget);
1356 } 1606 }
1357 1607
1358 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) 1608 void gnt_wm_window_close(GntWM *wm, GntWidget *widget)
1359 { 1609 {
1610 GntWS *s;
1360 GntNode *node; 1611 GntNode *node;
1361 int pos; 1612 int pos;
1362 1613
1614 s = gnt_wm_widget_find_workspace(wm, widget);
1615
1363 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) 1616 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL)
1364 return; 1617 return;
1365 1618
1366 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); 1619 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget);
1367 g_hash_table_remove(wm->nodes, widget); 1620 g_hash_table_remove(wm->nodes, widget);
1368 1621
1369 if (wm->windows) { 1622 if (wm->windows) {
1370 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); 1623 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget);
1371 } 1624 }
1372 1625
1373 pos = g_list_index(wm->list, widget); 1626 if (s) {
1374 1627 pos = g_list_index(s->list, widget);
1375 if (pos != -1) { 1628
1376 wm->list = g_list_remove(wm->list, widget); 1629 if (pos != -1) {
1377 wm->ordered = g_list_remove(wm->ordered, widget); 1630 s->list = g_list_remove(s->list, widget);
1378 1631 s->ordered = g_list_remove(s->ordered, widget);
1379 if (wm->ordered) 1632
1380 gnt_wm_raise_window(wm, wm->ordered->data); 1633 if (s->ordered && wm->cws == s)
1634 gnt_wm_raise_window(wm, s->ordered->data);
1635 }
1381 } 1636 }
1382 1637
1383 update_screen(wm); 1638 update_screen(wm);
1384 draw_taskbar(wm, FALSE); 1639 gnt_ws_draw_taskbar(wm->cws, FALSE);
1385 } 1640 }
1386 1641
1387 time_t gnt_wm_get_idle_time() 1642 time_t gnt_wm_get_idle_time()
1388 { 1643 {
1389 return time(NULL) - last_active_time; 1644 return time(NULL) - last_active_time;
1400 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { 1655 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) {
1401 return TRUE; 1656 return TRUE;
1402 } 1657 }
1403 1658
1404 /* Do some manual checking */ 1659 /* Do some manual checking */
1405 if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) { 1660 if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) {
1406 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; 1661 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1;
1407 int x, y, w, h; 1662 int x, y, w, h;
1408 GntWidget *widget = GNT_WIDGET(wm->ordered->data); 1663 GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data);
1409 int ox, oy, ow, oh; 1664 int ox, oy, ow, oh;
1410 1665
1411 gnt_widget_get_position(widget, &x, &y); 1666 gnt_widget_get_position(widget, &x, &y);
1412 gnt_widget_get_size(widget, &w, &h); 1667 gnt_widget_get_size(widget, &w, &h);
1413 ox = x; oy = y; 1668 ox = x; oy = y;
1479 1734
1480 if (wm->menu) 1735 if (wm->menu)
1481 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); 1736 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys);
1482 else if (wm->_list.window) 1737 else if (wm->_list.window)
1483 ret = gnt_widget_key_pressed(wm->_list.window, keys); 1738 ret = gnt_widget_key_pressed(wm->_list.window, keys);
1484 else if (wm->ordered) 1739 else if (wm->cws->ordered)
1485 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->ordered->data), keys); 1740 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys);
1486 return ret; 1741 return ret;
1487 } 1742 }
1488 1743
1489 static void 1744 static void
1490 gnt_wm_win_resized(GntWM *wm, GntNode *node) 1745 gnt_wm_win_resized(GntWM *wm, GntNode *node)
1614 1869
1615 if (!node) 1870 if (!node)
1616 return; 1871 return;
1617 1872
1618 if (widget != wm->_list.window && !GNT_IS_MENU(widget) && 1873 if (widget != wm->_list.window && !GNT_IS_MENU(widget) &&
1619 wm->ordered->data != widget) { 1874 wm->cws->ordered->data != widget) {
1620 GntWidget *w = wm->ordered->data; 1875 GntWidget *w = wm->cws->ordered->data;
1621 wm->ordered = g_list_bring_to_front(wm->ordered, widget); 1876 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget);
1622 gnt_widget_set_focus(w, FALSE); 1877 gnt_widget_set_focus(w, FALSE);
1623 } 1878 }
1624 1879
1625 gnt_widget_set_focus(widget, TRUE); 1880 gnt_widget_set_focus(widget, TRUE);
1626 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); 1881 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT);
1630 if (wm->_list.window) { 1885 if (wm->_list.window) {
1631 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); 1886 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window);
1632 top_panel(nd->panel); 1887 top_panel(nd->panel);
1633 } 1888 }
1634 update_screen(wm); 1889 update_screen(wm);
1635 draw_taskbar(wm, FALSE); 1890 gnt_ws_draw_taskbar(wm->cws, FALSE);
1636 } 1891 }
1637 1892
1638 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) 1893 void gnt_wm_update_window(GntWM *wm, GntWidget *widget)
1639 { 1894 {
1640 GntNode *node; 1895 GntNode *node = NULL;
1896 GntWS *ws;
1641 1897
1642 while (widget->parent) 1898 while (widget->parent)
1643 widget = widget->parent; 1899 widget = widget->parent;
1644 if (!GNT_IS_MENU(widget)) 1900 if (!GNT_IS_MENU(widget))
1645 gnt_box_sync_children(GNT_BOX(widget)); 1901 gnt_box_sync_children(GNT_BOX(widget));
1646 1902
1903 ws = gnt_wm_widget_find_workspace(wm, widget);
1647 node = g_hash_table_lookup(wm->nodes, widget); 1904 node = g_hash_table_lookup(wm->nodes, widget);
1648 if (node == NULL) { 1905 if (node == NULL) {
1649 gnt_wm_new_window(wm, widget); 1906 gnt_wm_new_window(wm, widget);
1650 } else 1907 } else
1651 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); 1908 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node);
1652 1909
1653 copy_win(widget, node); 1910 if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) {
1654 update_screen(wm); 1911 gnt_wm_copy_win(widget, node);
1655 draw_taskbar(wm, FALSE); 1912 update_screen(wm);
1913 gnt_ws_draw_taskbar(wm->cws, FALSE);
1914 } else if (ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) {
1915 if (!act || (act && !g_list_find(act, ws)))
1916 act = g_list_prepend(act, ws);
1917 update_act_msg();
1918 }
1656 } 1919 }
1657 1920
1658 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) 1921 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget)
1659 { 1922 {
1660 gboolean ret = TRUE; 1923 gboolean ret = TRUE;