]> Dogcows Code - chaz/openbox/blobdiff - src/workspace.cc
code reorganize
[chaz/openbox] / src / workspace.cc
index 8c44adab946d6f2e017ebe1044ea73f251a64daf..467d868400feda0670af4ed9f1c3897c3147e286 100644 (file)
@@ -1,25 +1,4 @@
 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
-// Workspace.cc for Blackbox - an X11 Window manager
-// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
-// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
 
 #ifdef    HAVE_CONFIG_H
 #  include "../config.h"
@@ -46,17 +25,14 @@ extern "C" {
 using std::string;
 
 #include "blackbox.hh"
-#include "clientmenu.hh"
-#include "font.hh"
-#include "netizen.hh"
-#include "screen.hh"
-#include "toolbar.hh"
-#include "util.hh"
-#include "window.hh"
+#include "otk/font.hh"
+#include "otk/display.hh"
+#include "bbscreen.hh"
+#include "otk/util.hh"
+#include "bbwindow.hh"
 #include "workspace.hh"
-#include "windowmenu.hh"
-#include "xatom.hh"
 
+namespace ob {
 
 Workspace::Workspace(BScreen *scrn, unsigned int i) {
   screen = scrn;
@@ -69,8 +45,6 @@ Workspace::Workspace(BScreen *scrn, unsigned int i) {
 
   id = i;
 
-  clientmenu = new Clientmenu(this);
-
   lastfocus = (BlackboxWindow *) 0;
 
   readName();
@@ -99,12 +73,6 @@ void Workspace::addWindow(BlackboxWindow *w, bool place, bool sticky) {
 
     windowList.push_back(w);
 
-    clientmenu->insert(w->getTitle());
-    clientmenu->update();
-
-    if (! sticky)
-      screen->updateNetizenWindowAdd(w->getClientWindow(), id);
-
     if (screen->doFocusNew() || (w->isTransient() && w->getTransientFor() &&
                                  w->getTransientFor()->isFocused())) {
       if (id != screen->getCurrentWorkspaceID()) {
@@ -132,7 +100,7 @@ void Workspace::removeWindow(BlackboxWindow *w, bool sticky) {
 
   // pass focus to the next appropriate window
   if ((w->isFocused() || w == lastfocus) &&
-      ! screen->getBlackbox()->doShutdown()) {
+      screen->getBlackbox()->state() != Openbox::State_Exiting) {
     focusFallback(w);
   }
     
@@ -146,12 +114,7 @@ void Workspace::removeWindow(BlackboxWindow *w, bool sticky) {
   assert(it != end);
   
   windowList.erase(it);
-  clientmenu->remove(i);
-  clientmenu->update();
-
   if (! sticky) {
-    screen->updateNetizenWindowDel(w->getClientWindow());
-
     BlackboxWindowList::iterator it = windowList.begin();
     const BlackboxWindowList::iterator end = windowList.end();
     unsigned int i = 0;
@@ -213,19 +176,6 @@ void Workspace::focusFallback(const BlackboxWindow *old_window) {
 }
 
 
-void Workspace::setFocused(const BlackboxWindow *w, bool focused) {
-  BlackboxWindowList::iterator it, end = windowList.end();
-  int i;
-  for (i = 0, it = windowList.begin(); it != end; ++it, ++i)
-    if (*it == w)
-      break;
-  // if its == end, then a window thats not in the windowList
-  // got focused, such as a !isNormal() window.
-  if (it != end)
-    clientmenu->setItemSelected(i, focused);
-}
-
-
 void Workspace::removeAll(void) {
   while (! windowList.empty())
     windowList.front()->iconify();
@@ -239,7 +189,8 @@ void Workspace::showAll(void) {
     // sticky windows arent unmapped on a workspace change so we don't have ot
     // map them, but sometimes on a restart, another app can unmap our sticky
     // windows, so we map on startup always
-    if (! bw->isStuck() || screen->getBlackbox()->isStartup())
+    if (! bw->isStuck() ||
+        screen->getBlackbox()->state() == Openbox::State_Starting)
       bw->show();
   }
 }
@@ -296,7 +247,6 @@ void Workspace::raiseTransients(const BlackboxWindow * const win,
   for (it = win->getTransients().begin(); it != end; ++it) {
     BlackboxWindow *w = *it;
     *stack++ = w->getFrameWindow();
-    screen->updateNetizenWindowRaise(w->getClientWindow());
 
     if (! w->isIconic()) {
       Workspace *wkspc = screen->getWorkspace(w->getWorkspaceNumber());
@@ -325,7 +275,6 @@ void Workspace::lowerTransients(const BlackboxWindow * const win,
   for (it = win->getTransients().rbegin(); it != end; ++it) {
     BlackboxWindow *w = *it;
     *stack++ = w->getFrameWindow();
-    screen->updateNetizenWindowLower(w->getClientWindow());
 
     if (! w->isIconic()) {
       Workspace *wkspc = screen->getWorkspace(w->getWorkspaceNumber());
@@ -353,7 +302,6 @@ void Workspace::raiseWindow(BlackboxWindow *w) {
   StackVector::iterator stack = stack_vector.begin();
 
   *(stack++) = win->getFrameWindow();
-  screen->updateNetizenWindowRaise(win->getClientWindow());
   if (! (win->isIconic() || win->isDesktop())) {
     Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
     wkspc->stackingList.remove(win);
@@ -383,7 +331,6 @@ void Workspace::lowerWindow(BlackboxWindow *w) {
   lowerTransients(win, stack);
 
   *(stack++) = win->getFrameWindow();
-  screen->updateNetizenWindowLower(win->getClientWindow());
   if (! (win->isIconic() || win->isDesktop())) {
     Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
     wkspc->stackingList.remove(win);
@@ -395,7 +342,6 @@ void Workspace::lowerWindow(BlackboxWindow *w) {
 
 
 void Workspace::reconfigure(void) {
-  clientmenu->reconfigure();
   std::for_each(windowList.begin(), windowList.end(),
                 std::mem_fun(&BlackboxWindow::reconfigure));
 }
@@ -445,14 +391,6 @@ BlackboxWindow* Workspace::getTopWindowOnStack(void) const {
 }
 
 
-void Workspace::sendWindowList(Netizen &n) {
-  BlackboxWindowList::iterator it = windowList.begin(),
-    end = windowList.end();
-  for(; it != end; ++it)
-    n.sendWindowAdd((*it)->getClientWindow(), getID());
-}
-
-
 unsigned int Workspace::getCount(void) const {
   return windowList.size();
 }
@@ -474,7 +412,7 @@ bool Workspace::isCurrent(void) const {
 }
 
 
-bool Workspace::isLastWindow(const BlackboxWindow* const w) const {
+bool Workspace::isLastWindow(const BlackboxWindow *w) const {
   return (w == windowList.back());
 }
 
@@ -485,25 +423,22 @@ void Workspace::setCurrent(void) {
 
 
 void Workspace::readName(void) {
-  XAtom::StringVect namesList;
+  otk::OBProperty::StringVect namesList;
   unsigned long numnames = id + 1;
     
   // attempt to get from the _NET_WM_DESKTOP_NAMES property
-  if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names,
-                      XAtom::utf8, numnames, namesList) &&
+  if (xatom->get(screen->getRootWindow(), otk::OBProperty::net_desktop_names,
+                 otk::OBProperty::utf8, &numnames, &namesList) &&
       namesList.size() > id) {
     name = namesList[id];
   
-    clientmenu->setLabel(name);
-    clientmenu->update();
   } else {
     /*
        Use a default name. This doesn't actually change the class. That will
        happen after the setName changes the root property, and that change
        makes its way back to this function.
     */
-    string tmp =i18n(WorkspaceSet, WorkspaceDefaultNameFormat,
-                     "Workspace %d");
+    string tmp = "Workspace %d";
     assert(tmp.length() < 32);
     char default_name[32];
     sprintf(default_name, tmp.c_str(), id + 1);
@@ -515,30 +450,31 @@ void Workspace::readName(void) {
 
 void Workspace::setName(const string& new_name) {
   // set the _NET_WM_DESKTOP_NAMES property with the new name
-  XAtom::StringVect namesList;
+  otk::OBProperty::StringVect namesList;
   unsigned long numnames = (unsigned) -1;
-  if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names,
-                      XAtom::utf8, numnames, namesList) &&
+  if (xatom->get(screen->getRootWindow(),
+                 otk::OBProperty::net_desktop_names,
+                 otk::OBProperty::utf8, &numnames, &namesList) &&
       namesList.size() > id)
     namesList[id] = new_name;
   else
     namesList.push_back(new_name);
 
-  xatom->setValue(screen->getRootWindow(), XAtom::net_desktop_names,
-                  XAtom::utf8, namesList);
+  xatom->set(screen->getRootWindow(), otk::OBProperty::net_desktop_names,
+             otk::OBProperty::utf8, namesList);
 }
 
 
 /*
  * Calculate free space available for window placement.
  */
-Workspace::rectList Workspace::calcSpace(const Rect &win,
+Workspace::rectList Workspace::calcSpace(const otk::Rect &win,
                                          const rectList &spaces) const {
-  Rect isect, extra;
+  otk::Rect isect, extra;
   rectList result;
   rectList::const_iterator siter, end = spaces.end();
   for (siter = spaces.begin(); siter != end; ++siter) {
-    const Rect &curr = *siter;
+    const otk::Rect &curr = *siter;
 
     if(! win.intersects(curr)) {
       result.push_back(curr);
@@ -576,56 +512,56 @@ Workspace::rectList Workspace::calcSpace(const Rect &win,
 }
 
 
-static bool rowRLBT(const Rect &first, const Rect &second) {
+static bool rowRLBT(const otk::Rect &first, const otk::Rect &second) {
   if (first.bottom() == second.bottom())
     return first.right() > second.right();
   return first.bottom() > second.bottom();
 }
 
-static bool rowRLTB(const Rect &first, const Rect &second) {
+static bool rowRLTB(const otk::Rect &first, const otk::Rect &second) {
   if (first.y() == second.y())
     return first.right() > second.right();
   return first.y() < second.y();
 }
 
-static bool rowLRBT(const Rect &first, const Rect &second) {
+static bool rowLRBT(const otk::Rect &first, const otk::Rect &second) {
   if (first.bottom() == second.bottom())
     return first.x() < second.x();
   return first.bottom() > second.bottom();
 }
 
-static bool rowLRTB(const Rect &first, const Rect &second) {
+static bool rowLRTB(const otk::Rect &first, const otk::Rect &second) {
   if (first.y() == second.y())
     return first.x() < second.x();
   return first.y() < second.y();
 }
 
-static bool colLRTB(const Rect &first, const Rect &second) {
+static bool colLRTB(const otk::Rect &first, const otk::Rect &second) {
   if (first.x() == second.x())
     return first.y() < second.y();
   return first.x() < second.x();
 }
 
-static bool colLRBT(const Rect &first, const Rect &second) {
+static bool colLRBT(const otk::Rect &first, const otk::Rect &second) {
   if (first.x() == second.x())
     return first.bottom() > second.bottom();
   return first.x() < second.x();
 }
 
-static bool colRLTB(const Rect &first, const Rect &second) {
+static bool colRLTB(const otk::Rect &first, const otk::Rect &second) {
   if (first.right() == second.right())
     return first.y() < second.y();
   return first.right() > second.right();
 }
 
-static bool colRLBT(const Rect &first, const Rect &second) {
+static bool colRLBT(const otk::Rect &first, const otk::Rect &second) {
   if (first.right() == second.right())
     return first.bottom() > second.bottom();
   return first.right() > second.right();
 }
 
 
-bool Workspace::smartPlacement(Rect& win) {
+bool Workspace::smartPlacement(otk::Rect& win) {
   rectList spaces;
  
   //initially the entire screen is free
@@ -646,7 +582,7 @@ bool Workspace::smartPlacement(Rect& win) {
   } else
 #endif // XINERAMA
   {
-    Rect r = screen->availableArea();
+    otk::Rect r = screen->availableArea();
     r.setRect(r.x() + screen->getSnapOffset(),
               r.y() + screen->getSnapOffset(),
               r.width() - screen->getSnapOffset(),
@@ -657,7 +593,7 @@ bool Workspace::smartPlacement(Rect& win) {
   //Find Free Spaces
   BlackboxWindowList::const_iterator wit = windowList.begin(),
     end = windowList.end();
-  Rect tmp;
+  otk::Rect tmp;
   for (; wit != end; ++wit) {
     const BlackboxWindow* const curr = *wit;
 
@@ -669,8 +605,8 @@ bool Workspace::smartPlacement(Rect& win) {
     }
 
     tmp.setRect(curr->frameRect().x(), curr->frameRect().y(),
-                curr->frameRect().width() + screen->getBorderWidth(),
-                curr->frameRect().height() + screen->getBorderWidth());
+                curr->frameRect().width() + screen->getWindowStyle()->getBorderWidth(),
+                curr->frameRect().height() + screen->getWindowStyle()->getBorderWidth());
 
     spaces = calcSpace(tmp, spaces);
   }
@@ -711,7 +647,7 @@ bool Workspace::smartPlacement(Rect& win) {
     return False;
 
   //set new position based on the empty space found
-  const Rect& where = *sit;
+  const otk::Rect& where = *sit;
   win.setX(where.x());
   win.setY(where.y());
 
@@ -731,14 +667,14 @@ bool Workspace::smartPlacement(Rect& win) {
 }
 
 
-bool Workspace::underMousePlacement(Rect &win) {
+bool Workspace::underMousePlacement(otk::Rect &win) {
   int x, y, rx, ry;
   Window c, r;
   unsigned int m;
-  XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(),
+  XQueryPointer(otk::OBDisplay::display, screen->getRootWindow(),
                 &r, &c, &rx, &ry, &x, &y, &m);
 
-  Rect area;
+  otk::Rect area;
 #ifdef    XINERAMA
   if (screen->isXineramaActive() &&
       screen->getBlackbox()->doXineramaPlacement()) {
@@ -772,8 +708,8 @@ bool Workspace::underMousePlacement(Rect &win) {
 }
 
 
-bool Workspace::cascadePlacement(Rect &win, const int offset) {
-  Rect area;
+bool Workspace::cascadePlacement(otk::Rect &win, const int offset) {
+  otk::Rect area;
   
 #ifdef    XINERAMA
   if (screen->isXineramaActive() &&
@@ -812,7 +748,7 @@ bool Workspace::cascadePlacement(Rect &win, const int offset) {
 
 
 void Workspace::placeWindow(BlackboxWindow *win) {
-  Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
+  otk::Rect new_win(0, 0, win->frameRect().width(), win->frameRect().height());
   bool placed = False;
 
   switch (screen->getPlacementPolicy()) {
@@ -829,7 +765,7 @@ void Workspace::placeWindow(BlackboxWindow *win) {
 
   if (placed == False)
     cascadePlacement(new_win, (win->getTitleHeight() +
-                               screen->getBorderWidth() * 2));
+                               screen->getWindowStyle()->getBorderWidth() * 2));
 
   if (new_win.right() > screen->availableArea().right())
     new_win.setX(screen->availableArea().left());
@@ -838,3 +774,5 @@ void Workspace::placeWindow(BlackboxWindow *win) {
 
   win->configure(new_win.x(), new_win.y(), new_win.width(), new_win.height());
 }
+
+}
This page took 0.038622 seconds and 4 git commands to generate.