all repos — openbox @ f7e3eb57294f9e73da2e342b503ca360485ae130

openbox fork - make it a bit more like ryudo

add some globals to modify the default scripting behavior
Dana Jansens danakj@orodu.net
commit

f7e3eb57294f9e73da2e342b503ca360485ae130

parent

103372b02f783053c69f8f94db2c0e161f3e7d93

M scripts/clicks.pyscripts/clicks.py

@@ -26,7 +26,8 @@ type == Type_IconifyButton or

type == Type_MaximizeButton or type == Type_CloseButton): return - OBClient_focus(client) + if click_focus != 0: + OBClient_focus(client) print "OBClient_raise(client)" def def_click_root(action, win, type, modifiers, button, time):

@@ -52,7 +53,7 @@ if button == Button1 and (type == Type_Titlebar or type == Type_Label):

print "OBClient_toggleshade(client)" -#preregister(Action_ButtonPress, def_press_model) +preregister(Action_ButtonPress, def_press_model) register(Action_Click, def_click_client) register(Action_Click, def_click_root) register(Action_DoubleClick, def_doubleclick_client)
M scripts/clientmotion.pyscripts/clientmotion.py

@@ -9,24 +9,11 @@ if client:

newi.append(new_Rect(OBClient_area(client))) posqueue.append(newi) - # ButtonPressAction *a = _posqueue[BUTTONS - 1]; - # for (int i=BUTTONS-1; i>0;) - # _posqueue[i] = _posqueue[--i]; - # _posqueue[0] = a; - # a->button = e.button; - # a->pos.setPoint(e.x_root, e.y_root); - - # OBClient *c = Openbox::instance->findClient(e.window); - # // if it's not defined, they should have clicked on the root window, so this - # // area would be meaningless anyways - # if (c) a->clientarea = c->area(); - def def_motion_release(action, win, type, modifiers, button, xroot, yroot, time): global posqueue for i in posqueue: if i[0] == button: - print "hi" client = Openbox_findClient(openbox, win) if client: delete_Rect(i[3])

@@ -53,7 +40,7 @@ client = Openbox_findClient(openbox, win)

if not client: return if (type == Type_Titlebar) or (type == Type_Label): - def_do_move(client, xroot, yroot) + def_do_motion(client, xroot, yroot) elif type == Type_LeftGrip: def_do_resize(client, xroot, yroot, OBClient_TopRight) elif type == Type_RightGrip:

@@ -62,15 +49,18 @@

def def_enter(action, win, type, modifiers): client = Openbox_findClient(openbox, win) if not client: return - OBClient_focus(client) + if enter_focus != 0: + OBClient_focus(client) def def_leave(action, win, type, modifiers): client = Openbox_findClient(openbox, win) if not client: return + if leave_unfocus != 0: + OBClient_unfocus(client) register(Action_EnterWindow, def_enter) -#register(Action_LeaveWindow, def_leave) +register(Action_LeaveWindow, def_leave) register(Action_ButtonPress, def_motion_press) register(Action_ButtonRelease, def_motion_release)
M scripts/globals.pyscripts/globals.py

@@ -6,4 +6,19 @@ screen = []

for i in range(Openbox_screenCount(openbox)): screen.append(Openbox_screen(openbox, i)) +# client_buttons - a list of the modifier(s) and buttons which are grabbed on +# client windows (for interactive move/resize, etc) +# examples: "A-2", "C-A-2", "W-1" +client_buttons = ["A-1", "A-2", "A-3"] + +# click_focus - true if clicking in a client will cause it to focus in the +# default hook functions +click_focus = 0 +# enter_focus - true if entering a client window will cause it to focus in the +# default hook functions +enter_focus = 1 +# leave_unfocus - true if leaving a client window will cause it to unfocus in +# the default hook functions +leave_unfocus = 1 + print "Loaded globals.py"
M src/bindings.ccsrc/bindings.cc

@@ -68,8 +68,7 @@ }

return true; } -bool OBBindings::translate(const std::string &str, Binding &b, - bool askey) const +bool OBBindings::translate(const std::string &str, Binding &b) const { // parse out the base key name std::string::size_type keybegin = str.find_last_of('-');

@@ -93,22 +92,14 @@ }

// set the binding b.modifiers = modval; - if (askey) { - KeySym sym = XStringToKeysym(const_cast<char *>(key.c_str())); - if (sym == NoSymbol) { - printf(_("Invalid Key name in key binding: %s\n"), key.c_str()); - return false; - } - if (!(b.key = XKeysymToKeycode(otk::OBDisplay::display, sym))) - printf(_("No valid keycode for Key in key binding: %s\n"), key.c_str()); - return b.key != 0; - } else { - if (!buttonvalue(key, &b.key)) { - printf(_("Invalid Button name in mouse binding: %s\n"), key.c_str()); - return false; - } else - return true; + KeySym sym = XStringToKeysym(const_cast<char *>(key.c_str())); + if (sym == NoSymbol) { + printf(_("Invalid Key name in key binding: %s\n"), key.c_str()); + return false; } + if (!(b.key = XKeysymToKeycode(otk::OBDisplay::display, sym))) + printf(_("No valid keycode for Key in key binding: %s\n"), key.c_str()); + return b.key != 0; } static void destroytree(BindingTree *tree)

@@ -143,7 +134,7 @@ }

OBBindings::OBBindings() - : _curpos(&_keytree), _mousetree(0), _resetkey(0,0) + : _curpos(&_keytree), _resetkey(0,0) { setResetKey("C-g"); // set the default reset key }

@@ -151,50 +142,8 @@

OBBindings::~OBBindings() { - grabMouseOnAll(false); // ungrab everything grabKeys(false); remove_all(); -} - - -bool OBBindings::add_mouse(const std::string &button, int id) -{ - BindingTree n; - - if (!translate(button, n.binding, false)) - return false; - - BindingTree *p = _mousetree, **newp = &_mousetree; - while (p) { - if (p->binding == n.binding) - return false; // conflict - p = p->next_sibling; - newp = &p->next_sibling; - } - - grabMouseOnAll(false); // ungrab everything - - *newp = new BindingTree(id); - (*newp)->chain = false; - (*newp)->binding.key = n.binding.key; - (*newp)->binding.modifiers = n.binding.modifiers; - - grabMouseOnAll(true); - - return true; -} - - -int OBBindings::remove_mouse(const std::string &button) -{ - (void)button; - assert(false); // XXX: function not implemented yet - - grabMouseOnAll(false); // ungrab everything - - // do shit... - - grabMouseOnAll(true); }

@@ -340,43 +289,6 @@ if (_keytree.first_child) {

remove_branch(_keytree.first_child); _keytree.first_child = 0; } - BindingTree *p = _mousetree; - while (p) { - BindingTree *n = p->next_sibling; - delete p; - p = n; - } - _mousetree = 0; -} - - -void OBBindings::grabMouse(bool grab, const OBClient *client) -{ - BindingTree *p = _mousetree; - while (p) { - if (grab) - otk::OBDisplay::grabButton(p->binding.key, p->binding.modifiers, - client->frame->window(), false, - ButtonMotionMask | ButtonPressMask | - ButtonReleaseMask, GrabModeAsync, - GrabModeAsync, None, None, false); - else - otk::OBDisplay::ungrabButton(p->binding.key, p->binding.modifiers, - client->frame->window()); - p = p->next_sibling; - } -} - - -void OBBindings::grabMouseOnAll(bool grab) -{ - for (int i = 0; i < Openbox::instance->screenCount(); ++i) { - OBScreen *s = Openbox::instance->screen(i); - assert(s); - OBScreen::ClientList::iterator it, end = s->clients.end(); - for (it = s->clients.begin(); it != end; ++it) - grabMouse(grab, *it); - } }

@@ -408,44 +320,32 @@ }

} -void OBBindings::fire(OBActions::ActionType type, Window window, - unsigned int modifiers, unsigned int key, Time time) +void OBBindings::fire(Window window, unsigned int modifiers, unsigned int key, + Time time) { - if (type == OBActions::Action_KeyPress) { - if (key == _resetkey.key && modifiers == _resetkey.modifiers) { - grabKeys(false); - _curpos = &_keytree; - grabKeys(true); - } else { - BindingTree *p = _curpos->first_child; - while (p) { - if (p->binding.key == key && p->binding.modifiers == modifiers) { - if (p->chain) { - grabKeys(false); - _curpos = p; - grabKeys(true); - } else { - python_callback_binding(p->id, type, window, modifiers, key, time); - grabKeys(false); - _curpos = &_keytree; - grabKeys(true); - } - break; - } - p = p->next_sibling; - } - } + if (key == _resetkey.key && modifiers == _resetkey.modifiers) { + grabKeys(false); + _curpos = &_keytree; + grabKeys(true); } else { - BindingTree *p = _mousetree; + BindingTree *p = _curpos->first_child; while (p) { if (p->binding.key == key && p->binding.modifiers == modifiers) { - python_callback_binding(p->id, type, window, modifiers, key, time); + if (p->chain) { + grabKeys(false); + _curpos = p; + grabKeys(true); + } else { + python_callback_binding(p->id, type, window, modifiers, key, time); + grabKeys(false); + _curpos = &_keytree; + grabKeys(true); + } break; } p = p->next_sibling; } } } - }
M src/bindings.hhsrc/bindings.hh

@@ -49,55 +49,36 @@ //! A list of strings

typedef std::vector<std::string> StringVect; private: - BindingTree _keytree; // root node of the tree (this doesn't have siblings!) + BindingTree _tree; // root node of the tree (this doesn't have siblings!) BindingTree *_curpos; // position in the keytree - BindingTree *_mousetree; // this tree is a list. it has only siblings - Binding _resetkey; // the key which resets the key chain status - int find_key(BindingTree *search) const; - bool translate(const std::string &str, Binding &b, bool askey) const; + int find(BindingTree *search) const; + bool translate(const std::string &str, Binding &b) const; BindingTree *buildtree(const StringVect &keylist, int id) const; void assimilate(BindingTree *node); - void grabMouseOnAll(bool grab); - public: //! Initializes an OBBinding object OBBindings(); //! Destroys the OBBinding object virtual ~OBBindings(); - //! Adds a new mouse binding - /*! - A binding will fail to be added if the binding already exists, or if the - string is invalid. - @return true if the binding could be added; false if it could not. - */ - bool add_mouse(const std::string &button, int id); - - //! Removes a mouse binding - /*! - @return The id of the binding that was removed, or '< 0' if none were - removed. - */ - int remove_mouse(const std::string &button); - //! Adds a new key binding /*! A binding will fail to be added if the binding already exists (as part of a chain or not), or if any of the strings in the keylist are invalid. @return true if the binding could be added; false if it could not. */ - bool add_key(const StringVect &keylist, int id); + bool add(const StringVect &keylist, int id); //! Removes a key binding /*! @return The id of the binding that was removed, or '< 0' if none were removed. */ - int remove_key(const StringVect &keylist); + int remove(const StringVect &keylist); //! Removes all key bindings void remove_all();

@@ -107,14 +88,12 @@ /*!

@return -1 if the keybinding was not found but does not conflict with any others; -2 if the keybinding conflicts with another. */ - int find_key(const StringVect &keylist); + int find(const StringVect &keylist); - void fire(OBActions::ActionType type, Window window, unsigned int modifiers, - unsigned int key, Time time); + void fire(Window window, unsigned int modifiers,unsigned int key, Time time); void setResetKey(const std::string &key); - void grabMouse(bool grab, const OBClient *client); void grabKeys(bool grab); };
M src/screen.ccsrc/screen.cc

@@ -402,7 +402,7 @@ clients.push_back(client);

// update the root properties setClientList(); - // grab buttons/keys on the window + // grab buttons on the window Openbox::instance->bindings()->grabMouse(true, client); }

@@ -411,7 +411,7 @@ void OBScreen::unmanageWindow(OBClient *client)

{ OBFrame *frame = client->frame; - // ungrab buttons/keys on the window + // ungrab buttons on the window Openbox::instance->bindings()->grabMouse(false, client); // XXX: pass around focus if this window was focused