diff options
author | rathnor <rathnor> | 2003-02-22 15:10:43 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-02-22 15:10:43 (GMT) |
commit | cc2f023a22db212b4097d7756379bb6b9e866b11 (patch) | |
tree | 33cd8f790e760965960d54406250dd73ab0aec93 /src/fluxbox.cc | |
parent | 7cf8c0863e6dd07e1023207964605de12f7d0a3c (diff) | |
download | fluxbox-cc2f023a22db212b4097d7756379bb6b9e866b11.zip fluxbox-cc2f023a22db212b4097d7756379bb6b9e866b11.tar.bz2 |
fix focus models for new event handler and Resource setup
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 120 |
1 files changed, 43 insertions, 77 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index be41df1..1cb66a9 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.cc,v 1.97 2003/02/18 15:11:12 rathnor Exp $ | 25 | // $Id: fluxbox.cc,v 1.98 2003/02/22 15:10:43 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "fluxbox.hh" | 28 | #include "fluxbox.hh" |
@@ -143,25 +143,6 @@ char *basename (char *s) { | |||
143 | #define RC_PATH "fluxbox" | 143 | #define RC_PATH "fluxbox" |
144 | #define RC_INIT_FILE "init" | 144 | #define RC_INIT_FILE "init" |
145 | 145 | ||
146 | |||
147 | // X event scanner for enter/leave notifies - adapted from twm | ||
148 | typedef struct scanargs { | ||
149 | Window w; | ||
150 | Bool leave, inferior, enter; | ||
151 | } scanargs; | ||
152 | |||
153 | static Bool queueScanner(Display *, XEvent *e, char *args) { | ||
154 | if ((e->type == LeaveNotify) && | ||
155 | (e->xcrossing.window == ((scanargs *) args)->w) && | ||
156 | (e->xcrossing.mode == NotifyNormal)) { | ||
157 | ((scanargs *) args)->leave = True; | ||
158 | ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); | ||
159 | } else if ((e->type == EnterNotify) && | ||
160 | (e->xcrossing.mode == NotifyUngrab)) | ||
161 | ((scanargs *) args)->enter = True; | ||
162 | |||
163 | return False; | ||
164 | } | ||
165 | //----------------------------------------------------------------- | 146 | //----------------------------------------------------------------- |
166 | //---- accessors for int, bool, and some enums with Resource ------ | 147 | //---- accessors for int, bool, and some enums with Resource ------ |
167 | //----------------------------------------------------------------- | 148 | //----------------------------------------------------------------- |
@@ -189,6 +170,19 @@ setFromString(char const *strval) { | |||
189 | } | 170 | } |
190 | 171 | ||
191 | template<> | 172 | template<> |
173 | void Resource<Fluxbox::FocusModel>:: | ||
174 | setFromString(char const *strval) { | ||
175 | if (strcasecmp(strval, "SloppyFocus") == 0) | ||
176 | m_value = Fluxbox::SLOPPYFOCUS; | ||
177 | else if (strcasecmp(strval, "SemiSloppyFocus") == 0) | ||
178 | m_value = Fluxbox::SEMISLOPPYFOCUS; | ||
179 | else if (strcasecmp(strval, "ClickToFocus") == 0) | ||
180 | m_value = Fluxbox::CLICKTOFOCUS; | ||
181 | else | ||
182 | setDefaultValue(); | ||
183 | } | ||
184 | |||
185 | template<> | ||
192 | void Resource<Fluxbox::TitlebarList>:: | 186 | void Resource<Fluxbox::TitlebarList>:: |
193 | setFromString(char const *strval) { | 187 | setFromString(char const *strval) { |
194 | vector<std::string> val; | 188 | vector<std::string> val; |
@@ -242,6 +236,21 @@ std::string Resource<std::string>:: | |||
242 | getString() { return **this; } | 236 | getString() { return **this; } |
243 | 237 | ||
244 | template<> | 238 | template<> |
239 | std::string Resource<Fluxbox::FocusModel>:: | ||
240 | getString() { | ||
241 | switch (m_value) { | ||
242 | case Fluxbox::SLOPPYFOCUS: | ||
243 | return string("SloppyFocus"); | ||
244 | case Fluxbox::SEMISLOPPYFOCUS: | ||
245 | return string("SemiSloppyFocus"); | ||
246 | case Fluxbox::CLICKTOFOCUS: | ||
247 | return string("ClickToFocus"); | ||
248 | } | ||
249 | // default string | ||
250 | return string("ClickToFocus"); | ||
251 | } | ||
252 | |||
253 | template<> | ||
245 | std::string Resource<Fluxbox::TitlebarList>:: | 254 | std::string Resource<Fluxbox::TitlebarList>:: |
246 | getString() { | 255 | getString() { |
247 | string retval; | 256 | string retval; |
@@ -691,18 +700,7 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
691 | 700 | ||
692 | } | 701 | } |
693 | break; | 702 | break; |
694 | case MotionNotify: { | 703 | case MotionNotify: |
695 | last_time = e->xmotion.time; | ||
696 | |||
697 | FluxboxWindow *win = 0; | ||
698 | Tab *tab = 0; | ||
699 | |||
700 | if ((win = searchWindow(e->xmotion.window)) !=0) | ||
701 | win->motionNotifyEvent(e->xmotion); | ||
702 | else if ((tab = searchTab(e->xmotion.window)) !=0) | ||
703 | tab->motionNotifyEvent(&e->xmotion); | ||
704 | |||
705 | } | ||
706 | break; | 704 | break; |
707 | case PropertyNotify: { | 705 | case PropertyNotify: { |
708 | 706 | ||
@@ -719,63 +717,26 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
719 | break; | 717 | break; |
720 | case EnterNotify: { | 718 | case EnterNotify: { |
721 | last_time = e->xcrossing.time; | 719 | last_time = e->xcrossing.time; |
722 | |||
723 | BScreen *screen = 0; | 720 | BScreen *screen = 0; |
724 | FluxboxWindow *win = 0; | ||
725 | Tab *tab = 0; | ||
726 | 721 | ||
727 | if (e->xcrossing.mode == NotifyGrab) | 722 | if (e->xcrossing.mode == NotifyGrab) |
728 | break; | 723 | break; |
729 | 724 | ||
730 | XEvent dummy; | ||
731 | scanargs sa; | ||
732 | sa.w = e->xcrossing.window; | ||
733 | sa.enter = sa.leave = False; | ||
734 | XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa); | ||
735 | |||
736 | if ((e->xcrossing.window == e->xcrossing.root) && | 725 | if ((e->xcrossing.window == e->xcrossing.root) && |
737 | (screen = searchScreen(e->xcrossing.window))) { | 726 | (screen = searchScreen(e->xcrossing.window))) { |
738 | screen->getImageControl()->installRootColormap(); | 727 | screen->getImageControl()->installRootColormap(); |
739 | } else if ((win = searchWindow(e->xcrossing.window))) { | ||
740 | if ((win->getScreen()->isSloppyFocus() || | ||
741 | win->getScreen()->isSemiSloppyFocus()) && | ||
742 | (! win->isFocused()) && (! no_focus)) { | ||
743 | |||
744 | grab(); | ||
745 | |||
746 | if (((! sa.leave) || sa.inferior) && win->isVisible() && | ||
747 | win->setInputFocus()) | ||
748 | win->installColormap(True); | ||
749 | 728 | ||
750 | ungrab(); | 729 | // if sloppy focus, then remove focus from windows |
751 | } | 730 | if (screen->isSloppyFocus() || |
752 | } else if ((tab = searchTab(e->xcrossing.window))) { | 731 | screen->isSemiSloppyFocus()) |
753 | win = tab->getWindow(); | 732 | setFocusedWindow(0); |
754 | if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) && | 733 | } |
755 | (! no_focus)) { | ||
756 | win->raise(); | ||
757 | |||
758 | grab(); | ||
759 | |||
760 | if (((! sa.leave) || sa.inferior) && win->isVisible() && | ||
761 | win->setInputFocus()) | ||
762 | win->installColormap(True); | ||
763 | |||
764 | ungrab(); | ||
765 | } | ||
766 | } | ||
767 | 734 | ||
768 | } | 735 | } |
769 | break; | 736 | break; |
770 | case LeaveNotify: | 737 | case LeaveNotify: |
771 | { | 738 | { |
772 | last_time = e->xcrossing.time; | 739 | last_time = e->xcrossing.time; |
773 | |||
774 | FluxboxWindow *win = (FluxboxWindow *) 0; | ||
775 | |||
776 | if ((win = searchWindow(e->xcrossing.window))) | ||
777 | win->installColormap(false); | ||
778 | |||
779 | } | 740 | } |
780 | break; | 741 | break; |
781 | case Expose: | 742 | case Expose: |
@@ -841,6 +802,7 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { | |||
841 | FluxboxWindow *win = 0; | 802 | FluxboxWindow *win = 0; |
842 | Tab *tab = 0; | 803 | Tab *tab = 0; |
843 | 804 | ||
805 | /* | ||
844 | if ((win = searchWindow(be.window))) { | 806 | if ((win = searchWindow(be.window))) { |
845 | 807 | ||
846 | win->buttonPressEvent(be); | 808 | win->buttonPressEvent(be); |
@@ -848,7 +810,7 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { | |||
848 | if (be.button == 1) | 810 | if (be.button == 1) |
849 | win->installColormap(True); | 811 | win->installColormap(True); |
850 | } | 812 | } |
851 | else if ((tab = searchTab(be.window))) { | 813 | else*/ if ((tab = searchTab(be.window))) { |
852 | tab->buttonPressEvent(&be); | 814 | tab->buttonPressEvent(&be); |
853 | } else { | 815 | } else { |
854 | ScreenList::iterator it = screenList.begin(); | 816 | ScreenList::iterator it = screenList.begin(); |
@@ -1782,6 +1744,8 @@ void Fluxbox::save_rc() { | |||
1782 | placement.c_str()); | 1744 | placement.c_str()); |
1783 | XrmPutLineResource(&new_blackboxrc, rc_string); | 1745 | XrmPutLineResource(&new_blackboxrc, rc_string); |
1784 | 1746 | ||
1747 | //TODO | ||
1748 | /* | ||
1785 | std::string focus_mode; | 1749 | std::string focus_mode; |
1786 | if (screen->isSloppyFocus() && screen->doAutoRaise()) | 1750 | if (screen->isSloppyFocus() && screen->doAutoRaise()) |
1787 | focus_mode = "AutoRaiseSloppyFocus"; | 1751 | focus_mode = "AutoRaiseSloppyFocus"; |
@@ -1797,7 +1761,7 @@ void Fluxbox::save_rc() { | |||
1797 | sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number, | 1761 | sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number, |
1798 | focus_mode.c_str()); | 1762 | focus_mode.c_str()); |
1799 | XrmPutLineResource(&new_blackboxrc, rc_string); | 1763 | XrmPutLineResource(&new_blackboxrc, rc_string); |
1800 | 1764 | */ | |
1801 | // load_rc(screen); | 1765 | // load_rc(screen); |
1802 | // these are static, but may not be saved in the users resource file, | 1766 | // these are static, but may not be saved in the users resource file, |
1803 | // writing these resources will allow the user to edit them at a later | 1767 | // writing these resources will allow the user to edit them at a later |
@@ -2024,6 +1988,8 @@ void Fluxbox::load_rc(BScreen *screen) { | |||
2024 | delete [] search; | 1988 | delete [] search; |
2025 | } | 1989 | } |
2026 | 1990 | ||
1991 | //TODO (use Fluxbox::FocusModel enum) | ||
1992 | /* | ||
2027 | sprintf(name_lookup, "session.screen%d.focusModel", screen_number); | 1993 | sprintf(name_lookup, "session.screen%d.focusModel", screen_number); |
2028 | sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number); | 1994 | sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number); |
2029 | if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, | 1995 | if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, |
@@ -2058,7 +2024,7 @@ void Fluxbox::load_rc(BScreen *screen) { | |||
2058 | screen->saveSloppyFocus(true); | 2024 | screen->saveSloppyFocus(true); |
2059 | screen->saveAutoRaise(false); | 2025 | screen->saveAutoRaise(false); |
2060 | } | 2026 | } |
2061 | 2027 | */ | |
2062 | sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); | 2028 | sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); |
2063 | sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); | 2029 | sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); |
2064 | if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, | 2030 | if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, |