diff options
author | markt <markt> | 2007-10-13 21:51:37 (GMT) |
---|---|---|
committer | markt <markt> | 2007-10-13 21:51:37 (GMT) |
commit | a59428d67a95a9df16554962f0a6257d6378328a (patch) | |
tree | f856ed9300c34f7a17d499f22d895610cfbc08e5 /src/IconbarTool.cc | |
parent | 41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff) | |
download | fluxbox_paul-a59428d67a95a9df16554962f0a6257d6378328a.zip fluxbox_paul-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2 |
merged changes from pre-devel
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r-- | src/IconbarTool.cc | 378 |
1 files changed, 102 insertions, 276 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 3509a0c..bbd867b 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #include "IconbarTool.hh" | 25 | #include "IconbarTool.hh" |
26 | 26 | ||
27 | #include "fluxbox.hh" | ||
28 | #include "WindowCmd.hh" | ||
27 | #include "Screen.hh" | 29 | #include "Screen.hh" |
28 | #include "IconbarTheme.hh" | 30 | #include "IconbarTheme.hh" |
29 | #include "Window.hh" | 31 | #include "Window.hh" |
@@ -86,40 +88,6 @@ void FbTk::Resource<IconbarTool::Mode>::setFromString(const char *strval) { | |||
86 | } | 88 | } |
87 | 89 | ||
88 | template<> | 90 | template<> |
89 | void FbTk::Resource<IconbarTool::WheelMode>::setDefaultValue() { | ||
90 | m_value = IconbarTool::SCREEN; | ||
91 | } | ||
92 | |||
93 | |||
94 | template<> | ||
95 | void FbTk::Resource<IconbarTool::WheelMode>::setFromString(const char* strval) { | ||
96 | if (strncasecmp(strval, "off", strlen("off")) == 0) | ||
97 | m_value = IconbarTool::OFF; | ||
98 | else if (strncasecmp(strval, "on", strlen("on")) == 0) | ||
99 | m_value = IconbarTool::ON; | ||
100 | else if (strncasecmp(strval, "screen", strlen("screen")) == 0) | ||
101 | m_value = IconbarTool::SCREEN; | ||
102 | else | ||
103 | setDefaultValue(); | ||
104 | } | ||
105 | |||
106 | |||
107 | template<> | ||
108 | string FbTk::Resource<IconbarTool::WheelMode>::getString() const { | ||
109 | switch(m_value) { | ||
110 | case IconbarTool::ON: | ||
111 | return string("On"); | ||
112 | break; | ||
113 | case IconbarTool::SCREEN: | ||
114 | return string("Screen"); | ||
115 | break; | ||
116 | case IconbarTool::OFF: | ||
117 | default: | ||
118 | return string("Off"); | ||
119 | }; | ||
120 | } | ||
121 | |||
122 | template<> | ||
123 | void FbTk::Resource<Container::Alignment>::setDefaultValue() { | 91 | void FbTk::Resource<Container::Alignment>::setDefaultValue() { |
124 | m_value = Container::RELATIVE; | 92 | m_value = Container::RELATIVE; |
125 | } | 93 | } |
@@ -290,53 +258,68 @@ void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { | |||
290 | } | 258 | } |
291 | 259 | ||
292 | inline bool checkAddWindow(IconbarTool::Mode mode, const FluxboxWindow &win) { | 260 | inline bool checkAddWindow(IconbarTool::Mode mode, const FluxboxWindow &win) { |
293 | bool ret_val = false; | 261 | if (win.isIconHidden() || mode == IconbarTool::NONE) |
294 | // just add the icons that are on the this workspace | 262 | return false; |
295 | switch (mode) { | ||
296 | case IconbarTool::NONE: | ||
297 | break; | ||
298 | case IconbarTool::ICONS: | ||
299 | if (win.isIconic()) | ||
300 | ret_val = true; | ||
301 | break; | ||
302 | case IconbarTool::NOICONS: | ||
303 | if (!win.isIconic()) | ||
304 | ret_val = true; | ||
305 | break; | ||
306 | case IconbarTool::WORKSPACEICONS: | ||
307 | if(win.workspaceNumber() == win.screen().currentWorkspaceID() && | ||
308 | win.isIconic()) | ||
309 | ret_val = true; | ||
310 | break; | ||
311 | case IconbarTool::WORKSPACENOICONS: | ||
312 | if (win.isIconic()) | ||
313 | break; | ||
314 | case IconbarTool::WORKSPACE: | ||
315 | if (win.workspaceNumber() == win.screen().currentWorkspaceID()) | ||
316 | ret_val = true; | ||
317 | break; | ||
318 | case IconbarTool::ALLWINDOWS: | ||
319 | ret_val = true; | ||
320 | break; | ||
321 | } | ||
322 | 263 | ||
323 | if (win.isIconHidden()) | 264 | if ((mode == IconbarTool::ICONS || mode == IconbarTool::WORKSPACEICONS) && |
324 | ret_val = false; | 265 | !win.isIconic()) |
266 | return false; | ||
325 | 267 | ||
326 | return ret_val; | 268 | if ((mode == IconbarTool::NOICONS || mode == IconbarTool::WORKSPACENOICONS) |
327 | } | 269 | && win.isIconic()) |
270 | return false; | ||
328 | 271 | ||
329 | void removeDuplicate(const IconbarTool::IconList &iconlist, list<FluxboxWindow *> &windowlist) { | 272 | if ((mode == IconbarTool::WORKSPACE || mode == IconbarTool::WORKSPACEICONS |
330 | IconbarTool::IconList::const_iterator icon_it = iconlist.begin(); | 273 | || mode == IconbarTool::WORKSPACENOICONS) && |
331 | IconbarTool::IconList::const_iterator icon_it_end = iconlist.end(); | 274 | win.workspaceNumber() != win.screen().currentWorkspaceID()) |
332 | list<FluxboxWindow *>::iterator remove_it = windowlist.end(); | 275 | return false; |
333 | for (; icon_it != icon_it_end; ++icon_it) | ||
334 | remove_it = remove(windowlist.begin(), remove_it, &(*icon_it)->win()); | ||
335 | 276 | ||
336 | // remove already existing windows | 277 | return true; |
337 | windowlist.erase(remove_it, windowlist.end()); | ||
338 | } | 278 | } |
339 | 279 | ||
280 | typedef FbTk::RefCount<FbTk::Command> RefCmd; | ||
281 | |||
282 | class ShowMenu: public FbTk::Command { | ||
283 | public: | ||
284 | explicit ShowMenu(FluxboxWindow &win):m_win(win) { } | ||
285 | void execute() { | ||
286 | // hide the menu if it's already showing for this FluxboxWindow | ||
287 | if (m_win.menu().isVisible() && WindowCmd<void>::window() == &m_win) { | ||
288 | m_win.screen().hideMenus(); | ||
289 | return; | ||
290 | } | ||
291 | m_win.screen().hideMenus(); | ||
292 | // get last button pos | ||
293 | const XEvent &event = Fluxbox::instance()->lastEvent(); | ||
294 | int x = event.xbutton.x_root - (m_win.menu().width() / 2); | ||
295 | int y = event.xbutton.y_root - (m_win.menu().height() / 2); | ||
296 | m_win.showMenu(x, y); | ||
297 | } | ||
298 | private: | ||
299 | FluxboxWindow &m_win; | ||
300 | }; | ||
301 | |||
302 | class FocusCommand: public FbTk::Command { | ||
303 | public: | ||
304 | explicit FocusCommand(Focusable &win): m_win(win) { } | ||
305 | void execute() { | ||
306 | // this needs to be a local variable, as this object could be destroyed | ||
307 | // if the workspace is changed. | ||
308 | FluxboxWindow *fbwin = m_win.fbwindow(); | ||
309 | if (!fbwin) | ||
310 | return; | ||
311 | if (m_win.isFocused()) | ||
312 | fbwin->iconify(); | ||
313 | else { | ||
314 | m_win.focus(); | ||
315 | fbwin->raise(); | ||
316 | } | ||
317 | } | ||
318 | |||
319 | private: | ||
320 | Focusable &m_win; | ||
321 | }; | ||
322 | |||
340 | }; // end anonymous namespace | 323 | }; // end anonymous namespace |
341 | 324 | ||
342 | IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen, | 325 | IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen, |
@@ -345,16 +328,9 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
345 | m_screen(screen), | 328 | m_screen(screen), |
346 | m_icon_container(parent), | 329 | m_icon_container(parent), |
347 | m_theme(theme), | 330 | m_theme(theme), |
348 | m_focused_pm( screen.imageControl() ), | ||
349 | m_unfocused_pm( screen.imageControl() ), | ||
350 | m_focused_err_pm( screen.imageControl() ), | ||
351 | m_unfocused_err_pm( screen.imageControl() ), | ||
352 | m_empty_pm( screen.imageControl() ), | 331 | m_empty_pm( screen.imageControl() ), |
353 | m_rc_mode(screen.resourceManager(), WORKSPACE, | 332 | m_rc_mode(screen.resourceManager(), WORKSPACE, |
354 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), | 333 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), |
355 | m_wheel_mode(screen.resourceManager(), OFF, | ||
356 | screen.name() + ".iconbar.wheelMode", | ||
357 | screen.name() + ".iconbar.WheelMode"), | ||
358 | m_rc_alignment(screen.resourceManager(), Container::LEFT, | 334 | m_rc_alignment(screen.resourceManager(), Container::LEFT, |
359 | screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), | 335 | screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), |
360 | m_rc_client_width(screen.resourceManager(), 70, | 336 | m_rc_client_width(screen.resourceManager(), 70, |
@@ -392,15 +368,6 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
392 | screen.clientListSig().attach(this); | 368 | screen.clientListSig().attach(this); |
393 | screen.iconListSig().attach(this); | 369 | screen.iconListSig().attach(this); |
394 | screen.currentWorkspaceSig().attach(this); | 370 | screen.currentWorkspaceSig().attach(this); |
395 | // setup focus timer | ||
396 | |||
397 | FbTk::RefCount<FbTk::Command> timer_cmd(new FbTk::SimpleCommand<IconbarTool>(*this, &IconbarTool::timedRender)); | ||
398 | timeval to; | ||
399 | to.tv_sec = 0; | ||
400 | to.tv_usec = 1; // so it updates next event round | ||
401 | m_focus_timer.setCommand(timer_cmd); | ||
402 | m_focus_timer.setTimeout(to); | ||
403 | m_focus_timer.fireOnce(true); | ||
404 | 371 | ||
405 | } | 372 | } |
406 | 373 | ||
@@ -506,18 +473,10 @@ void IconbarTool::update(FbTk::Subject *subj) { | |||
506 | if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { | 473 | if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { |
507 | // we handle everything except die signal here | 474 | // we handle everything except die signal here |
508 | FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj); | 475 | FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj); |
509 | if (subj == &(winsubj->win().focusSig())) { | 476 | if (subj == &(winsubj->win().workspaceSig())) { |
510 | // start focus timer, so we can update without flicker | ||
511 | m_focus_timer.start(); | ||
512 | |||
513 | return; | ||
514 | } else if (subj == &(winsubj->win().workspaceSig())) { | ||
515 | // we can ignore this signal if we're in ALLWINDOWS mode | 477 | // we can ignore this signal if we're in ALLWINDOWS mode |
516 | // unless the window was focused and has nothing to revert to | 478 | if (mode() == ALLWINDOWS || mode() == ICONS || mode() == NOICONS) |
517 | if (mode() == ALLWINDOWS || mode() == ICONS || mode() == NOICONS) { | ||
518 | m_focus_timer.start(); | ||
519 | return; | 479 | return; |
520 | } | ||
521 | 480 | ||
522 | // workspace changed for this window, and if it's not on current workspace we remove it | 481 | // workspace changed for this window, and if it's not on current workspace we remove it |
523 | if (m_screen.currentWorkspaceID() != winsubj->win().workspaceNumber()) { | 482 | if (m_screen.currentWorkspaceID() != winsubj->win().workspaceNumber()) { |
@@ -525,30 +484,24 @@ void IconbarTool::update(FbTk::Subject *subj) { | |||
525 | renderTheme(); | 484 | renderTheme(); |
526 | } | 485 | } |
527 | return; | 486 | return; |
528 | } else if (subj == &(winsubj->win().dieSig())) { // die sig | ||
529 | removeWindow(winsubj->win()); | ||
530 | renderTheme(); | ||
531 | return; // we don't need to update the entire list | ||
532 | } else if (subj == &(winsubj->win().stateSig())) { | 487 | } else if (subj == &(winsubj->win().stateSig())) { |
533 | if (!checkAddWindow(mode(), winsubj->win())) { | 488 | if (!checkAddWindow(mode(), winsubj->win())) { |
534 | removeWindow(winsubj->win()); | 489 | removeWindow(winsubj->win()); |
535 | renderTheme(); | 490 | renderTheme(); |
536 | } | 491 | } |
537 | |||
538 | return; | 492 | return; |
539 | 493 | ||
540 | } else if (subj == &(winsubj->win().attentionSig())) { | ||
541 | // render with titlebar focus, on attention | ||
542 | IconButton *button = findButton(winsubj->win()); | ||
543 | if (button) { | ||
544 | renderButton(*button, true, | ||
545 | winsubj->win().getAttentionState()); | ||
546 | } | ||
547 | return; | ||
548 | } else { | 494 | } else { |
549 | // signal not handled | 495 | // signal not handled |
550 | return; | 496 | return; |
551 | } | 497 | } |
498 | } else if (subj != 0 && typeid(*subj) == typeid(Focusable::FocusSubject)) { | ||
499 | Focusable::FocusSubject *winsubj = static_cast<Focusable::FocusSubject *>(subj); | ||
500 | if (subj == &(winsubj->win().dieSig())) { // die sig | ||
501 | removeWindow(winsubj->win()); | ||
502 | renderTheme(); | ||
503 | return; // we don't need to update the entire list | ||
504 | } | ||
552 | } | 505 | } |
553 | 506 | ||
554 | bool remove_all = false; // if we should readd all windows | 507 | bool remove_all = false; // if we should readd all windows |
@@ -587,7 +540,7 @@ void IconbarTool::update(FbTk::Subject *subj) { | |||
587 | renderTheme(); | 540 | renderTheme(); |
588 | } | 541 | } |
589 | 542 | ||
590 | IconButton *IconbarTool::findButton(FluxboxWindow &win) { | 543 | IconButton *IconbarTool::findButton(Focusable &win) { |
591 | 544 | ||
592 | IconList::iterator icon_it = m_icon_list.begin(); | 545 | IconList::iterator icon_it = m_icon_list.begin(); |
593 | IconList::iterator icon_it_end = m_icon_list.end(); | 546 | IconList::iterator icon_it_end = m_icon_list.end(); |
@@ -598,25 +551,14 @@ IconButton *IconbarTool::findButton(FluxboxWindow &win) { | |||
598 | 551 | ||
599 | return 0; | 552 | return 0; |
600 | } | 553 | } |
601 | /* | 554 | |
602 | void IconbarTool::renderWindow(FluxboxWindow &win) { | ||
603 | IconButton *button = findButton(win); | ||
604 | if (button == 0) | ||
605 | return; | ||
606 | renderButton(*button); | ||
607 | } | ||
608 | */ | ||
609 | void IconbarTool::updateSizing() { | 555 | void IconbarTool::updateSizing() { |
610 | m_icon_container.setBorderWidth(m_theme.border().width()); | 556 | m_icon_container.setBorderWidth(m_theme.border().width()); |
611 | 557 | ||
612 | IconList::iterator icon_it = m_icon_list.begin(); | 558 | IconList::iterator icon_it = m_icon_list.begin(); |
613 | const IconList::iterator icon_it_end = m_icon_list.end(); | 559 | const IconList::iterator icon_it_end = m_icon_list.end(); |
614 | for (; icon_it != icon_it_end; ++icon_it) { | 560 | for (; icon_it != icon_it_end; ++icon_it) |
615 | if ((*icon_it)->win().isFocused()) | 561 | (*icon_it)->reconfigTheme(); |
616 | (*icon_it)->setBorderWidth(m_theme.focusedBorder().width()); | ||
617 | else // unfocused | ||
618 | (*icon_it)->setBorderWidth(m_theme.unfocusedBorder().width()); | ||
619 | } | ||
620 | 562 | ||
621 | } | 563 | } |
622 | 564 | ||
@@ -631,127 +573,33 @@ void IconbarTool::renderTheme() { | |||
631 | // update button sizes before we get max width per client! | 573 | // update button sizes before we get max width per client! |
632 | updateSizing(); | 574 | updateSizing(); |
633 | 575 | ||
634 | unsigned int icon_width = 0, icon_height = 0; | ||
635 | unsigned int icon_width_off=0, icon_height_off=0; | ||
636 | |||
637 | if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) { | ||
638 | icon_width = m_icon_container.maxWidthPerClient(); | ||
639 | icon_height = m_icon_container.height(); | ||
640 | icon_width_off = 1; | ||
641 | } else { | ||
642 | icon_width = m_icon_container.width(); | ||
643 | icon_height = m_icon_container.maxWidthPerClient(); | ||
644 | icon_height_off = 1; | ||
645 | } | ||
646 | |||
647 | if (!m_theme.focusedTexture().usePixmap()) { | ||
648 | m_focused_pm.reset( 0 ); | ||
649 | m_focused_err_pm.reset( 0 ); | ||
650 | } else { | ||
651 | m_focused_pm.reset( m_screen.imageControl(). | ||
652 | renderImage(icon_width, icon_height, | ||
653 | m_theme.focusedTexture(), orientation()) ); | ||
654 | m_focused_err_pm.reset( m_screen.imageControl(). | ||
655 | renderImage(icon_width + icon_width_off, | ||
656 | icon_height + icon_height_off, | ||
657 | m_theme.focusedTexture(), orientation()) ); | ||
658 | } | ||
659 | |||
660 | if (!m_theme.unfocusedTexture().usePixmap()) { | ||
661 | m_unfocused_pm.reset( 0 ); | ||
662 | m_unfocused_err_pm.reset( 0 ); | ||
663 | } else { | ||
664 | m_unfocused_pm.reset( m_screen.imageControl(). | ||
665 | renderImage(icon_width, icon_height, | ||
666 | m_theme.unfocusedTexture(), orientation()) ); | ||
667 | m_unfocused_err_pm.reset( m_screen.imageControl(). | ||
668 | renderImage(icon_width+icon_width_off, | ||
669 | icon_height+icon_height_off, | ||
670 | m_theme.unfocusedTexture(), orientation()) ); | ||
671 | } | ||
672 | |||
673 | // if we dont have any icons then we should render empty texture | 576 | // if we dont have any icons then we should render empty texture |
674 | if (!m_theme.emptyTexture().usePixmap()) { | 577 | if (!m_theme.emptyTexture().usePixmap()) { |
675 | m_empty_pm.reset( 0 ); | 578 | m_empty_pm.reset( 0 ); |
676 | m_icon_container.setBackgroundColor(m_theme.emptyTexture().color()); | 579 | m_icon_container.setBackgroundColor(m_theme.emptyTexture().color()); |
677 | } else { | 580 | } else { |
678 | m_empty_pm.reset( m_screen.imageControl(). | 581 | m_empty_pm.reset(m_screen.imageControl(). |
679 | renderImage(m_icon_container.width(), m_icon_container.height(), | 582 | renderImage(m_icon_container.width(), |
680 | m_theme.emptyTexture(), orientation()) ); | 583 | m_icon_container.height(), |
584 | m_theme.emptyTexture(), orientation())); | ||
681 | m_icon_container.setBackgroundPixmap(m_empty_pm); | 585 | m_icon_container.setBackgroundPixmap(m_empty_pm); |
682 | } | 586 | } |
683 | 587 | ||
684 | // set to zero so its consistent and not ugly | ||
685 | m_icon_container.setBorderWidth(m_theme.border().width()); | ||
686 | m_icon_container.setBorderColor(m_theme.border().color()); | ||
687 | m_icon_container.setAlpha(m_alpha); | 588 | m_icon_container.setAlpha(m_alpha); |
688 | 589 | ||
689 | // update buttons | 590 | // update buttons |
690 | IconList::iterator icon_it = m_icon_list.begin(); | 591 | IconList::iterator icon_it = m_icon_list.begin(); |
691 | const IconList::iterator icon_it_end = m_icon_list.end(); | 592 | const IconList::iterator icon_it_end = m_icon_list.end(); |
692 | for (; icon_it != icon_it_end; ++icon_it) { | 593 | for (; icon_it != icon_it_end; ++icon_it) |
693 | renderButton(*(*icon_it)); | 594 | renderButton(*(*icon_it)); |
694 | } | 595 | |
695 | } | 596 | } |
696 | 597 | ||
697 | void IconbarTool::renderButton(IconButton &button, bool clear, | 598 | void IconbarTool::renderButton(IconButton &button, bool clear) { |
698 | int focusOption) { | ||
699 | 599 | ||
700 | button.setPixmap(*m_rc_use_pixmap); | 600 | button.setPixmap(*m_rc_use_pixmap); |
701 | button.setAlpha(m_alpha); | ||
702 | button.setTextPadding(*m_rc_client_padding); | 601 | button.setTextPadding(*m_rc_client_padding); |
703 | 602 | button.reconfigTheme(); | |
704 | // The last button is always the regular width | ||
705 | bool wider_button = false; | ||
706 | if (!m_icon_container.empty()) { | ||
707 | if (button.orientation() == FbTk::ROT0 || button.orientation() == FbTk::ROT180) | ||
708 | wider_button = button.width() != m_icon_container.back()->width(); | ||
709 | else | ||
710 | wider_button = button.height() != m_icon_container.back()->height(); | ||
711 | // wider_button = (button.width() != m_icon_container.maxWidthPerClient() || // height to cover both orients | ||
712 | |||
713 | // button.height() != m_icon_container.back()->height()); | ||
714 | } | ||
715 | |||
716 | if (focusOption == 1 || | ||
717 | (focusOption == -1 && | ||
718 | button.win().isFocused())) { | ||
719 | |||
720 | // focused texture | ||
721 | if (button.win().isFocused()) | ||
722 | m_icon_container.setSelected(m_icon_container.find(&button)); | ||
723 | |||
724 | button.setGC(m_theme.focusedText().textGC()); | ||
725 | button.setFont(m_theme.focusedText().font()); | ||
726 | button.setJustify(m_theme.focusedText().justify()); | ||
727 | button.setBorderWidth(m_theme.focusedBorder().width()); | ||
728 | button.setBorderColor(m_theme.focusedBorder().color()); | ||
729 | |||
730 | if (!wider_button && m_focused_pm != 0) | ||
731 | button.setBackgroundPixmap(m_focused_pm); | ||
732 | else if (wider_button && m_focused_err_pm != 0) | ||
733 | button.setBackgroundPixmap(m_focused_err_pm); | ||
734 | else | ||
735 | button.setBackgroundColor(m_theme.focusedTexture().color()); | ||
736 | |||
737 | } else { // unfocused | ||
738 | if (m_icon_container.selected() == &button) | ||
739 | m_icon_container.setSelected(-1); | ||
740 | |||
741 | button.setGC(m_theme.unfocusedText().textGC()); | ||
742 | button.setFont(m_theme.unfocusedText().font()); | ||
743 | button.setJustify(m_theme.unfocusedText().justify()); | ||
744 | button.setBorderWidth(m_theme.unfocusedBorder().width()); | ||
745 | button.setBorderColor(m_theme.unfocusedBorder().color()); | ||
746 | |||
747 | if (!wider_button && m_unfocused_pm != 0) | ||
748 | button.setBackgroundPixmap(m_unfocused_pm); | ||
749 | else if (wider_button && m_unfocused_err_pm != 0) | ||
750 | button.setBackgroundPixmap(m_unfocused_err_pm); | ||
751 | else | ||
752 | button.setBackgroundColor(m_theme.unfocusedTexture().color()); | ||
753 | } | ||
754 | |||
755 | if (clear) | 603 | if (clear) |
756 | button.clear(); // the clear also updates transparent | 604 | button.clear(); // the clear also updates transparent |
757 | } | 605 | } |
@@ -764,7 +612,7 @@ void IconbarTool::deleteIcons() { | |||
764 | } | 612 | } |
765 | } | 613 | } |
766 | 614 | ||
767 | void IconbarTool::removeWindow(FluxboxWindow &win) { | 615 | void IconbarTool::removeWindow(Focusable &win) { |
768 | // got window die signal, lets find and remove the window | 616 | // got window die signal, lets find and remove the window |
769 | IconList::iterator it = m_icon_list.begin(); | 617 | IconList::iterator it = m_icon_list.begin(); |
770 | IconList::iterator it_end = m_icon_list.end(); | 618 | IconList::iterator it_end = m_icon_list.end(); |
@@ -780,12 +628,11 @@ void IconbarTool::removeWindow(FluxboxWindow &win) { | |||
780 | cerr<<"IconbarTool::"<<__FUNCTION__<<"( 0x"<<&win<<" title = "<<win.title()<<") found!"<<endl; | 628 | cerr<<"IconbarTool::"<<__FUNCTION__<<"( 0x"<<&win<<" title = "<<win.title()<<") found!"<<endl; |
781 | #endif // DEBUG | 629 | #endif // DEBUG |
782 | // detach from all signals | 630 | // detach from all signals |
783 | win.focusSig().detach(this); | ||
784 | win.dieSig().detach(this); | 631 | win.dieSig().detach(this); |
785 | win.workspaceSig().detach(this); | 632 | if (win.fbwindow()) { |
786 | win.stateSig().detach(this); | 633 | win.fbwindow()->workspaceSig().detach(this); |
787 | win.titleSig().detach(this); | 634 | win.fbwindow()->stateSig().detach(this); |
788 | 635 | } | |
789 | 636 | ||
790 | // remove from list and render theme again | 637 | // remove from list and render theme again |
791 | IconButton *button = *it; | 638 | IconButton *button = *it; |
@@ -797,46 +644,46 @@ void IconbarTool::removeWindow(FluxboxWindow &win) { | |||
797 | 644 | ||
798 | } | 645 | } |
799 | 646 | ||
800 | void IconbarTool::addWindow(FluxboxWindow &win) { | 647 | void IconbarTool::addWindow(Focusable &win) { |
801 | // we just want windows that has clients | 648 | // we just want windows that have clients |
802 | if (win.clientList().empty() || win.isIconHidden() ) | 649 | FluxboxWindow *fbwin = win.fbwindow(); |
650 | if (!fbwin || fbwin->clientList().empty() || fbwin->isIconHidden()) | ||
803 | return; | 651 | return; |
804 | #ifdef DEBUG | 652 | #ifdef DEBUG |
805 | cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl; | 653 | cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl; |
806 | #endif // DEBUG | 654 | #endif // DEBUG |
807 | IconButton *button = new IconButton(*this, | 655 | IconButton *button = new IconButton(m_icon_container, m_theme, win); |
808 | m_icon_container, | ||
809 | m_theme.focusedText().font(), | ||
810 | win); | ||
811 | 656 | ||
657 | RefCmd focus_cmd(new ::FocusCommand(win)); | ||
658 | RefCmd menu_cmd(new ::ShowMenu(*fbwin)); | ||
659 | button->setOnClick(focus_cmd, 1); | ||
660 | button->setOnClick(menu_cmd, 3); | ||
812 | 661 | ||
813 | renderButton(*button, false); // update the attributes, but don't clear it | 662 | renderButton(*button, false); // update the attributes, but don't clear it |
814 | m_icon_container.insertItem(button); | 663 | m_icon_container.insertItem(button); |
815 | m_icon_list.push_back(button); | 664 | m_icon_list.push_back(button); |
816 | 665 | ||
817 | // dont forget to detach signal in removeWindow | 666 | // dont forget to detach signal in removeWindow |
818 | win.focusSig().attach(this); | ||
819 | win.dieSig().attach(this); | 667 | win.dieSig().attach(this); |
820 | win.workspaceSig().attach(this); | 668 | fbwin->workspaceSig().attach(this); |
821 | win.stateSig().attach(this); | 669 | fbwin->stateSig().attach(this); |
822 | win.attentionSig().attach(this); | ||
823 | } | 670 | } |
824 | 671 | ||
825 | void IconbarTool::updateList() { | 672 | void IconbarTool::updateList() { |
826 | list<WinClient *> ordered_list = | 673 | list<Focusable *> ordered_list = |
827 | m_screen.focusControl().creationOrderList(); | 674 | m_screen.focusControl().creationOrderWinList(); |
828 | list<WinClient *>::iterator it = ordered_list.begin(); | 675 | list<Focusable *>::iterator it = ordered_list.begin(); |
829 | list<WinClient *>::iterator it_end = ordered_list.end(); | 676 | list<Focusable *>::iterator it_end = ordered_list.end(); |
830 | for (; it != it_end; ++it) { | 677 | for (; it != it_end; ++it) { |
831 | if ((*it)->fbwindow() && checkAddWindow(mode(), *(*it)->fbwindow()) && | 678 | if ((*it)->fbwindow() && checkAddWindow(mode(), *(*it)->fbwindow()) && |
832 | !checkDuplicate(*(*it)->fbwindow())) | 679 | !checkDuplicate(**it)) |
833 | addWindow(*(*it)->fbwindow()); | 680 | addWindow(**it); |
834 | } | 681 | } |
835 | 682 | ||
836 | renderTheme(); | 683 | renderTheme(); |
837 | } | 684 | } |
838 | 685 | ||
839 | bool IconbarTool::checkDuplicate(FluxboxWindow &win) { | 686 | bool IconbarTool::checkDuplicate(Focusable &win) { |
840 | IconList::iterator it = m_icon_list.begin(); | 687 | IconList::iterator it = m_icon_list.begin(); |
841 | IconList::iterator it_end = m_icon_list.end(); | 688 | IconList::iterator it_end = m_icon_list.end(); |
842 | for (; it != it_end; ++it) { | 689 | for (; it != it_end; ++it) { |
@@ -846,27 +693,6 @@ bool IconbarTool::checkDuplicate(FluxboxWindow &win) { | |||
846 | return false; | 693 | return false; |
847 | } | 694 | } |
848 | 695 | ||
849 | void IconbarTool::timedRender() { | ||
850 | WinClient *client = FocusControl::focusedWindow(); | ||
851 | IconButton *current_button = static_cast<IconButton *>(m_icon_container.selected()); | ||
852 | |||
853 | if (client == 0 || client->fbwindow() == 0) { | ||
854 | if (current_button != 0) | ||
855 | renderButton(*current_button); | ||
856 | return; | ||
857 | } | ||
858 | |||
859 | IconButton *button = findButton(*client->fbwindow()); | ||
860 | // if old window is the same as the new focused window then ignore this render | ||
861 | // else render old client and new client | ||
862 | if (button == current_button) | ||
863 | return; | ||
864 | if (button != 0) | ||
865 | renderButton(*button); | ||
866 | if (current_button != 0) | ||
867 | renderButton(*current_button); | ||
868 | } | ||
869 | |||
870 | void IconbarTool::setOrientation(FbTk::Orientation orient) { | 696 | void IconbarTool::setOrientation(FbTk::Orientation orient) { |
871 | m_icon_container.setOrientation(orient); | 697 | m_icon_container.setOrientation(orient); |
872 | ToolbarItem::setOrientation(orient); | 698 | ToolbarItem::setOrientation(orient); |