]> Dogcows Code - chaz/openbox/blobdiff - src/screen.cc
free the colors on shutdown
[chaz/openbox] / src / screen.cc
index d242e8876173a7444297301a58a0fa8faab03488..039d82050fa770004a9f2ff93ef877ba7353d33d 100644 (file)
@@ -2,6 +2,15 @@
 
 #include "config.h"
 
+#include "screen.hh"
+#include "client.hh"
+#include "openbox.hh"
+#include "frame.hh"
+#include "bindings.hh"
+#include "python.hh"
+#include "otk/display.hh"
+#include "otk/property.hh"
+
 extern "C" {
 #ifdef    HAVE_UNISTD_H
 #  include <sys/types.h>
@@ -12,15 +21,6 @@ extern "C" {
 #define _(str) gettext(str)
 }
 
-#include "screen.hh"
-#include "client.hh"
-#include "openbox.hh"
-#include "frame.hh"
-#include "bindings.hh"
-#include "python.hh"
-#include "otk/display.hh"
-#include "otk/property.hh"
-
 #include <vector>
 #include <algorithm>
 #include <cstdio>
@@ -44,8 +44,6 @@ Screen::Screen(int screen)
   assert(screen >= 0); assert(screen < ScreenCount(**otk::display));
   _info = otk::display->screenInfo(screen);
 
-  _showing_desktop = false;
-
   ::running = false;
   XErrorHandler old = XSetErrorHandler(::anotherWMRunning);
   XSelectInput(**otk::display, _info->rootWindow(),
@@ -113,6 +111,12 @@ Screen::Screen(int screen)
 
   changeDesktop(0); // set the hint
 
+  // don't start in showing-desktop mode
+  _showing_desktop = false;
+  otk::Property::set(_info->rootWindow(),
+                     otk::Property::atoms.net_showing_desktop,
+                     otk::Property::atoms.cardinal, 0);
+
   // create the window which gets focus when no clients get it
   XSetWindowAttributes attr;
   attr.override_redirect = true;
@@ -863,6 +867,11 @@ void Screen::setDesktopName(unsigned int i, const otk::ustring &name)
                      otk::Property::utf8, newnames);
 }
 
+otk::ustring Screen::desktopName(unsigned int i) const
+{
+  if (i >= _num_desktops) return "";
+  return _desktop_names[i];
+}
 
 const otk::Rect& Screen::area(unsigned int desktop) const {
   assert(desktop < _num_desktops || desktop == 0xffffffff);
@@ -889,15 +898,10 @@ void Screen::showDesktop(bool show)
   if (show) {
     Client *c = openbox->focusedClient();
     if (c) saved_focus = c->window();
-  } else {
-    Client *f = openbox->focusedClient();
-    if (!f || f->type() == Client::Type_Desktop) {
-      Client *c = openbox->findClient(saved_focus);
-      if (c) c->focus();
-    }
   }
   
   _showing_desktop = show;
+
   ClientList::iterator it, end = clients.end();
   for (it = clients.begin(); it != end; ++it) {
     if ((*it)->type() == Client::Type_Desktop) {
@@ -906,6 +910,19 @@ void Screen::showDesktop(bool show)
     } else
       (*it)->showhide();
   }
+
+  if (!show) {
+    Client *f = openbox->focusedClient();
+    if (!f || f->type() == Client::Type_Desktop) {
+      Client *c = openbox->findClient(saved_focus);
+      if (c) c->focus();
+    }
+  }
+
+  otk::Property::set(_info->rootWindow(),
+                     otk::Property::atoms.net_showing_desktop,
+                     otk::Property::atoms.cardinal,
+                     show ? 1 : 0);
 }
 
 void Screen::propertyHandler(const XPropertyEvent &e)
This page took 0.025102 seconds and 4 git commands to generate.