]> Dogcows Code - chaz/openbox/commitdiff
add some globals to modify the default scripting behavior
authorDana Jansens <danakj@orodu.net>
Tue, 31 Dec 2002 08:46:17 +0000 (08:46 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 31 Dec 2002 08:46:17 +0000 (08:46 +0000)
scripts/clicks.py
scripts/clientmotion.py
scripts/globals.py
src/bindings.cc
src/bindings.hh
src/screen.cc

index f9d2cb6fa0a28ca3eff0177f2c957fde53ca56db..91429d1ff725a3db10b66f21d713c7b3c894aa12 100644 (file)
@@ -26,7 +26,8 @@ def def_press_model(action, win, type, modifiers, button, xroot, yroot, time):
                          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 @@ def def_doubleclick_client(action, win, type, modifiers, button, time):
                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)
index e34afed4c2944db9f8ab61f52a140bedb74c33c5..bd446f87da74bf660db0025ddf7dc7c8066cfac1 100644 (file)
@@ -9,24 +9,11 @@ def def_motion_press(action, win, type, modifiers, button, xroot, yroot, time):
                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 @@ def def_motion(action, win, type, modifiers, xroot, yroot, time):
        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_motion(action, win, type, modifiers, xroot, yroot, time):
 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)
index 98f71c34155e34c8be0cc9464b6e9313dc4b08d5..2a9d8240ccdc46074873c16c1a5e9cea502f834d 100644 (file)
@@ -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"
index 08b2ca2144322e0f2b76f60c5d8788de8a87ed31..a6b91dc40d297b1edf1fedea6b01eecd31b9bf69 100644 (file)
@@ -68,8 +68,7 @@ static bool modvalue(const std::string &mod, unsigned int *val)
   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 @@ bool OBBindings::translate(const std::string &str, Binding &b,
 
   // 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 @@ BindingTree *OBBindings::buildtree(const StringVect &keylist, int id) const
 
 
 OBBindings::OBBindings()
-  : _curpos(&_keytree), _mousetree(0), _resetkey(0,0)
+  : _curpos(&_keytree), _resetkey(0,0)
 {
   setResetKey("C-g"); // set the default reset key
 }
@@ -151,53 +142,11 @@ OBBindings::OBBindings()
 
 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);
-}
-
-
 void OBBindings::assimilate(BindingTree *node)
 {
   BindingTree *a, *b, *tmp, *last;
@@ -340,43 +289,6 @@ void OBBindings::remove_all()
     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,38 +320,27 @@ void OBBindings::grabKeys(bool grab)
 }
 
 
-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;
@@ -447,5 +348,4 @@ void OBBindings::fire(OBActions::ActionType type, Window window,
   }
 }
 
-
 }
index e04a7b1874a606640cc0fd76835e5ce9d9f7bfb4..dde799491dd72e894830b8b9bd01036da98cf9b5 100644 (file)
@@ -49,55 +49,36 @@ public:
   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 @@ public:
     @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);
 };
 
index e4518fba3b4af1595b0719ba546033c97676d44f..7e9d0ea0b15bec5c9d69855a174d7262fcc109b0 100644 (file)
@@ -402,7 +402,7 @@ void OBScreen::manageWindow(Window window)
   // 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
This page took 0.034927 seconds and 4 git commands to generate.