]> Dogcows Code - chaz/openbox/blobdiff - src/Screen.cc
new focus code! working better than ever!
[chaz/openbox] / src / Screen.cc
index 60ae159e5ba3b551b624abfaa51a6aa6bb194916..50a0f1d125cc9f131d00c419264522e3e0ab5364 100644 (file)
@@ -1,4 +1,3 @@
-#include <iostream.h>
 // Screen.cc for Openbox
 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
 #include <string>
 #include <algorithm>
 #include <functional>
-using namespace std;
+using std::ends;
 
 static Bool running = True;
 
@@ -226,6 +225,7 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
   slit = NULL;
 #endif // SLIT
   toolbar = NULL;
+  current_workspace = (Workspace *) 0;
 
 #ifdef    HAVE_GETPID
   pid_t bpid = getpid();
@@ -484,9 +484,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
     }
   }
 
-  XSetInputFocus(getBaseDisplay().getXDisplay(),
-                 PointerRoot, None, CurrentTime);
-
   XFree(children);
   XFlush(getBaseDisplay().getXDisplay());
 }
@@ -916,7 +913,7 @@ XFontSet BScreen::createFontSet(const char *fontname) {
 
 void BScreen::setSloppyFocus(bool b) {
   resource.sloppy_focus = b;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
   config.setValue(s.str(),
                   (resource.sloppy_focus ?
@@ -928,7 +925,7 @@ void BScreen::setSloppyFocus(bool b) {
 
 void BScreen::setAutoRaise(bool a) {
   resource.auto_raise = a;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
   config.setValue(s.str(),
                   (resource.sloppy_focus ?
@@ -940,7 +937,7 @@ void BScreen::setAutoRaise(bool a) {
 
 void BScreen::setImageDither(bool d, bool reconfig) {
   image_control->setDither(d);
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".imageDither" << ends;
   config.setValue(s.str(), imageDither());
   if (reconfig)
@@ -951,7 +948,7 @@ void BScreen::setImageDither(bool d, bool reconfig) {
 
 void BScreen::setOpaqueMove(bool o) {
   resource.opaque_move = o;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends;
   config.setValue(s.str(), resource.opaque_move);
   s.rdbuf()->freeze(0);
@@ -960,7 +957,7 @@ void BScreen::setOpaqueMove(bool o) {
 
 void BScreen::setFullMax(bool f) {
   resource.full_max = f;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends;
   config.setValue(s.str(), resource.full_max);
   s.rdbuf()->freeze(0);
@@ -969,7 +966,7 @@ void BScreen::setFullMax(bool f) {
 
 void BScreen::setFocusNew(bool f) {
   resource.focus_new = f;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends;
   config.setValue(s.str(), resource.focus_new);
   s.rdbuf()->freeze(0);
@@ -978,7 +975,7 @@ void BScreen::setFocusNew(bool f) {
 
 void BScreen::setFocusLast(bool f) {
   resource.focus_last = f;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends;
   config.setValue(s.str(), resource.focus_last);
   s.rdbuf()->freeze(0);
@@ -987,7 +984,7 @@ void BScreen::setFocusLast(bool f) {
 
 void BScreen::setWindowZones(int z) {
   resource.zones = z;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".windowZones" << ends;
   config.setValue(s.str(), resource.zones);
   s.rdbuf()->freeze(0);
@@ -996,7 +993,7 @@ void BScreen::setWindowZones(int z) {
 
 void BScreen::setWorkspaceCount(int w) {
   resource.workspaces = w;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".workspaces" << ends;
   config.setValue(s.str(), resource.workspaces);
   s.rdbuf()->freeze(0);
@@ -1005,7 +1002,7 @@ void BScreen::setWorkspaceCount(int w) {
 
 void BScreen::setPlacementPolicy(int p) {
   resource.placement_policy = p;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".windowPlacement" << ends;
   const char *placement;
   switch (resource.placement_policy) {
@@ -1024,7 +1021,7 @@ void BScreen::setPlacementPolicy(int p) {
 
 void BScreen::setEdgeSnapThreshold(int t) {
   resource.edge_snap_threshold = t;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends;
   config.setValue(s.str(), resource.edge_snap_threshold);
   s.rdbuf()->freeze(0);
@@ -1033,7 +1030,7 @@ void BScreen::setEdgeSnapThreshold(int t) {
 
 void BScreen::setRowPlacementDirection(int d) {
   resource.row_direction = d;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".rowPlacementDirection" << ends;
   config.setValue(s.str(),
                   resource.row_direction == LeftRight ?
@@ -1044,7 +1041,7 @@ void BScreen::setRowPlacementDirection(int d) {
 
 void BScreen::setColPlacementDirection(int d) {
   resource.col_direction = d;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".colPlacementDirection" << ends;
   config.setValue(s.str(),
                   resource.col_direction == TopBottom ?
@@ -1072,7 +1069,7 @@ void BScreen::setStrftimeFormat(const char *f) {
     delete [] resource.strftime_format;
 
   resource.strftime_format = bstrdup(f);
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends;
   config.setValue(s.str(), resource.strftime_format);
   s.rdbuf()->freeze(0);
@@ -1082,7 +1079,7 @@ void BScreen::setStrftimeFormat(const char *f) {
 
 void BScreen::setDateFormat(int f) {
   resource.date_format = f;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".dateFormat" << ends;
   config.setValue(s.str(), resource.date_format == B_EuropeanDate ?
                   "European" : "American");
@@ -1092,7 +1089,7 @@ void BScreen::setDateFormat(int f) {
 
 void BScreen::setClock24Hour(Bool c) {
   resource.clock24hour = c;
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".clockFormat" << ends;
   config.setValue(s.str(), resource.clock24hour ? 24 : 12);
   s.rdbuf()->freeze(0);
@@ -1106,7 +1103,7 @@ void BScreen::setHideToolbar(bool b) {
     getToolbar()->unMapToolbar();
   else
     getToolbar()->mapToolbar();
-  ostrstream s;
+  std::ostrstream s;
   s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
   config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
   s.rdbuf()->freeze(0);
@@ -1114,7 +1111,7 @@ void BScreen::setHideToolbar(bool b) {
 
 
 void BScreen::saveWorkspaceNames() {
-  ostrstream rc, names;
+  std::ostrstream rc, names;
 
   wkspList::iterator it;
   wkspList::iterator last = workspacesList.end() - 1;
@@ -1165,7 +1162,7 @@ void BScreen::save() {
 
 
 void BScreen::load() {
-  ostrstream rscreen, rname, rclass;
+  std::ostrstream rscreen, rname, rclass;
   std::string s;
   bool b;
   long l;
@@ -1251,9 +1248,9 @@ void BScreen::load() {
   rname << rscreen.str() << "workspaceNames" << ends;
   rclass << rscreen.str() << "WorkspaceNames" << ends;
   if (config.getValue(rname.str(), rclass.str(), s)) {
-    string::const_iterator it = s.begin(), end = s.end();
+    std::string::const_iterator it = s.begin(), end = s.end();
     while(1) {
-      string::const_iterator tmp = it;// current string.begin()
+      std::string::const_iterator tmp = it;// current string.begin()
       it = std::find(tmp, end, ',');       // look for comma between tmp and end
       std::string name(tmp, it);           // name = s[tmp:it]
       addWorkspaceName(name.c_str());
@@ -1982,8 +1979,7 @@ void BScreen::changeWorkspaceID(int id) {
     if (openbox.focusedWindow() &&
        openbox.focusedWindow()->getScreen() == this &&
         (! openbox.focusedWindow()->isStuck())) {
-      current_workspace->setLastFocusedWindow(openbox.focusedWindow());
-      openbox.focusWindow((OpenboxWindow *) 0);
+      openbox.focusWindow(0);
     }
 
     current_workspace = getWorkspace(id);
@@ -1994,9 +1990,9 @@ void BScreen::changeWorkspaceID(int id) {
 
     current_workspace->showAll();
 
-    if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
+    if (resource.focus_last && current_workspace->lastFocusedWindow()) {
       XSync(openbox.getXDisplay(), False);
-      current_workspace->getLastFocusedWindow()->setInputFocus();
+      current_workspace->lastFocusedWindow()->setInputFocus();
     }
   }
 
This page took 0.027864 seconds and 4 git commands to generate.