Mercurial > pidgin
comparison finch/libgnt/gntwm.c @ 17828:4d4a396a478c
propagate from branch 'im.pidgin.pidgin' (head 6f6e8345100a2f026e20c28fa52592fadd9c8193)
to branch 'im.pidgin.finch.workspaces' (head a54e86b400cf8e4b692ae83a4e4976843855b1f6)
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Sun, 13 May 2007 00:21:15 +0000 |
parents | f1abdde52538 3af867ef5a15 |
children | 08776fc5c06f |
comparison
equal
deleted
inserted
replaced
17063:1ae4c1a45750 | 17828:4d4a396a478c |
---|---|
4 #endif | 4 #endif |
5 | 5 |
6 #include "config.h" | 6 #include "config.h" |
7 | 7 |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 #include <glib/gprintf.h> | |
10 #include <gmodule.h> | |
9 #include <stdlib.h> | 11 #include <stdlib.h> |
10 #include <string.h> | 12 #include <string.h> |
11 #include <time.h> | 13 #include <time.h> |
12 | 14 |
13 #include "gntwm.h" | 15 #include "gntwm.h" |
45 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); | 47 static void gnt_wm_win_resized(GntWM *wm, GntNode *node); |
46 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); | 48 static void gnt_wm_win_moved(GntWM *wm, GntNode *node); |
47 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); | 49 static void gnt_wm_give_focus(GntWM *wm, GntWidget *widget); |
48 static void update_window_in_list(GntWM *wm, GntWidget *wid); | 50 static void update_window_in_list(GntWM *wm, GntWidget *wid); |
49 static void shift_window(GntWM *wm, GntWidget *widget, int dir); | 51 static void shift_window(GntWM *wm, GntWidget *widget, int dir); |
52 static gboolean workspace_next(GntBindable *wm, GList *n); | |
53 static gboolean workspace_prev(GntBindable *wm, GList *n); | |
50 | 54 |
51 #ifndef NO_WIDECHAR | 55 #ifndef NO_WIDECHAR |
52 static int widestringwidth(wchar_t *wide); | 56 static int widestringwidth(wchar_t *wide); |
53 #endif | 57 #endif |
54 | 58 |
55 static gboolean write_already(gpointer data); | 59 static gboolean write_already(gpointer data); |
56 static int write_timeout; | 60 static int write_timeout; |
57 static time_t last_active_time; | 61 static time_t last_active_time; |
58 static gboolean idle_update; | 62 static gboolean idle_update; |
63 static GList *act = NULL; /* list of WS with unseen activitiy */ | |
59 | 64 |
60 static GList * | 65 static GList * |
61 g_list_bring_to_front(GList *list, gpointer data) | 66 g_list_bring_to_front(GList *list, gpointer data) |
62 { | 67 { |
63 list = g_list_remove(list, data); | 68 list = g_list_remove(list, data); |
72 hide_panel(node->panel); | 77 hide_panel(node->panel); |
73 del_panel(node->panel); | 78 del_panel(node->panel); |
74 g_free(node); | 79 g_free(node); |
75 } | 80 } |
76 | 81 |
77 static void | 82 void |
78 draw_taskbar(GntWM *wm, gboolean reposition) | 83 gnt_wm_copy_win(GntWidget *widget, GntNode *node) |
79 { | |
80 static WINDOW *taskbar = NULL; | |
81 GList *iter; | |
82 int n, width = 0; | |
83 int i; | |
84 | |
85 if (taskbar == NULL) { | |
86 taskbar = newwin(1, getmaxx(stdscr), getmaxy(stdscr) - 1, 0); | |
87 } else if (reposition) { | |
88 int Y_MAX = getmaxy(stdscr) - 1; | |
89 mvwin(taskbar, Y_MAX, 0); | |
90 } | |
91 | |
92 wbkgdset(taskbar, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
93 werase(taskbar); | |
94 | |
95 n = g_list_length(wm->list); | |
96 if (n) | |
97 width = getmaxx(stdscr) / n; | |
98 | |
99 for (i = 0, iter = wm->list; iter; iter = iter->next, i++) | |
100 { | |
101 GntWidget *w = iter->data; | |
102 int color; | |
103 const char *title; | |
104 | |
105 if (w == wm->ordered->data) { | |
106 /* This is the current window in focus */ | |
107 color = GNT_COLOR_TITLE; | |
108 } else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_URGENT)) { | |
109 /* This is a window with the URGENT hint set */ | |
110 color = GNT_COLOR_URGENT; | |
111 } else { | |
112 color = GNT_COLOR_NORMAL; | |
113 } | |
114 wbkgdset(taskbar, '\0' | COLOR_PAIR(color)); | |
115 if (iter->next) | |
116 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), width); | |
117 else | |
118 mvwhline(taskbar, 0, width * i, ' ' | COLOR_PAIR(color), getmaxx(stdscr) - width * i); | |
119 title = GNT_BOX(w)->title; | |
120 mvwprintw(taskbar, 0, width * i, "%s", title ? title : "<gnt>"); | |
121 if (i) | |
122 mvwaddch(taskbar, 0, width *i - 1, ACS_VLINE | A_STANDOUT | COLOR_PAIR(GNT_COLOR_NORMAL)); | |
123 | |
124 update_window_in_list(wm, w); | |
125 } | |
126 | |
127 wrefresh(taskbar); | |
128 } | |
129 | |
130 static void | |
131 copy_win(GntWidget *widget, GntNode *node) | |
132 { | 84 { |
133 WINDOW *src, *dst; | 85 WINDOW *src, *dst; |
134 int shadow; | 86 int shadow; |
135 if (!node) | 87 if (!node) |
136 return; | 88 return; |
197 } | 149 } |
198 } | 150 } |
199 #endif | 151 #endif |
200 } | 152 } |
201 | 153 |
154 static void | |
155 update_act_msg() | |
156 { | |
157 GntWidget *label; | |
158 GList *iter; | |
159 static GntWidget *message = NULL; | |
160 GString *text = g_string_new("act: "); | |
161 if (message) | |
162 gnt_widget_destroy(message); | |
163 if (g_list_length(act) == 0) | |
164 return; | |
165 for (iter = act; iter; iter = iter->next) { | |
166 GntWS *ws = iter->data; | |
167 g_string_sprintfa(text, "%s, ", gnt_ws_get_name(ws)); | |
168 } | |
169 g_string_erase(text, text->len - 2, 2); | |
170 message = gnt_vbox_new(FALSE); | |
171 label = gnt_label_new_with_format(text->str, GNT_TEXT_FLAG_BOLD | GNT_TEXT_FLAG_HIGHLIGHT); | |
172 GNT_WIDGET_UNSET_FLAGS(GNT_BOX(message), GNT_WIDGET_CAN_TAKE_FOCUS); | |
173 GNT_WIDGET_SET_FLAGS(GNT_BOX(message), GNT_WIDGET_TRANSIENT); | |
174 gnt_box_add_widget(GNT_BOX(message), label); | |
175 gnt_widget_set_name(message, "wm-message"); | |
176 gnt_widget_set_position(message, 0, 0); | |
177 gnt_widget_draw(message); | |
178 g_string_free(text, TRUE); | |
179 } | |
180 | |
202 static gboolean | 181 static gboolean |
203 update_screen(GntWM *wm) | 182 update_screen(GntWM *wm) |
204 { | 183 { |
205 if (wm->menu) { | 184 if (wm->menu) { |
206 GntMenu *top = wm->menu; | 185 GntMenu *top = wm->menu; |
327 | 306 |
328 static void | 307 static void |
329 gnt_wm_init(GTypeInstance *instance, gpointer class) | 308 gnt_wm_init(GTypeInstance *instance, gpointer class) |
330 { | 309 { |
331 GntWM *wm = GNT_WM(instance); | 310 GntWM *wm = GNT_WM(instance); |
332 wm->list = NULL; | 311 wm->workspaces = NULL; |
333 wm->ordered = NULL; | 312 wm->name_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
313 wm->title_places = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
314 gnt_style_read_workspaces(wm); | |
315 if (wm->workspaces == NULL) { | |
316 wm->cws = g_object_new(GNT_TYPE_WS, NULL); | |
317 gnt_ws_set_name(wm->cws, "default"); | |
318 gnt_wm_add_workspace(wm, wm->cws); | |
319 } else { | |
320 wm->cws = wm->workspaces->data; | |
321 } | |
334 wm->event_stack = FALSE; | 322 wm->event_stack = FALSE; |
323 wm->tagged = NULL; | |
335 wm->windows = NULL; | 324 wm->windows = NULL; |
336 wm->actions = NULL; | 325 wm->actions = NULL; |
337 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); | 326 wm->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); |
338 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 327 wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
339 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) | 328 if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) |
340 read_window_positions(wm); | 329 read_window_positions(wm); |
341 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); | 330 g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); |
342 time(&last_active_time); | 331 time(&last_active_time); |
332 gnt_wm_switch_workspace(wm, 0); | |
343 } | 333 } |
344 | 334 |
345 static void | 335 static void |
346 switch_window(GntWM *wm, int direction) | 336 switch_window(GntWM *wm, int direction) |
347 { | 337 { |
349 int pos; | 339 int pos; |
350 | 340 |
351 if (wm->_list.window || wm->menu) | 341 if (wm->_list.window || wm->menu) |
352 return; | 342 return; |
353 | 343 |
354 if (!wm->ordered || !wm->ordered->next) | 344 if (!wm->cws->ordered || !wm->cws->ordered->next) |
355 return; | 345 return; |
356 | 346 |
357 w = wm->ordered->data; | 347 w = wm->cws->ordered->data; |
358 pos = g_list_index(wm->list, w); | 348 pos = g_list_index(wm->cws->list, w); |
359 pos += direction; | 349 pos += direction; |
360 | 350 |
361 if (pos < 0) | 351 if (pos < 0) |
362 wid = g_list_last(wm->list)->data; | 352 wid = g_list_last(wm->cws->list)->data; |
363 else if (pos >= g_list_length(wm->list)) | 353 else if (pos >= g_list_length(wm->cws->list)) |
364 wid = wm->list->data; | 354 wid = wm->cws->list->data; |
365 else if (pos >= 0) | 355 else if (pos >= 0) |
366 wid = g_list_nth_data(wm->list, pos); | 356 wid = g_list_nth_data(wm->cws->list, pos); |
367 | 357 |
368 wm->ordered = g_list_bring_to_front(wm->ordered, wid); | 358 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, wid); |
369 | 359 |
370 gnt_wm_raise_window(wm, wm->ordered->data); | 360 gnt_wm_raise_window(wm, wm->cws->ordered->data); |
371 | 361 |
372 if (w != wid) { | 362 if (w != wid) { |
373 gnt_widget_set_focus(w, FALSE); | 363 gnt_widget_set_focus(w, FALSE); |
374 } | 364 } |
375 } | 365 } |
396 GntWM *wm = GNT_WM(bind); | 386 GntWM *wm = GNT_WM(bind); |
397 GntWidget *w = NULL; | 387 GntWidget *w = NULL; |
398 GList *l; | 388 GList *l; |
399 int n; | 389 int n; |
400 | 390 |
401 if (!wm->ordered) | 391 if (!wm->cws->ordered) |
402 return TRUE; | 392 return TRUE; |
403 | 393 |
404 if (list) | 394 if (list) |
405 n = GPOINTER_TO_INT(list->data); | 395 n = GPOINTER_TO_INT(list->data); |
406 else | 396 else |
407 n = 0; | 397 n = 0; |
408 | 398 |
409 w = wm->ordered->data; | 399 w = wm->cws->ordered->data; |
410 | 400 |
411 if ((l = g_list_nth(wm->list, n)) != NULL) | 401 if ((l = g_list_nth(wm->cws->list, n)) != NULL) |
412 { | 402 { |
413 gnt_wm_raise_window(wm, l->data); | 403 gnt_wm_raise_window(wm, l->data); |
414 } | 404 } |
415 | 405 |
416 if (l && w != l->data) | 406 if (l && w != l->data) |
425 { | 415 { |
426 GntWM *wm = GNT_WM(bindable); | 416 GntWM *wm = GNT_WM(bindable); |
427 GntWidget *window; | 417 GntWidget *window; |
428 GntNode *node; | 418 GntNode *node; |
429 | 419 |
430 if (!wm->ordered) | 420 if (!wm->cws->ordered) |
431 return TRUE; | 421 return TRUE; |
432 | 422 |
433 window = wm->ordered->data; | 423 window = wm->cws->ordered->data; |
434 node = g_hash_table_lookup(wm->nodes, window); | 424 node = g_hash_table_lookup(wm->nodes, window); |
435 if (!node) | 425 if (!node) |
436 return TRUE; | 426 return TRUE; |
437 | 427 |
438 if (node->scroll) { | 428 if (node->scroll) { |
439 node->scroll--; | 429 node->scroll--; |
440 copy_win(window, node); | 430 gnt_wm_copy_win(window, node); |
441 update_screen(wm); | 431 update_screen(wm); |
442 } | 432 } |
443 return TRUE; | 433 return TRUE; |
444 } | 434 } |
445 | 435 |
449 GntWM *wm = GNT_WM(bindable); | 439 GntWM *wm = GNT_WM(bindable); |
450 GntWidget *window; | 440 GntWidget *window; |
451 GntNode *node; | 441 GntNode *node; |
452 int w, h; | 442 int w, h; |
453 | 443 |
454 if (!wm->ordered) | 444 if (!wm->cws->ordered) |
455 return TRUE; | 445 return TRUE; |
456 | 446 |
457 window = wm->ordered->data; | 447 window = wm->cws->ordered->data; |
458 node = g_hash_table_lookup(wm->nodes, window); | 448 node = g_hash_table_lookup(wm->nodes, window); |
459 if (!node) | 449 if (!node) |
460 return TRUE; | 450 return TRUE; |
461 | 451 |
462 gnt_widget_get_size(window, &w, &h); | 452 gnt_widget_get_size(window, &w, &h); |
463 if (h - node->scroll > getmaxy(node->window)) { | 453 if (h - node->scroll > getmaxy(node->window)) { |
464 node->scroll++; | 454 node->scroll++; |
465 copy_win(window, node); | 455 gnt_wm_copy_win(window, node); |
466 update_screen(wm); | 456 update_screen(wm); |
467 } | 457 } |
468 return TRUE; | 458 return TRUE; |
469 } | 459 } |
470 | 460 |
474 GntWM *wm = GNT_WM(bindable); | 464 GntWM *wm = GNT_WM(bindable); |
475 | 465 |
476 if (wm->_list.window) | 466 if (wm->_list.window) |
477 return TRUE; | 467 return TRUE; |
478 | 468 |
479 if (wm->ordered) { | 469 if (wm->cws->ordered) { |
480 gnt_widget_destroy(wm->ordered->data); | 470 gnt_widget_destroy(wm->cws->ordered->data); |
481 } | 471 } |
482 | 472 |
483 return TRUE; | 473 return TRUE; |
484 } | 474 } |
485 | 475 |
488 { | 478 { |
489 GntWM *wm = GNT_WM(bindable); | 479 GntWM *wm = GNT_WM(bindable); |
490 GntWidget *widget, *tree, *win, *active; | 480 GntWidget *widget, *tree, *win, *active; |
491 char *title; | 481 char *title; |
492 | 482 |
493 if (!wm->ordered) | 483 if (!wm->cws->ordered) |
494 return TRUE; | 484 return TRUE; |
495 | 485 |
496 widget = wm->ordered->data; | 486 widget = wm->cws->ordered->data; |
497 if (!GNT_IS_BOX(widget)) | 487 if (!GNT_IS_BOX(widget)) |
498 return TRUE; | 488 return TRUE; |
499 active = GNT_BOX(widget)->active; | 489 active = GNT_BOX(widget)->active; |
500 | 490 |
501 tree = gnt_widget_bindings_view(active); | 491 tree = gnt_widget_bindings_view(active); |
538 } | 528 } |
539 | 529 |
540 static void | 530 static void |
541 window_list_activate(GntTree *tree, GntWM *wm) | 531 window_list_activate(GntTree *tree, GntWM *wm) |
542 { | 532 { |
543 GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree)); | 533 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(tree)); |
544 | 534 |
545 if (!wm->ordered || !widget) | 535 gnt_widget_destroy(wm->_list.window); |
536 | |
537 if (!sel) | |
546 return; | 538 return; |
547 | 539 |
548 gnt_widget_destroy(wm->_list.window); | 540 if (GNT_IS_WS(sel)) { |
549 gnt_wm_raise_window(wm, widget); | 541 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, sel)); |
550 } | 542 } else { |
551 | 543 GntNode *node = g_hash_table_lookup(wm->nodes, sel); |
552 static void | 544 if (node && node->ws != wm->cws) |
553 populate_window_list(GntWM *wm) | 545 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, node->ws)); |
546 gnt_wm_raise_window(wm, GNT_WIDGET(sel)); | |
547 } | |
548 } | |
549 | |
550 static void | |
551 populate_window_list(GntWM *wm, gboolean workspace) | |
554 { | 552 { |
555 GList *iter; | 553 GList *iter; |
556 GntTree *tree = GNT_TREE(wm->windows->tree); | 554 GntTree *tree = GNT_TREE(wm->windows->tree); |
557 for (iter = wm->list; iter; iter = iter->next) { | 555 if (!workspace) { |
558 GntBox *box = GNT_BOX(iter->data); | 556 for (iter = wm->cws->list; iter; iter = iter->next) { |
559 | 557 GntBox *box = GNT_BOX(iter->data); |
560 gnt_tree_add_row_last(tree, box, | 558 |
561 gnt_tree_create_row(tree, box->title), NULL); | 559 gnt_tree_add_row_last(tree, box, |
562 update_window_in_list(wm, GNT_WIDGET(box)); | 560 gnt_tree_create_row(tree, box->title), NULL); |
561 update_window_in_list(wm, GNT_WIDGET(box)); | |
562 } | |
563 } else { | |
564 GList *ws = wm->workspaces; | |
565 for (; ws; ws = ws->next) { | |
566 gnt_tree_add_row_last(tree, ws->data, | |
567 gnt_tree_create_row(tree, gnt_ws_get_name(GNT_WS(ws->data))), NULL); | |
568 for (iter = GNT_WS(ws->data)->list; iter; iter = iter->next) { | |
569 GntBox *box = GNT_BOX(iter->data); | |
570 | |
571 gnt_tree_add_row_last(tree, box, | |
572 gnt_tree_create_row(tree, box->title), ws->data); | |
573 update_window_in_list(wm, GNT_WIDGET(box)); | |
574 } | |
575 } | |
563 } | 576 } |
564 } | 577 } |
565 | 578 |
566 static gboolean | 579 static gboolean |
567 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) | 580 window_list_key_pressed(GntWidget *widget, const char *text, GntWM *wm) |
568 { | 581 { |
569 if (text[1] == 0 && wm->ordered) { | 582 if (text[1] == 0 && wm->cws->ordered) { |
570 GntWidget *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); | 583 GntBindable *sel = gnt_tree_get_selection_data(GNT_TREE(widget)); |
571 switch (text[0]) { | 584 switch (text[0]) { |
572 case '-': | 585 case '-': |
573 case ',': | 586 case ',': |
574 shift_window(wm, sel, -1); | 587 if (GNT_IS_WS(sel)) { |
588 /* reorder the workspace. */ | |
589 } else | |
590 shift_window(wm, GNT_WIDGET(sel), -1); | |
575 break; | 591 break; |
576 case '=': | 592 case '=': |
577 case '.': | 593 case '.': |
578 shift_window(wm, sel, 1); | 594 if (GNT_IS_WS(sel)) { |
595 /* reorder the workspace. */ | |
596 } else | |
597 shift_window(wm, GNT_WIDGET(sel), 1); | |
579 break; | 598 break; |
580 default: | 599 default: |
581 return FALSE; | 600 return FALSE; |
582 } | 601 } |
583 gnt_tree_remove_all(GNT_TREE(widget)); | 602 gnt_tree_remove_all(GNT_TREE(widget)); |
584 populate_window_list(wm); | 603 populate_window_list(wm, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "workspace"))); |
585 gnt_tree_set_selected(GNT_TREE(widget), sel); | 604 gnt_tree_set_selected(GNT_TREE(widget), sel); |
586 return TRUE; | 605 return TRUE; |
587 } | 606 } |
588 return FALSE; | 607 return FALSE; |
589 } | 608 } |
590 | 609 |
591 static gboolean | 610 static void |
592 window_list(GntBindable *bindable, GList *null) | 611 list_of_windows(GntWM *wm, gboolean workspace) |
593 { | 612 { |
594 GntWM *wm = GNT_WM(bindable); | |
595 GntWidget *tree, *win; | 613 GntWidget *tree, *win; |
596 | |
597 if (wm->_list.window || wm->menu) | |
598 return TRUE; | |
599 | |
600 if (!wm->ordered) | |
601 return TRUE; | |
602 | |
603 setup__list(wm); | 614 setup__list(wm); |
604 wm->windows = &wm->_list; | 615 wm->windows = &wm->_list; |
605 | 616 |
606 win = wm->windows->window; | 617 win = wm->windows->window; |
607 tree = wm->windows->tree; | 618 tree = wm->windows->tree; |
608 | 619 |
609 gnt_box_set_title(GNT_BOX(win), "Window List"); | 620 gnt_box_set_title(GNT_BOX(win), workspace ? "Workspace List" : "Window List"); |
610 | 621 |
611 populate_window_list(wm); | 622 populate_window_list(wm, workspace); |
612 | 623 |
613 gnt_tree_set_selected(GNT_TREE(tree), wm->ordered->data); | 624 if (wm->cws->ordered) |
625 gnt_tree_set_selected(GNT_TREE(tree), wm->cws->ordered->data); | |
626 else if (workspace) | |
627 gnt_tree_set_selected(GNT_TREE(tree), wm->cws); | |
628 | |
614 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); | 629 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), wm); |
615 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); | 630 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(window_list_key_pressed), wm); |
631 g_object_set_data(G_OBJECT(tree), "workspace", GINT_TO_POINTER(workspace)); | |
616 | 632 |
617 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); | 633 gnt_tree_set_col_width(GNT_TREE(tree), 0, getmaxx(stdscr) / 3); |
618 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); | 634 gnt_widget_set_size(tree, 0, getmaxy(stdscr) / 2); |
619 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); | 635 gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4); |
620 | 636 |
621 gnt_widget_show(win); | 637 gnt_widget_show(win); |
638 } | |
639 | |
640 static gboolean | |
641 window_list(GntBindable *bindable, GList *null) | |
642 { | |
643 GntWM *wm = GNT_WM(bindable); | |
644 | |
645 if (wm->_list.window || wm->menu) | |
646 return TRUE; | |
647 | |
648 if (!wm->cws->ordered) | |
649 return TRUE; | |
650 | |
651 list_of_windows(wm, FALSE); | |
652 | |
622 return TRUE; | 653 return TRUE; |
623 } | 654 } |
624 | 655 |
625 static gboolean | 656 static gboolean |
626 dump_screen(GntBindable *bindable, GList *null) | 657 dump_screen(GntBindable *bindable, GList *null) |
735 } | 766 } |
736 | 767 |
737 static void | 768 static void |
738 shift_window(GntWM *wm, GntWidget *widget, int dir) | 769 shift_window(GntWM *wm, GntWidget *widget, int dir) |
739 { | 770 { |
740 GList *all = wm->list; | 771 GList *all = wm->cws->list; |
741 GList *list = g_list_find(all, widget); | 772 GList *list = g_list_find(all, widget); |
742 int length, pos; | 773 int length, pos; |
743 if (!list) | 774 if (!list) |
744 return; | 775 return; |
745 | 776 |
755 else if (pos > length) | 786 else if (pos > length) |
756 pos = 0; | 787 pos = 0; |
757 | 788 |
758 all = g_list_insert(all, widget, pos); | 789 all = g_list_insert(all, widget, pos); |
759 all = g_list_delete_link(all, list); | 790 all = g_list_delete_link(all, list); |
760 wm->list = all; | 791 wm->cws->list = all; |
761 draw_taskbar(wm, FALSE); | 792 gnt_ws_draw_taskbar(wm->cws, FALSE); |
762 } | 793 } |
763 | 794 |
764 static gboolean | 795 static gboolean |
765 shift_left(GntBindable *bindable, GList *null) | 796 shift_left(GntBindable *bindable, GList *null) |
766 { | 797 { |
767 GntWM *wm = GNT_WM(bindable); | 798 GntWM *wm = GNT_WM(bindable); |
768 if (wm->_list.window) | 799 if (wm->_list.window) |
769 return TRUE; | 800 return TRUE; |
770 | 801 |
771 shift_window(wm, wm->ordered->data, -1); | 802 shift_window(wm, wm->cws->ordered->data, -1); |
772 return TRUE; | 803 return TRUE; |
773 } | 804 } |
774 | 805 |
775 static gboolean | 806 static gboolean |
776 shift_right(GntBindable *bindable, GList *null) | 807 shift_right(GntBindable *bindable, GList *null) |
777 { | 808 { |
778 GntWM *wm = GNT_WM(bindable); | 809 GntWM *wm = GNT_WM(bindable); |
779 if (wm->_list.window) | 810 if (wm->_list.window) |
780 return TRUE; | 811 return TRUE; |
781 | 812 |
782 shift_window(wm, wm->ordered->data, 1); | 813 shift_window(wm, wm->cws->ordered->data, 1); |
783 return TRUE; | 814 return TRUE; |
784 } | 815 } |
785 | 816 |
786 static void | 817 static void |
787 action_list_activate(GntTree *tree, GntWM *wm) | 818 action_list_activate(GntTree *tree, GntWM *wm) |
901 | 932 |
902 /* the left and right */ | 933 /* the left and right */ |
903 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); | 934 for (i = 0; i < h; i += reverse_char(d, i, 0, set)); |
904 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); | 935 for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); |
905 | 936 |
906 copy_win(win, g_hash_table_lookup(wm->nodes, win)); | 937 gnt_wm_copy_win(win, g_hash_table_lookup(wm->nodes, win)); |
907 update_screen(wm); | 938 update_screen(wm); |
908 } | 939 } |
909 | 940 |
910 static gboolean | 941 static gboolean |
911 start_move(GntBindable *bindable, GList *null) | 942 start_move(GntBindable *bindable, GList *null) |
912 { | 943 { |
913 GntWM *wm = GNT_WM(bindable); | 944 GntWM *wm = GNT_WM(bindable); |
914 if (wm->_list.window || wm->menu) | 945 if (wm->_list.window || wm->menu) |
915 return TRUE; | 946 return TRUE; |
916 if (!wm->ordered) | 947 if (!wm->cws->ordered) |
917 return TRUE; | 948 return TRUE; |
918 | 949 |
919 wm->mode = GNT_KP_MODE_MOVE; | 950 wm->mode = GNT_KP_MODE_MOVE; |
920 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE, wm); | 951 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
921 | 952 |
922 return TRUE; | 953 return TRUE; |
923 } | 954 } |
924 | 955 |
925 static gboolean | 956 static gboolean |
926 start_resize(GntBindable *bindable, GList *null) | 957 start_resize(GntBindable *bindable, GList *null) |
927 { | 958 { |
928 GntWM *wm = GNT_WM(bindable); | 959 GntWM *wm = GNT_WM(bindable); |
929 if (wm->_list.window || wm->menu) | 960 if (wm->_list.window || wm->menu) |
930 return TRUE; | 961 return TRUE; |
931 if (!wm->ordered) | 962 if (!wm->cws->ordered) |
932 return TRUE; | 963 return TRUE; |
933 | 964 |
934 wm->mode = GNT_KP_MODE_RESIZE; | 965 wm->mode = GNT_KP_MODE_RESIZE; |
935 window_reverse(GNT_WIDGET(wm->ordered->data), TRUE, wm); | 966 window_reverse(GNT_WIDGET(wm->cws->ordered->data), TRUE, wm); |
936 | 967 |
937 return TRUE; | 968 return TRUE; |
938 } | 969 } |
939 | 970 |
940 static gboolean | 971 static gboolean |
962 refresh(); | 993 refresh(); |
963 curs_set(0); /* endwin resets the cursor to normal */ | 994 curs_set(0); /* endwin resets the cursor to normal */ |
964 | 995 |
965 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); | 996 g_hash_table_foreach(wm->nodes, (GHFunc)refresh_node, NULL); |
966 update_screen(wm); | 997 update_screen(wm); |
967 draw_taskbar(wm, TRUE); | 998 gnt_ws_draw_taskbar(wm->cws, TRUE); |
968 | 999 |
969 return FALSE; | 1000 return FALSE; |
970 } | 1001 } |
971 | 1002 |
972 static gboolean | 1003 static gboolean |
990 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); | 1021 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(text)); |
991 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); | 1022 gnt_box_add_widget(GNT_BOX(clip), gnt_label_new(" ")); |
992 gnt_widget_set_position(clip, 0, 0); | 1023 gnt_widget_set_position(clip, 0, 0); |
993 gnt_widget_draw(clip); | 1024 gnt_widget_draw(clip); |
994 g_free(text); | 1025 g_free(text); |
1026 return TRUE; | |
1027 } | |
1028 | |
1029 static void remove_tag(gpointer wid, gpointer wim) | |
1030 { | |
1031 GntWM *wm = GNT_WM(wim); | |
1032 GntWidget *w = GNT_WIDGET(wid); | |
1033 wm->tagged = g_list_remove(wm->tagged, w); | |
1034 mvwhline(w->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL), 3); | |
1035 gnt_widget_draw(w); | |
1036 } | |
1037 | |
1038 static gboolean | |
1039 tag_widget(GntBindable *b, GList *params) | |
1040 { | |
1041 GntWM *wm = GNT_WM(b); | |
1042 GntWidget *widget; | |
1043 | |
1044 if (!wm->cws->ordered) | |
1045 return FALSE; | |
1046 widget = wm->cws->ordered->data; | |
1047 | |
1048 if (g_list_find(wm->tagged, widget)) { | |
1049 remove_tag(widget, wm); | |
1050 return TRUE; | |
1051 } | |
1052 | |
1053 wm->tagged = g_list_prepend(wm->tagged, widget); | |
1054 wbkgdset(widget->window, ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); | |
1055 mvwprintw(widget->window, 0, 1, "[T]"); | |
1056 gnt_widget_draw(widget); | |
1057 return TRUE; | |
1058 } | |
1059 | |
1060 static void | |
1061 widget_move_ws(gpointer wid, gpointer w) | |
1062 { | |
1063 GntWM *wm = GNT_WM(w); | |
1064 gnt_wm_widget_move_workspace(wm, wm->cws, GNT_WIDGET(wid)); | |
1065 } | |
1066 | |
1067 static gboolean | |
1068 place_tagged(GntBindable *b, GList *params) | |
1069 { | |
1070 GntWM *wm = GNT_WM(b); | |
1071 g_list_foreach(wm->tagged, widget_move_ws, wm); | |
1072 g_list_foreach(wm->tagged, remove_tag, wm); | |
1073 g_list_free(wm->tagged); | |
1074 wm->tagged = NULL; | |
1075 return TRUE; | |
1076 } | |
1077 | |
1078 static gboolean | |
1079 workspace_list(GntBindable *b, GList *params) | |
1080 { | |
1081 GntWM *wm = GNT_WM(b); | |
1082 | |
1083 if (wm->_list.window || wm->menu) | |
1084 return TRUE; | |
1085 | |
1086 list_of_windows(wm, TRUE); | |
1087 | |
995 return TRUE; | 1088 return TRUE; |
996 } | 1089 } |
997 | 1090 |
998 static void | 1091 static void |
999 gnt_wm_class_init(GntWMClass *klass) | 1092 gnt_wm_class_init(GntWMClass *klass) |
1127 "\033" GNT_KEY_CTRL_J, NULL); | 1220 "\033" GNT_KEY_CTRL_J, NULL); |
1128 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, | 1221 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, |
1129 "\033" GNT_KEY_CTRL_K, NULL); | 1222 "\033" GNT_KEY_CTRL_K, NULL); |
1130 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, | 1223 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, |
1131 "\033" "/", NULL); | 1224 "\033" "/", NULL); |
1225 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-next", workspace_next, | |
1226 "\033" ">", NULL); | |
1227 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-prev", workspace_prev, | |
1228 "\033" "<", NULL); | |
1229 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-tag", tag_widget, | |
1230 "\033" "t", NULL); | |
1231 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "place-tagged", place_tagged, | |
1232 "\033" "T", NULL); | |
1233 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "workspace-list", workspace_list, | |
1234 "\033" "s", NULL); | |
1132 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", | 1235 gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", |
1133 toggle_clipboard, "\033" "C", NULL); | 1236 toggle_clipboard, "\033" "C", NULL); |
1134 | 1237 |
1135 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); | 1238 gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); |
1136 | 1239 |
1171 &info, 0); | 1274 &info, 0); |
1172 } | 1275 } |
1173 | 1276 |
1174 return type; | 1277 return type; |
1175 } | 1278 } |
1279 void | |
1280 gnt_wm_add_workspace(GntWM *wm, GntWS *ws) | |
1281 { | |
1282 wm->workspaces = g_list_append(wm->workspaces, ws); | |
1283 } | |
1284 | |
1285 gboolean | |
1286 gnt_wm_switch_workspace(GntWM *wm, gint n) | |
1287 { | |
1288 GntWS *s = g_list_nth_data(wm->workspaces, n); | |
1289 if (!s) | |
1290 return FALSE; | |
1291 | |
1292 if (wm->_list.window) { | |
1293 gnt_widget_destroy(wm->_list.window); | |
1294 } | |
1295 gnt_ws_hide(wm->cws, wm->nodes); | |
1296 wm->cws = s; | |
1297 gnt_ws_show(wm->cws, wm->nodes); | |
1298 | |
1299 gnt_ws_draw_taskbar(wm->cws, TRUE); | |
1300 update_screen(wm); | |
1301 if (wm->cws->ordered) { | |
1302 gnt_widget_set_focus(wm->cws->ordered->data, TRUE); | |
1303 gnt_wm_raise_window(wm, wm->cws->ordered->data); | |
1304 } | |
1305 | |
1306 if (act && g_list_find(act, wm->cws)) { | |
1307 act = g_list_remove(act, wm->cws); | |
1308 update_act_msg(); | |
1309 } | |
1310 return TRUE; | |
1311 } | |
1312 | |
1313 gboolean | |
1314 gnt_wm_switch_workspace_prev(GntWM *wm) | |
1315 { | |
1316 int n = g_list_index(wm->workspaces, wm->cws); | |
1317 return gnt_wm_switch_workspace(wm, --n); | |
1318 } | |
1319 | |
1320 gboolean | |
1321 gnt_wm_switch_workspace_next(GntWM *wm) | |
1322 { | |
1323 int n = g_list_index(wm->workspaces, wm->cws); | |
1324 return gnt_wm_switch_workspace(wm, ++n); | |
1325 } | |
1326 | |
1327 static gboolean | |
1328 workspace_next(GntBindable *wm, GList *n) | |
1329 { | |
1330 return gnt_wm_switch_workspace_next(GNT_WM(wm)); | |
1331 } | |
1332 | |
1333 static gboolean | |
1334 workspace_prev(GntBindable *wm, GList *n) | |
1335 { | |
1336 return gnt_wm_switch_workspace_prev(GNT_WM(wm)); | |
1337 } | |
1338 | |
1339 void | |
1340 gnt_wm_widget_move_workspace(GntWM *wm, GntWS *neww, GntWidget *widget) | |
1341 { | |
1342 GntWS *oldw = gnt_wm_widget_find_workspace(wm, widget); | |
1343 GntNode *node; | |
1344 if (!oldw || oldw == neww) | |
1345 return; | |
1346 node = g_hash_table_lookup(wm->nodes, widget); | |
1347 if (node && node->ws == neww) | |
1348 return; | |
1349 | |
1350 if (node) | |
1351 node->ws = neww; | |
1352 | |
1353 gnt_ws_remove_widget(oldw, widget); | |
1354 gnt_ws_add_widget(neww, widget); | |
1355 if (neww == wm->cws) { | |
1356 gnt_ws_widget_show(widget, wm->nodes); | |
1357 } else { | |
1358 gnt_ws_widget_hide(widget, wm->nodes); | |
1359 } | |
1360 } | |
1361 | |
1362 static gint widget_in_workspace(gconstpointer workspace, gconstpointer wid) | |
1363 { | |
1364 GntWS *s = (GntWS *)workspace; | |
1365 if (s->list && g_list_find(s->list, wid)) | |
1366 return 0; | |
1367 return 1; | |
1368 } | |
1369 | |
1370 GntWS *gnt_wm_widget_find_workspace(GntWM *wm, GntWidget *widget) | |
1371 { | |
1372 GList *l = g_list_find_custom(wm->workspaces, widget, widget_in_workspace); | |
1373 if (l) | |
1374 return l->data; | |
1375 return NULL; | |
1376 } | |
1377 | |
1378 static void free_workspaces(gpointer data, gpointer n) | |
1379 { | |
1380 GntWS *s = data; | |
1381 g_free(s->name); | |
1382 } | |
1383 | |
1384 void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces) | |
1385 { | |
1386 g_list_foreach(wm->workspaces, free_workspaces, NULL); | |
1387 wm->workspaces = workspaces; | |
1388 gnt_wm_switch_workspace(wm, 0); | |
1389 } | |
1390 | |
1176 static void | 1391 static void |
1177 update_window_in_list(GntWM *wm, GntWidget *wid) | 1392 update_window_in_list(GntWM *wm, GntWidget *wid) |
1178 { | 1393 { |
1179 GntTextFormatFlags flag = 0; | 1394 GntTextFormatFlags flag = 0; |
1180 | 1395 |
1181 if (wm->windows == NULL) | 1396 if (wm->windows == NULL) |
1182 return; | 1397 return; |
1183 | 1398 |
1184 if (wid == wm->ordered->data) | 1399 if (wm->cws->ordered && wid == wm->cws->ordered->data) |
1185 flag |= GNT_TEXT_FLAG_DIM; | 1400 flag |= GNT_TEXT_FLAG_DIM; |
1186 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) | 1401 else if (GNT_WIDGET_IS_FLAG_SET(wid, GNT_WIDGET_URGENT)) |
1187 flag |= GNT_TEXT_FLAG_BOLD; | 1402 flag |= GNT_TEXT_FLAG_BOLD; |
1188 | 1403 |
1189 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); | 1404 gnt_tree_set_row_flags(GNT_TREE(wm->windows->tree), wid, flag); |
1405 } | |
1406 | |
1407 static gboolean | |
1408 match_title(gpointer title, gpointer n, gpointer wid_title) | |
1409 { | |
1410 /* maybe check for regex.h? */ | |
1411 if (g_strrstr((gchar *)wid_title, (gchar *)title)) | |
1412 return TRUE; | |
1413 return FALSE; | |
1414 } | |
1415 | |
1416 static GntWS * | |
1417 new_widget_find_workspace(GntWM *wm, GntWidget *widget, gchar *wid_title) | |
1418 { | |
1419 GntWS *ret; | |
1420 const gchar *name; | |
1421 ret = g_hash_table_find(wm->title_places, match_title, wid_title); | |
1422 if (ret) | |
1423 return ret; | |
1424 name = gnt_widget_get_name(widget); | |
1425 if (name) | |
1426 ret = g_hash_table_lookup(wm->name_places, name); | |
1427 return ret ? ret : wm->cws; | |
1190 } | 1428 } |
1191 | 1429 |
1192 static void | 1430 static void |
1193 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) | 1431 gnt_wm_new_window_real(GntWM *wm, GntWidget *widget) |
1194 { | 1432 { |
1233 y = MAX(0, maxy - h); | 1471 y = MAX(0, maxy - h); |
1234 | 1472 |
1235 w = MIN(w, maxx); | 1473 w = MIN(w, maxx); |
1236 h = MIN(h, maxy); | 1474 h = MIN(h, maxy); |
1237 node->window = newwin(h + shadow, w + shadow, y, x); | 1475 node->window = newwin(h + shadow, w + shadow, y, x); |
1238 copy_win(widget, node); | 1476 gnt_wm_copy_win(widget, node); |
1239 } | 1477 } |
1240 #endif | 1478 #endif |
1241 | 1479 |
1242 node->panel = new_panel(node->window); | 1480 node->panel = new_panel(node->window); |
1243 set_panel_userptr(node->panel, node); | 1481 set_panel_userptr(node->panel, node); |
1244 | 1482 |
1245 if (!transient) { | 1483 if (!transient) { |
1484 GntWS *ws = wm->cws; | |
1246 if (node->me != wm->_list.window) { | 1485 if (node->me != wm->_list.window) { |
1247 GntWidget *w = NULL; | 1486 GntWidget *w = NULL; |
1248 | 1487 |
1249 if (wm->ordered) | 1488 if (GNT_IS_BOX(widget)) { |
1250 w = wm->ordered->data; | 1489 char *title = GNT_BOX(widget)->title; |
1251 | 1490 ws = new_widget_find_workspace(wm, widget, title); |
1252 wm->list = g_list_append(wm->list, widget); | 1491 } |
1492 | |
1493 if (ws->ordered) | |
1494 w = ws->ordered->data; | |
1495 | |
1496 node->ws = ws; | |
1497 ws->list = g_list_append(ws->list, widget); | |
1253 | 1498 |
1254 if (wm->event_stack) | 1499 if (wm->event_stack) |
1255 wm->ordered = g_list_prepend(wm->ordered, widget); | 1500 ws->ordered = g_list_prepend(ws->ordered, widget); |
1256 else | 1501 else |
1257 wm->ordered = g_list_append(wm->ordered, widget); | 1502 ws->ordered = g_list_append(ws->ordered, widget); |
1258 | 1503 |
1259 gnt_widget_set_focus(widget, TRUE); | 1504 gnt_widget_set_focus(widget, TRUE); |
1260 if (w) | 1505 if (w) |
1261 gnt_widget_set_focus(w, FALSE); | 1506 gnt_widget_set_focus(w, FALSE); |
1262 } | 1507 } |
1263 | 1508 |
1264 if (wm->event_stack || node->me == wm->_list.window) { | 1509 if (wm->event_stack || node->me == wm->_list.window) { |
1510 if (wm->cws != ws) | |
1511 gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws)); | |
1265 gnt_wm_raise_window(wm, node->me); | 1512 gnt_wm_raise_window(wm, node->me); |
1266 } else { | 1513 } else { |
1267 bottom_panel(node->panel); /* New windows should not grab focus */ | 1514 bottom_panel(node->panel); /* New windows should not grab focus */ |
1268 gnt_widget_set_urgent(node->me); | 1515 gnt_widget_set_urgent(node->me); |
1516 if (wm->cws != ws) | |
1517 gnt_ws_widget_hide(widget, wm->nodes); | |
1269 } | 1518 } |
1270 } | 1519 } |
1271 } | 1520 } |
1272 | 1521 |
1273 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) | 1522 void gnt_wm_new_window(GntWM *wm, GntWidget *widget) |
1297 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { | 1546 if (wm->windows && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
1298 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget | 1547 if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && wm->_list.window != widget |
1299 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { | 1548 && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS)) { |
1300 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, | 1549 gnt_tree_add_row_last(GNT_TREE(wm->windows->tree), widget, |
1301 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), | 1550 gnt_tree_create_row(GNT_TREE(wm->windows->tree), GNT_BOX(widget)->title), |
1302 NULL); | 1551 g_object_get_data(G_OBJECT(wm->windows->tree), "workspace") ? wm->cws : NULL); |
1303 update_window_in_list(wm, widget); | 1552 update_window_in_list(wm, widget); |
1304 } | 1553 } |
1305 } | 1554 } |
1306 | 1555 |
1307 update_screen(wm); | 1556 update_screen(wm); |
1308 draw_taskbar(wm, FALSE); | 1557 gnt_ws_draw_taskbar(wm->cws, FALSE); |
1309 } | 1558 } |
1310 | 1559 |
1311 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) | 1560 void gnt_wm_window_decorate(GntWM *wm, GntWidget *widget) |
1312 { | 1561 { |
1313 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); | 1562 g_signal_emit(wm, signals[SIG_DECORATE_WIN], 0, widget); |
1314 } | 1563 } |
1315 | 1564 |
1316 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) | 1565 void gnt_wm_window_close(GntWM *wm, GntWidget *widget) |
1317 { | 1566 { |
1567 GntWS *s; | |
1318 GntNode *node; | 1568 GntNode *node; |
1319 int pos; | 1569 int pos; |
1320 | 1570 |
1571 s = gnt_wm_widget_find_workspace(wm, widget); | |
1572 | |
1321 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) | 1573 if ((node = g_hash_table_lookup(wm->nodes, widget)) == NULL) |
1322 return; | 1574 return; |
1323 | 1575 |
1324 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); | 1576 g_signal_emit(wm, signals[SIG_CLOSE_WIN], 0, widget); |
1325 g_hash_table_remove(wm->nodes, widget); | 1577 g_hash_table_remove(wm->nodes, widget); |
1326 | 1578 |
1327 if (wm->windows) { | 1579 if (wm->windows) { |
1328 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); | 1580 gnt_tree_remove(GNT_TREE(wm->windows->tree), widget); |
1329 } | 1581 } |
1330 | 1582 |
1331 pos = g_list_index(wm->list, widget); | 1583 if (s) { |
1332 | 1584 pos = g_list_index(s->list, widget); |
1333 if (pos != -1) { | 1585 |
1334 wm->list = g_list_remove(wm->list, widget); | 1586 if (pos != -1) { |
1335 wm->ordered = g_list_remove(wm->ordered, widget); | 1587 s->list = g_list_remove(s->list, widget); |
1336 | 1588 s->ordered = g_list_remove(s->ordered, widget); |
1337 if (wm->ordered) | 1589 |
1338 gnt_wm_raise_window(wm, wm->ordered->data); | 1590 if (s->ordered && wm->cws == s) |
1591 gnt_wm_raise_window(wm, s->ordered->data); | |
1592 } | |
1339 } | 1593 } |
1340 | 1594 |
1341 update_screen(wm); | 1595 update_screen(wm); |
1342 draw_taskbar(wm, FALSE); | 1596 gnt_ws_draw_taskbar(wm->cws, FALSE); |
1343 } | 1597 } |
1344 | 1598 |
1345 time_t gnt_wm_get_idle_time() | 1599 time_t gnt_wm_get_idle_time() |
1346 { | 1600 { |
1347 return time(NULL) - last_active_time; | 1601 return time(NULL) - last_active_time; |
1358 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { | 1612 if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { |
1359 return TRUE; | 1613 return TRUE; |
1360 } | 1614 } |
1361 | 1615 |
1362 /* Do some manual checking */ | 1616 /* Do some manual checking */ |
1363 if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) { | 1617 if (wm->cws->ordered && wm->mode != GNT_KP_MODE_NORMAL) { |
1364 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; | 1618 int xmin = 0, ymin = 0, xmax = getmaxx(stdscr), ymax = getmaxy(stdscr) - 1; |
1365 int x, y, w, h; | 1619 int x, y, w, h; |
1366 GntWidget *widget = GNT_WIDGET(wm->ordered->data); | 1620 GntWidget *widget = GNT_WIDGET(wm->cws->ordered->data); |
1367 int ox, oy, ow, oh; | 1621 int ox, oy, ow, oh; |
1368 | 1622 |
1369 gnt_widget_get_position(widget, &x, &y); | 1623 gnt_widget_get_position(widget, &x, &y); |
1370 gnt_widget_get_size(widget, &w, &h); | 1624 gnt_widget_get_size(widget, &w, &h); |
1371 ox = x; oy = y; | 1625 ox = x; oy = y; |
1437 | 1691 |
1438 if (wm->menu) | 1692 if (wm->menu) |
1439 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); | 1693 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->menu), keys); |
1440 else if (wm->_list.window) | 1694 else if (wm->_list.window) |
1441 ret = gnt_widget_key_pressed(wm->_list.window, keys); | 1695 ret = gnt_widget_key_pressed(wm->_list.window, keys); |
1442 else if (wm->ordered) | 1696 else if (wm->cws->ordered) |
1443 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->ordered->data), keys); | 1697 ret = gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys); |
1444 return ret; | 1698 return ret; |
1445 } | 1699 } |
1446 | 1700 |
1447 static void | 1701 static void |
1448 gnt_wm_win_resized(GntWM *wm, GntNode *node) | 1702 gnt_wm_win_resized(GntWM *wm, GntNode *node) |
1572 | 1826 |
1573 if (!node) | 1827 if (!node) |
1574 return; | 1828 return; |
1575 | 1829 |
1576 if (widget != wm->_list.window && !GNT_IS_MENU(widget) && | 1830 if (widget != wm->_list.window && !GNT_IS_MENU(widget) && |
1577 wm->ordered->data != widget) { | 1831 wm->cws->ordered->data != widget) { |
1578 GntWidget *w = wm->ordered->data; | 1832 GntWidget *w = wm->cws->ordered->data; |
1579 wm->ordered = g_list_bring_to_front(wm->ordered, widget); | 1833 wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget); |
1580 gnt_widget_set_focus(w, FALSE); | 1834 gnt_widget_set_focus(w, FALSE); |
1581 } | 1835 } |
1582 | 1836 |
1583 gnt_widget_set_focus(widget, TRUE); | 1837 gnt_widget_set_focus(widget, TRUE); |
1584 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); | 1838 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_URGENT); |
1588 if (wm->_list.window) { | 1842 if (wm->_list.window) { |
1589 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); | 1843 GntNode *nd = g_hash_table_lookup(wm->nodes, wm->_list.window); |
1590 top_panel(nd->panel); | 1844 top_panel(nd->panel); |
1591 } | 1845 } |
1592 update_screen(wm); | 1846 update_screen(wm); |
1593 draw_taskbar(wm, FALSE); | 1847 gnt_ws_draw_taskbar(wm->cws, FALSE); |
1594 } | 1848 } |
1595 | 1849 |
1596 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) | 1850 void gnt_wm_update_window(GntWM *wm, GntWidget *widget) |
1597 { | 1851 { |
1598 GntNode *node; | 1852 GntNode *node = NULL; |
1853 GntWS *ws; | |
1599 | 1854 |
1600 while (widget->parent) | 1855 while (widget->parent) |
1601 widget = widget->parent; | 1856 widget = widget->parent; |
1602 if (!GNT_IS_MENU(widget)) | 1857 if (!GNT_IS_MENU(widget)) |
1603 gnt_box_sync_children(GNT_BOX(widget)); | 1858 gnt_box_sync_children(GNT_BOX(widget)); |
1604 | 1859 |
1860 ws = gnt_wm_widget_find_workspace(wm, widget); | |
1605 node = g_hash_table_lookup(wm->nodes, widget); | 1861 node = g_hash_table_lookup(wm->nodes, widget); |
1606 if (node == NULL) { | 1862 if (node == NULL) { |
1607 gnt_wm_new_window(wm, widget); | 1863 gnt_wm_new_window(wm, widget); |
1608 } else | 1864 } else |
1609 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); | 1865 g_signal_emit(wm, signals[SIG_UPDATE_WIN], 0, node); |
1610 | 1866 |
1611 copy_win(widget, node); | 1867 if (ws == wm->cws || GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_TRANSIENT)) { |
1612 update_screen(wm); | 1868 gnt_wm_copy_win(widget, node); |
1613 draw_taskbar(wm, FALSE); | 1869 update_screen(wm); |
1870 gnt_ws_draw_taskbar(wm->cws, FALSE); | |
1871 } else if (ws != wm->cws && GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_URGENT)) { | |
1872 if (!act || (act && !g_list_find(act, ws))) | |
1873 act = g_list_prepend(act, ws); | |
1874 update_act_msg(); | |
1875 } | |
1614 } | 1876 } |
1615 | 1877 |
1616 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) | 1878 gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) |
1617 { | 1879 { |
1618 gboolean ret = TRUE; | 1880 gboolean ret = TRUE; |