all repos — openbox @ 7fe3301e7ea905a8a76d54c22751f3d8a346e28b

openbox fork - make it a bit more like ryudo

Add the "obsetroot" tool. Use it to set the root background.
Dana Jansens danakj@orodu.net
commit

7fe3301e7ea905a8a76d54c22751f3d8a346e28b

parent

299dc47a6b6379bba77fc489ef6825dcfe18faf5

M Makefile.amMakefile.am

@@ -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
M configure.acconfigure.ac

@@ -54,6 +54,7 @@

AC_CONFIG_FILES([Makefile po/Makefile.in otk/Makefile src/Makefile + tools/Makefile wrap/Makefile scripts/Makefile doc/Makefile
M otk/.cvsignoreotk/.cvsignore

@@ -41,3 +41,4 @@ rendercontrol.lo

rendercolor.lo otk.py otk.pc +otk.lo
M otk/Makefile.amotk/Makefile.am

@@ -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
M otk/application.ccotk/application.cc

@@ -8,41 +8,34 @@ #include "timer.hh"

#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(); - Timer::initialize(); - RenderColor::initialize(); - RenderStyle::initialize(); - Property::initialize(); - + _screen = DefaultScreen(**display); + loadStyle(); } Application::~Application() { - RenderStyle::destroy(); - RenderColor::destroy(); - Timer::destroy(); + otk::destroy(); } void Application::loadStyle(void)
M otk/application.hhotk/application.hh

@@ -3,7 +3,6 @@ #ifndef __application_hh

#define __application_hh #include "eventdispatcher.hh" -#include "display.hh" namespace otk {

@@ -27,7 +26,6 @@

private: void loadStyle(void); - Display _display; int _screen; bool _dockable;
M otk/appwidget.ccotk/appwidget.cc

@@ -6,6 +6,7 @@ #include "appwidget.hh"

#include "application.hh" #include "property.hh" #include "renderstyle.hh" +#include "display.hh" extern "C" { #include <X11/Xlib.h>
A otk/otk.cc

@@ -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; +} + +}
M otk/otk.hhotk/otk.hh

@@ -30,4 +30,9 @@ #include "util.hh"

#include "ustring.hh" #include "widget.hh" +namespace otk { +void initialize(); +void destroy(); +} + #endif // __otk_hh
M otk/property.ccotk/property.cc

@@ -134,6 +134,9 @@ create("_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");

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"); }
M otk/property.hhotk/property.hh

@@ -125,6 +125,9 @@ Atom kde_net_system_tray_windows;

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; };
M otk/pseudorendercontrol.ccotk/pseudorendercontrol.cc

@@ -9,13 +9,11 @@ #include "surface.hh"

#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 {
M otk/rendercontrol.ccotk/rendercontrol.cc

@@ -13,15 +13,22 @@ #include "screeninfo.hh"

#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 {

@@ -47,20 +54,15 @@ }

RenderControl::RenderControl(int screen) : _screen(screen) + { printf("Initializing RenderControl\n"); + } 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,
M otk/rendercontrol.hhotk/rendercontrol.hh

@@ -48,9 +48,6 @@ virtual ~RenderControl();

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.
M otk/renderstyle.ccotk/renderstyle.cc

@@ -73,11 +73,11 @@ {

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 @@ s->_bevel_width = 1;

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 @@ {

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 @@ }

RenderStyle::~RenderStyle() { - assert(_root_color); - delete _root_color; - assert(_text_color_focus); delete _text_color_focus; assert(_text_color_unfocus);
M otk/renderstyle.hhotk/renderstyle.hh

@@ -8,6 +8,7 @@ #include "font.hh"

#include "ustring.hh" #include <list> +#include <string> namespace otk {

@@ -49,7 +50,7 @@

int _screen; ustring _file; - RenderColor *_root_color; + std::string _root_args; RenderColor *_text_color_focus; RenderColor *_text_color_unfocus;

@@ -97,7 +98,7 @@ virtual ~RenderStyle();

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 @@ };

} -#endif // __rendertexture_hh +#endif // __renderstyle_hh
M otk/truerendercontrol.ccotk/truerendercontrol.cc

@@ -9,13 +9,11 @@ #include "surface.hh"

#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 {
M src/actions.ccsrc/actions.cc

@@ -72,6 +72,8 @@ {

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);
M src/openbox.ccsrc/openbox.cc

@@ -38,6 +38,11 @@ #include <algorithm>

#include <cstdio> #include <cstdlib> +namespace otk { +extern void initialize(); +extern void destroy(); +} + namespace ob { Openbox *openbox = (Openbox *) 0;

@@ -73,8 +78,7 @@

Openbox::Openbox(int argc, char **argv) : otk::EventDispatcher(), - otk::EventHandler(), - _display() + otk::EventHandler() { struct sigaction action;

@@ -82,7 +86,6 @@ _state = State_Starting; // initializing everything

openbox = this; - _displayreq = (char*) 0; _argv = argv; _shutdown = false; _restart = false;

@@ -94,6 +97,8 @@ _single = false;

parseCommandLine(argc, argv); + otk::initialize(); + XSynchronize(**otk::display, _sync); // set up the signal handler

@@ -112,10 +117,6 @@

// 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 @@ XSetInputFocus(**otk::display, PointerRoot, RevertToNone,

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 @@

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
M src/openbox.hhsrc/openbox.hh

@@ -72,9 +72,6 @@ //! A list of Screen classes

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 @@ /*!

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)
M src/screen.ccsrc/screen.cc

@@ -10,6 +10,7 @@ #include "bindings.hh"

#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 @@ openbox->cursors().session);

// 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();
A tools/.cvsignore

@@ -0,0 +1,5 @@

+.libs +.deps +obsetroot +Makefile.in +Makefile
A tools/Makefile.am

@@ -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 .\#*
A tools/obsetroot.cc

@@ -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(); +}