merged with embedded-tab-branch

This commit is contained in:
fluxgen 2003-04-14 15:28:52 +00:00
parent 2928b32f3a
commit fd6d2d20d9
2 changed files with 309 additions and 376 deletions

View file

@ -22,8 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.cc,v 1.105 2003/03/23 01:33:31 rathnor Exp $
// $Id: fluxbox.cc,v 1.106 2003/04/14 15:28:52 fluxgen Exp $
#include "fluxbox.hh"
@ -39,6 +38,7 @@
#include "ImageControl.hh"
#include "EventManager.hh"
#include "FbCommands.hh"
#include "WinClient.hh"
//Use GNU extensions
#ifndef _GNU_SOURCE
@ -508,10 +508,10 @@ Fluxbox::~Fluxbox() {
}
//---------- setupConfigFiles -----------
// setup the configutation files in
// home directory
//---------------------------------------
/**
setup the configutation files in
home directory
*/
void Fluxbox::setupConfigFiles() {
bool createInit, createKeys, createMenu;
@ -702,14 +702,25 @@ void Fluxbox::handleEvent(XEvent * const e) {
case CreateNotify:
break;
case DestroyNotify: {
FluxboxWindow *win = 0;
if ((win = searchWindow(e->xdestroywindow.window)) && win->getClientWindow() == e->xdestroywindow.window) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__FUNCTION__<<"): DestroyNotify"<<endl;
#endif // DEBUG
FluxboxWindow *win = searchWindow(e->xdestroywindow.window);
if (win != 0) {
WinClient *client = win->findClient(e->xdestroywindow.window);
if (client != 0) {
win->destroyNotifyEvent(e->xdestroywindow);
removeWindowSearch(win->getClientWindow());
delete client;
if (win->numClients() == 0 ||
&win->winClient() == client && win->numClients() == 1) {
delete win;
}
}
}
}
break;
case MotionNotify:
@ -750,12 +761,10 @@ void Fluxbox::handleEvent(XEvent * const e) {
case Expose:
{
FluxboxWindow *win = (FluxboxWindow *) 0;
Tab *tab = 0;
if ((win = searchWindow(e->xexpose.window)))
win->exposeEvent(e->xexpose);
else if ((tab = searchTab(e->xexpose.window)))
tab->exposeEvent(&e->xexpose);
}
break;
case KeyPress:
@ -807,11 +816,8 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
{
last_time = be.time;
Tab *tab = 0;
if ((tab = searchTab(be.window))) {
tab->buttonPressEvent(&be);
} else {
ScreenList::iterator it = screenList.begin();
ScreenList::iterator it_end = screenList.end();
@ -893,8 +899,8 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
} else if (screen->isDesktopWheeling() && be.button == 5) {
screen->prevWorkspace(1);
}
}
}
} // end for
}
break;
@ -902,12 +908,9 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
{
last_time = be.time;
FluxboxWindow *win = (FluxboxWindow *) 0;
Tab *tab = 0;
if ((win = searchWindow(be.window)))
win->buttonReleaseEvent(be);
else if ((tab = searchTab(be.window)))
tab->buttonReleaseEvent(&be);
}
break;
@ -923,32 +926,37 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
BScreen *screen = searchScreen(ue.event);
if ( (ue.event != ue.window) && (screen != 0 || !ue.send_event))
if ( ue.event != ue.window && (screen != 0 || !ue.send_event))
return;
if ((win = searchWindow(ue.window)) != 0) {
WinClient *client = win->findClient(ue.window);
if (client != 0) {
win->unmapNotifyEvent(ue);
if (win->getClientWindow() == ue.window) {
client = 0; // it's invalid now when win destroyed the client
if (win == focused_window)
focused_window = 0;
removeWindowSearch(win->getClientWindow());
// finaly destroy window if empty
if (win->numClients() == 0) {
delete win;
win = 0;
}
}
}
}
//------------ handleClientMessage --------
// Handles XClientMessageEvent
//-----------------------------------------
/**
* Handles XClientMessageEvent
*/
void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<<hex<<ce.data.l[0]<<
" message_type=0x"<<ce.message_type<<dec<<endl;
#endif // DEBUG
if (ce.format != 32)
@ -1005,9 +1013,10 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
}
}
}
//----------- handleKeyEvent ---------------
// Handles KeyRelease and KeyPress events
//------------------------------------------
/**
Handles KeyRelease and KeyPress events
*/
void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
switch (ke.type) {
case KeyPress:
@ -1016,7 +1025,9 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
if (screen) {
if (screen == 0)
break;
#ifdef DEBUG
cerr<<"KeyEvent"<<endl;
#endif
@ -1131,51 +1142,45 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
screen->prevFocus(key->getParam());
break;
case Keys::NEXTTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
if (tab->next()) {
tab->next()->getWindow()->raise();
tab->next()->getWindow()->setInputFocus();
} else {
tab->first()->getWindow()->raise();
tab->first()->getWindow()->setInputFocus();
}
}
if (focused_window && focused_window->numClients() > 1)
focused_window->nextClient();
break;
case Keys::PREVTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
if (tab->prev()) {
tab->prev()->getWindow()->raise();
tab->prev()->getWindow()->setInputFocus();
} else {
tab->last()->getWindow()->raise();
tab->last()->getWindow()->setInputFocus();
}
}
if (focused_window && focused_window->numClients() > 1)
focused_window->prevClient();
break;
case Keys::FIRSTTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
tab->first()->getWindow()->raise();
tab->first()->getWindow()->setInputFocus();
}
cerr<<"FIRSTTAB TODO!"<<endl;
break;
case Keys::LASTTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
tab->last()->getWindow()->raise();
tab->last()->getWindow()->setInputFocus();
}
cerr<<"LASTTAB TODO!"<<endl;
break;
case Keys::MOVETABPREV:
if (focused_window && focused_window->getTab()) {
focused_window->getTab()->movePrev();
}
cerr<<"MOVETABPREV TODO!"<<endl;
break;
case Keys::MOVETABNEXT:
if (focused_window && focused_window->getTab()) {
focused_window->getTab()->moveNext();
cerr<<"MOVETABNEXT TODO!"<<endl;
break;
case Keys::ATTACHLAST:
//!! just attach last window to focused window
if (focused_window) {
Workspace *space = screen->getCurrentWorkspace();
Workspace::Windows &wins = space->getWindowList();
if (wins.size() == 1)
break;
Workspace::Windows::iterator it = wins.begin();
for (; it != wins.end(); ++it) {
if ((*it) != focused_window) {
focused_window->attachClient((*it)->winClient());
break;
}
}
}
break;
case Keys::DETACHCLIENT:
if (focused_window) {
focused_window->detachClient(focused_window->winClient());
}
break;
case Keys::EXECUTE: //execute command on keypress
@ -1234,7 +1239,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
default: //try to see if its a window action
doWindowAction(action, key->getParam());
}
}
break;
}
@ -1248,9 +1253,6 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) {
if (!focused_window)
return;
unsigned int t_placement = focused_window->getScreen()->getTabPlacement();
unsigned int t_alignment = focused_window->getScreen()->getTabAlignment();
switch (action) {
case Keys::ICONIFY:
focused_window->iconify();
@ -1278,8 +1280,6 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) {
break;
case Keys::SHADE:
focused_window->shade(); // this has to be done in THIS order
if (focused_window->hasTab())
focused_window->getTab()->shade();
break;
case Keys::MAXIMIZE:
focused_window->maximize();
@ -1341,59 +1341,28 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) {
focused_window->getXFrame(), focused_window->getYFrame(),
focused_window->getWidth()+10, focused_window->getHeight());
if (focused_window->hasTab() &&
(t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) {
if (t_alignment == Tab::ARELATIVE)
focused_window->getTab()->calcIncrease();
if (t_alignment != Tab::PLEFT)
focused_window->getTab()->setPosition();
}
break;
case Keys::VERTINC:
focused_window->moveResize(
focused_window->getXFrame(), focused_window->getYFrame(),
focused_window->getWidth(), focused_window->getHeight()+10);
if (focused_window->hasTab() &&
(t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) {
if (t_alignment == Tab::ARELATIVE)
focused_window->getTab()->calcIncrease();
if (t_alignment != Tab::PRIGHT)
focused_window->getTab()->setPosition();
}
break;
case Keys::HORIZDEC:
focused_window->moveResize(
focused_window->getXFrame(), focused_window->getYFrame(),
focused_window->getWidth()-10, focused_window->getHeight());
if (focused_window->hasTab() &&
(t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) {
if (t_alignment == Tab::ARELATIVE)
focused_window->getTab()->calcIncrease();
if (t_alignment != Tab::PLEFT)
focused_window->getTab()->setPosition();
}
break;
case Keys::VERTDEC:
focused_window->moveResize(
focused_window->getXFrame(), focused_window->getYFrame(),
focused_window->getWidth(), focused_window->getHeight()-10);
if (focused_window->hasTab() &&
(t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) {
if (t_alignment == Tab::ARELATIVE)
focused_window->getTab()->calcIncrease();
if (t_alignment != Tab::PRIGHT)
focused_window->getTab()->setPosition();
}
break;
case Keys::TOGGLEDECOR:
focused_window->toggleDecoration();
break;
case Keys::TOGGLETAB:
focused_window->setTab(!focused_window->hasTab());
cerr<<"TOGGLETAB TODO!"<<endl;
break;
default: //do nothing
break;
@ -1401,7 +1370,7 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) {
}
// handle system signals here
/// handle system signals
void Fluxbox::handleSignal(int signum) {
I18n *i18n = I18n::instance();
static int re_enter = 0;
@ -1455,46 +1424,58 @@ void Fluxbox::handleSignal(int signum) {
void Fluxbox::update(FbTk::Subject *changedsub) {
//TODO: fix signaling, this does not look good
//TODO: fix signaling, this does not look good
if (typeid(*changedsub) == typeid(FluxboxWindow::WinSubject)) {
FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub);
FluxboxWindow &win = winsub->win();
if ((&(win.hintSig())) == changedsub) { // hint signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW hint signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateHints(win);
}
} else if ((&(win.stateSig())) == changedsub) { // state signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW state signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateState(win);
}
// if window changed to iconic state
// add to icon list
if (win.isIconic()) {
Workspace *space = win.getScreen().getWorkspace(win.getWorkspaceNumber());
if (space != 0)
space->removeWindow(&win);
win.getScreen().addIcon(&win);
}
if (win.isStuck()) {
// if we're sticky then reassociate window
// to all workspaces
BScreen &scr = win.getScreen();
if (scr.getCurrentWorkspaceID() != win.getWorkspaceNumber()) {
scr.reassociateWindow(&win,
scr.getCurrentWorkspaceID(),
true);
}
}
} else if ((&(win.layerSig())) == changedsub) { // layer signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW layer signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateLayer(win);
}
} else if ((&(win.dieSig())) == changedsub) { // window death signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW die signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateWindowClose(win);
}
// make sure each workspace get this
BScreen &scr = win.getScreen();
for (int workspace = 0; workspace < scr.getNumberOfWorkspaces();
++workspace) {
scr.getWorkspace(workspace)->removeWindow(&win);
}
} else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateWorkspace(win);
@ -1509,38 +1490,42 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub);
BScreen &screen = subj->screen();
if ((&(screen.workspaceCountSig())) == changedsub) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace count signal"<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateWorkspaceCount(screen);
}
} else if ((&(screen.workspaceNamesSig())) == changedsub) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace names signal"<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateWorkspaceNames(screen);
}
} else if ((&(screen.currentWorkspaceSig())) == changedsub) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN current workspace signal"<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateCurrentWorkspace(screen);
}
} else if ((&(screen.clientListSig())) == changedsub) {
#ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN client list signal"<<endl;
#endif // DEBUG
for (size_t i=0; i<m_atomhandler.size(); ++i) {
if (m_atomhandler[i]->update())
m_atomhandler[i]->updateClientList(screen);
}
}
} else if (typeid(*changedsub) == typeid(WinClient::WinClientSubj)) {
WinClient::WinClientSubj *subj = dynamic_cast<WinClient::WinClientSubj *>(changedsub);
WinClient &client = subj->winClient();
//!! TODO we shouldn't call update netizen on every screen
// just the screen it was located on
ScreenList::iterator screen_it = screenList.begin();
const ScreenList::iterator screen_it_end = screenList.end();
for (; screen_it != screen_it_end; ++screen_it)
(*screen_it)->updateNetizenWindowDel(client.window());
removeWindowSearch(client.window());
//!! TODO
#ifdef DEBUG
cerr<<__FILE__<<"("<<__FUNCTION__<<") TODO: signal stuff for client death!!"<<endl;
#endif // DEBUG
}
}
@ -1549,6 +1534,7 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
win.stateSig().attach(this);
win.workspaceSig().attach(this);
win.layerSig().attach(this);
win.winClient().dieSig().attach(this);
win.dieSig().attach(this);
for (size_t i=0; i<m_atomhandler.size(); ++i) {
m_atomhandler[i]->setupWindow(win);
@ -1556,7 +1542,7 @@ void Fluxbox::attachSignals(FluxboxWindow &win) {
}
BScreen *Fluxbox::searchScreen(Window window) {
BScreen *screen = (BScreen *) 0;
BScreen *screen = 0;
ScreenList::iterator it = screenList.begin();
ScreenList::iterator it_end = screenList.end();
@ -1569,7 +1555,7 @@ BScreen *Fluxbox::searchScreen(Window window) {
}
}
return (BScreen *) 0;
return 0;
}
@ -1584,10 +1570,6 @@ FluxboxWindow *Fluxbox::searchGroup(Window window, FluxboxWindow *win) {
return it == groupSearch.end() ? 0 : it->second;
}
Tab *Fluxbox::searchTab(Window window) {
std::map<Window, Tab *>::iterator it = tabSearch.find(window);
return it == tabSearch.end() ? 0 : it->second;
}
void Fluxbox::saveWindowSearch(Window window, FluxboxWindow *data) {
windowSearch[window] = data;
@ -1598,9 +1580,6 @@ void Fluxbox::saveGroupSearch(Window window, FluxboxWindow *data) {
groupSearch[window] = data;
}
void Fluxbox::saveTabSearch(Window window, Tab *data) {
tabSearch[window] = data;
}
void Fluxbox::removeWindowSearch(Window window) {
windowSearch.erase(window);
@ -1611,9 +1590,6 @@ void Fluxbox::removeGroupSearch(Window window) {
groupSearch.erase(window);
}
void Fluxbox::removeTabSearch(Window window) {
tabSearch.erase(window);
}
void Fluxbox::restart(const char *prog) {
shutdown();
@ -2090,15 +2066,6 @@ void Fluxbox::load_rc(BScreen *screen) {
screen->getToolbarWidthPercent() > 100)
screen->saveToolbarWidthPercent(66);
if (screen->getTabWidth()>512)
screen->saveTabWidth(512);
else if (screen->getTabWidth()<0)
screen->saveTabWidth(64);
if (screen->getTabHeight()>512)
screen->saveTabHeight(512);
else if (screen->getTabHeight()<0)
screen->saveTabHeight(5);
}
void Fluxbox::loadRootCommand(BScreen *screen) {
@ -2170,34 +2137,9 @@ void Fluxbox::real_reconfigure() {
//reconfigure keys
key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str());
//reconfigure tabs
reconfigureTabs();
}
//------------- reconfigureTabs ----------
// Reconfigure all tabs size and increase steps
// ---------------------------------------
void Fluxbox::reconfigureTabs() {
//tab reconfiguring
TabList::iterator it = tabSearch.begin();
TabList::iterator it_end = tabSearch.end();
//setting all to unconfigured
for (; it != it_end; ++it) {
it->second->setConfigured(false);
}
it = tabSearch.begin(); // resetting list and start configure tabs
//reconfiguring
for (; it != it_end; ++it) {
Tab *tab = it->second;
if (!tab->configured()) {
tab->setConfigured(true);
tab->resizeGroup();
tab->calcIncrease();
tab->setPosition();
}
}
}
void Fluxbox::checkMenu() {
Bool reread = False;
@ -2289,7 +2231,7 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
if (focused_window != 0) {
old_win = focused_window;
old_screen = old_win->getScreen();
old_screen = &old_win->getScreen();
old_tbar = old_screen->getToolbar();
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
@ -2303,7 +2245,7 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
// make sure we have a valid win pointer with a valid screen
ScreenList::iterator winscreen =
std::find(screenList.begin(), screenList.end(),
win->getScreen());
&win->getScreen());
if (winscreen == screenList.end()) {
focused_window = 0; // the window pointer wasn't valid, mark no window focused
} else {
@ -2313,6 +2255,7 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
focused_window = win; // update focused window
win->setFocusFlag(True); // set focus flag
// select this window in workspace menu
if (wkspc != 0)
wkspc->menu().setItemSelected(win->getWindowNumber(), true);
}
} else

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.hh,v 1.46 2003/04/07 13:56:20 fluxgen Exp $
// $Id: fluxbox.hh,v 1.47 2003/04/14 15:25:14 fluxgen Exp $
#ifndef FLUXBOX_HH
#define FLUXBOX_HH
@ -65,7 +65,6 @@
class AtomHandler;
class FluxboxWindow;
class Tab;
/**
main class for the window manager.
@ -81,9 +80,7 @@ public:
static Fluxbox *instance() { return singleton; }
inline bool useTabs() { return *m_rc_tabs; }
inline bool useIconBar() { return *m_rc_iconbar; }
inline void saveTabs(bool value) { *m_rc_tabs = value; }
inline void saveIconBar(bool value) { m_rc_iconbar = value; }
#ifdef HAVE_GETPID
inline Atom getFluxboxPidAtom() const { return fluxbox_pid; }
@ -99,8 +96,6 @@ public:
inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; }
inline const Time &getLastTime() const { return last_time; }
Tab *searchTab(Window);
/// obsolete
enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
@ -156,15 +151,12 @@ public:
void saveTitlebarFilename(const char *);
void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); }
void saveWindowSearch(Window, FluxboxWindow *);
void saveTabSearch(Window, Tab *);
void saveGroupSearch(Window, FluxboxWindow *);
void save_rc();
void removeWindowSearch(Window);
void removeTabSearch(Window);
void removeGroupSearch(Window);
void restart(const char * = 0);
void reconfigure();
void reconfigureTabs();
void rereadMenu();
void checkMenu();
@ -236,8 +228,6 @@ private:
std::map<Window, FluxboxWindow *> windowSearch;
std::map<Window, FluxboxWindow *> groupSearch;
typedef std::map<Window, Tab *> TabList;
TabList tabSearch;
std::list<MenuTimestamp *> menuTimestamps;
typedef std::list<BScreen *> ScreenList;