merging changes in head since the 2_2 branch began
authorDana Jansens <danakj@orodu.net>
Fri, 1 Nov 2002 01:54:02 +0000 (01:54 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 1 Nov 2002 01:54:02 +0000 (01:54 +0000)
14 files changed:
src/Font.cc
src/Font.hh
src/Screen.cc
src/Window.cc
util/epist/ChangeLog
util/epist/config.cc
util/epist/config.hh
util/epist/epist.1.in
util/epist/epistrc.5.in
util/epist/keytree.cc
util/epist/parser.cc
util/epist/parser.hh
util/epist/screen.cc
util/epist/screen.hh

index e963c38ffef367f64096e547544b0dad6c91ed7b..8a04abc910bed765ebb1e7e88893407e8fcc2675 100644 (file)
@@ -48,7 +48,8 @@ string      BFont::_fallback_font   = "fixed";
 
 #ifdef XFT
 BFont::BFont(Display *d, BScreen *screen, const string &family, int size,
-             bool bold, bool italic, bool shadow, bool antialias) :
+             bool bold, bool italic, bool shadow, unsigned char offset, 
+             int tint, bool antialias) :
                                           _display(d),
                                           _screen(screen),
                                           _family(family),
@@ -58,6 +59,8 @@ BFont::BFont(Display *d, BScreen *screen, const string &family, int size,
                                           _italic(italic),
                                           _antialias(antialias),
                                           _shadow(shadow),
+                                          _offset(offset),
+                                          _tint(tint),
                                           _xftfont(0),
                                           _font(0),
                                           _fontset(0),
@@ -264,19 +267,29 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color,
 
     if (_shadow) {
       XftColor c;
-      c.color.red = 0;
-      c.color.green = 0;
-      c.color.blue = 0;
-      c.color.alpha = 0x40 | 0x40 << 8; // transparent shadow
-      c.pixel = BlackPixel(_display, _screen->getScreenNumber());
+      if (_tint >= 0) {
+        c.color.red = 0;
+        c.color.green = 0;
+        c.color.blue = 0;
+        c.color.alpha = 0xffff * _tint/100; // transparent shadow
+        c.pixel = BlackPixel(_display, _screen->getScreenNumber());
+      } else {
+        c.color.red = 0xffff * -_tint/100;
+        c.color.green = 0xffff * -_tint/100;
+        c.color.blue = 0xffff * -_tint/100;
+        c.color.alpha = 0xffff * -_tint/100;
+        c.pixel = WhitePixel(_display, _screen->getScreenNumber());
+      }
 
 #ifdef XFT_UTF8
       XftDrawStringUtf8(
 #else
       XftDrawString8(
 #endif
-                     draw, &c, _xftfont, x + 1, _xftfont->ascent + y + 1,
-                     (XftChar8 *) string.c_str(), string.size());
+                     draw, &c, _xftfont, x + _offset, 
+                     _xftfont->ascent + y + _offset,
+                     (XftChar8 *) string.c_str(), 
+                     string.size());
     }
     
     XftColor c;
@@ -327,7 +340,7 @@ unsigned int BFont::measureString(const string &string) const {
                     _display, _xftfont, (XftChar8 *) string.c_str(),
                     string.size(), &info);
 
-    return info.xOff + (_shadow ? 1 : 0);
+    return info.xOff + (_shadow ? std::abs(_offset) : 0);
   }
 #endif // XFT
 
@@ -346,7 +359,7 @@ unsigned int BFont::height(void) const {
 
 #ifdef    XFT
   if (_xftfont)
-    return _xftfont->height + (_shadow ? 1 : 0);
+    return _xftfont->height + (_shadow ? std::abs(_offset) : 0);
 #endif // XFT
 
   if (i18n.multibyte())
index e29f41b114550ae6aa039cfb0b03b99624617bfb..6f6431ef276af8d83723a0f677f79c6a34678600 100644 (file)
@@ -72,6 +72,8 @@ private:
 #ifdef XFT
   bool              _antialias;
   bool              _shadow;
+  unsigned char     _offset;
+  int               _tint;
 
   XftFont          *_xftfont;
 
@@ -96,7 +98,8 @@ public:
 #ifdef XFT
   // loads an Xft font
   BFont(Display *d, BScreen *screen, const std::string &family, int size,
-        bool bold, bool italic, bool shadow, bool antialias = True);
+        bool bold, bool italic, bool shadow, unsigned char offset, 
+        int tint, bool antialias = True);
 #endif
   // loads a standard X font
   BFont(Display *d, BScreen *screen, const std::string &xlfd);
index d138ffbf58cbcdd2346bb33c27659c3e6ae411a5..2351abcceb2bdc2e7d7445c4954c418712742778 100644 (file)
@@ -2725,15 +2725,33 @@ BFont *BScreen::readDatabaseFont(const string &rbasename,
     string family = s;
     bool bold = False;
     bool italic = False;
+    bool dropShadow = False;
+
     if (style.getValue(rbasename + "xft.flags", s)) {
       if (s.find("bold") != string::npos)
         bold = True;
       if (s.find("italic") != string::npos)
         italic = True;
+      if (s.find("shadow") != string::npos)
+        dropShadow = True;
+    }
+    
+    unsigned char offset = 1;
+    if (style.getValue(rbasename + "xft.shadow.offset", s)) {
+      offset = atoi(s.c_str()); //doesn't detect errors
+      if (offset > CHAR_MAX)
+        offset = 1;
     }
+
+    unsigned char tint = 0x40;
+    if (style.getValue(rbasename + "xft.shadow.tint", s)) {
+      tint = atoi(s.c_str());
+    }
+
     
     BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold,
-                         italic, resource.shadow_fonts, resource.aa_fonts);
+                         italic, dropShadow && resource.shadow_fonts, offset, 
+                         tint, resource.aa_fonts);
     if (b->valid())
       return b;
     else
index b321538e45b3c379d31b6e9d5a97627f9a052445..83adf766a3c1f79ac85d4b18573258435e90aa30 100644 (file)
@@ -600,21 +600,17 @@ void BlackboxWindow::decorate(void) {
   if (needsPressed) {
     texture = &(screen->getWindowStyle()->b_pressed);
     
-    Pixmap pbutton = texture->render(frame.button_w, frame.button_w,
-                                     pbutton);
-    unsigned long pixel;
-    
-    if (!pbutton) {
-      pixel = texture->color().pixel();
-      if (needsPressed & 0x1)
-        frame.pfbutton_pixel = pixel;
-      if (needsPressed & 0x2)
-        frame.pubutton_pixel = pixel;
-    } else {
-      if (needsPressed & 0x1)
-        frame.pfbutton = pbutton;
-      if (needsPressed & 0x2)
-        frame.pubutton = pbutton;
+    if (needsPressed & 0x1) {
+      frame.pfbutton = texture->render(frame.button_w, frame.button_w,
+                                       frame.pfbutton);
+      if (! frame.pfbutton)
+        frame.pfbutton_pixel = texture->color().pixel();
+    }
+    if (needsPressed & 0x2) {
+      frame.pubutton = texture->render(frame.button_w, frame.button_w,
+                                       frame.pubutton);
+      if (! frame.pubutton)
+        frame.pubutton = texture->color().pixel();
     }
     
   }
@@ -4229,8 +4225,6 @@ void BlackboxWindow::constrain(Corner anchor,
     if (dh > client.max_height) dh = client.max_height;
   }
 
-  assert(dw >= base_width && dh >= base_height);
-
   if (client.width_inc > 1) {
     dw -= base_width;
     dw /= client.width_inc;
index bf6df70709c5602c441bb211d362781fdefb7562..39b0e00313fddb8ad76117fad8c7ad2903a428f3 100644 (file)
@@ -1,3 +1,12 @@
+  * Fixed (hopefully) the ugly bugly that would cause  (Marius)
+    epist to hog the keyboard on invalid keys.
+
+  * Added stackedCyclingRaise option, to allow windows (Marius)
+    to raise on focus when stacked is on.
+
+  * Small fixes, better sanity checks, much better     (Marius)
+    error reporting on bad keys and modifiers.
+
 2.1.0
 
   * Improved parser: much better error reporting for
index cefa28cc84bd3d30a0aaee7a8efafd496131461b..461778e5f952958b8eb0ada2689f29729364a7ec 100644 (file)
@@ -97,6 +97,7 @@ void Config::addOption(const std::string &name, const std::string &value)
   }
   bool_options[] = {
     { "stackedcycling", Config::stackedCycling },
+    { "stackedcyclingraise", Config::stackedCyclingRaise },
     { "", NUM_BOOL_TYPES }
   };
 
index 2c2957470e075fa18f3470fb9b35fadbe7f45824..8749009dda7fe0908480d388bef2b412704c4615 100644 (file)
@@ -36,6 +36,7 @@ public:
   enum BoolType {
     NO_BOOL_TYPE,
     stackedCycling,
+    stackedCyclingRaise,
     NUM_BOOL_TYPES
   };
 
index 65c51e0e502f5f5e0a243134e3c347cc593163d3..5e9175b2ac3e3c49dbb47adaed85c2c5e36878c7 100644 (file)
@@ -5,7 +5,7 @@ epist - NetWM keybindings grabber
 \fBepist\fR [options]
 .SH DESCRIPTION
 \fBepist\fR is intended to provide keygrabbing for the OpenBox window manager
-for the X Windows System. This allows you to control things with keypresses
+for the X Window System. This allows you to control things with keypresses
 rather than the mouse.
 .SH OPTIONS
 .TP
index a11013b87cdab0575867a9d6e6b0470a43c07aab..06615768ec7d9dc0da7320fc00725e39f3f17e7c 100644 (file)
@@ -62,18 +62,23 @@ Control-Mod1-x {
 .br
 }
 .SH OPTIONS
-.SS stackedCycling (boolean)
+.SS stackedCycling (boolean, default=off)
 When this option is set to True, any window cycling actions, such as nextWindow,
 prevWindow, nextWindowOfClass, etc., will cause the windows to focus, but they will
 not be raised until the modifiers are released. When the modifier is released,
 the focused (and now raised) window will be moved to the top of the stacking order,
 so if you execute nextWindow and release the modifiers multiple times, focus will
 cycle between two windows.
-.SS chainTimeout (number)
+.SS stackedCyclingRaise (boolean, default=off)
+This option modifies the window raise behavior when stackedCycling is turned on.
+When true, windows will be raised immediatly on focus, rather than when the
+keys are released. This may be desirable if you frequently have windows that are
+obscured by other windows.
+.SS chainTimeout (number, default=3500)
 Specifies the period of time after which a started key chain will
 be timed out. It takes a number argument specifying the number of
 milliseconds to wait. It defaults to 4000.
-.SS workspaceColumns (number)
+.SS workspaceColumns (number, default=0, disabled)
 Specifies the number of columns of your workspace layout if you are using
 your workspaces in a 2-dimensional manner. This option must exist if one of
 the prevWorkspaceColumn, prevWorkspaceRow, nextWorkspaceColumn,
index 009cb355ed26126cb800b7c575bb1e209928a438..94b542b0e3c057a59826e2d27520fd276101e7c5 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.hh"
 
 #include <string>
+#include <iostream>
 
 using std::string;
 
@@ -84,18 +85,26 @@ void keytree::grabDefaults(screen *scr)
 
 void keytree::ungrabDefaults(screen *scr)
 {
+  Action *act;
+
   ChildList::const_iterator it, end = _head->children.end();
-  for (it = _head->children.begin(); it != end; ++it)
-    if ( (*it)->action && (*it)->action->type() != Action::toggleGrabs)
-      scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
+  for (it = _head->children.begin(); it != end; ++it) {
+    act = (*it)->action;
+    if (act && act->type() != Action::toggleGrabs)
+      scr->ungrabKey(act->keycode(), act->modifierMask());
+  }
 }
 
 void keytree::grabChildren(keynode *node, screen *scr)
 {
+  Action *act;
+
   ChildList::const_iterator it, end = node->children.end();
-  for (it = node->children.begin(); it != end; ++it)
-    if ( (*it)->action )
-      scr->grabKey( (*it)->action->keycode(), (*it)->action->modifierMask() );
+  for (it = node->children.begin(); it != end; ++it) {
+    act = (*it)->action;
+    if (act)
+      scr->grabKey(act->keycode(), act->modifierMask());
+  }
 }
 
 void keytree::ungrabChildren(keynode *node, screen *scr)
@@ -178,8 +187,6 @@ const Action * keytree::getAction(const XEvent &e, unsigned int state,
 void keytree::addAction(Action::ActionType action, unsigned int mask,
                         string key, string arg)
 {
-  keynode *tmp = new keynode;
-
   if (action == Action::toggleGrabs && _current != _head) {
     // the toggleGrabs key can only be set up as a root key, since if
     // it was a chain key, we'd have to not ungrab the whole chain up
@@ -187,9 +194,11 @@ void keytree::addAction(Action::ActionType action, unsigned int mask,
     return;
   }
 
+  KeySym sym = XStringToKeysym(key.c_str());
+  keynode *tmp = new keynode;
+
   tmp->action = new Action(action,
-                           XKeysymToKeycode(_display,
-                                            XStringToKeysym(key.c_str())),
+                           XKeysymToKeycode(_display, sym),
                            mask, arg);
   tmp->parent = _current;
   _current->children.push_back(tmp);
@@ -215,10 +224,10 @@ void keytree::setCurrentNodeProps(Action::ActionType action, unsigned int mask,
 {
   if (_current->action)
     delete _current->action;
-  
+
+  KeySym sym = XStringToKeysym(key.c_str());
   _current->action = new Action(action,
-                                XKeysymToKeycode(_display,
-                                                 XStringToKeysym(key.c_str())),
+                                XKeysymToKeycode(_display, sym),
                                 mask, arg);
 }
 
index 00be5d7e9fe8da72f6b0183a29a5bcccaf410ea1..f6ed589e4ed8449eb67b28e6e7339f63ccab1667 100644 (file)
@@ -54,13 +54,29 @@ void parser::parse(string rc_file)
 
   yyin = fopen(rc_file.c_str(), "r");
 
-  yyparse(this);
+  if (yyin) {
+    yyparse(this);
+    fclose(yyin);
+  } else {
+    std::cerr << "ERROR: Configuration file could not be opened/found.\n";
+  }
 
-  fclose(yyin);
   _kt->reset();
   _kt->initialize();
 }
 
+void parser::setKey(string key)
+{ 
+  KeySym sym = XStringToKeysym(key.c_str());
+
+  if (sym == 0) {
+    std::cerr << "ERROR: Invalid key (" << key << ")! This may cause odd behavior.\n";
+    _add = false;
+  } else {
+    _key = key;
+  }
+}
+
 void parser::setAction(string act)
 {
   struct {
@@ -189,14 +205,11 @@ void parser::endChain()
 
 void parser::setChainBinding()
 {
-  if (_mask != 0 && _key != "") {
-    if (!_add) {
-      cout << "Error: Bad modifier detected on chain's root key.\n";
-      _add = true;
-    }
+  if (_add)
     _kt->setCurrentNodeProps(Action::noaction, _mask, _key, "");
-    reset();
-  }
+  
+  _add = true;
+  reset();
 }
 
 void parser::reset()
index b1c02a319a0d03c397be3d49ea34a66958078c6e..d106f16d669d9c0c52a241d202c353614cf3a166 100644 (file)
@@ -36,9 +36,6 @@ public:
 
   void parse(std::string);
 
-  void setKey(std::string key)
-  {  _key = key; }
-
   void setArgumentNum(std::string arg)
   { _arg = arg; }
 
@@ -57,6 +54,7 @@ public:
   void setOption(std::string opt)
   { _config->addOption(opt, _arg); }
 
+  void setKey(std::string);
   void setAction(std::string);
   void addModifier(std::string);
   void endAction();
index 5711d5515646beb7f1373d39bd8f5b94db24ffae..ca029652efacfd330bd1b29b08b00c84adf7c2ec 100644 (file)
@@ -66,7 +66,7 @@ using std::string;
 screen::screen(epist *epist, int number) 
   : _clients(epist->clientsList()), _active(epist->activeWindow()),
     _config(epist->getConfig()), _grabbed(true), _cycling(false),
-    _stacked_cycling(false)
+    _stacked_cycling(false), _stacked_raise(false)
 {
   _epist = epist;
   _xatom = _epist->xatom();
@@ -76,6 +76,8 @@ screen::screen(epist *epist, int number)
   _root = _info->getRootWindow();
 
   _config->getValue(Config::stackedCycling, _stacked_cycling);
+  if (_stacked_cycling)
+    _config->getValue(Config::stackedCyclingRaise, _stacked_raise);
 
   // find a window manager supporting NETWM, waiting for it to load if we must
   int count = 20;  // try for 20 seconds
@@ -656,10 +658,11 @@ void screen::cycleWindow(unsigned int state, const bool forward,
 
     // if the window is on another desktop, we can't use XSetInputFocus, since
     // it doesn't imply a workspace change.
-    if (t->desktop() == _active_desktop || t->desktop() == 0xffffffff)
-      t->focus(false); // focus, but don't raise
+    if (_stacked_raise || (t->desktop() != _active_desktop &&
+                           t->desktop() != 0xffffffff))
+      t->focus(); // raise
     else
-      t->focus(); // change workspace and focus
+      t->focus(false); // don't raise
   }  
   else {
     t->focus();
index 92533d98d3a2fb1d5592e452808635883da52425..f0f3de079d87a654eaa608a541040dfde9646be1 100644 (file)
@@ -59,6 +59,7 @@ class screen {
   bool _grabbed; // used for keygrab toggle function
   bool _cycling; // used for stacked cycling
   bool _stacked_cycling;
+  bool _stacked_raise;
 
   XWindow *findWindow(const XEvent &e) const;
   void updateNumDesktops();