]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
dont put DEBUG: in the printf
[chaz/openbox] / src / client.cc
index 353bda69d04e81109262ccce70fad54fe60c0245..f9676e7cf7eebd3bbb8cc87722d5f84cb80c7cb5 100644 (file)
@@ -402,7 +402,6 @@ void Client::getState()
   }
 }
 
-
 void Client::getShaped()
 {
   _shaped = false;
@@ -421,12 +420,40 @@ void Client::getShaped()
 #endif // SHAPE
 }
 
+Client *Client::searchFocusTree(Client *node, Client *skip)
+{
+  List::const_iterator it, end = node->_transients.end();
+  Client *ret;
+
+  for (it = node->_transients.begin(); it != end; ++it) {
+    if (*it == skip) continue; // circular?
+    if ((ret = searchModalTree(*it, skip))) return ret; // got one
+    if ((*it)->_focused) return *it; // got one
+  }
+  return 0;
+}
 
 void Client::calcLayer() {
   StackLayer l;
+  bool fs = false;
 
+  // are we fullscreen, or do we have a fullscreen transient parent?
+  Client *c = this;
+  while (c) {
+    if (c->_fullscreen) {
+      fs =true;
+      break;
+    }
+    c = c->_transient_for;
+  }
+  if (!fs && _fullscreen) {
+    // is one of our transients focused?
+    c = searchFocusTree(this, this);
+    if (c) fs = true;
+  }
+  
   if (_iconic) l = Layer_Icon;
-  else if (_fullscreen) l = Layer_Fullscreen;
+  else if (fs) l = Layer_Fullscreen;
   else if (_type == Type_Desktop) l = Layer_Desktop;
   else if (_type == Type_Dock) {
     if (!_below) l = Layer_Top;
@@ -448,7 +475,6 @@ void Client::calcLayer() {
   }
 }
 
-
 void Client::updateProtocols()
 {
   Atom *proto;
@@ -471,7 +497,6 @@ void Client::updateProtocols()
   }
 }
 
-
 void Client::updateNormalHints()
 {
   XSizeHints size;
@@ -522,7 +547,6 @@ void Client::updateNormalHints()
   }
 }
 
-
 void Client::updateWMHints(bool initstate)
 {
   XWMHints *hints;
@@ -557,7 +581,7 @@ void Client::updateWMHints(bool initstate)
   if (ur != _urgent) {
     _urgent = ur;
 #ifdef DEBUG
-    printf("DEBUG: Urgent Hint for 0x%lx: %s\n",
+    printf("Urgent Hint for 0x%lx: %s\n",
            (long)_window, _urgent ? "ON" : "OFF");
 #endif
     // fire the urgent callback if we're mapped, otherwise, wait until after
@@ -567,7 +591,6 @@ void Client::updateWMHints(bool initstate)
   }
 }
 
-
 void Client::updateTitle()
 {
   _title = "";
@@ -587,7 +610,6 @@ void Client::updateTitle()
     frame->adjustTitle();
 }
 
-
 void Client::updateIconTitle()
 {
   _icon_title = "";
@@ -604,7 +626,6 @@ void Client::updateIconTitle()
     _icon_title = _("Unnamed Window");
 }
 
-
 void Client::updateClass()
 {
   // set the defaults
@@ -627,7 +648,6 @@ void Client::updateClass()
   }
 }
 
-
 void Client::updateStrut()
 {
   unsigned long num = 4;
@@ -651,7 +671,6 @@ void Client::updateStrut()
   delete [] data;
 }
 
-
 void Client::updateTransientFor()
 {
   Window t = 0;
@@ -684,12 +703,12 @@ void Client::updateTransientFor()
   }
 }
 
-
 void Client::updateIcons()
 {
   unsigned long num = (unsigned) -1;
   unsigned long *data;
   unsigned long w, h, i = 0;
+  bool freeit = false;
 
   for (int j = 0; j < _nicons; ++j)
     delete [] _icons[j].data;
@@ -697,37 +716,40 @@ void Client::updateIcons()
     delete [] _icons;
   _nicons = 0;
 
-  if (otk::Property::get(_window, otk::Property::atoms.net_wm_icon,
-                         otk::Property::atoms.cardinal, &num, &data)) {
-    // figure out how man valid icons are in here
-    while (num - i > 2) {
-      w = data[i++];
-      h = data[i++];
-      i += w * h;
-      if (i > num) break;
-      ++_nicons;
-    }
+  if (!otk::Property::get(_window, otk::Property::atoms.net_wm_icon,
+                          otk::Property::atoms.cardinal, &num, &data)) {
+    // use default icon(s)
+    num = openbox->screen(_screen)->config().icon_length;
+    data = openbox->screen(_screen)->config().default_icon;
+  } else
+    freeit = true;
+  
+  // figure out how man valid icons are in here
+  while (num - i > 2) {
+    w = data[i++];
+    h = data[i++];
+    i += w * h;
+    if (i > num) break;
+    ++_nicons;
+  }
 
-    _icons = new Icon[_nicons];
+  _icons = new Icon[_nicons];
 
-    // store the icons
-    i = 0;
-    for (int j = 0; j < _nicons; ++j) {
-      w = _icons[j].w = data[i++];
+  // store the icons
+  i = 0;
+  for (int j = 0; j < _nicons; ++j) {
+    w = _icons[j].w = data[i++];
       h = _icons[j].h = data[i++];
       _icons[j].data = new unsigned long[w * h];
       ::memcpy(_icons[j].data, &data[i], w * h * sizeof(unsigned long));
       i += w * h;
       assert(i <= num);
-    }
-    printf("i: %lu\n", i);
-    printf("bleffffffff\n");
-    
-    delete [] data;
   }
 
+  if (freeit)
+    delete [] data;
+
   if (_nicons <= 0) {
-    // set the default icon(s) XXX load these from the py
     _nicons = 1;
     _icons = new Icon[1];
     _icons[i].w = 0;
@@ -740,7 +762,6 @@ void Client::updateIcons()
   if (frame) frame->adjustIcon();
 }
 
-
 void Client::propertyHandler(const XPropertyEvent &e)
 {
   otk::EventHandler::propertyHandler(e);
@@ -788,7 +809,6 @@ void Client::propertyHandler(const XPropertyEvent &e)
     updateIcons();
 }
 
-
 void Client::setWMState(long state)
 {
   if (state == _wmstate) return; // no change
@@ -803,7 +823,6 @@ void Client::setWMState(long state)
   }
 }
 
-
 void Client::setDesktop(unsigned int target)
 {
   if (target == _desktop) return;
@@ -824,7 +843,6 @@ void Client::setDesktop(unsigned int target)
   openbox->screen(_screen)->updateStruts();
 }
 
-
 void Client::showhide()
 {
   bool show;
@@ -840,7 +858,6 @@ void Client::showhide()
   else      frame->hide();
 }
 
-
 void Client::setState(StateAction action, long data1, long data2)
 {
   bool shadestate = _shaded;
@@ -954,7 +971,6 @@ void Client::setState(StateAction action, long data1, long data2)
   changeState(); // change the hint to relect these changes
 }
 
-
 void Client::toggleClientBorder(bool addborder)
 {
   // adjust our idea of where the client is, based on its border. When the
@@ -1018,7 +1034,6 @@ void Client::toggleClientBorder(bool addborder)
     XSetWindowBorderWidth(**otk::display, _window, 0);
 }
 
-
 void Client::clientMessageHandler(const XClientMessageEvent &e)
 {
   otk::EventHandler::clientMessageHandler(e);
@@ -1105,7 +1120,6 @@ void Client::clientMessageHandler(const XClientMessageEvent &e)
   }
 }
 
-
 #if defined(SHAPE)
 void Client::shapeHandler(const XShapeEvent &e)
 {
@@ -1118,14 +1132,12 @@ void Client::shapeHandler(const XShapeEvent &e)
 }
 #endif
 
-
 void Client::resize(Corner anchor, int w, int h)
 {
   if (!(_functions & Func_Resize)) return;
   internal_resize(anchor, w, h);
 }
 
-
 void Client::internal_resize(Corner anchor, int w, int h,
                              bool user, int x, int y)
 {
@@ -1238,7 +1250,6 @@ void Client::move(int x, int y)
   internal_move(x, y);
 }
 
-
 void Client::internal_move(int x, int y)
 {
   _area = otk::Rect(otk::Point(x, y), _area.size());
@@ -1274,7 +1285,6 @@ void Client::internal_move(int x, int y)
   }
 }
 
-
 void Client::close()
 {
   XEvent ce;
@@ -1300,7 +1310,6 @@ void Client::close()
   XSendEvent(**otk::display, _window, false, NoEventMask, &ce);
 }
 
-
 void Client::changeState()
 {
   unsigned long state[2];
@@ -1340,7 +1349,6 @@ void Client::changeState()
     frame->adjustState();
 }
 
-
 void Client::changeAllowedActions(void)
 {
   Atom actions[9];
@@ -1384,7 +1392,6 @@ void Client::changeAllowedActions(void)
     else _max_vert = _max_horz = false;
 }
 
-
 void Client::remaximize()
 {
   int dir;
@@ -1400,7 +1407,6 @@ void Client::remaximize()
   maximize(true, dir, false);
 }
 
-
 void Client::applyStartupState()
 {
   // these are in a carefully crafted order..
@@ -1438,7 +1444,6 @@ void Client::applyStartupState()
   if (_below);        // nothing to do for this
 }
 
-
 void Client::fireUrgent()
 {
   // call the python UrgentWindow callbacks
@@ -1446,7 +1451,6 @@ void Client::fireUrgent()
   openbox->bindings()->fireEvent(&data);
 }
 
-
 void Client::shade(bool shade)
 {
   if (!(_functions & Func_Shade) || // can't
@@ -1460,7 +1464,6 @@ void Client::shade(bool shade)
   frame->adjustSize();
 }
 
-
 void Client::maximize(bool max, int dir, bool savearea)
 {
   assert(dir == 0 || dir == 1 || dir == 2);
@@ -1567,7 +1570,6 @@ void Client::maximize(bool max, int dir, bool savearea)
   internal_resize(TopLeft, w, h, true, x, y);
 }
 
-
 void Client::fullscreen(bool fs, bool savearea)
 {
   static FunctionFlags saved_func;
@@ -1642,7 +1644,6 @@ void Client::fullscreen(bool fs, bool savearea)
   if (fs) focus();
 }
 
-
 void Client::iconify(bool iconic, bool curdesk)
 {
   if (_iconic == iconic) return; // nothing to do
@@ -1670,14 +1671,12 @@ void Client::iconify(bool iconic, bool curdesk)
   openbox->screen(_screen)->updateStruts();
 }
 
-
 void Client::disableDecorations(DecorationFlags flags)
 {
   _disabled_decorations = flags;
   setupDecorAndFunctions();
 }
 
-
 void Client::installColormap(bool install) const
 {
   XWindowAttributes wa;
@@ -1689,9 +1688,6 @@ void Client::installColormap(bool install) const
   }
 }
 
-
-// recursively searches the client 'tree' for a modal client, always skips the
-// topmost node (the window you're starting with)
 Client *Client::searchModalTree(Client *node, Client *skip)
 {
   List::const_iterator it, end = node->_transients.end();
@@ -1784,6 +1780,8 @@ void Client::focusHandler(const XFocusChangeEvent &e)
   _focused = true;
   frame->adjustFocus();
 
+  calcLayer(); // focus state can affect the stacking layer
+
   openbox->setFocusedClient(this);
 }
 
@@ -1799,6 +1797,8 @@ void Client::unfocusHandler(const XFocusChangeEvent &e)
   _focused = false;
   frame->adjustFocus();
 
+  calcLayer(); // focus state can affect the stacking layer
+
   if (openbox->focusedClient() == this)
     openbox->setFocusedClient(0);
 }
This page took 0.0343560000000001 seconds and 4 git commands to generate.