new version of bsetroot ported from blackbox cvs
This commit is contained in:
parent
527864614b
commit
f75083669f
6 changed files with 224 additions and 186 deletions
|
@ -338,8 +338,8 @@ BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|||
XSetErrorHandler((XErrorHandler) handleXErrors);
|
||||
|
||||
screenInfoList.reserve(ScreenCount(display));
|
||||
for (int i = 0; i < number_of_screens; i++)
|
||||
screenInfoList.push_back(new ScreenInfo(*this, i));
|
||||
for (unsigned int s = 0; s < number_of_screens; s++)
|
||||
screenInfoList.push_back(new ScreenInfo(*this, s));
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
NumLockMask = ScrollLockMask = 0;
|
||||
|
@ -512,8 +512,6 @@ void BaseDisplay::grab(void) {
|
|||
void BaseDisplay::ungrab(void) {
|
||||
if (! --server_grabs)
|
||||
XUngrabServer(display);
|
||||
|
||||
if (server_grabs < 0) server_grabs = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ private:
|
|||
TimerList timerList;
|
||||
|
||||
char *display_name, *application_name;
|
||||
int number_of_screens, server_grabs, colors_per_channel;
|
||||
unsigned int number_of_screens, server_grabs, colors_per_channel;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -150,128 +150,128 @@ protected:
|
|||
|
||||
public:
|
||||
BaseDisplay(const char *, char * = 0);
|
||||
virtual ~BaseDisplay(void);
|
||||
virtual ~BaseDisplay();
|
||||
|
||||
inline const Atom &getWMChangeStateAtom(void) const
|
||||
inline const Atom &getWMChangeStateAtom() const
|
||||
{ return xa_wm_change_state; }
|
||||
inline const Atom &getWMStateAtom(void) const
|
||||
inline const Atom &getWMStateAtom() const
|
||||
{ return xa_wm_state; }
|
||||
inline const Atom &getWMDeleteAtom(void) const
|
||||
inline const Atom &getWMDeleteAtom() const
|
||||
{ return xa_wm_delete_window; }
|
||||
inline const Atom &getWMProtocolsAtom(void) const
|
||||
inline const Atom &getWMProtocolsAtom() const
|
||||
{ return xa_wm_protocols; }
|
||||
inline const Atom &getWMTakeFocusAtom(void) const
|
||||
inline const Atom &getWMTakeFocusAtom() const
|
||||
{ return xa_wm_take_focus; }
|
||||
inline const Atom &getWMColormapAtom(void) const
|
||||
inline const Atom &getWMColormapAtom() const
|
||||
{ return xa_wm_colormap_windows; }
|
||||
inline const Atom &getMotifWMHintsAtom(void) const
|
||||
inline const Atom &getMotifWMHintsAtom() const
|
||||
{ return motif_wm_hints; }
|
||||
|
||||
// this atom is for normal app->WM hints about decorations, stacking,
|
||||
// starting workspace etc...
|
||||
inline const Atom &getOpenboxHintsAtom(void) const
|
||||
inline const Atom &getOpenboxHintsAtom() const
|
||||
{ return openbox_hints;}
|
||||
|
||||
// these atoms are for normal app->WM interaction beyond the scope of the
|
||||
// ICCCM...
|
||||
inline const Atom &getOpenboxAttributesAtom(void) const
|
||||
inline const Atom &getOpenboxAttributesAtom() const
|
||||
{ return openbox_attributes; }
|
||||
inline const Atom &getOpenboxChangeAttributesAtom(void) const
|
||||
inline const Atom &getOpenboxChangeAttributesAtom() const
|
||||
{ return openbox_change_attributes; }
|
||||
|
||||
// these atoms are for window->WM interaction, with more control and
|
||||
// information on window "structure"... common examples are
|
||||
// notifying apps when windows are raised/lowered... when the user changes
|
||||
// workspaces... i.e. "pager talk"
|
||||
inline const Atom &getOpenboxStructureMessagesAtom(void) const
|
||||
inline const Atom &getOpenboxStructureMessagesAtom() const
|
||||
{ return openbox_structure_messages; }
|
||||
|
||||
// *Notify* portions of the NETStructureMessages protocol
|
||||
inline const Atom &getOpenboxNotifyStartupAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyStartupAtom() const
|
||||
{ return openbox_notify_startup; }
|
||||
inline const Atom &getOpenboxNotifyWindowAddAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWindowAddAtom() const
|
||||
{ return openbox_notify_window_add; }
|
||||
inline const Atom &getOpenboxNotifyWindowDelAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWindowDelAtom() const
|
||||
{ return openbox_notify_window_del; }
|
||||
inline const Atom &getOpenboxNotifyWindowFocusAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWindowFocusAtom() const
|
||||
{ return openbox_notify_window_focus; }
|
||||
inline const Atom &getOpenboxNotifyCurrentWorkspaceAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyCurrentWorkspaceAtom() const
|
||||
{ return openbox_notify_current_workspace; }
|
||||
inline const Atom &getOpenboxNotifyWorkspaceCountAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWorkspaceCountAtom() const
|
||||
{ return openbox_notify_workspace_count; }
|
||||
inline const Atom &getOpenboxNotifyWindowRaiseAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWindowRaiseAtom() const
|
||||
{ return openbox_notify_window_raise; }
|
||||
inline const Atom &getOpenboxNotifyWindowLowerAtom(void) const
|
||||
inline const Atom &getOpenboxNotifyWindowLowerAtom() const
|
||||
{ return openbox_notify_window_lower; }
|
||||
|
||||
// atoms to change that request changes to the desktop environment during
|
||||
// runtime... these messages can be sent by any client... as the sending
|
||||
// client window id is not included in the ClientMessage event...
|
||||
inline const Atom &getOpenboxChangeWorkspaceAtom(void) const
|
||||
inline const Atom &getOpenboxChangeWorkspaceAtom() const
|
||||
{ return openbox_change_workspace; }
|
||||
inline const Atom &getOpenboxChangeWindowFocusAtom(void) const
|
||||
inline const Atom &getOpenboxChangeWindowFocusAtom() const
|
||||
{ return openbox_change_window_focus; }
|
||||
inline const Atom &getOpenboxCycleWindowFocusAtom(void) const
|
||||
inline const Atom &getOpenboxCycleWindowFocusAtom() const
|
||||
{ return openbox_cycle_window_focus; }
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
|
||||
// root window properties
|
||||
inline const Atom &getNETSupportedAtom(void) const
|
||||
inline const Atom &getNETSupportedAtom() const
|
||||
{ return net_supported; }
|
||||
inline const Atom &getNETClientListAtom(void) const
|
||||
inline const Atom &getNETClientListAtom() const
|
||||
{ return net_client_list; }
|
||||
inline const Atom &getNETClientListStackingAtom(void) const
|
||||
inline const Atom &getNETClientListStackingAtom() const
|
||||
{ return net_client_list_stacking; }
|
||||
inline const Atom &getNETNumberOfDesktopsAtom(void) const
|
||||
inline const Atom &getNETNumberOfDesktopsAtom() const
|
||||
{ return net_number_of_desktops; }
|
||||
inline const Atom &getNETDesktopGeometryAtom(void) const
|
||||
inline const Atom &getNETDesktopGeometryAtom() const
|
||||
{ return net_desktop_geometry; }
|
||||
inline const Atom &getNETDesktopViewportAtom(void) const
|
||||
inline const Atom &getNETDesktopViewportAtom() const
|
||||
{ return net_desktop_viewport; }
|
||||
inline const Atom &getNETCurrentDesktopAtom(void) const
|
||||
inline const Atom &getNETCurrentDesktopAtom() const
|
||||
{ return net_current_desktop; }
|
||||
inline const Atom &getNETDesktopNamesAtom(void) const
|
||||
inline const Atom &getNETDesktopNamesAtom() const
|
||||
{ return net_desktop_names; }
|
||||
inline const Atom &getNETActiveWindowAtom(void) const
|
||||
inline const Atom &getNETActiveWindowAtom() const
|
||||
{ return net_active_window; }
|
||||
inline const Atom &getNETWorkareaAtom(void) const
|
||||
inline const Atom &getNETWorkareaAtom() const
|
||||
{ return net_workarea; }
|
||||
inline const Atom &getNETSupportingWMCheckAtom(void) const
|
||||
inline const Atom &getNETSupportingWMCheckAtom() const
|
||||
{ return net_supporting_wm_check; }
|
||||
inline const Atom &getNETVirtualRootsAtom(void) const
|
||||
inline const Atom &getNETVirtualRootsAtom() const
|
||||
{ return net_virtual_roots; }
|
||||
|
||||
// root window messages
|
||||
inline const Atom &getNETCloseWindowAtom(void) const
|
||||
inline const Atom &getNETCloseWindowAtom() const
|
||||
{ return net_close_window; }
|
||||
inline const Atom &getNETWMMoveResizeAtom(void) const
|
||||
inline const Atom &getNETWMMoveResizeAtom() const
|
||||
{ return net_wm_moveresize; }
|
||||
|
||||
// application window properties
|
||||
inline const Atom &getNETPropertiesAtom(void) const
|
||||
inline const Atom &getNETPropertiesAtom() const
|
||||
{ return net_properties; }
|
||||
inline const Atom &getNETWMNameAtom(void) const
|
||||
inline const Atom &getNETWMNameAtom() const
|
||||
{ return net_wm_name; }
|
||||
inline const Atom &getNETWMDesktopAtom(void) const
|
||||
inline const Atom &getNETWMDesktopAtom() const
|
||||
{ return net_wm_desktop; }
|
||||
inline const Atom &getNETWMWindowTypeAtom(void) const
|
||||
inline const Atom &getNETWMWindowTypeAtom() const
|
||||
{ return net_wm_window_type; }
|
||||
inline const Atom &getNETWMStateAtom(void) const
|
||||
inline const Atom &getNETWMStateAtom() const
|
||||
{ return net_wm_state; }
|
||||
inline const Atom &getNETWMStrutAtom(void) const
|
||||
inline const Atom &getNETWMStrutAtom() const
|
||||
{ return net_wm_strut; }
|
||||
inline const Atom &getNETWMIconGeometryAtom(void) const
|
||||
inline const Atom &getNETWMIconGeometryAtom() const
|
||||
{ return net_wm_icon_geometry; }
|
||||
inline const Atom &getNETWMIconAtom(void) const
|
||||
inline const Atom &getNETWMIconAtom() const
|
||||
{ return net_wm_icon; }
|
||||
inline const Atom &getNETWMPidAtom(void) const
|
||||
inline const Atom &getNETWMPidAtom() const
|
||||
{ return net_wm_pid; }
|
||||
inline const Atom &getNETWMHandledIconsAtom(void) const
|
||||
inline const Atom &getNETWMHandledIconsAtom() const
|
||||
{ return net_wm_handled_icons; }
|
||||
|
||||
// application protocols
|
||||
inline const Atom &getNETWMPingAtom(void) const
|
||||
inline const Atom &getNETWMPingAtom() const
|
||||
{ return net_wm_ping; }
|
||||
|
||||
#endif // NEWWMSPEC
|
||||
|
@ -281,40 +281,40 @@ public:
|
|||
return screenInfoList[s];
|
||||
}
|
||||
|
||||
inline const Bool &hasShapeExtensions(void) const
|
||||
inline const Bool &hasShapeExtensions() const
|
||||
{ return shape.extensions; }
|
||||
inline const Bool &doShutdown(void) const
|
||||
inline const Bool &doShutdown() const
|
||||
{ return _shutdown; }
|
||||
inline const Bool &isStartup(void) const
|
||||
inline const Bool &isStartup() const
|
||||
{ return _startup; }
|
||||
|
||||
inline const Cursor &getSessionCursor(void) const
|
||||
inline const Cursor &getSessionCursor() const
|
||||
{ return cursor.session; }
|
||||
inline const Cursor &getMoveCursor(void) const
|
||||
inline const Cursor &getMoveCursor() const
|
||||
{ return cursor.move; }
|
||||
inline const Cursor &getLowerLeftAngleCursor(void) const
|
||||
inline const Cursor &getLowerLeftAngleCursor() const
|
||||
{ return cursor.ll_angle; }
|
||||
inline const Cursor &getLowerRightAngleCursor(void) const
|
||||
inline const Cursor &getLowerRightAngleCursor() const
|
||||
{ return cursor.lr_angle; }
|
||||
inline const Cursor &getUpperLeftAngleCursor(void) const
|
||||
inline const Cursor &getUpperLeftAngleCursor() const
|
||||
{ return cursor.ul_angle; }
|
||||
inline const Cursor &getUpperRightAngleCursor(void) const
|
||||
inline const Cursor &getUpperRightAngleCursor() const
|
||||
{ return cursor.ur_angle; }
|
||||
|
||||
inline Display *getXDisplay(void) { return display; }
|
||||
inline Display *getXDisplay() { return display; }
|
||||
|
||||
inline const char *getXDisplayName(void) const
|
||||
inline const char *getXDisplayName() const
|
||||
{ return (const char *) display_name; }
|
||||
inline const char *getApplicationName(void) const
|
||||
inline const char *getApplicationName() const
|
||||
{ return (const char *) application_name; }
|
||||
|
||||
inline const int &getNumberOfScreens(void) const
|
||||
inline const unsigned int getNumberOfScreens() const
|
||||
{ return number_of_screens; }
|
||||
inline const int &getShapeEventBase(void) const
|
||||
inline const int &getShapeEventBase() const
|
||||
{ return shape.event_basep; }
|
||||
|
||||
inline void shutdown(void) { _shutdown = True; }
|
||||
inline void run(void) { _startup = _shutdown = False; }
|
||||
inline void shutdown() { _shutdown = True; }
|
||||
inline void run() { _startup = _shutdown = False; }
|
||||
|
||||
const Bool validateWindow(Window);
|
||||
|
||||
|
@ -323,9 +323,9 @@ public:
|
|||
void ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const;
|
||||
|
||||
void grab(void);
|
||||
void ungrab(void);
|
||||
void eventLoop(void);
|
||||
void grab();
|
||||
void ungrab();
|
||||
void eventLoop();
|
||||
void addTimer(BTimer *);
|
||||
void removeTimer(BTimer *);
|
||||
|
||||
|
@ -349,17 +349,17 @@ private:
|
|||
public:
|
||||
ScreenInfo(BaseDisplay &, int);
|
||||
|
||||
inline BaseDisplay &getBaseDisplay(void) { return basedisplay; }
|
||||
inline BaseDisplay &getBaseDisplay() { return basedisplay; }
|
||||
|
||||
inline Visual *getVisual(void) { return visual; }
|
||||
inline const Window &getRootWindow(void) const { return root_window; }
|
||||
inline const Colormap &getColormap(void) const { return colormap; }
|
||||
inline Visual *getVisual() const { return visual; }
|
||||
inline const Window &getRootWindow() const { return root_window; }
|
||||
inline const Colormap &getColormap() const { return colormap; }
|
||||
|
||||
inline const int &getDepth(void) const { return depth; }
|
||||
inline const int &getScreenNumber(void) const { return screen_number; }
|
||||
inline const int &getDepth() const { return depth; }
|
||||
inline const int &getScreenNumber() const { return screen_number; }
|
||||
|
||||
// inline const unsigned int &getWidth(void) const { return width; }
|
||||
// inline const unsigned int &getHeight(void) const { return height; }
|
||||
// inline const unsigned int &getWidth() const { return width; }
|
||||
// inline const unsigned int &getHeight() const { return height; }
|
||||
inline const Size &size() const { return m_size; }
|
||||
};
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ public:
|
|||
|
||||
inline const Window &getDrawable(void) const { return window; }
|
||||
|
||||
inline Visual *getVisual(void) { return screeninfo.getVisual(); }
|
||||
inline Visual *getVisual(void) const { return screeninfo.getVisual(); }
|
||||
|
||||
inline const int &getBitsPerPixel(void) const { return bits_per_pixel; }
|
||||
inline const int &getDepth(void) const { return screen_depth; }
|
||||
|
|
|
@ -196,8 +196,8 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
for (int i = 0; i < getNumberOfScreens(); i++) {
|
||||
BScreen *screen = new BScreen(*this, i, config);
|
||||
for (unsigned int s = 0; s < getNumberOfScreens(); s++) {
|
||||
BScreen *screen = new BScreen(*this, s, config);
|
||||
|
||||
if (! screen->isScreenManaged()) {
|
||||
delete screen;
|
||||
|
|
225
util/bsetroot.cc
225
util/bsetroot.cc
|
@ -1,3 +1,26 @@
|
|||
// bsetroot.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben@orodu.net)
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Brad Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
@ -19,6 +42,7 @@
|
|||
#include "../src/Image.h"
|
||||
#include "bsetroot.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
|
||||
: BaseDisplay(argv[0], dpy_name)
|
||||
|
@ -75,16 +99,17 @@ bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
|
|||
|
||||
if ((mod + sol + grd) != True) {
|
||||
fprintf(stderr,
|
||||
i18n->getMessage(bsetrootSet, bsetrootMustSpecify,
|
||||
"%s: error: must specify one of: -solid, -mod, -gradient\n"),
|
||||
getApplicationName());
|
||||
|
||||
i18n->getMessage(bsetrootSet, bsetrootMustSpecify,
|
||||
"%s: error: must specify one of: "
|
||||
"-solid, -mod, -gradient\n"),
|
||||
getApplicationName());
|
||||
|
||||
usage(2);
|
||||
}
|
||||
|
||||
|
||||
img_ctrl = new BImageControl*[getNumberOfScreens()];
|
||||
for (int i = 0; i < getNumberOfScreens(); i++)
|
||||
img_ctrl[i] = new BImageControl(*this, *getScreenInfo(i), True);
|
||||
for (unsigned int s = 0; s < getNumberOfScreens(); ++s)
|
||||
img_ctrl[s] = new BImageControl(*this, *getScreenInfo(s), true);
|
||||
|
||||
if (sol && fore) solid();
|
||||
else if (mod && mod_x && mod_y && fore && back) modula(mod_x, mod_y);
|
||||
|
@ -98,47 +123,60 @@ bsetroot::~bsetroot(void) {
|
|||
|
||||
XKillClient(getXDisplay(), AllTemporary);
|
||||
|
||||
for (int i = 0; i < getNumberOfScreens(); i++)
|
||||
delete img_ctrl[i];
|
||||
std::for_each(img_ctrl, img_ctrl + getNumberOfScreens(), PointerAssassin());
|
||||
|
||||
delete [] img_ctrl;
|
||||
}
|
||||
|
||||
|
||||
// adapted from wmsetbg
|
||||
void bsetroot::setPixmapProperty(int screen, Pixmap pixmap) {
|
||||
static Atom rootpmap_id = None;
|
||||
static Atom rootpmap_id = None, esetroot_id = None;
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long length, after;
|
||||
unsigned char *data;
|
||||
int mode;
|
||||
|
||||
if (rootpmap_id == None)
|
||||
rootpmap_id = XInternAtom(getXDisplay(), "_XROOTPMAP_ID", False);
|
||||
int mode = PropModeAppend;
|
||||
const ScreenInfo *screen_info = getScreenInfo(screen);
|
||||
|
||||
if (rootpmap_id == None) {
|
||||
rootpmap_id = XInternAtom(getXDisplay(), "_XROOTPMAP_ID", True);
|
||||
esetroot_id = XInternAtom(getXDisplay(), "_ESETROOT_PMAP_ID", True);
|
||||
}
|
||||
|
||||
XGrabServer(getXDisplay());
|
||||
|
||||
|
||||
/* Clear out the old pixmap */
|
||||
XGetWindowProperty(getXDisplay(), getScreenInfo(screen)->getRootWindow(),
|
||||
rootpmap_id, 0L, 1L, False, AnyPropertyType,
|
||||
&type, &format, &length, &after, &data);
|
||||
|
||||
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
rootpmap_id, 0L, 1L, False, AnyPropertyType,
|
||||
&type, &format, &length, &after, &data);
|
||||
|
||||
if ((type == XA_PIXMAP) && (format == 32) && (length == 1)) {
|
||||
XKillClient(getXDisplay(), *((Pixmap *)data));
|
||||
XSync(getXDisplay(), False);
|
||||
mode = PropModeReplace;
|
||||
} else {
|
||||
mode = PropModeAppend;
|
||||
unsigned char* data_esetroot = 0;
|
||||
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
esetroot_id, 0L, 1L, False, AnyPropertyType,
|
||||
&type, &format, &length, &after, &data);
|
||||
if (data && data_esetroot && *((Pixmap *) data)) {
|
||||
XKillClient(getXDisplay(), *((Pixmap *) data));
|
||||
XSync(getXDisplay(), False);
|
||||
mode = PropModeReplace;
|
||||
}
|
||||
}
|
||||
|
||||
if (pixmap) {
|
||||
XChangeProperty(getXDisplay(), getScreenInfo(screen)->getRootWindow(),
|
||||
rootpmap_id, XA_PIXMAP, 32, mode,
|
||||
(unsigned char *) &pixmap, 1);
|
||||
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
rootpmap_id, XA_PIXMAP, 32, mode,
|
||||
(unsigned char *) &pixmap, 1);
|
||||
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
esetroot_id, XA_PIXMAP, 32, mode,
|
||||
(unsigned char *) &pixmap, 1);
|
||||
} else {
|
||||
XDeleteProperty(getXDisplay(), getScreenInfo(screen)->getRootWindow(),
|
||||
rootpmap_id);
|
||||
XDeleteProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
rootpmap_id);
|
||||
XDeleteProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||
esetroot_id);
|
||||
}
|
||||
|
||||
|
||||
XUngrabServer(getXDisplay());
|
||||
XFlush(getXDisplay());
|
||||
}
|
||||
|
@ -146,15 +184,15 @@ void bsetroot::setPixmapProperty(int screen, Pixmap pixmap) {
|
|||
|
||||
// adapted from wmsetbg
|
||||
Pixmap bsetroot::duplicatePixmap(int screen, Pixmap pixmap,
|
||||
int width, int height) {
|
||||
int width, int height) {
|
||||
XSync(getXDisplay(), False);
|
||||
|
||||
Pixmap copyP = XCreatePixmap(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
width, height,
|
||||
DefaultDepth(getXDisplay(), screen));
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
width, height,
|
||||
DefaultDepth(getXDisplay(), screen));
|
||||
XCopyArea(getXDisplay(), pixmap, copyP, DefaultGC(getXDisplay(), screen),
|
||||
0, 0, width, height, 0, 0);
|
||||
0, 0, width, height, 0, 0);
|
||||
XSync(getXDisplay(), False);
|
||||
|
||||
return copyP;
|
||||
|
@ -162,23 +200,23 @@ Pixmap bsetroot::duplicatePixmap(int screen, Pixmap pixmap,
|
|||
|
||||
|
||||
void bsetroot::solid(void) {
|
||||
for (int screen = 0; screen < getNumberOfScreens(); screen++) {
|
||||
for (unsigned int screen = 0; screen < getNumberOfScreens(); screen++) {
|
||||
BColor c;
|
||||
|
||||
img_ctrl[screen]->parseColor(&c, fore);
|
||||
if (! c.isAllocated()) c.setPixel(BlackPixel(getXDisplay(), screen));
|
||||
|
||||
XSetWindowBackground(getXDisplay(), getScreenInfo(screen)->getRootWindow(),
|
||||
const ScreenInfo *screen_info = getScreenInfo(screen);
|
||||
|
||||
XSetWindowBackground(getXDisplay(), screen_info->getRootWindow(),
|
||||
c.getPixel());
|
||||
XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow());
|
||||
XClearWindow(getXDisplay(), screen_info->getRootWindow());
|
||||
|
||||
Pixmap pixmap = XCreatePixmap(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
8, 8, DefaultDepth(getXDisplay(), screen));
|
||||
XSetForeground(getXDisplay(), DefaultGC(getXDisplay(), screen),
|
||||
c.getPixel());
|
||||
screen_info->getRootWindow(),
|
||||
8, 8, DefaultDepth(getXDisplay(), screen));
|
||||
XFillRectangle(getXDisplay(), pixmap, DefaultGC(getXDisplay(), screen),
|
||||
0, 0, 8, 8);
|
||||
0, 0, 8, 8);
|
||||
|
||||
setPixmapProperty(screen, duplicatePixmap(screen, pixmap, 8, 8));
|
||||
|
||||
|
@ -191,7 +229,7 @@ void bsetroot::modula(int x, int y) {
|
|||
char data[32];
|
||||
long pattern;
|
||||
|
||||
int screen, i;
|
||||
unsigned int screen, i;
|
||||
|
||||
for (pattern = 0, screen = 0; screen < getNumberOfScreens(); screen++) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
@ -213,54 +251,57 @@ void bsetroot::modula(int x, int y) {
|
|||
BColor f, b;
|
||||
GC gc;
|
||||
Pixmap bitmap;
|
||||
XGCValues gcv;
|
||||
|
||||
const ScreenInfo *screen_info = getScreenInfo(screen);
|
||||
|
||||
bitmap =
|
||||
XCreateBitmapFromData(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(), data,
|
||||
screen_info->getRootWindow(), data,
|
||||
16, 16);
|
||||
|
||||
|
||||
img_ctrl[screen]->parseColor(&f, fore);
|
||||
img_ctrl[screen]->parseColor(&b, back);
|
||||
|
||||
if (! f.isAllocated()) f.setPixel(WhitePixel(getXDisplay(), screen));
|
||||
if (! b.isAllocated()) b.setPixel(BlackPixel(getXDisplay(), screen));
|
||||
|
||||
XGCValues gcv;
|
||||
gcv.foreground = f.getPixel();
|
||||
gcv.background = b.getPixel();
|
||||
|
||||
gc = XCreateGC(getXDisplay(), getScreenInfo(screen)->getRootWindow(),
|
||||
gc = XCreateGC(getXDisplay(), screen_info->getRootWindow(),
|
||||
GCForeground | GCBackground, &gcv);
|
||||
|
||||
Pixmap pixmap = XCreatePixmap(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
16, 16, getScreenInfo(screen)->getDepth());
|
||||
screen_info->getRootWindow(),
|
||||
16, 16, screen_info->getDepth());
|
||||
|
||||
XCopyPlane(getXDisplay(), bitmap, pixmap, gc,
|
||||
0, 0, 16, 16, 0, 0, 1l);
|
||||
XSetWindowBackgroundPixmap(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
screen_info->getRootWindow(),
|
||||
pixmap);
|
||||
XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow());
|
||||
XClearWindow(getXDisplay(), screen_info->getRootWindow());
|
||||
|
||||
setPixmapProperty(screen,
|
||||
duplicatePixmap(screen, pixmap, 16, 16));
|
||||
duplicatePixmap(screen, pixmap, 16, 16));
|
||||
|
||||
XFreeGC(getXDisplay(), gc);
|
||||
XFreePixmap(getXDisplay(), bitmap);
|
||||
|
||||
if (! (getScreenInfo(screen)->getVisual()->c_class & 1))
|
||||
if (! (screen_info->getVisual()->c_class & 1))
|
||||
XFreePixmap(getXDisplay(), pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void bsetroot::gradient(void) {
|
||||
for (int screen = 0; screen < getNumberOfScreens(); screen++) {
|
||||
for (unsigned int screen = 0; screen < getNumberOfScreens(); screen++) {
|
||||
BTexture texture;
|
||||
img_ctrl[screen]->parseTexture(&texture, grad);
|
||||
img_ctrl[screen]->parseColor(texture.getColor(), fore);
|
||||
img_ctrl[screen]->parseColor(texture.getColorTo(), back);
|
||||
const ScreenInfo *screen_info = getScreenInfo(screen);
|
||||
|
||||
if (! texture.getColor()->isAllocated())
|
||||
texture.getColor()->setPixel(WhitePixel(getXDisplay(), screen));
|
||||
|
@ -268,21 +309,21 @@ void bsetroot::gradient(void) {
|
|||
texture.getColorTo()->setPixel(BlackPixel(getXDisplay(), screen));
|
||||
|
||||
Pixmap pixmap =
|
||||
img_ctrl[screen]->renderImage(getScreenInfo(screen)->size().w(),
|
||||
getScreenInfo(screen)->size().h(),
|
||||
img_ctrl[screen]->renderImage(screen_info->size().w(),
|
||||
screen_info->size().h(),
|
||||
&texture);
|
||||
|
||||
XSetWindowBackgroundPixmap(getXDisplay(),
|
||||
getScreenInfo(screen)->getRootWindow(),
|
||||
screen_info->getRootWindow(),
|
||||
pixmap);
|
||||
XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow());
|
||||
XClearWindow(getXDisplay(), screen_info->getRootWindow());
|
||||
|
||||
setPixmapProperty(screen,
|
||||
duplicatePixmap(screen, pixmap,
|
||||
getScreenInfo(screen)->size().w(),
|
||||
getScreenInfo(screen)->size().h()));
|
||||
|
||||
if (! (getScreenInfo(screen)->getVisual()->c_class & 1)) {
|
||||
duplicatePixmap(screen, pixmap,
|
||||
screen_info->size().w(),
|
||||
screen_info->size().h()));
|
||||
|
||||
if (! (screen_info->getVisual()->c_class & 1)) {
|
||||
img_ctrl[screen]->removeImage(pixmap);
|
||||
}
|
||||
}
|
||||
|
@ -290,47 +331,47 @@ void bsetroot::gradient(void) {
|
|||
|
||||
|
||||
void bsetroot::usage(int exit_code) {
|
||||
fprintf(stderr,
|
||||
i18n->
|
||||
getMessage(bsetrootSet, bsetrootUsage,
|
||||
"%s 2.0 : (c) 1997-1999 Brad Hughes\n\n"
|
||||
" -display <string> display connection\n"
|
||||
" -mod <x> <y> modula pattern\n"
|
||||
" -foreground, -fg <color> modula foreground color\n"
|
||||
" -background, -bg <color> modula background color\n\n"
|
||||
" -gradient <texture> gradient texture\n"
|
||||
" -from <color> gradient start color\n"
|
||||
" -to <color> gradient end color\n\n"
|
||||
" -solid <color> solid color\n\n"
|
||||
" -help print this help text and exit\n"),
|
||||
getApplicationName());
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
fprintf(stderr,
|
||||
i18n->getMessage(bsetrootSet, bsetrootUsage,
|
||||
"%s 2.0\n\n"
|
||||
"Copyright (c) 1997-2000, 2002 Bradley T Hughes\n"
|
||||
"Copyright (c) 2001-2002 Sean 'Shaleh' Perry\n\n"
|
||||
" -display <string> display connection\n"
|
||||
" -mod <x> <y> modula pattern\n"
|
||||
" -foreground, -fg <color> modula foreground color\n"
|
||||
" -background, -bg <color> modula background color\n\n"
|
||||
" -gradient <texture> gradient texture\n"
|
||||
" -from <color> gradient start color\n"
|
||||
" -to <color> gradient end color\n\n"
|
||||
" -solid <color> solid color\n\n"
|
||||
" -help print this help text and exit\n"),
|
||||
getApplicationName());
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char *display_name = (char *) 0;
|
||||
|
||||
NLSInit("openbox.cat");
|
||||
|
||||
|
||||
i18n->openCatalog("blackbox.cat");
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (! strcmp(argv[i], "-display")) {
|
||||
// check for -display option
|
||||
|
||||
|
||||
if ((++i) >= argc) {
|
||||
fprintf(stderr,
|
||||
i18n->getMessage(mainSet, mainDISPLAYRequiresArg,
|
||||
"error: '-display' requires an argument\n"));
|
||||
|
||||
fprintf(stderr, i18n->getMessage(mainSet, mainDISPLAYRequiresArg,
|
||||
"error: '-display' requires an argument\n"));
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
|
||||
display_name = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bsetroot app(argc, argv, display_name);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,32 +4,31 @@
|
|||
#include "../src/BaseDisplay.h"
|
||||
#include "../src/Image.h"
|
||||
|
||||
|
||||
class bsetroot : public BaseDisplay {
|
||||
private:
|
||||
BImageControl **img_ctrl;
|
||||
|
||||
char *fore, *back, *grad;
|
||||
|
||||
// no copying!!
|
||||
bsetroot(const bsetroot &);
|
||||
bsetroot& operator=(const bsetroot&);
|
||||
|
||||
protected:
|
||||
inline virtual void process_event(XEvent *) { }
|
||||
inline virtual void process_event(XEvent * /*unused*/) { }
|
||||
|
||||
|
||||
public:
|
||||
bsetroot(int, char **, char * = 0);
|
||||
bsetroot(int argc, char **argv, char *dpy_name = 0);
|
||||
~bsetroot(void);
|
||||
|
||||
inline virtual Bool handleSignal(int) { return False; }
|
||||
inline virtual Bool handleSignal(int /*unused*/) { return False; }
|
||||
|
||||
void setPixmapProperty(int, Pixmap);
|
||||
Pixmap duplicatePixmap(int, Pixmap, int, int);
|
||||
void setPixmapProperty(int screen, Pixmap pixmap);
|
||||
Pixmap duplicatePixmap(int screen, Pixmap pixmap, int width, int height);
|
||||
|
||||
void gradient(void);
|
||||
void modula(int, int);
|
||||
void modula(int x, int y);
|
||||
void solid(void);
|
||||
void usage(int = 0);
|
||||
void usage(int exit_code = 0);
|
||||
};
|
||||
|
||||
|
||||
#endif // __bsetroot2_hh
|
||||
|
|
Loading…
Reference in a new issue