aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Slit.cc90
1 files changed, 53 insertions, 37 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index 45ec396..48345c9 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Slit.cc,v 1.12 2002/04/08 22:26:58 fluxgen Exp $ 22// $Id: Slit.cc,v 1.13 2002/05/08 14:12:28 fluxgen Exp $
23 23
24//use GNU extensions 24//use GNU extensions
25#ifndef _GNU_SOURCE 25#ifndef _GNU_SOURCE
@@ -44,7 +44,7 @@
44#include <algorithm> 44#include <algorithm>
45 45
46 46
47Slit::Slit(BScreen *scr):screen(scr), timer(this), slitmenu(this) { 47Slit::Slit(BScreen *scr):screen(scr), timer(this), slitmenu(*this) {
48 fluxbox = Fluxbox::instance(); 48 fluxbox = Fluxbox::instance();
49 49
50 on_top = screen->isSlitOnTop(); 50 on_top = screen->isSlitOnTop();
@@ -96,6 +96,10 @@ Slit::~Slit() {
96 96
97 97
98void Slit::addClient(Window w) { 98void Slit::addClient(Window w) {
99 //Can't add non existent window
100 if (w == None)
101 return;
102
99 fluxbox->grab(); 103 fluxbox->grab();
100 if (fluxbox->validateWindow(w)) { 104 if (fluxbox->validateWindow(w)) {
101 SlitClient *client = new SlitClient; 105 SlitClient *client = new SlitClient;
@@ -660,8 +664,9 @@ void Slit::timeout(void) {
660} 664}
661 665
662 666
663Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) { 667Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen),
664 slit = sl; 668slit(sl) {
669
665 I18n *i18n = I18n::instance(); 670 I18n *i18n = I18n::instance();
666 using namespace FBNLS; 671 using namespace FBNLS;
667 setLabel(i18n->getMessage( 672 setLabel(i18n->getMessage(
@@ -672,7 +677,7 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
672 directionmenu = new Directionmenu(this); 677 directionmenu = new Directionmenu(this);
673 placementmenu = new Placementmenu(this); 678 placementmenu = new Placementmenu(this);
674#ifdef XINERAMA 679#ifdef XINERAMA
675 if (slit->screen->hasXinerama()) { // only create if we need 680 if (screen()->hasXinerama()) { // only create if we need
676 headmenu = new Headmenu(this); 681 headmenu = new Headmenu(this);
677 } 682 }
678#endif // XINERAMA 683#endif // XINERAMA
@@ -688,7 +693,7 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
688 693
689#ifdef XINERAMA 694#ifdef XINERAMA
690 //TODO: NLS 695 //TODO: NLS
691 if (slit->screen->hasXinerama()) { 696 if (screen()->hasXinerama()) {
692 insert(i18n->getMessage(0, 0, "Place on Head"), headmenu); 697 insert(i18n->getMessage(0, 0, "Place on Head"), headmenu);
693 } 698 }
694#endif // XINERAMA 699#endif // XINERAMA
@@ -700,10 +705,11 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
700 CommonSet, CommonAutoHide, 705 CommonSet, CommonAutoHide,
701 "Auto hide"), 2); 706 "Auto hide"), 2);
702 707
708 setItemSelected(2, slit.isOnTop());
709 setItemSelected(3, slit.doAutoHide());
710
703 update(); 711 update();
704 712
705 if (slit->isOnTop()) setItemSelected(2, true);
706 if (slit->doAutoHide()) setItemSelected(3, true);
707} 713}
708 714
709 715
@@ -711,7 +717,7 @@ Slitmenu::~Slitmenu(void) {
711 delete directionmenu; 717 delete directionmenu;
712 delete placementmenu; 718 delete placementmenu;
713#ifdef XINERAMA 719#ifdef XINERAMA
714 if (slit->screen->hasXinerama()) { 720 if (screen()->hasXinerama()) {
715 delete headmenu; 721 delete headmenu;
716 } 722 }
717#endif // XINERAMA 723#endif // XINERAMA
@@ -726,33 +732,37 @@ void Slitmenu::itemSelected(int button, unsigned int index) {
726 switch (item->function()) { 732 switch (item->function()) {
727 case 1: // always on top 733 case 1: // always on top
728 { 734 {
729 bool change = ((slit->isOnTop()) ? false : true); 735 bool change = ((slit.isOnTop()) ? false : true);
730 slit->on_top = change; 736 slit.on_top = change;
737 screen()->saveSlitOnTop(change);
731 setItemSelected(2, change); 738 setItemSelected(2, change);
732
733 if (slit->isOnTop())
734 slit->screen->raiseWindows((Window *) 0, 0);
735 739
740 if (slit.isOnTop())
741 screen()->raiseWindows(0, 0);
742
736 break; 743 break;
737 } 744 }
738 745
739 case 2: // auto hide 746 case 2: // auto hide
740 { 747 {
741 bool change = ((slit->doAutoHide()) ? false : true); 748 bool change = (slit.doAutoHide() ? false : true);
742 slit->do_auto_hide = change; 749 slit.do_auto_hide = change;
750 screen()->saveSlitAutoHide(change);
743 setItemSelected(3, change); 751 setItemSelected(3, change);
744
745 break; 752 break;
746 } 753 }
747 } 754 }
755 //save the new configuration
756 Fluxbox::instance()->save_rc();
757 update();
748 } 758 }
749} 759}
750 760
751 761
752void Slitmenu::internal_hide(void) { 762void Slitmenu::internal_hide(void) {
753 Basemenu::internal_hide(); 763 Basemenu::internal_hide();
754 if (slit->doAutoHide()) 764 if (slit.doAutoHide())
755 slit->timeout(); 765 slit.timeout();
756} 766}
757 767
758 768
@@ -760,17 +770,20 @@ void Slitmenu::reconfigure(void) {
760 directionmenu->reconfigure(); 770 directionmenu->reconfigure();
761 placementmenu->reconfigure(); 771 placementmenu->reconfigure();
762#ifdef XINERAMA 772#ifdef XINERAMA
763 if (slit->screen->hasXinerama()) { 773 if (screen()->hasXinerama()) {
764 headmenu->reconfigure(); 774 headmenu->reconfigure();
765 } 775 }
766#endif // XINERAMA 776#endif // XINERAMA
777 setItemSelected(2, slit.isOnTop());
778 setItemSelected(3, slit.doAutoHide());
767 779
768 Basemenu::reconfigure(); 780 Basemenu::reconfigure();
769} 781}
770 782
771 783
772Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm) : Basemenu(sm->slit->screen) { 784Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm) : Basemenu(sm->screen()),
773 slitmenu = sm; 785slitmenu(sm) {
786
774 I18n *i18n = I18n::instance(); 787 I18n *i18n = I18n::instance();
775 using namespace FBNLS; 788 using namespace FBNLS;
776 setLabel(i18n->getMessage( 789 setLabel(i18n->getMessage(
@@ -789,7 +802,7 @@ Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm) : Basemenu(sm->slit->screen
789 802
790 update(); 803 update();
791 804
792 if (sm->slit->screen->getSlitDirection() == Slit::HORIZONTAL) 805 if (screen()->getSlitDirection() == Slit::HORIZONTAL)
793 setItemSelected(0, true); 806 setItemSelected(0, true);
794 else 807 else
795 setItemSelected(1, true); 808 setItemSelected(1, true);
@@ -801,7 +814,7 @@ void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) {
801 BasemenuItem *item = find(index); 814 BasemenuItem *item = find(index);
802 if (! item) return; 815 if (! item) return;
803 816
804 slitmenu->slit->screen->saveSlitDirection(item->function()); 817 screen()->saveSlitDirection(item->function());
805 818
806 if (item->function() == Slit::HORIZONTAL) { 819 if (item->function() == Slit::HORIZONTAL) {
807 setItemSelected(0, true); 820 setItemSelected(0, true);
@@ -810,15 +823,16 @@ void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) {
810 setItemSelected(0, false); 823 setItemSelected(0, false);
811 setItemSelected(1, true); 824 setItemSelected(1, true);
812 } 825 }
813 826 Fluxbox::instance()->save_rc();
814 hide(); 827 hide();
815 slitmenu->slit->reconfigure(); 828 slitmenu->slit.reconfigure();
816 } 829 }
817} 830}
818 831
819 832
820Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm) : Basemenu(sm->slit->screen) { 833Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm) : Basemenu(sm->screen()),
821 slitmenu = sm; 834slitmenu(sm) {
835
822 I18n *i18n = I18n::instance(); 836 I18n *i18n = I18n::instance();
823 using namespace FBNLS; 837 using namespace FBNLS;
824 setLabel(i18n->getMessage( 838 setLabel(i18n->getMessage(
@@ -871,24 +885,25 @@ void Slitmenu::Placementmenu::itemSelected(int button, unsigned int index) {
871 if (! item) return; 885 if (! item) return;
872 886
873 if (item->function()) { 887 if (item->function()) {
874 slitmenu->slit->screen->saveSlitPlacement(item->function()); 888 screen()->saveSlitPlacement(item->function());
875 hide(); 889 hide();
876 slitmenu->slit->reconfigure(); 890 slitmenu->slit.reconfigure();
891 Fluxbox::instance()->save_rc();
877 } 892 }
878 } 893 }
879} 894}
880 895
881#ifdef XINERAMA 896#ifdef XINERAMA
882 897
883Slitmenu::Headmenu::Headmenu(Slitmenu *sm) 898Slitmenu::Headmenu::Headmenu(Slitmenu *sm): Basemenu(sm->screen()),
884 : Basemenu(sm->slit->screen) { 899slitmenu(sm) {
885 slitmenu = sm; 900
886 I18n *i18n = I18n::instance(); 901 I18n *i18n = I18n::instance();
887 902
888 setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS 903 setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS
889 setInternalMenu(); 904 setInternalMenu();
890 905
891 int numHeads = slitmenu->slit->screen->getNumHeads(); 906 int numHeads = screen()->getNumHeads();
892 // fill menu with head entries 907 // fill menu with head entries
893 for (int i = 0; i < numHeads; i++) { 908 for (int i = 0; i < numHeads; i++) {
894 char headName[32]; 909 char headName[32];
@@ -905,9 +920,10 @@ void Slitmenu::Headmenu::itemSelected(int button, unsigned int index) {
905 if (! item) 920 if (! item)
906 return; 921 return;
907 922
908 slitmenu->slit->screen->saveSlitOnHead(item->function()); 923 screen()->saveSlitOnHead(item->function());
909 hide(); 924 hide();
910 slitmenu->slit->reconfigure(); 925 slitmenu->slit.reconfigure();
926 Fluxbox::instance()->save_rc();
911 } 927 }
912} 928}
913 929