indentation and EventManager usage

This commit is contained in:
fluxgen 2002-12-02 23:49:56 +00:00
parent 29c647645b
commit 0611f932ee

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.cc,v 1.84 2002/12/01 13:42:06 rathnor Exp $ // $Id: fluxbox.cc,v 1.85 2002/12/02 23:49:56 fluxgen Exp $
#include "fluxbox.hh" #include "fluxbox.hh"
@ -41,6 +41,7 @@
#include "XrmDatabaseHelper.hh" #include "XrmDatabaseHelper.hh"
#include "AtomHandler.hh" #include "AtomHandler.hh"
#include "ImageControl.hh" #include "ImageControl.hh"
#include "EventManager.hh"
//Use GNU extensions //Use GNU extensions
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -409,13 +410,11 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc
I18n *i18n = I18n::instance(); I18n *i18n = I18n::instance();
if (screenList.size() == 0) { if (screenList.size() == 0) {
fprintf(stderr, throw string(
i18n-> i18n->
getMessage( getMessage(
FBNLS::blackboxSet, FBNLS::blackboxNoManagableScreens, FBNLS::blackboxSet, FBNLS::blackboxNoManagableScreens,
"Fluxbox::Fluxbox: no managable screens found, aborting.\n")); "Fluxbox::Fluxbox: no managable screens found, aborting."));
throw static_cast<int>(3);
} }
XSynchronize(getXDisplay(), False); XSynchronize(getXDisplay(), False);
@ -572,6 +571,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
case ButtonRelease: case ButtonRelease:
case ButtonPress: case ButtonPress:
handleButtonEvent(e->xbutton); handleButtonEvent(e->xbutton);
FbTk::EventManager::instance()->handleEvent(*e);
break; break;
case ConfigureRequest: case ConfigureRequest:
{ {
@ -758,7 +758,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
BScreen *screen = (BScreen *) 0; BScreen *screen = (BScreen *) 0;
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
Basemenu *menu = (Basemenu *) 0; Basemenu *menu = (Basemenu *) 0;
Toolbar *tbar = (Toolbar *) 0;
Tab *tab = (Tab *) 0; Tab *tab = (Tab *) 0;
#ifdef SLIT #ifdef SLIT
Slit *slit = (Slit *) 0; Slit *slit = (Slit *) 0;
@ -791,9 +791,9 @@ void Fluxbox::handleEvent(XEvent * const e) {
} }
} else if ((menu = searchMenu(e->xcrossing.window))) } else if ((menu = searchMenu(e->xcrossing.window)))
menu->enterNotifyEvent(&e->xcrossing); menu->enterNotifyEvent(&e->xcrossing);
else if ((tbar = searchToolbar(e->xcrossing.window))) /* else if ((tbar = searchToolbar(e->xcrossing.window)))
tbar->enterNotifyEvent(&e->xcrossing); tbar->enterNotifyEvent(&e->xcrossing);
else if ((tab = searchTab(e->xcrossing.window))) { */else if ((tab = searchTab(e->xcrossing.window))) {
win = tab->getWindow(); win = tab->getWindow();
if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) && if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) &&
(! no_focus)) { (! no_focus)) {
@ -808,11 +808,13 @@ void Fluxbox::handleEvent(XEvent * const e) {
ungrab(); ungrab();
} }
} }
#ifdef SLIT #ifdef SLIT
else if ((slit = searchSlit(e->xcrossing.window))) else if ((slit = searchSlit(e->xcrossing.window)))
slit->enterNotifyEvent(&e->xcrossing); slit->enterNotifyEvent(&e->xcrossing);
#endif // SLIT #endif // SLIT
else {
FbTk::EventManager::instance()->handleEvent(*e);
}
} }
@ -823,7 +825,6 @@ void Fluxbox::handleEvent(XEvent * const e) {
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
Basemenu *menu = (Basemenu *) 0; Basemenu *menu = (Basemenu *) 0;
Toolbar *tbar = (Toolbar *) 0;
#ifdef SLIT #ifdef SLIT
Slit *slit = (Slit *) 0; Slit *slit = (Slit *) 0;
@ -833,13 +834,16 @@ void Fluxbox::handleEvent(XEvent * const e) {
menu->leaveNotifyEvent(&e->xcrossing); menu->leaveNotifyEvent(&e->xcrossing);
else if ((win = searchWindow(e->xcrossing.window))) else if ((win = searchWindow(e->xcrossing.window)))
win->installColormap(False); win->installColormap(False);
else if ((tbar = searchToolbar(e->xcrossing.window))) /* else if ((tbar = searchToolbar(e->xcrossing.window)))
tbar->leaveNotifyEvent(&e->xcrossing); tbar->leaveNotifyEvent(&e->xcrossing);
*/
#ifdef SLIT #ifdef SLIT
else if ((slit = searchSlit(e->xcrossing.window))) else if ((slit = searchSlit(e->xcrossing.window)))
slit->leaveNotifyEvent(&e->xcrossing); slit->leaveNotifyEvent(&e->xcrossing);
#endif // SLIT #endif // SLIT
else {
FbTk::EventManager::instance()->handleEvent(*e);
}
} }
break; break;
@ -847,22 +851,21 @@ void Fluxbox::handleEvent(XEvent * const e) {
{ {
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
Basemenu *menu = (Basemenu *) 0; Basemenu *menu = (Basemenu *) 0;
Toolbar *tbar = (Toolbar *) 0;
Tab *tab = 0; Tab *tab = 0;
if ((win = searchWindow(e->xexpose.window))) if ((win = searchWindow(e->xexpose.window)))
win->exposeEvent(&e->xexpose); win->exposeEvent(&e->xexpose);
else if ((menu = searchMenu(e->xexpose.window))) else if ((menu = searchMenu(e->xexpose.window)))
menu->exposeEvent(&e->xexpose); menu->exposeEvent(&e->xexpose);
else if ((tbar = searchToolbar(e->xexpose.window)))
tbar->exposeEvent(&e->xexpose);
else if ((tab = searchTab(e->xexpose.window))) else if ((tab = searchTab(e->xexpose.window)))
tab->exposeEvent(&e->xexpose); tab->exposeEvent(&e->xexpose);
else
FbTk::EventManager::instance()->handleEvent(*e);
} }
break; break;
case KeyPress: case KeyPress:
handleKeyEvent(e->xkey); handleKeyEvent(e->xkey);
FbTk::EventManager::instance()->handleEvent(*e);
break; break;
case ColormapNotify: { case ColormapNotify: {
BScreen *screen = searchScreen(e->xcolormap.window); BScreen *screen = searchScreen(e->xcolormap.window);
@ -900,7 +903,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
win->shapeEvent(shape_event); win->shapeEvent(shape_event);
} }
#endif // SHAPE #endif // SHAPE
FbTk::EventManager::instance()->handleEvent(*e);
} }
} }
} }
@ -911,16 +914,13 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
{ {
last_time = be.time; last_time = be.time;
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = 0;
Basemenu *menu = (Basemenu *) 0; Basemenu *menu = 0;
Tab *tab = 0;
#ifdef SLIT #ifdef SLIT
Slit *slit = (Slit *) 0; Slit *slit = (Slit *) 0;
#endif // SLIT #endif // SLIT
Toolbar *tbar = (Toolbar *) 0;
Tab *tab = 0;
if ((win = searchWindow(be.window))) { if ((win = searchWindow(be.window))) {
win->buttonPressEvent(&be); win->buttonPressEvent(&be);
@ -930,15 +930,13 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
} else if ((menu = searchMenu(be.window))) { } else if ((menu = searchMenu(be.window))) {
menu->buttonPressEvent(&be); menu->buttonPressEvent(&be);
}
#ifdef SLIT #ifdef SLIT
} else if ((slit = searchSlit(be.window))) { else if ((slit = searchSlit(be.window))) {
slit->buttonPressEvent(&be); slit->buttonPressEvent(&be);
}
#endif // SLIT #endif // SLIT
else if ((tab = searchTab(be.window))) {
} else if ((tbar = searchToolbar(be.window))) {
tbar->buttonPressEvent(&be);
} else if ((tab = searchTab(be.window))) {
tab->buttonPressEvent(&be); tab->buttonPressEvent(&be);
} else { } else {
ScreenList::iterator it = screenList.begin(); ScreenList::iterator it = screenList.begin();
@ -1032,15 +1030,12 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
last_time = be.time; last_time = be.time;
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
Basemenu *menu = (Basemenu *) 0; Basemenu *menu = (Basemenu *) 0;
Toolbar *tbar = (Toolbar *) 0;
Tab *tab = 0; Tab *tab = 0;
if ((win = searchWindow(be.window))) if ((win = searchWindow(be.window)))
win->buttonReleaseEvent(&be); win->buttonReleaseEvent(&be);
else if ((menu = searchMenu(be.window))) else if ((menu = searchMenu(be.window)))
menu->buttonReleaseEvent(&be); menu->buttonReleaseEvent(&be);
else if ((tbar = searchToolbar(be.window)))
tbar->buttonReleaseEvent(&be);
else if ((tab = searchTab(be.window))) else if ((tab = searchTab(be.window)))
tab->buttonReleaseEvent(&be); tab->buttonReleaseEvent(&be);
} }
@ -1152,12 +1147,11 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
switch (ke.type) { switch (ke.type) {
case KeyPress: case KeyPress:
{ {
Toolbar *tbar = searchToolbar(ke.window);
BScreen *screen = searchScreen(ke.window); BScreen *screen = searchScreen(ke.window);
if (tbar && tbar->isEditing())
tbar->keyPressEvent(&ke);
else if (screen) { if (screen) {
#ifdef DEBUG #ifdef DEBUG
cerr<<"KeyEvent"<<endl; cerr<<"KeyEvent"<<endl;
#endif #endif
@ -2359,19 +2353,18 @@ void Fluxbox::load_rc(BScreen *screen) {
} }
void Fluxbox::loadRootCommand(BScreen *screen) { void Fluxbox::loadRootCommand(BScreen *screen) {
XrmDatabase database = (XrmDatabase) 0;
string dbfile(getRcFilename()); string dbfile(getRcFilename());
database = XrmGetFileDatabase(dbfile.c_str()); XrmDatabaseHelper database(dbfile.c_str());
if (!database) if (!*database)
database = XrmGetFileDatabase(DEFAULT_INITFILE); database = XrmGetFileDatabase(DEFAULT_INITFILE);
XrmValue value; XrmValue value;
char *value_type, name_lookup[1024], class_lookup[1024]; char *value_type, name_lookup[1024], class_lookup[1024];
sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber());
sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber());
if (XrmGetResource(database, name_lookup, class_lookup, &value_type, if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
&value)) { &value)) {
screen->saveRootCommand(value.addr==0 ? "": value.addr); screen->saveRootCommand(value.addr==0 ? "": value.addr);
} else } else