summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Window.cc28
-rw-r--r--src/Window.hh9
2 files changed, 27 insertions, 10 deletions
diff --git a/src/Window.cc b/src/Window.cc
index a29ea77..5eb380e 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -264,6 +264,9 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
264 m_toggled_decos(false), 264 m_toggled_decos(false),
265 m_icon_hidden(false), 265 m_icon_hidden(false),
266 m_focus_hidden(false), 266 m_focus_hidden(false),
267 m_focus_new(screen().focusControl().focusNew()),
268 m_mouse_focus(screen().focusControl().isMouseFocus()),
269 m_click_focus(true),
267 m_old_pos_x(0), m_old_pos_y(0), 270 m_old_pos_x(0), m_old_pos_y(0),
268 m_old_width(1), m_old_height(1), 271 m_old_width(1), m_old_height(1),
269 m_last_button_x(0), m_last_button_y(0), 272 m_last_button_x(0), m_last_button_y(0),
@@ -548,8 +551,7 @@ void FluxboxWindow::init() {
548 deiconify(false); 551 deiconify(false);
549 // check if we should prevent this window from gaining focus 552 // check if we should prevent this window from gaining focus
550 m_focused = false; // deiconify sets this 553 m_focused = false; // deiconify sets this
551 if (!Fluxbox::instance()->isStartup() && 554 if (!Fluxbox::instance()->isStartup() && m_focus_new) {
552 screen().focusControl().focusNew()) {
553 m_focused = focusRequestFromClient(*m_client); 555 m_focused = focusRequestFromClient(*m_client);
554 if (!m_focused) 556 if (!m_focused)
555 lower(); 557 lower();
@@ -655,13 +657,12 @@ void FluxboxWindow::attachClient(WinClient &client, int x, int y) {
655 frame().clientArea().height()); 657 frame().clientArea().height());
656 658
657 // right now, this block only happens with new windows or on restart 659 // right now, this block only happens with new windows or on restart
658 bool focus_new = screen().focusControl().focusNew();
659 bool is_startup = Fluxbox::instance()->isStartup(); 660 bool is_startup = Fluxbox::instance()->isStartup();
660 661
661 // we use m_focused as a signal to focus the window when mapped 662 // we use m_focused as a signal to focus the window when mapped
662 if (focus_new && !is_startup) 663 if (m_focus_new && !is_startup)
663 m_focused = focusRequestFromClient(client); 664 m_focused = focusRequestFromClient(client);
664 focused_win = (focus_new || is_startup) ? &client : m_client; 665 focused_win = (m_focus_new || is_startup) ? &client : m_client;
665 666
666 client.saveBlackboxAttribs(m_blackbox_attrib, 667 client.saveBlackboxAttribs(m_blackbox_attrib,
667 PropBlackboxAttributesElements); 668 PropBlackboxAttributesElements);
@@ -1447,7 +1448,7 @@ void FluxboxWindow::deiconify(bool do_raise) {
1447 // but not on startup: focus will be handled after creating everything 1448 // but not on startup: focus will be handled after creating everything
1448 // we use m_focused as a signal to focus the window when mapped 1449 // we use m_focused as a signal to focus the window when mapped
1449 if (screen().currentWorkspace()->numberOfWindows() == 1 || 1450 if (screen().currentWorkspace()->numberOfWindows() == 1 ||
1450 screen().focusControl().focusNew() || m_client->isTransient()) 1451 m_focus_new || m_client->isTransient())
1451 m_focused = true; 1452 m_focused = true;
1452 1453
1453 oplock = false; 1454 oplock = false;
@@ -2230,7 +2231,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
2230 setCurrentClient(*client, false); // focus handled on MapNotify 2231 setCurrentClient(*client, false); // focus handled on MapNotify
2231 deiconify(); 2232 deiconify();
2232 2233
2233 if (screen().focusControl().focusNew()) { 2234 if (m_focus_new) {
2234 m_focused = false; // deiconify sets this 2235 m_focused = false; // deiconify sets this
2235 m_focused = focusRequestFromClient(*client); 2236 m_focused = focusRequestFromClient(*client);
2236 if (!m_focused) 2237 if (!m_focused)
@@ -2607,7 +2608,7 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2607 2608
2608 frame().tabcontainer().tryButtonPressEvent(be); 2609 frame().tabcontainer().tryButtonPressEvent(be);
2609 if (be.button == 1) { 2610 if (be.button == 1) {
2610 if (!m_focused && acceptsFocus()) //check focus 2611 if (!m_focused && acceptsFocus() && m_click_focus) //check focus
2611 focus(); 2612 focus();
2612 2613
2613 if (frame().window().window() == be.window || 2614 if (frame().window().window() == be.window ||
@@ -2908,8 +2909,7 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2908 ev.window == m_client->window() || 2909 ev.window == m_client->window() ||
2909 client) { 2910 client) {
2910 2911
2911 if (screen().focusControl().isMouseFocus() && !isFocused() && 2912 if (m_mouse_focus && !isFocused() && acceptsFocus()) {
2912 acceptsFocus() && getWindowType() != Focusable::TYPE_DESKTOP) {
2913 2913
2914 // check that there aren't any subsequent leave notify events in the 2914 // check that there aren't any subsequent leave notify events in the
2915 // X event queue 2915 // X event queue
@@ -4157,6 +4157,9 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
4157 */ 4157 */
4158 setFocusHidden(true); 4158 setFocusHidden(true);
4159 setIconHidden(true); 4159 setIconHidden(true);
4160 setFocusNew(false);
4161 setMouseFocus(false);
4162 setClickFocus(false);
4160 setDecorationMask(FbWinFrame::DECOR_NONE); 4163 setDecorationMask(FbWinFrame::DECOR_NONE);
4161 moveToLayer(::Layer::DOCK); 4164 moveToLayer(::Layer::DOCK);
4162 break; 4165 break;
@@ -4169,6 +4172,8 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
4169 */ 4172 */
4170 setFocusHidden(true); 4173 setFocusHidden(true);
4171 setIconHidden(true); 4174 setIconHidden(true);
4175 setFocusNew(false);
4176 setMouseFocus(false);
4172 moveToLayer(::Layer::DESKTOP); 4177 moveToLayer(::Layer::DESKTOP);
4173 setDecorationMask(FbWinFrame::DECOR_NONE); 4178 setDecorationMask(FbWinFrame::DECOR_NONE);
4174 setTabable(false); 4179 setTabable(false);
@@ -4185,6 +4190,9 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) {
4185 setDecorationMask(FbWinFrame::DECOR_NONE); 4190 setDecorationMask(FbWinFrame::DECOR_NONE);
4186 setFocusHidden(true); 4191 setFocusHidden(true);
4187 setIconHidden(true); 4192 setIconHidden(true);
4193 setFocusNew(false);
4194 setMouseFocus(false);
4195 setClickFocus(false);
4188 setMovable(false); 4196 setMovable(false);
4189 break; 4197 break;
4190 case Focusable::TYPE_DIALOG: 4198 case Focusable::TYPE_DIALOG:
diff --git a/src/Window.hh b/src/Window.hh
index 1d54d18..d0db606 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -286,6 +286,12 @@ public:
286 void setFocusHidden(bool value); 286 void setFocusHidden(bool value);
287 /// sets the window icon hidden state 287 /// sets the window icon hidden state
288 void setIconHidden(bool value); 288 void setIconHidden(bool value);
289 /// sets whether or not the window normally gets focus when mapped
290 void setFocusNew(bool value) { m_focus_new = value; }
291 /// sets whether or not the window gets focused with mouse
292 void setMouseFocus(bool value) { m_mouse_focus = value; }
293 /// sets whether or not the window gets focused with click
294 void setClickFocus(bool value) { m_click_focus = value; }
289 void reconfigure(); 295 void reconfigure();
290 296
291 297
@@ -603,6 +609,9 @@ private:
603 609
604 bool m_icon_hidden; ///< if the window is in the iconbar 610 bool m_icon_hidden; ///< if the window is in the iconbar
605 bool m_focus_hidden; ///< if the window is in the NextWindow list 611 bool m_focus_hidden; ///< if the window is in the NextWindow list
612 bool m_focus_new; ///< if the window is normally focused when mapped
613 bool m_mouse_focus; ///< if the window is focused with EnterNotify
614 bool m_click_focus; ///< if the window is focused by clicking
606 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized 615 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized
607 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state 616 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state
608 int m_last_button_x, ///< last known x position of the mouse button 617 int m_last_button_x, ///< last known x position of the mouse button