using Select2nd
This commit is contained in:
parent
6b943ec69a
commit
dce0e2e40c
4 changed files with 124 additions and 117 deletions
|
@ -69,6 +69,8 @@
|
|||
#include "FbTk/ImageControl.hh"
|
||||
#include "FbTk/EventManager.hh"
|
||||
#include "FbTk/Transparent.hh"
|
||||
#include "FbTk/Select2nd.hh"
|
||||
#include "FbTk/Compose.hh"
|
||||
|
||||
//use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -830,16 +832,17 @@ void BScreen::removeClient(WinClient &client) {
|
|||
for_each(getWorkspacesList().begin(), getWorkspacesList().end(),
|
||||
mem_fun(&Workspace::updateClientmenu));
|
||||
|
||||
using namespace FbTk;
|
||||
|
||||
// remove any grouping this is expecting
|
||||
Groupables::iterator it = m_expecting_groups.begin();
|
||||
Groupables::iterator it_end = m_expecting_groups.end();
|
||||
for (; it != it_end; ++it) {
|
||||
if (it->second == &client) {
|
||||
m_expecting_groups.erase(it);
|
||||
// it should only be in there a maximum of once
|
||||
break;
|
||||
}
|
||||
}
|
||||
Groupables::iterator erase_it = find_if(m_expecting_groups.begin(),
|
||||
m_expecting_groups.end(),
|
||||
Compose(bind2nd(equal_to<WinClient *>(), &client),
|
||||
Select2nd<Groupables::value_type>()));
|
||||
|
||||
if (erase_it != m_expecting_groups.end())
|
||||
m_expecting_groups.erase(erase_it);
|
||||
|
||||
// the client could be on icon menu so we update it
|
||||
//!! TODO: check this with the new icon menu
|
||||
// updateIconMenu();
|
||||
|
@ -1711,14 +1714,12 @@ void BScreen::addConfigMenu(const char *label, FbTk::Menu &menu) {
|
|||
}
|
||||
|
||||
void BScreen::removeConfigMenu(FbTk::Menu &menu) {
|
||||
Configmenus::iterator it = m_configmenu_list.begin();
|
||||
Configmenus::iterator it_end = m_configmenu_list.end();
|
||||
for (; it != it_end; ++it) {
|
||||
if (it->second == &menu) {
|
||||
m_configmenu_list.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Configmenus::iterator erase_it = find_if(m_configmenu_list.begin(),
|
||||
m_configmenu_list.end(),
|
||||
FbTk::Compose(bind2nd(equal_to<FbTk::Menu *>(), &menu),
|
||||
FbTk::Select2nd<Configmenus::value_type>()));
|
||||
if (erase_it != m_configmenu_list.end())
|
||||
m_configmenu_list.erase(erase_it);
|
||||
setupConfigmenu(*m_configmenu.get());
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "FbTk/EventManager.hh"
|
||||
#include "FbTk/KeyUtil.hh"
|
||||
#include "FbTk/SimpleCommand.hh"
|
||||
#include "FbTk/Select2nd.hh"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -81,15 +82,18 @@
|
|||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace FbTk;
|
||||
|
||||
namespace {
|
||||
|
||||
void grabButton(Display *display, unsigned int button,
|
||||
void grabButton(unsigned int button,
|
||||
Window window, Cursor cursor) {
|
||||
|
||||
const int numlock = FbTk::KeyUtil::instance().numlock();
|
||||
const int capslock = FbTk::KeyUtil::instance().capslock();
|
||||
const int scrolllock = FbTk::KeyUtil::instance().scrolllock();
|
||||
static Display *display = App::instance()->display();
|
||||
|
||||
const int numlock = KeyUtil::instance().numlock();
|
||||
const int capslock = KeyUtil::instance().capslock();
|
||||
const int scrolllock = KeyUtil::instance().scrolllock();
|
||||
|
||||
// Grab with Mod1 and with all lock modifiers
|
||||
// (num, scroll and caps)
|
||||
|
@ -863,7 +867,7 @@ bool FluxboxWindow::removeClient(WinClient &client) {
|
|||
WinClient *FluxboxWindow::findClient(Window win) {
|
||||
ClientList::iterator it = find_if(clientList().begin(),
|
||||
clientList().end(),
|
||||
FbTk::Compose(bind2nd(equal_to<Window>(), win),
|
||||
Compose(bind2nd(equal_to<Window>(), win),
|
||||
mem_fun(&WinClient::window)));
|
||||
return (it == clientList().end() ? 0 : *it);
|
||||
}
|
||||
|
@ -948,6 +952,7 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x
|
|||
x, y, &dest_x, &dest_y,
|
||||
&labelbutton))
|
||||
return m_clientlist.end();
|
||||
|
||||
Client2ButtonMap::iterator it = m_labelbuttons.begin();
|
||||
Client2ButtonMap::iterator it_end = m_labelbuttons.end();
|
||||
// find the label button to move next to
|
||||
|
@ -955,10 +960,11 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x
|
|||
if ((*it).second->window() == labelbutton)
|
||||
break;
|
||||
}
|
||||
|
||||
// label button not found
|
||||
if(it==it_end) {
|
||||
if (it == m_labelbuttons.end())
|
||||
return m_clientlist.end();
|
||||
}
|
||||
|
||||
Window child_return=0;
|
||||
// make x and y relative to our labelbutton
|
||||
if (!XTranslateCoordinates(FbTk::App::instance()->display(),
|
||||
|
@ -966,13 +972,14 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x
|
|||
dest_x, dest_y, &x, &y,
|
||||
&child_return))
|
||||
return m_clientlist.end();
|
||||
|
||||
ClientList::iterator client = find(m_clientlist.begin(),
|
||||
m_clientlist.end(),
|
||||
it->first);
|
||||
if (x > (*it).second->width() / 2)
|
||||
client++;
|
||||
return client;
|
||||
|
||||
return client;
|
||||
|
||||
}
|
||||
|
||||
|
@ -993,10 +1000,11 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
|
|||
if ((*it).second->window() == labelbutton)
|
||||
break;
|
||||
}
|
||||
|
||||
// label button not found
|
||||
if(it==it_end) {
|
||||
if (it == it_end)
|
||||
return;
|
||||
}
|
||||
|
||||
Window child_return = 0;
|
||||
//make x and y relative to our labelbutton
|
||||
if (!XTranslateCoordinates(FbTk::App::instance()->display(),
|
||||
|
@ -1004,11 +1012,10 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) {
|
|||
dest_x, dest_y, &x, &y,
|
||||
&child_return))
|
||||
return;
|
||||
if(x>(*it).second->width()/2) {
|
||||
if (x > (*it).second->width() / 2)
|
||||
moveClientRightOf(win, *it->first);
|
||||
} else {
|
||||
else
|
||||
moveClientLeftOf(win, *it->first);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1154,7 +1161,7 @@ void FluxboxWindow::grabButtons() {
|
|||
GrabModeAsync, None, frame().theme().moveCursor());
|
||||
|
||||
//----grab with "all" modifiers
|
||||
grabButton(display, Button1, frame().window().window(), frame().theme().moveCursor());
|
||||
grabButton(Button1, frame().window().window(), frame().theme().moveCursor());
|
||||
|
||||
XGrabButton(display, Button2, Mod1Mask, frame().window().window(), True,
|
||||
ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
|
||||
|
@ -1164,7 +1171,7 @@ void FluxboxWindow::grabButtons() {
|
|||
GrabModeAsync, None, None);
|
||||
|
||||
//---grab with "all" modifiers
|
||||
grabButton(display, Button3, frame().window().window(), None);
|
||||
grabButton(Button3, frame().window().window(), None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3772,14 +3779,13 @@ void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
|
|||
}
|
||||
|
||||
void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
|
||||
ExtraMenus::iterator it = m_extramenus.begin();
|
||||
ExtraMenus::iterator it_end = m_extramenus.end();
|
||||
for (; it != it_end; ++it) {
|
||||
if (it->second == menu) {
|
||||
ExtraMenus::iterator it = find_if(m_extramenus.begin(),
|
||||
m_extramenus.end(),
|
||||
Compose(bind2nd(equal_to<Menu *>(), menu),
|
||||
Select2nd<ExtraMenus::value_type>()));
|
||||
if (it != m_extramenus.end())
|
||||
m_extramenus.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setupMenu();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include "FbTk/SimpleCommand.hh"
|
||||
#include "FbTk/CompareEqual.hh"
|
||||
#include "FbTk/Transparent.hh"
|
||||
#include "FbTk/Select2nd.hh"
|
||||
#include "FbTk/Compose.hh"
|
||||
|
||||
//Use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -1329,12 +1331,14 @@ BScreen *Fluxbox::searchScreen(Window window) {
|
|||
|
||||
AtomHandler* Fluxbox::getAtomHandler(const std::string &name) {
|
||||
if ( name != "" ) {
|
||||
for (AtomHandlerContainerIt it= m_atomhandler.begin();
|
||||
it != m_atomhandler.end(); it++ ) {
|
||||
if ( name == (*it).second )
|
||||
using namespace FbTk;
|
||||
AtomHandlerContainerIt it = find_if(m_atomhandler.begin(),
|
||||
m_atomhandler.end(),
|
||||
Compose(bind2nd(equal_to<string>(), name),
|
||||
Select2nd<AtomHandlerContainer::value_type>()));
|
||||
if (it != m_atomhandler.end())
|
||||
return (*it).first;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void Fluxbox::addAtomHandler(AtomHandler *atomh, const std::string &name) {
|
||||
|
@ -1342,7 +1346,6 @@ void Fluxbox::addAtomHandler(AtomHandler *atomh, const std::string &name) {
|
|||
}
|
||||
|
||||
void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
|
||||
|
||||
for (AtomHandlerContainerIt it= m_atomhandler.begin();
|
||||
it != m_atomhandler.end();
|
||||
++it) {
|
||||
|
@ -1354,11 +1357,11 @@ void Fluxbox::removeAtomHandler(AtomHandler *atomh) {
|
|||
}
|
||||
|
||||
WinClient *Fluxbox::searchWindow(Window window) {
|
||||
std::map<Window, WinClient *>::iterator it = m_window_search.find(window);
|
||||
WinClientMap::iterator it = m_window_search.find(window);
|
||||
if (it != m_window_search.end())
|
||||
return it->second;
|
||||
|
||||
std::map<Window, FluxboxWindow *>::iterator git = m_window_search_group.find(window);
|
||||
WindowMap::iterator git = m_window_search_group.find(window);
|
||||
return git == m_window_search_group.end() ? 0 : &git->second->winClient();
|
||||
}
|
||||
|
||||
|
@ -1806,18 +1809,13 @@ void Fluxbox::setFocusedWindow(WinClient *client) {
|
|||
|
||||
if (m_focused_window != 0) {
|
||||
// check if m_focused_window is valid
|
||||
bool found = false;
|
||||
std::map<Window, WinClient *>::iterator it = m_window_search.begin();
|
||||
std::map<Window, WinClient *>::iterator it_end = m_window_search.end();
|
||||
for (; it != it_end; ++it) {
|
||||
if (it->second == m_focused_window) {
|
||||
// we found it, end loop
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
WinClientMap::iterator it = find_if(m_window_search.begin(),
|
||||
m_window_search.end(),
|
||||
Compose(bind2nd(equal_to<WinClient *>(), m_focused_window),
|
||||
Select2nd<WinClientMap::value_type>()));
|
||||
|
||||
if (!found) {
|
||||
// if not found...
|
||||
if (it == m_window_search.end()) {
|
||||
m_focused_window = 0;
|
||||
} else {
|
||||
old_client = m_focused_window;
|
||||
|
|
|
@ -273,8 +273,10 @@ private:
|
|||
FbTk::Resource<time_t> m_rc_auto_raise_delay;
|
||||
FbTk::Resource<bool> m_rc_use_mod1; /// temporary!, to disable mod1 for resize/move
|
||||
|
||||
std::map<Window, WinClient *> m_window_search;
|
||||
std::map<Window, FluxboxWindow *> m_window_search_group;
|
||||
typedef std::map<Window, WinClient *> WinClientMap;
|
||||
WinClientMap m_window_search;
|
||||
typedef std::map<Window, FluxboxWindow *> WindowMap;
|
||||
WindowMap m_window_search_group;
|
||||
// A window is the group leader, which can map to several
|
||||
// WinClients in the group, it is *not* fluxbox's concept of groups
|
||||
// See ICCCM section 4.1.11
|
||||
|
|
Loading…
Reference in a new issue