added special FocusIn/Out MouseOver/Out ChangeWorkspace keys
markt markt
8 files changed,
90 insertions(+),
17 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,6 +1,20 @@
(Format: Year/Month/Day) Changes for 1.0.1: *07/11/22: + * Added some new special keys to the keys file: FocusIn, FocusOut, MouseOver, + MouseOut, ChangeWorkspace (Mark) + - FocusIn/FocusOut correspond to a window gaining or losing focus, e.g. the + following will raise all xterms when one gains focus: + FocusIn :If {Matches (xterm)} {Raise (xterm)} {} + - MouseOver/MouseOut correspond to the mouse moving over the window or + toolbar (when used with OnToolbar) -- OnDesktop not yet supported, e.g. + the following will unshade a window when you move your mouse over it with + alt pressed: + Mod1 MouseOver :If {Matches (shaded=yes)} {Shade} {} + - ChangeWorkspace corresponds to the workspace being changed, e.g. the + following will set a different wallpaper for each workspace: + ChangeWorkspace :Exec fbsetbg ~/.fluxbox/bg$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}').png + Keys.cc Window.cc Screen.cc Toolbar.cc * Added translations for zh_TW (thanks Wei-Lun Chao) * Fix division by 0 error when resize increments are set to 0 by an application, bug #1836182
M
src/FbCommandFactory.cc
→
src/FbCommandFactory.cc
@@ -809,17 +809,16 @@
pos = err; err = FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + pos, '{', '}', " \t\n", true); - if (err > 0) - t = CommandParser::instance().parseLine(cmd, trusted); - if (err == 0 || *t == 0) + if (err == 0) return 0; + t = CommandParser::instance().parseLine(cmd, trusted); pos += err; err = FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + pos, '{', '}', " \t\n", true); if (err > 0) f = CommandParser::instance().parseLine(cmd, trusted); - if (err == 0 || *f == 0) + if (err == 0 || *t == 0 && *f == 0) return 0; return new FbTk::IfCommand(cond, t, f);
M
src/FbTk/LogicCommands.hh
→
src/FbTk/LogicCommands.hh
@@ -38,10 +38,10 @@ IfCommand(RefCount<BoolCommand> &cond,
RefCount<Command> &t, RefCount<Command> &f): m_cond(cond), m_t(t), m_f(f) { } void execute() { - if (m_cond->bool_execute()) - m_t->execute(); - else - m_f->execute(); + if (m_cond->bool_execute()) { + if (*m_t) m_t->execute(); + } else + if (*m_f) m_f->execute(); } private:
M
src/FbWinFrame.cc
→
src/FbWinFrame.cc
@@ -55,7 +55,8 @@ m_theme(theme),
m_imagectrl(imgctrl), m_window(theme.screenNum(), x, y, width, height, ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask, true), + ButtonMotionMask | EnterWindowMask | + LeaveWindowMask, true), m_layeritem(window(), layer), m_titlebar(m_window, 0, 0, 100, 16, ButtonPressMask | ButtonReleaseMask |@@ -666,7 +667,8 @@ win.setEventMask(PropertyChangeMask | StructureNotifyMask |
FocusChangeMask | KeyPressMask); m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask); + ButtonMotionMask | EnterWindowMask | + LeaveWindowMask | SubstructureRedirectMask); XFlush(win.display());
M
src/Keys.cc
→
src/Keys.cc
@@ -307,10 +307,35 @@ else if (strcasecmp("onwindow", val[argc].c_str()) == 0)
context |= ON_WINDOW; else if (strcasecmp("NONE",val[argc].c_str())) { // check if it's a mouse button - if (!strcasecmp(val[argc].substr(0,5).c_str(), "mouse") && - val[argc].length() > 5) { + if (strcasecmp("focusin", val[argc].c_str()) == 0) { + context = ON_WINDOW; + mod = key = 0; + type = FocusIn; + } else if (strcasecmp("focusout", val[argc].c_str()) == 0) { + context = ON_WINDOW; + mod = key = 0; + type = FocusOut; + } else if (strcasecmp("changeworkspace", + val[argc].c_str()) == 0) { + context = ON_DESKTOP; + mod = key = 0; + type = FocusIn; + } else if (strcasecmp("mouseover", val[argc].c_str()) == 0) { + type = EnterNotify; + if (!(context & (ON_WINDOW|ON_TOOLBAR))) + context |= ON_WINDOW; + key = 0; + } else if (strcasecmp("mouseout", val[argc].c_str()) == 0) { + type = LeaveNotify; + if (!(context & (ON_WINDOW|ON_TOOLBAR))) + context |= ON_WINDOW; + key = 0; + } else if (strcasecmp(val[argc].substr(0,5).c_str(), + "mouse") == 0 && + val[argc].length() > 5) { type = ButtonPress; - key = atoi(val[argc].substr(5,val[argc].length()-5).c_str()); + key = atoi(val[argc].substr(5, + val[argc].length()-5).c_str()); // keycode covers the following three two-byte cases: // 0x - hex // +[1-9] - number between +1 and +9@@ -331,7 +356,7 @@ key = FbTk::KeyUtil::getKey(val[argc].c_str());
type = KeyPress; } - if (key == 0) + if (key == 0 && (type == KeyPress || type == ButtonPress)) return false; if (!first_new_key) { first_new_keylist = current_key;
M
src/Screen.cc
→
src/Screen.cc
@@ -1237,6 +1237,8 @@ FbTk::App::instance()->sync(false);
m_currentworkspace_sig.notify(); + // do this after atom handlers, so scripts can access new workspace number + Fluxbox::instance()->keys()->doAction(FocusIn, 0, 0, Keys::ON_DESKTOP); }
M
src/Toolbar.cc
→
src/Toolbar.cc
@@ -556,7 +556,9 @@ menu().hide();
} -void Toolbar::enterNotifyEvent(XCrossingEvent ¬_used) { +void Toolbar::enterNotifyEvent(XCrossingEvent &ce) { + Fluxbox::instance()->keys()->doAction(ce.type, ce.state, 0, + Keys::ON_TOOLBAR); if (! doAutoHide()) { if (isHidden()) toggleHidden();@@ -573,11 +575,14 @@ }
} void Toolbar::leaveNotifyEvent(XCrossingEvent &event) { - if (! doAutoHide()) - return; // still inside? if (event.x_root > x() && event.x_root <= (int)(x() + width()) && event.y_root > y() && event.y_root <= (int)(y() + height())) + return; + + Fluxbox::instance()->keys()->doAction(event.type, event.state, 0, + Keys::ON_TOOLBAR); + if (! doAutoHide()) return; if (isHidden()) {
M
src/Window.cc
→
src/Window.cc
@@ -1930,6 +1930,9 @@ m_attention_state = false;
m_focussig.notify(); if (m_client) m_client->focusSig().notify(); + WindowCmd<void>::setClient(m_client); + Fluxbox::instance()->keys()->doAction(focus ? FocusIn : FocusOut, 0, 0, + Keys::ON_WINDOW); } }@@ -2942,6 +2945,12 @@ !isVisible()) {
return; } + if (ev.window == frame().window()) { + WindowCmd<void>::setWindow(this); + Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, + Keys::ON_WINDOW); + } + WinClient *client = 0; if (screen().focusControl().isMouseTabFocus()) { // determine if we're in a label button (tab)@@ -2984,6 +2993,23 @@
} void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) { + + // ignore grab activates, or if we're not visible + if (ev.mode == NotifyGrab || ev.mode == NotifyUngrab || + !isVisible()) { + return; + } + + // still inside? + if (ev.x_root > frame().x() && ev.y_root > frame().y() && + ev.x_root <= (int)(frame().x() + frame().width()) && + ev.y_root <= (int)(frame().y() + frame().height())) + return; + + WindowCmd<void>::setWindow(this); + Fluxbox::instance()->keys()->doAction(ev.type, ev.state, 0, + Keys::ON_WINDOW); + // I hope commenting this out is right - simon 21jul2003 //if (ev.window == frame().window()) //installColormap(false);