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,126 +571,127 @@ 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:
{ {
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
#ifdef SLIT #ifdef SLIT
Slit *slit = (Slit *) 0; Slit *slit = (Slit *) 0;
#endif // SLIT #endif // SLIT
if ((win = searchWindow(e->xconfigurerequest.window))) { if ((win = searchWindow(e->xconfigurerequest.window))) {
win->configureRequestEvent(&e->xconfigurerequest); win->configureRequestEvent(&e->xconfigurerequest);
#ifdef SLIT #ifdef SLIT
} else if ((slit = searchSlit(e->xconfigurerequest.window))) { } else if ((slit = searchSlit(e->xconfigurerequest.window))) {
slit->configureRequestEvent(&e->xconfigurerequest); slit->configureRequestEvent(&e->xconfigurerequest);
#endif // SLIT #endif // SLIT
} else { } else {
grab(); grab();
if (validateWindow(e->xconfigurerequest.window)) { if (validateWindow(e->xconfigurerequest.window)) {
XWindowChanges xwc; XWindowChanges xwc;
xwc.x = e->xconfigurerequest.x; xwc.x = e->xconfigurerequest.x;
xwc.y = e->xconfigurerequest.y; xwc.y = e->xconfigurerequest.y;
xwc.width = e->xconfigurerequest.width; xwc.width = e->xconfigurerequest.width;
xwc.height = e->xconfigurerequest.height; xwc.height = e->xconfigurerequest.height;
xwc.border_width = e->xconfigurerequest.border_width; xwc.border_width = e->xconfigurerequest.border_width;
xwc.sibling = e->xconfigurerequest.above; xwc.sibling = e->xconfigurerequest.above;
xwc.stack_mode = e->xconfigurerequest.detail; xwc.stack_mode = e->xconfigurerequest.detail;
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window, XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
e->xconfigurerequest.value_mask, &xwc); e->xconfigurerequest.value_mask, &xwc);
}
ungrab();
} }
ungrab();
} }
break;
}
break;
case MapRequest: case MapRequest:
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, fprintf(stderr,
I18n::instance()-> I18n::instance()->
getMessage( getMessage(
FBNLS::blackboxSet, FBNLS::blackboxMapRequest, FBNLS::blackboxSet, FBNLS::blackboxMapRequest,
"Fluxbox::process_event(): MapRequest for 0x%lx\n"), "Fluxbox::process_event(): MapRequest for 0x%lx\n"),
e->xmaprequest.window); e->xmaprequest.window);
#endif // DEBUG #endif // DEBUG
#ifdef SLIT #ifdef SLIT
#ifdef KDE #ifdef KDE
//Check and see if client is KDE dock applet. //Check and see if client is KDE dock applet.
//If so add to Slit //If so add to Slit
bool iskdedockapp = false; bool iskdedockapp = false;
Atom ajunk; Atom ajunk;
int ijunk; int ijunk;
unsigned long *data = (unsigned long *) 0, uljunk; unsigned long *data = (unsigned long *) 0, uljunk;
// Check if KDE v2.x dock applet // Check if KDE v2.x dock applet
if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window,
getKWM2DockwindowAtom(), 0l, 1l, False,
XA_WINDOW, &ajunk, &ijunk, &uljunk,
&uljunk, (unsigned char **) &data) == Success) {
if (data)
iskdedockapp = True;
XFree((char *) data);
}
// Check if KDE v1.x dock applet
if (!iskdedockapp) {
if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window,
getKWM1DockwindowAtom(), 0l, 1l, False, getKWM2DockwindowAtom(), 0l, 1l, False,
getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk, XA_WINDOW, &ajunk, &ijunk, &uljunk,
&uljunk, (unsigned char **) &data) == Success) { &uljunk, (unsigned char **) &data) == Success) {
iskdedockapp = (data && data[0] != 0);
if (data)
iskdedockapp = True;
XFree((char *) data); XFree((char *) data);
} }
}
if (iskdedockapp) { // Check if KDE v1.x dock applet
XSelectInput(getXDisplay(), e->xmaprequest.window, StructureNotifyMask); if (!iskdedockapp) {
ScreenList::iterator it = screenList.begin(); if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window,
for (; (*it) == screenList.back(); ++it) { getKWM1DockwindowAtom(), 0l, 1l, False,
(*it)->getSlit()->addClient(e->xmaprequest.window); getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk,
&uljunk, (unsigned char **) &data) == Success) {
iskdedockapp = (data && data[0] != 0);
XFree((char *) data);
}
}
if (iskdedockapp) {
XSelectInput(getXDisplay(), e->xmaprequest.window, StructureNotifyMask);
ScreenList::iterator it = screenList.begin();
for (; (*it) == screenList.back(); ++it) {
(*it)->getSlit()->addClient(e->xmaprequest.window);
}
return;
} }
return;
}
#endif //KDE #endif //KDE
#endif // SLIT #endif // SLIT
FluxboxWindow *win = searchWindow(e->xmaprequest.window); FluxboxWindow *win = searchWindow(e->xmaprequest.window);
if (! win) { if (! win) {
win = new FluxboxWindow(e->xmaprequest.window); win = new FluxboxWindow(e->xmaprequest.window);
if (!win->isManaged()) { if (!win->isManaged()) {
delete win; delete win;
win = 0; win = 0;
} else { } else {
// attach signals // attach signals
attachSignals(*win); attachSignals(*win);
}
} }
if ((win = searchWindow(e->xmaprequest.window)))
win->mapRequestEvent(&e->xmaprequest);
} }
break;
if ((win = searchWindow(e->xmaprequest.window)))
win->mapRequestEvent(&e->xmaprequest);
}
break;
case MapNotify: case MapNotify:
{ {
FluxboxWindow *win = searchWindow(e->xmap.window); FluxboxWindow *win = searchWindow(e->xmap.window);
if (win != 0) if (win != 0)
win->mapNotifyEvent(&e->xmap); win->mapNotifyEvent(&e->xmap);
} }
break; break;
case UnmapNotify: case UnmapNotify:
@ -721,7 +721,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
#endif // SLIT #endif // SLIT
} }
break; break;
case MotionNotify: { case MotionNotify: {
last_time = e->xmotion.time; last_time = e->xmotion.time;
@ -738,7 +738,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
} }
break; break;
case PropertyNotify: { case PropertyNotify: {
last_time = e->xproperty.time; last_time = e->xproperty.time;
@ -751,14 +751,14 @@ void Fluxbox::handleEvent(XEvent * const e) {
} }
} }
break; break;
case EnterNotify: { case EnterNotify: {
last_time = e->xcrossing.time; last_time = e->xcrossing.time;
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)) {
@ -807,62 +807,65 @@ 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);
}
} }
break; break;
case LeaveNotify: case LeaveNotify:
{ {
last_time = e->xcrossing.time; last_time = e->xcrossing.time;
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;
#endif // SLIT #endif // SLIT
if ((menu = searchMenu(e->xcrossing.window))) if ((menu = searchMenu(e->xcrossing.window)))
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;
case Expose: case Expose:
{ {
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))) else if ((tab = searchTab(e->xexpose.window)))
tbar->exposeEvent(&e->xexpose); tab->exposeEvent(&e->xexpose);
else if ((tab = searchTab(e->xexpose.window))) else
tab->exposeEvent(&e->xexpose); 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);
@ -872,7 +875,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
ColormapInstalled) ? True : False); ColormapInstalled) ? True : False);
} }
} }
break; break;
case FocusIn: { case FocusIn: {
if (e->xfocus.mode == NotifyUngrab || if (e->xfocus.mode == NotifyUngrab ||
e->xfocus.detail == NotifyPointer) e->xfocus.detail == NotifyPointer)
@ -891,17 +894,17 @@ void Fluxbox::handleEvent(XEvent * const e) {
default: { default: {
#ifdef SHAPE #ifdef SHAPE
if (e->type == getShapeEventBase()) { if (e->type == getShapeEventBase()) {
XShapeEvent *shape_event = (XShapeEvent *) e; XShapeEvent *shape_event = (XShapeEvent *) e;
FluxboxWindow *win = (FluxboxWindow *) 0; FluxboxWindow *win = (FluxboxWindow *) 0;
if ((win = searchWindow(e->xany.window)) ||
(shape_event->kind != ShapeBounding))
win->shapeEvent(shape_event);
}
#endif // SHAPE
if ((win = searchWindow(e->xany.window)) ||
(shape_event->kind != ShapeBounding))
win->shapeEvent(shape_event);
} }
#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);
} }
@ -1151,252 +1146,251 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
void Fluxbox::handleKeyEvent(XKeyEvent &ke) { 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) {
#ifdef DEBUG
cerr<<"KeyEvent"<<endl;
#endif
//find action
Keys::KeyAction action = key->getAction(&ke);
#ifdef DEBUG
const char *actionstr = key->getActionStr(action);
if (actionstr)
cerr<<"KeyAction("<<actionstr<<")"<<endl;
#endif
if (action==Keys::LASTKEYGRAB) //if action not found end case
break;
// what to allow if moving if (screen) {
if (focused_window && focused_window->isMoving()) { #ifdef DEBUG
int allowed = false; cerr<<"KeyEvent"<<endl;
switch (action) { #endif
case Keys::WORKSPACE: //find action
case Keys::SENDTOWORKSPACE: Keys::KeyAction action = key->getAction(&ke);
case Keys::WORKSPACE1: #ifdef DEBUG
case Keys::WORKSPACE2: const char *actionstr = key->getActionStr(action);
case Keys::WORKSPACE3: if (actionstr)
case Keys::WORKSPACE4: cerr<<"KeyAction("<<actionstr<<")"<<endl;
case Keys::WORKSPACE5: #endif
case Keys::WORKSPACE6: if (action==Keys::LASTKEYGRAB) //if action not found end case
case Keys::WORKSPACE7:
case Keys::WORKSPACE8:
case Keys::WORKSPACE9:
case Keys::WORKSPACE10:
case Keys::WORKSPACE11:
case Keys::WORKSPACE12:
case Keys::NEXTWORKSPACE:
case Keys::PREVWORKSPACE:
case Keys::LEFTWORKSPACE:
case Keys::RIGHTWORKSPACE:
allowed = true;
break; break;
default:
allowed = false;
}
if (!allowed) break;
}
switch (action) { // what to allow if moving
case Keys::WORKSPACE: if (focused_window && focused_window->isMoving()) {
// Workspace1 has id 0, hence -1 int allowed = false;
screen->changeWorkspaceID(key->getParam()-1); switch (action) {
break; case Keys::WORKSPACE:
case Keys::SENDTOWORKSPACE: case Keys::SENDTOWORKSPACE:
// Workspace1 has id 0, hence -1 case Keys::WORKSPACE1:
screen->sendToWorkspace(key->getParam()-1); case Keys::WORKSPACE2:
break; case Keys::WORKSPACE3:
// NOTE!!! The WORKSPACEn commands are not needed anymore case Keys::WORKSPACE4:
case Keys::WORKSPACE1: case Keys::WORKSPACE5:
screen->changeWorkspaceID(0); case Keys::WORKSPACE6:
break; case Keys::WORKSPACE7:
case Keys::WORKSPACE2: case Keys::WORKSPACE8:
screen->changeWorkspaceID(1); case Keys::WORKSPACE9:
break; case Keys::WORKSPACE10:
case Keys::WORKSPACE3: case Keys::WORKSPACE11:
screen->changeWorkspaceID(2); case Keys::WORKSPACE12:
break; case Keys::NEXTWORKSPACE:
case Keys::WORKSPACE4: case Keys::PREVWORKSPACE:
screen->changeWorkspaceID(3); case Keys::LEFTWORKSPACE:
break; case Keys::RIGHTWORKSPACE:
case Keys::WORKSPACE5: allowed = true;
screen->changeWorkspaceID(4); break;
break; default:
case Keys::WORKSPACE6: allowed = false;
screen->changeWorkspaceID(5); }
break; if (!allowed) break;
case Keys::WORKSPACE7:
screen->changeWorkspaceID(6);
break;
case Keys::WORKSPACE8:
screen->changeWorkspaceID(7);
break;
case Keys::WORKSPACE9:
screen->changeWorkspaceID(8);
break;
case Keys::WORKSPACE10:
screen->changeWorkspaceID(9);
break;
case Keys::WORKSPACE11:
screen->changeWorkspaceID(10);
break;
case Keys::WORKSPACE12:
screen->changeWorkspaceID(11);
break;
case Keys::NEXTWORKSPACE:
screen->nextWorkspace(key->getParam());
break;
case Keys::PREVWORKSPACE:
screen->prevWorkspace(key->getParam());
break;
case Keys::LEFTWORKSPACE:
screen->leftWorkspace(key->getParam());
break;
case Keys::RIGHTWORKSPACE:
screen->rightWorkspace(key->getParam());
break;
case Keys::KILLWINDOW: //kill the current window
if (focused_window) {
XKillClient(screen->getBaseDisplay()->getXDisplay(),
focused_window->getClientWindow());
} }
break;
case Keys::NEXTWINDOW: //activate next window switch (action) {
screen->nextFocus(key->getParam()); case Keys::WORKSPACE:
if (focused_window && focused_window->getTab()) // Workspace1 has id 0, hence -1
focused_window->getTab()->raise(); screen->changeWorkspaceID(key->getParam()-1);
break; break;
case Keys::PREVWINDOW: //activate prev window case Keys::SENDTOWORKSPACE:
screen->prevFocus(key->getParam()); // Workspace1 has id 0, hence -1
if (focused_window && focused_window->getTab()) screen->sendToWorkspace(key->getParam()-1);
focused_window->getTab()->raise(); break;
break; // NOTE!!! The WORKSPACEn commands are not needed anymore
case Keys::NEXTTAB: case Keys::WORKSPACE1:
if (focused_window && focused_window->getTab()) { screen->changeWorkspaceID(0);
Tab *tab = focused_window->getTab(); break;
if (tab->next()) { case Keys::WORKSPACE2:
screen->changeWorkspaceID(1);
break;
case Keys::WORKSPACE3:
screen->changeWorkspaceID(2);
break;
case Keys::WORKSPACE4:
screen->changeWorkspaceID(3);
break;
case Keys::WORKSPACE5:
screen->changeWorkspaceID(4);
break;
case Keys::WORKSPACE6:
screen->changeWorkspaceID(5);
break;
case Keys::WORKSPACE7:
screen->changeWorkspaceID(6);
break;
case Keys::WORKSPACE8:
screen->changeWorkspaceID(7);
break;
case Keys::WORKSPACE9:
screen->changeWorkspaceID(8);
break;
case Keys::WORKSPACE10:
screen->changeWorkspaceID(9);
break;
case Keys::WORKSPACE11:
screen->changeWorkspaceID(10);
break;
case Keys::WORKSPACE12:
screen->changeWorkspaceID(11);
break;
case Keys::NEXTWORKSPACE:
screen->nextWorkspace(key->getParam());
break;
case Keys::PREVWORKSPACE:
screen->prevWorkspace(key->getParam());
break;
case Keys::LEFTWORKSPACE:
screen->leftWorkspace(key->getParam());
break;
case Keys::RIGHTWORKSPACE:
screen->rightWorkspace(key->getParam());
break;
case Keys::KILLWINDOW: //kill the current window
if (focused_window) {
XKillClient(screen->getBaseDisplay()->getXDisplay(),
focused_window->getClientWindow());
}
break;
case Keys::NEXTWINDOW: //activate next window
screen->nextFocus(key->getParam());
if (focused_window && focused_window->getTab())
focused_window->getTab()->raise();
break;
case Keys::PREVWINDOW: //activate prev window
screen->prevFocus(key->getParam());
if (focused_window && focused_window->getTab())
focused_window->getTab()->raise();
break;
case Keys::NEXTTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
if (tab->next()) {
screen->getCurrentWorkspace()->raiseWindow(
tab->next()->getWindow());
tab->next()->getWindow()->setInputFocus();
} else {
screen->getCurrentWorkspace()->raiseWindow(
tab->first()->getWindow());
tab->first()->getWindow()->setInputFocus();
}
}
break;
case Keys::PREVTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
if (tab->prev()) {
screen->getCurrentWorkspace()->raiseWindow(
tab->prev()->getWindow());
tab->prev()->getWindow()->setInputFocus();
} else {
screen->getCurrentWorkspace()->raiseWindow(
tab->last()->getWindow());
tab->last()->getWindow()->setInputFocus();
}
}
break;
case Keys::FIRSTTAB:
if (focused_window && focused_window->getTab()) {
Tab *tab = focused_window->getTab();
screen->getCurrentWorkspace()->raiseWindow( screen->getCurrentWorkspace()->raiseWindow(
tab->next()->getWindow()); tab->first()->getWindow());
tab->next()->getWindow()->setInputFocus();
} else {
screen->getCurrentWorkspace()->raiseWindow(
tab->first()->getWindow());
tab->first()->getWindow()->setInputFocus(); tab->first()->getWindow()->setInputFocus();
} }
} break;
break; case Keys::LASTTAB:
case Keys::PREVTAB: if (focused_window && focused_window->getTab()) {
if (focused_window && focused_window->getTab()) { Tab *tab = focused_window->getTab();
Tab *tab = focused_window->getTab();
if (tab->prev()) {
screen->getCurrentWorkspace()->raiseWindow( screen->getCurrentWorkspace()->raiseWindow(
tab->prev()->getWindow()); tab->last()->getWindow());
tab->prev()->getWindow()->setInputFocus();
} else {
screen->getCurrentWorkspace()->raiseWindow(
tab->last()->getWindow());
tab->last()->getWindow()->setInputFocus(); tab->last()->getWindow()->setInputFocus();
} }
} break;
break; case Keys::MOVETABPREV:
case Keys::FIRSTTAB: if (focused_window && focused_window->getTab()) {
if (focused_window && focused_window->getTab()) { focused_window->getTab()->movePrev();
Tab *tab = focused_window->getTab(); }
screen->getCurrentWorkspace()->raiseWindow( break;
tab->first()->getWindow()); case Keys::MOVETABNEXT:
tab->first()->getWindow()->setInputFocus(); if (focused_window && focused_window->getTab()) {
} focused_window->getTab()->moveNext();
break; }
case Keys::LASTTAB: break;
if (focused_window && focused_window->getTab()) { case Keys::EXECUTE: //execute command on keypress
Tab *tab = focused_window->getTab(); {
screen->getCurrentWorkspace()->raiseWindow(
tab->last()->getWindow());
tab->last()->getWindow()->setInputFocus();
}
break;
case Keys::MOVETABPREV:
if (focused_window && focused_window->getTab()) {
focused_window->getTab()->movePrev();
}
break;
case Keys::MOVETABNEXT:
if (focused_window && focused_window->getTab()) {
focused_window->getTab()->moveNext();
}
break;
case Keys::EXECUTE: //execute command on keypress
{
#ifndef __EMX__ #ifndef __EMX__
char displaystring[MAXPATHLEN]; char displaystring[MAXPATHLEN];
sprintf(displaystring, "DISPLAY=%s", sprintf(displaystring, "DISPLAY=%s",
DisplayString(getXDisplay())); DisplayString(getXDisplay()));
sprintf(displaystring + strlen(displaystring) - 1, "%d", sprintf(displaystring + strlen(displaystring) - 1, "%d",
screen->getScreenNumber()); screen->getScreenNumber());
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): Executing:"<<key->getExecCommand().c_str()<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): Executing:"<<key->getExecCommand().c_str()<<endl;
#endif // DEBUG #endif // DEBUG
bexec(key->getExecCommand().c_str(), displaystring); bexec(key->getExecCommand().c_str(), displaystring);
#else #else
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL); spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL);
#endif // !__EMX__ #endif // !__EMX__
} }
break; break;
case Keys::ROOTMENU: //show root menu case Keys::ROOTMENU: //show root menu
{ {
ScreenList::iterator it = screenList.begin(); ScreenList::iterator it = screenList.begin();
ScreenList::iterator it_end = screenList.end(); ScreenList::iterator it_end = screenList.end();
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
BScreen *screen = (*it); BScreen *screen = (*it);
if (ke.window != screen->getRootWindow()) if (ke.window != screen->getRootWindow())
continue; continue;
//calculate placement of workspace menu //calculate placement of workspace menu
//and show/hide it //and show/hide it
int mx = ke.x_root - int mx = ke.x_root -
(screen->getRootmenu()->width() / 2); (screen->getRootmenu()->width() / 2);
int my = ke.y_root - int my = ke.y_root -
(screen->getRootmenu()->titleHeight() / 2); (screen->getRootmenu()->titleHeight() / 2);
if (mx < 0) mx = 0; if (mx < 0) mx = 0;
if (my < 0) my = 0; if (my < 0) my = 0;
if (mx + screen->getRootmenu()->width() > screen->getWidth()) { if (mx + screen->getRootmenu()->width() > screen->getWidth()) {
mx = screen->getWidth() - mx = screen->getWidth() -
screen->getRootmenu()->width() - screen->getRootmenu()->width() -
screen->getBorderWidth(); screen->getBorderWidth();
} }
if (my + screen->getRootmenu()->height() > if (my + screen->getRootmenu()->height() >
screen->getHeight()) { screen->getHeight()) {
my = screen->getHeight() - my = screen->getHeight() -
screen->getRootmenu()->height() - screen->getRootmenu()->height() -
screen->getBorderWidth(); screen->getBorderWidth();
} }
screen->getRootmenu()->move(mx, my); screen->getRootmenu()->move(mx, my);
if (! screen->getRootmenu()->isVisible()) { if (! screen->getRootmenu()->isVisible()) {
checkMenu(); checkMenu();
screen->getRootmenu()->show(); screen->getRootmenu()->show();
}
}
} }
break;
default: //try to see if its a window action
doWindowAction(action, key->getParam());
} }
} }
break; break;
default: //try to see if its a window action
doWindowAction(action, key->getParam());
}
} }
break;
}
default: default:
break; break;
@ -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