aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-08-20 17:01:25 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-08-20 17:01:25 (GMT)
commitbc2b21547b290f599ca83297e3131c6c0c87759f (patch)
treed1ae4947f3c2818aef33d2cd0ef5d639b558dd72
parentb4e65724efbfbefdf4f5a12be19225b2d8a8dda6 (diff)
downloadfluxbox_paul-bc2b21547b290f599ca83297e3131c6c0c87759f.zip
fluxbox_paul-bc2b21547b290f599ca83297e3131c6c0c87759f.tar.bz2
implemented 'ActivateTab' action to (re)allow activation of tabs via mouse
-rw-r--r--data/keys3
-rw-r--r--doc/asciidoc/fluxbox-keys.txt3
-rw-r--r--src/CurrentWindowCmd.cc21
-rw-r--r--src/Keys.cc2
-rw-r--r--src/Window.cc101
-rw-r--r--src/Window.hh2
-rw-r--r--src/fluxbox.cc2
-rw-r--r--util/fluxbox-update_configs.cc16
8 files changed, 77 insertions, 73 deletions
diff --git a/data/keys b/data/keys
index d29e81b..3bfca00 100644
--- a/data/keys
+++ b/data/keys
@@ -29,7 +29,8 @@ OnTitlebar Control Mouse1 :StartTabbing
29OnTitlebar Double Mouse1 :Shade 29OnTitlebar Double Mouse1 :Shade
30 30
31# left click on the titlebar to move the window 31# left click on the titlebar to move the window
32OnTitlebar Mouse1 :StartMoving 32OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus}
33OnTitlebar Move1 :StartMoving
33 34
34# middle click on the titlebar to lower 35# middle click on the titlebar to lower
35OnTitlebar Mouse2 :Lower 36OnTitlebar Mouse2 :Lower
diff --git a/doc/asciidoc/fluxbox-keys.txt b/doc/asciidoc/fluxbox-keys.txt
index 3f3431d..41ad1e2 100644
--- a/doc/asciidoc/fluxbox-keys.txt
+++ b/doc/asciidoc/fluxbox-keys.txt
@@ -184,6 +184,9 @@ Bottom BottomRight*
184*StartTabbing*:: 184*StartTabbing*::
185 Start dragging to add this window to another's tabgroup. 185 Start dragging to add this window to another's tabgroup.
186 186
187*ActivateTab*::
188 Activates the tab underneath the mouse.
189
187Window Commands 190Window Commands
188~~~~~~~~~~~~~~~ 191~~~~~~~~~~~~~~~
189These commands ordinarily affect only the currently focused window. The 192These commands ordinarily affect only the currently focused window. The
diff --git a/src/CurrentWindowCmd.cc b/src/CurrentWindowCmd.cc
index 713c32a..4d25d54 100644
--- a/src/CurrentWindowCmd.cc
+++ b/src/CurrentWindowCmd.cc
@@ -223,6 +223,27 @@ FbTk::Command<void> *parseFocusCmd(const string &command, const string &args,
223REGISTER_COMMAND_PARSER(activate, parseFocusCmd, void); 223REGISTER_COMMAND_PARSER(activate, parseFocusCmd, void);
224REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void); 224REGISTER_COMMAND_PARSER(focus, parseFocusCmd, void);
225 225
226
227class ActivateTabCmd: public WindowHelperCmd {
228public:
229 ActivateTabCmd() { }
230protected:
231 void real_execute();
232};
233
234
235void ActivateTabCmd::real_execute() {
236
237 WinClient* winclient = fbwindow().winClientOfLabelButtonWindow(
238 Fluxbox::instance()->lastEvent().xany.window);
239
240 if (winclient && winclient != &fbwindow().winClient()) {
241 fbwindow().setCurrentClient(*winclient, true);
242 }
243}
244
245REGISTER_COMMAND(activatetab, ActivateTabCmd, void);
246
226} // end anonymous namespace 247} // end anonymous namespace
227 248
228void SetHeadCmd::real_execute() { 249void SetHeadCmd::real_execute() {
diff --git a/src/Keys.cc b/src/Keys.cc
index e8e2ab7..7cd77eb 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -354,6 +354,8 @@ void Keys::loadDefaults() {
354 addBinding("OnDesktop Mouse2 :WorkspaceMenu"); 354 addBinding("OnDesktop Mouse2 :WorkspaceMenu");
355 addBinding("OnDesktop Mouse3 :RootMenu"); 355 addBinding("OnDesktop Mouse3 :RootMenu");
356 addBinding("OnTitlebar Mouse3 :WindowMenu"); 356 addBinding("OnTitlebar Mouse3 :WindowMenu");
357 addBinding("OnWindow Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}");
358 addBinding("OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus}");
357 addBinding("OnTitlebar Move1 :StartMoving"); 359 addBinding("OnTitlebar Move1 :StartMoving");
358 addBinding("OnLeftGrip Move1 :StartResizing bottomleft"); 360 addBinding("OnLeftGrip Move1 :StartResizing bottomleft");
359 addBinding("OnRightGrip Move1 :StartResizing bottomright"); 361 addBinding("OnRightGrip Move1 :StartResizing bottomright");
diff --git a/src/Window.cc b/src/Window.cc
index 56cbd96..bf100e2 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -812,16 +812,10 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x
812 &labelbutton)) 812 &labelbutton))
813 return m_clientlist.end(); 813 return m_clientlist.end();
814 814
815 Client2ButtonMap::iterator it = 815 WinClient* c = winClientOfLabelButtonWindow(labelbutton);
816 find_if(m_labelbuttons.begin(),
817 m_labelbuttons.end(),
818 Compose(bind2nd(equal_to<Window>(), labelbutton),
819 Compose(mem_fun(&TextButton::window),
820 Select2nd<Client2ButtonMap::value_type>())));
821
822 816
823 // label button not found 817 // label button not found
824 if (it == m_labelbuttons.end()) 818 if (!c)
825 return m_clientlist.end(); 819 return m_clientlist.end();
826 820
827 Window child_return=0; 821 Window child_return=0;
@@ -834,8 +828,8 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x
834 828
835 ClientList::iterator client = find(m_clientlist.begin(), 829 ClientList::iterator client = find(m_clientlist.begin(),
836 m_clientlist.end(), 830 m_clientlist.end(),
837 it->first); 831 c);
838 if (x > static_cast<signed>((*it).second->width()) / 2) 832 if (x > static_cast<signed>(m_labelbuttons[c]->width()) / 2)
839 client++; 833 client++;
840 834
841 return client; 835 return client;
@@ -853,15 +847,9 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
853 &labelbutton)) 847 &labelbutton))
854 return; 848 return;
855 849
856 Client2ButtonMap::iterator it = 850 WinClient* client = winClientOfLabelButtonWindow(labelbutton);
857 find_if(m_labelbuttons.begin(),
858 m_labelbuttons.end(),
859 Compose(bind2nd(equal_to<Window>(), labelbutton),
860 Compose(mem_fun(&TextButton::window),
861 Select2nd<Client2ButtonMap::value_type>())));
862 851
863 // label button not found 852 if (!client)
864 if (it == m_labelbuttons.end())
865 return; 853 return;
866 854
867 Window child_return = 0; 855 Window child_return = 0;
@@ -871,10 +859,10 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
871 dest_x, dest_y, &x, &y, 859 dest_x, dest_y, &x, &y,
872 &child_return)) 860 &child_return))
873 return; 861 return;
874 if (x > static_cast<signed>((*it).second->width()) / 2) 862 if (x > static_cast<signed>(m_labelbuttons[client]->width()) / 2)
875 moveClientRightOf(win, *it->first); 863 moveClientRightOf(win, *client);
876 else 864 else
877 moveClientLeftOf(win, *it->first); 865 moveClientLeftOf(win, *client);
878 866
879} 867}
880 868
@@ -2360,40 +2348,15 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2360 frame().insideTitlebar( be.window ) && 2348 frame().insideTitlebar( be.window ) &&
2361 frame().handle().window() != be.window; 2349 frame().handle().window() != be.window;
2362 2350
2363#if 0 // disabled
2364 if (onTitlebar && be.button == 1)
2365 raise();
2366#endif
2367
2368 // check keys file first
2369 Keys *k = Fluxbox::instance()->keys(); 2351 Keys *k = Fluxbox::instance()->keys();
2370 if ((onTitlebar && k->doAction(be.type, be.state, be.button, 2352 if ((onTitlebar && k->doAction(be.type, be.state, be.button, Keys::ON_TITLEBAR, &winClient(), be.time)) ||
2371 Keys::ON_TITLEBAR, m_client, be.time)) || 2353 k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, &winClient(), be.time)) {
2372 k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, m_client, 2354
2373 be.time)) {
2374 return; 2355 return;
2375 } 2356 }
2376 2357
2377 frame().tabcontainer().tryButtonPressEvent(be);
2378 if (be.button == 1) {
2379 if (frame().window().window() == be.window ||
2380 frame().tabcontainer().window() == be.window) {
2381 if (screen().clickRaises())
2382 raise();
2383
2384 fbdbg<<"FluxboxWindow::buttonPressEvent: AllowEvent"<<endl;
2385
2386 XAllowEvents(display, ReplayPointer, be.time);
2387
2388 m_button_grab_x = be.x_root - frame().x() - frame().window().borderWidth();
2389 m_button_grab_y = be.y_root - frame().y() - frame().window().borderWidth();
2390 } else if (frame().handle() == be.window)
2391 raise();
2392 2358
2393 FbTk::Menu::hideShownMenu(); 2359 XAllowEvents(display, ReplayPointer, be.time);
2394 if (!m_focused && acceptsFocus() && m_click_focus) //check focus
2395 focus();
2396 }
2397} 2360}
2398 2361
2399void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { 2362void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
@@ -2650,15 +2613,7 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2650 WinClient *client = 0; 2613 WinClient *client = 0;
2651 if (screen().focusControl().isMouseTabFocus()) { 2614 if (screen().focusControl().isMouseTabFocus()) {
2652 // determine if we're in a label button (tab) 2615 // determine if we're in a label button (tab)
2653 Client2ButtonMap::iterator it = 2616 client = winClientOfLabelButtonWindow(ev.window);
2654 find_if(m_labelbuttons.begin(),
2655 m_labelbuttons.end(),
2656 Compose(bind2nd(equal_to<Window>(), ev.window),
2657 Compose(mem_fun(&TextButton::window),
2658 Select2nd<Client2ButtonMap::value_type>())));
2659 if (it != m_labelbuttons.end())
2660 client = (*it).first;
2661
2662 } 2617 }
2663 2618
2664 if (ev.window == frame().window() || 2619 if (ev.window == frame().window() ||
@@ -3149,21 +3104,26 @@ void FluxboxWindow::stopResizing(bool interrupted) {
3149 ungrabPointer(CurrentTime); 3104 ungrabPointer(CurrentTime);
3150} 3105}
3151 3106
3152void FluxboxWindow::startTabbing(const XButtonEvent &be) { 3107WinClient* FluxboxWindow::winClientOfLabelButtonWindow(Window window) {
3153 3108 WinClient* result = 0;
3154 if (s_num_grabs > 0)
3155 return;
3156
3157 m_attaching_tab = 0;
3158 // determine if we're in titlebar
3159 Client2ButtonMap::iterator it = 3109 Client2ButtonMap::iterator it =
3160 find_if(m_labelbuttons.begin(), 3110 find_if(m_labelbuttons.begin(),
3161 m_labelbuttons.end(), 3111 m_labelbuttons.end(),
3162 Compose(bind2nd(equal_to<Window>(), be.window), 3112 Compose(bind2nd(equal_to<Window>(), window),
3163 Compose(mem_fun(&TextButton::window), 3113 Compose(mem_fun(&FbTk::Button::window),
3164 Select2nd<Client2ButtonMap::value_type>()))); 3114 Select2nd<Client2ButtonMap::value_type>())));
3165 if (it != m_labelbuttons.end()) 3115 if (it != m_labelbuttons.end())
3166 m_attaching_tab = it->first; 3116 result = it->first;
3117
3118 return result;
3119}
3120
3121void FluxboxWindow::startTabbing(const XButtonEvent &be) {
3122
3123 if (s_num_grabs > 0)
3124 return;
3125
3126 m_attaching_tab = winClientOfLabelButtonWindow(be.window);
3167 3127
3168 // start drag'n'drop for tab 3128 // start drag'n'drop for tab
3169 grabPointer(be.window, False, ButtonMotionMask | 3129 grabPointer(be.window, False, ButtonMotionMask |
@@ -3704,8 +3664,6 @@ void FluxboxWindow::associateClient(WinClient &client) {
3704 frame().theme().unfocusedTheme()->iconbarTheme(), client); 3664 frame().theme().unfocusedTheme()->iconbarTheme(), client);
3705 frame().createTab(*btn); 3665 frame().createTab(*btn);
3706 3666
3707 FbTk::RefCount<FbTk::Command<void> > setcmd(new SetClientCmd(client));
3708 btn->setOnClick(setcmd, 1);
3709 btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); 3667 btn->setTextPadding(Fluxbox::instance()->getTabsPadding());
3710 btn->setPixmap(screen().getTabsUsePixmap()); 3668 btn->setPixmap(screen().getTabsUsePixmap());
3711 3669
@@ -3715,6 +3673,7 @@ void FluxboxWindow::associateClient(WinClient &client) {
3715 3673
3716 evm.add(*this, btn->window()); // we take care of button events for this 3674 evm.add(*this, btn->window()); // we take care of button events for this
3717 evm.add(*this, client.window()); 3675 evm.add(*this, client.window());
3676
3718 client.setFluxboxWindow(this); 3677 client.setFluxboxWindow(this);
3719 join(client.titleSig(), 3678 join(client.titleSig(),
3720 FbTk::MemFun(*this, &FluxboxWindow::setTitle)); 3679 FbTk::MemFun(*this, &FluxboxWindow::setTitle));
diff --git a/src/Window.hh b/src/Window.hh
index 5554ad3..d7fd812 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -398,6 +398,8 @@ public:
398 WinClient &winClient() { return *m_client; } 398 WinClient &winClient() { return *m_client; }
399 const WinClient &winClient() const { return *m_client; } 399 const WinClient &winClient() const { return *m_client; }
400 400
401 WinClient* winClientOfLabelButtonWindow(Window w);
402
401 bool isTyping() const; 403 bool isTyping() const;
402 404
403 const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); } 405 const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); }
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index e8445bb..192b44c 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -605,7 +605,7 @@ void Fluxbox::setupConfigFiles() {
605 if (create_windowmenu) 605 if (create_windowmenu)
606 FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); 606 FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str());
607 607
608#define CONFIG_VERSION 11 608#define CONFIG_VERSION 12
609 FbTk::Resource<int> config_version(m_resourcemanager, 0, 609 FbTk::Resource<int> config_version(m_resourcemanager, 0,
610 "session.configVersion", "Session.ConfigVersion"); 610 "session.configVersion", "Session.ConfigVersion");
611 if (*config_version < CONFIG_VERSION) { 611 if (*config_version < CONFIG_VERSION) {
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index f4a2019..129833c 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -391,11 +391,27 @@ int run_updates(int old_version, FbTk::ResourceManager &rm) {
391 new_keyfile += "OnWindowBorder Move1 :StartMoving\n\n"; 391 new_keyfile += "OnWindowBorder Move1 :StartMoving\n\n";
392 new_keyfile += whole_keyfile; // don't forget user's old keybindings 392 new_keyfile += whole_keyfile; // don't forget user's old keybindings
393 393
394 new_keyfile += "\n"; // just for good looks
394 write_file(keyfilename, new_keyfile); 395 write_file(keyfilename, new_keyfile);
395 396
396 new_version = 11; 397 new_version = 11;
397 } 398 }
398 399
400 if (old_version < 12) { // update keys for ActivateTab
401
402 string whole_file = read_file(keyfilename);
403 string new_keyfile = "";
404
405 new_keyfile += "!mouse actions added by fluxbox-update_configs\n";
406 new_keyfile += "OnTitlebar Mouse1 :MacroCmd {ActivateTab} {Raise} {Focus}\n";
407 new_keyfile += whole_file;
408
409 new_keyfile += "\n"; // just for good looks
410 write_file(keyfilename, new_keyfile);
411
412 new_version = 12;
413 }
414
399 return new_version; 415 return new_version;
400} 416}
401 417