]> Dogcows Code - chaz/openbox/commitdiff
Add the "obsetroot" tool. Use it to set the root background.
authorDana Jansens <danakj@orodu.net>
Fri, 14 Feb 2003 23:05:59 +0000 (23:05 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 14 Feb 2003 23:05:59 +0000 (23:05 +0000)
24 files changed:
Makefile.am
configure.ac
otk/.cvsignore
otk/Makefile.am
otk/application.cc
otk/application.hh
otk/appwidget.cc
otk/otk.cc [new file with mode: 0644]
otk/otk.hh
otk/property.cc
otk/property.hh
otk/pseudorendercontrol.cc
otk/rendercontrol.cc
otk/rendercontrol.hh
otk/renderstyle.cc
otk/renderstyle.hh
otk/truerendercontrol.cc
src/actions.cc
src/openbox.cc
src/openbox.hh
src/screen.cc
tools/.cvsignore [new file with mode: 0644]
tools/Makefile.am [new file with mode: 0644]
tools/obsetroot.cc [new file with mode: 0644]

index 4c82fef8d46df6303a883cb4b6f4927b0879b05e..24916164390856c28cbedf57345f77cc3cb6fb70 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = po data doc otk wrap src scripts
+SUBDIRS = po data doc otk wrap src scripts tools
 MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
 
 .PHONY: doc
index c5302aa4cf9a049e9f71f916ac8bb04becfde1fb..b83776fad98c0844fadf40efd51bac8d8aab0c1a 100644 (file)
@@ -54,6 +54,7 @@ X11_EXT_XINERAMA
 AC_CONFIG_FILES([Makefile po/Makefile.in
                otk/Makefile
                src/Makefile
+               tools/Makefile
                wrap/Makefile
                scripts/Makefile
                doc/Makefile
index 0497be4ac8ae74a814a151e225c68debbc989ea8..7dab6bb60b7ac500ef569beb187ad33d8fa84b29 100644 (file)
@@ -41,3 +41,4 @@ rendercontrol.lo
 rendercolor.lo
 otk.py
 otk.pc
+otk.lo
index f0c2e805d654f19f916fe59059283ed5c3379db9..dc53291fdd8ea9350d8c97c7a815a202dc3f74e7 100644 (file)
@@ -10,7 +10,8 @@ libotk_la_SOURCES=rendercontrol.cc truerendercontrol.cc surface.cc util.cc \
                   renderstyle.cc rendercolor.cc pseudorendercontrol.cc \
                   display.cc font.cc screeninfo.cc property.cc timer.cc \
                   eventdispatcher.cc eventhandler.cc ustring.cc \
-                  widget.cc application.cc label.cc appwidget.cc button.cc
+                  widget.cc application.cc label.cc appwidget.cc button.cc \
+                  otk.cc
 
 #focuswidget.cc focuslabel.cc
 
index 94842ca5848dd96617e84a91d6cb20ed54cbfc52..afe06f803a41b5048604ca4f49e112dd8330fe67 100644 (file)
@@ -8,41 +8,34 @@
 #include "property.hh"
 #include "rendercolor.hh"
 #include "renderstyle.hh"
+#include "display.hh"
 
-extern "C" {
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-}
-
+#include <cstdlib>
 #include <iostream>
 
 namespace otk {
 
+extern void initialize();
+extern void destroy();
+
 Application::Application(int argc, char **argv)
   : EventDispatcher(),
-    _display(),
     _dockable(false),
     _appwidget_count(0)
 {
   (void)argc;
   (void)argv;
 
-  _screen = DefaultScreen(*_display);
+  otk::initialize();
+  
+  _screen = DefaultScreen(**display);
   
-  Timer::initialize();
-  RenderColor::initialize();
-  RenderStyle::initialize();
-  Property::initialize();
-
   loadStyle();
 }
 
 Application::~Application()
 {
-  RenderStyle::destroy();
-  RenderColor::destroy();
-  Timer::destroy();
+  otk::destroy();
 }
 
 void Application::loadStyle(void)
index 848b79858723a195155b393f99f6a73b79b1612c..6da36d28e40764f0963f446ee7d1982e27a22303 100644 (file)
@@ -3,7 +3,6 @@
 #define __application_hh
 
 #include "eventdispatcher.hh"
-#include "display.hh"
 
 namespace otk {
 
@@ -27,7 +26,6 @@ public:
 private:
   void loadStyle(void);
 
-  Display _display;
   int _screen;
   bool _dockable;
 
index 8b157225fd09031477d6e5a5965c9157ab6d1941..5dcad7aea6e08c2628137bb577a04692534338f8 100644 (file)
@@ -6,6 +6,7 @@
 #include "application.hh"
 #include "property.hh"
 #include "renderstyle.hh"
+#include "display.hh"
 
 extern "C" {
 #include <X11/Xlib.h>
diff --git a/otk/otk.cc b/otk/otk.cc
new file mode 100644 (file)
index 0000000..130e3b7
--- /dev/null
@@ -0,0 +1,25 @@
+#include "display.hh"
+#include "timer.hh"
+#include "renderstyle.hh"
+#include "property.hh"
+
+namespace otk {
+
+void initialize()
+{
+  new Display();
+  Timer::initialize();
+  RenderColor::initialize();
+  RenderStyle::initialize();
+  Property::initialize();
+}
+
+void destroy()
+{
+  RenderStyle::destroy();
+  RenderColor::destroy();
+  Timer::destroy();
+  delete display;
+}
+
+}
index 62788cba9baf8d1f28a59e8467ce582939ed6dc3..74187f05499bb32dc148e5cf40ff9f89835c2c08 100644 (file)
@@ -30,4 +30,9 @@
 #include "ustring.hh"
 #include "widget.hh"
 
+namespace otk {
+void initialize();
+void destroy();
+}
+
 #endif // __otk_hh
index 75f9a7cf20f9974b6c33c12ff5177454963fcfe5..16b507f51adacbed113c370e2b62d1ded7796b1f 100644 (file)
@@ -134,6 +134,9 @@ void Property::initialize()
   atoms.kde_net_wm_window_type_override =
     create("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
 
+  atoms.rootpmapid = create("_XROOTPMAP_ID");
+  atoms.esetrootid = create("ESETROOT_PMAP_ID");
+
   atoms.openbox_premax = create("_OPENBOX_PREMAX");
   atoms.openbox_active_window = create("_OPENBOX_ACTIVE_WINDOW");
 }
index f773c649c2d0b35ba8daa6b4f1dbadb05c28ccfd..e6677a643620231cdd71758317ada365a3065468 100644 (file)
@@ -125,6 +125,9 @@ struct Atoms {
   Atom kde_net_wm_system_tray_window_for;
   Atom kde_net_wm_window_type_override;
 
+  Atom rootpmapid;
+  Atom esetrootid;
+
   Atom openbox_premax;
   Atom openbox_active_window;
 };
index 7af57192461443d65b5a5ac21df4a9aa51fa4dd9..cf9929248586e4e2c12d0b002eba771bcfb610fe 100644 (file)
@@ -9,14 +9,12 @@
 #include "rendertexture.hh"
 
 extern "C" {
-#ifdef    HAVE_STDLIB_H
-#  include <stdlib.h>
-#endif // HAVE_STDLIB_H
-
 #include "../src/gettext.h"
 #define _(str) gettext(str)
 }
 
+#include <cstdlib>
+
 namespace otk {
 
 PseudoRenderControl::PseudoRenderControl(int screen)
index a4de270a3ab6abe857fc43349624f8c1bb7185b2..8f9329688c04c4f09fffdd9db6967f466999c947 100644 (file)
 #include "surface.hh"
 #include "font.hh"
 #include "ustring.hh"
+#include "property.hh"
 
 extern "C" {
-#ifdef    HAVE_STDLIB_H
-#  include <stdlib.h>
-#endif // HAVE_STDLIB_H
+#ifdef    HAVE_SYS_WAIT_H
+#  include <sys/wait.h>
+#endif // HAVE_SYS_WAIT_H
+
+#ifdef    HAVE_UNISTD_H
+#  include <unistd.h>
+#endif // HAVE_UNISTD_H
 
 #include "../src/gettext.h"
 #define _(str) gettext(str)
 }
 
+#include <cstdlib>
+
 namespace otk {
 
 RenderControl *RenderControl::getRenderControl(int screen)
@@ -47,8 +54,10 @@ RenderControl *RenderControl::getRenderControl(int screen)
 
 RenderControl::RenderControl(int screen)
   : _screen(screen)
+    
 {
   printf("Initializing RenderControl\n");
+  
 }
 
 RenderControl::~RenderControl()
@@ -56,13 +65,6 @@ RenderControl::~RenderControl()
   printf("Destroying RenderControl\n");
 }
 
-void RenderControl::drawRoot(const RenderColor &color) const
-{
-  Window root = display->screenInfo(_screen)->rootWindow();
-  XSetWindowBackground(**display, root, color.pixel());
-  XClearWindow(**display, root);
-}
-
 void RenderControl::drawString(Surface& sf, const Font &font, int x, int y,
                               const RenderColor &color,
                                const ustring &string) const
index 56f45c8a94cbcc7b393ce7f63499e4ca777ff896..5e21da291f0cc3528428d0eec0184e366d27aad2 100644 (file)
@@ -48,9 +48,6 @@ public:
 
   static RenderControl *getRenderControl(int screen);
 
-  //! Draws onto the root window
-  virtual void drawRoot(const RenderColor &color) const;
-  
   //! Draws a background onto a Surface, as specified by a RenderTexture
   /*!
     This function will overwrite the entire surface.
index d9e106ab09d8f634f18ff47eb725474205e48598..88c8d7871fca4fd7e62022ab32c40c2c24d303a9 100644 (file)
@@ -73,11 +73,11 @@ bool RenderStyle::loadStyle(RenderStyle *s, int screen,
   s->_screen = screen;
   s->_file = stylefile;
 // pick one..
-//#define FIERON
-#define MERRY
+#define FIERON
+//#define MERRY
 
 #ifdef FIERON
-  s->_root_color = new RenderColor(screen, 0x272a2f);
+  s->_root_args = "#272a2f";
   
   s->_text_color_focus = new RenderColor(screen, 0x272a2f);
   s->_text_color_unfocus = new RenderColor(screen, 0x676869);
@@ -281,7 +281,7 @@ bool RenderStyle::loadStyle(RenderStyle *s, int screen,
   s->_handle_width = 4;
 #else
 #  ifdef MERRY
-  s->_root_color = new RenderColor(screen, 0x7b756a);
+  s->_root_args = "#7b756a";
   
   s->_text_color_focus = new RenderColor(screen, 0xffffff);
   s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
@@ -497,7 +497,7 @@ void RenderStyle::defaultStyle(RenderStyle *s, int screen)
   s->_screen = screen;
   s->_file = "";
 
-  s->_root_color = new RenderColor(screen, 0);
+  s->_root_args = "#000000";
   s->_text_color_focus = new RenderColor(screen, 0xffffff);
   s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
   s->_button_color_focus = new RenderColor(screen, 0);
@@ -634,9 +634,6 @@ void RenderStyle::defaultStyle(RenderStyle *s, int screen)
 
 RenderStyle::~RenderStyle()
 {
-  assert(_root_color);
-  delete _root_color;
-  
   assert(_text_color_focus);
   delete _text_color_focus;
   assert(_text_color_unfocus);
index 69c26a7fa189ecf5666e20c3dba0f01cde283462..0f512148e94e6f503885b13528726a13b541680c 100644 (file)
@@ -8,6 +8,7 @@
 #include "ustring.hh"
 
 #include <list>
+#include <string>
 
 namespace otk {
 
@@ -49,7 +50,7 @@ private:
   int _screen;
   ustring _file;
 
-  RenderColor *_root_color;
+  std::string _root_args;
   
   RenderColor *_text_color_focus;
   RenderColor *_text_color_unfocus;
@@ -97,7 +98,7 @@ public:
 
   inline int screen() const { return _screen; }
   
-  inline RenderColor *rootColor() const { return _root_color; }
+  inline const std::string& rootArgs() const { return _root_args; }
   
   inline RenderColor *textFocusColor() const { return _text_color_focus; }
   inline RenderColor *textUnfocusColor() const { return _text_color_unfocus; }
@@ -153,4 +154,4 @@ public:
 
 }
 
-#endif // __rendertexture_hh
+#endif // __renderstyle_hh
index 2ce771ebcc32180627513ffaef776f5b4a1439d0..42589dd3e5f8adb2fd8e6f77337ab72826570545 100644 (file)
@@ -9,14 +9,12 @@
 #include "rendertexture.hh"
 
 extern "C" {
-#ifdef    HAVE_STDLIB_H
-#  include <stdlib.h>
-#endif // HAVE_STDLIB_H
-
 #include "../src/gettext.h"
 #define _(str) gettext(str)
 }
 
+#include <cstdlib>
+
 namespace otk {
 
 TrueRenderControl::TrueRenderControl(int screen)
index cefa577872f2ebaa0d13ec5a74e23139cf19d266..1213f21ef40a1293948f3e9f65159651e8c81caf 100644 (file)
@@ -72,6 +72,8 @@ void Actions::buttonPressHandler(const XButtonEvent &e)
   otk::EventHandler::buttonPressHandler(e);
   insertPress(e);
 
+  printf("press queue %u pressed %u\n", _button, e.button);
+
   MouseContext::MC context;
   EventHandler *h = openbox->findHandler(e.window);
   Frame *f = dynamic_cast<Frame*>(h);
index 89e541aa7d29e4a18a60a963f938d86466ae8320..d068880baf08e8c1a6d66c2dc3adc5fea180419b 100644 (file)
@@ -38,6 +38,11 @@ extern "C" {
 #include <cstdio>
 #include <cstdlib>
 
+namespace otk {
+extern void initialize();
+extern void destroy();
+}
+
 namespace ob {
 
 Openbox *openbox = (Openbox *) 0;
@@ -73,8 +78,7 @@ void Openbox::signalHandler(int signal)
 
 Openbox::Openbox(int argc, char **argv)
   : otk::EventDispatcher(),
-    otk::EventHandler(),
-    _display()
+    otk::EventHandler()
 {
   struct sigaction action;
 
@@ -82,7 +86,6 @@ Openbox::Openbox(int argc, char **argv)
 
   openbox = this;
 
-  _displayreq = (char*) 0;
   _argv = argv;
   _shutdown = false;
   _restart = false;
@@ -94,6 +97,8 @@ Openbox::Openbox(int argc, char **argv)
 
   parseCommandLine(argc, argv);
 
+  otk::initialize();
+  
   XSynchronize(**otk::display, _sync);
   
   // set up the signal handler
@@ -112,10 +117,6 @@ Openbox::Openbox(int argc, char **argv)
   // anything that died while we were restarting won't give us a SIGCHLD
   while (waitpid(-1, NULL, WNOHANG) > 0);
 
-  otk::RenderColor::initialize();
-  otk::RenderStyle::initialize();
-  otk::Timer::initialize();
-  otk::Property::initialize();
   _actions = new Actions();
   _bindings = new Bindings();
 
@@ -200,14 +201,7 @@ Openbox::~Openbox()
                  CurrentTime);
   XSync(**otk::display, false);
 
-  // this tends to block.. i honestly am not sure why. causing an x error in
-  // the shutdown process unblocks it. blackbox simply did a ::exit(0), so
-  // all im gunna do is the same.
-  //delete _display;
-
-  otk::Timer::destroy();
-  otk::RenderStyle::destroy();
-  otk::RenderColor::destroy();
+  otk::destroy();
 }
 
 
@@ -218,12 +212,7 @@ void Openbox::parseCommandLine(int argc, char **argv)
   for (int i = 1; i < argc; ++i) {
     std::string arg(argv[i]);
 
-    if (arg == "-display") {
-      if (++i >= argc)
-        err = true;
-      else
-        _displayreq = argv[i];
-    } else if (arg == "-rc") {
+    if (arg == "-rc") {
       if (++i >= argc)
         err = true;
       else
index 8145531fc4e64abb36105f8b78985947fab5b1c1..e718dd2520cb5d0ce727ef5712e0e6e0035e85e7 100644 (file)
@@ -72,9 +72,6 @@ public:
   typedef std::vector<Screen *> ScreenList;
   
 private:
-  //! The display on which Openbox is running
-  otk::Display _display;
-  
   // stuff that can be passed on the command line
   //! Path to the config file to use/in use
   /*!
@@ -91,8 +88,6 @@ private:
     Defaults to $(HOME)/.openbox/user.py
   */
   std::string _scriptfilepath;
-  //! The display requested by the user, or null to use the DISPLAY env var
-  char *_displayreq;
   //! The value of argv, i.e. how this application was executed
   char **_argv;
   //! Run the application in synchronous mode? (for debugging)
index 3f507afbe51ca89efd06df7edf073d09f1f5f391..6eaa5cc577190461a0ca2fd6022b5705ddfe758e 100644 (file)
@@ -10,6 +10,7 @@
 #include "python.hh"
 #include "otk/display.hh"
 #include "otk/property.hh"
+#include "otk/util.hh"
 
 extern "C" {
 #ifdef    HAVE_UNISTD_H
@@ -68,8 +69,9 @@ Screen::Screen(int screen)
 
   // initialize the screen's style
   otk::RenderStyle::setStyle(_number, _config.theme);
-  otk::display->renderControl(_number)->
-    drawRoot(*otk::RenderStyle::style(_number)->rootColor());
+  // draw the root window
+  otk::bexec("obsetroot " + otk::RenderStyle::style(_number)->rootArgs(),
+             _info->displayString());
 
   // set up notification of netwm support
   changeSupportedAtoms();
diff --git a/tools/.cvsignore b/tools/.cvsignore
new file mode 100644 (file)
index 0000000..b0f0d99
--- /dev/null
@@ -0,0 +1,5 @@
+.libs
+.deps
+obsetroot
+Makefile.in
+Makefile
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644 (file)
index 0000000..1785c00
--- /dev/null
@@ -0,0 +1,10 @@
+bin_PROGRAMS=obsetroot
+
+obsetroot_LDADD=$(XFT_LIBS) -L../otk -lotk @LIBINTL@
+obsetroot_CPPFLAGS=$(XFT_CFLAGS) -I..
+obsetroot_SOURCES=obsetroot.cc
+
+MAINTAINERCLEANFILES=Makefile.in
+
+distclean-local:
+       $(RM) *\~ *.orig *.rej .\#*
diff --git a/tools/obsetroot.cc b/tools/obsetroot.cc
new file mode 100644 (file)
index 0000000..286a61e
--- /dev/null
@@ -0,0 +1,66 @@
+#include <otk/otk.hh>
+
+int main(int argc, char **argv)
+{
+  otk::initialize();
+
+  int screen = DefaultScreen(**otk::display);
+  
+  Pixmap old;
+  Window root = otk::display->screenInfo(screen)->rootWindow();
+
+  otk::Surface *s = new otk::Surface(screen,
+                                    otk::display->screenInfo(screen)->size());
+  otk::RenderTexture *tx = new otk::RenderTexture(screen, false,
+                                                 otk::RenderTexture::Flat,
+                                                 otk::RenderTexture::Bevel1,
+                                                 false,
+                                                 otk::RenderTexture::Solid,
+                                                 false, 0x202020, 0x0000ff,
+                                                 0, 0);
+  otk::display->renderControl(screen)->drawBackground(*s, *tx);
+
+  otk::display->grab();
+
+  otk::display->setIgnoreErrors(true);
+  // get the current pixmap and free it
+  if (otk::Property::get(root, otk::Property::atoms.rootpmapid,
+                        otk::Property::atoms.pixmap, &old) && old) {
+    XKillClient(**otk::display, old);
+    XSync(**otk::display, false);
+    XFreePixmap(**otk::display, old);
+  }
+  if (otk::Property::get(root, otk::Property::atoms.esetrootid,
+                        otk::Property::atoms.pixmap, &old) && old)
+    XFreePixmap(**otk::display, old);
+  otk::display->setIgnoreErrors(false);
+
+  //  XSetWindowBackground(**display, root, color.pixel());
+
+  // don't kill us when someone wants to change the background!!
+  Pixmap pixmap = XCreatePixmap(**otk::display, root, s->size().width(),
+                               s->size().height(),
+                               otk::display->screenInfo(screen)->depth());
+  XCopyArea(**otk::display, s->pixmap(), pixmap,
+           DefaultGC(**otk::display, screen), 0, 0,
+           s->size().width(), s->size().height(), 0, 0);
+
+  // set the new pixmap
+  XSetWindowBackgroundPixmap(**otk::display, root, pixmap);
+  XClearWindow(**otk::display, root);
+
+  otk::Property::set(root, otk::Property::atoms.rootpmapid,
+                    otk::Property::atoms.pixmap, pixmap);
+  otk::Property::set(root, otk::Property::atoms.esetrootid,
+                    otk::Property::atoms.pixmap, pixmap);
+  
+  otk::display->ungrab();
+
+  delete tx;
+  delete s;
+
+  XSetCloseDownMode(**otk::display, RetainPermanent);
+  XKillClient(**otk::display, AllTemporary);
+  
+  otk::destroy();
+}
This page took 0.04693 seconds and 4 git commands to generate.