Add the "obsetroot" tool. Use it to set the root background.

This commit is contained in:
Dana Jansens 2003-02-14 23:05:59 +00:00
parent 299dc47a6b
commit 7fe3301e7e
24 changed files with 173 additions and 80 deletions

View 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

View 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

View file

@ -41,3 +41,4 @@ rendercontrol.lo
rendercolor.lo
otk.py
otk.pc
otk.lo

View 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

View 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)

View 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;

View file

@ -6,6 +6,7 @@
#include "application.hh"
#include "property.hh"
#include "renderstyle.hh"
#include "display.hh"
extern "C" {
#include <X11/Xlib.h>

25
otk/otk.cc Normal file
View file

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

View file

@ -30,4 +30,9 @@
#include "ustring.hh"
#include "widget.hh"
namespace otk {
void initialize();
void destroy();
}
#endif // __otk_hh

View 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");
}

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

View 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)

View file

@ -13,16 +13,23 @@
#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

View 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.

View 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);

View 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

View 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)

View 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);

View 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

View 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)

View 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();

5
tools/.cvsignore Normal file
View file

@ -0,0 +1,5 @@
.libs
.deps
obsetroot
Makefile.in
Makefile

10
tools/Makefile.am Normal file
View file

@ -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 .\#*

66
tools/obsetroot.cc Normal file
View file

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