all repos — fluxbox @ 28b5c604490094e187494dcc566bd3d7a05a2c25

custom fork of the fluxbox windowmanager

Indenting from tabs to emacs 4-space
rathnor rathnor
commit

28b5c604490094e187494dcc566bd3d7a05a2c25

parent

b9134162f9633784d9097df18769a699a62650fe

92 files changed, 17774 insertions(+), 17774 deletions(-)

jump to
M src/AtomHandler.hhsrc/AtomHandler.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: AtomHandler.hh,v 1.4 2002/11/30 20:59:54 fluxgen Exp $ +// $Id: AtomHandler.hh,v 1.5 2002/12/01 13:41:54 rathnor Exp $ #ifndef ATOMHANDLER_HH #define ATOMHANDLER_HH

@@ -31,30 +31,30 @@ class BScreen;

class AtomHandler { public: - virtual ~AtomHandler() { } + virtual ~AtomHandler() { } - virtual void initForScreen(const BScreen &screen) = 0; - virtual void setupWindow(FluxboxWindow &win) = 0; + virtual void initForScreen(const BScreen &screen) = 0; + virtual void setupWindow(FluxboxWindow &win) = 0; - virtual void updateClientList(const BScreen &screen) = 0; - virtual void updateWorkspaceNames(const BScreen &screen) = 0; - virtual void updateCurrentWorkspace(const BScreen &screen) = 0; - virtual void updateWorkspaceCount(const BScreen &screen) = 0; + virtual void updateClientList(const BScreen &screen) = 0; + virtual void updateWorkspaceNames(const BScreen &screen) = 0; + virtual void updateCurrentWorkspace(const BScreen &screen) = 0; + virtual void updateWorkspaceCount(const BScreen &screen) = 0; - virtual void updateWorkspace(FluxboxWindow &win) = 0; - virtual void updateState(FluxboxWindow &win) = 0; - virtual void updateHints(FluxboxWindow &win) = 0; + virtual void updateWorkspace(FluxboxWindow &win) = 0; + virtual void updateState(FluxboxWindow &win) = 0; + virtual void updateHints(FluxboxWindow &win) = 0; - virtual bool checkClientMessage(const XClientMessageEvent &ce, - BScreen * const screen, FluxboxWindow * const win) = 0; + virtual bool checkClientMessage(const XClientMessageEvent &ce, + BScreen * const screen, FluxboxWindow * const win) = 0; - /// should this object be updated or not? - bool update() const { return m_update; } + /// should this object be updated or not? + bool update() const { return m_update; } protected: - void disableUpdate() { m_update = false; } - void enableUpdate() { m_update = true; } + void disableUpdate() { m_update = false; } + void enableUpdate() { m_update = true; } private: - bool m_update; ///< do we get update or not + bool m_update; ///< do we get update or not }; #endif // ATOMHANDLER_HH
M src/BaseDisplay.ccsrc/BaseDisplay.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: BaseDisplay.cc,v 1.23 2002/11/26 16:05:34 fluxgen Exp $ +// $Id: BaseDisplay.cc,v 1.24 2002/12/01 13:41:54 rathnor Exp $

@@ -93,167 +93,167 @@ static Window last_bad_window = None;

#ifdef DEBUG static int handleXErrors(Display *d, XErrorEvent *e) { - char errtxt[128]; + char errtxt[128]; - XGetErrorText(d, e->error_code, errtxt, 128); - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXError, - "%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"), - BaseDisplay::instance()->getApplicationName(), errtxt, e->error_code, - e->request_code, e->minor_code, e->resourceid); + XGetErrorText(d, e->error_code, errtxt, 128); + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXError, + "%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"), + BaseDisplay::instance()->getApplicationName(), errtxt, e->error_code, + e->request_code, e->minor_code, e->resourceid); #else // !DEBUG -static int handleXErrors(Display *, XErrorEvent *e) { + static int handleXErrors(Display *, XErrorEvent *e) { #endif // DEBUG if (e->error_code == BadWindow) - last_bad_window = e->resourceid; + last_bad_window = e->resourceid; if (internal_error) - abort(); + abort(); return(False); -} + } // convenience functions #ifndef __EMX__ -void bexec(const char *command, char *displaystring) { + void bexec(const char *command, char *displaystring) { if (! fork()) { - setsid(); - putenv(displaystring); - execl("/bin/sh", "/bin/sh", "-c", command, 0); - exit(0); + setsid(); + putenv(displaystring); + execl("/bin/sh", "/bin/sh", "-c", command, 0); + exit(0); } -} + } #endif // !__EMX__ -BaseDisplay *BaseDisplay::s_singleton = 0; + BaseDisplay *BaseDisplay::s_singleton = 0; -BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name), -m_startup(true), m_shutdown(false), -m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), -m_server_grabs(0) -{ - if (s_singleton != 0) + BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name), + m_startup(true), m_shutdown(false), + m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), + m_server_grabs(0) + { + if (s_singleton != 0) throw string("Can't create more than one instance of BaseDisplay!"); - s_singleton = this; + s_singleton = this; - last_bad_window = None; - I18n *i18n = I18n::instance(); + last_bad_window = None; + I18n *i18n = I18n::instance(); - if (display() == 0) { + if (display() == 0) { fprintf(stderr, i18n-> getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXConnectFail, - "BaseDisplay::BaseDisplay: connection to X server failed.\n")); + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXConnectFail, + "BaseDisplay::BaseDisplay: connection to X server failed.\n")); throw static_cast<int>(2); //throw error 2 - } else if (fcntl(ConnectionNumber(display()), F_SETFD, 1) == -1) { + } else if (fcntl(ConnectionNumber(display()), F_SETFD, 1) == -1) { fprintf(stderr, i18n-> - getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayCloseOnExecFail, - "BaseDisplay::BaseDisplay: couldn't mark display connection " - "as close-on-exec\n")); + getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayCloseOnExecFail, + "BaseDisplay::BaseDisplay: couldn't mark display connection " + "as close-on-exec\n")); throw static_cast<int>(2); //throw error 2 - } + } - number_of_screens = ScreenCount(display()); + number_of_screens = ScreenCount(display()); #ifdef SHAPE - shape.extensions = XShapeQueryExtension(display(), &shape.event_basep, - &shape.error_basep); + shape.extensions = XShapeQueryExtension(display(), &shape.event_basep, + &shape.error_basep); #else // !SHAPE - shape.extensions = False; + shape.extensions = False; #endif // SHAPE - XSetErrorHandler((XErrorHandler) handleXErrors); + XSetErrorHandler((XErrorHandler) handleXErrors); - for (int i = 0; i < number_of_screens; i++) { + for (int i = 0; i < number_of_screens; i++) { ScreenInfo *screeninfo = new ScreenInfo(i); screenInfoList.push_back(screeninfo); - } -} + } + } -BaseDisplay::~BaseDisplay() { + BaseDisplay::~BaseDisplay() { ScreenInfoList::iterator it = screenInfoList.begin(); ScreenInfoList::iterator it_end = screenInfoList.end(); for (; it != it_end; ++it) { - delete (*it); + delete (*it); } s_singleton = 0; -} + } -BaseDisplay *BaseDisplay::instance() { + BaseDisplay *BaseDisplay::instance() { if (s_singleton == 0) - throw string("BaseDisplay not created!"); + throw string("BaseDisplay not created!"); return s_singleton; -} + } -void BaseDisplay::eventLoop() { + void BaseDisplay::eventLoop() { run(); while ((! m_shutdown) && (! internal_error)) { - if (XPending(display())) { - XEvent e; - XNextEvent(display(), &e); + if (XPending(display())) { + XEvent e; + XNextEvent(display(), &e); - if (last_bad_window != None && e.xany.window == last_bad_window) { + if (last_bad_window != None && e.xany.window == last_bad_window) { #ifdef DEBUG - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayBadWindowRemove, - "BaseDisplay::eventLoop(): removing bad window " - "from event queue\n")); + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayBadWindowRemove, + "BaseDisplay::eventLoop(): removing bad window " + "from event queue\n")); #endif // DEBUG - } else { - last_bad_window = None; - handleEvent(&e); - } - } else { - BTimer::updateTimers(ConnectionNumber(display())); //handle all timers - } + } else { + last_bad_window = None; + handleEvent(&e); + } + } else { + BTimer::updateTimers(ConnectionNumber(display())); //handle all timers + } } -} + } -bool BaseDisplay::validateWindow(Window window) { + bool BaseDisplay::validateWindow(Window window) { XEvent event; if (XCheckTypedWindowEvent(display(), window, DestroyNotify, &event)) { - XPutBackEvent(display(), &event); - return false; + XPutBackEvent(display(), &event); + return false; } return true; -} + } -void BaseDisplay::grab() { + void BaseDisplay::grab() { if (! m_server_grabs++) - XGrabServer(display()); -} + XGrabServer(display()); + } -void BaseDisplay::ungrab() { + void BaseDisplay::ungrab() { if (! --m_server_grabs) - XUngrabServer(display()); + XUngrabServer(display()); if (m_server_grabs < 0) - m_server_grabs = 0; -} + m_server_grabs = 0; + } -ScreenInfo::ScreenInfo(int num) { + ScreenInfo::ScreenInfo(int num) { basedisplay = BaseDisplay::instance(); Display * const disp = basedisplay->getXDisplay(); screen_number = num;

@@ -262,9 +262,9 @@ root_window = RootWindow(disp, screen_number);

depth = DefaultDepth(disp, screen_number); width = - WidthOfScreen(ScreenOfDisplay(disp, screen_number)); + WidthOfScreen(ScreenOfDisplay(disp, screen_number)); height = - HeightOfScreen(ScreenOfDisplay(disp, screen_number)); + HeightOfScreen(ScreenOfDisplay(disp, screen_number)); // search for a TrueColor Visual... if we can't find one... we will use the // default visual for the screen

@@ -277,50 +277,50 @@

visual = (Visual *) 0; if ((vinfo_return = XGetVisualInfo(disp, - VisualScreenMask | VisualClassMask, - &vinfo_template, &vinfo_nitems)) && - vinfo_nitems > 0) { + VisualScreenMask | VisualClassMask, + &vinfo_template, &vinfo_nitems)) && + vinfo_nitems > 0) { - for (int i = 0; i < vinfo_nitems; i++) { - if (depth < (vinfo_return + i)->depth) { - depth = (vinfo_return + i)->depth; - visual = (vinfo_return + i)->visual; - } - } + for (int i = 0; i < vinfo_nitems; i++) { + if (depth < (vinfo_return + i)->depth) { + depth = (vinfo_return + i)->depth; + visual = (vinfo_return + i)->visual; + } + } - XFree(vinfo_return); + XFree(vinfo_return); } if (visual) { - m_colormap = XCreateColormap(disp, root_window, - visual, AllocNone); + m_colormap = XCreateColormap(disp, root_window, + visual, AllocNone); } else { - visual = DefaultVisual(disp, screen_number); - m_colormap = DefaultColormap(disp, screen_number); + visual = DefaultVisual(disp, screen_number); + m_colormap = DefaultColormap(disp, screen_number); } #ifdef XINERAMA // check if we have Xinerama extension enabled if (XineramaIsActive(disp)) { - m_hasXinerama = true; - xineramaLastHead = 0; - xineramaInfos = - XineramaQueryScreens(disp, &xineramaNumHeads); + m_hasXinerama = true; + xineramaLastHead = 0; + xineramaInfos = + XineramaQueryScreens(disp, &xineramaNumHeads); } else { - m_hasXinerama = false; - xineramaInfos = 0; // make sure we don't point anywhere we shouldn't + m_hasXinerama = false; + xineramaInfos = 0; // make sure we don't point anywhere we shouldn't } #endif // XINERAMA -} + } -ScreenInfo::~ScreenInfo() { + ScreenInfo::~ScreenInfo() { #ifdef XINERAMA if (m_hasXinerama) { // only free if we first had it - XFree(xineramaInfos); - xineramaInfos = 0; + XFree(xineramaInfos); + xineramaInfos = 0; } #endif // XINERAMA -} + } #ifdef XINERAMA

@@ -329,130 +329,130 @@ // Searches for the head at the coordinates

// x,y. If it fails or Xinerama isn't // activated it'll return head nr 0 //----------------------------------------- -unsigned int ScreenInfo::getHead(int x, int y) const { + unsigned int ScreenInfo::getHead(int x, int y) const { // is Xinerama extensions enabled? if (hasXinerama()) { - // check if last head is still active + // check if last head is still active /* if ((xineramaInfos[xineramaLastHead].x_org <= x) && - ((xineramaInfos[xineramaLastHead].x_org + - xineramaInfos[xineramaLastHead].width) > x) && - (xineramaInfos[xineramaLastHead].y_org <= y) && - ((xineramaInfos[xineramaLastHead].y_org + - xineramaInfos[xineramaLastHead].height) > y)) { - return xineramaLastHead; + ((xineramaInfos[xineramaLastHead].x_org + + xineramaInfos[xineramaLastHead].width) > x) && + (xineramaInfos[xineramaLastHead].y_org <= y) && + ((xineramaInfos[xineramaLastHead].y_org + + xineramaInfos[xineramaLastHead].height) > y)) { + return xineramaLastHead; } else { */ - // go trough all the heads, and search - for (int i = 0; (signed) i < xineramaNumHeads; i++) { - if (xineramaInfos[i].x_org <= x && - (xineramaInfos[i].x_org + xineramaInfos[i].width) > x && - xineramaInfos[i].y_org <= y && - (xineramaInfos[i].y_org + xineramaInfos[i].height) > y) - // return (xineramaLastHead = i); - return i; - } - // } + // go trough all the heads, and search + for (int i = 0; (signed) i < xineramaNumHeads; i++) { + if (xineramaInfos[i].x_org <= x && + (xineramaInfos[i].x_org + xineramaInfos[i].width) > x && + xineramaInfos[i].y_org <= y && + (xineramaInfos[i].y_org + xineramaInfos[i].height) > y) + // return (xineramaLastHead = i); + return i; + } + // } } return 0; -} + } //------------- getCurrHead -------------- // Searches for the head that the pointer // currently is on, if it isn't found // the first one is returned //---------------------------------------- -unsigned int ScreenInfo::getCurrHead(void) const { + unsigned int ScreenInfo::getCurrHead(void) const { // is Xinerama extensions enabled? if (hasXinerama()) { - int x, y, wX, wY; - unsigned int mask; - Window rRoot, rChild; - // get pointer cordinates - if ( (XQueryPointer(basedisplay->getXDisplay(), root_window, + int x, y, wX, wY; + unsigned int mask; + Window rRoot, rChild; + // get pointer cordinates + if ( (XQueryPointer(basedisplay->getXDisplay(), root_window, &rRoot, &rChild, &x, &y, &wX, &wY, &mask)) != 0 ) { - return getHead(x, y); - } + return getHead(x, y); + } } return 0; -} + } //----------- getHeadWidth ------------ // Returns the width of head //------------------------------------- -unsigned int ScreenInfo::getHeadWidth(unsigned int head) const { + unsigned int ScreenInfo::getHeadWidth(unsigned int head) const { if (hasXinerama()) { - if ((signed) head >= xineramaNumHeads) { - #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Head: " << head << " doesn't exist!" << endl; - #endif // DEBUG - return xineramaInfos[xineramaNumHeads - 1].width; - } else - return xineramaInfos[head].width; + if ((signed) head >= xineramaNumHeads) { +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Head: " << head << " doesn't exist!" << endl; +#endif // DEBUG + return xineramaInfos[xineramaNumHeads - 1].width; + } else + return xineramaInfos[head].width; } return getWidth(); -} + } //----------- getHeadHeight ------------ // Returns the heigt of head //-------------------------------------- -unsigned int ScreenInfo::getHeadHeight(unsigned int head) const { + unsigned int ScreenInfo::getHeadHeight(unsigned int head) const { if (hasXinerama()) { - if ((signed) head >= xineramaNumHeads) { - #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Head: " << head << " doesn't exist!" << endl; - #endif // DEBUG - return xineramaInfos[xineramaNumHeads - 1].height; - } else - return xineramaInfos[head].height; + if ((signed) head >= xineramaNumHeads) { +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Head: " << head << " doesn't exist!" << endl; +#endif // DEBUG + return xineramaInfos[xineramaNumHeads - 1].height; + } else + return xineramaInfos[head].height; } return getHeight(); -} + } //----------- getHeadX ----------------- // Returns the X start of head nr head //-------------------------------------- -int ScreenInfo::getHeadX(unsigned int head) const { + int ScreenInfo::getHeadX(unsigned int head) const { if (hasXinerama()) { - if ((signed) head >= xineramaNumHeads) { - #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Head: " << head << " doesn't exist!" << endl; - #endif // DEBUG - return xineramaInfos[head = xineramaNumHeads - 1].x_org; - } else - return xineramaInfos[head].x_org; + if ((signed) head >= xineramaNumHeads) { +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Head: " << head << " doesn't exist!" << endl; +#endif // DEBUG + return xineramaInfos[head = xineramaNumHeads - 1].x_org; + } else + return xineramaInfos[head].x_org; } return 0; -} + } //----------- getHeadY ----------------- // Returns the Y start of head //-------------------------------------- -int ScreenInfo::getHeadY(unsigned int head) const { + int ScreenInfo::getHeadY(unsigned int head) const { if (hasXinerama()) { - if ((signed) head >= xineramaNumHeads) { - #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Head: " << head << " doesn't exist!" << endl; - #endif // DEBUG - return xineramaInfos[xineramaNumHeads - 1].y_org; - } else - return xineramaInfos[head].y_org; + if ((signed) head >= xineramaNumHeads) { +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Head: " << head << " doesn't exist!" << endl; +#endif // DEBUG + return xineramaInfos[xineramaNumHeads - 1].y_org; + } else + return xineramaInfos[head].y_org; } return 0; -} + } #endif // XINERAMA
M src/BaseDisplay.hhsrc/BaseDisplay.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: BaseDisplay.hh,v 1.33 2002/11/27 21:44:45 fluxgen Exp $ +// $Id: BaseDisplay.hh,v 1.34 2002/12/01 13:41:54 rathnor Exp $ #ifndef BASEDISPLAY_HH #define BASEDISPLAY_HH

@@ -56,119 +56,119 @@ */

class BaseDisplay:public FbTk::App, private FbTk::NotCopyable { public: - BaseDisplay(const char *app_name, const char *display_name = 0); - virtual ~BaseDisplay(); - static BaseDisplay *instance(); + BaseDisplay(const char *app_name, const char *display_name = 0); + virtual ~BaseDisplay(); + static BaseDisplay *instance(); - /** - obsolete by FluxboxWindow - @see FluxboxWindow - */ - enum Attrib { - ATTRIB_SHADED = 0x01, - ATTRIB_MAXHORIZ = 0x02, - ATTRIB_MAXVERT = 0x04, - ATTRIB_OMNIPRESENT = 0x08, - ATTRIB_WORKSPACE = 0x10, - ATTRIB_STACK = 0x20, - ATTRIB_DECORATION = 0x40 - }; + /** + obsolete by FluxboxWindow + @see FluxboxWindow + */ + enum Attrib { + ATTRIB_SHADED = 0x01, + ATTRIB_MAXHORIZ = 0x02, + ATTRIB_MAXVERT = 0x04, + ATTRIB_OMNIPRESENT = 0x08, + ATTRIB_WORKSPACE = 0x10, + ATTRIB_STACK = 0x20, + ATTRIB_DECORATION = 0x40 + }; - typedef struct _blackbox_hints { - unsigned long flags, attrib, workspace, stack; - int decoration; - } BlackboxHints; + typedef struct _blackbox_hints { + unsigned long flags, attrib, workspace, stack; + int decoration; + } BlackboxHints; - typedef struct _blackbox_attributes { - unsigned long flags, attrib, workspace, stack; - int premax_x, premax_y; - unsigned int premax_w, premax_h; - } BlackboxAttributes; + typedef struct _blackbox_attributes { + unsigned long flags, attrib, workspace, stack; + int premax_x, premax_y; + unsigned int premax_w, premax_h; + } BlackboxAttributes; - inline ScreenInfo *getScreenInfo(int s) { return screenInfoList[s]; } + inline ScreenInfo *getScreenInfo(int s) { return screenInfoList[s]; } - inline bool hasShapeExtensions() const { return shape.extensions; } - inline bool doShutdown() const { return m_shutdown; } - inline bool isStartup() const { return m_startup; } + inline bool hasShapeExtensions() const { return shape.extensions; } + inline bool doShutdown() const { return m_shutdown; } + inline bool isStartup() const { return m_startup; } - static Display *getXDisplay() { return App::instance()->display(); } + static Display *getXDisplay() { return App::instance()->display(); } - inline const char *getXDisplayName() const { return m_display_name; } - inline const char *getApplicationName() const { return m_app_name; } + inline const char *getXDisplayName() const { return m_display_name; } + inline const char *getApplicationName() const { return m_app_name; } - inline int getNumberOfScreens() const { return number_of_screens; } - inline int getShapeEventBase() const { return shape.event_basep; } + inline int getNumberOfScreens() const { return number_of_screens; } + inline int getShapeEventBase() const { return shape.event_basep; } - inline void shutdown() { m_shutdown = true; } - inline void run() { m_startup = m_shutdown = false; } + inline void shutdown() { m_shutdown = true; } + inline void run() { m_startup = m_shutdown = false; } - bool validateWindow(Window); + bool validateWindow(Window); - void grab(); - void ungrab(); - void eventLoop(); - virtual void handleEvent(XEvent * const ev) { } + void grab(); + void ungrab(); + void eventLoop(); + virtual void handleEvent(XEvent * const ev) { } private: - struct shape { - Bool extensions; - int event_basep, error_basep; - } shape; + struct shape { + Bool extensions; + int event_basep, error_basep; + } shape; - bool m_startup, m_shutdown; + bool m_startup, m_shutdown; typedef std::vector<ScreenInfo *> ScreenInfoList; ScreenInfoList screenInfoList; - const char *m_display_name, *m_app_name; - int number_of_screens, m_server_grabs; + const char *m_display_name, *m_app_name; + int number_of_screens, m_server_grabs; - static BaseDisplay *s_singleton; + static BaseDisplay *s_singleton; }; class ScreenInfo { public: - explicit ScreenInfo(int screen_num); - ~ScreenInfo(); + explicit ScreenInfo(int screen_num); + ~ScreenInfo(); - inline BaseDisplay *getBaseDisplay() { return basedisplay; } + inline BaseDisplay *getBaseDisplay() { return basedisplay; } - inline Visual *getVisual() const { return visual; } - inline Window getRootWindow() const { return root_window; } - inline Colormap colormap() const { return m_colormap; } + inline Visual *getVisual() const { return visual; } + inline Window getRootWindow() const { return root_window; } + inline Colormap colormap() const { return m_colormap; } - inline int getDepth() const { return depth; } - inline int getScreenNumber() const { return screen_number; } + inline int getDepth() const { return depth; } + inline int getScreenNumber() const { return screen_number; } - inline unsigned int getWidth() const { return width; } - inline unsigned int getHeight() const { return height; } + inline unsigned int getWidth() const { return width; } + inline unsigned int getHeight() const { return height; } #ifdef XINERAMA - inline bool hasXinerama() const { return m_hasXinerama; } - inline int getNumHeads() const { return xineramaNumHeads; } - unsigned int getHead(int x, int y) const; - unsigned int getCurrHead() const; - unsigned int getHeadWidth(unsigned int head) const; - unsigned int getHeadHeight(unsigned int head) const; - int getHeadX(unsigned int head) const; - int getHeadY(unsigned int head) const; + inline bool hasXinerama() const { return m_hasXinerama; } + inline int getNumHeads() const { return xineramaNumHeads; } + unsigned int getHead(int x, int y) const; + unsigned int getCurrHead() const; + unsigned int getHeadWidth(unsigned int head) const; + unsigned int getHeadHeight(unsigned int head) const; + int getHeadX(unsigned int head) const; + int getHeadY(unsigned int head) const; #endif // XINERAMA private: - BaseDisplay *basedisplay; - Visual *visual; - Window root_window; - Colormap m_colormap; + BaseDisplay *basedisplay; + Visual *visual; + Window root_window; + Colormap m_colormap; - int depth, screen_number; - unsigned int width, height; + int depth, screen_number; + unsigned int width, height; #ifdef XINERAMA - bool m_hasXinerama; - int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead; - XineramaScreenInfo *xineramaInfos; + bool m_hasXinerama; + int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead; + XineramaScreenInfo *xineramaInfos; #endif // XINERAMA };
M src/Basemenu.ccsrc/Basemenu.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Basemenu.cc,v 1.38 2002/11/30 20:09:19 fluxgen Exp $ +// $Id: Basemenu.cc,v 1.39 2002/12/01 13:41:54 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -53,1037 +53,1037 @@

static Basemenu *shown = 0; Basemenu::Basemenu(BScreen *screen): -m_screen(screen), -m_display(Fluxbox::instance()->getXDisplay()), -m_parent(0), -m_image_ctrl(screen->getImageControl()), -m_alignment(ALIGNDONTCARE) { + m_screen(screen), + m_display(Fluxbox::instance()->getXDisplay()), + m_parent(0), + m_image_ctrl(screen->getImageControl()), + m_alignment(ALIGNDONTCARE) { - title_vis = - movable = - hide_tree = true; + title_vis = + movable = + hide_tree = true; - shifted = - internal_menu = - moving = - torn = - visible = false; + shifted = + internal_menu = + moving = + torn = + visible = false; - menu.x = - menu.y = - menu.x_shift = - menu.y_shift = - menu.x_move = - menu.y_move = 0; + menu.x = + menu.y = + menu.x_shift = + menu.y_shift = + menu.x_move = + menu.y_move = 0; - which_sub = - which_press = - which_sbl = -1; + which_sub = + which_press = + which_sbl = -1; - menu.frame_pixmap = - menu.title_pixmap = - menu.hilite_pixmap = - menu.sel_pixmap = None; + menu.frame_pixmap = + menu.title_pixmap = + menu.hilite_pixmap = + menu.sel_pixmap = None; - menu.bevel_w = m_screen->getBevelWidth(); + menu.bevel_w = m_screen->getBevelWidth(); - menu.width = menu.title_h = menu.item_w = menu.frame_h = - m_screen->getMenuStyle()->titlefont.height() + menu.bevel_w * 2; + menu.width = menu.title_h = menu.item_w = menu.frame_h = + m_screen->getMenuStyle()->titlefont.height() + menu.bevel_w * 2; - menu.sublevels = - menu.persub = - menu.minsub = 0; + menu.sublevels = + menu.persub = + menu.minsub = 0; - menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; + menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; - menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h; + menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h; - //set attributes for menu window - unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - XSetWindowAttributes attrib; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - m_screen->getBorderColor()->pixel(); - attrib.colormap = m_screen->colormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask; + //set attributes for menu window + unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | + CWColormap | CWOverrideRedirect | CWEventMask; + XSetWindowAttributes attrib; + attrib.background_pixmap = None; + attrib.background_pixel = attrib.border_pixel = + m_screen->getBorderColor()->pixel(); + attrib.colormap = m_screen->colormap(); + attrib.override_redirect = True; + attrib.event_mask = ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | ExposureMask; - //create menu window - menu.window = - XCreateWindow(m_display, m_screen->getRootWindow(), menu.x, menu.y, menu.width, - menu.height, m_screen->getBorderWidth(), m_screen->getDepth(), - InputOutput, m_screen->getVisual(), attrib_mask, &attrib); + //create menu window + menu.window = + XCreateWindow(m_display, m_screen->getRootWindow(), menu.x, menu.y, menu.width, + menu.height, m_screen->getBorderWidth(), m_screen->getDepth(), + InputOutput, m_screen->getVisual(), attrib_mask, &attrib); - Fluxbox * const fluxbox = Fluxbox::instance(); - fluxbox->saveMenuSearch(menu.window, this); + Fluxbox * const fluxbox = Fluxbox::instance(); + fluxbox->saveMenuSearch(menu.window, this); - //attibutes for title to menuwindow - attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask; - attrib.background_pixel = m_screen->getBorderColor()->pixel(); - attrib.event_mask |= EnterWindowMask | LeaveWindowMask; - //create menu title - menu.title = - XCreateWindow(m_display, menu.window, 0, 0, menu.width, menu.height, 0, - m_screen->getDepth(), InputOutput, m_screen->getVisual(), - attrib_mask, &attrib); - fluxbox->saveMenuSearch(menu.title, this); + //attibutes for title to menuwindow + attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask; + attrib.background_pixel = m_screen->getBorderColor()->pixel(); + attrib.event_mask |= EnterWindowMask | LeaveWindowMask; + //create menu title + menu.title = + XCreateWindow(m_display, menu.window, 0, 0, menu.width, menu.height, 0, + m_screen->getDepth(), InputOutput, m_screen->getVisual(), + attrib_mask, &attrib); + fluxbox->saveMenuSearch(menu.title, this); - attrib.event_mask |= PointerMotionMask; - menu.frame = XCreateWindow(m_display, menu.window, 0, - menu.title_h + m_screen->getBorderWidth(), - menu.width, menu.frame_h, 0, - m_screen->getDepth(), InputOutput, - m_screen->getVisual(), attrib_mask, &attrib); - fluxbox->saveMenuSearch(menu.frame, this); + attrib.event_mask |= PointerMotionMask; + menu.frame = XCreateWindow(m_display, menu.window, 0, + menu.title_h + m_screen->getBorderWidth(), + menu.width, menu.frame_h, 0, + m_screen->getDepth(), InputOutput, + m_screen->getVisual(), attrib_mask, &attrib); + fluxbox->saveMenuSearch(menu.frame, this); } Basemenu::~Basemenu() { - XUnmapWindow(m_display, menu.window); + XUnmapWindow(m_display, menu.window); - if (shown && shown->windowID() == windowID()) - shown = (Basemenu *) 0; + if (shown && shown->windowID() == windowID()) + shown = (Basemenu *) 0; - //TODO: this looks kind of strange - int n = menuitems.size() - 1; - for (int i = 0; i < n; ++i) - remove(0); + //TODO: this looks kind of strange + int n = menuitems.size() - 1; + for (int i = 0; i < n; ++i) + remove(0); - if (menu.title_pixmap) - m_image_ctrl->removeImage(menu.title_pixmap); + if (menu.title_pixmap) + m_image_ctrl->removeImage(menu.title_pixmap); - if (menu.frame_pixmap) - m_image_ctrl->removeImage(menu.frame_pixmap); + if (menu.frame_pixmap) + m_image_ctrl->removeImage(menu.frame_pixmap); - if (menu.hilite_pixmap) - m_image_ctrl->removeImage(menu.hilite_pixmap); + if (menu.hilite_pixmap) + m_image_ctrl->removeImage(menu.hilite_pixmap); - if (menu.sel_pixmap) - m_image_ctrl->removeImage(menu.sel_pixmap); + if (menu.sel_pixmap) + m_image_ctrl->removeImage(menu.sel_pixmap); - Fluxbox * fluxbox = Fluxbox::instance(); + Fluxbox * fluxbox = Fluxbox::instance(); - fluxbox->removeMenuSearch(menu.title); - XDestroyWindow(m_display, menu.title); + fluxbox->removeMenuSearch(menu.title); + XDestroyWindow(m_display, menu.title); - fluxbox->removeMenuSearch(menu.frame); - XDestroyWindow(m_display, menu.frame); + fluxbox->removeMenuSearch(menu.frame); + XDestroyWindow(m_display, menu.frame); - fluxbox->removeMenuSearch(menu.window); - XDestroyWindow(m_display, menu.window); + fluxbox->removeMenuSearch(menu.window); + XDestroyWindow(m_display, menu.window); } int Basemenu::insert(const char *label, int function, const char *exec, int pos) { - BasemenuItem *item = new BasemenuItem(label, function, exec); - if (pos == -1) { - menuitems.push_back(item); - } else { - menuitems.insert(menuitems.begin() + pos, item); - } + BasemenuItem *item = new BasemenuItem(label, function, exec); + if (pos == -1) { + menuitems.push_back(item); + } else { + menuitems.insert(menuitems.begin() + pos, item); + } - return menuitems.size(); + return menuitems.size(); } int Basemenu::insert(const char *label, Basemenu *submenu, int pos) { - BasemenuItem *item = new BasemenuItem(label, submenu); - if (pos == -1) { - menuitems.push_back(item); - } else { - menuitems.insert(menuitems.begin() + pos, item); - } + BasemenuItem *item = new BasemenuItem(label, submenu); + if (pos == -1) { + menuitems.push_back(item); + } else { + menuitems.insert(menuitems.begin() + pos, item); + } - submenu->m_parent = this; + submenu->m_parent = this; - return menuitems.size(); + return menuitems.size(); } int Basemenu::remove(unsigned int index) { - if (index >= menuitems.size()) { + if (index >= menuitems.size()) { #ifdef DEBUG - std::cout << "Bad index (" << index << ") given to Basemenu::remove()" - << " -- should be between 0 and " << menuitems.size() - << " inclusive." << std::endl; + std::cout << "Bad index (" << index << ") given to Basemenu::remove()" + << " -- should be between 0 and " << menuitems.size() + << " inclusive." << std::endl; #endif // DEBUG - return -1; - } + return -1; + } - Menuitems::iterator it = menuitems.begin() + index; - BasemenuItem *item = (*it); + Menuitems::iterator it = menuitems.begin() + index; + BasemenuItem *item = (*it); - if (item) { - menuitems.erase(it); - if ((! internal_menu) && (item->submenu())) { - Basemenu *tmp = (Basemenu *) item->submenu(); + if (item) { + menuitems.erase(it); + if ((! internal_menu) && (item->submenu())) { + Basemenu *tmp = (Basemenu *) item->submenu(); - if (! tmp->internal_menu) { - delete tmp; - } else - tmp->internal_hide(); - } + if (! tmp->internal_menu) { + delete tmp; + } else + tmp->internal_hide(); + } - delete item; - } + delete item; + } - if (static_cast<unsigned int>(which_sub) == index) - which_sub = -1; - else if (static_cast<unsigned int>(which_sub) > index) - which_sub--; + if (static_cast<unsigned int>(which_sub) == index) + which_sub = -1; + else if (static_cast<unsigned int>(which_sub) > index) + which_sub--; - return menuitems.size(); + return menuitems.size(); } void Basemenu::raise() { - XRaiseWindow(BaseDisplay::getXDisplay(), windowID()); + XRaiseWindow(BaseDisplay::getXDisplay(), windowID()); } void Basemenu::lower() { - XLowerWindow(BaseDisplay::getXDisplay(), windowID()); + XLowerWindow(BaseDisplay::getXDisplay(), windowID()); } void Basemenu::update() { - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; - menu.title_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w*2; + menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; + menu.title_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w*2; - if (title_vis) { - const char *s = (menu.label!="") ? menu.label.c_str() : - i18n->getMessage( - FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, - "fluxbox Menu"); - int l = strlen(s); + if (title_vis) { + const char *s = (menu.label!="") ? menu.label.c_str() : + i18n->getMessage( + FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, + "fluxbox Menu"); + int l = strlen(s); - menu.item_w = m_screen->getMenuStyle()->titlefont.textWidth(s, l); + menu.item_w = m_screen->getMenuStyle()->titlefont.textWidth(s, l); - menu.item_w += (menu.bevel_w * 2); - } else - menu.item_w = 1; + menu.item_w += (menu.bevel_w * 2); + } else + menu.item_w = 1; - int ii = 0; - Menuitems::iterator it = menuitems.begin(); - Menuitems::iterator it_end = menuitems.end(); - for (; it != it_end; ++it) { - BasemenuItem *itmp = (*it); + int ii = 0; + Menuitems::iterator it = menuitems.begin(); + Menuitems::iterator it_end = menuitems.end(); + for (; it != it_end; ++it) { + BasemenuItem *itmp = (*it); - const char *s = itmp->label().c_str(); - int l = itmp->label().size(); + const char *s = itmp->label().c_str(); + int l = itmp->label().size(); - ii = screen()->getMenuStyle()->framefont.textWidth(s, l); + ii = screen()->getMenuStyle()->framefont.textWidth(s, l); - ii += (menu.bevel_w * 2) + (menu.item_h * 2); + ii += (menu.bevel_w * 2) + (menu.item_h * 2); - menu.item_w = ((menu.item_w < (unsigned int) ii) ? ii : menu.item_w); - } + menu.item_w = ((menu.item_w < (unsigned int) ii) ? ii : menu.item_w); + } - if (menuitems.size()) { - menu.sublevels = 1; + if (menuitems.size()) { + menu.sublevels = 1; - while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels) + - menu.title_h + m_screen->getBorderWidth()) > - m_screen->getHeight()) - menu.sublevels++; + while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels) + + menu.title_h + m_screen->getBorderWidth()) > + m_screen->getHeight()) + menu.sublevels++; - if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub; + if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub; - menu.persub = menuitems.size() / menu.sublevels; - if (menuitems.size() % menu.sublevels) menu.persub++; - } else { - menu.sublevels = 0; - menu.persub = 0; - } + menu.persub = menuitems.size() / menu.sublevels; + if (menuitems.size() % menu.sublevels) menu.persub++; + } else { + menu.sublevels = 0; + menu.persub = 0; + } - menu.width = (menu.sublevels * (menu.item_w)); - if (! menu.width) menu.width = menu.item_w; + menu.width = (menu.sublevels * (menu.item_w)); + if (! menu.width) menu.width = menu.item_w; - menu.frame_h = (menu.item_h * menu.persub); - menu.height = ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) + - menu.frame_h; - if (! menu.frame_h) menu.frame_h = 1; - if (menu.height < 1) menu.height = 1; + menu.frame_h = (menu.item_h * menu.persub); + menu.height = ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) + + menu.frame_h; + if (! menu.frame_h) menu.frame_h = 1; + if (menu.height < 1) menu.height = 1; - Pixmap tmp; - if (title_vis) { - tmp = menu.title_pixmap; - const FbTk::Texture &tex = m_screen->getMenuStyle()->title; - if (tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - menu.title_pixmap = None; - XSetWindowBackground(m_display, menu.title, tex.color().pixel()); - } else { - menu.title_pixmap = - m_image_ctrl->renderImage(menu.width, menu.title_h, tex); - XSetWindowBackgroundPixmap(m_display, menu.title, menu.title_pixmap); - } + Pixmap tmp; + if (title_vis) { + tmp = menu.title_pixmap; + const FbTk::Texture &tex = m_screen->getMenuStyle()->title; + if (tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + menu.title_pixmap = None; + XSetWindowBackground(m_display, menu.title, tex.color().pixel()); + } else { + menu.title_pixmap = + m_image_ctrl->renderImage(menu.width, menu.title_h, tex); + XSetWindowBackgroundPixmap(m_display, menu.title, menu.title_pixmap); + } - if (tmp) - m_image_ctrl->removeImage(tmp); + if (tmp) + m_image_ctrl->removeImage(tmp); - XClearWindow(m_display, menu.title); - } + XClearWindow(m_display, menu.title); + } - tmp = menu.frame_pixmap; - const FbTk::Texture &frame_tex = m_screen->getMenuStyle()->frame; - if (frame_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - menu.frame_pixmap = None; - XSetWindowBackground(m_display, menu.frame, frame_tex.color().pixel()); - } else { - menu.frame_pixmap = - m_image_ctrl->renderImage(menu.width, menu.frame_h, frame_tex); - XSetWindowBackgroundPixmap(m_display, menu.frame, menu.frame_pixmap); - } + tmp = menu.frame_pixmap; + const FbTk::Texture &frame_tex = m_screen->getMenuStyle()->frame; + if (frame_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + menu.frame_pixmap = None; + XSetWindowBackground(m_display, menu.frame, frame_tex.color().pixel()); + } else { + menu.frame_pixmap = + m_image_ctrl->renderImage(menu.width, menu.frame_h, frame_tex); + XSetWindowBackgroundPixmap(m_display, menu.frame, menu.frame_pixmap); + } - if (tmp) - m_image_ctrl->removeImage(tmp); + if (tmp) + m_image_ctrl->removeImage(tmp); - tmp = menu.hilite_pixmap; - const FbTk::Texture &hilite_tex = m_screen->getMenuStyle()->hilite; - if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) - menu.hilite_pixmap = None; - else - menu.hilite_pixmap = - m_image_ctrl->renderImage(menu.item_w, menu.item_h, hilite_tex); - if (tmp) - m_image_ctrl->removeImage(tmp); + tmp = menu.hilite_pixmap; + const FbTk::Texture &hilite_tex = m_screen->getMenuStyle()->hilite; + if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) + menu.hilite_pixmap = None; + else + menu.hilite_pixmap = + m_image_ctrl->renderImage(menu.item_w, menu.item_h, hilite_tex); + if (tmp) + m_image_ctrl->removeImage(tmp); - tmp = menu.sel_pixmap; - if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) - menu.sel_pixmap = None; - else { - int hw = menu.item_h / 2; - menu.sel_pixmap = - m_image_ctrl->renderImage(hw, hw, hilite_tex); - } - if (tmp) - m_image_ctrl->removeImage(tmp); + tmp = menu.sel_pixmap; + if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) + menu.sel_pixmap = None; + else { + int hw = menu.item_h / 2; + menu.sel_pixmap = + m_image_ctrl->renderImage(hw, hw, hilite_tex); + } + if (tmp) + m_image_ctrl->removeImage(tmp); - XResizeWindow(m_display, menu.window, menu.width, menu.height); + XResizeWindow(m_display, menu.window, menu.width, menu.height); - if (title_vis) - XResizeWindow(m_display, menu.title, menu.width, menu.title_h); + if (title_vis) + XResizeWindow(m_display, menu.title, menu.width, menu.title_h); - XMoveResizeWindow(m_display, menu.frame, 0, - ((title_vis) ? menu.title_h + - m_screen->getBorderWidth() : 0), menu.width, - menu.frame_h); + XMoveResizeWindow(m_display, menu.frame, 0, + ((title_vis) ? menu.title_h + + m_screen->getBorderWidth() : 0), menu.width, + menu.frame_h); - XClearWindow(m_display, menu.window); - XClearWindow(m_display, menu.title); - XClearWindow(m_display, menu.frame); + XClearWindow(m_display, menu.window); + XClearWindow(m_display, menu.title); + XClearWindow(m_display, menu.frame); - if (title_vis && visible) redrawTitle(); + if (title_vis && visible) redrawTitle(); - unsigned int i = 0; - for (i = 0; visible && i < menuitems.size(); i++) { - if (i == (unsigned int)which_sub) { - drawItem(i, True, 0); - drawSubmenu(i); - } else - drawItem(i, False, 0); - } + unsigned int i = 0; + for (i = 0; visible && i < menuitems.size(); i++) { + if (i == (unsigned int)which_sub) { + drawItem(i, True, 0); + drawSubmenu(i); + } else + drawItem(i, False, 0); + } - if (m_parent && visible) - m_parent->drawSubmenu(m_parent->which_sub); + if (m_parent && visible) + m_parent->drawSubmenu(m_parent->which_sub); - XMapSubwindows(m_display, menu.window); + XMapSubwindows(m_display, menu.window); } void Basemenu::show() { - XMapSubwindows(m_display, menu.window); - XMapWindow(m_display, menu.window); - visible = True; + XMapSubwindows(m_display, menu.window); + XMapWindow(m_display, menu.window); + visible = True; - if (! m_parent) { - if (shown && (! shown->torn)) - shown->hide(); + if (! m_parent) { + if (shown && (! shown->torn)) + shown->hide(); - shown = this; - } + shown = this; + } } void Basemenu::hide() { - if ((! torn) && hide_tree && m_parent && m_parent->isVisible()) { - Basemenu *p = m_parent; + if ((! torn) && hide_tree && m_parent && m_parent->isVisible()) { + Basemenu *p = m_parent; - while (p->isVisible() && (! p->torn) && p->m_parent) - p = p->m_parent; - p->internal_hide(); - } else - internal_hide(); + while (p->isVisible() && (! p->torn) && p->m_parent) + p = p->m_parent; + p->internal_hide(); + } else + internal_hide(); } void Basemenu::internal_hide() { - if (which_sub >= 0) { - BasemenuItem *tmp = menuitems[which_sub]; - tmp->submenu()->internal_hide(); - } + if (which_sub >= 0) { + BasemenuItem *tmp = menuitems[which_sub]; + tmp->submenu()->internal_hide(); + } - if (m_parent && (! torn)) { - m_parent->drawItem(m_parent->which_sub, False, True); + if (m_parent && (! torn)) { + m_parent->drawItem(m_parent->which_sub, False, True); - m_parent->which_sub = -1; - } else if (shown && shown->menu.window == menu.window) - shown = (Basemenu *) 0; + m_parent->which_sub = -1; + } else if (shown && shown->menu.window == menu.window) + shown = (Basemenu *) 0; - torn = visible = false; - which_sub = which_press = which_sub = -1; + torn = visible = false; + which_sub = which_press = which_sub = -1; - XUnmapWindow(m_display, menu.window); + XUnmapWindow(m_display, menu.window); } void Basemenu::move(int x, int y) { - menu.x = x; - menu.y = y; - XMoveWindow(m_display, menu.window, x, y); - if (which_sub != -1) - drawSubmenu(which_sub); + menu.x = x; + menu.y = y; + XMoveWindow(m_display, menu.window, x, y); + if (which_sub != -1) + drawSubmenu(which_sub); } void Basemenu::redrawTitle() { - I18n *i18n = I18n::instance(); - const char *text = menu.label.size() ? menu.label.c_str() : - i18n->getMessage( - FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, - "fluxbox Menu"); - int dx = menu.bevel_w, len = strlen(text); - unsigned int l = m_screen->getMenuStyle()->titlefont.textWidth(text, len) + menu.bevel_w*2; + I18n *i18n = I18n::instance(); + const char *text = menu.label.size() ? menu.label.c_str() : + i18n->getMessage( + FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, + "fluxbox Menu"); + int dx = menu.bevel_w, len = strlen(text); + unsigned int l = m_screen->getMenuStyle()->titlefont.textWidth(text, len) + menu.bevel_w*2; - switch (m_screen->getMenuStyle()->titlefont_justify) { - case DrawUtil::Font::RIGHT: - dx += menu.width - l; - break; + switch (m_screen->getMenuStyle()->titlefont_justify) { + case DrawUtil::Font::RIGHT: + dx += menu.width - l; + break; - case DrawUtil::Font::CENTER: - dx += (menu.width - l) / 2; - break; - default: - break; - } + case DrawUtil::Font::CENTER: + dx += (menu.width - l) / 2; + break; + default: + break; + } - m_screen->getMenuStyle()->titlefont.drawText( - menu.title, // drawable - m_screen->getScreenNumber(), - m_screen->getMenuStyle()->t_text_gc, // graphic context - text, len, // text string with lenght - dx, m_screen->getMenuStyle()->titlefont.ascent() + menu.bevel_w); // position + m_screen->getMenuStyle()->titlefont.drawText( + menu.title, // drawable + m_screen->getScreenNumber(), + m_screen->getMenuStyle()->t_text_gc, // graphic context + text, len, // text string with lenght + dx, m_screen->getMenuStyle()->titlefont.ascent() + menu.bevel_w); // position } void Basemenu::drawSubmenu(unsigned int index) { - if (which_sub >= 0 && static_cast<unsigned int>(which_sub) != index && - static_cast<unsigned int>(which_sub) < menuitems.size()) { - BasemenuItem *itmp = menuitems[which_sub]; + if (which_sub >= 0 && static_cast<unsigned int>(which_sub) != index && + static_cast<unsigned int>(which_sub) < menuitems.size()) { + BasemenuItem *itmp = menuitems[which_sub]; - if (! itmp->submenu()->isTorn()) - itmp->submenu()->internal_hide(); - } + if (! itmp->submenu()->isTorn()) + itmp->submenu()->internal_hide(); + } - if (index < menuitems.size()) { - BasemenuItem *item = menuitems[index]; - if (item->submenu() && visible && (! item->submenu()->isTorn()) && - item->isEnabled()) { + if (index < menuitems.size()) { + BasemenuItem *item = menuitems[index]; + if (item->submenu() && visible && (! item->submenu()->isTorn()) && + item->isEnabled()) { - if (item->submenu()->m_parent != this) - item->submenu()->m_parent = this; + if (item->submenu()->m_parent != this) + item->submenu()->m_parent = this; - int sbl = index / menu.persub, i = index - (sbl * menu.persub), - x = menu.x + - ((menu.item_w * (sbl + 1)) + m_screen->getBorderWidth()), y; + int sbl = index / menu.persub, i = index - (sbl * menu.persub), + x = menu.x + + ((menu.item_w * (sbl + 1)) + m_screen->getBorderWidth()), y; - if (m_alignment == ALIGNTOP) { - y = (((shifted) ? menu.y_shift : menu.y) + - ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) - - ((item->submenu()->title_vis) ? - item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0)); - } else { - y = (((shifted) ? menu.y_shift : menu.y) + - (menu.item_h * i) + - ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) - - ((item->submenu()->title_vis) ? - item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0)); - } + if (m_alignment == ALIGNTOP) { + y = (((shifted) ? menu.y_shift : menu.y) + + ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) - + ((item->submenu()->title_vis) ? + item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0)); + } else { + y = (((shifted) ? menu.y_shift : menu.y) + + (menu.item_h * i) + + ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) - + ((item->submenu()->title_vis) ? + item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0)); + } - if (m_alignment == ALIGNBOTTOM && - (y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift : - menu.y) + menu.height) { - y = (((shifted) ? menu.y_shift : menu.y) + - menu.height - item->submenu()->menu.height); - } + if (m_alignment == ALIGNBOTTOM && + (y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift : + menu.y) + menu.height) { + y = (((shifted) ? menu.y_shift : menu.y) + + menu.height - item->submenu()->menu.height); + } - #ifdef XINERAMA - int head_x = 0, - head_y = 0, - head_w, - head_h; +#ifdef XINERAMA + int head_x = 0, + head_y = 0, + head_w, + head_h; - unsigned int head = 0; - if (m_screen->hasXinerama()) { - head = m_screen->getHead(menu.x, menu.y); - head_x = m_screen->getHeadX(head); - head_y = m_screen->getHeadY(head); - head_w = m_screen->getHeadWidth(head); - head_h = m_screen->getHeadHeight(head); - } else { - head_w = m_screen->getWidth(); - head_h = m_screen->getHeight(); - } + unsigned int head = 0; + if (m_screen->hasXinerama()) { + head = m_screen->getHead(menu.x, menu.y); + head_x = m_screen->getHeadX(head); + head_y = m_screen->getHeadY(head); + head_w = m_screen->getHeadWidth(head); + head_h = m_screen->getHeadHeight(head); + } else { + head_w = m_screen->getWidth(); + head_h = m_screen->getHeight(); + } - if (static_cast<int>(x + item->submenu()->width()) > static_cast<int>(head_x + head_w)) { - x = ((shifted) ? menu.x_shift : menu.x) - - item->submenu()->width() - m_screen->getBorderWidth(); - } + if (static_cast<int>(x + item->submenu()->width()) > static_cast<int>(head_x + head_w)) { + x = ((shifted) ? menu.x_shift : menu.x) - + item->submenu()->width() - m_screen->getBorderWidth(); + } - if (x < head_x) - x = head_x; + if (x < head_x) + x = head_x; - if (static_cast<int>(y + item->submenu()->height()) > static_cast<int>(head_y + head_h)) { - y = head_y + head_h - - item->submenu()->height() - m_screen->getBorderWidth2x(); - } + if (static_cast<int>(y + item->submenu()->height()) > static_cast<int>(head_y + head_h)) { + y = head_y + head_h - + item->submenu()->height() - m_screen->getBorderWidth2x(); + } - if (y < head_y) - y = head_y; - #else // !XINERAMA + if (y < head_y) + y = head_y; +#else // !XINERAMA - if ((x + item->submenu()->width()) > m_screen->getWidth()) { - x = ((shifted) ? menu.x_shift : menu.x) - - item->submenu()->width() - m_screen->getBorderWidth(); - } + if ((x + item->submenu()->width()) > m_screen->getWidth()) { + x = ((shifted) ? menu.x_shift : menu.x) - + item->submenu()->width() - m_screen->getBorderWidth(); + } - if (x < 0) - x = 0; + if (x < 0) + x = 0; - if ((y + item->submenu()->height()) > m_screen->getHeight()) { - y = m_screen->getHeight() - item->submenu()->height() - - m_screen->getBorderWidth2x(); - } + if ((y + item->submenu()->height()) > m_screen->getHeight()) { + y = m_screen->getHeight() - item->submenu()->height() - + m_screen->getBorderWidth2x(); + } - if (y < 0) - y = 0; - #endif // XINERAMA + if (y < 0) + y = 0; +#endif // XINERAMA - item->submenu()->move(x, y); - if (! moving) - drawItem(index, True); + item->submenu()->move(x, y); + if (! moving) + drawItem(index, True); - if (! item->submenu()->isVisible()) - item->submenu()->show(); + if (! item->submenu()->isVisible()) + item->submenu()->show(); - item->submenu()->moving = moving; - which_sub = index; - } else - which_sub = -1; - } + item->submenu()->moving = moving; + which_sub = index; + } else + which_sub = -1; + } } bool Basemenu::hasSubmenu(unsigned int index) const { - if (index >= menuitems.size()) //boundary check - return false; + if (index >= menuitems.size()) //boundary check + return false; - if (!menuitems[index]->submenu()) //has submenu? - return false; + if (!menuitems[index]->submenu()) //has submenu? + return false; - return true; + return true; } void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, - int x, int y, unsigned int w, unsigned int h) + int x, int y, unsigned int w, unsigned int h) { - if (index >= menuitems.size() || menuitems.size() == 0) - return; + if (index >= menuitems.size() || menuitems.size() == 0) + return; - BasemenuItem *item = menuitems[index]; - if (! item) return; + BasemenuItem *item = menuitems[index]; + if (! item) return; - bool dotext = true, dohilite = true, dosel = true; - const char *text = item->label().c_str(); - int sbl = index / menu.persub, i = index - (sbl * menu.persub); - int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h); - int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0; - int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0; - unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0; - unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; + bool dotext = true, dohilite = true, dosel = true; + const char *text = item->label().c_str(); + int sbl = index / menu.persub, i = index - (sbl * menu.persub); + int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h); + int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0; + int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0; + unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0; + unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; - if (text) { - text_w = m_screen->getMenuStyle()->framefont.textWidth(text, len); + if (text) { + text_w = m_screen->getMenuStyle()->framefont.textWidth(text, len); - text_y = item_y + menu.bevel_w/2 + m_screen->getMenuStyle()->framefont.ascent(); + text_y = item_y + menu.bevel_w/2 + m_screen->getMenuStyle()->framefont.ascent(); - switch(m_screen->getMenuStyle()->framefont_justify) { - case DrawUtil::Font::LEFT: - text_x = item_x + menu.bevel_w + menu.item_h + 1; - break; + switch(m_screen->getMenuStyle()->framefont_justify) { + case DrawUtil::Font::LEFT: + text_x = item_x + menu.bevel_w + menu.item_h + 1; + break; - case DrawUtil::Font::RIGHT: - text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w); - break; - default: //center - text_x = item_x + ((menu.item_w + 1 - text_w) / 2); - break; - } + case DrawUtil::Font::RIGHT: + text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w); + break; + default: //center + text_x = item_x + ((menu.item_w + 1 - text_w) / 2); + break; + } - text_h = menu.item_h - menu.bevel_w; - } + text_h = menu.item_h - menu.bevel_w; + } - GC gc = - ((highlight || item->isSelected()) ? m_screen->getMenuStyle()->h_text_gc : - m_screen->getMenuStyle()->f_text_gc), - tgc = - ((highlight) ? m_screen->getMenuStyle()->h_text_gc : - ((item->isEnabled()) ? m_screen->getMenuStyle()->f_text_gc : - m_screen->getMenuStyle()->d_text_gc)); + GC gc = + ((highlight || item->isSelected()) ? m_screen->getMenuStyle()->h_text_gc : + m_screen->getMenuStyle()->f_text_gc), + tgc = + ((highlight) ? m_screen->getMenuStyle()->h_text_gc : + ((item->isEnabled()) ? m_screen->getMenuStyle()->f_text_gc : + m_screen->getMenuStyle()->d_text_gc)); - sel_x = item_x; + sel_x = item_x; - if (m_screen->getMenuStyle()->bullet_pos == RIGHT) - sel_x += (menu.item_w - menu.item_h - menu.bevel_w); + if (m_screen->getMenuStyle()->bullet_pos == RIGHT) + sel_x += (menu.item_w - menu.item_h - menu.bevel_w); - sel_x += quarter_w; - sel_y = item_y + quarter_w; + sel_x += quarter_w; + sel_y = item_y + quarter_w; - if (clear) { - XClearArea(m_display, menu.frame, item_x, item_y, menu.item_w, menu.item_h, - False); - } else if (! (x == y && y == -1 && w == h && h == 0)) { - // calculate the which part of the hilite to redraw - if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) && - std::max(item_y, y) <= (signed) std::min(item_y + menu.item_h, y + h))) { - dohilite = False; - } else { - hilite_x = std::max(item_x, x); - hilite_y = std::max(item_y, y); - hilite_w = std::min(item_x + menu.item_w, x + w) - hilite_x; - hilite_h = std::min(item_y + menu.item_h, y + h) - hilite_y; - hoff_x = hilite_x % menu.item_w; - hoff_y = hilite_y % menu.item_h; - } + if (clear) { + XClearArea(m_display, menu.frame, item_x, item_y, menu.item_w, menu.item_h, + False); + } else if (! (x == y && y == -1 && w == h && h == 0)) { + // calculate the which part of the hilite to redraw + if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) && + std::max(item_y, y) <= (signed) std::min(item_y + menu.item_h, y + h))) { + dohilite = False; + } else { + hilite_x = std::max(item_x, x); + hilite_y = std::max(item_y, y); + hilite_w = std::min(item_x + menu.item_w, x + w) - hilite_x; + hilite_h = std::min(item_y + menu.item_h, y + h) - hilite_y; + hoff_x = hilite_x % menu.item_w; + hoff_y = hilite_y % menu.item_h; + } - // check if we need to redraw the text - int text_ry = item_y + (menu.bevel_w / 2); - if (! (std::max(text_x, x) <= (signed) std::min(text_x + text_w, x + w) && - std::max(text_ry, y) <= (signed) std::min(text_ry + text_h, y + h))) - dotext = False; + // check if we need to redraw the text + int text_ry = item_y + (menu.bevel_w / 2); + if (! (std::max(text_x, x) <= (signed) std::min(text_x + text_w, x + w) && + std::max(text_ry, y) <= (signed) std::min(text_ry + text_h, y + h))) + dotext = False; - // check if we need to redraw the select pixmap/menu bullet - if (! (std::max(sel_x, x) <= (signed) std::min(sel_x + half_w, x + w) && - std::max(sel_y, y) <= (signed) std::min(sel_y + half_w, y + h))) - dosel = False; + // check if we need to redraw the select pixmap/menu bullet + if (! (std::max(sel_x, x) <= (signed) std::min(sel_x + half_w, x + w) && + std::max(sel_y, y) <= (signed) std::min(sel_y + half_w, y + h))) + dosel = False; - } + } - if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { - if (menu.hilite_pixmap) { - XCopyArea(m_display, menu.hilite_pixmap, menu.frame, - m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y, - hilite_w, hilite_h, hilite_x, hilite_y); - } else { - XFillRectangle(m_display, menu.frame, - m_screen->getMenuStyle()->hilite_gc, - hilite_x, hilite_y, hilite_w, hilite_h); - } - } + if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { + if (menu.hilite_pixmap) { + XCopyArea(m_display, menu.hilite_pixmap, menu.frame, + m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y, + hilite_w, hilite_h, hilite_x, hilite_y); + } else { + XFillRectangle(m_display, menu.frame, + m_screen->getMenuStyle()->hilite_gc, + hilite_x, hilite_y, hilite_w, hilite_h); + } + } - if (dosel && item->isSelected() && - (menu.sel_pixmap != ParentRelative)) { - if (menu.sel_pixmap) { - XCopyArea(m_display, highlight ? menu.frame_pixmap : menu.sel_pixmap, menu.frame, - m_screen->getMenuStyle()->hilite_gc, 0, 0, - half_w, half_w, sel_x, sel_y); - } else { - XFillRectangle(m_display, menu.frame, - m_screen->getMenuStyle()->hilite_gc, - sel_x, sel_y, half_w, half_w); - } - } + if (dosel && item->isSelected() && + (menu.sel_pixmap != ParentRelative)) { + if (menu.sel_pixmap) { + XCopyArea(m_display, highlight ? menu.frame_pixmap : menu.sel_pixmap, menu.frame, + m_screen->getMenuStyle()->hilite_gc, 0, 0, + half_w, half_w, sel_x, sel_y); + } else { + XFillRectangle(m_display, menu.frame, + m_screen->getMenuStyle()->hilite_gc, + sel_x, sel_y, half_w, half_w); + } + } - if (dotext && text) { - m_screen->getMenuStyle()->framefont.drawText( - menu.frame, // drawable - m_screen->getScreenNumber(), - tgc, - text, len, // text string and lenght - text_x, text_y); // position + if (dotext && text) { + m_screen->getMenuStyle()->framefont.drawText( + menu.frame, // drawable + m_screen->getScreenNumber(), + tgc, + text, len, // text string and lenght + text_x, text_y); // position - } + } - if (dosel && item->submenu()) { - switch (m_screen->getMenuStyle()->bullet) { - case SQUARE: - XDrawRectangle(m_display, menu.frame, gc, sel_x, sel_y, half_w, half_w); - break; + if (dosel && item->submenu()) { + switch (m_screen->getMenuStyle()->bullet) { + case SQUARE: + XDrawRectangle(m_display, menu.frame, gc, sel_x, sel_y, half_w, half_w); + break; - case TRIANGLE: - XPoint tri[3]; + case TRIANGLE: + XPoint tri[3]; - if (m_screen->getMenuStyle()->bullet_pos == RIGHT) { - tri[0].x = sel_x + quarter_w - 2; - tri[0].y = sel_y + quarter_w - 2; - tri[1].x = 4; - tri[1].y = 2; - tri[2].x = -4; - tri[2].y = 2; - } else { - tri[0].x = sel_x + quarter_w - 2; - tri[0].y = item_y + half_w; - tri[1].x = 4; - tri[1].y = 2; - tri[2].x = 0; - tri[2].y = -4; - } + if (m_screen->getMenuStyle()->bullet_pos == RIGHT) { + tri[0].x = sel_x + quarter_w - 2; + tri[0].y = sel_y + quarter_w - 2; + tri[1].x = 4; + tri[1].y = 2; + tri[2].x = -4; + tri[2].y = 2; + } else { + tri[0].x = sel_x + quarter_w - 2; + tri[0].y = item_y + half_w; + tri[1].x = 4; + tri[1].y = 2; + tri[2].x = 0; + tri[2].y = -4; + } - XFillPolygon(m_display, menu.frame, gc, tri, 3, Convex, - CoordModePrevious); - break; + XFillPolygon(m_display, menu.frame, gc, tri, 3, Convex, + CoordModePrevious); + break; - case DIAMOND: - XPoint dia[4]; + case DIAMOND: + XPoint dia[4]; - dia[0].x = sel_x + quarter_w - 3; - dia[0].y = item_y + half_w; - dia[1].x = 3; - dia[1].y = -3; - dia[2].x = 3; - dia[2].y = 3; - dia[3].x = -3; - dia[3].y = 3; + dia[0].x = sel_x + quarter_w - 3; + dia[0].y = item_y + half_w; + dia[1].x = 3; + dia[1].y = -3; + dia[2].x = 3; + dia[2].y = 3; + dia[3].x = -3; + dia[3].y = 3; - XFillPolygon(m_display, menu.frame, gc, dia, 4, Convex, - CoordModePrevious); - break; - } - } + XFillPolygon(m_display, menu.frame, gc, dia, 4, Convex, + CoordModePrevious); + break; + } + } } void Basemenu::setLabel(const char *labelstr) { - //make sure we don't send 0 to std::string - menu.label = (labelstr ? labelstr : ""); + //make sure we don't send 0 to std::string + menu.label = (labelstr ? labelstr : ""); } void Basemenu::setItemSelected(unsigned int index, bool sel) { - if (index >= menuitems.size()) return; + if (index >= menuitems.size()) return; - BasemenuItem *item = find(index); - if (! item) return; + BasemenuItem *item = find(index); + if (! item) return; - item->setSelected(sel); - if (visible) drawItem(index, (index == (unsigned int)which_sub), true); + item->setSelected(sel); + if (visible) drawItem(index, (index == (unsigned int)which_sub), true); } bool Basemenu::isItemSelected(unsigned int index) const{ - if (index >= menuitems.size()) return false; + if (index >= menuitems.size()) return false; - const BasemenuItem *item = find(index); - if (!item) - return false; + const BasemenuItem *item = find(index); + if (!item) + return false; - return item->isSelected(); + return item->isSelected(); } void Basemenu::setItemEnabled(unsigned int index, bool enable) { - if (index >= menuitems.size()) return; + if (index >= menuitems.size()) return; - BasemenuItem *item = find(index); - if (! item) return; + BasemenuItem *item = find(index); + if (! item) return; - item->setEnabled(enable); - if (visible) drawItem(index, (index == static_cast<unsigned int>(which_sub)), True); + item->setEnabled(enable); + if (visible) drawItem(index, (index == static_cast<unsigned int>(which_sub)), True); } bool Basemenu::isItemEnabled(unsigned int index) const { - if (index >= menuitems.size()) return false; + if (index >= menuitems.size()) return false; - BasemenuItem *item = find(index); - if (!item) - return false; + BasemenuItem *item = find(index); + if (!item) + return false; - return item->isEnabled(); + return item->isEnabled(); } void Basemenu::buttonPressEvent(XButtonEvent *be) { - if (be->window == menu.frame) { - int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); - int w = (sbl * menu.persub) + i; + if (be->window == menu.frame) { + int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); + int w = (sbl * menu.persub) + i; - if (w < static_cast<int>(menuitems.size()) && w >= 0) { - which_press = i; - which_sbl = sbl; + if (w < static_cast<int>(menuitems.size()) && w >= 0) { + which_press = i; + which_sbl = sbl; - BasemenuItem *item = menuitems[w]; + BasemenuItem *item = menuitems[w]; - if (item->submenu()) - drawSubmenu(w); - else - drawItem(w, (item->isEnabled()), true); - } - } else { - menu.x_move = be->x_root - menu.x; - menu.y_move = be->y_root - menu.y; - } + if (item->submenu()) + drawSubmenu(w); + else + drawItem(w, (item->isEnabled()), true); + } + } else { + menu.x_move = be->x_root - menu.x; + menu.y_move = be->y_root - menu.y; + } } void Basemenu::buttonReleaseEvent(XButtonEvent *re) { - if (re->window == menu.title) { - if (moving) { - moving = false; + if (re->window == menu.title) { + if (moving) { + moving = false; - if (which_sub >= 0) - drawSubmenu(which_sub); - } + if (which_sub >= 0) + drawSubmenu(which_sub); + } - if (re->x >= 0 && re->x <= (signed) menu.width && - re->y >= 0 && re->y <= (signed) menu.title_h && - re->button == 3) - hide(); + if (re->x >= 0 && re->x <= (signed) menu.width && + re->y >= 0 && re->y <= (signed) menu.title_h && + re->button == 3) + hide(); - } else if (re->window == menu.frame && - re->x >= 0 && re->x < (signed) menu.width && - re->y >= 0 && re->y < (signed) menu.frame_h) { + } else if (re->window == menu.frame && + re->x >= 0 && re->x < (signed) menu.width && + re->y >= 0 && re->y < (signed) menu.frame_h) { - if (re->button == 3) { - hide(); - } else { - int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h), - ix = sbl * menu.item_w, iy = i * menu.item_h, - w = (sbl * menu.persub) + i, - p = (which_sbl * menu.persub) + which_press; + if (re->button == 3) { + hide(); + } else { + int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h), + ix = sbl * menu.item_w, iy = i * menu.item_h, + w = (sbl * menu.persub) + i, + p = (which_sbl * menu.persub) + which_press; - if (w < static_cast<int>(menuitems.size()) && w >= 0) { - drawItem(p, (p == which_sub), True); + if (w < static_cast<int>(menuitems.size()) && w >= 0) { + drawItem(p, (p == which_sub), True); - if (p == w && isItemEnabled(w)) { - if (re->x > ix && re->x < (signed) (ix + menu.item_w) && - re->y > iy && re->y < (signed) (iy + menu.item_h)) { - itemSelected(re->button, w); - } - } - } else - drawItem(p, False, True); + if (p == w && isItemEnabled(w)) { + if (re->x > ix && re->x < (signed) (ix + menu.item_w) && + re->y > iy && re->y < (signed) (iy + menu.item_h)) { + itemSelected(re->button, w); + } + } + } else + drawItem(p, False, True); - } - } + } + } } void Basemenu::motionNotifyEvent(XMotionEvent *me) { - if (me->window == menu.title && (me->state & Button1Mask)) { - if (movable) { - if (! moving) { - if (m_parent && (! torn)) { - m_parent->drawItem(m_parent->which_sub, False, True); - m_parent->which_sub = -1; - } + if (me->window == menu.title && (me->state & Button1Mask)) { + if (movable) { + if (! moving) { + if (m_parent && (! torn)) { + m_parent->drawItem(m_parent->which_sub, False, True); + m_parent->which_sub = -1; + } - moving = torn = True; + moving = torn = True; - if (which_sub >= 0) - drawSubmenu(which_sub); - } else { - menu.x = me->x_root - menu.x_move, - menu.y = me->y_root - menu.y_move; + if (which_sub >= 0) + drawSubmenu(which_sub); + } else { + menu.x = me->x_root - menu.x_move, + menu.y = me->y_root - menu.y_move; - XMoveWindow(m_display, menu.window, menu.x, menu.y); + XMoveWindow(m_display, menu.window, menu.x, menu.y); - if (which_sub >= 0) - drawSubmenu(which_sub); - } - } - } else if ((! (me->state & Button1Mask)) && me->window == menu.frame && - me->x >= 0 && me->x < (signed) menu.width && - me->y >= 0 && me->y < (signed) menu.frame_h) { - int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h), - w = (sbl * menu.persub) + i; + if (which_sub >= 0) + drawSubmenu(which_sub); + } + } + } else if ((! (me->state & Button1Mask)) && me->window == menu.frame && + me->x >= 0 && me->x < (signed) menu.width && + me->y >= 0 && me->y < (signed) menu.frame_h) { + int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h), + w = (sbl * menu.persub) + i; - if ((i != which_press || sbl != which_sbl) && - (w < static_cast<int>(menuitems.size()) && w >= 0)) { - if (which_press != -1 && which_sbl != -1) { - int p = (which_sbl * menu.persub) + which_press; - BasemenuItem *item = menuitems[p]; + if ((i != which_press || sbl != which_sbl) && + (w < static_cast<int>(menuitems.size()) && w >= 0)) { + if (which_press != -1 && which_sbl != -1) { + int p = (which_sbl * menu.persub) + which_press; + BasemenuItem *item = menuitems[p]; - drawItem(p, False, True); - if (item->submenu()) { - if (item->submenu()->isVisible() && - (! item->submenu()->isTorn())) { - item->submenu()->internal_hide(); - which_sub = -1; - } - } - } + drawItem(p, False, True); + if (item->submenu()) { + if (item->submenu()->isVisible() && + (! item->submenu()->isTorn())) { + item->submenu()->internal_hide(); + which_sub = -1; + } + } + } - which_press = i; - which_sbl = sbl; + which_press = i; + which_sbl = sbl; - BasemenuItem *itmp = menuitems[w]; + BasemenuItem *itmp = menuitems[w]; - if (itmp->submenu()) - drawSubmenu(w); - else - drawItem(w, (itmp->isEnabled()), True); - } - } + if (itmp->submenu()) + drawSubmenu(w); + else + drawItem(w, (itmp->isEnabled()), True); + } + } } void Basemenu::exposeEvent(XExposeEvent *ee) { - if (ee->window == menu.title) { - redrawTitle(); - } else if (ee->window == menu.frame) { - // this is a compilicated algorithm... lets do it step by step... - // first... we see in which sub level the expose starts... and how many - // items down in that sublevel + if (ee->window == menu.title) { + redrawTitle(); + } else if (ee->window == menu.frame) { + // this is a compilicated algorithm... lets do it step by step... + // first... we see in which sub level the expose starts... and how many + // items down in that sublevel - int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h), - // next... figure out how many sublevels over the redraw spans - sbl_d = ((ee->x + ee->width) / menu.item_w), - // then we see how many items down to redraw - id_d = ((ee->y + ee->height) / menu.item_h); + int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h), + // next... figure out how many sublevels over the redraw spans + sbl_d = ((ee->x + ee->width) / menu.item_w), + // then we see how many items down to redraw + id_d = ((ee->y + ee->height) / menu.item_h); - if (id_d > menu.persub) id_d = menu.persub; + if (id_d > menu.persub) id_d = menu.persub; - // draw the sublevels and the number of items the exposure spans - int i, ii; - for (i = sbl; i <= sbl_d; i++) { - // set the iterator to the first item in the sublevel needing redrawing - int index = id + i * menu.persub; - if (index < static_cast<int>(menuitems.size()) && index >= 0) { - Menuitems::iterator it = menuitems.begin() + index; - Menuitems::iterator it_end = menuitems.end(); - for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { - int index = ii + (i * menu.persub); - // redraw the item - drawItem(index, (which_sub == index), true, - ee->x, ee->y, ee->width, ee->height); - } - } - } - } + // draw the sublevels and the number of items the exposure spans + int i, ii; + for (i = sbl; i <= sbl_d; i++) { + // set the iterator to the first item in the sublevel needing redrawing + int index = id + i * menu.persub; + if (index < static_cast<int>(menuitems.size()) && index >= 0) { + Menuitems::iterator it = menuitems.begin() + index; + Menuitems::iterator it_end = menuitems.end(); + for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { + int index = ii + (i * menu.persub); + // redraw the item + drawItem(index, (which_sub == index), true, + ee->x, ee->y, ee->width, ee->height); + } + } + } + } } void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { #ifdef XINERAMA - int head = m_screen->hasXinerama() ? m_screen->getCurrHead() : 0; + int head = m_screen->hasXinerama() ? m_screen->getCurrHead() : 0; - if (ce->window == menu.frame) { - menu.x_shift = menu.x, menu.y_shift = menu.y; - if (menu.x + menu.width > - (m_screen->getHeadX(head) + m_screen->getHeadWidth(head))) { - menu.x_shift = m_screen->getHeadX(head) + m_screen->getHeadWidth(head) - - menu.width - m_screen->getBorderWidth2x(); - shifted = True; - } else if (menu.x < m_screen->getHeadX(head)) { - menu.x_shift = m_screen->getHeadX(head); - shifted = True; - } + if (ce->window == menu.frame) { + menu.x_shift = menu.x, menu.y_shift = menu.y; + if (menu.x + menu.width > + (m_screen->getHeadX(head) + m_screen->getHeadWidth(head))) { + menu.x_shift = m_screen->getHeadX(head) + m_screen->getHeadWidth(head) - + menu.width - m_screen->getBorderWidth2x(); + shifted = True; + } else if (menu.x < m_screen->getHeadX(head)) { + menu.x_shift = m_screen->getHeadX(head); + shifted = True; + } - if (menu.y + menu.height > - (m_screen->getHeadY(head) + m_screen->getHeadHeight(head))) { - menu.y_shift = m_screen->getHeadY(head) + m_screen->getHeadHeight(head) - - menu.height - m_screen->getBorderWidth2x(); - shifted = True; - } else if (menu.y + (signed) menu.title_h < m_screen->getHeadY(head)) { - menu.y_shift = m_screen->getHeadY(head); - shifted = True; - } + if (menu.y + menu.height > + (m_screen->getHeadY(head) + m_screen->getHeadHeight(head))) { + menu.y_shift = m_screen->getHeadY(head) + m_screen->getHeadHeight(head) - + menu.height - m_screen->getBorderWidth2x(); + shifted = True; + } else if (menu.y + (signed) menu.title_h < m_screen->getHeadY(head)) { + menu.y_shift = m_screen->getHeadY(head); + shifted = True; + } #else // !XINERAMA if (ce->window == menu.frame) { - menu.x_shift = menu.x, menu.y_shift = menu.y; - if (menu.x + menu.width > m_screen->getWidth()) { - menu.x_shift = m_screen->getWidth() - menu.width - - m_screen->getBorderWidth(); - shifted = True; - } else if (menu.x < 0) { - menu.x_shift = -m_screen->getBorderWidth(); - shifted = True; - } + menu.x_shift = menu.x, menu.y_shift = menu.y; + if (menu.x + menu.width > m_screen->getWidth()) { + menu.x_shift = m_screen->getWidth() - menu.width - + m_screen->getBorderWidth(); + shifted = True; + } else if (menu.x < 0) { + menu.x_shift = -m_screen->getBorderWidth(); + shifted = True; + } - if (menu.y + menu.height > m_screen->getHeight()) { - menu.y_shift = m_screen->getHeight() - menu.height - - m_screen->getBorderWidth(); - shifted = True; - } else if (menu.y + (signed) menu.title_h < 0) { - menu.y_shift = -m_screen->getBorderWidth(); - shifted = True; - } + if (menu.y + menu.height > m_screen->getHeight()) { + menu.y_shift = m_screen->getHeight() - menu.height - + m_screen->getBorderWidth(); + shifted = True; + } else if (menu.y + (signed) menu.title_h < 0) { + menu.y_shift = -m_screen->getBorderWidth(); + shifted = True; + } #endif // XINERAMA - if (shifted) { - #ifdef XINERAMA - menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads - menu.y = menu.y_shift; - #endif // XINERAMA - XMoveWindow(m_display, menu.window, menu.x_shift, menu.y_shift); - } + if (shifted) { +#ifdef XINERAMA + menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads + menu.y = menu.y_shift; +#endif // XINERAMA + XMoveWindow(m_display, menu.window, menu.x_shift, menu.y_shift); + } - if (which_sub >= 0 && static_cast<size_t>(which_sub) < menuitems.size()) { - BasemenuItem *tmp = menuitems[which_sub]; - if (tmp->submenu()->isVisible()) { - int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), - w = (sbl * menu.persub) + i; + if (which_sub >= 0 && static_cast<size_t>(which_sub) < menuitems.size()) { + BasemenuItem *tmp = menuitems[which_sub]; + if (tmp->submenu()->isVisible()) { + int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), + w = (sbl * menu.persub) + i; - if (w != which_sub && (! tmp->submenu()->isTorn())) { - tmp->submenu()->internal_hide(); + if (w != which_sub && (! tmp->submenu()->isTorn())) { + tmp->submenu()->internal_hide(); - drawItem(which_sub, False, True); - which_sub = -1; - } - } - } + drawItem(which_sub, False, True); + which_sub = -1; + } + } + } } -} + } -void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) { + void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) { if (ce->window == menu.frame) { - if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { - int p = (which_sbl * menu.persub) + which_press; + if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { + int p = (which_sbl * menu.persub) + which_press; - drawItem(p, (p == which_sub), true); + drawItem(p, (p == which_sub), true); - which_sbl = which_press = -1; - } + which_sbl = which_press = -1; + } - if (shifted) { - XMoveWindow(m_display, menu.window, menu.x, menu.y); - shifted = false; + if (shifted) { + XMoveWindow(m_display, menu.window, menu.x, menu.y); + shifted = false; - if (which_sub >= 0) - drawSubmenu(which_sub); - } + if (which_sub >= 0) + drawSubmenu(which_sub); + } } -} + } -void Basemenu::reconfigure(void) { + void Basemenu::reconfigure(void) { XSetWindowBackground(m_display, menu.window, - m_screen->getBorderColor()->pixel()); + m_screen->getBorderColor()->pixel()); XSetWindowBorder(m_display, menu.window, m_screen->getBorderColor()->pixel()); XSetWindowBorderWidth(m_display, menu.window, m_screen->getBorderWidth()); menu.bevel_w = m_screen->getBevelWidth(); update(); -} + }
M src/Basemenu.hhsrc/Basemenu.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Basemenu.hh,v 1.19 2002/11/26 16:06:36 fluxgen Exp $ +// $Id: Basemenu.hh,v 1.20 2002/12/01 13:41:54 rathnor Exp $ #ifndef BASEMENU_HH #define BASEMENU_HH

@@ -37,122 +37,122 @@ class Fluxbox;

class BImageControl; class BScreen; /** - Base class for menus + Base class for menus */ class Basemenu { public: - enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; - enum { RIGHT = 1, LEFT }; + enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; + enum { RIGHT = 1, LEFT }; - /** - Bullet type - */ - enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; + /** + Bullet type + */ + enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; - explicit Basemenu(BScreen *screen); - virtual ~Basemenu(); + explicit Basemenu(BScreen *screen); + virtual ~Basemenu(); - /** - @name manipulators - */ - //@{ - int insert(const char *label, int function= 0, const char *exec = 0, int pos = -1); - int insert(const char *label, Basemenu *submenu, int pos= -1); - int remove(unsigned int item); - inline void setInternalMenu() { internal_menu = true; } - inline void setAlignment(Alignment a) { m_alignment = a; } - inline void setTorn() { torn = true; } - inline void removeParent() { if (internal_menu) m_parent = 0; } - void raise(); - void lower(); - /** - @name event handlers - */ - //@{ - void buttonPressEvent(XButtonEvent *bp); - void buttonReleaseEvent(XButtonEvent *br); - void motionNotifyEvent(XMotionEvent *mn); - void enterNotifyEvent(XCrossingEvent *en); - void leaveNotifyEvent(XCrossingEvent *ce); - void exposeEvent(XExposeEvent *ee); - //@} + /** + @name manipulators + */ + //@{ + int insert(const char *label, int function= 0, const char *exec = 0, int pos = -1); + int insert(const char *label, Basemenu *submenu, int pos= -1); + int remove(unsigned int item); + inline void setInternalMenu() { internal_menu = true; } + inline void setAlignment(Alignment a) { m_alignment = a; } + inline void setTorn() { torn = true; } + inline void removeParent() { if (internal_menu) m_parent = 0; } + void raise(); + void lower(); + /** + @name event handlers + */ + //@{ + void buttonPressEvent(XButtonEvent *bp); + void buttonReleaseEvent(XButtonEvent *br); + void motionNotifyEvent(XMotionEvent *mn); + void enterNotifyEvent(XCrossingEvent *en); + void leaveNotifyEvent(XCrossingEvent *ce); + void exposeEvent(XExposeEvent *ee); + //@} - void reconfigure(); - /// set label string - void setLabel(const char *labelstr); - /// move menu to x,y - void move(int x, int y); - void update(); - void setItemSelected(unsigned int index, bool val); - void setItemEnabled(unsigned int index, bool val); - virtual void drawSubmenu(unsigned int index); - virtual void show(); - virtual void hide(); - /*@}*/ + void reconfigure(); + /// set label string + void setLabel(const char *labelstr); + /// move menu to x,y + void move(int x, int y); + void update(); + void setItemSelected(unsigned int index, bool val); + void setItemEnabled(unsigned int index, bool val); + virtual void drawSubmenu(unsigned int index); + virtual void show(); + virtual void hide(); + /*@}*/ - /** - @name accessors - */ - //@{ - bool isTorn() const { return torn; } - bool isVisible() const { return visible; } - const BScreen *screen() const { return m_screen; } - BScreen *screen() { return m_screen; } - Window windowID() const { return menu.window; } - const std::string &label() const { return menu.label; } - int x() const { return menu.x; } - int y() const { return menu.y; } - unsigned int width() const { return menu.width; } - unsigned int height() const { return menu.height; } - unsigned int numberOfItems() const { return menuitems.size(); } - int currentSubmenu() const { return which_sub; } - unsigned int titleHeight() const { return menu.title_h; } - bool hasSubmenu(unsigned int index) const; - bool isItemSelected(unsigned int index) const; - bool isItemEnabled(unsigned int index) const; - //@} + /** + @name accessors + */ + //@{ + bool isTorn() const { return torn; } + bool isVisible() const { return visible; } + const BScreen *screen() const { return m_screen; } + BScreen *screen() { return m_screen; } + Window windowID() const { return menu.window; } + const std::string &label() const { return menu.label; } + int x() const { return menu.x; } + int y() const { return menu.y; } + unsigned int width() const { return menu.width; } + unsigned int height() const { return menu.height; } + unsigned int numberOfItems() const { return menuitems.size(); } + int currentSubmenu() const { return which_sub; } + unsigned int titleHeight() const { return menu.title_h; } + bool hasSubmenu(unsigned int index) const; + bool isItemSelected(unsigned int index) const; + bool isItemEnabled(unsigned int index) const; + //@} protected: - inline BasemenuItem *find(unsigned int index) const { return menuitems[index]; } - inline void setTitleVisibility(bool b) { title_vis = b; } - inline void setMovable(bool b) { movable = b; } - inline void setHideTree(bool h) { hide_tree = h; } - inline void setMinimumSublevels(int m) { menu.minsub = m; } + inline BasemenuItem *find(unsigned int index) const { return menuitems[index]; } + inline void setTitleVisibility(bool b) { title_vis = b; } + inline void setMovable(bool b) { movable = b; } + inline void setHideTree(bool h) { hide_tree = h; } + inline void setMinimumSublevels(int m) { menu.minsub = m; } - virtual void itemSelected(int button, unsigned int index) = 0; - virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false, - int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); - virtual void redrawTitle(); - virtual void internal_hide(); - inline Basemenu *parent() { return m_parent; } - inline const Basemenu *parent() const { return m_parent; } + virtual void itemSelected(int button, unsigned int index) = 0; + virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false, + int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); + virtual void redrawTitle(); + virtual void internal_hide(); + inline Basemenu *parent() { return m_parent; } + inline const Basemenu *parent() const { return m_parent; } private: - typedef std::vector<BasemenuItem *> Menuitems; - BScreen *m_screen; - Display *m_display; - Basemenu *m_parent; - BImageControl *m_image_ctrl; - Menuitems menuitems; + typedef std::vector<BasemenuItem *> Menuitems; + BScreen *m_screen; + Display *m_display; + Basemenu *m_parent; + BImageControl *m_image_ctrl; + Menuitems menuitems; - bool moving, visible, movable, torn, internal_menu, title_vis, shifted, - hide_tree; + bool moving, visible, movable, torn, internal_menu, title_vis, shifted, + hide_tree; - int which_sub, which_press, which_sbl; - Alignment m_alignment; + int which_sub, which_press, which_sbl; + Alignment m_alignment; - struct _menu { - Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; - Window window, frame, title; + struct _menu { + Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; + Window window, frame, title; - std::string label; - int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, - grab_x, grab_y; - unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, - bevel_h; - } menu; + std::string label; + int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, + grab_x, grab_y; + unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, + bevel_h; + } menu; };

@@ -161,50 +161,50 @@ A menu item in Basemenu

*/ class BasemenuItem { public: - BasemenuItem( - const char *label, - int function, - const char *exec = (const char *) 0) - : m_label(label ? label : "") - , m_exec(exec ? exec : "") - , m_submenu(0) - , m_function(function) - , m_enabled(true) - , m_selected(false) + BasemenuItem( + const char *label, + int function, + const char *exec = (const char *) 0) + : m_label(label ? label : "") + , m_exec(exec ? exec : "") + , m_submenu(0) + , m_function(function) + , m_enabled(true) + , m_selected(false) { } - BasemenuItem(const char *label, Basemenu *submenu) - : m_label(label ? label : "") - , m_exec("") - , m_submenu(submenu) - , m_function(0) - , m_enabled(true) - , m_selected(false) + BasemenuItem(const char *label, Basemenu *submenu) + : m_label(label ? label : "") + , m_exec("") + , m_submenu(submenu) + , m_function(0) + , m_enabled(true) + , m_selected(false) { } - void setSelected(bool selected) { m_selected = selected; } - void setEnabled(bool enabled) { m_enabled = enabled; } - Basemenu *submenu() { return m_submenu; } - /** - @name accessors - */ - //@{ - const std::string &exec() const { return m_exec; } - const std::string &label() const { return m_label; } - int function() const { return m_function; } - const Basemenu *submenu() const { return m_submenu; } - bool isEnabled() const { return m_enabled; } - bool isSelected() const { return m_selected; } - //@} + void setSelected(bool selected) { m_selected = selected; } + void setEnabled(bool enabled) { m_enabled = enabled; } + Basemenu *submenu() { return m_submenu; } + /** + @name accessors + */ + //@{ + const std::string &exec() const { return m_exec; } + const std::string &label() const { return m_label; } + int function() const { return m_function; } + const Basemenu *submenu() const { return m_submenu; } + bool isEnabled() const { return m_enabled; } + bool isSelected() const { return m_selected; } + //@} private: - std::string m_label; ///< label of this item - std::string m_exec; ///< command string to execute - Basemenu *m_submenu; ///< a submenu, 0 if we don't have one - int m_function; - bool m_enabled, m_selected; + std::string m_label; ///< label of this item + std::string m_exec; ///< command string to execute + Basemenu *m_submenu; ///< a submenu, 0 if we don't have one + int m_function; + bool m_enabled, m_selected; - friend class Basemenu; + friend class Basemenu; };
M src/Clientmenu.ccsrc/Clientmenu.cc

@@ -39,28 +39,28 @@ #include "Workspacemenu.hh"

Clientmenu::Clientmenu(Workspace &ws) : Basemenu(ws.getScreen()), -m_wkspc(ws) { - setInternalMenu(); + m_wkspc(ws) { + setInternalMenu(); } void Clientmenu::itemSelected(int button, unsigned int index) { - if (button > 2) - return; - //get the window with index of the item we selected - FluxboxWindow *win = m_wkspc.getWindow(index); - if (win) { - if (button == 1) { - if (! m_wkspc.isCurrent()) - m_wkspc.setCurrent(); - } else if (button == 2) { - if (! m_wkspc.isCurrent()) - win->deiconify(true, false); - } - m_wkspc.raiseWindow(win); - win->setInputFocus(); - } + if (button > 2) + return; + //get the window with index of the item we selected + FluxboxWindow *win = m_wkspc.getWindow(index); + if (win) { + if (button == 1) { + if (! m_wkspc.isCurrent()) + m_wkspc.setCurrent(); + } else if (button == 2) { + if (! m_wkspc.isCurrent()) + win->deiconify(true, false); + } + m_wkspc.raiseWindow(win); + win->setInputFocus(); + } - if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); + if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) + hide(); }
M src/Clientmenu.hhsrc/Clientmenu.hh

@@ -28,13 +28,13 @@ class Workspace;

class Clientmenu: public Basemenu { public: - explicit Clientmenu(Workspace &wrksp); + explicit Clientmenu(Workspace &wrksp); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); private: - Workspace &m_wkspc; + Workspace &m_wkspc; };
M src/Configmenu.ccsrc/Configmenu.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Configmenu.cc,v 1.21 2002/11/30 20:10:09 fluxgen Exp $ +// $Id: Configmenu.cc,v 1.22 2002/12/01 13:41:55 rathnor Exp $ #include "Configmenu.hh"

@@ -39,86 +39,86 @@ #include "config.h"

#endif // HAVE_CONFIG_H enum {CMENU_USE_TABS=9, CMENU_USE_ICONS, CMENU_SLOPPY_WIN_GROUP, - CMENU_DESKTOP_WHEELING, CMENU_WORKSPACE_WARPING, CMENU_ANTIALIAS, CMENU_TAB_ROTATE=21}; + CMENU_DESKTOP_WHEELING, CMENU_WORKSPACE_WARPING, CMENU_ANTIALIAS, CMENU_TAB_ROTATE=21}; Configmenu::Configmenu(BScreen *scr) : Basemenu(scr), -m_focusmenu(scr), -m_placementmenu(scr), -m_tabmenu(scr) { + m_focusmenu(scr), + m_placementmenu(scr), + m_tabmenu(scr) { - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - setLabel(i18n->getMessage( - FBNLS::ConfigmenuSet, FBNLS::ConfigmenuConfigOptions, - "Config options")); + setLabel(i18n->getMessage( + FBNLS::ConfigmenuSet, FBNLS::ConfigmenuConfigOptions, + "Config options")); - setInternalMenu(); + setInternalMenu(); - using namespace FBNLS; - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuFocusModel, - "Focus Model"), &m_focusmenu); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuWindowPlacement, - "Window Placement"), &m_placementmenu); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuTabPlacement, - "Tab Placement"), &m_tabmenu); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuImageDithering, - "Image Dithering"), 1); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuOpaqueMove, - "Opaque Window Moving"), 2); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuFullMax, - "Full Maximization"), 3); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuFocusNew, - "Focus New Windows"), 4); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuFocusLast, - "Focus Last Window on Workspace"), 5); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuMaxOverSlit, - "Maximize Over Slit"), 6); + using namespace FBNLS; + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusModel, + "Focus Model"), &m_focusmenu); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuWindowPlacement, + "Window Placement"), &m_placementmenu); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuTabPlacement, + "Tab Placement"), &m_tabmenu); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuImageDithering, + "Image Dithering"), 1); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuOpaqueMove, + "Opaque Window Moving"), 2); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuFullMax, + "Full Maximization"), 3); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusNew, + "Focus New Windows"), 4); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusLast, + "Focus Last Window on Workspace"), 5); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuMaxOverSlit, + "Maximize Over Slit"), 6); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuTabs, + "Use Tabs"), CMENU_USE_TABS); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuIcons, + "Use Icons"), CMENU_USE_ICONS); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuSloppyWindowGrouping, + "Sloppy Window Grouping"), CMENU_SLOPPY_WIN_GROUP); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuWorkspaceWarping, + "Workspace Warping"), CMENU_WORKSPACE_WARPING); insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuTabs, - "Use Tabs"), CMENU_USE_TABS); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuIcons, - "Use Icons"), CMENU_USE_ICONS); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuSloppyWindowGrouping, - "Sloppy Window Grouping"), CMENU_SLOPPY_WIN_GROUP); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuWorkspaceWarping, - "Workspace Warping"), CMENU_WORKSPACE_WARPING); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuDesktopWheeling, - "Desktop MouseWheel Switching"), CMENU_DESKTOP_WHEELING); + ConfigmenuSet, ConfigmenuDesktopWheeling, + "Desktop MouseWheel Switching"), CMENU_DESKTOP_WHEELING); - //TODO: do we really need i18n support for this? + //TODO: do we really need i18n support for this? #ifdef USE_XFT - insert("Antialias", CMENU_ANTIALIAS); + insert("Antialias", CMENU_ANTIALIAS); #endif // USE_XFT - update(); - setItemSelected(8, screen()->doMaxOverSlit()); + update(); + setItemSelected(8, screen()->doMaxOverSlit()); - setItemSelected(3, screen()->getImageControl()->doDither()); - setItemSelected(4, screen()->doOpaqueMove()); - setItemSelected(5, screen()->doFullMax()); - setItemSelected(6, screen()->doFocusNew()); - setItemSelected(7, screen()->doFocusLast()); - setItemSelected(CMENU_USE_TABS, Fluxbox::instance()->useTabs()); - setItemSelected(CMENU_USE_ICONS, Fluxbox::instance()->useIconBar()); - setItemSelected(CMENU_SLOPPY_WIN_GROUP, screen()->isSloppyWindowGrouping()); - setItemSelected(CMENU_WORKSPACE_WARPING, screen()->isWorkspaceWarping()); - setItemSelected(CMENU_DESKTOP_WHEELING, screen()->isDesktopWheeling()); + setItemSelected(3, screen()->getImageControl()->doDither()); + setItemSelected(4, screen()->doOpaqueMove()); + setItemSelected(5, screen()->doFullMax()); + setItemSelected(6, screen()->doFocusNew()); + setItemSelected(7, screen()->doFocusLast()); + setItemSelected(CMENU_USE_TABS, Fluxbox::instance()->useTabs()); + setItemSelected(CMENU_USE_ICONS, Fluxbox::instance()->useIconBar()); + setItemSelected(CMENU_SLOPPY_WIN_GROUP, screen()->isSloppyWindowGrouping()); + setItemSelected(CMENU_WORKSPACE_WARPING, screen()->isWorkspaceWarping()); + setItemSelected(CMENU_DESKTOP_WHEELING, screen()->isDesktopWheeling()); #ifdef USE_XFT - setItemSelected(CMENU_ANTIALIAS, screen()->antialias()); + setItemSelected(CMENU_ANTIALIAS, screen()->antialias()); #endif // USE_XFT }

@@ -129,585 +129,585 @@ }

void Configmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); + if (button == 1) { + BasemenuItem *item = find(index); - if (item->function()) - switch(item->function()) { - case 1: // dither - screen()->getImageControl()-> - setDither((! screen()->getImageControl()->doDither())); + if (item->function()) + switch(item->function()) { + case 1: // dither + screen()->getImageControl()-> + setDither((! screen()->getImageControl()->doDither())); - setItemSelected(index, screen()->getImageControl()->doDither()); + setItemSelected(index, screen()->getImageControl()->doDither()); - break; + break; - case 2: // opaque move - screen()->saveOpaqueMove((! screen()->doOpaqueMove())); + case 2: // opaque move + screen()->saveOpaqueMove((! screen()->doOpaqueMove())); - setItemSelected(index, screen()->doOpaqueMove()); + setItemSelected(index, screen()->doOpaqueMove()); - break; + break; - case 3: // full maximization - screen()->saveFullMax((! screen()->doFullMax())); + case 3: // full maximization + screen()->saveFullMax((! screen()->doFullMax())); - setItemSelected(index, screen()->doFullMax()); + setItemSelected(index, screen()->doFullMax()); - break; - case 4: // focus new windows - screen()->saveFocusNew((! screen()->doFocusNew())); + break; + case 4: // focus new windows + screen()->saveFocusNew((! screen()->doFocusNew())); - setItemSelected(index, screen()->doFocusNew()); - break; + setItemSelected(index, screen()->doFocusNew()); + break; - case 6: // maximize over slit - screen()->saveMaxOverSlit( !screen()->doMaxOverSlit() ); - setItemSelected(index, screen()->doMaxOverSlit()); - break; + case 6: // maximize over slit + screen()->saveMaxOverSlit( !screen()->doMaxOverSlit() ); + setItemSelected(index, screen()->doMaxOverSlit()); + break; - case 5: // focus last window on workspace - screen()->saveFocusLast((! screen()->doFocusLast())); - setItemSelected(index, screen()->doFocusLast()); - break; - case CMENU_USE_TABS: - { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->saveTabs(!fluxbox->useTabs()); - setItemSelected(index, fluxbox->useTabs()); - screen()->reconfigure(); - } - break; - case CMENU_USE_ICONS: - { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->saveIconBar(!fluxbox->useIconBar()); - setItemSelected(index, fluxbox->useIconBar()); - screen()->reconfigure(); - } - break; - case CMENU_SLOPPY_WIN_GROUP: - { - screen()->saveSloppyWindowGrouping(!screen()->isSloppyWindowGrouping()); - setItemSelected(index, screen()->isSloppyWindowGrouping()); - screen()->reconfigure(); - } - break; - case CMENU_WORKSPACE_WARPING: - { - screen()->saveWorkspaceWarping(!screen()->isWorkspaceWarping()); - setItemSelected(index, screen()->isWorkspaceWarping()); - screen()->reconfigure(); - } - break; - case CMENU_DESKTOP_WHEELING: - { - screen()->saveDesktopWheeling(!screen()->isDesktopWheeling()); - setItemSelected(index, screen()->isDesktopWheeling()); - screen()->reconfigure(); - } - break; + case 5: // focus last window on workspace + screen()->saveFocusLast((! screen()->doFocusLast())); + setItemSelected(index, screen()->doFocusLast()); + break; + case CMENU_USE_TABS: + { + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->saveTabs(!fluxbox->useTabs()); + setItemSelected(index, fluxbox->useTabs()); + screen()->reconfigure(); + } + break; + case CMENU_USE_ICONS: + { + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->saveIconBar(!fluxbox->useIconBar()); + setItemSelected(index, fluxbox->useIconBar()); + screen()->reconfigure(); + } + break; + case CMENU_SLOPPY_WIN_GROUP: + { + screen()->saveSloppyWindowGrouping(!screen()->isSloppyWindowGrouping()); + setItemSelected(index, screen()->isSloppyWindowGrouping()); + screen()->reconfigure(); + } + break; + case CMENU_WORKSPACE_WARPING: + { + screen()->saveWorkspaceWarping(!screen()->isWorkspaceWarping()); + setItemSelected(index, screen()->isWorkspaceWarping()); + screen()->reconfigure(); + } + break; + case CMENU_DESKTOP_WHEELING: + { + screen()->saveDesktopWheeling(!screen()->isDesktopWheeling()); + setItemSelected(index, screen()->isDesktopWheeling()); + screen()->reconfigure(); + } + break; #ifdef USE_XFT - case CMENU_ANTIALIAS: + case CMENU_ANTIALIAS: // Note: no need to reconfigure here, screen reconfigures if antialias changes - screen()->setAntialias(!screen()->antialias()); - setItemSelected(index, screen()->antialias()); - break; + screen()->setAntialias(!screen()->antialias()); + setItemSelected(index, screen()->antialias()); + break; #endif // USE_XFT - } - //save resources - Fluxbox::instance()->save_rc(); + } + //save resources + Fluxbox::instance()->save_rc(); - } + } } void Configmenu::reconfigure() { - m_focusmenu.reconfigure(); - m_placementmenu.reconfigure(); - m_tabmenu.reconfigure(); + m_focusmenu.reconfigure(); + m_placementmenu.reconfigure(); + m_tabmenu.reconfigure(); - Basemenu::reconfigure(); + Basemenu::reconfigure(); } Configmenu::Focusmenu::Focusmenu(BScreen *scr) : Basemenu(scr) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - ConfigmenuSet, ConfigmenuFocusModel, - "Focus Model")); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + ConfigmenuSet, ConfigmenuFocusModel, + "Focus Model")); + setInternalMenu(); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuClickToFocus, - "Click To Focus"), 1); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuSloppyFocus, - "Sloppy Focus"), 2); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuSemiSloppyFocus, - "Semi Sloppy Focus"), 3); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuAutoRaise, - "Auto Raise"), 4); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuClickToFocus, + "Click To Focus"), 1); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuSloppyFocus, + "Sloppy Focus"), 2); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuSemiSloppyFocus, + "Semi Sloppy Focus"), 3); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuAutoRaise, + "Auto Raise"), 4); - update(); + update(); - setItemSelected(0, !(screen()->isSloppyFocus() || - screen()->isSemiSloppyFocus())); - setItemSelected(1, screen()->isSloppyFocus()); - setItemSelected(2, screen()->isSemiSloppyFocus()); - setItemEnabled(3, (screen()->isSloppyFocus() || - screen()->isSemiSloppyFocus())); - setItemSelected(3, screen()->doAutoRaise()); + setItemSelected(0, !(screen()->isSloppyFocus() || + screen()->isSemiSloppyFocus())); + setItemSelected(1, screen()->isSloppyFocus()); + setItemSelected(2, screen()->isSemiSloppyFocus()); + setItemEnabled(3, (screen()->isSloppyFocus() || + screen()->isSemiSloppyFocus())); + setItemSelected(3, screen()->doAutoRaise()); } void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); + if (button == 1) { + BasemenuItem *item = find(index); - if (item->function()) { - switch (item->function()) { - case 1: // click to focus - screen()->saveSloppyFocus(False); - screen()->saveSemiSloppyFocus(False); - screen()->saveAutoRaise(False); + if (item->function()) { + switch (item->function()) { + case 1: // click to focus + screen()->saveSloppyFocus(False); + screen()->saveSemiSloppyFocus(False); + screen()->saveAutoRaise(False); - if (! Fluxbox::instance()->getFocusedWindow()) { - XSetInputFocus(Fluxbox::instance()->getXDisplay(), - screen()->getToolbar()->getWindowID(), - RevertToParent, CurrentTime); - } else { - XSetInputFocus(Fluxbox::instance()->getXDisplay(), - Fluxbox::instance()->getFocusedWindow()->getClientWindow(), - RevertToParent, CurrentTime); - } + if (! Fluxbox::instance()->getFocusedWindow()) { + XSetInputFocus(Fluxbox::instance()->getXDisplay(), + screen()->getToolbar()->getWindowID(), + RevertToParent, CurrentTime); + } else { + XSetInputFocus(Fluxbox::instance()->getXDisplay(), + Fluxbox::instance()->getFocusedWindow()->getClientWindow(), + RevertToParent, CurrentTime); + } - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case 2: // sloppy focus - screen()->saveSemiSloppyFocus(False); - screen()->saveSloppyFocus(True); + case 2: // sloppy focus + screen()->saveSemiSloppyFocus(False); + screen()->saveSloppyFocus(True); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case 3: // semi sloppy focus - screen()->saveSloppyFocus(False); - screen()->saveSemiSloppyFocus(True); + case 3: // semi sloppy focus + screen()->saveSloppyFocus(False); + screen()->saveSemiSloppyFocus(True); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case 4: // auto raise with sloppy focus - Bool change = ((screen()->doAutoRaise()) ? False : True); - screen()->saveAutoRaise(change); + case 4: // auto raise with sloppy focus + Bool change = ((screen()->doAutoRaise()) ? False : True); + screen()->saveAutoRaise(change); - break; - } - //save resources - Fluxbox::instance()->save_rc(); + break; + } + //save resources + Fluxbox::instance()->save_rc(); - //toggle options - setItemSelected(0, !(screen()->isSloppyFocus() || - screen()->isSemiSloppyFocus())); - setItemSelected(1, screen()->isSloppyFocus()); - setItemSelected(2, screen()->isSemiSloppyFocus()); - setItemEnabled(3, (screen()->isSloppyFocus() || - screen()->isSemiSloppyFocus())); - setItemSelected(3, screen()->doAutoRaise()); - } - } + //toggle options + setItemSelected(0, !(screen()->isSloppyFocus() || + screen()->isSemiSloppyFocus())); + setItemSelected(1, screen()->isSloppyFocus()); + setItemSelected(2, screen()->isSemiSloppyFocus()); + setItemEnabled(3, (screen()->isSloppyFocus() || + screen()->isSemiSloppyFocus())); + setItemSelected(3, screen()->doAutoRaise()); + } + } } Configmenu::Placementmenu::Placementmenu(BScreen *scr) : Basemenu(scr) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - ConfigmenuSet, ConfigmenuWindowPlacement, - "Window Placement")); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + ConfigmenuSet, ConfigmenuWindowPlacement, + "Window Placement")); + setInternalMenu(); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuSmartRows, - "Smart Placement (Rows)"), BScreen::ROWSMARTPLACEMENT); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuSmartCols, - "Smart Placement (Columns)"), BScreen::COLSMARTPLACEMENT); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuCascade, - "Cascade Placement"), BScreen::CASCADEPLACEMENT); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuLeftRight, - "Left to Right"), BScreen::LEFTRIGHT); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuRightLeft, - "Right to Left"), BScreen::RIGHTLEFT); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuTopBottom, - "Top to Bottom"), BScreen::TOPBOTTOM); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuBottomTop, - "Bottom to Top"), BScreen::BOTTOMTOP); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuSmartRows, + "Smart Placement (Rows)"), BScreen::ROWSMARTPLACEMENT); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuSmartCols, + "Smart Placement (Columns)"), BScreen::COLSMARTPLACEMENT); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuCascade, + "Cascade Placement"), BScreen::CASCADEPLACEMENT); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuLeftRight, + "Left to Right"), BScreen::LEFTRIGHT); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuRightLeft, + "Right to Left"), BScreen::RIGHTLEFT); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuTopBottom, + "Top to Bottom"), BScreen::TOPBOTTOM); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuBottomTop, + "Bottom to Top"), BScreen::BOTTOMTOP); - update(); + update(); - switch (screen()->getPlacementPolicy()) { - case BScreen::ROWSMARTPLACEMENT: - setItemSelected(0, true); - break; + switch (screen()->getPlacementPolicy()) { + case BScreen::ROWSMARTPLACEMENT: + setItemSelected(0, true); + break; - case BScreen::COLSMARTPLACEMENT: - setItemSelected(1, true); - break; + case BScreen::COLSMARTPLACEMENT: + setItemSelected(1, true); + break; - case BScreen::CASCADEPLACEMENT: - setItemSelected(2, true); - break; - } + case BScreen::CASCADEPLACEMENT: + setItemSelected(2, true); + break; + } - bool rl = (screen()->getRowPlacementDirection() == - BScreen::LEFTRIGHT), - tb = (screen()->getColPlacementDirection() == - BScreen::TOPBOTTOM); + bool rl = (screen()->getRowPlacementDirection() == + BScreen::LEFTRIGHT), + tb = (screen()->getColPlacementDirection() == + BScreen::TOPBOTTOM); - setItemSelected(3, rl); - setItemSelected(4, ! rl); + setItemSelected(3, rl); + setItemSelected(4, ! rl); - setItemSelected(5, tb); - setItemSelected(6, ! tb); + setItemSelected(5, tb); + setItemSelected(6, ! tb); } void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); + if (button == 1) { + BasemenuItem *item = find(index); - if (item->function()) { - switch (item->function()) { - case BScreen::ROWSMARTPLACEMENT: - screen()->savePlacementPolicy(item->function()); + if (item->function()) { + switch (item->function()) { + case BScreen::ROWSMARTPLACEMENT: + screen()->savePlacementPolicy(item->function()); - setItemSelected(0, true); - setItemSelected(1, false); - setItemSelected(2, false); + setItemSelected(0, true); + setItemSelected(1, false); + setItemSelected(2, false); - break; + break; - case BScreen::COLSMARTPLACEMENT: - screen()->savePlacementPolicy(item->function()); + case BScreen::COLSMARTPLACEMENT: + screen()->savePlacementPolicy(item->function()); - setItemSelected(0, false); - setItemSelected(1, true); - setItemSelected(2, false); + setItemSelected(0, false); + setItemSelected(1, true); + setItemSelected(2, false); - break; + break; - case BScreen::CASCADEPLACEMENT: - screen()->savePlacementPolicy(item->function()); + case BScreen::CASCADEPLACEMENT: + screen()->savePlacementPolicy(item->function()); - setItemSelected(0, false); - setItemSelected(1, false); - setItemSelected(2, true); + setItemSelected(0, false); + setItemSelected(1, false); + setItemSelected(2, true); - break; + break; - case BScreen::LEFTRIGHT: - screen()->saveRowPlacementDirection(BScreen::LEFTRIGHT); + case BScreen::LEFTRIGHT: + screen()->saveRowPlacementDirection(BScreen::LEFTRIGHT); - setItemSelected(3, true); - setItemSelected(4, false); + setItemSelected(3, true); + setItemSelected(4, false); - break; + break; - case BScreen::RIGHTLEFT: - screen()->saveRowPlacementDirection(BScreen::RIGHTLEFT); + case BScreen::RIGHTLEFT: + screen()->saveRowPlacementDirection(BScreen::RIGHTLEFT); - setItemSelected(3, false); - setItemSelected(4, true); + setItemSelected(3, false); + setItemSelected(4, true); - break; + break; - case BScreen::TOPBOTTOM: - screen()->saveColPlacementDirection(BScreen::TOPBOTTOM); + case BScreen::TOPBOTTOM: + screen()->saveColPlacementDirection(BScreen::TOPBOTTOM); - setItemSelected(5, true); - setItemSelected(6, false); + setItemSelected(5, true); + setItemSelected(6, false); - break; + break; - case BScreen::BOTTOMTOP: - screen()->saveColPlacementDirection(BScreen::BOTTOMTOP); + case BScreen::BOTTOMTOP: + screen()->saveColPlacementDirection(BScreen::BOTTOMTOP); - setItemSelected(5, false); - setItemSelected(6, true); + setItemSelected(5, false); + setItemSelected(6, true); - break; - } - //save resources - Fluxbox::instance()->save_rc(); - } - } + break; + } + //save resources + Fluxbox::instance()->save_rc(); + } + } } Configmenu::Tabmenu::Tabmenu(BScreen *scr) : Basemenu(scr) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; + I18n *i18n = I18n::instance(); + using namespace FBNLS; - setLabel(i18n->getMessage( - ConfigmenuSet, ConfigmenuTabPlacement, - "Tab Placement")); - setInternalMenu(); + setLabel(i18n->getMessage( + ConfigmenuSet, ConfigmenuTabPlacement, + "Tab Placement")); + setInternalMenu(); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopLeft, - "Top Left"), Tab::PTOP + Tab::ALEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopCenter, - "Top Center"), Tab::PTOP + Tab::ACENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopRight, - "Top Right"), Tab::PTOP + Tab::ARIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopRelative, - "Top Relative"), Tab::PTOP + Tab::ARELATIVE); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomLeft, - "Bottom Left"), Tab::PBOTTOM + Tab::ALEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomCenter, - "Bottom Center"), Tab::PBOTTOM + Tab::ACENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomRight, - "Bottom Right"), Tab::PBOTTOM + Tab::ARIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomRelative, - "Bottom Relative"), Tab::PBOTTOM + Tab::ARELATIVE); - insert(i18n->getMessage( - CommonSet, CommonPlacementLeftTop, - "Left Top"), Tab::PLEFT + Tab::ARIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementLeftCenter, - "Left Center"), Tab::PLEFT + Tab::ACENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementLeftBottom, - "Left Bottom"), Tab::PLEFT + Tab::ALEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementLeftRelative, - "Left Relative"), Tab::PLEFT + Tab::ARELATIVE); - insert(i18n->getMessage( - CommonSet, CommonPlacementRightTop, - "Right Top"), Tab::PRIGHT + Tab::ARIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementRightCenter, - "Right Center"), Tab::PRIGHT + Tab::ACENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementRightBottom, - "Right Bottom"), Tab::PRIGHT + Tab::ALEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementRightRelative, - "Right Relative"), Tab::PRIGHT + Tab::ARELATIVE); - insert(i18n->getMessage( - ConfigmenuSet, ConfigmenuTabRotateVertical, - "Rotate Vertical Tabs"), CMENU_TAB_ROTATE); - update(); - setSelected(); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopLeft, + "Top Left"), Tab::PTOP + Tab::ALEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopCenter, + "Top Center"), Tab::PTOP + Tab::ACENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopRight, + "Top Right"), Tab::PTOP + Tab::ARIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopRelative, + "Top Relative"), Tab::PTOP + Tab::ARELATIVE); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomLeft, + "Bottom Left"), Tab::PBOTTOM + Tab::ALEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomCenter, + "Bottom Center"), Tab::PBOTTOM + Tab::ACENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomRight, + "Bottom Right"), Tab::PBOTTOM + Tab::ARIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomRelative, + "Bottom Relative"), Tab::PBOTTOM + Tab::ARELATIVE); + insert(i18n->getMessage( + CommonSet, CommonPlacementLeftTop, + "Left Top"), Tab::PLEFT + Tab::ARIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementLeftCenter, + "Left Center"), Tab::PLEFT + Tab::ACENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementLeftBottom, + "Left Bottom"), Tab::PLEFT + Tab::ALEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementLeftRelative, + "Left Relative"), Tab::PLEFT + Tab::ARELATIVE); + insert(i18n->getMessage( + CommonSet, CommonPlacementRightTop, + "Right Top"), Tab::PRIGHT + Tab::ARIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementRightCenter, + "Right Center"), Tab::PRIGHT + Tab::ACENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementRightBottom, + "Right Bottom"), Tab::PRIGHT + Tab::ALEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementRightRelative, + "Right Relative"), Tab::PRIGHT + Tab::ARELATIVE); + insert(i18n->getMessage( + ConfigmenuSet, ConfigmenuTabRotateVertical, + "Rotate Vertical Tabs"), CMENU_TAB_ROTATE); + update(); + setSelected(); } void Configmenu::Tabmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - #ifdef DEBUG - fprintf(stderr, "Item(%d)\n", index); - #endif - BasemenuItem *item = find(index); + if (button == 1) { +#ifdef DEBUG + fprintf(stderr, "Item(%d)\n", index); +#endif + BasemenuItem *item = find(index); - switch (item->function()) { - case (Tab::PTOP + Tab::ALEFT): - screen()->saveTabPlacement(Tab::PTOP); - screen()->saveTabAlignment(Tab::ALEFT); + switch (item->function()) { + case (Tab::PTOP + Tab::ALEFT): + screen()->saveTabPlacement(Tab::PTOP); + screen()->saveTabAlignment(Tab::ALEFT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PTOP + Tab::ACENTER): - screen()->saveTabPlacement(Tab::PTOP); - screen()->saveTabAlignment(Tab::ACENTER); + case (Tab::PTOP + Tab::ACENTER): + screen()->saveTabPlacement(Tab::PTOP); + screen()->saveTabAlignment(Tab::ACENTER); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PTOP + Tab::ARIGHT): - screen()->saveTabPlacement(Tab::PTOP); - screen()->saveTabAlignment(Tab::ARIGHT); + case (Tab::PTOP + Tab::ARIGHT): + screen()->saveTabPlacement(Tab::PTOP); + screen()->saveTabAlignment(Tab::ARIGHT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PTOP + Tab::ARELATIVE): - screen()->saveTabPlacement(Tab::PTOP); - screen()->saveTabAlignment(Tab::ARELATIVE); + case (Tab::PTOP + Tab::ARELATIVE): + screen()->saveTabPlacement(Tab::PTOP); + screen()->saveTabAlignment(Tab::ARELATIVE); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PBOTTOM + Tab::ALEFT): - screen()->saveTabPlacement(Tab::PBOTTOM); - screen()->saveTabAlignment(Tab::ALEFT); + case (Tab::PBOTTOM + Tab::ALEFT): + screen()->saveTabPlacement(Tab::PBOTTOM); + screen()->saveTabAlignment(Tab::ALEFT); - screen()->reconfigure(); + screen()->reconfigure(); - break; - case (Tab::PBOTTOM + Tab::ACENTER): - screen()->saveTabPlacement(Tab::PBOTTOM); - screen()->saveTabAlignment(Tab::ACENTER); + break; + case (Tab::PBOTTOM + Tab::ACENTER): + screen()->saveTabPlacement(Tab::PBOTTOM); + screen()->saveTabAlignment(Tab::ACENTER); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PBOTTOM + Tab::ARIGHT): - screen()->saveTabPlacement(Tab::PBOTTOM); - screen()->saveTabAlignment(Tab::ARIGHT); + case (Tab::PBOTTOM + Tab::ARIGHT): + screen()->saveTabPlacement(Tab::PBOTTOM); + screen()->saveTabAlignment(Tab::ARIGHT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PBOTTOM + Tab::ARELATIVE): - screen()->saveTabPlacement(Tab::PBOTTOM); - screen()->saveTabAlignment(Tab::ARELATIVE); + case (Tab::PBOTTOM + Tab::ARELATIVE): + screen()->saveTabPlacement(Tab::PBOTTOM); + screen()->saveTabAlignment(Tab::ARELATIVE); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PLEFT + Tab::ARIGHT): - screen()->saveTabPlacement(Tab::PLEFT); - screen()->saveTabAlignment(Tab::ARIGHT); + case (Tab::PLEFT + Tab::ARIGHT): + screen()->saveTabPlacement(Tab::PLEFT); + screen()->saveTabAlignment(Tab::ARIGHT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PLEFT + Tab::ACENTER): - screen()->saveTabPlacement(Tab::PLEFT); - screen()->saveTabAlignment(Tab::ACENTER); + case (Tab::PLEFT + Tab::ACENTER): + screen()->saveTabPlacement(Tab::PLEFT); + screen()->saveTabAlignment(Tab::ACENTER); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PLEFT + Tab::ALEFT): - screen()->saveTabPlacement(Tab::PLEFT); - screen()->saveTabAlignment(Tab::ALEFT); + case (Tab::PLEFT + Tab::ALEFT): + screen()->saveTabPlacement(Tab::PLEFT); + screen()->saveTabAlignment(Tab::ALEFT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PLEFT + Tab::ARELATIVE): - screen()->saveTabPlacement(Tab::PLEFT); - screen()->saveTabAlignment(Tab::ARELATIVE); + case (Tab::PLEFT + Tab::ARELATIVE): + screen()->saveTabPlacement(Tab::PLEFT); + screen()->saveTabAlignment(Tab::ARELATIVE); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PRIGHT + Tab::ARIGHT): - screen()->saveTabPlacement(Tab::PRIGHT); - screen()->saveTabAlignment(Tab::ARIGHT); + case (Tab::PRIGHT + Tab::ARIGHT): + screen()->saveTabPlacement(Tab::PRIGHT); + screen()->saveTabAlignment(Tab::ARIGHT); - screen()->reconfigure(); + screen()->reconfigure(); - break; - case (Tab::PRIGHT + Tab::ACENTER): - screen()->saveTabPlacement(Tab::PRIGHT); - screen()->saveTabAlignment(Tab::ACENTER); + break; + case (Tab::PRIGHT + Tab::ACENTER): + screen()->saveTabPlacement(Tab::PRIGHT); + screen()->saveTabAlignment(Tab::ACENTER); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PRIGHT + Tab::ALEFT): - screen()->saveTabPlacement(Tab::PRIGHT); - screen()->saveTabAlignment(Tab::ALEFT); + case (Tab::PRIGHT + Tab::ALEFT): + screen()->saveTabPlacement(Tab::PRIGHT); + screen()->saveTabAlignment(Tab::ALEFT); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case (Tab::PRIGHT + Tab::ARELATIVE): - screen()->saveTabPlacement(Tab::PRIGHT); - screen()->saveTabAlignment(Tab::ARELATIVE); + case (Tab::PRIGHT + Tab::ARELATIVE): + screen()->saveTabPlacement(Tab::PRIGHT); + screen()->saveTabAlignment(Tab::ARELATIVE); - screen()->reconfigure(); + screen()->reconfigure(); - break; + break; - case CMENU_TAB_ROTATE: - if (screen()->isTabRotateVertical()) - screen()->saveTabRotateVertical(False); - else - screen()->saveTabRotateVertical(True); - break; - } - //save resources - Fluxbox::instance()->save_rc(); - Fluxbox::instance()->reconfigureTabs(); //TODO - setSelected(); - } + case CMENU_TAB_ROTATE: + if (screen()->isTabRotateVertical()) + screen()->saveTabRotateVertical(False); + else + screen()->saveTabRotateVertical(True); + break; + } + //save resources + Fluxbox::instance()->save_rc(); + Fluxbox::instance()->reconfigureTabs(); //TODO + setSelected(); + } } void Configmenu::Tabmenu::setSelected() { - setItemSelected(0, (screen()->getTabPlacement() == Tab::PTOP && - screen()->getTabAlignment() == Tab::ALEFT)); - setItemSelected(1, (screen()->getTabPlacement() == Tab::PTOP && - screen()->getTabAlignment() == Tab::ACENTER)); - setItemSelected(2, (screen()->getTabPlacement() == Tab::PTOP && - screen()->getTabAlignment() == Tab::ARIGHT)); - setItemSelected(3, (screen()->getTabPlacement() == Tab::PTOP && - screen()->getTabAlignment() == Tab::ARELATIVE)); - setItemSelected(4, (screen()->getTabPlacement() == Tab::PBOTTOM && - screen()->getTabAlignment() == Tab::ALEFT)); - setItemSelected(5, (screen()->getTabPlacement() == Tab::PBOTTOM && - screen()->getTabAlignment() == Tab::ACENTER)); - setItemSelected(6, (screen()->getTabPlacement() == Tab::PBOTTOM && - screen()->getTabAlignment() == Tab::ARIGHT)); - setItemSelected(7, (screen()->getTabPlacement() == Tab::PBOTTOM && - screen()->getTabAlignment() == Tab::ARELATIVE)); - setItemSelected(8, (screen()->getTabPlacement() == Tab::PLEFT && - screen()->getTabAlignment() == Tab::ARIGHT)); - setItemSelected(9, (screen()->getTabPlacement() == Tab::PLEFT && - screen()->getTabAlignment() == Tab::ACENTER)); - setItemSelected(10, (screen()->getTabPlacement() == Tab::PLEFT && - screen()->getTabAlignment() == Tab::ALEFT)); - setItemSelected(11, (screen()->getTabPlacement() == Tab::PLEFT && - screen()->getTabAlignment() == Tab::ARELATIVE)); - setItemSelected(12, (screen()->getTabPlacement() == Tab::PRIGHT && - screen()->getTabAlignment() == Tab::ARIGHT)); - setItemSelected(13, (screen()->getTabPlacement() == Tab::PRIGHT && - screen()->getTabAlignment() == Tab::ACENTER)); - setItemSelected(14, (screen()->getTabPlacement() == Tab::PRIGHT && - screen()->getTabAlignment() == Tab::ALEFT)); - setItemSelected(15, (screen()->getTabPlacement() == Tab::PRIGHT && - screen()->getTabAlignment() == Tab::ARELATIVE)); - setItemEnabled(16, (screen()->getTabPlacement() == Tab::PLEFT || - screen()->getTabPlacement() == Tab::PRIGHT)); - setItemSelected(16, (screen()->isTabRotateVertical() && - (screen()->getTabPlacement() == Tab::PLEFT || - screen()->getTabPlacement() == Tab::PRIGHT))); + setItemSelected(0, (screen()->getTabPlacement() == Tab::PTOP && + screen()->getTabAlignment() == Tab::ALEFT)); + setItemSelected(1, (screen()->getTabPlacement() == Tab::PTOP && + screen()->getTabAlignment() == Tab::ACENTER)); + setItemSelected(2, (screen()->getTabPlacement() == Tab::PTOP && + screen()->getTabAlignment() == Tab::ARIGHT)); + setItemSelected(3, (screen()->getTabPlacement() == Tab::PTOP && + screen()->getTabAlignment() == Tab::ARELATIVE)); + setItemSelected(4, (screen()->getTabPlacement() == Tab::PBOTTOM && + screen()->getTabAlignment() == Tab::ALEFT)); + setItemSelected(5, (screen()->getTabPlacement() == Tab::PBOTTOM && + screen()->getTabAlignment() == Tab::ACENTER)); + setItemSelected(6, (screen()->getTabPlacement() == Tab::PBOTTOM && + screen()->getTabAlignment() == Tab::ARIGHT)); + setItemSelected(7, (screen()->getTabPlacement() == Tab::PBOTTOM && + screen()->getTabAlignment() == Tab::ARELATIVE)); + setItemSelected(8, (screen()->getTabPlacement() == Tab::PLEFT && + screen()->getTabAlignment() == Tab::ARIGHT)); + setItemSelected(9, (screen()->getTabPlacement() == Tab::PLEFT && + screen()->getTabAlignment() == Tab::ACENTER)); + setItemSelected(10, (screen()->getTabPlacement() == Tab::PLEFT && + screen()->getTabAlignment() == Tab::ALEFT)); + setItemSelected(11, (screen()->getTabPlacement() == Tab::PLEFT && + screen()->getTabAlignment() == Tab::ARELATIVE)); + setItemSelected(12, (screen()->getTabPlacement() == Tab::PRIGHT && + screen()->getTabAlignment() == Tab::ARIGHT)); + setItemSelected(13, (screen()->getTabPlacement() == Tab::PRIGHT && + screen()->getTabAlignment() == Tab::ACENTER)); + setItemSelected(14, (screen()->getTabPlacement() == Tab::PRIGHT && + screen()->getTabAlignment() == Tab::ALEFT)); + setItemSelected(15, (screen()->getTabPlacement() == Tab::PRIGHT && + screen()->getTabAlignment() == Tab::ARELATIVE)); + setItemEnabled(16, (screen()->getTabPlacement() == Tab::PLEFT || + screen()->getTabPlacement() == Tab::PRIGHT)); + setItemSelected(16, (screen()->isTabRotateVertical() && + (screen()->getTabPlacement() == Tab::PLEFT || + screen()->getTabPlacement() == Tab::PRIGHT))); }
M src/Configmenu.hhsrc/Configmenu.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Configmenu.hh,v 1.6 2002/10/15 09:50:38 fluxgen Exp $ +// $Id: Configmenu.hh,v 1.7 2002/12/01 13:41:55 rathnor Exp $ #ifndef CONFIGMENU_HH #define CONFIGMENU_HH

@@ -33,50 +33,50 @@ class BScreen;

class Configmenu : public Basemenu { public: - explicit Configmenu(BScreen *scr); - virtual ~Configmenu(); + explicit Configmenu(BScreen *scr); + virtual ~Configmenu(); - Basemenu &focusmenu() { return m_focusmenu; } - Basemenu &getPlacementmenu() { return m_placementmenu; } - Basemenu &getTabmenu() { return m_tabmenu; } + Basemenu &focusmenu() { return m_focusmenu; } + Basemenu &getPlacementmenu() { return m_placementmenu; } + Basemenu &getTabmenu() { return m_tabmenu; } - const Basemenu &focusmenu() const { return m_focusmenu; } - const Basemenu &placementmenu() const { return m_placementmenu; } - const Basemenu &tabmenu() const { return m_tabmenu; } + const Basemenu &focusmenu() const { return m_focusmenu; } + const Basemenu &placementmenu() const { return m_placementmenu; } + const Basemenu &tabmenu() const { return m_tabmenu; } - void reconfigure(); + void reconfigure(); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); private: - class Focusmenu : public Basemenu { - public: - explicit Focusmenu(BScreen *scr); - protected: - virtual void itemSelected(int button, unsigned int index); - }; + class Focusmenu : public Basemenu { + public: + explicit Focusmenu(BScreen *scr); + protected: + virtual void itemSelected(int button, unsigned int index); + }; - class Placementmenu : public Basemenu { - public: - explicit Placementmenu(BScreen *scr); + class Placementmenu : public Basemenu { + public: + explicit Placementmenu(BScreen *scr); - protected: - virtual void itemSelected(int button, unsigned int index); - }; + protected: + virtual void itemSelected(int button, unsigned int index); + }; - class Tabmenu : public Basemenu { - public: - explicit Tabmenu(BScreen *scr); - protected: - virtual void itemSelected(int button, unsigned int index); - private: - void setSelected(); - }; + class Tabmenu : public Basemenu { + public: + explicit Tabmenu(BScreen *scr); + protected: + virtual void itemSelected(int button, unsigned int index); + private: + void setSelected(); + }; - Focusmenu m_focusmenu; - Placementmenu m_placementmenu; - Tabmenu m_tabmenu; + Focusmenu m_focusmenu; + Placementmenu m_placementmenu; + Tabmenu m_tabmenu; };
M src/DrawUtil.ccsrc/DrawUtil.cc

@@ -19,43 +19,43 @@ // 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. -// $Id: DrawUtil.cc,v 1.10 2002/11/26 15:50:46 fluxgen Exp $ +// $Id: DrawUtil.cc,v 1.11 2002/12/01 13:41:55 rathnor Exp $ #include "DrawUtil.hh" namespace DrawUtil { int doAlignment(int max_width, int bevel, Font::FontJustify justify, - const FbTk::Font &font, const char * const text, size_t textlen, size_t &newlen) { + const FbTk::Font &font, const char * const text, size_t textlen, size_t &newlen) { - if (text == 0 || textlen == 0) - return 0; + if (text == 0 || textlen == 0) + return 0; - int l = font.textWidth(text, textlen) + bevel; - size_t dlen = textlen; - int dx = bevel; - if (l > max_width) { - for (; dlen > 0; dlen--) { - l = font.textWidth(text, dlen) + bevel; - if (l<=max_width) - break; - } - } + int l = font.textWidth(text, textlen) + bevel; + size_t dlen = textlen; + int dx = bevel; + if (l > max_width) { + for (; dlen > 0; dlen--) { + l = font.textWidth(text, dlen) + bevel; + if (l<=max_width) + break; + } + } - newlen = dlen; + newlen = dlen; - switch (justify) { - case DrawUtil::Font::RIGHT: - dx = max_width - l - bevel; + switch (justify) { + case DrawUtil::Font::RIGHT: + dx = max_width - l - bevel; break; - case DrawUtil::Font::CENTER: - dx = (max_width - l)/2; + case DrawUtil::Font::CENTER: + dx = (max_width - l)/2; break; - case DrawUtil::Font::LEFT: + case DrawUtil::Font::LEFT: break; - } + } - return dx; + return dx; } }; //end namespace DrawUtil
M src/DrawUtil.hhsrc/DrawUtil.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: DrawUtil.hh,v 1.9 2002/11/26 15:45:48 fluxgen Exp $ +// $Id: DrawUtil.hh,v 1.10 2002/12/01 13:41:55 rathnor Exp $ #ifndef DRAWUTIL_HH #define DRAWUTIL_HH

@@ -28,17 +28,17 @@ #include <X11/Xlib.h>

#include "Font.hh" namespace DrawUtil { - // note: obsolete! - struct Font { - enum FontJustify {LEFT=0, RIGHT, CENTER}; +// note: obsolete! +struct Font { + enum FontJustify {LEFT=0, RIGHT, CENTER}; - XFontSet set; - XFontSetExtents *set_extents; - XFontStruct *fontstruct; - FontJustify justify; - }; + XFontSet set; + XFontSetExtents *set_extents; + XFontStruct *fontstruct; + FontJustify justify; +}; - int doAlignment(int max_width, int bevel, Font::FontJustify justify, +int doAlignment(int max_width, int bevel, Font::FontJustify justify, const FbTk::Font &font, const char * const text, size_t textlen, size_t &newlen); }; //end namespace DrawUtil
M src/Ewmh.ccsrc/Ewmh.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Ewmh.cc,v 1.6 2002/11/26 19:49:40 fluxgen Exp $ +// $Id: Ewmh.cc,v 1.7 2002/12/01 13:41:55 rathnor Exp $ #include "Ewmh.hh"

@@ -32,166 +32,166 @@ #include <new>

using namespace std; Ewmh::Ewmh() { - createAtoms(); + createAtoms(); } Ewmh::~Ewmh() { - while (!m_windows.empty()) { - XDestroyWindow(BaseDisplay::getXDisplay(), m_windows.back()); - m_windows.pop_back(); - } + while (!m_windows.empty()) { + XDestroyWindow(BaseDisplay::getXDisplay(), m_windows.back()); + m_windows.pop_back(); + } } void Ewmh::initForScreen(const BScreen &screen) { - Display *disp = BaseDisplay::getXDisplay(); + Display *disp = BaseDisplay::getXDisplay(); - Window wincheck = XCreateSimpleWindow(disp, - screen.getRootWindow(), 0, 0, 5, 5, 0, 0, 0); + Window wincheck = XCreateSimpleWindow(disp, + screen.getRootWindow(), 0, 0, 5, 5, 0, 0, 0); - if (wincheck != None) { - m_windows.push_back(wincheck); + if (wincheck != None) { + m_windows.push_back(wincheck); - XChangeProperty(disp, screen.getRootWindow(), m_net_supporting_wm_check, XA_WINDOW, 32, + XChangeProperty(disp, screen.getRootWindow(), m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &wincheck, 1); - XChangeProperty(disp, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, + XChangeProperty(disp, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &wincheck, 1); - XChangeProperty(disp, wincheck, m_net_wm_name, XA_STRING, 8, + XChangeProperty(disp, wincheck, m_net_wm_name, XA_STRING, 8, PropModeReplace, (unsigned char *) "Fluxbox", strlen("Fluxbox")); - } + } - //set supported atoms - Atom atomsupported[] = { - // window properties - m_net_wm_state, - // states that we support: - m_net_wm_state_sticky, - m_net_wm_state_shaded, + //set supported atoms + Atom atomsupported[] = { + // window properties + m_net_wm_state, + // states that we support: + m_net_wm_state_sticky, + m_net_wm_state_shaded, - m_net_wm_desktop, + m_net_wm_desktop, - // root properties - m_net_client_list, - m_net_number_of_desktops, - m_net_current_desktop, - m_net_active_window, - m_net_close_window, - m_net_moveresize_window, - m_net_desktop_names, - m_net_supporting_wm_check - }; + // root properties + m_net_client_list, + m_net_number_of_desktops, + m_net_current_desktop, + m_net_active_window, + m_net_close_window, + m_net_moveresize_window, + m_net_desktop_names, + m_net_supporting_wm_check + }; - XChangeProperty(disp, screen.getRootWindow(), - m_net_supported, XA_ATOM, 32, - PropModeReplace, (unsigned char *) &atomsupported, (sizeof atomsupported)/sizeof atomsupported[0]); + XChangeProperty(disp, screen.getRootWindow(), + m_net_supported, XA_ATOM, 32, + PropModeReplace, (unsigned char *) &atomsupported, (sizeof atomsupported)/sizeof atomsupported[0]); } void Ewmh::setupWindow(FluxboxWindow &win) { - Display *disp = BaseDisplay::getXDisplay(); - Atom ret_type; - int fmt; - unsigned long nitems, bytes_after; - long *data = 0; + Display *disp = BaseDisplay::getXDisplay(); + Atom ret_type; + int fmt; + unsigned long nitems, bytes_after; + long *data = 0; /* if (XGetWindowProperty(disp, win.getClientWindow(), - m_net_wm_state, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, - (unsigned char **) &data) == Success && data) { - flags = *data; - setState(win, flags); - XFree(data); + m_net_wm_state, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, + (unsigned char **) &data) == Success && data) { + flags = *data; + setState(win, flags); + XFree(data); } */ - if (XGetWindowProperty(disp, win.getClientWindow(), - m_net_wm_desktop, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, - (unsigned char **) &data) == Success && data) { - unsigned int desktop = static_cast<unsigned int>(*data); - if (desktop == 0xFFFFFFFF && !win.isStuck()) - win.stick(); - else if (win.getScreen()) - win.getScreen()->sendToWorkspace(desktop, &win, false); + if (XGetWindowProperty(disp, win.getClientWindow(), + m_net_wm_desktop, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, + (unsigned char **) &data) == Success && data) { + unsigned int desktop = static_cast<unsigned int>(*data); + if (desktop == 0xFFFFFFFF && !win.isStuck()) + win.stick(); + else if (win.getScreen()) + win.getScreen()->sendToWorkspace(desktop, &win, false); - XFree(data); - } + XFree(data); + } } void Ewmh::updateClientList(const BScreen &screen) { - size_t num=0; + size_t num=0; - BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); - BScreen::Workspaces::const_iterator workspace_it_end = screen.getWorkspacesList().end(); - for (; workspace_it != workspace_it_end; ++workspace_it) { - num += (*workspace_it)->getWindowList().size(); - } - //int num = getCurrentWorkspace()->getWindowList().size(); + BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); + BScreen::Workspaces::const_iterator workspace_it_end = screen.getWorkspacesList().end(); + for (; workspace_it != workspace_it_end; ++workspace_it) { + num += (*workspace_it)->getWindowList().size(); + } + //int num = getCurrentWorkspace()->getWindowList().size(); - Window *wl = new (nothrow) Window[num]; - if (wl == 0) { - cerr<<"Fatal: Out of memory, can't allocate for Ewmh client list"<<endl; - return; - } - //start the iterator from begining - workspace_it = screen.getWorkspacesList().begin(); - int win=0; - for (; workspace_it != workspace_it_end; ++workspace_it) { + Window *wl = new (nothrow) Window[num]; + if (wl == 0) { + cerr<<"Fatal: Out of memory, can't allocate for Ewmh client list"<<endl; + return; + } + //start the iterator from begining + workspace_it = screen.getWorkspacesList().begin(); + int win=0; + for (; workspace_it != workspace_it_end; ++workspace_it) { - // Fill in array of window ID's - Workspace::Windows::const_iterator it = (*workspace_it)->getWindowList().begin(); - Workspace::Windows::const_iterator it_end = (*workspace_it)->getWindowList().end(); - for (; it != it_end; ++it) { - wl[win++] = (*it)->getClientWindow(); - } - } - //number of windows to show in client list - num = win; - XChangeProperty(BaseDisplay::getXDisplay(), - screen.getRootWindow(), - m_net_client_list, - XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)wl, num); + // Fill in array of window ID's + Workspace::Windows::const_iterator it = (*workspace_it)->getWindowList().begin(); + Workspace::Windows::const_iterator it_end = (*workspace_it)->getWindowList().end(); + for (; it != it_end; ++it) { + wl[win++] = (*it)->getClientWindow(); + } + } + //number of windows to show in client list + num = win; + XChangeProperty(BaseDisplay::getXDisplay(), + screen.getRootWindow(), + m_net_client_list, + XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)wl, num); - delete [] wl; + delete [] wl; } void Ewmh::updateWorkspaceNames(const BScreen &screen) { - XTextProperty text; - const size_t number_of_desks = screen.getWorkspaceNames().size(); + XTextProperty text; + const size_t number_of_desks = screen.getWorkspaceNames().size(); - char *names[number_of_desks]; + char *names[number_of_desks]; - for (size_t i = 0; i < number_of_desks; i++) { - names[i] = new char[screen.getWorkspaceNames()[i].size()]; - strcpy(names[i], screen.getWorkspaceNames()[i].c_str()); - } + for (size_t i = 0; i < number_of_desks; i++) { + names[i] = new char[screen.getWorkspaceNames()[i].size()]; + strcpy(names[i], screen.getWorkspaceNames()[i].c_str()); + } - if (XStringListToTextProperty(names, number_of_desks, &text)) { - XSetTextProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), + if (XStringListToTextProperty(names, number_of_desks, &text)) { + XSetTextProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), &text, m_net_desktop_names); - XFree(text.value); - } + XFree(text.value); + } - for (size_t i = 0; i < number_of_desks; i++) - delete [] names[i]; + for (size_t i = 0; i < number_of_desks; i++) + delete [] names[i]; } void Ewmh::updateCurrentWorkspace(const BScreen &screen) { - size_t workspace = screen.getCurrentWorkspaceID(); - XChangeProperty(BaseDisplay::getXDisplay(), - screen.getRootWindow(), - m_net_current_desktop, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&workspace, 1); + size_t workspace = screen.getCurrentWorkspaceID(); + XChangeProperty(BaseDisplay::getXDisplay(), + screen.getRootWindow(), + m_net_current_desktop, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&workspace, 1); } void Ewmh::updateWorkspaceCount(const BScreen &screen) { - size_t numworkspaces = screen.getCount(); - XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), - m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&numworkspaces, 1); + size_t numworkspaces = screen.getCount(); + XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), + m_net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&numworkspaces, 1); } void Ewmh::updateState(FluxboxWindow &win) {

@@ -203,177 +203,177 @@

} void Ewmh::updateWorkspace(FluxboxWindow &win) { - int workspace = win.getWorkspaceNumber(); - if (win.isStuck()) - workspace = 0xFFFFFFFF; // appear on all desktops/workspaces + int workspace = win.getWorkspaceNumber(); + if (win.isStuck()) + workspace = 0xFFFFFFFF; // appear on all desktops/workspaces - XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), - m_net_wm_desktop, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&workspace, 1); + XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), + m_net_wm_desktop, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&workspace, 1); } // return true if we did handle the atom here bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win) { - if (ce.message_type == m_net_wm_desktop) { - if (screen == 0) - return true; - // ce.data.l[0] = workspace number - // valid window and workspace number? - if (win == 0 || static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount()) - return true; + if (ce.message_type == m_net_wm_desktop) { + if (screen == 0) + return true; + // ce.data.l[0] = workspace number + // valid window and workspace number? + if (win == 0 || static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount()) + return true; - screen->sendToWorkspace(ce.data.l[0], win, false); - return true; - } else if (ce.message_type == m_net_wm_state) { - if (win == 0) - return true; - // ce.data.l[0] = the action (remove, add or toggle) - // ce.data.l[1] = the first property to alter - // ce.data.l[2] = second property to alter (can be zero) - if (ce.data.l[0] == STATE_REMOVE) { - setState(*win, ce.data.l[1], false); - setState(*win, ce.data.l[2], false); - } else if (ce.data.l[0] == STATE_ADD) { - setState(*win, ce.data.l[1], true); - setState(*win, ce.data.l[2], true); - } else if (ce.data.l[0] == STATE_TOGGLE) { - toggleState(*win, ce.data.l[1]); - toggleState(*win, ce.data.l[2]); - } - return true; - } else if (ce.message_type == m_net_number_of_desktops) { - if (screen == 0) - return true; - // ce.data.l[0] = number of workspaces + screen->sendToWorkspace(ce.data.l[0], win, false); + return true; + } else if (ce.message_type == m_net_wm_state) { + if (win == 0) + return true; + // ce.data.l[0] = the action (remove, add or toggle) + // ce.data.l[1] = the first property to alter + // ce.data.l[2] = second property to alter (can be zero) + if (ce.data.l[0] == STATE_REMOVE) { + setState(*win, ce.data.l[1], false); + setState(*win, ce.data.l[2], false); + } else if (ce.data.l[0] == STATE_ADD) { + setState(*win, ce.data.l[1], true); + setState(*win, ce.data.l[2], true); + } else if (ce.data.l[0] == STATE_TOGGLE) { + toggleState(*win, ce.data.l[1]); + toggleState(*win, ce.data.l[2]); + } + return true; + } else if (ce.message_type == m_net_number_of_desktops) { + if (screen == 0) + return true; + // ce.data.l[0] = number of workspaces - // no need to alter number of desktops if they are the same - // or if requested number of workspace is less than zero - if (screen->getCount() == static_cast<unsigned int>(ce.data.l[0]) || - ce.data.l[0] < 0) - return true; + // no need to alter number of desktops if they are the same + // or if requested number of workspace is less than zero + if (screen->getCount() == static_cast<unsigned int>(ce.data.l[0]) || + ce.data.l[0] < 0) + return true; - if (screen->getCount() > static_cast<unsigned int>(ce.data.l[0])) { - // remove last workspace until we have - // the same number of workspaces - while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) { - screen->removeLastWorkspace(); - if (screen->getCount() == 1) // must have at least one workspace - break; - } - } else { // add workspaces to screen until workspace count match the requested size - while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) { - screen->addWorkspace(); - } - } + if (screen->getCount() > static_cast<unsigned int>(ce.data.l[0])) { + // remove last workspace until we have + // the same number of workspaces + while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) { + screen->removeLastWorkspace(); + if (screen->getCount() == 1) // must have at least one workspace + break; + } + } else { // add workspaces to screen until workspace count match the requested size + while (screen->getCount() != static_cast<unsigned int>(ce.data.l[0])) { + screen->addWorkspace(); + } + } - return true; - } else if (ce.message_type == m_net_current_desktop) { - if (screen == 0) - return true; - // ce.data.l[0] = workspace number + return true; + } else if (ce.message_type == m_net_current_desktop) { + if (screen == 0) + return true; + // ce.data.l[0] = workspace number - // prevent out of range value - if (static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount()) - return true; - screen->changeWorkspaceID(ce.data.l[0]); - return true; - } else if (ce.message_type == m_net_active_window) { + // prevent out of range value + if (static_cast<unsigned int>(ce.data.l[0]) >= screen->getCount()) + return true; + screen->changeWorkspaceID(ce.data.l[0]); + return true; + } else if (ce.message_type == m_net_active_window) { - // make sure we have a valid window - if (win == 0) - return true; - // ce.window = window to focus + // make sure we have a valid window + if (win == 0) + return true; + // ce.window = window to focus - // should move set focus somewhere else - // so we don't need fluxbox depedencies here - Fluxbox::instance()->setFocusedWindow(win); - return true; - } else if (ce.message_type == m_net_close_window) { - if (win == 0) - return true; - // ce.window = window to close (which in this case is the win argument) - win->close(); - return true; - } else if (ce.message_type == m_net_moveresize_window) { - if (win == 0) - return true; - // ce.data.l[0] = gravity and flags - // ce.data.l[1] = x - // ce.data.l[2] = y - // ce.data.l[3] = width - // ce.data.l[4] = height - // TODO: gravity and flags - win->configure(ce.data.l[1], ce.data.l[2], - ce.data.l[3], ce.data.l[4]); - return true; - } + // should move set focus somewhere else + // so we don't need fluxbox depedencies here + Fluxbox::instance()->setFocusedWindow(win); + return true; + } else if (ce.message_type == m_net_close_window) { + if (win == 0) + return true; + // ce.window = window to close (which in this case is the win argument) + win->close(); + return true; + } else if (ce.message_type == m_net_moveresize_window) { + if (win == 0) + return true; + // ce.data.l[0] = gravity and flags + // ce.data.l[1] = x + // ce.data.l[2] = y + // ce.data.l[3] = width + // ce.data.l[4] = height + // TODO: gravity and flags + win->configure(ce.data.l[1], ce.data.l[2], + ce.data.l[3], ce.data.l[4]); + return true; + } - // we didn't handle the ce.message_type here - return false; + // we didn't handle the ce.message_type here + return false; } void Ewmh::createAtoms() { - Display *disp = BaseDisplay::getXDisplay(); - m_net_supported = XInternAtom(disp, "_NET_SUPPORTED", False); - m_net_client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False); - m_net_client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False); - m_net_number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False); - m_net_desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False); - m_net_desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False); - m_net_current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False); - m_net_desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False); - m_net_active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False); - m_net_workarea = XInternAtom(disp, "_NET_WORKAREA", False); - m_net_supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False); - m_net_virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False); + Display *disp = BaseDisplay::getXDisplay(); + m_net_supported = XInternAtom(disp, "_NET_SUPPORTED", False); + m_net_client_list = XInternAtom(disp, "_NET_CLIENT_LIST", False); + m_net_client_list_stacking = XInternAtom(disp, "_NET_CLIENT_LIST_STACKING", False); + m_net_number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False); + m_net_desktop_geometry = XInternAtom(disp, "_NET_DESKTOP_GEOMETRY", False); + m_net_desktop_viewport = XInternAtom(disp, "_NET_DESKTOP_VIEWPORT", False); + m_net_current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False); + m_net_desktop_names = XInternAtom(disp, "_NET_DESKTOP_NAMES", False); + m_net_active_window = XInternAtom(disp, "_NET_ACTIVE_WINDOW", False); + m_net_workarea = XInternAtom(disp, "_NET_WORKAREA", False); + m_net_supporting_wm_check = XInternAtom(disp, "_NET_SUPPORTING_WM_CHECK", False); + m_net_virtual_roots = XInternAtom(disp, "_NET_VIRTUAL_ROOTS", False); - m_net_close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False); - m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False); + m_net_close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False); + m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False); - // TODO: implement this one - m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False); + // TODO: implement this one + m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False); - m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False); - m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False); - m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False); - m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False); + m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False); + m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False); + m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False); + m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False); - // state atom and the supported state atoms - m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False); - m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False); - m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False); + // state atom and the supported state atoms + m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False); + m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False); + m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False); - m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False); - m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False); - m_net_wm_icon = XInternAtom(disp, "_NET_WM_ICON", False); - m_net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False); - m_net_wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False); + m_net_wm_strut = XInternAtom(disp, "_NET_WM_STRUT", False); + m_net_wm_icon_geometry = XInternAtom(disp, "_NET_WM_ICON_GEOMETRY", False); + m_net_wm_icon = XInternAtom(disp, "_NET_WM_ICON", False); + m_net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False); + m_net_wm_handled_icons = XInternAtom(disp, "_NET_WM_HANDLED_ICONS", False); - m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False); + m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False); } // set window state void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) const { - if (state == m_net_wm_state_sticky) { // STICKY - if (value && !win.isStuck() || - (!value && win.isStuck())) - win.stick(); - } else if (state == m_net_wm_state_shaded) { // SHADED - if ((value && !win.isShaded()) || - (!value && win.isShaded())) - win.shade(); - } + if (state == m_net_wm_state_sticky) { // STICKY + if (value && !win.isStuck() || + (!value && win.isStuck())) + win.stick(); + } else if (state == m_net_wm_state_shaded) { // SHADED + if ((value && !win.isShaded()) || + (!value && win.isShaded())) + win.shade(); + } } // toggle window state void Ewmh::toggleState(FluxboxWindow &win, Atom state) const { - if (state == m_net_wm_state_sticky) { - win.stick(); - } else if (state == m_net_wm_state_shaded) - win.shade(); + if (state == m_net_wm_state_sticky) { + win.stick(); + } else if (state == m_net_wm_state_shaded) + win.shade(); }
M src/Ewmh.hhsrc/Ewmh.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Ewmh.hh,v 1.3 2002/10/16 19:02:25 fluxgen Exp $ +// $Id: Ewmh.hh,v 1.4 2002/12/01 13:41:56 rathnor Exp $ #include "AtomHandler.hh"

@@ -29,48 +29,48 @@

class Ewmh:public AtomHandler { public: - Ewmh(); - ~Ewmh(); - void initForScreen(const BScreen &screen); - void setupWindow(FluxboxWindow &win); + Ewmh(); + ~Ewmh(); + void initForScreen(const BScreen &screen); + void setupWindow(FluxboxWindow &win); - void updateClientList(const BScreen &screen); - void updateWorkspaceNames(const BScreen &screen); - void updateCurrentWorkspace(const BScreen &screen); - void updateWorkspaceCount(const BScreen &screen); + void updateClientList(const BScreen &screen); + void updateWorkspaceNames(const BScreen &screen); + void updateCurrentWorkspace(const BScreen &screen); + void updateWorkspaceCount(const BScreen &screen); - void updateState(FluxboxWindow &win); - void updateHints(FluxboxWindow &win); - void updateWorkspace(FluxboxWindow &win); + void updateState(FluxboxWindow &win); + void updateHints(FluxboxWindow &win); + void updateWorkspace(FluxboxWindow &win); - bool checkClientMessage(const XClientMessageEvent &ce, - BScreen * const screen, FluxboxWindow * const win); + bool checkClientMessage(const XClientMessageEvent &ce, + BScreen * const screen, FluxboxWindow * const win); private: - enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; + enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; - void setState(FluxboxWindow &win, Atom state, bool value) const; - void toggleState(FluxboxWindow &win, Atom state) const; - void createAtoms(); + void setState(FluxboxWindow &win, Atom state, bool value) const; + void toggleState(FluxboxWindow &win, Atom state) const; + void createAtoms(); - // root window properties - Atom m_net_supported, m_net_client_list, m_net_client_list_stacking, - m_net_number_of_desktops, m_net_desktop_geometry, m_net_desktop_viewport, - m_net_current_desktop, m_net_desktop_names, m_net_active_window, m_net_workarea, - m_net_supporting_wm_check, m_net_virtual_roots, m_net_moveresize_window; + // root window properties + Atom m_net_supported, m_net_client_list, m_net_client_list_stacking, + m_net_number_of_desktops, m_net_desktop_geometry, m_net_desktop_viewport, + m_net_current_desktop, m_net_desktop_names, m_net_active_window, m_net_workarea, + m_net_supporting_wm_check, m_net_virtual_roots, m_net_moveresize_window; - // root window messages - Atom m_net_close_window, m_net_wm_moveresize; + // root window messages + Atom m_net_close_window, m_net_wm_moveresize; - // application window properties - Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, m_net_wm_window_type, - m_net_wm_state, m_net_wm_state_sticky, m_net_wm_state_shaded, - m_net_wm_strut, m_net_wm_icon_geometry, m_net_wm_icon, m_net_wm_pid, - m_net_wm_handled_icons; + // application window properties + Atom m_net_properties, m_net_wm_name, m_net_wm_desktop, m_net_wm_window_type, + m_net_wm_state, m_net_wm_state_sticky, m_net_wm_state_shaded, + m_net_wm_strut, m_net_wm_icon_geometry, m_net_wm_icon, m_net_wm_pid, + m_net_wm_handled_icons; - // application protocols - Atom m_net_wm_ping; + // application protocols + Atom m_net_wm_ping; - std::vector<Window> m_windows; + std::vector<Window> m_windows; };
M src/FbAtoms.ccsrc/FbAtoms.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: FbAtoms.cc,v 1.4 2002/09/07 20:12:47 fluxgen Exp $ +// $Id: FbAtoms.cc,v 1.5 2002/12/01 13:41:56 rathnor Exp $ #include "FbAtoms.hh"

@@ -29,14 +29,14 @@

FbAtoms *FbAtoms::s_singleton = 0; FbAtoms::FbAtoms(Display *display):m_init(false) { - if (s_singleton != 0) - throw string("You can only create one instance of FbAtoms"); + if (s_singleton != 0) + throw string("You can only create one instance of FbAtoms"); - if (display == 0) - throw string("Must supply FbAtoms with an valid display connection"); + if (display == 0) + throw string("Must supply FbAtoms with an valid display connection"); - s_singleton = this; - initAtoms(display); + s_singleton = this; + initAtoms(display); } FbAtoms::~FbAtoms() {

@@ -44,50 +44,50 @@

} FbAtoms *FbAtoms::instance() { - assert(s_singleton); - return s_singleton; + assert(s_singleton); + return s_singleton; } void FbAtoms::initAtoms(Display *display) { - xa_wm_colormap_windows = - XInternAtom(display, "WM_COLORMAP_WINDOWS", False); - xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); - xa_wm_state = XInternAtom(display, "WM_STATE", False); - xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False); - xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False); - xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False); - motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False); + xa_wm_colormap_windows = + XInternAtom(display, "WM_COLORMAP_WINDOWS", False); + xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False); + xa_wm_state = XInternAtom(display, "WM_STATE", False); + xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False); + xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False); + xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False); + motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False); - blackbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False); - blackbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False); - blackbox_change_attributes = - XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False); + blackbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False); + blackbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False); + blackbox_change_attributes = + XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False); - blackbox_structure_messages = - XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False); - blackbox_notify_startup = - XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False); - blackbox_notify_window_add = - XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False); - blackbox_notify_window_del = - XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False); - blackbox_notify_current_workspace = - XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False); - blackbox_notify_workspace_count = - XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False); - blackbox_notify_window_focus = - XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False); - blackbox_notify_window_raise = - XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False); - blackbox_notify_window_lower = - XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False); + blackbox_structure_messages = + XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False); + blackbox_notify_startup = + XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False); + blackbox_notify_window_add = + XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False); + blackbox_notify_window_del = + XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False); + blackbox_notify_current_workspace = + XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False); + blackbox_notify_workspace_count = + XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False); + blackbox_notify_window_focus = + XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False); + blackbox_notify_window_raise = + XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False); + blackbox_notify_window_lower = + XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False); - blackbox_change_workspace = - XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False); - blackbox_change_window_focus = - XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False); - blackbox_cycle_window_focus = - XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False); + blackbox_change_workspace = + XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False); + blackbox_change_window_focus = + XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False); + blackbox_cycle_window_focus = + XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False); }
M src/FbAtoms.hhsrc/FbAtoms.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: FbAtoms.hh,v 1.7 2002/09/07 20:10:54 fluxgen Exp $ +// $Id: FbAtoms.hh,v 1.8 2002/12/01 13:41:56 rathnor Exp $ #ifndef FBATOMS_HH #define FBATOMS_HH

@@ -31,72 +31,72 @@ atom handler for base atoms

*/ class FbAtoms { public: - explicit FbAtoms(Display *display); - virtual ~FbAtoms(); - static FbAtoms *instance(); + explicit FbAtoms(Display *display); + virtual ~FbAtoms(); + static FbAtoms *instance(); - inline Atom getWMChangeStateAtom() const { return xa_wm_change_state; } - inline Atom getWMStateAtom() const { return xa_wm_state; } - inline Atom getWMDeleteAtom() const { return xa_wm_delete_window; } - inline Atom getWMProtocolsAtom() const { return xa_wm_protocols; } - inline Atom getWMTakeFocusAtom() const { return xa_wm_take_focus; } - inline Atom getWMColormapAtom() const { return xa_wm_colormap_windows; } - inline Atom getMotifWMHintsAtom() const { return motif_wm_hints; } + inline Atom getWMChangeStateAtom() const { return xa_wm_change_state; } + inline Atom getWMStateAtom() const { return xa_wm_state; } + inline Atom getWMDeleteAtom() const { return xa_wm_delete_window; } + inline Atom getWMProtocolsAtom() const { return xa_wm_protocols; } + inline Atom getWMTakeFocusAtom() const { return xa_wm_take_focus; } + inline Atom getWMColormapAtom() const { return xa_wm_colormap_windows; } + inline Atom getMotifWMHintsAtom() const { return motif_wm_hints; } - // this atom is for normal app->WM hints about decorations, stacking, - // starting workspace etc... - inline Atom getFluxboxHintsAtom() const { return blackbox_hints;} + // this atom is for normal app->WM hints about decorations, stacking, + // starting workspace etc... + inline Atom getFluxboxHintsAtom() const { return blackbox_hints;} - // these atoms are for normal app->WM interaction beyond the scope of the - // ICCCM... - inline Atom getFluxboxAttributesAtom() const { return blackbox_attributes; } - inline Atom getFluxboxChangeAttributesAtom() const { return blackbox_change_attributes; } + // these atoms are for normal app->WM interaction beyond the scope of the + // ICCCM... + inline Atom getFluxboxAttributesAtom() const { return blackbox_attributes; } + inline Atom getFluxboxChangeAttributesAtom() const { return blackbox_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 Atom getFluxboxStructureMessagesAtom() const{ return blackbox_structure_messages; } + // 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 Atom getFluxboxStructureMessagesAtom() const{ return blackbox_structure_messages; } - // *Notify* portions of the NETStructureMessages protocol - inline Atom getFluxboxNotifyStartupAtom() const { return blackbox_notify_startup; } - inline Atom getFluxboxNotifyWindowAddAtom() const { return blackbox_notify_window_add; } - inline Atom getFluxboxNotifyWindowDelAtom() const { return blackbox_notify_window_del; } - inline Atom getFluxboxNotifyWindowFocusAtom() const { return blackbox_notify_window_focus; } - inline Atom getFluxboxNotifyCurrentWorkspaceAtom() const { return blackbox_notify_current_workspace; } - inline Atom getFluxboxNotifyWorkspaceCountAtom() const { return blackbox_notify_workspace_count; } - inline Atom getFluxboxNotifyWindowRaiseAtom() const { return blackbox_notify_window_raise; } - inline Atom getFluxboxNotifyWindowLowerAtom() const { return blackbox_notify_window_lower; } + // *Notify* portions of the NETStructureMessages protocol + inline Atom getFluxboxNotifyStartupAtom() const { return blackbox_notify_startup; } + inline Atom getFluxboxNotifyWindowAddAtom() const { return blackbox_notify_window_add; } + inline Atom getFluxboxNotifyWindowDelAtom() const { return blackbox_notify_window_del; } + inline Atom getFluxboxNotifyWindowFocusAtom() const { return blackbox_notify_window_focus; } + inline Atom getFluxboxNotifyCurrentWorkspaceAtom() const { return blackbox_notify_current_workspace; } + inline Atom getFluxboxNotifyWorkspaceCountAtom() const { return blackbox_notify_workspace_count; } + inline Atom getFluxboxNotifyWindowRaiseAtom() const { return blackbox_notify_window_raise; } + inline Atom getFluxboxNotifyWindowLowerAtom() const { return blackbox_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 Atom getFluxboxChangeWorkspaceAtom() const { return blackbox_change_workspace; } - inline Atom getFluxboxChangeWindowFocusAtom() const { return blackbox_change_window_focus; } - inline Atom getFluxboxCycleWindowFocusAtom() const { return blackbox_cycle_window_focus; } + // 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 Atom getFluxboxChangeWorkspaceAtom() const { return blackbox_change_workspace; } + inline Atom getFluxboxChangeWindowFocusAtom() const { return blackbox_change_window_focus; } + inline Atom getFluxboxCycleWindowFocusAtom() const { return blackbox_cycle_window_focus; } private: - void initAtoms(Display *disp); + void initAtoms(Display *disp); // NETAttributes - Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints; + Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints; - // NETStructureMessages - Atom blackbox_structure_messages, blackbox_notify_startup, - blackbox_notify_window_add, blackbox_notify_window_del, - blackbox_notify_window_focus, blackbox_notify_current_workspace, - blackbox_notify_workspace_count, blackbox_notify_window_raise, - blackbox_notify_window_lower; + // NETStructureMessages + Atom blackbox_structure_messages, blackbox_notify_startup, + blackbox_notify_window_add, blackbox_notify_window_del, + blackbox_notify_window_focus, blackbox_notify_current_workspace, + blackbox_notify_workspace_count, blackbox_notify_window_raise, + blackbox_notify_window_lower; - // message_types for client -> wm messages - Atom blackbox_change_workspace, blackbox_change_window_focus, - blackbox_cycle_window_focus; + // message_types for client -> wm messages + Atom blackbox_change_workspace, blackbox_change_window_focus, + blackbox_cycle_window_focus; - Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state, - xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, - motif_wm_hints; - bool m_init; - static FbAtoms *s_singleton; + Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state, + xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, + motif_wm_hints; + bool m_init; + static FbAtoms *s_singleton; }; #endif //FBATOMS_HH
M src/FbTk/App.ccsrc/FbTk/App.cc

@@ -31,37 +31,37 @@

App *App::s_app = 0; App *App::instance() { - if (s_app == 0) - throw std::string("You must create an instance of FbTk::App first!"); - return s_app; + if (s_app == 0) + throw std::string("You must create an instance of FbTk::App first!"); + return s_app; } App::App(const char *displayname):m_done(false) { - if (s_app != 0) - throw std::string("Can't create more than one instance of FbTk::App"); - s_app = this; - m_display = XOpenDisplay(displayname); + if (s_app != 0) + throw std::string("Can't create more than one instance of FbTk::App"); + s_app = this; + m_display = XOpenDisplay(displayname); } App::~App() { - if (m_display != 0) { - XCloseDisplay(m_display); - m_display = 0; - } - s_app = 0; + if (m_display != 0) { + XCloseDisplay(m_display); + m_display = 0; + } + s_app = 0; } void App::eventLoop() { - XEvent ev; - while (!m_done) { - XNextEvent(display(), &ev); - EventManager::instance()->handleEvent(ev); - } + XEvent ev; + while (!m_done) { + XNextEvent(display(), &ev); + EventManager::instance()->handleEvent(ev); + } } void App::end() { - m_done = true; //end loop in App::eventLoop + m_done = true; //end loop in App::eventLoop } }; // end namespace FbTk
M src/FbTk/App.hhsrc/FbTk/App.hh

@@ -26,24 +26,24 @@ #include <X11/Xlib.h>

namespace FbTk { /** - Main class for applications, every application must create an instance of this class + Main class for applications, every application must create an instance of this class */ class App { public: - /// @return singleton instance of App - static App *instance(); - explicit App(const char *displayname=0); - virtual ~App(); - /// display connection - Display *display() const { return m_display; } - /// starts event loop - virtual void eventLoop(); - /// ends event loop - void end(); + /// @return singleton instance of App + static App *instance(); + explicit App(const char *displayname=0); + virtual ~App(); + /// display connection + Display *display() const { return m_display; } + /// starts event loop + virtual void eventLoop(); + /// ends event loop + void end(); private: - static App *s_app; - bool m_done; - Display *m_display; + static App *s_app; + bool m_done; + Display *m_display; }; }; // end namespace FbTk
M src/FbTk/Color.ccsrc/FbTk/Color.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Color.cc,v 1.2 2002/11/28 19:22:40 fluxgen Exp $ +// $Id: Color.cc,v 1.3 2002/12/01 13:42:14 rathnor Exp $ #include "Color.hh"

@@ -30,10 +30,10 @@ using namespace std;

namespace { unsigned char maxValue(unsigned short colval) { - if (colval == 65535) - return 0xFF; + if (colval == 65535) + return 0xFF; - return static_cast<unsigned char>(colval/0xFF); + return static_cast<unsigned char>(colval/0xFF); } };

@@ -41,130 +41,130 @@

namespace FbTk { Color::Color(): -m_allocated(false), -m_screen(0) { + m_allocated(false), + m_screen(0) { } Color::Color(const Color &col_copy) { - copy(col_copy); + copy(col_copy); } Color::Color(unsigned char red, unsigned char green, unsigned char blue, int screen): -m_red(red), m_green(green), m_blue(blue), -m_pixel(0), m_allocated(false), -m_screen(screen) { - allocate(red, green, blue, screen); + m_red(red), m_green(green), m_blue(blue), + m_pixel(0), m_allocated(false), + m_screen(screen) { + allocate(red, green, blue, screen); } Color::Color(const char *color_string, int screen): -m_allocated(false), -m_screen(screen) { - setFromString(color_string, screen); + m_allocated(false), + m_screen(screen) { + setFromString(color_string, screen); } Color::~Color() { - free(); + free(); } bool Color::setFromString(const char *color_string, int screen) { - if (color_string == 0) { - free(); - return false; - } + if (color_string == 0) { + free(); + return false; + } - Display *disp = App::instance()->display(); - Colormap colm = DefaultColormap(disp, screen); + Display *disp = App::instance()->display(); + Colormap colm = DefaultColormap(disp, screen); - XColor color; + XColor color; - if (! XParseColor(disp, colm, color_string, &color)) { - cerr<<"FbTk::Color: Parse color error: \""<<color_string<<"\""<<endl; - return false; - } else if (! XAllocColor(disp, colm, &color)) { - cerr<<"FbTk::Color: Allocation error: \""<<color_string<<"\""<<endl; - return false; - } + if (! XParseColor(disp, colm, color_string, &color)) { + cerr<<"FbTk::Color: Parse color error: \""<<color_string<<"\""<<endl; + return false; + } else if (! XAllocColor(disp, colm, &color)) { + cerr<<"FbTk::Color: Allocation error: \""<<color_string<<"\""<<endl; + return false; + } - setPixel(color.pixel); - setRGB(maxValue(color.red), - maxValue(color.green), - maxValue(color.blue)); - setAllocated(true); - m_screen = screen; + setPixel(color.pixel); + setRGB(maxValue(color.red), + maxValue(color.green), + maxValue(color.blue)); + setAllocated(true); + m_screen = screen; - return true; + return true; } /* -Color &Color::Color::operator = (const Color &col_copy) { - // check for aliasing - if (this == &col_copy) - return *this; + Color &Color::Color::operator = (const Color &col_copy) { + // check for aliasing + if (this == &col_copy) + return *this; - copy(col_copy); - return *this; -} + copy(col_copy); + return *this; + } */ void Color::free() { - if (isAllocated()) { - unsigned long pixel = m_pixel; - Display *disp = App::instance()->display(); - XFreeColors(disp, DefaultColormap(disp, m_screen), &pixel, 1, 0); - setPixel(0); - setRGB(0, 0, 0); - setAllocated(false); - } + if (isAllocated()) { + unsigned long pixel = m_pixel; + Display *disp = App::instance()->display(); + XFreeColors(disp, DefaultColormap(disp, m_screen), &pixel, 1, 0); + setPixel(0); + setRGB(0, 0, 0); + setAllocated(false); + } } void Color::copy(const Color &col_copy) { - if (!col_copy.isAllocated()) { - free(); - setRGB(col_copy.red(), col_copy.green(), col_copy.blue()); - setPixel(col_copy.pixel()); - return; - } + if (!col_copy.isAllocated()) { + free(); + setRGB(col_copy.red(), col_copy.green(), col_copy.blue()); + setPixel(col_copy.pixel()); + return; + } - free(); + free(); - allocate(col_copy.red(), - col_copy.green(), - col_copy.blue(), - col_copy.m_screen); + allocate(col_copy.red(), + col_copy.green(), + col_copy.blue(), + col_copy.m_screen); } void Color::allocate(unsigned char red, unsigned char green, unsigned char blue, int screen) { - Display *disp = App::instance()->display(); - XColor color; - // fill xcolor structure - color.red = red; - color.green = green; - color.blue = blue; + Display *disp = App::instance()->display(); + XColor color; + // fill xcolor structure + color.red = red; + color.green = green; + color.blue = blue; - if (!XAllocColor(disp, DefaultColormap(disp, screen), &color)) { - cerr<<"FbTk::Color: Allocation error."<<endl; - } else { - setRGB(maxValue(color.red), - maxValue(color.green), - maxValue(color.blue)); - setPixel(color.pixel); - setAllocated(true); - } + if (!XAllocColor(disp, DefaultColormap(disp, screen), &color)) { + cerr<<"FbTk::Color: Allocation error."<<endl; + } else { + setRGB(maxValue(color.red), + maxValue(color.green), + maxValue(color.blue)); + setPixel(color.pixel); + setAllocated(true); + } - m_screen = screen; + m_screen = screen; } void Color::setRGB(unsigned char red, unsigned char green, unsigned char blue) { - m_red = red; - m_green = green; - m_blue = blue; + m_red = red; + m_green = green; + m_blue = blue; } };
M src/FbTk/Color.hhsrc/FbTk/Color.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Color.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +// $Id: Color.hh,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_COLOR_HH #define FBTK_COLOR_HH

@@ -31,41 +31,41 @@ #include "NotCopyable.hh"

namespace FbTk { /** - Holds rgb color and pixel value + Holds rgb color and pixel value */ class Color { public: - Color(); - explicit Color(unsigned long pixel); - Color(const Color &col_copy); - Color(unsigned char red, unsigned char green, unsigned char blue, int screen); - Color(const char *color_string, int screen); - ~Color(); + Color(); + explicit Color(unsigned long pixel); + Color(const Color &col_copy); + Color(unsigned char red, unsigned char green, unsigned char blue, int screen); + Color(const char *color_string, int screen); + ~Color(); - bool setFromString(const char *color_string, int screen); - /// TODO don't like this - void setPixel(unsigned long pixel) { m_pixel = pixel; } - // TODO - //Color &operator = (const Color &col_copy); + bool setFromString(const char *color_string, int screen); + /// TODO don't like this + void setPixel(unsigned long pixel) { m_pixel = pixel; } + // TODO + //Color &operator = (const Color &col_copy); - bool isAllocated() const { return m_allocated; } - unsigned char red() const { return m_red; } - unsigned char green() const { return m_green; } - unsigned char blue() const { return m_blue; } - unsigned long pixel() const { return m_pixel; } + bool isAllocated() const { return m_allocated; } + unsigned char red() const { return m_red; } + unsigned char green() const { return m_green; } + unsigned char blue() const { return m_blue; } + unsigned long pixel() const { return m_pixel; } private: - void free(); - void copy(const Color &col); - void allocate(unsigned char red, unsigned char green, unsigned char blue, int screen); - inline void setAllocated(bool a) { m_allocated = a; } - void setRGB(unsigned char red, unsigned char green, unsigned char blue); + void free(); + void copy(const Color &col); + void allocate(unsigned char red, unsigned char green, unsigned char blue, int screen); + inline void setAllocated(bool a) { m_allocated = a; } + void setRGB(unsigned char red, unsigned char green, unsigned char blue); - unsigned char m_red, m_green, m_blue; - unsigned long m_pixel; - bool m_allocated; - int m_screen; + unsigned char m_red, m_green, m_blue; + unsigned long m_pixel; + bool m_allocated; + int m_screen; }; }; // end namespace FbTk
M src/FbTk/EventHandler.hhsrc/FbTk/EventHandler.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: EventHandler.hh,v 1.2 2002/11/27 21:41:38 fluxgen Exp $ +// $Id: EventHandler.hh,v 1.3 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_EVENTHANDLER_HH #define FBTK_EVENTHANDLER_HH

@@ -29,24 +29,24 @@

namespace FbTk { /** - interface for X events + interface for X events */ class EventHandler { public: - virtual ~EventHandler() { } + virtual ~EventHandler() { } - /** - Events that don't have an specific event function - */ - virtual void handleEvent(XEvent &ev) { } - virtual void buttonPressEvent(XButtonEvent &ev) { } - virtual void buttonReleaseEvent(XButtonEvent &ev) { } - virtual void exposeEvent(XExposeEvent &ev) { } - virtual void motionNotifyEvent(XMotionEvent &ev) { } - virtual void keyPressEvent(XKeyEvent &ev) { } - virtual void keyReleaseEvent(XKeyEvent &ev) { } - virtual void leaveNotifyEvent(XCrossingEvent &ev) { } - virtual void enterNotifyEvent(XCrossingEvent &ev) { } + /** + Events that don't have an specific event function + */ + virtual void handleEvent(XEvent &ev) { } + virtual void buttonPressEvent(XButtonEvent &ev) { } + virtual void buttonReleaseEvent(XButtonEvent &ev) { } + virtual void exposeEvent(XExposeEvent &ev) { } + virtual void motionNotifyEvent(XMotionEvent &ev) { } + virtual void keyPressEvent(XKeyEvent &ev) { } + virtual void keyReleaseEvent(XKeyEvent &ev) { } + virtual void leaveNotifyEvent(XCrossingEvent &ev) { } + virtual void enterNotifyEvent(XCrossingEvent &ev) { } }; };
M src/FbTk/EventManager.ccsrc/FbTk/EventManager.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: EventManager.cc,v 1.1 2002/11/27 21:41:13 fluxgen Exp $ +// $Id: EventManager.cc,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #include "EventManager.hh"

@@ -29,64 +29,64 @@

namespace FbTk { EventManager *EventManager::instance() { - static EventManager ev; - return &ev; + static EventManager ev; + return &ev; } EventManager::~EventManager() { - if (m_eventhandlers.size() != 0) - cerr<<"FbTk::EventManager: Warning: unregistered eventhandlers!"<<endl; + if (m_eventhandlers.size() != 0) + cerr<<"FbTk::EventManager: Warning: unregistered eventhandlers!"<<endl; } void EventManager::handleEvent(XEvent &ev) { - // find eventhandler for event window - if (m_eventhandlers.find(ev.xany.window) == m_eventhandlers.end()) { - cerr<<"Can't find window="<<ev.xany.window<<endl; - return; - } - EventHandler *evhand = m_eventhandlers[ev.xany.window]; - if (evhand == 0) { - cerr<<"FbTk::EventManager: Warning: evhand == 0!"<<endl; - return; - } + // find eventhandler for event window + if (m_eventhandlers.find(ev.xany.window) == m_eventhandlers.end()) { + cerr<<"Can't find window="<<ev.xany.window<<endl; + return; + } + EventHandler *evhand = m_eventhandlers[ev.xany.window]; + if (evhand == 0) { + cerr<<"FbTk::EventManager: Warning: evhand == 0!"<<endl; + return; + } - switch (ev.xany.type) { - case KeyPress: - evhand->keyPressEvent(ev.xkey); + switch (ev.xany.type) { + case KeyPress: + evhand->keyPressEvent(ev.xkey); break; - case KeyRelease: - evhand->keyReleaseEvent(ev.xkey); + case KeyRelease: + evhand->keyReleaseEvent(ev.xkey); break; - case ButtonPress: - evhand->buttonPressEvent(ev.xbutton); + case ButtonPress: + evhand->buttonPressEvent(ev.xbutton); break; - case ButtonRelease: - evhand->buttonReleaseEvent(ev.xbutton); + case ButtonRelease: + evhand->buttonReleaseEvent(ev.xbutton); break; - case MotionNotify: - evhand->motionNotifyEvent(ev.xmotion); + case MotionNotify: + evhand->motionNotifyEvent(ev.xmotion); break; - case Expose: - evhand->exposeEvent(ev.xexpose); + case Expose: + evhand->exposeEvent(ev.xexpose); break; - case EnterNotify: - evhand->enterNotifyEvent(ev.xcrossing); + case EnterNotify: + evhand->enterNotifyEvent(ev.xcrossing); break; - case LeaveNotify: - evhand->leaveNotifyEvent(ev.xcrossing); + case LeaveNotify: + evhand->leaveNotifyEvent(ev.xcrossing); break; - default: - evhand->handleEvent(ev); + default: + evhand->handleEvent(ev); break; - }; + }; } void EventManager::registerEventHandler(EventHandler &ev, Window win) { - m_eventhandlers[win] = &ev; + m_eventhandlers[win] = &ev; } void EventManager::unregisterEventHandler(Window win) { - m_eventhandlers.erase(win); + m_eventhandlers.erase(win); } };
M src/FbTk/EventManager.hhsrc/FbTk/EventManager.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: EventManager.hh,v 1.1 2002/11/27 21:41:13 fluxgen Exp $ +// $Id: EventManager.hh,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #include "EventHandler.hh" #include <map>

@@ -27,21 +27,21 @@

namespace FbTk { /** - singleton mediator for EventHandlers + singleton mediator for EventHandlers */ class EventManager { public: - static EventManager *instance(); + static EventManager *instance(); - void handleEvent(XEvent &ev); + void handleEvent(XEvent &ev); - void registerEventHandler(EventHandler &ev, Window win); - void unregisterEventHandler(Window win); + void registerEventHandler(EventHandler &ev, Window win); + void unregisterEventHandler(Window win); private: - EventManager() { } - ~EventManager(); + EventManager() { } + ~EventManager(); - std::map<Window, EventHandler *> m_eventhandlers; + std::map<Window, EventHandler *> m_eventhandlers; }; }; //end namespace FbTk
M src/FbTk/Font.ccsrc/FbTk/Font.cc

@@ -19,7 +19,7 @@ // 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. -//$Id: Font.cc,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +//$Id: Font.cc,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #include "Font.hh"

@@ -66,43 +66,43 @@ bool Font::m_multibyte = false;

bool Font::m_utf8mode = false; Font::Font(const char *name, bool antialias): -m_fontimp(0), -m_antialias(false), m_rotated(false) { + m_fontimp(0), + m_antialias(false), m_rotated(false) { - // MB_CUR_MAX returns the size of a char in the current locale - if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte - m_multibyte = true; + // MB_CUR_MAX returns the size of a char in the current locale + if (MB_CUR_MAX > 1) // more than one byte, then we're multibyte + m_multibyte = true; - char *s; // temporary string for enviroment variable - // check for utf-8 mode - if (((s = getenv("LC_ALL")) && *s) || - ((s = getenv("LC_CTYPE")) && *s) || - ((s = getenv("LANG")) && *s)) { - if (strstr(s, "UTF-8")) - m_utf8mode = true; - } + char *s; // temporary string for enviroment variable + // check for utf-8 mode + if (((s = getenv("LC_ALL")) && *s) || + ((s = getenv("LC_CTYPE")) && *s) || + ((s = getenv("LANG")) && *s)) { + if (strstr(s, "UTF-8")) + m_utf8mode = true; + } - // create the right font implementation - // antialias is prio 1 + // create the right font implementation + // antialias is prio 1 #ifdef USE_XFT - if (antialias) { - m_fontimp.reset(new XftFontImp(0, m_utf8mode)); - m_antialias = true; - } + if (antialias) { + m_fontimp.reset(new XftFontImp(0, m_utf8mode)); + m_antialias = true; + } #endif //USE_XFT - // if we didn't create a Xft font then create basic font - if (m_fontimp.get() == 0) { + // if we didn't create a Xft font then create basic font + if (m_fontimp.get() == 0) { #ifdef USE_XMB - if (m_multibyte || m_utf8mode) - m_fontimp.reset(new XmbFontImp(0, m_utf8mode)); - else // basic font implementation + if (m_multibyte || m_utf8mode) + m_fontimp.reset(new XmbFontImp(0, m_utf8mode)); + else // basic font implementation #endif // USE_XMB - m_fontimp.reset(new XFontImp()); - } + m_fontimp.reset(new XFontImp()); + } - if (name != 0) { - load(name); - } + if (name != 0) { + load(name); + } }

@@ -111,74 +111,74 @@

} void Font::setAntialias(bool flag) { - bool loaded = m_fontimp->loaded(); + bool loaded = m_fontimp->loaded(); #ifdef USE_XFT - if (flag && !isAntialias() && !m_rotated) { - m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); - } else if (!flag && isAntialias()) + if (flag && !isAntialias() && !m_rotated) { + m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); + } else if (!flag && isAntialias()) #endif // USE_XFT { #ifdef USE_XMB - if (m_multibyte || m_utf8mode) - m_fontimp.reset(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); - else + if (m_multibyte || m_utf8mode) + m_fontimp.reset(new XmbFontImp(m_fontstr.c_str(), m_utf8mode)); + else #endif // USE_XMB - m_fontimp.reset(new XFontImp(m_fontstr.c_str())); + m_fontimp.reset(new XFontImp(m_fontstr.c_str())); } - if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' - if (!m_fontimp->load("fixed")) // if that failes too, output warning - cerr<<"Warning: can't load fallback font 'fixed'."<<endl; - } + if (m_fontimp->loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' + if (!m_fontimp->load("fixed")) // if that failes too, output warning + cerr<<"Warning: can't load fallback font 'fixed'."<<endl; + } - m_antialias = flag; + m_antialias = flag; } bool Font::load(const char *name) { - if (name == 0) - return false; - m_fontstr = name; - return m_fontimp->load(name); + if (name == 0) + return false; + m_fontstr = name; + return m_fontimp->load(name); } unsigned int Font::textWidth(const char * const text, unsigned int size) const { - return m_fontimp->textWidth(text, size); + return m_fontimp->textWidth(text, size); } unsigned int Font::height() const { - return m_fontimp->height(); + return m_fontimp->height(); } int Font::ascent() const { - return m_fontimp->ascent(); + return m_fontimp->ascent(); } int Font::descent() const { - return m_fontimp->descent(); + return m_fontimp->descent(); } void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { - if (text == 0 || len == 0) - return; - m_fontimp->drawText(w, screen, gc, text, len, x, y); + if (text == 0 || len == 0) + return; + m_fontimp->drawText(w, screen, gc, text, len, x, y); } void Font::rotate(float angle) { #ifdef USE_XFT - // if we are rotated and we are changing to horiz text - // and we were antialiased before we rotated then change to XftFontImp - if (isRotated() && angle == 0 && isAntialias()) - m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); + // if we are rotated and we are changing to horiz text + // and we were antialiased before we rotated then change to XftFontImp + if (isRotated() && angle == 0 && isAntialias()) + m_fontimp.reset(new XftFontImp(m_fontstr.c_str(), m_utf8mode)); #endif // USE_XFT - // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment) - // if we're going to rotate this font - if (angle != 0 && isAntialias() && !isRotated()) { - m_fontimp.reset(new XFontImp(m_fontstr.c_str())); - } + // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment) + // if we're going to rotate this font + if (angle != 0 && isAntialias() && !isRotated()) { + m_fontimp.reset(new XFontImp(m_fontstr.c_str())); + } - //Note: only XFontImp implements FontImp::rotate - m_fontimp->rotate(angle); + //Note: only XFontImp implements FontImp::rotate + m_fontimp->rotate(angle); - m_rotated = (angle == 0 ? false : true); + m_rotated = (angle == 0 ? false : true); } };
M src/FbTk/Font.hhsrc/FbTk/Font.hh

@@ -19,7 +19,7 @@ // 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. -//$Id: Font.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +//$Id: Font.hh,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_FONT_HH #define FBTK_FONT_HH

@@ -35,48 +35,48 @@

class FontImp; /** - Handles the client to fontimp bridge. + Handles the client to fontimp bridge. */ class Font { public: - Font(const char *name=0, bool antialias = false); - virtual ~Font(); - /** - Load a font - @return true on success, else false and it'll fall back on the last - loaded font - */ - bool load(const char *name); + Font(const char *name=0, bool antialias = false); + virtual ~Font(); + /** + Load a font + @return true on success, else false and it'll fall back on the last + loaded font + */ + bool load(const char *name); - /// @return true if multibyte is enabled, else false - static bool multibyte() { return m_multibyte; } - /// @return true if utf-8 mode is enabled, else false - static bool utf8() { return m_utf8mode; } - void setAntialias(bool flag); - /** - @param text text to check size - @param size length of text in bytes - @return size of text in pixels - */ - unsigned int textWidth(const char * const text, unsigned int size) const; - unsigned int height() const; - int ascent() const; - int descent() const; - /** - Rotate font in any angle (currently only 90 degrees supported and just XFont implementation) - */ - void rotate(float angle); - void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - bool isAntialias() const { return m_antialias; } - bool isRotated() const { return m_rotated; } + /// @return true if multibyte is enabled, else false + static bool multibyte() { return m_multibyte; } + /// @return true if utf-8 mode is enabled, else false + static bool utf8() { return m_utf8mode; } + void setAntialias(bool flag); + /** + @param text text to check size + @param size length of text in bytes + @return size of text in pixels + */ + unsigned int textWidth(const char * const text, unsigned int size) const; + unsigned int height() const; + int ascent() const; + int descent() const; + /** + Rotate font in any angle (currently only 90 degrees supported and just XFont implementation) + */ + void rotate(float angle); + void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + bool isAntialias() const { return m_antialias; } + bool isRotated() const { return m_rotated; } private: - std::auto_ptr<FontImp> m_fontimp; - std::string m_fontstr; - static bool m_multibyte; - static bool m_utf8mode; - bool m_antialias; - bool m_rotated; ///< wheter we're rotated or not + std::auto_ptr<FontImp> m_fontimp; + std::string m_fontstr; + static bool m_multibyte; + static bool m_utf8mode; + bool m_antialias; + bool m_rotated; ///< wheter we're rotated or not }; }; //end namespace FbTk
M src/FbTk/FontImp.hhsrc/FbTk/FontImp.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: FontImp.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +// $Id: FontImp.hh,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_FONTIMP_HH #define FBTK_FONTIMP_HH

@@ -33,23 +33,23 @@

namespace FbTk { /** - FontImp, second part of the bridge pattern for fonts - pure interface class. - @see Font + FontImp, second part of the bridge pattern for fonts + pure interface class. + @see Font */ class FontImp { public: - virtual ~FontImp() { } - virtual bool load(const std::string &name) = 0; - virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const = 0; - virtual unsigned int textWidth(const char * const text, unsigned int size) const = 0; - virtual int ascent() const = 0; - virtual int descent() const = 0; - virtual unsigned int height() const = 0; - virtual bool loaded() const = 0; - virtual void rotate(float angle) { } // by default, no rotate support + virtual ~FontImp() { } + virtual bool load(const std::string &name) = 0; + virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const = 0; + virtual unsigned int textWidth(const char * const text, unsigned int size) const = 0; + virtual int ascent() const = 0; + virtual int descent() const = 0; + virtual unsigned int height() const = 0; + virtual bool loaded() const = 0; + virtual void rotate(float angle) { } // by default, no rotate support protected: - FontImp() { } + FontImp() { } }; }; // end namespace FbTk
M src/FbTk/NotCopyable.hhsrc/FbTk/NotCopyable.hh

@@ -25,16 +25,16 @@

namespace FbTk { /** Makes the inherited class not copyable. - inherit this class to - disable assignment and copy + inherit this class to + disable assignment and copy */ class NotCopyable { protected: - NotCopyable() {} + NotCopyable() {} private: - NotCopyable(const NotCopyable &rhs); // copy constructor - NotCopyable &operator=(const NotCopyable &rhs); // assignment operator + NotCopyable(const NotCopyable &rhs); // copy constructor + NotCopyable &operator=(const NotCopyable &rhs); // assignment operator }; }; // end namespace FbTk
M src/FbTk/SignalHandler.ccsrc/FbTk/SignalHandler.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: SignalHandler.cc,v 1.2 2002/11/27 21:47:46 fluxgen Exp $ +// $Id: SignalHandler.cc,v 1.3 2002/12/01 13:42:14 rathnor Exp $ #include "SignalHandler.hh"

@@ -28,52 +28,52 @@

SignalEventHandler *SignalHandler::s_signal_handler[NSIG]; SignalHandler::SignalHandler() { - // clear signal list - for (int i=0; i < NSIG; ++i) - s_signal_handler[i] = 0; + // clear signal list + for (int i=0; i < NSIG; ++i) + s_signal_handler[i] = 0; } SignalHandler *SignalHandler::instance() { - static SignalHandler singleton; - return &singleton; + static SignalHandler singleton; + return &singleton; } bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh, - SignalEventHandler **oldhandler_ret) { - // must be less than NSIG - if (signum >= NSIG) - return false; + SignalEventHandler **oldhandler_ret) { + // must be less than NSIG + if (signum >= NSIG) + return false; - // get old signal handler for this signum - if (oldhandler_ret != 0) - *oldhandler_ret = s_signal_handler[signum]; + // get old signal handler for this signum + if (oldhandler_ret != 0) + *oldhandler_ret = s_signal_handler[signum]; - struct sigaction sa; - // set callback - sa.sa_handler = SignalHandler::handleSignal; - sigemptyset (&sa.sa_mask); - sa.sa_flags = 0; + struct sigaction sa; + // set callback + sa.sa_handler = SignalHandler::handleSignal; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; - if (sigaction(signum, &sa, 0) == -1) - return false; + if (sigaction(signum, &sa, 0) == -1) + return false; - s_signal_handler[signum] = eh; + s_signal_handler[signum] = eh; - return true; + return true; } void SignalHandler::removeHandler(int signum) { - if (signum < NSIG) - s_signal_handler[signum] = 0; // clear handler pointer + if (signum < NSIG) + s_signal_handler[signum] = 0; // clear handler pointer } void SignalHandler::handleSignal(int signum) { - if (signum >= NSIG) - return; - // make sure we got a handler for this signal - if (s_signal_handler[signum] != 0) { - s_signal_handler[signum]->handleSignal(signum); - } + if (signum >= NSIG) + return; + // make sure we got a handler for this signal + if (s_signal_handler[signum] != 0) { + s_signal_handler[signum]->handleSignal(signum); + } } };
M src/FbTk/SignalHandler.hhsrc/FbTk/SignalHandler.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: SignalHandler.hh,v 1.2 2002/11/27 21:47:33 fluxgen Exp $ +// $Id: SignalHandler.hh,v 1.3 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_SIGNALHANDLER_HH #define FBTK_SIGNALHANDLER_HH

@@ -31,38 +31,38 @@

class SignalEventHandler { public: - virtual void handleSignal(int signum) = 0; + virtual void handleSignal(int signum) = 0; }; /** - Handles system signals, singleton. - Usage: inherit the class EventHandler and then register - it to SignalHandler by calling registerHandler with - a signal number + Handles system signals, singleton. + Usage: inherit the class EventHandler and then register + it to SignalHandler by calling registerHandler with + a signal number */ class SignalHandler { public: - /// get singleton object - static SignalHandler *instance(); - /** - Register an event handler - @return true on success else false - @param signum signal number - @param eh event handler - @param oldhandler_ret return handler to old sighandler - */ - bool registerHandler(int signum, SignalEventHandler *eh, SignalEventHandler **oldhandler_ret = 0); - /** - removes the signum handler - @param signum signal number - */ - void removeHandler(int signum); + /// get singleton object + static SignalHandler *instance(); + /** + Register an event handler + @return true on success else false + @param signum signal number + @param eh event handler + @param oldhandler_ret return handler to old sighandler + */ + bool registerHandler(int signum, SignalEventHandler *eh, SignalEventHandler **oldhandler_ret = 0); + /** + removes the signum handler + @param signum signal number + */ + void removeHandler(int signum); private: - SignalHandler(); + SignalHandler(); - static void handleSignal(int signum); + static void handleSignal(int signum); - static SignalEventHandler *s_signal_handler[NSIG]; ///< NSIG defined in signal.h + static SignalEventHandler *s_signal_handler[NSIG]; ///< NSIG defined in signal.h }; }; // end namespace FbTk
M src/FbTk/Texture.ccsrc/FbTk/Texture.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Texture.cc,v 1.4 2002/11/30 20:35:06 fluxgen Exp $ +// $Id: Texture.cc,v 1.5 2002/12/01 13:42:14 rathnor Exp $ #include "Texture.hh"

@@ -32,66 +32,66 @@

namespace FbTk { void Texture::setFromString(const char * const texture_str) { - if (texture_str == 0) - return; - int t_len = strlen(texture_str) + 1; - char *ts = new char[t_len]; - strcpy(ts, texture_str); + if (texture_str == 0) + return; + int t_len = strlen(texture_str) + 1; + char *ts = new char[t_len]; + strcpy(ts, texture_str); - // to lower - for (size_t byte_pos = 0; byte_pos < strlen(ts); ++byte_pos) - ts[byte_pos] = tolower(ts[byte_pos]); + // to lower + for (size_t byte_pos = 0; byte_pos < strlen(ts); ++byte_pos) + ts[byte_pos] = tolower(ts[byte_pos]); - if (strstr(ts, "parentrelative")) { - setType(Texture::PARENTRELATIVE); - } else { - setType(Texture::NONE); + if (strstr(ts, "parentrelative")) { + setType(Texture::PARENTRELATIVE); + } else { + setType(Texture::NONE); - if (strstr(ts, "solid")) - addType(Texture::SOLID); - else if (strstr(ts, "gradient")) { - addType(Texture::GRADIENT); - if (strstr(ts, "crossdiagonal")) - addType(Texture::CROSSDIAGONAL); - else if (strstr(ts, "rectangle")) - addType(Texture::RECTANGLE); - else if (strstr(ts, "pyramid")) - addType(Texture::PYRAMID); - else if (strstr(ts, "pipecross")) - addType(Texture::PIPECROSS); - else if (strstr(ts, "elliptic")) - addType(Texture::ELLIPTIC); - else if (strstr(ts, "diagonal")) - addType(Texture::DIAGONAL); - else if (strstr(ts, "horizontal")) - addType(Texture::HORIZONTAL); - else if (strstr(ts, "vertical")) - addType(Texture::VERTICAL); - else - addType(Texture::DIAGONAL); - } else - addType(Texture::SOLID); + if (strstr(ts, "solid")) + addType(Texture::SOLID); + else if (strstr(ts, "gradient")) { + addType(Texture::GRADIENT); + if (strstr(ts, "crossdiagonal")) + addType(Texture::CROSSDIAGONAL); + else if (strstr(ts, "rectangle")) + addType(Texture::RECTANGLE); + else if (strstr(ts, "pyramid")) + addType(Texture::PYRAMID); + else if (strstr(ts, "pipecross")) + addType(Texture::PIPECROSS); + else if (strstr(ts, "elliptic")) + addType(Texture::ELLIPTIC); + else if (strstr(ts, "diagonal")) + addType(Texture::DIAGONAL); + else if (strstr(ts, "horizontal")) + addType(Texture::HORIZONTAL); + else if (strstr(ts, "vertical")) + addType(Texture::VERTICAL); + else + addType(Texture::DIAGONAL); + } else + addType(Texture::SOLID); - if (strstr(ts, "raised")) - addType(Texture::RAISED); - else if (strstr(ts, "sunken")) - addType(Texture::SUNKEN); - else if (strstr(ts, "flat")) - addType(Texture::FLAT); - else - addType(Texture::RAISED); + if (strstr(ts, "raised")) + addType(Texture::RAISED); + else if (strstr(ts, "sunken")) + addType(Texture::SUNKEN); + else if (strstr(ts, "flat")) + addType(Texture::FLAT); + else + addType(Texture::RAISED); - if (! (type() & Texture::FLAT)) - if (strstr(ts, "bevel2")) - addType(Texture::BEVEL2); - else - addType(Texture::BEVEL1); + if (! (type() & Texture::FLAT)) + if (strstr(ts, "bevel2")) + addType(Texture::BEVEL2); + else + addType(Texture::BEVEL1); - if (strstr(ts, "interlaced")) - addType(Texture::INTERLACED); - } + if (strstr(ts, "interlaced")) + addType(Texture::INTERLACED); + } - delete [] ts; + delete [] ts; } }; // end namespace FbTk
M src/FbTk/Texture.hhsrc/FbTk/Texture.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Texture.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +// $Id: Texture.hh,v 1.2 2002/12/01 13:42:14 rathnor Exp $ #ifndef FBTK_TEXTURE_HH #define FBTK_TEXTURE_HH

@@ -32,64 +32,64 @@

namespace FbTk { /** - Holds texture type and info + Holds texture type and info */ class Texture { public: - enum Bevel { - FLAT = 0x00002, - SUNKEN = 0x00004, - RAISED = 0x00008 - }; + enum Bevel { + FLAT = 0x00002, + SUNKEN = 0x00004, + RAISED = 0x00008 + }; - enum Textures { - NONE = 0x00000, - SOLID = 0x00010, - GRADIENT = 0x00020 - }; + enum Textures { + NONE = 0x00000, + SOLID = 0x00010, + GRADIENT = 0x00020 + }; - enum Gradients { - HORIZONTAL = 0x00040, - VERTICAL = 0x00080, - DIAGONAL = 0x00100, - CROSSDIAGONAL = 0x00200, - RECTANGLE = 0x00400, - PYRAMID = 0x00800, - PIPECROSS = 0x01000, - ELLIPTIC = 0x02000 - }; + enum Gradients { + HORIZONTAL = 0x00040, + VERTICAL = 0x00080, + DIAGONAL = 0x00100, + CROSSDIAGONAL = 0x00200, + RECTANGLE = 0x00400, + PYRAMID = 0x00800, + PIPECROSS = 0x01000, + ELLIPTIC = 0x02000 + }; - enum { - BEVEL1 = 0x04000, - BEVEL2 = 0x08000, // bevel types - INVERT = 0x010000, //inverted image - PARENTRELATIVE = 0x20000, - INTERLACED = 0x40000 - }; + enum { + BEVEL1 = 0x04000, + BEVEL2 = 0x08000, // bevel types + INVERT = 0x010000, //inverted image + PARENTRELATIVE = 0x20000, + INTERLACED = 0x40000 + }; - Texture():m_type(0) { } + Texture():m_type(0) { } - void setType(unsigned long t) { m_type = t; } - void addType(unsigned long t) { m_type |= t; } - void setFromString(const char * const str); + void setType(unsigned long t) { m_type = t; } + void addType(unsigned long t) { m_type |= t; } + void setFromString(const char * const str); - Color &color() { return m_color; } - Color &colorTo() { return m_color_to; } - Color &hiColor() { return m_hicolor; } - Color &loColor() { return m_locolor; } + Color &color() { return m_color; } + Color &colorTo() { return m_color_to; } + Color &hiColor() { return m_hicolor; } + Color &loColor() { return m_locolor; } - const Color &color() const { return m_color; } - const Color &colorTo() const { return m_color_to; } - const Color &hiColor() const { return m_hicolor; } - const Color &loColor() const { return m_locolor; } + const Color &color() const { return m_color; } + const Color &colorTo() const { return m_color_to; } + const Color &hiColor() const { return m_hicolor; } + const Color &loColor() const { return m_locolor; } - inline unsigned long type() const { return m_type; } + inline unsigned long type() const { return m_type; } private: - FbTk::Color m_color, m_color_to, m_hicolor, m_locolor; - unsigned long m_type; + FbTk::Color m_color, m_color_to, m_hicolor, m_locolor; + unsigned long m_type; }; }; // end namespace FbTk
M src/FbTk/XFontImp.ccsrc/FbTk/XFontImp.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: XFontImp.cc,v 1.3 2002/11/26 19:56:48 fluxgen Exp $ +// $Id: XFontImp.cc,v 1.4 2002/12/01 13:42:14 rathnor Exp $ #include "XFontImp.hh" #include "App.hh"

@@ -34,353 +34,353 @@

namespace FbTk { XFontImp::XFontImp(const char *fontname):m_rotfont(0), m_fontstruct(0), -m_angle(0) { - if (fontname != 0) - load(fontname); + m_angle(0) { + if (fontname != 0) + load(fontname); } XFontImp::~XFontImp() { - if (m_fontstruct != 0) - XFreeFont(App::instance()->display(), m_fontstruct); - if (m_rotfont != 0) - freeRotFont(); + if (m_fontstruct != 0) + XFreeFont(App::instance()->display(), m_fontstruct); + if (m_rotfont != 0) + freeRotFont(); } int XFontImp::ascent() const { - if (m_fontstruct == 0) - return 0; - if (m_rotfont != 0) - return m_rotfont->max_ascent; + if (m_fontstruct == 0) + return 0; + if (m_rotfont != 0) + return m_rotfont->max_ascent; - return m_fontstruct->ascent; + return m_fontstruct->ascent; } bool XFontImp::load(const std::string &fontname) { - XFontStruct *font = XLoadQueryFont(App::instance()->display(), fontname.c_str()); - if (font == 0) - return false; - if (m_fontstruct != 0) // free old font struct, if any - XFreeFont(App::instance()->display(), m_fontstruct); + XFontStruct *font = XLoadQueryFont(App::instance()->display(), fontname.c_str()); + if (font == 0) + return false; + if (m_fontstruct != 0) // free old font struct, if any + XFreeFont(App::instance()->display(), m_fontstruct); - m_fontstruct = font; //set new font - return true; + m_fontstruct = font; //set new font + return true; } void XFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { - if (m_fontstruct == 0) - return; - // use roated font functions? - if (m_rotfont != 0) { - drawRotText(w, screen, gc, text, len, x, y); - return; - } + if (m_fontstruct == 0) + return; + // use roated font functions? + if (m_rotfont != 0) { + drawRotText(w, screen, gc, text, len, x, y); + return; + } - Display *disp = App::instance()->display(); - XSetFont(disp, gc, m_fontstruct->fid); - XDrawString(disp, w, gc, x, y, text, len); + Display *disp = App::instance()->display(); + XSetFont(disp, gc, m_fontstruct->fid); + XDrawString(disp, w, gc, x, y, text, len); } unsigned int XFontImp::textWidth(const char * const text, unsigned int size) const { - if (text == 0) - return 0; - if (m_fontstruct == 0) - return 0; - // check rotated font? - if (m_rotfont != 0) - return rotTextWidth(text, size); + if (text == 0) + return 0; + if (m_fontstruct == 0) + return 0; + // check rotated font? + if (m_rotfont != 0) + return rotTextWidth(text, size); - return XTextWidth(m_fontstruct, text, size); + return XTextWidth(m_fontstruct, text, size); } unsigned int XFontImp::height() const { - if (m_fontstruct == 0) - return 0; + if (m_fontstruct == 0) + return 0; - return m_fontstruct->ascent + m_fontstruct->descent; + return m_fontstruct->ascent + m_fontstruct->descent; } void XFontImp::rotate(float angle) { - //we must have a font loaded before we rotate - if (m_fontstruct == 0) - return; - if (m_rotfont != 0) - freeRotFont(); - // no need for rotating, use regular font - if (angle == 0) - return; + //we must have a font loaded before we rotate + if (m_fontstruct == 0) + return; + if (m_rotfont != 0) + freeRotFont(); + // no need for rotating, use regular font + if (angle == 0) + return; - //get positive angle - while (angle < 0) - angle += 360; + //get positive angle + while (angle < 0) + angle += 360; - char val; - XImage *I1, *I2; - // X system default vars - Display *dpy = App::instance()->display(); - Window rootwin = DefaultRootWindow(dpy); - int screen = DefaultScreen(dpy); + char val; + XImage *I1, *I2; + // X system default vars + Display *dpy = App::instance()->display(); + Window rootwin = DefaultRootWindow(dpy); + int screen = DefaultScreen(dpy); - GC font_gc; - char text[3]; - int ichar, i, j, index, boxlen = 60; - int vert_w, vert_h, vert_len, bit_w, bit_h, bit_len; - int min_char, max_char; - unsigned char *vertdata, *bitdata; - int ascent, descent, lbearing, rbearing; + GC font_gc; + char text[3]; + int ichar, i, j, index, boxlen = 60; + int vert_w, vert_h, vert_len, bit_w, bit_h, bit_len; + int min_char, max_char; + unsigned char *vertdata, *bitdata; + int ascent, descent, lbearing, rbearing; - // get nearest vertical or horizontal direction - int dir = (int)((angle+45.0)/90.0)%4; + // get nearest vertical or horizontal direction + int dir = (int)((angle+45.0)/90.0)%4; - if (dir == 0) // no rotation - return; + if (dir == 0) // no rotation + return; - // create the depth 1 canvas bitmap - Pixmap canvas = XCreatePixmap(dpy, rootwin, boxlen, boxlen, 1); + // create the depth 1 canvas bitmap + Pixmap canvas = XCreatePixmap(dpy, rootwin, boxlen, boxlen, 1); - // create graphic context for our canvas - font_gc = XCreateGC(dpy, canvas, 0, 0); + // create graphic context for our canvas + font_gc = XCreateGC(dpy, canvas, 0, 0); - XSetBackground(dpy, font_gc, None); + XSetBackground(dpy, font_gc, None); - XSetFont(dpy, font_gc, m_fontstruct->fid); + XSetFont(dpy, font_gc, m_fontstruct->fid); - // allocate space for rotated font - m_rotfont = new(nothrow) XRotFontStruct; + // allocate space for rotated font + m_rotfont = new(nothrow) XRotFontStruct; - if (m_rotfont == 0) { - cerr<<"RotFont: out of memory"<<endl; - return; - } + if (m_rotfont == 0) { + cerr<<"RotFont: out of memory"<<endl; + return; + } - // determine which characters are defined in font - min_char = m_fontstruct->min_char_or_byte2; - max_char = m_fontstruct->max_char_or_byte2; + // determine which characters are defined in font + min_char = m_fontstruct->min_char_or_byte2; + max_char = m_fontstruct->max_char_or_byte2; - // we only want printable chars - if (min_char<32) - min_char = 32; - if (max_char>126) - max_char = 126; + // we only want printable chars + if (min_char<32) + min_char = 32; + if (max_char>126) + max_char = 126; - /* some overall font data ... */ - m_rotfont->dir = dir; - m_rotfont->min_char = min_char; - m_rotfont->max_char = max_char; - m_rotfont->max_ascent = m_fontstruct->max_bounds.ascent; - m_rotfont->max_descent = m_fontstruct->max_bounds.descent; - m_rotfont->height = m_rotfont->max_ascent + m_rotfont->max_descent; + /* some overall font data ... */ + m_rotfont->dir = dir; + m_rotfont->min_char = min_char; + m_rotfont->max_char = max_char; + m_rotfont->max_ascent = m_fontstruct->max_bounds.ascent; + m_rotfont->max_descent = m_fontstruct->max_bounds.descent; + m_rotfont->height = m_rotfont->max_ascent + m_rotfont->max_descent; - // font needs rotation - // loop through each character - for (ichar = min_char; ichar <= max_char; ichar++) { - index = ichar - m_fontstruct->min_char_or_byte2; + // font needs rotation + // loop through each character + for (ichar = min_char; ichar <= max_char; ichar++) { + index = ichar - m_fontstruct->min_char_or_byte2; - // per char dimensions ... - ascent = m_rotfont->per_char[ichar-32].ascent = m_fontstruct->per_char[index].ascent; - descent = m_rotfont->per_char[ichar-32].descent = m_fontstruct->per_char[index].descent; - lbearing = m_rotfont->per_char[ichar-32].lbearing = m_fontstruct->per_char[index].lbearing; - rbearing = m_rotfont->per_char[ichar-32].rbearing = m_fontstruct->per_char[index].rbearing; - m_rotfont->per_char[ichar-32].width = m_fontstruct->per_char[index].width; + // per char dimensions ... + ascent = m_rotfont->per_char[ichar-32].ascent = m_fontstruct->per_char[index].ascent; + descent = m_rotfont->per_char[ichar-32].descent = m_fontstruct->per_char[index].descent; + lbearing = m_rotfont->per_char[ichar-32].lbearing = m_fontstruct->per_char[index].lbearing; + rbearing = m_rotfont->per_char[ichar-32].rbearing = m_fontstruct->per_char[index].rbearing; + m_rotfont->per_char[ichar-32].width = m_fontstruct->per_char[index].width; - // some space chars have zero body, but a bitmap can't have - if (!ascent && !descent) - ascent = m_rotfont->per_char[ichar-32].ascent = 1; - if (!lbearing && !rbearing) - rbearing = m_rotfont->per_char[ichar-32].rbearing = 1; + // some space chars have zero body, but a bitmap can't have + if (!ascent && !descent) + ascent = m_rotfont->per_char[ichar-32].ascent = 1; + if (!lbearing && !rbearing) + rbearing = m_rotfont->per_char[ichar-32].rbearing = 1; - // glyph width and height when vertical - vert_w = rbearing - lbearing; - vert_h = ascent + descent; + // glyph width and height when vertical + vert_w = rbearing - lbearing; + vert_h = ascent + descent; - // width in bytes - vert_len = (vert_w-1)/8+1; + // width in bytes + vert_len = (vert_w-1)/8+1; - XSetForeground(dpy, font_gc, None); - XFillRectangle(dpy, canvas, font_gc, 0, 0, boxlen, boxlen); + XSetForeground(dpy, font_gc, None); + XFillRectangle(dpy, canvas, font_gc, 0, 0, boxlen, boxlen); - // draw the character centre top right on canvas - sprintf(text, "%c", ichar); - XSetForeground(dpy, font_gc, 1); - XDrawImageString(dpy, canvas, font_gc, boxlen/2 - lbearing, - boxlen/2 - descent, text, 1); + // draw the character centre top right on canvas + sprintf(text, "%c", ichar); + XSetForeground(dpy, font_gc, 1); + XDrawImageString(dpy, canvas, font_gc, boxlen/2 - lbearing, + boxlen/2 - descent, text, 1); - // reserve memory for first XImage - vertdata = (unsigned char *) malloc((unsigned)(vert_len*vert_h)); + // reserve memory for first XImage + vertdata = (unsigned char *) malloc((unsigned)(vert_len*vert_h)); - /* create the XImage ... */ - I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, - 0, (char *)vertdata, vert_w, vert_h, 8, 0); + /* create the XImage ... */ + I1 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, + 0, (char *)vertdata, vert_w, vert_h, 8, 0); - if (I1 == None) { - cerr<<"RotFont: Cant create ximage."<<endl; - delete m_rotfont; - m_rotfont = 0; - return; - } + if (I1 == None) { + cerr<<"RotFont: Cant create ximage."<<endl; + delete m_rotfont; + m_rotfont = 0; + return; + } - I1->byte_order = I1->bitmap_bit_order = MSBFirst; + I1->byte_order = I1->bitmap_bit_order = MSBFirst; - /* extract character from canvas ... */ - XGetSubImage(dpy, canvas, boxlen/2, boxlen/2 - vert_h, - vert_w, vert_h, 1, XYPixmap, I1, 0, 0); - I1->format = XYBitmap; + /* extract character from canvas ... */ + XGetSubImage(dpy, canvas, boxlen/2, boxlen/2 - vert_h, + vert_w, vert_h, 1, XYPixmap, I1, 0, 0); + I1->format = XYBitmap; - /* width, height of rotated character ... */ - if (dir == 2) { - bit_w = vert_w; - bit_h = vert_h; - } else { - bit_w = vert_h; - bit_h = vert_w; - } + /* width, height of rotated character ... */ + if (dir == 2) { + bit_w = vert_w; + bit_h = vert_h; + } else { + bit_w = vert_h; + bit_h = vert_w; + } - /* width in bytes ... */ - bit_len = (bit_w-1)/8 + 1; + /* width in bytes ... */ + bit_len = (bit_w-1)/8 + 1; - m_rotfont->per_char[ichar-32].glyph.bit_w = bit_w; - m_rotfont->per_char[ichar-32].glyph.bit_h = bit_h; + m_rotfont->per_char[ichar-32].glyph.bit_w = bit_w; + m_rotfont->per_char[ichar-32].glyph.bit_h = bit_h; - /* reserve memory for the rotated image ... */ - bitdata = (unsigned char *)calloc((unsigned)(bit_h * bit_len), 1); + /* reserve memory for the rotated image ... */ + bitdata = (unsigned char *)calloc((unsigned)(bit_h * bit_len), 1); - /* create the image ... */ - I2 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0, - (char *)bitdata, bit_w, bit_h, 8, 0); + /* create the image ... */ + I2 = XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0, + (char *)bitdata, bit_w, bit_h, 8, 0); - if (I2 == None) { - cerr<<"XFontImp: Cant create ximage!"<<endl; - delete m_rotfont; - m_rotfont = 0; - return; - } + if (I2 == None) { + cerr<<"XFontImp: Cant create ximage!"<<endl; + delete m_rotfont; + m_rotfont = 0; + return; + } - I2->byte_order = I2->bitmap_bit_order = MSBFirst; + I2->byte_order = I2->bitmap_bit_order = MSBFirst; - /* map vertical data to rotated character ... */ - for (j = 0; j < bit_h; j++) { - for (i = 0; i < bit_w; i++) { + /* map vertical data to rotated character ... */ + for (j = 0; j < bit_h; j++) { + for (i = 0; i < bit_w; i++) { /* map bits ... */ - if (dir == 1) { - val = vertdata[i*vert_len + (vert_w-j-1)/8] & - (128>>((vert_w-j-1)%8)); - } else if (dir == 2) { - val = vertdata[(vert_h-j-1)*vert_len + - (vert_w-i-1)/8] & (128>>((vert_w-i-1)%8)); - } else { - val = vertdata[(vert_h-i-1)*vert_len + j/8] & - (128>>(j%8)); - } - if (val) { - bitdata[j*bit_len + i/8] = bitdata[j*bit_len + i/8] | - (128>>(i%8)); - } - } - } + if (dir == 1) { + val = vertdata[i*vert_len + (vert_w-j-1)/8] & + (128>>((vert_w-j-1)%8)); + } else if (dir == 2) { + val = vertdata[(vert_h-j-1)*vert_len + + (vert_w-i-1)/8] & (128>>((vert_w-i-1)%8)); + } else { + val = vertdata[(vert_h-i-1)*vert_len + j/8] & + (128>>(j%8)); + } + if (val) { + bitdata[j*bit_len + i/8] = bitdata[j*bit_len + i/8] | + (128>>(i%8)); + } + } + } - // create this character's bitmap - m_rotfont->per_char[ichar-32].glyph.bm = - XCreatePixmap(dpy, rootwin, bit_w, bit_h, 1); + // create this character's bitmap + m_rotfont->per_char[ichar-32].glyph.bm = + XCreatePixmap(dpy, rootwin, bit_w, bit_h, 1); - // put the image into the bitmap - XPutImage(dpy, m_rotfont->per_char[ichar-32].glyph.bm, - font_gc, I2, 0, 0, 0, 0, bit_w, bit_h); + // put the image into the bitmap + XPutImage(dpy, m_rotfont->per_char[ichar-32].glyph.bm, + font_gc, I2, 0, 0, 0, 0, bit_w, bit_h); - // free the image and data - XDestroyImage(I1); - XDestroyImage(I2); - } + // free the image and data + XDestroyImage(I1); + XDestroyImage(I2); + } - /* free pixmap and GC ... */ - XFreePixmap(dpy, canvas); - XFreeGC(dpy, font_gc); + /* free pixmap and GC ... */ + XFreePixmap(dpy, canvas); + XFreeGC(dpy, font_gc); } void XFontImp::freeRotFont() { - if (m_rotfont == 0) - return; - // loop through each character and free its pixmap - for (int ichar = m_rotfont->min_char - 32; - ichar <= m_rotfont->max_char - 32; ++ichar) { - XFreePixmap(App::instance()->display(), m_rotfont->per_char[ichar].glyph.bm); - } + if (m_rotfont == 0) + return; + // loop through each character and free its pixmap + for (int ichar = m_rotfont->min_char - 32; + ichar <= m_rotfont->max_char - 32; ++ichar) { + XFreePixmap(App::instance()->display(), m_rotfont->per_char[ichar].glyph.bm); + } - delete m_rotfont; - m_rotfont = 0; + delete m_rotfont; + m_rotfont = 0; } void XFontImp::drawRotText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { - Display *dpy = App::instance()->display(); - static GC my_gc = 0; - int xp, yp, dir, ichar; + Display *dpy = App::instance()->display(); + static GC my_gc = 0; + int xp, yp, dir, ichar; - if (text == NULL || len<1) - return; + if (text == NULL || len<1) + return; - dir = m_rotfont->dir; - if (my_gc == 0) - my_gc = XCreateGC(dpy, w, 0, 0); + dir = m_rotfont->dir; + if (my_gc == 0) + my_gc = XCreateGC(dpy, w, 0, 0); - XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc); + XCopyGC(dpy, gc, GCForeground|GCBackground, my_gc); - // vertical or upside down + // vertical or upside down - XSetFillStyle(dpy, my_gc, FillStippled); + XSetFillStyle(dpy, my_gc, FillStippled); - // loop through each character in texting - for (size_t i = 0; i<len; i++) { - ichar = text[i]-32; + // loop through each character in texting + for (size_t i = 0; i<len; i++) { + ichar = text[i]-32; - // make sure it's a printing character - if (ichar >= 0 && ichar<95) { - // suitable offset - if (dir == 1) { - xp = x-m_rotfont->per_char[ichar].ascent; - yp = y-m_rotfont->per_char[ichar].rbearing; - } else if (dir == 2) { - xp = x-m_rotfont->per_char[ichar].rbearing; - yp = y-m_rotfont->per_char[ichar].descent+1; - } else { - xp = x-m_rotfont->per_char[ichar].descent+1; - yp = y+m_rotfont->per_char[ichar].lbearing; - } + // make sure it's a printing character + if (ichar >= 0 && ichar<95) { + // suitable offset + if (dir == 1) { + xp = x-m_rotfont->per_char[ichar].ascent; + yp = y-m_rotfont->per_char[ichar].rbearing; + } else if (dir == 2) { + xp = x-m_rotfont->per_char[ichar].rbearing; + yp = y-m_rotfont->per_char[ichar].descent+1; + } else { + xp = x-m_rotfont->per_char[ichar].descent+1; + yp = y+m_rotfont->per_char[ichar].lbearing; + } - // draw the glyph - XSetStipple(dpy, my_gc, m_rotfont->per_char[ichar].glyph.bm); + // draw the glyph + XSetStipple(dpy, my_gc, m_rotfont->per_char[ichar].glyph.bm); - XSetTSOrigin(dpy, my_gc, xp, yp); + XSetTSOrigin(dpy, my_gc, xp, yp); - XFillRectangle(dpy, w, my_gc, xp, yp, - m_rotfont->per_char[ichar].glyph.bit_w, - m_rotfont->per_char[ichar].glyph.bit_h); + XFillRectangle(dpy, w, my_gc, xp, yp, + m_rotfont->per_char[ichar].glyph.bit_w, + m_rotfont->per_char[ichar].glyph.bit_h); - // advance position - if (dir == 1) - y -= m_rotfont->per_char[ichar].width; - else if (dir == 2) - x -= m_rotfont->per_char[ichar].width; - else - y += m_rotfont->per_char[ichar].width; - } - } + // advance position + if (dir == 1) + y -= m_rotfont->per_char[ichar].width; + else if (dir == 2) + x -= m_rotfont->per_char[ichar].width; + else + y += m_rotfont->per_char[ichar].width; + } + } } unsigned int XFontImp::rotTextWidth(const char * const text, unsigned int size) const { - if (text == 0) - return 0; + if (text == 0) + return 0; - unsigned int width = 0; - for (size_t i = 0; i<size; i++) { - int ichar = text[i] - 32; - // make sure it's a printing character - if (ichar >= 0 && ichar < 95) - width += m_rotfont->per_char[ichar].width; - } + unsigned int width = 0; + for (size_t i = 0; i<size; i++) { + int ichar = text[i] - 32; + // make sure it's a printing character + if (ichar >= 0 && ichar < 95) + width += m_rotfont->per_char[ichar].width; + } - return width; + return width; } };
M src/FbTk/XFontImp.hhsrc/FbTk/XFontImp.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: XFontImp.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +// $Id: XFontImp.hh,v 1.2 2002/12/01 13:42:15 rathnor Exp $ #ifndef FBTK_XFONTIMP_HH #define FBTK_XFONTIMP_HH

@@ -29,51 +29,51 @@ namespace FbTk {

class XFontImp:public FbTk::FontImp { public: - explicit XFontImp(const char *filename = 0); - ~XFontImp(); - bool load(const std::string &filename); - unsigned int textWidth(const char * const text, unsigned int size) const; - unsigned int height() const; - float angle() const { return m_angle; } - int ascent() const; - int descent() const { return m_fontstruct ? m_fontstruct->descent : 0; } - void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - bool loaded() const { return m_fontstruct != 0; } - void rotate(float angle); + explicit XFontImp(const char *filename = 0); + ~XFontImp(); + bool load(const std::string &filename); + unsigned int textWidth(const char * const text, unsigned int size) const; + unsigned int height() const; + float angle() const { return m_angle; } + int ascent() const; + int descent() const { return m_fontstruct ? m_fontstruct->descent : 0; } + void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + bool loaded() const { return m_fontstruct != 0; } + void rotate(float angle); private: - void freeRotFont(); - void drawRotText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - unsigned int rotTextWidth(const char * const text, unsigned int size) const; - struct BitmapStruct { - int bit_w; - int bit_h; + void freeRotFont(); + void drawRotText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + unsigned int rotTextWidth(const char * const text, unsigned int size) const; + struct BitmapStruct { + int bit_w; + int bit_h; - Pixmap bm; - }; + Pixmap bm; + }; - struct XRotCharStruct { - int ascent; - int descent; - int lbearing; - int rbearing; - int width; + struct XRotCharStruct { + int ascent; + int descent; + int lbearing; + int rbearing; + int width; - BitmapStruct glyph; - }; + BitmapStruct glyph; + }; - struct XRotFontStruct { - int dir; - int height; - int max_ascent; - int max_descent; - int max_char; - int min_char; + struct XRotFontStruct { + int dir; + int height; + int max_ascent; + int max_descent; + int max_char; + int min_char; - XRotCharStruct per_char[95]; - }; - XRotFontStruct *m_rotfont; - XFontStruct *m_fontstruct; - float m_angle; + XRotCharStruct per_char[95]; + }; + XRotFontStruct *m_rotfont; + XFontStruct *m_fontstruct; + float m_angle; }; }; // end namespace FbTk
M src/FbTk/XftFontImp.ccsrc/FbTk/XftFontImp.cc

@@ -19,7 +19,7 @@ // 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. -//$Id: XftFontImp.cc,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +//$Id: XftFontImp.cc,v 1.2 2002/12/01 13:42:15 rathnor Exp $ #include "XftFontImp.hh" #include "App.hh"

@@ -30,114 +30,114 @@ #endif //HAVE_CONFIG_H

namespace FbTk { XftFontImp::XftFontImp(const char *name, bool utf8):m_xftfont(0), -m_utf8mode(utf8) { - if (name != 0) - load(name); + m_utf8mode(utf8) { + if (name != 0) + load(name); } XftFontImp::~XftFontImp() { - if (m_xftfont != 0) - XftFontClose(App::instance()->display(), m_xftfont); + if (m_xftfont != 0) + XftFontClose(App::instance()->display(), m_xftfont); } bool XftFontImp::load(const std::string &name) { - //Note: assumes screen 0 for now, changes on draw if needed + //Note: assumes screen 0 for now, changes on draw if needed - Display *disp = App::instance()->display(); - XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); + Display *disp = App::instance()->display(); + XftFont *newxftfont = XftFontOpenName(disp, 0, name.c_str()); - if (newxftfont == 0) { // failed to open font, lets test with XLFD - newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); - if (newxftfont == 0) - return false; - } - // destroy old font and set new - if (m_xftfont != 0) - XftFontClose(disp, m_xftfont); + if (newxftfont == 0) { // failed to open font, lets test with XLFD + newxftfont = XftFontOpenXlfd(disp, 0, name.c_str()); + if (newxftfont == 0) + return false; + } + // destroy old font and set new + if (m_xftfont != 0) + XftFontClose(disp, m_xftfont); - m_xftfont = newxftfont; + m_xftfont = newxftfont; - return true; + return true; } void XftFontImp::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { - if (m_xftfont == 0) - return; - Display *disp = App::instance()->display(); - XftDraw *draw = XftDrawCreate(disp, - w, - DefaultVisual(disp, screen), - DefaultColormap(disp, screen)); + if (m_xftfont == 0) + return; + Display *disp = App::instance()->display(); + XftDraw *draw = XftDrawCreate(disp, + w, + DefaultVisual(disp, screen), + DefaultColormap(disp, screen)); - XGCValues gc_val; + XGCValues gc_val; - // get foreground pixel value and convert it to XRenderColor value - // TODO: we should probably check return status - XGetGCValues(disp, gc, GCForeground, &gc_val); + // get foreground pixel value and convert it to XRenderColor value + // TODO: we should probably check return status + XGetGCValues(disp, gc, GCForeground, &gc_val); - // get red, green, blue values - XColor xcol; - xcol.pixel = gc_val.foreground; - XQueryColor(disp, DefaultColormap(disp, screen), &xcol); + // get red, green, blue values + XColor xcol; + xcol.pixel = gc_val.foreground; + XQueryColor(disp, DefaultColormap(disp, screen), &xcol); - // convert xcolor to XftColor - XRenderColor rendcol; - rendcol.red = xcol.red; - rendcol.green = xcol.green; - rendcol.blue = xcol.blue; - rendcol.alpha = 0xFFFF; - XftColor xftcolor; - XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), - &rendcol, &xftcolor); + // convert xcolor to XftColor + XRenderColor rendcol; + rendcol.red = xcol.red; + rendcol.green = xcol.green; + rendcol.blue = xcol.blue; + rendcol.alpha = 0xFFFF; + XftColor xftcolor; + XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), + &rendcol, &xftcolor); - // draw string + // draw string #ifdef HAVE_XFT_UTF8_STRING - if (m_utf8mode) { - XftDrawStringUtf8(draw, - &xftcolor, - m_xftfont, - x, y, - (XftChar8 *)(text), len); - } else + if (m_utf8mode) { + XftDrawStringUtf8(draw, + &xftcolor, + m_xftfont, + x, y, + (XftChar8 *)(text), len); + } else #endif // HAVE_XFT_UTF8_STRING { - XftDrawString8(draw, - &xftcolor, - m_xftfont, - x, y, - (XftChar8 *)(text), len); + XftDrawString8(draw, + &xftcolor, + m_xftfont, + x, y, + (XftChar8 *)(text), len); } - XftColorFree(disp, DefaultVisual(disp, screen), - DefaultColormap(disp, screen), &xftcolor); - XftDrawDestroy(draw); + XftColorFree(disp, DefaultVisual(disp, screen), + DefaultColormap(disp, screen), &xftcolor); + XftDrawDestroy(draw); } unsigned int XftFontImp::textWidth(const char * const text, unsigned int len) const { - if (m_xftfont == 0) - return 0; - XGlyphInfo ginfo; + if (m_xftfont == 0) + return 0; + XGlyphInfo ginfo; #ifdef HAVE_XFT_UTF8_STRING - if (m_utf8mode) { - XftTextExtentsUtf8(App::instance()->display(), - m_xftfont, - (XftChar8 *)text, len, - &ginfo); - } else + if (m_utf8mode) { + XftTextExtentsUtf8(App::instance()->display(), + m_xftfont, + (XftChar8 *)text, len, + &ginfo); + } else #endif //HAVE_XFT_UTF8_STRING { - XftTextExtents8(App::instance()->display(), - m_xftfont, - (XftChar8 *)text, len, - &ginfo); + XftTextExtents8(App::instance()->display(), + m_xftfont, + (XftChar8 *)text, len, + &ginfo); } - return ginfo.xOff; + return ginfo.xOff; } unsigned int XftFontImp::height() const { - if (m_xftfont == 0) - return 0; - return m_xftfont->height; + if (m_xftfont == 0) + return 0; + return m_xftfont->height; } }; // end namespace FbTk
M src/FbTk/XftFontImp.hhsrc/FbTk/XftFontImp.hh

@@ -19,7 +19,7 @@ // 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. -//$Id: XftFontImp.hh,v 1.1 2002/11/26 16:01:27 fluxgen Exp $ +//$Id: XftFontImp.hh,v 1.2 2002/12/01 13:42:15 rathnor Exp $ #ifndef XFTFONTIMP_HH #define XFTFONTIMP_HH

@@ -30,18 +30,18 @@ namespace FbTk {

class XftFontImp:public FbTk::FontImp { public: - XftFontImp(const char *fontname, bool utf8); - ~XftFontImp(); - bool load(const std::string &name); - void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - unsigned int textWidth(const char * const text, unsigned int len) const; - unsigned int height() const; - int ascent() const { return m_xftfont ? m_xftfont->ascent : 0; } - int descent() const { return m_xftfont ? m_xftfont->descent : 0; } - bool loaded() const { return m_xftfont != 0; } + XftFontImp(const char *fontname, bool utf8); + ~XftFontImp(); + bool load(const std::string &name); + void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + unsigned int textWidth(const char * const text, unsigned int len) const; + unsigned int height() const; + int ascent() const { return m_xftfont ? m_xftfont->ascent : 0; } + int descent() const { return m_xftfont ? m_xftfont->descent : 0; } + bool loaded() const { return m_xftfont != 0; } private: - XftFont *m_xftfont; - bool m_utf8mode; + XftFont *m_xftfont; + bool m_utf8mode; }; }; // end namespace FbTk
M src/FbTk/XmbFontImp.ccsrc/FbTk/XmbFontImp.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: XmbFontImp.cc,v 1.2 2002/11/26 20:04:15 fluxgen Exp $ +// $Id: XmbFontImp.cc,v 1.3 2002/12/01 13:42:15 rathnor Exp $ #include "XmbFontImp.hh"

@@ -50,131 +50,131 @@ // Tries to find a string in another and

// ignoring the case of the characters // Returns 0 on success else pointer to str. const char *strcasestr(const char *str, const char *ptn) { - const char *s2, *p2; - for( ; *str; str++) { - for(s2=str, p2=ptn; ; s2++,p2++) { - if (!*p2) return str; // check if we reached the end of ptn, if so, return str - if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case) - } - } - return 0; + const char *s2, *p2; + for( ; *str; str++) { + for(s2=str, p2=ptn; ; s2++,p2++) { + if (!*p2) return str; // check if we reached the end of ptn, if so, return str + if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case) + } + } + return 0; } #endif //HAVE_STRCASESTR const char *getFontSize(const char *pattern, int *size) { - const char *p; - const char *p2=0; - int n=0; + const char *p; + const char *p2=0; + int n=0; - for (p=pattern; 1; p++) { - if (!*p) { - if (p2!=0 && n>1 && n<72) { - *size = n; return p2+1; - } else { - *size = 16; return 0; - } - } else if (*p=='-') { - if (n>1 && n<72 && p2!=0) { - *size = n; - return p2+1; - } - p2=p; n=0; - } else if (*p>='0' && *p<='9' && p2!=0) { - n *= 10; - n += *p-'0'; - } else { - p2=0; n=0; - } - } + for (p=pattern; 1; p++) { + if (!*p) { + if (p2!=0 && n>1 && n<72) { + *size = n; return p2+1; + } else { + *size = 16; return 0; + } + } else if (*p=='-') { + if (n>1 && n<72 && p2!=0) { + *size = n; + return p2+1; + } + p2=p; n=0; + } else if (*p>='0' && *p<='9' && p2!=0) { + n *= 10; + n += *p-'0'; + } else { + p2=0; n=0; + } + } } const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...) { - const char *p, *v; - char *p2; - va_list va; + const char *p, *v; + char *p2; + va_list va; - va_start(va, bufsiz); - buf[bufsiz-1] = 0; - buf[bufsiz-2] = '*'; - while((v = va_arg(va, char *)) != 0) { - p = ::strcasestr(pattern, v); - if (p) { - std::strncpy(buf, p+1, bufsiz-2); - p2 = strchr(buf, '-'); - if (p2) *p2=0; - va_end(va); - return p; - } - } - va_end(va); - std::strncpy(buf, "*", bufsiz); - return 0; + va_start(va, bufsiz); + buf[bufsiz-1] = 0; + buf[bufsiz-2] = '*'; + while((v = va_arg(va, char *)) != 0) { + p = ::strcasestr(pattern, v); + if (p) { + std::strncpy(buf, p+1, bufsiz-2); + p2 = strchr(buf, '-'); + if (p2) *p2=0; + va_end(va); + return p; + } + } + va_end(va); + std::strncpy(buf, "*", bufsiz); + return 0; } XFontSet createFontSet(const char *fontname) { - Display *display = FbTk::App::instance()->display(); - XFontSet fs; - const int FONT_ELEMENT_SIZE=50; - char **missing, *def = "-"; - int nmissing, pixel_size = 0, buf_size = 0; - char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; + Display *display = FbTk::App::instance()->display(); + XFontSet fs; + const int FONT_ELEMENT_SIZE=50; + char **missing, *def = "-"; + int nmissing, pixel_size = 0, buf_size = 0; + char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; - fs = XCreateFontSet(display, - fontname, &missing, &nmissing, &def); - if (fs && (! nmissing)) return fs; + fs = XCreateFontSet(display, + fontname, &missing, &nmissing, &def); + if (fs && (! nmissing)) return fs; #ifdef HAVE_SETLOCALE - if (! fs) { - if (nmissing) XFreeStringList(missing); + if (! fs) { + if (nmissing) XFreeStringList(missing); - setlocale(LC_CTYPE, "C"); - fs = XCreateFontSet(display, fontname, - &missing, &nmissing, &def); - setlocale(LC_CTYPE, ""); - } + setlocale(LC_CTYPE, "C"); + fs = XCreateFontSet(display, fontname, + &missing, &nmissing, &def); + setlocale(LC_CTYPE, ""); + } #endif // HAVE_SETLOCALE - if (fs) { - XFontStruct **fontstructs; - char **fontnames; - XFontsOfFontSet(fs, &fontstructs, &fontnames); - fontname = fontnames[0]; - } + if (fs) { + XFontStruct **fontstructs; + char **fontnames; + XFontsOfFontSet(fs, &fontstructs, &fontnames); + fontname = fontnames[0]; + } - getFontElement(fontname, weight, FONT_ELEMENT_SIZE, - "-medium-", "-bold-", "-demibold-", "-regular-", 0); - getFontElement(fontname, slant, FONT_ELEMENT_SIZE, - "-r-", "-i-", "-o-", "-ri-", "-ro-", 0); - getFontSize(fontname, &pixel_size); + getFontElement(fontname, weight, FONT_ELEMENT_SIZE, + "-medium-", "-bold-", "-demibold-", "-regular-", 0); + getFontElement(fontname, slant, FONT_ELEMENT_SIZE, + "-r-", "-i-", "-o-", "-ri-", "-ro-", 0); + getFontSize(fontname, &pixel_size); - if (! strcmp(weight, "*")) - std::strncpy(weight, "medium", FONT_ELEMENT_SIZE); - if (! strcmp(slant, "*")) - std::strncpy(slant, "r", FONT_ELEMENT_SIZE); - if (pixel_size < 3) - pixel_size = 3; - else if (pixel_size > 97) - pixel_size = 97; + if (! strcmp(weight, "*")) + std::strncpy(weight, "medium", FONT_ELEMENT_SIZE); + if (! strcmp(slant, "*")) + std::strncpy(slant, "r", FONT_ELEMENT_SIZE); + if (pixel_size < 3) + pixel_size = 3; + else if (pixel_size > 97) + pixel_size = 97; - buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64; - char *pattern2 = new char[buf_size]; - snprintf(pattern2, buf_size - 1, - "%s," - "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*," - "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*", - fontname, weight, slant, pixel_size, pixel_size); - fontname = pattern2; + buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64; + char *pattern2 = new char[buf_size]; + snprintf(pattern2, buf_size - 1, + "%s," + "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*," + "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*", + fontname, weight, slant, pixel_size, pixel_size); + fontname = pattern2; - if (nmissing) - XFreeStringList(missing); - if (fs) - XFreeFontSet(display, fs); + if (nmissing) + XFreeStringList(missing); + if (fs) + XFreeFontSet(display, fs); - fs = XCreateFontSet(display, fontname, - &missing, &nmissing, &def); - delete [] pattern2; + fs = XCreateFontSet(display, fontname, + &missing, &nmissing, &def); + delete [] pattern2; - return fs; + return fs; } };

@@ -183,75 +183,75 @@

XmbFontImp::XmbFontImp(const char *filename, bool utf8):m_fontset(0), m_utf8mode(utf8) { #ifdef DEBUG #ifdef X_HAVE_UTF8_STRING - cerr<<"Using utf8 = "<<utf8<<endl; + cerr<<"Using utf8 = "<<utf8<<endl; #else // X_HAVE_UTF8_STRING - cerr<<"Using uft8 = false"<<endl; + cerr<<"Using uft8 = false"<<endl; #endif //X_HAVE_UTF8_STRING #endif // DEBUG - if (filename != 0) - load(filename); + if (filename != 0) + load(filename); } XmbFontImp::~XmbFontImp() { - if (m_fontset != 0) - XFreeFontSet(App::instance()->display(), m_fontset); + if (m_fontset != 0) + XFreeFontSet(App::instance()->display(), m_fontset); } bool XmbFontImp::load(const std::string &fontname) { - if (fontname.size() == 0) - return false; - XFontSet set = createFontSet(fontname.c_str()); - if (set == 0) - return false; - if (m_fontset != 0) - XFreeFontSet(App::instance()->display(), m_fontset); - m_fontset = set; - m_setextents = XExtentsOfFontSet(m_fontset); + if (fontname.size() == 0) + return false; + XFontSet set = createFontSet(fontname.c_str()); + if (set == 0) + return false; + if (m_fontset != 0) + XFreeFontSet(App::instance()->display(), m_fontset); + m_fontset = set; + m_setextents = XExtentsOfFontSet(m_fontset); - return true; + return true; } void XmbFontImp::drawText(Drawable w, int screen, GC gc, const char *text, - size_t len, int x, int y) const { + size_t len, int x, int y) const { - if (text == 0 || len == 0 || w == 0 || m_fontset == 0) - return; + if (text == 0 || len == 0 || w == 0 || m_fontset == 0) + return; #ifdef X_HAVE_UTF8_STRING - if (m_utf8mode) { - Xutf8DrawString(App::instance()->display(), w, m_fontset, + if (m_utf8mode) { + Xutf8DrawString(App::instance()->display(), w, m_fontset, gc, x, y, text, len); - } else + } else #endif //X_HAVE_UTF8_STRING { - XmbDrawString(App::instance()->display(), w, m_fontset, - gc, x, y, - text, len); + XmbDrawString(App::instance()->display(), w, m_fontset, + gc, x, y, + text, len); } } unsigned int XmbFontImp::textWidth(const char * const text, unsigned int len) const { - if (m_fontset == 0) - return 0; - XRectangle ink, logical; + if (m_fontset == 0) + return 0; + XRectangle ink, logical; #ifdef X_HAVE_UTF8_STRING - if (m_utf8mode) { - Xutf8TextExtents(m_fontset, text, len, - &ink, &logical); - } else + if (m_utf8mode) { + Xutf8TextExtents(m_fontset, text, len, + &ink, &logical); + } else #endif // X_HAVE_UTF8_STRING { - XmbTextExtents(m_fontset, text, len, - &ink, &logical); + XmbTextExtents(m_fontset, text, len, + &ink, &logical); } - return logical.width; + return logical.width; } unsigned int XmbFontImp::height() const { - if (m_fontset == 0) - return 0; - return m_setextents->max_ink_extent.height; + if (m_fontset == 0) + return 0; + return m_setextents->max_ink_extent.height; } }; // end namespace FbTk
M src/FbTk/XmbFontImp.hhsrc/FbTk/XmbFontImp.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: XmbFontImp.hh,v 1.1 2002/11/26 16:01:28 fluxgen Exp $ +// $Id: XmbFontImp.hh,v 1.2 2002/12/01 13:42:15 rathnor Exp $ #ifndef FBTK_XMBFONTIMP_HH #define FBTK_XMBFONTIMP_HH

@@ -29,19 +29,19 @@ namespace FbTk {

class XmbFontImp:public FbTk::FontImp { public: - XmbFontImp(const char *fontname, bool utf8); - ~XmbFontImp(); - bool load(const std::string &name); - virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; - unsigned int textWidth(const char * const text, unsigned int len) const; - unsigned int height() const; - int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; } - int descent() const { return m_setextents ? m_setextents->max_ink_extent.height + m_setextents->max_ink_extent.y : 0; } - bool loaded() const { return m_fontset != 0; } + XmbFontImp(const char *fontname, bool utf8); + ~XmbFontImp(); + bool load(const std::string &name); + virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; + unsigned int textWidth(const char * const text, unsigned int len) const; + unsigned int height() const; + int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; } + int descent() const { return m_setextents ? m_setextents->max_ink_extent.height + m_setextents->max_ink_extent.y : 0; } + bool loaded() const { return m_fontset != 0; } private: - XFontSet m_fontset; - XFontSetExtents *m_setextents; - const bool m_utf8mode; + XFontSet m_fontset; + XFontSetExtents *m_setextents; + const bool m_utf8mode; }; }; // end namespace FbTk
M src/Gnome.ccsrc/Gnome.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Gnome.cc,v 1.5 2002/11/26 19:49:40 fluxgen Exp $ +// $Id: Gnome.cc,v 1.6 2002/12/01 13:41:57 rathnor Exp $ #include "Gnome.hh"

@@ -31,326 +31,326 @@ #include <new>

using namespace std; Gnome::Gnome() { - createAtoms(); + createAtoms(); } Gnome::~Gnome() { - // destroy gnome windows - while (!m_gnomewindows.empty()) { - XDestroyWindow(BaseDisplay::getXDisplay(), m_gnomewindows.back()); - m_gnomewindows.pop_back(); - } + // destroy gnome windows + while (!m_gnomewindows.empty()) { + XDestroyWindow(BaseDisplay::getXDisplay(), m_gnomewindows.back()); + m_gnomewindows.pop_back(); + } } void Gnome::initForScreen(const BScreen &screen) { - Display *disp = BaseDisplay::getXDisplay(); - // create the GNOME window - Window gnome_win = XCreateSimpleWindow(disp, - screen.getRootWindow(), 0, 0, 5, 5, 0, 0, 0); - // supported WM check - XChangeProperty(disp, screen.getRootWindow(), - m_gnome_wm_supporting_wm_check, - XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); + Display *disp = BaseDisplay::getXDisplay(); + // create the GNOME window + Window gnome_win = XCreateSimpleWindow(disp, + screen.getRootWindow(), 0, 0, 5, 5, 0, 0, 0); + // supported WM check + XChangeProperty(disp, screen.getRootWindow(), + m_gnome_wm_supporting_wm_check, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); - XChangeProperty(disp, gnome_win, - m_gnome_wm_supporting_wm_check, - XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); + XChangeProperty(disp, gnome_win, + m_gnome_wm_supporting_wm_check, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); - Atom gnomeatomlist[] = { - m_gnome_wm_supporting_wm_check, - m_gnome_wm_win_workspace_names, - m_gnome_wm_win_client_list, - m_gnome_wm_win_state, - m_gnome_wm_win_hints + Atom gnomeatomlist[] = { + m_gnome_wm_supporting_wm_check, + m_gnome_wm_win_workspace_names, + m_gnome_wm_win_client_list, + m_gnome_wm_win_state, + m_gnome_wm_win_hints // m_gnome_wm_win_layer not supported yet - }; + }; - //list atoms that we support - XChangeProperty(disp, screen.getRootWindow(), - m_gnome_wm_prot, XA_ATOM, 32, PropModeReplace, - (unsigned char *)gnomeatomlist, (sizeof gnomeatomlist)/sizeof gnomeatomlist[0]); + //list atoms that we support + XChangeProperty(disp, screen.getRootWindow(), + m_gnome_wm_prot, XA_ATOM, 32, PropModeReplace, + (unsigned char *)gnomeatomlist, (sizeof gnomeatomlist)/sizeof gnomeatomlist[0]); - m_gnomewindows.push_back(gnome_win); + m_gnomewindows.push_back(gnome_win); - updateClientList(screen); - updateWorkspaceNames(screen); - updateWorkspaceCount(screen); - updateCurrentWorkspace(screen); + updateClientList(screen); + updateWorkspaceNames(screen); + updateWorkspaceCount(screen); + updateCurrentWorkspace(screen); } void Gnome::setupWindow(FluxboxWindow &win) { - // load gnome state atom - Display *disp = BaseDisplay::getXDisplay(); - Atom ret_type; - int fmt; - unsigned long nitems, bytes_after; - long flags, *data = 0; + // load gnome state atom + Display *disp = BaseDisplay::getXDisplay(); + Atom ret_type; + int fmt; + unsigned long nitems, bytes_after; + long flags, *data = 0; - if (XGetWindowProperty(disp, win.getClientWindow(), - m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, - &ret_type, &fmt, &nitems, &bytes_after, - (unsigned char **) &data) == Success && data) { - flags = *data; - setState(&win, flags); - XFree (data); - } + if (XGetWindowProperty(disp, win.getClientWindow(), + m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, + &ret_type, &fmt, &nitems, &bytes_after, + (unsigned char **) &data) == Success && data) { + flags = *data; + setState(&win, flags); + XFree (data); + } - // make sure we get right workspace - updateWorkspace(win); + // make sure we get right workspace + updateWorkspace(win); } void Gnome::updateClientList(const BScreen &screen) { - size_t num=0; + size_t num=0; - BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); - BScreen::Workspaces::const_iterator workspace_it_end = screen.getWorkspacesList().end(); - for (; workspace_it != workspace_it_end; ++workspace_it) { - num += (*workspace_it)->getWindowList().size(); - } - //int num = getCurrentWorkspace()->getWindowList().size(); + BScreen::Workspaces::const_iterator workspace_it = screen.getWorkspacesList().begin(); + BScreen::Workspaces::const_iterator workspace_it_end = screen.getWorkspacesList().end(); + for (; workspace_it != workspace_it_end; ++workspace_it) { + num += (*workspace_it)->getWindowList().size(); + } + //int num = getCurrentWorkspace()->getWindowList().size(); - Window *wl = new (nothrow) Window[num]; - if (wl == 0) { - cerr<<"Fatal: Out of memory, can't allocate for gnome client list"<<endl; - return; - } - //start the iterator from begining - workspace_it = screen.getWorkspacesList().begin(); - int win=0; - for (; workspace_it != workspace_it_end; ++workspace_it) { + Window *wl = new (nothrow) Window[num]; + if (wl == 0) { + cerr<<"Fatal: Out of memory, can't allocate for gnome client list"<<endl; + return; + } + //start the iterator from begining + workspace_it = screen.getWorkspacesList().begin(); + int win=0; + for (; workspace_it != workspace_it_end; ++workspace_it) { - // Fill in array of window ID's - Workspace::Windows::const_iterator it = (*workspace_it)->getWindowList().begin(); - Workspace::Windows::const_iterator it_end = (*workspace_it)->getWindowList().end(); - for (; it != it_end; ++it) { - // TODO! - //check if the window don't want to be visible in the list - //if (! ( (*it)->getGnomeHints() & WIN_STATE_HIDDEN) ) { - wl[win++] = (*it)->getClientWindow(); - //} - } - } - //number of windows to show in client list - num = win; - XChangeProperty(BaseDisplay::getXDisplay(), - screen.getRootWindow(), - m_gnome_wm_win_client_list, - XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)wl, num); + // Fill in array of window ID's + Workspace::Windows::const_iterator it = (*workspace_it)->getWindowList().begin(); + Workspace::Windows::const_iterator it_end = (*workspace_it)->getWindowList().end(); + for (; it != it_end; ++it) { + // TODO! + //check if the window don't want to be visible in the list + //if (! ( (*it)->getGnomeHints() & WIN_STATE_HIDDEN) ) { + wl[win++] = (*it)->getClientWindow(); + //} + } + } + //number of windows to show in client list + num = win; + XChangeProperty(BaseDisplay::getXDisplay(), + screen.getRootWindow(), + m_gnome_wm_win_client_list, + XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)wl, num); - delete wl; + delete wl; } void Gnome::updateWorkspaceNames(const BScreen &screen) { - XTextProperty text; - int number_of_desks = screen.getWorkspaceNames().size(); + XTextProperty text; + int number_of_desks = screen.getWorkspaceNames().size(); - char s[1024]; - char *names[number_of_desks]; + char s[1024]; + char *names[number_of_desks]; - for (int i = 0; i < number_of_desks; i++) { - sprintf(s, "Desktop %i", i); - names[i] = new char[strlen(s) + 1]; - strcpy(names[i], s); - } + for (int i = 0; i < number_of_desks; i++) { + sprintf(s, "Desktop %i", i); + names[i] = new char[strlen(s) + 1]; + strcpy(names[i], s); + } - if (XStringListToTextProperty(names, number_of_desks, &text)) { - XSetTextProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), + if (XStringListToTextProperty(names, number_of_desks, &text)) { + XSetTextProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), &text, m_gnome_wm_win_workspace_names); - XFree(text.value); - } + XFree(text.value); + } - for (int i = 0; i < number_of_desks; i++) - delete [] names[i]; + for (int i = 0; i < number_of_desks; i++) + delete [] names[i]; } void Gnome::updateCurrentWorkspace(const BScreen &screen) { - int workspace = screen.getCurrentWorkspaceID(); - XChangeProperty(BaseDisplay::getXDisplay(), - screen.getRootWindow(), - m_gnome_wm_win_workspace, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&workspace, 1); + int workspace = screen.getCurrentWorkspaceID(); + XChangeProperty(BaseDisplay::getXDisplay(), + screen.getRootWindow(), + m_gnome_wm_win_workspace, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&workspace, 1); - updateClientList(screen); // make sure the client list is updated too + updateClientList(screen); // make sure the client list is updated too } void Gnome::updateWorkspaceCount(const BScreen &screen) { - int numworkspaces = screen.getCount(); - XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), - m_gnome_wm_win_workspace_count, XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&numworkspaces, 1); + int numworkspaces = screen.getCount(); + XChangeProperty(BaseDisplay::getXDisplay(), screen.getRootWindow(), + m_gnome_wm_win_workspace_count, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&numworkspaces, 1); } void Gnome::updateWorkspace(FluxboxWindow &win) { - int val = win.getWorkspaceNumber(); + int val = win.getWorkspaceNumber(); #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): setting workspace("<<val<< - ") for window("<<&win<<")"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): setting workspace("<<val<< + ") for window("<<&win<<")"<<endl; #endif // DEBUG - XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), - m_gnome_wm_win_workspace, - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); + XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), + m_gnome_wm_win_workspace, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); } void Gnome::updateState(FluxboxWindow &win) { - //translate to gnome win state - int state=0; - if (win.isStuck()) - state |= WIN_STATE_STICKY; - if (win.isIconic()) - state |= WIN_STATE_MINIMIZED; - if (win.isShaded()) - state |= WIN_STATE_SHADED; + //translate to gnome win state + int state=0; + if (win.isStuck()) + state |= WIN_STATE_STICKY; + if (win.isIconic()) + state |= WIN_STATE_MINIMIZED; + if (win.isShaded()) + state |= WIN_STATE_SHADED; - XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), - m_gnome_wm_win_state, - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&state, 1); + XChangeProperty(BaseDisplay::getXDisplay(), win.getClientWindow(), + m_gnome_wm_win_state, + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&state, 1); } void Gnome::updateHints(FluxboxWindow &win) { - //TODO + //TODO } bool Gnome::checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win) { - if (ce.message_type == m_gnome_wm_win_workspace) { + if (ce.message_type == m_gnome_wm_win_workspace) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Got workspace atom="<<ce.data.l[0]<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): Got workspace atom="<<ce.data.l[0]<<endl; #endif//!DEBUG - if ( win !=0 && // the message sent to client window? - win->getScreen() && ce.data.l[0] >= 0 && - ce.data.l[0] < (signed)win->getScreen()->getCount()) { - win->getScreen()->changeWorkspaceID(ce.data.l[0]); + if ( win !=0 && // the message sent to client window? + win->getScreen() && ce.data.l[0] >= 0 && + ce.data.l[0] < (signed)win->getScreen()->getCount()) { + win->getScreen()->changeWorkspaceID(ce.data.l[0]); - } else if (screen!=0 && //the message sent to root window? - ce.data.l[0] >= 0 && - ce.data.l[0] < (signed)screen->getCount()) - screen->changeWorkspaceID(ce.data.l[0]); - return true; - } else if (win == 0) - return false; + } else if (screen!=0 && //the message sent to root window? + ce.data.l[0] >= 0 && + ce.data.l[0] < (signed)screen->getCount()) + screen->changeWorkspaceID(ce.data.l[0]); + return true; + } else if (win == 0) + return false; - if (ce.message_type == m_gnome_wm_win_state) { + if (ce.message_type == m_gnome_wm_win_state) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_STATE"<<endl; #endif // DEBUG #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Mask of members to change:"<< - hex<<ce.data.l[0]<<dec<<endl; // mask_of_members_to_change - cerr<<"New members:"<<ce.data.l[1]<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): Mask of members to change:"<< + hex<<ce.data.l[0]<<dec<<endl; // mask_of_members_to_change + cerr<<"New members:"<<ce.data.l[1]<<endl; #endif // DEBUG - //get new states - int flag = ce.data.l[0] & ce.data.l[1]; - //don't update this when when we set new state - disableUpdate(); - // convert to Fluxbox state - setState(win, flag); - // enable update of atom states - enableUpdate(); + //get new states + int flag = ce.data.l[0] & ce.data.l[1]; + //don't update this when when we set new state + disableUpdate(); + // convert to Fluxbox state + setState(win, flag); + // enable update of atom states + enableUpdate(); - } else if (ce.message_type == m_gnome_wm_win_hints) { + } else if (ce.message_type == m_gnome_wm_win_hints) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_HINTS"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): _WIN_HINTS"<<endl; #endif // DEBUG - } else - return false; //the gnome atom wasn't found or not supported + } else + return false; //the gnome atom wasn't found or not supported - return true; // we handled the atom + return true; // we handled the atom } void Gnome::setState(FluxboxWindow *win, int state) { #ifdef DEBUG - cerr<<"Gnome: state=0x"<<hex<<state<<dec<<endl; + cerr<<"Gnome: state=0x"<<hex<<state<<dec<<endl; #endif // DEBUG - if (state & WIN_STATE_STICKY) { + if (state & WIN_STATE_STICKY) { #ifdef DEBUG - cerr<<"Gnome state: Sticky"<<endl; + cerr<<"Gnome state: Sticky"<<endl; #endif // DEBUG - if (!win->isStuck()) - win->stick(); - } else if (win->isStuck()) - win->stick(); + if (!win->isStuck()) + win->stick(); + } else if (win->isStuck()) + win->stick(); - if (state & WIN_STATE_MINIMIZED) { + if (state & WIN_STATE_MINIMIZED) { #ifdef DEBUG - cerr<<"Gnome state: Minimized"<<endl; + cerr<<"Gnome state: Minimized"<<endl; #endif // DEBUG - if (win->isIconic()) - win->iconify(); - } else if (win->isIconic()) - win->deiconify(true, true); + if (win->isIconic()) + win->iconify(); + } else if (win->isIconic()) + win->deiconify(true, true); - if (state & WIN_STATE_SHADED) { + if (state & WIN_STATE_SHADED) { #ifdef DEBUG - cerr<<"Gnome state: Shade"<<endl; + cerr<<"Gnome state: Shade"<<endl; #endif // DEBUG - if (!win->isShaded()) - win->shade(); - } else if (win->isShaded()) - win->shade(); + if (!win->isShaded()) + win->shade(); + } else if (win->isShaded()) + win->shade(); - /* TODO - if (state & WIN_STATE_MAXIMIZED_VERT) - cerr<<"Maximize Vert"<<endl; - if (state & WIN_STATE_MAXIMIZED_HORIZ) - cerr<<"Maximize Horiz"<<endl; - if (state & WIN_STATE_HIDDEN) - cerr<<"Hidden"<<endl; - if (state & WIN_STATE_HID_WORKSPACE) - cerr<<"HID Workspace"<<endl; - if (state & WIN_STATE_HID_TRANSIENT) - cerr<<"HID Transient"<<endl; - if (state & WIN_STATE_FIXED_POSITION) - cerr<<"Fixed Position"<<endl; - if (state & WIN_STATE_ARRANGE_IGNORE) - cerr<<"Arrange Ignore"<<endl; - */ + /* TODO + if (state & WIN_STATE_MAXIMIZED_VERT) + cerr<<"Maximize Vert"<<endl; + if (state & WIN_STATE_MAXIMIZED_HORIZ) + cerr<<"Maximize Horiz"<<endl; + if (state & WIN_STATE_HIDDEN) + cerr<<"Hidden"<<endl; + if (state & WIN_STATE_HID_WORKSPACE) + cerr<<"HID Workspace"<<endl; + if (state & WIN_STATE_HID_TRANSIENT) + cerr<<"HID Transient"<<endl; + if (state & WIN_STATE_FIXED_POSITION) + cerr<<"Fixed Position"<<endl; + if (state & WIN_STATE_ARRANGE_IGNORE) + cerr<<"Arrange Ignore"<<endl; + */ } void Gnome::setLayer(GnomeLayer layer) { - FluxboxWindow::WinLayer winlayer; + FluxboxWindow::WinLayer winlayer; - switch (layer) { - case WIN_LAYER_DESKTOP: - winlayer = FluxboxWindow::LAYER_BOTTOM; - break; - case WIN_LAYER_BELOW: - winlayer = FluxboxWindow::LAYER_BELOW; - break; - case WIN_LAYER_NORMAL: - winlayer = FluxboxWindow::LAYER_NORMAL; - break; - case WIN_LAYER_ONTOP: - case WIN_LAYER_DOCK: - case WIN_LAYER_ABOVE_DOCK: - case WIN_LAYER_MENU: - winlayer = FluxboxWindow::LAYER_TOP; - break; - default: - winlayer = FluxboxWindow::LAYER_NORMAL; - break; - } + switch (layer) { + case WIN_LAYER_DESKTOP: + winlayer = FluxboxWindow::LAYER_BOTTOM; + break; + case WIN_LAYER_BELOW: + winlayer = FluxboxWindow::LAYER_BELOW; + break; + case WIN_LAYER_NORMAL: + winlayer = FluxboxWindow::LAYER_NORMAL; + break; + case WIN_LAYER_ONTOP: + case WIN_LAYER_DOCK: + case WIN_LAYER_ABOVE_DOCK: + case WIN_LAYER_MENU: + winlayer = FluxboxWindow::LAYER_TOP; + break; + default: + winlayer = FluxboxWindow::LAYER_NORMAL; + break; + } } void Gnome::createAtoms() { - Display *disp = BaseDisplay::getXDisplay(); - m_gnome_wm_win_layer = XInternAtom(disp, "_WIN_LAYER", False); - m_gnome_wm_win_state = XInternAtom(disp, "_WIN_STATE", False); - m_gnome_wm_win_hints = XInternAtom(disp, "_WIN_HINTS", False); - m_gnome_wm_win_app_state = XInternAtom(disp, "_WIN_APP_STATE", False); - m_gnome_wm_win_expanded_size = XInternAtom(disp, "_WIN_EXPANDED_SIZE", False); - m_gnome_wm_win_icons = XInternAtom(disp, "_WIN_ICONS", False); - m_gnome_wm_win_workspace = XInternAtom(disp, "_WIN_WORKSPACE", False); - m_gnome_wm_win_workspace_count = XInternAtom(disp, "_WIN_WORKSPACE_COUNT", False); - m_gnome_wm_win_workspace_names = XInternAtom(disp, "_WIN_WORKSPACE_NAMES", False); - m_gnome_wm_win_client_list = XInternAtom(disp, "_WIN_CLIENT_LIST", False); - m_gnome_wm_prot = XInternAtom(disp, "_WIN_PROTOCOLS", False); - m_gnome_wm_supporting_wm_check = XInternAtom(disp, "_WIN_SUPPORTING_WM_CHECK", False); + Display *disp = BaseDisplay::getXDisplay(); + m_gnome_wm_win_layer = XInternAtom(disp, "_WIN_LAYER", False); + m_gnome_wm_win_state = XInternAtom(disp, "_WIN_STATE", False); + m_gnome_wm_win_hints = XInternAtom(disp, "_WIN_HINTS", False); + m_gnome_wm_win_app_state = XInternAtom(disp, "_WIN_APP_STATE", False); + m_gnome_wm_win_expanded_size = XInternAtom(disp, "_WIN_EXPANDED_SIZE", False); + m_gnome_wm_win_icons = XInternAtom(disp, "_WIN_ICONS", False); + m_gnome_wm_win_workspace = XInternAtom(disp, "_WIN_WORKSPACE", False); + m_gnome_wm_win_workspace_count = XInternAtom(disp, "_WIN_WORKSPACE_COUNT", False); + m_gnome_wm_win_workspace_names = XInternAtom(disp, "_WIN_WORKSPACE_NAMES", False); + m_gnome_wm_win_client_list = XInternAtom(disp, "_WIN_CLIENT_LIST", False); + m_gnome_wm_prot = XInternAtom(disp, "_WIN_PROTOCOLS", False); + m_gnome_wm_supporting_wm_check = XInternAtom(disp, "_WIN_SUPPORTING_WM_CHECK", False); }
M src/Gnome.hhsrc/Gnome.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Gnome.hh,v 1.3 2002/10/16 19:01:58 fluxgen Exp $ +// $Id: Gnome.hh,v 1.4 2002/12/01 13:41:57 rathnor Exp $ #ifndef GNOME_HH #define GNOME_HH

@@ -31,67 +31,67 @@ #include <vector>

class Gnome:public AtomHandler { public: - enum GnomeLayer { - WIN_LAYER_DESKTOP = 0, - WIN_LAYER_BELOW = 2, - WIN_LAYER_NORMAL = 4, - WIN_LAYER_ONTOP = 6, - WIN_LAYER_DOCK = 8, - WIN_LAYER_ABOVE_DOCK = 10, - WIN_LAYER_MENU = 12 - }; + enum GnomeLayer { + WIN_LAYER_DESKTOP = 0, + WIN_LAYER_BELOW = 2, + WIN_LAYER_NORMAL = 4, + WIN_LAYER_ONTOP = 6, + WIN_LAYER_DOCK = 8, + WIN_LAYER_ABOVE_DOCK = 10, + WIN_LAYER_MENU = 12 + }; - enum GnomeState { - WIN_STATE_STICKY = (1<<0), // everyone knows sticky - WIN_STATE_MINIMIZED = (1<<1), // Reserved - definition is unclear - WIN_STATE_MAXIMIZED_VERT = (1<<2), // window in maximized V state - WIN_STATE_MAXIMIZED_HORIZ = (1<<3), // window in maximized H state - WIN_STATE_HIDDEN = (1<<4), // not on taskbar but window visible - WIN_STATE_SHADED = (1<<5), // shaded (MacOS / Afterstep style) - WIN_STATE_HID_WORKSPACE = (1<<6), // not on current desktop - WIN_STATE_HID_TRANSIENT = (1<<7), // owner of transient is hidden - WIN_STATE_FIXED_POSITION = (1<<8), // window is fixed in position even - WIN_STATE_ARRANGE_IGNORE = (1<<9) // ignore for auto arranging - }; + enum GnomeState { + WIN_STATE_STICKY = (1<<0), // everyone knows sticky + WIN_STATE_MINIMIZED = (1<<1), // Reserved - definition is unclear + WIN_STATE_MAXIMIZED_VERT = (1<<2), // window in maximized V state + WIN_STATE_MAXIMIZED_HORIZ = (1<<3), // window in maximized H state + WIN_STATE_HIDDEN = (1<<4), // not on taskbar but window visible + WIN_STATE_SHADED = (1<<5), // shaded (MacOS / Afterstep style) + WIN_STATE_HID_WORKSPACE = (1<<6), // not on current desktop + WIN_STATE_HID_TRANSIENT = (1<<7), // owner of transient is hidden + WIN_STATE_FIXED_POSITION = (1<<8), // window is fixed in position even + WIN_STATE_ARRANGE_IGNORE = (1<<9) // ignore for auto arranging + }; - enum GnomeHints { - WIN_HINTS_SKIP_FOCUS = (1<<0), // skip this window - WIN_HINTS_SKIP_WINLIST = (1<<1), // do not show in window list - WIN_HINTS_SKIP_TASKBAR = (1<<2), // do not show on taskbar - WIN_HINTS_GROUP_TRANSIENT = (1<<3), // Reserved - definition is unclear - WIN_HINTS_FOCUS_ON_CLICK = (1<<4) // app only accepts focus if clicked - }; + enum GnomeHints { + WIN_HINTS_SKIP_FOCUS = (1<<0), // skip this window + WIN_HINTS_SKIP_WINLIST = (1<<1), // do not show in window list + WIN_HINTS_SKIP_TASKBAR = (1<<2), // do not show on taskbar + WIN_HINTS_GROUP_TRANSIENT = (1<<3), // Reserved - definition is unclear + WIN_HINTS_FOCUS_ON_CLICK = (1<<4) // app only accepts focus if clicked + }; - Gnome(); - ~Gnome(); - void initForScreen(const BScreen &screen); - void setupWindow(FluxboxWindow &win); + Gnome(); + ~Gnome(); + void initForScreen(const BScreen &screen); + void setupWindow(FluxboxWindow &win); - void updateClientList(const BScreen &screen); - void updateWorkspaceNames(const BScreen &screen); - void updateCurrentWorkspace(const BScreen &screen); - void updateWorkspaceCount(const BScreen &screen); + void updateClientList(const BScreen &screen); + void updateWorkspaceNames(const BScreen &screen); + void updateCurrentWorkspace(const BScreen &screen); + void updateWorkspaceCount(const BScreen &screen); - void updateState(FluxboxWindow &win); - void updateHints(FluxboxWindow &win); - void updateWorkspace(FluxboxWindow &win); + void updateState(FluxboxWindow &win); + void updateHints(FluxboxWindow &win); + void updateWorkspace(FluxboxWindow &win); - bool checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win); + bool checkClientMessage(const XClientMessageEvent &ce, BScreen * const screen, FluxboxWindow * const win); private: - void setLayer(GnomeLayer layer); - void setState(FluxboxWindow *win, int state); - void setLayer(int layer); - void createAtoms(); - Atom m_gnome_wm_win_layer, m_gnome_wm_win_state, m_gnome_wm_win_hints, - m_gnome_wm_win_app_state, m_gnome_wm_win_expanded_size, - m_gnome_wm_win_icons, m_gnome_wm_win_workspace, - m_gnome_wm_win_workspace_count, m_gnome_wm_win_workspace_names, - m_gnome_wm_win_client_list; - Atom m_gnome_wm_prot; - Atom m_gnome_wm_supporting_wm_check; - std::vector<Window> m_gnomewindows; + void setLayer(GnomeLayer layer); + void setState(FluxboxWindow *win, int state); + void setLayer(int layer); + void createAtoms(); + Atom m_gnome_wm_win_layer, m_gnome_wm_win_state, m_gnome_wm_win_hints, + m_gnome_wm_win_app_state, m_gnome_wm_win_expanded_size, + m_gnome_wm_win_icons, m_gnome_wm_win_workspace, + m_gnome_wm_win_workspace_count, m_gnome_wm_win_workspace_names, + m_gnome_wm_win_client_list; + Atom m_gnome_wm_prot; + Atom m_gnome_wm_supporting_wm_check; + std::vector<Window> m_gnomewindows; }; #endif // GNOME_HH
M src/IconBar.ccsrc/IconBar.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: IconBar.cc,v 1.20 2002/11/30 20:10:42 fluxgen Exp $ +// $Id: IconBar.cc,v 1.21 2002/12/01 13:41:57 rathnor Exp $ #include "IconBar.hh" #include "i18n.hh"

@@ -31,8 +31,8 @@ #include <algorithm>

IconBarObj::IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin) { - m_fluxboxwin = fluxboxwin; - m_iconwin = iconwin; + m_fluxboxwin = fluxboxwin; + m_iconwin = iconwin; } IconBarObj::~IconBarObj() {

@@ -44,26 +44,26 @@ // will return the width of an icon

// window //------------------------------------ unsigned int IconBarObj::width() const { - Window root; + Window root; - unsigned int width, height; - unsigned int border_width, depth; //not used - int x, y; //not used + unsigned int width, height; + unsigned int border_width, depth; //not used + int x, y; //not used - Display *m_display = Fluxbox::instance()->getXDisplay(); + Display *m_display = Fluxbox::instance()->getXDisplay(); - XGetGeometry(m_display, m_iconwin, &root, &x, &y, - &width, &height, &border_width, &depth); + XGetGeometry(m_display, m_iconwin, &root, &x, &y, + &width, &height, &border_width, &depth); - return width; + return width; } IconBar::IconBar(BScreen *scrn, Window parent): -m_screen(scrn), -m_parent(parent) + m_screen(scrn), + m_parent(parent) { - m_display = scrn->getBaseDisplay()->getXDisplay(); + m_display = scrn->getBaseDisplay()->getXDisplay(); } IconBar::~IconBar() {

@@ -76,17 +76,17 @@ // returns window to iconobj

//-------------------------------------------- Window IconBar::addIcon(FluxboxWindow *fluxboxwin) { - Window iconwin = createIconWindow(fluxboxwin, m_parent); - decorate(iconwin); - //add window object to list - m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin)); - //reposition all icons to fit windowbar - repositionIcons(); + Window iconwin = createIconWindow(fluxboxwin, m_parent); + decorate(iconwin); + //add window object to list + m_iconlist.push_back(new IconBarObj(fluxboxwin, iconwin)); + //reposition all icons to fit windowbar + repositionIcons(); - XMapSubwindows(m_display, iconwin); - XMapWindow(m_display, iconwin); + XMapSubwindows(m_display, iconwin); + XMapWindow(m_display, iconwin); - return iconwin; + return iconwin; } //----------- delIcon -------------------

@@ -96,20 +96,20 @@ // Return X Window of the removed iconobj

// returns None if no window was found //--------------------------------------- Window IconBar::delIcon(FluxboxWindow *fluxboxwin) { - Window retwin = None; - IconBarObj *obj = findIcon(fluxboxwin); - if (obj) { - IconList::iterator it = - std::find(m_iconlist.begin(), m_iconlist.end(), obj); - if (it != m_iconlist.end()) { - m_iconlist.erase(it); - retwin = obj->getIconWin(); - delete obj; - XDestroyWindow(m_display, retwin); - repositionIcons(); - } - } - return retwin; + Window retwin = None; + IconBarObj *obj = findIcon(fluxboxwin); + if (obj) { + IconList::iterator it = + std::find(m_iconlist.begin(), m_iconlist.end(), obj); + if (it != m_iconlist.end()) { + m_iconlist.erase(it); + retwin = obj->getIconWin(); + delete obj; + XDestroyWindow(m_display, retwin); + repositionIcons(); + } + } + return retwin; } //------------ loadTheme ---------------

@@ -117,25 +117,25 @@ // renders theme to m_focus_pm

// with the size width * height //-------------------------------------- void IconBar::loadTheme(unsigned int width, unsigned int height) { - BImageControl *image_ctrl = m_screen->getImageControl(); - Pixmap tmp = m_focus_pm; - const FbTk::Texture *texture = &(m_screen->getWindowStyle()->tab.l_focus); + BImageControl *image_ctrl = m_screen->getImageControl(); + Pixmap tmp = m_focus_pm; + const FbTk::Texture *texture = &(m_screen->getWindowStyle()->tab.l_focus); - //If we are working on a PARENTRELATIVE, change to right focus value - if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { - texture = &(m_screen->getWindowStyle()->tab.t_focus); - } + //If we are working on a PARENTRELATIVE, change to right focus value + if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { + texture = &(m_screen->getWindowStyle()->tab.t_focus); + } - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - m_focus_pm = None; - m_focus_pixel = texture->color().pixel(); - } else { - m_focus_pm = - image_ctrl->renderImage(width, height, *texture); - } + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + m_focus_pm = None; + m_focus_pixel = texture->color().pixel(); + } else { + m_focus_pm = + image_ctrl->renderImage(width, height, *texture); + } - if (tmp) - image_ctrl->removeImage(tmp); + if (tmp) + image_ctrl->removeImage(tmp); } //------------ decorate ------------------

@@ -144,12 +144,12 @@ // border, border width of the window

//---------------------------------------- void IconBar::decorate(Window win) { - XSetWindowBorderWidth(m_display, win, m_screen->getWindowStyle()->tab.border_width); - XSetWindowBorder(m_display, win, m_screen->getWindowStyle()->tab.border_color.pixel()); - if (m_focus_pm) - XSetWindowBackgroundPixmap(m_display, win, m_focus_pm); - else - XSetWindowBackground(m_display, win, m_focus_pixel); + XSetWindowBorderWidth(m_display, win, m_screen->getWindowStyle()->tab.border_width); + XSetWindowBorder(m_display, win, m_screen->getWindowStyle()->tab.border_color.pixel()); + if (m_focus_pm) + XSetWindowBackgroundPixmap(m_display, win, m_focus_pm); + else + XSetWindowBackground(m_display, win, m_focus_pixel); }

@@ -158,7 +158,7 @@ // Reconfigures the icons

// theme, pos and width //---------------------------------------- void IconBar::reconfigure() { - repositionIcons(); + repositionIcons(); } //---------- exposeEvent -----------------

@@ -166,66 +166,66 @@ // Handles the expose event

// just redraws all the icons //---------------------------------------- void IconBar::exposeEvent(XExposeEvent *ee) { - IconBarObj *obj=0; - IconList::iterator it = m_iconlist.begin(); - IconList::iterator it_end = m_iconlist.end(); - for (; it != it_end; ++it) { - if ((*it)->getIconWin() == ee->window) { - obj = (*it); - break; - } - } + IconBarObj *obj=0; + IconList::iterator it = m_iconlist.begin(); + IconList::iterator it_end = m_iconlist.end(); + for (; it != it_end; ++it) { + if ((*it)->getIconWin() == ee->window) { + obj = (*it); + break; + } + } - if (obj) { + if (obj) { - Window root; - unsigned int width, height; - unsigned int border_width, depth; //not used - int x, y; - XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, - &border_width, &depth); + Window root; + unsigned int width, height; + unsigned int border_width, depth; //not used + int x, y; + XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, + &border_width, &depth); - //max width on every icon - unsigned int icon_width = width / m_iconlist.size(); + //max width on every icon + unsigned int icon_width = width / m_iconlist.size(); - //load right size of theme - loadTheme(icon_width, height); + //load right size of theme + loadTheme(icon_width, height); - draw(obj, icon_width); + draw(obj, icon_width); - } + } } //------------ repositionIcons ------------ // Calculates and moves/resizes the icons //----------------------------------------- void IconBar::repositionIcons() { - if (m_iconlist.size() == 0) - return; + if (m_iconlist.size() == 0) + return; - Window root; - unsigned int width, height; - unsigned int border_width, depth; //not used - int x, y; - XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, - &border_width, &depth); + Window root; + unsigned int width, height; + unsigned int border_width, depth; //not used + int x, y; + XGetGeometry(m_display, m_parent, &root, &x, &y, &width, &height, + &border_width, &depth); - //max width on every icon - unsigned int icon_width = width / m_iconlist.size(); + //max width on every icon + unsigned int icon_width = width / m_iconlist.size(); - //load right size of theme - loadTheme(icon_width, height); + //load right size of theme + loadTheme(icon_width, height); - IconList::iterator it = m_iconlist.begin(); - IconList::iterator it_end = m_iconlist.end(); - for (x = 0; it != it_end; ++it, x += icon_width) { - Window iconwin = (*it)->getIconWin(); - XMoveResizeWindow(m_display, iconwin, - x, 0, - icon_width, height); - draw((*it), icon_width); - decorate(iconwin); - } + IconList::iterator it = m_iconlist.begin(); + IconList::iterator it_end = m_iconlist.end(); + for (x = 0; it != it_end; ++it, x += icon_width) { + Window iconwin = (*it)->getIconWin(); + XMoveResizeWindow(m_display, iconwin, + x, 0, + icon_width, height); + draw((*it), icon_width); + decorate(iconwin); + } }

@@ -234,73 +234,73 @@ // creates the X Window of icon

// returns the created X Window //---------------------------------------------- Window IconBar::createIconWindow(FluxboxWindow *fluxboxwin, Window parent) { - unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - XSetWindowAttributes attrib; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - fluxboxwin->getScreen()->getWindowStyle()->tab.border_color.pixel(); - attrib.colormap = fluxboxwin->getScreen()->colormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask | EnterWindowMask; + unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | + CWColormap | CWOverrideRedirect | CWEventMask; + XSetWindowAttributes attrib; + attrib.background_pixmap = None; + attrib.background_pixel = attrib.border_pixel = + fluxboxwin->getScreen()->getWindowStyle()->tab.border_color.pixel(); + attrib.colormap = fluxboxwin->getScreen()->colormap(); + attrib.override_redirect = True; + attrib.event_mask = ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | ExposureMask | EnterWindowMask; - //create iconwindow - Window iconwin = XCreateWindow(m_display, parent, 0, 0, 1, 1, 0, - fluxboxwin->getScreen()->getDepth(), InputOutput, fluxboxwin->getScreen()->getVisual(), - attrib_mask, &attrib); + //create iconwindow + Window iconwin = XCreateWindow(m_display, parent, 0, 0, 1, 1, 0, + fluxboxwin->getScreen()->getDepth(), InputOutput, fluxboxwin->getScreen()->getVisual(), + attrib_mask, &attrib); - return iconwin; + return iconwin; } //------------ draw ------------------ // Draws theme and string to Window w //------------------------------------ void IconBar::draw(const IconBarObj * const obj, int width) const { - if (!obj) - return; + if (!obj) + return; - const FluxboxWindow * const fluxboxwin = obj->getFluxboxWin(); - Window iconwin = obj->getIconWin(); - unsigned int title_text_w; + const FluxboxWindow * const fluxboxwin = obj->getFluxboxWin(); + Window iconwin = obj->getIconWin(); + unsigned int title_text_w; - title_text_w = m_screen->getWindowStyle()->font.textWidth( - fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); - int l = title_text_w; - unsigned int dlen=fluxboxwin->getIconTitle().size(); - unsigned int bevel_w = m_screen->getBevelWidth(); - int dx=bevel_w*2; + title_text_w = m_screen->getWindowStyle()->font.textWidth( + fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); + int l = title_text_w; + unsigned int dlen=fluxboxwin->getIconTitle().size(); + unsigned int bevel_w = m_screen->getBevelWidth(); + int dx=bevel_w*2; - for (; dlen >= 0; dlen--) { - l = m_screen->getWindowStyle()->tab.font.textWidth( - fluxboxwin->getIconTitle().c_str(), dlen); - l += (bevel_w * 4); + for (; dlen >= 0; dlen--) { + l = m_screen->getWindowStyle()->tab.font.textWidth( + fluxboxwin->getIconTitle().c_str(), dlen); + l += (bevel_w * 4); - if (l < width) - break; - } + if (l < width) + break; + } - switch (m_screen->getWindowStyle()->tab.justify) { - case DrawUtil::Font::RIGHT: - dx += width - l; - break; - case DrawUtil::Font::CENTER: - dx += (width - l) / 2; - break; - default: - break; - } + switch (m_screen->getWindowStyle()->tab.justify) { + case DrawUtil::Font::RIGHT: + dx += width - l; + break; + case DrawUtil::Font::CENTER: + dx += (width - l) / 2; + break; + default: + break; + } - //Draw title to m_iconwin + //Draw title to m_iconwin - XClearWindow(m_display, iconwin); + XClearWindow(m_display, iconwin); - m_screen->getWindowStyle()->tab.font.drawText( - iconwin, - m_screen->getScreenNumber(), - m_screen->getWindowStyle()->tab.l_text_focus_gc, - fluxboxwin->getIconTitle().c_str(), dlen, - dx, 1+ m_screen->getWindowStyle()->tab.font.ascent()); + m_screen->getWindowStyle()->tab.font.drawText( + iconwin, + m_screen->getScreenNumber(), + m_screen->getWindowStyle()->tab.l_text_focus_gc, + fluxboxwin->getIconTitle().c_str(), dlen, + dx, 1+ m_screen->getWindowStyle()->tab.font.ascent()); }

@@ -312,16 +312,16 @@ // 0 on failure

//---------------------------------- FluxboxWindow *IconBar::findWindow(Window w) { - IconList::iterator it = m_iconlist.begin(); - IconList::iterator it_end = m_iconlist.end(); - for (; it != it_end; ++it) { - IconBarObj *tmp = (*it); - if (tmp) - if (tmp->getIconWin() == w) - return tmp->getFluxboxWin(); - } + IconList::iterator it = m_iconlist.begin(); + IconList::iterator it_end = m_iconlist.end(); + for (; it != it_end; ++it) { + IconBarObj *tmp = (*it); + if (tmp) + if (tmp->getIconWin() == w) + return tmp->getFluxboxWin(); + } - return 0; + return 0; } //----------- findIcon ---------------

@@ -332,28 +332,28 @@ //------------------------------------

IconBarObj *IconBar::findIcon(FluxboxWindow *fluxboxwin) { - IconList::iterator it = m_iconlist.begin(); - IconList::iterator it_end = m_iconlist.end(); - for (; it != it_end; ++it) { - IconBarObj *tmp = (*it); - if (tmp) - if (tmp->getFluxboxWin() == fluxboxwin) - return tmp; - } + IconList::iterator it = m_iconlist.begin(); + IconList::iterator it_end = m_iconlist.end(); + for (; it != it_end; ++it) { + IconBarObj *tmp = (*it); + if (tmp) + if (tmp->getFluxboxWin() == fluxboxwin) + return tmp; + } - return 0; + return 0; } const IconBarObj *IconBar::findIcon(const FluxboxWindow * const fluxboxwin) const { - IconList::const_iterator it = m_iconlist.begin(); - IconList::const_iterator it_end = m_iconlist.end(); - for (; it != it_end; ++it) { - IconBarObj *tmp = (*it); - if (tmp) - if (tmp->getFluxboxWin() == fluxboxwin) - return tmp; - } + IconList::const_iterator it = m_iconlist.begin(); + IconList::const_iterator it_end = m_iconlist.end(); + for (; it != it_end; ++it) { + IconBarObj *tmp = (*it); + if (tmp) + if (tmp->getFluxboxWin() == fluxboxwin) + return tmp; + } - return 0; + return 0; }
M src/IconBar.hhsrc/IconBar.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: IconBar.hh,v 1.8 2002/10/29 15:52:44 fluxgen Exp $ +// $Id: IconBar.hh,v 1.9 2002/12/01 13:41:57 rathnor Exp $ #ifndef ICONBAR_HH #define ICONBAR_HH

@@ -34,16 +34,16 @@ */

class IconBarObj { public: - IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin); - ~IconBarObj(); - Window getIconWin() const { return m_iconwin; } - FluxboxWindow *getFluxboxWin() { return m_fluxboxwin; } - const FluxboxWindow *getFluxboxWin() const { return m_fluxboxwin; } - unsigned int width() const; + IconBarObj(FluxboxWindow *fluxboxwin, Window iconwin); + ~IconBarObj(); + Window getIconWin() const { return m_iconwin; } + FluxboxWindow *getFluxboxWin() { return m_fluxboxwin; } + const FluxboxWindow *getFluxboxWin() const { return m_fluxboxwin; } + unsigned int width() const; private: - FluxboxWindow *m_fluxboxwin; - Window m_iconwin; + FluxboxWindow *m_fluxboxwin; + Window m_iconwin; }; /**

@@ -52,34 +52,34 @@ */

class IconBar { public: - IconBar(BScreen *scrn, Window parent); - ~IconBar(); - void draw(); //TODO - void reconfigure(); - Window addIcon(FluxboxWindow *fluxboxwin); - Window delIcon(FluxboxWindow *fluxboxwin); - void buttonPressEvent(XButtonEvent *be); - FluxboxWindow *findWindow(Window w); - IconBarObj *findIcon(FluxboxWindow * const fluxboxwin); - const IconBarObj *findIcon(const FluxboxWindow * const fluxboxwin) const; - void exposeEvent(XExposeEvent *ee); + IconBar(BScreen *scrn, Window parent); + ~IconBar(); + void draw(); //TODO + void reconfigure(); + Window addIcon(FluxboxWindow *fluxboxwin); + Window delIcon(FluxboxWindow *fluxboxwin); + void buttonPressEvent(XButtonEvent *be); + FluxboxWindow *findWindow(Window w); + IconBarObj *findIcon(FluxboxWindow * const fluxboxwin); + const IconBarObj *findIcon(const FluxboxWindow * const fluxboxwin) const; + void exposeEvent(XExposeEvent *ee); - void draw(const IconBarObj * const obj, int width) const; + void draw(const IconBarObj * const obj, int width) const; private: - typedef std::list<IconBarObj *> IconList; + typedef std::list<IconBarObj *> IconList; // void draw(IconBarObj *obj, int width); - void loadTheme(unsigned int width, unsigned int height); - void decorate(Window win); + void loadTheme(unsigned int width, unsigned int height); + void decorate(Window win); // IconBarObj *findIcon(FluxboxWindow *fluxboxwin); - void repositionIcons(); - Window createIconWindow(FluxboxWindow *fluxboxwin, Window parent); - BScreen *m_screen; - Display *m_display; - Window m_parent; - IconList m_iconlist; - Pixmap m_focus_pm; - unsigned long m_focus_pixel; + void repositionIcons(); + Window createIconWindow(FluxboxWindow *fluxboxwin, Window parent); + BScreen *m_screen; + Display *m_display; + Window m_parent; + IconList m_iconlist; + Pixmap m_focus_pm; + unsigned long m_focus_pixel; }; #endif // ICONBAR_HH
M src/Iconmenu.ccsrc/Iconmenu.cc

@@ -29,26 +29,26 @@ #include "Workspacemenu.hh"

#include "i18n.hh" Iconmenu::Iconmenu(BScreen *scrn) : Basemenu(scrn) { - setInternalMenu(); + setInternalMenu(); - setLabel(I18n::instance()->getMessage( - FBNLS::IconSet, FBNLS::IconIcons, - "Icons")); - update(); + setLabel(I18n::instance()->getMessage( + FBNLS::IconSet, FBNLS::IconIcons, + "Icons")); + update(); } void Iconmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - if (index < screen()->getIconCount()) { - FluxboxWindow *win = screen()->getIcon(index); + if (button == 1) { + if (index < screen()->getIconCount()) { + FluxboxWindow *win = screen()->getIcon(index); - if (win) - win->deiconify(); + if (win) + win->deiconify(); - } + } - if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); - } + if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) + hide(); + } }
M src/Iconmenu.hhsrc/Iconmenu.hh

@@ -31,9 +31,9 @@ #include "Basemenu.hh"

class Iconmenu : public Basemenu { public: - explicit Iconmenu(BScreen *scr); + explicit Iconmenu(BScreen *scr); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); };
M src/ImageControl.ccsrc/ImageControl.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: ImageControl.cc,v 1.1 2002/11/30 20:07:06 fluxgen Exp $ +// $Id: ImageControl.cc,v 1.2 2002/12/01 13:41:57 rathnor Exp $ #include "ImageControl.hh"

@@ -62,575 +62,575 @@

namespace { // anonymous unsigned long bsqrt(unsigned long x) { - if (x <= 0) return 0; - if (x == 1) return 1; + if (x <= 0) return 0; + if (x == 1) return 1; - unsigned long r = x >> 1; - unsigned long q; + unsigned long r = x >> 1; + unsigned long q; - while (1) { - q = x / r; - if (q >= r) return r; - r = (r + q) >> 1; - } + while (1) { + q = x / r; + if (q >= r) return r; + r = (r + q) >> 1; + } } }; BImageControl::BImageControl(int screen_num, bool dither, - int cpc, unsigned long cache_timeout, unsigned long cmax): -m_dither(dither), -m_timer(this), -m_colors(0), -m_num_colors(0), -m_colors_per_channel(cpc) { + int cpc, unsigned long cache_timeout, unsigned long cmax): + m_dither(dither), + m_timer(this), + m_colors(0), + m_num_colors(0), + m_colors_per_channel(cpc) { - Display *disp = FbTk::App::instance()->display(); + Display *disp = FbTk::App::instance()->display(); - m_screen_depth = DefaultDepth(disp, screen_num); - m_screen_num = screen_num; - m_root_window = RootWindow(disp, screen_num); - m_visual = DefaultVisual(disp, screen_num); - m_colormap = DefaultColormap(disp, screen_num); + m_screen_depth = DefaultDepth(disp, screen_num); + m_screen_num = screen_num; + m_root_window = RootWindow(disp, screen_num); + m_visual = DefaultVisual(disp, screen_num); + m_colormap = DefaultColormap(disp, screen_num); - cache_max = cmax; + cache_max = cmax; #ifdef TIMEDCACHE - if (cache_timeout) { - m_timer.setTimeout(cache_timeout); - m_timer.start(); - } + if (cache_timeout) { + m_timer.setTimeout(cache_timeout); + m_timer.start(); + } #endif // TIMEDCACHE - createColorTable(); + createColorTable(); } BImageControl::~BImageControl() { - if (sqrt_table) { - delete [] sqrt_table; - } + if (sqrt_table) { + delete [] sqrt_table; + } - if (grad_xbuffer) { - delete [] grad_xbuffer; - } + if (grad_xbuffer) { + delete [] grad_xbuffer; + } - if (grad_ybuffer) { - delete [] grad_ybuffer; - } + if (grad_ybuffer) { + delete [] grad_ybuffer; + } - if (m_colors) { - unsigned long *pixels = new unsigned long [m_num_colors]; + if (m_colors) { + unsigned long *pixels = new unsigned long [m_num_colors]; - for (unsigned int color = 0; color < m_num_colors; color++) - *(pixels + color) = (*(m_colors + color)).pixel; + for (unsigned int color = 0; color < m_num_colors; color++) + *(pixels + color) = (*(m_colors + color)).pixel; - XFreeColors(FbTk::App::instance()->display(), m_colormap, pixels, m_num_colors, 0); + XFreeColors(FbTk::App::instance()->display(), m_colormap, pixels, m_num_colors, 0); - delete [] m_colors; - } + delete [] m_colors; + } - if (cache.size() > 0) { - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::ImageSet, FBNLS::ImagePixmapRelease, - "BImageContol::~BImageControl: pixmap cache - " - "releasing %d pixmaps\n"), cache.size()); + if (cache.size() > 0) { + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::ImageSet, FBNLS::ImagePixmapRelease, + "BImageContol::~BImageControl: pixmap cache - " + "releasing %d pixmaps\n"), cache.size()); - CacheList::iterator it = cache.begin(); - CacheList::iterator it_end = cache.end(); - Display *disp = FbTk::App::instance()->display(); - for (; it != it_end; ++it) { - XFreePixmap(disp, (*it)->pixmap); - delete (*it); - } + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + Display *disp = FbTk::App::instance()->display(); + for (; it != it_end; ++it) { + XFreePixmap(disp, (*it)->pixmap); + delete (*it); + } - } + } } Pixmap BImageControl::searchCache(unsigned int width, unsigned int height, - unsigned long texture_type, - const FbTk::Color &color, const FbTk::Color &color_to) const { - CacheList::iterator it = cache.begin(); - CacheList::iterator it_end = cache.end(); - for (; it != it_end; ++it) { - if (((*it)->width == width) && - ((*it)->height == height) && - ((*it)->texture == texture_type) && - ((*it)->pixel1 == color.pixel())) { - if (texture_type & FbTk::Texture::GRADIENT) { - if ((*it)->pixel2 == color_to.pixel()) { - (*it)->count++; - return (*it)->pixmap; - } - } else { - (*it)->count++; - return (*it)->pixmap; - } - } - } + unsigned long texture_type, + const FbTk::Color &color, const FbTk::Color &color_to) const { + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + if (((*it)->width == width) && + ((*it)->height == height) && + ((*it)->texture == texture_type) && + ((*it)->pixel1 == color.pixel())) { + if (texture_type & FbTk::Texture::GRADIENT) { + if ((*it)->pixel2 == color_to.pixel()) { + (*it)->count++; + return (*it)->pixmap; + } + } else { + (*it)->count++; + return (*it)->pixmap; + } + } + } - return None; + return None; } Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, - const FbTk::Texture &texture) { + const FbTk::Texture &texture) { - if (texture.type() & FbTk::Texture::PARENTRELATIVE) - return ParentRelative; + if (texture.type() & FbTk::Texture::PARENTRELATIVE) + return ParentRelative; // search cache first - Pixmap pixmap = searchCache(width, height, texture.type(), - texture.color(), texture.colorTo()); - if (pixmap) - return pixmap; // return cache item + Pixmap pixmap = searchCache(width, height, texture.type(), + texture.color(), texture.colorTo()); + if (pixmap) + return pixmap; // return cache item // render new image - TextureRender image(*this, width, height); - pixmap = image.render(texture); + TextureRender image(*this, width, height); + pixmap = image.render(texture); - if (pixmap) { - // create new cache item and add it to cache list + if (pixmap) { + // create new cache item and add it to cache list - Cache *tmp = new Cache; + Cache *tmp = new Cache; - tmp->pixmap = pixmap; - tmp->width = width; - tmp->height = height; - tmp->count = 1; - tmp->texture = texture.type(); - tmp->pixel1 = texture.color().pixel(); + tmp->pixmap = pixmap; + tmp->width = width; + tmp->height = height; + tmp->count = 1; + tmp->texture = texture.type(); + tmp->pixel1 = texture.color().pixel(); - if (texture.type() & FbTk::Texture::GRADIENT) - tmp->pixel2 = texture.colorTo().pixel(); - else - tmp->pixel2 = 0l; + if (texture.type() & FbTk::Texture::GRADIENT) + tmp->pixel2 = texture.colorTo().pixel(); + else + tmp->pixel2 = 0l; - cache.push_back(tmp); + cache.push_back(tmp); - if ((unsigned) cache.size() > cache_max) { + if ((unsigned) cache.size() > cache_max) { #ifdef DEBUG - cerr<<I18n::instance()-> - getMessage( - FBNLS::ImageSet, FBNLS::ImagePixmapCacheLarge, - "BImageControl::renderImage: cache is large, " - "forcing cleanout\n")<<endl; + cerr<<I18n::instance()-> + getMessage( + FBNLS::ImageSet, FBNLS::ImagePixmapCacheLarge, + "BImageControl::renderImage: cache is large, " + "forcing cleanout\n")<<endl; #endif // DEBUG - timeout(); - } + timeout(); + } - return pixmap; - } + return pixmap; + } - return None; + return None; } void BImageControl::removeImage(Pixmap pixmap) { - if (!pixmap) - return; + if (!pixmap) + return; - CacheList::iterator it = cache.begin(); - CacheList::iterator it_end = cache.end(); - for (; it != it_end; ++it) { - if ((*it)->pixmap == pixmap) { - if ((*it)->count) { - (*it)->count--; + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + if ((*it)->pixmap == pixmap) { + if ((*it)->count) { + (*it)->count--; #ifdef TIMEDCACHE - timeout(); + timeout(); #else // !TIMEDCACHE - if (! (*it)->count) timeout(); + if (! (*it)->count) timeout(); #endif // TIMEDCACHE - } + } - return; - } - } + return; + } + } } void BImageControl::colorTables(const unsigned char **rmt, const unsigned char **gmt, - const unsigned char **bmt, - int *roff, int *goff, int *boff, - int *rbit, int *gbit, int *bbit) const { + const unsigned char **bmt, + int *roff, int *goff, int *boff, + int *rbit, int *gbit, int *bbit) const { - if (rmt) *rmt = red_color_table; - if (gmt) *gmt = green_color_table; - if (bmt) *bmt = blue_color_table; + if (rmt) *rmt = red_color_table; + if (gmt) *gmt = green_color_table; + if (bmt) *bmt = blue_color_table; - if (roff) *roff = red_offset; - if (goff) *goff = green_offset; - if (boff) *boff = blue_offset; + if (roff) *roff = red_offset; + if (goff) *goff = green_offset; + if (boff) *boff = blue_offset; - if (rbit) *rbit = red_bits; - if (gbit) *gbit = green_bits; - if (bbit) *bbit = blue_bits; + if (rbit) *rbit = red_bits; + if (gbit) *gbit = green_bits; + if (bbit) *bbit = blue_bits; } void BImageControl::getXColorTable(XColor **c, int *n) { - if (c) *c = m_colors; - if (n) *n = m_num_colors; + if (c) *c = m_colors; + if (n) *n = m_num_colors; } void BImageControl::getGradientBuffers(unsigned int w, - unsigned int h, - unsigned int **xbuf, - unsigned int **ybuf) { + unsigned int h, + unsigned int **xbuf, + unsigned int **ybuf) { - if (w > grad_buffer_width) { - if (grad_xbuffer) { - delete [] grad_xbuffer; - } + if (w > grad_buffer_width) { + if (grad_xbuffer) { + delete [] grad_xbuffer; + } - grad_buffer_width = w; + grad_buffer_width = w; - grad_xbuffer = new unsigned int[grad_buffer_width * 3]; - } + grad_xbuffer = new unsigned int[grad_buffer_width * 3]; + } - if (h > grad_buffer_height) { - if (grad_ybuffer) { - delete [] grad_ybuffer; - } + if (h > grad_buffer_height) { + if (grad_ybuffer) { + delete [] grad_ybuffer; + } - grad_buffer_height = h; + grad_buffer_height = h; - grad_ybuffer = new unsigned int[grad_buffer_height * 3]; - } + grad_ybuffer = new unsigned int[grad_buffer_height * 3]; + } - *xbuf = grad_xbuffer; - *ybuf = grad_ybuffer; + *xbuf = grad_xbuffer; + *ybuf = grad_ybuffer; } void BImageControl::installRootColormap() { - XGrabServer(FbTk::App::instance()->display()); + XGrabServer(FbTk::App::instance()->display()); - Display *disp = FbTk::App::instance()->display(); - bool install = true; - int i = 0, ncmap = 0; - Colormap *cmaps = - XListInstalledColormaps(disp, m_root_window, &ncmap); + Display *disp = FbTk::App::instance()->display(); + bool install = true; + int i = 0, ncmap = 0; + Colormap *cmaps = + XListInstalledColormaps(disp, m_root_window, &ncmap); - if (cmaps) { - for (i = 0; i < ncmap; i++) { - if (*(cmaps + i) == m_colormap) - install = false; - } + if (cmaps) { + for (i = 0; i < ncmap; i++) { + if (*(cmaps + i) == m_colormap) + install = false; + } - if (install) - XInstallColormap(disp, m_colormap); + if (install) + XInstallColormap(disp, m_colormap); - XFree(cmaps); - } + XFree(cmaps); + } - XUngrabServer(FbTk::App::instance()->display()); + XUngrabServer(FbTk::App::instance()->display()); } void BImageControl::setColorsPerChannel(int cpc) { - if (cpc < 2) cpc = 2; - if (cpc > 6) cpc = 6; + if (cpc < 2) cpc = 2; + if (cpc > 6) cpc = 6; - m_colors_per_channel = cpc; + m_colors_per_channel = cpc; } unsigned long BImageControl::getSqrt(unsigned int x) const { - if (! sqrt_table) { - // build sqrt table for use with elliptic gradient + if (! sqrt_table) { + // build sqrt table for use with elliptic gradient - sqrt_table = new unsigned long[(256 * 256 * 2) + 1]; - int i = 0; + sqrt_table = new unsigned long[(256 * 256 * 2) + 1]; + int i = 0; - for (; i < (256 * 256 * 2); i++) - *(sqrt_table + i) = bsqrt(i); - } + for (; i < (256 * 256 * 2); i++) + *(sqrt_table + i) = bsqrt(i); + } - return (*(sqrt_table + x)); + return (*(sqrt_table + x)); } void BImageControl::timeout() { - Display *disp = FbTk::App::instance()->display(); - CacheList::iterator it = cache.begin(); - CacheList::iterator it_end = cache.end(); - for (; it != it_end; ++it) { - Cache *tmp = (*it); + Display *disp = FbTk::App::instance()->display(); + CacheList::iterator it = cache.begin(); + CacheList::iterator it_end = cache.end(); + for (; it != it_end; ++it) { + Cache *tmp = (*it); - if (tmp->count <= 0) { - XFreePixmap(disp, tmp->pixmap); - it = cache.erase(it); - delete tmp; - if (it == it_end) break; - } - } + if (tmp->count <= 0) { + XFreePixmap(disp, tmp->pixmap); + it = cache.erase(it); + delete tmp; + if (it == it_end) break; + } + } } void BImageControl::createColorTable() { - Display *disp = FbTk::App::instance()->display(); + Display *disp = FbTk::App::instance()->display(); - grad_xbuffer = grad_ybuffer = (unsigned int *) 0; - grad_buffer_width = grad_buffer_height = 0; + grad_xbuffer = grad_ybuffer = (unsigned int *) 0; + grad_buffer_width = grad_buffer_height = 0; - int count; - XPixmapFormatValues *pmv = XListPixmapFormats(disp, &count); + int count; + XPixmapFormatValues *pmv = XListPixmapFormats(disp, &count); - if (pmv) { - bits_per_pixel = 0; - for (int i = 0; i < count; i++) { - if (pmv[i].depth == m_screen_depth) { - bits_per_pixel = pmv[i].bits_per_pixel; - break; - } - } + if (pmv) { + bits_per_pixel = 0; + for (int i = 0; i < count; i++) { + if (pmv[i].depth == m_screen_depth) { + bits_per_pixel = pmv[i].bits_per_pixel; + break; + } + } - XFree(pmv); - } + XFree(pmv); + } - if (bits_per_pixel == 0) - bits_per_pixel = m_screen_depth; - if (bits_per_pixel >= 24) - setDither(false); + if (bits_per_pixel == 0) + bits_per_pixel = m_screen_depth; + if (bits_per_pixel >= 24) + setDither(false); - red_offset = green_offset = blue_offset = 0; - I18n *i18n = I18n::instance(); - switch (visual()->c_class) { - case TrueColor: { - int i; + red_offset = green_offset = blue_offset = 0; + I18n *i18n = I18n::instance(); + switch (visual()->c_class) { + case TrueColor: { + int i; - // compute color tables - unsigned long red_mask = visual()->red_mask, - green_mask = visual()->green_mask, - blue_mask = visual()->blue_mask; + // compute color tables + unsigned long red_mask = visual()->red_mask, + green_mask = visual()->green_mask, + blue_mask = visual()->blue_mask; - while (! (red_mask & 1)) { red_offset++; red_mask >>= 1; } - while (! (green_mask & 1)) { green_offset++; green_mask >>= 1; } - while (! (blue_mask & 1)) { blue_offset++; blue_mask >>= 1; } + while (! (red_mask & 1)) { red_offset++; red_mask >>= 1; } + while (! (green_mask & 1)) { green_offset++; green_mask >>= 1; } + while (! (blue_mask & 1)) { blue_offset++; blue_mask >>= 1; } - red_bits = 255 / red_mask; - green_bits = 255 / green_mask; - blue_bits = 255 / blue_mask; + red_bits = 255 / red_mask; + green_bits = 255 / green_mask; + blue_bits = 255 / blue_mask; - for (i = 0; i < 256; i++) { - red_color_table[i] = i / red_bits; - green_color_table[i] = i / green_bits; - blue_color_table[i] = i / blue_bits; - } - } + for (i = 0; i < 256; i++) { + red_color_table[i] = i / red_bits; + green_color_table[i] = i / green_bits; + blue_color_table[i] = i / blue_bits; + } + } - break; + break; - case PseudoColor: - case StaticColor: { + case PseudoColor: + case StaticColor: { - m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; + m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; - if (m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { - m_colors_per_channel = (1 << m_screen_depth) / 3; - m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; - } + if (m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { + m_colors_per_channel = (1 << m_screen_depth) / 3; + m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; + } - if (m_colors_per_channel < 2 || m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageInvalidColormapSize, - "BImageControl::BImageControl: invalid colormap size %d " - "(%d/%d/%d) - reducing"), - m_num_colors, m_colors_per_channel, m_colors_per_channel, - m_colors_per_channel); + if (m_colors_per_channel < 2 || m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageInvalidColormapSize, + "BImageControl::BImageControl: invalid colormap size %d " + "(%d/%d/%d) - reducing"), + m_num_colors, m_colors_per_channel, m_colors_per_channel, + m_colors_per_channel); - m_colors_per_channel = (1 << m_screen_depth) / 3; - } + m_colors_per_channel = (1 << m_screen_depth) / 3; + } - m_colors = new XColor[m_num_colors]; + m_colors = new XColor[m_num_colors]; - int bits = 256 / m_colors_per_channel; + int bits = 256 / m_colors_per_channel; #ifndef ORDEREDPSEUDO - bits = 255 / (m_colors_per_channel - 1); + bits = 255 / (m_colors_per_channel - 1); #endif // ORDEREDPSEUDO - red_bits = green_bits = blue_bits = bits; + red_bits = green_bits = blue_bits = bits; - for (unsigned int i = 0; i < 256; i++) { - red_color_table[i] = green_color_table[i] = blue_color_table[i] = - i / bits; - } + for (unsigned int i = 0; i < 256; i++) { + red_color_table[i] = green_color_table[i] = blue_color_table[i] = + i / bits; + } - for (int r = 0, i = 0; r < m_colors_per_channel; r++) { - for (int g = 0; g < m_colors_per_channel; g++) { - for (int b = 0; b < m_colors_per_channel; b++, i++) { - m_colors[i].red = (r * 0xffff) / (m_colors_per_channel - 1); - m_colors[i].green = (g * 0xffff) / (m_colors_per_channel - 1); - m_colors[i].blue = (b * 0xffff) / (m_colors_per_channel - 1);; - m_colors[i].flags = DoRed|DoGreen|DoBlue; - } - } - } + for (int r = 0, i = 0; r < m_colors_per_channel; r++) { + for (int g = 0; g < m_colors_per_channel; g++) { + for (int b = 0; b < m_colors_per_channel; b++, i++) { + m_colors[i].red = (r * 0xffff) / (m_colors_per_channel - 1); + m_colors[i].green = (g * 0xffff) / (m_colors_per_channel - 1); + m_colors[i].blue = (b * 0xffff) / (m_colors_per_channel - 1);; + m_colors[i].flags = DoRed|DoGreen|DoBlue; + } + } + } - for (unsigned int i = 0; i < m_num_colors; i++) { - if (! XAllocColor(disp, m_colormap, &m_colors[i])) { - fprintf(stderr, - i18n->getMessage( - FBNLS::ImageSet, FBNLS::ImageColorAllocFail, - "couldn't alloc color %i %i %i\n"), - m_colors[i].red, m_colors[i].green, m_colors[i].blue); - m_colors[i].flags = 0; - } else - m_colors[i].flags = DoRed|DoGreen|DoBlue; - } + for (unsigned int i = 0; i < m_num_colors; i++) { + if (! XAllocColor(disp, m_colormap, &m_colors[i])) { + fprintf(stderr, + i18n->getMessage( + FBNLS::ImageSet, FBNLS::ImageColorAllocFail, + "couldn't alloc color %i %i %i\n"), + m_colors[i].red, m_colors[i].green, m_colors[i].blue); + m_colors[i].flags = 0; + } else + m_colors[i].flags = DoRed|DoGreen|DoBlue; + } - XColor icolors[256]; - unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth)); + XColor icolors[256]; + unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : (1 << m_screen_depth)); - for (unsigned int i = 0; i < incolors; i++) - icolors[i].pixel = i; + for (unsigned int i = 0; i < incolors; i++) + icolors[i].pixel = i; - XQueryColors(disp, m_colormap, icolors, incolors); - for (unsigned int i = 0; i < m_num_colors; i++) { - if (! m_colors[i].flags) { - unsigned long chk = 0xffffffff, pixel, close = 0; - char p = 2; + XQueryColors(disp, m_colormap, icolors, incolors); + for (unsigned int i = 0; i < m_num_colors; i++) { + if (! m_colors[i].flags) { + unsigned long chk = 0xffffffff, pixel, close = 0; + char p = 2; - while (p--) { - for (unsigned int ii = 0; ii < incolors; ii++) { - int r = (m_colors[i].red - icolors[i].red) >> 8; - int g = (m_colors[i].green - icolors[i].green) >> 8; - int b = (m_colors[i].blue - icolors[i].blue) >> 8; - pixel = (r * r) + (g * g) + (b * b); + while (p--) { + for (unsigned int ii = 0; ii < incolors; ii++) { + int r = (m_colors[i].red - icolors[i].red) >> 8; + int g = (m_colors[i].green - icolors[i].green) >> 8; + int b = (m_colors[i].blue - icolors[i].blue) >> 8; + pixel = (r * r) + (g * g) + (b * b); - if (pixel < chk) { - chk = pixel; - close = ii; - } + if (pixel < chk) { + chk = pixel; + close = ii; + } - m_colors[i].red = icolors[close].red; - m_colors[i].green = icolors[close].green; - m_colors[i].blue = icolors[close].blue; + m_colors[i].red = icolors[close].red; + m_colors[i].green = icolors[close].green; + m_colors[i].blue = icolors[close].blue; - if (XAllocColor(disp, m_colormap, - &m_colors[i])) { - m_colors[i].flags = DoRed|DoGreen|DoBlue; - break; - } - } - } - } - } + if (XAllocColor(disp, m_colormap, + &m_colors[i])) { + m_colors[i].flags = DoRed|DoGreen|DoBlue; + break; + } + } + } + } + } - break; - } + break; + } - case GrayScale: - case StaticGray: - { + case GrayScale: + case StaticGray: + { - if (visual()->c_class == StaticGray) { - m_num_colors = 1 << m_screen_depth; - } else { - m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; + if (visual()->c_class == StaticGray) { + m_num_colors = 1 << m_screen_depth; + } else { + m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; - if (m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { - m_colors_per_channel = (1 << m_screen_depth) / 3; - m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; - } - } + if (m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { + m_colors_per_channel = (1 << m_screen_depth) / 3; + m_num_colors = m_colors_per_channel * m_colors_per_channel * m_colors_per_channel; + } + } - if (m_colors_per_channel < 2 || m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageInvalidColormapSize, - "BImageControl::BImageControl: invalid colormap size %d " - "(%d/%d/%d) - reducing"), - m_num_colors, m_colors_per_channel, m_colors_per_channel, - m_colors_per_channel); + if (m_colors_per_channel < 2 || m_num_colors > static_cast<unsigned int>(1 << m_screen_depth)) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageInvalidColormapSize, + "BImageControl::BImageControl: invalid colormap size %d " + "(%d/%d/%d) - reducing"), + m_num_colors, m_colors_per_channel, m_colors_per_channel, + m_colors_per_channel); - m_colors_per_channel = (1 << m_screen_depth) / 3; - } + m_colors_per_channel = (1 << m_screen_depth) / 3; + } - m_colors = new XColor[m_num_colors]; + m_colors = new XColor[m_num_colors]; - int p, bits = 255 / (m_colors_per_channel - 1); - red_bits = green_bits = blue_bits = bits; + int p, bits = 255 / (m_colors_per_channel - 1); + red_bits = green_bits = blue_bits = bits; - for (unsigned int i = 0; i < 256; i++) - red_color_table[i] = green_color_table[i] = blue_color_table[i] = - i / bits; + for (unsigned int i = 0; i < 256; i++) + red_color_table[i] = green_color_table[i] = blue_color_table[i] = + i / bits; - for (unsigned int i = 0; i < m_num_colors; i++) { - m_colors[i].red = (i * 0xffff) / (m_colors_per_channel - 1); - m_colors[i].green = (i * 0xffff) / (m_colors_per_channel - 1); - m_colors[i].blue = (i * 0xffff) / (m_colors_per_channel - 1);; - m_colors[i].flags = DoRed|DoGreen|DoBlue; + for (unsigned int i = 0; i < m_num_colors; i++) { + m_colors[i].red = (i * 0xffff) / (m_colors_per_channel - 1); + m_colors[i].green = (i * 0xffff) / (m_colors_per_channel - 1); + m_colors[i].blue = (i * 0xffff) / (m_colors_per_channel - 1);; + m_colors[i].flags = DoRed|DoGreen|DoBlue; - if (! XAllocColor(disp, m_colormap, - &m_colors[i])) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageColorAllocFail, - "couldn't alloc color %i %i %i\n"), - m_colors[i].red, m_colors[i].green, m_colors[i].blue); - m_colors[i].flags = 0; - } else - m_colors[i].flags = DoRed|DoGreen|DoBlue; - } + if (! XAllocColor(disp, m_colormap, + &m_colors[i])) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageColorAllocFail, + "couldn't alloc color %i %i %i\n"), + m_colors[i].red, m_colors[i].green, m_colors[i].blue); + m_colors[i].flags = 0; + } else + m_colors[i].flags = DoRed|DoGreen|DoBlue; + } - XColor icolors[256]; - unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : - (1 << m_screen_depth)); + XColor icolors[256]; + unsigned int incolors = (((1 << m_screen_depth) > 256) ? 256 : + (1 << m_screen_depth)); - for (unsigned int i = 0; i < incolors; i++) - icolors[i].pixel = i; + for (unsigned int i = 0; i < incolors; i++) + icolors[i].pixel = i; - XQueryColors(disp, m_colormap, icolors, incolors); - for (unsigned int i = 0; i < m_num_colors; i++) { - if (! m_colors[i].flags) { - unsigned long chk = 0xffffffff, pixel, close = 0; + XQueryColors(disp, m_colormap, icolors, incolors); + for (unsigned int i = 0; i < m_num_colors; i++) { + if (! m_colors[i].flags) { + unsigned long chk = 0xffffffff, pixel, close = 0; - p = 2; - while (p--) { - for (unsigned int ii = 0; ii < incolors; ii++) { - int r = (m_colors[i].red - icolors[i].red) >> 8; - int g = (m_colors[i].green - icolors[i].green) >> 8; - int b = (m_colors[i].blue - icolors[i].blue) >> 8; - pixel = (r * r) + (g * g) + (b * b); + p = 2; + while (p--) { + for (unsigned int ii = 0; ii < incolors; ii++) { + int r = (m_colors[i].red - icolors[i].red) >> 8; + int g = (m_colors[i].green - icolors[i].green) >> 8; + int b = (m_colors[i].blue - icolors[i].blue) >> 8; + pixel = (r * r) + (g * g) + (b * b); - if (pixel < chk) { - chk = pixel; - close = ii; - } + if (pixel < chk) { + chk = pixel; + close = ii; + } - m_colors[i].red = icolors[close].red; - m_colors[i].green = icolors[close].green; - m_colors[i].blue = icolors[close].blue; + m_colors[i].red = icolors[close].red; + m_colors[i].green = icolors[close].green; + m_colors[i].blue = icolors[close].blue; - if (XAllocColor(disp, m_colormap, &m_colors[i])) { - m_colors[i].flags = DoRed|DoGreen|DoBlue; - break; - } - } - } - } - } + if (XAllocColor(disp, m_colormap, &m_colors[i])) { + m_colors[i].flags = DoRed|DoGreen|DoBlue; + break; + } + } + } + } + } - break; - } + break; + } - default: - throw string(i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageUnsupVisual, - "BImageControl::BImageControl: unsupported visual")); + default: + throw string(i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageUnsupVisual, + "BImageControl::BImageControl: unsupported visual")); - } + } }
M src/ImageControl.hhsrc/ImageControl.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: ImageControl.hh,v 1.2 2002/11/30 20:59:54 fluxgen Exp $ +// $Id: ImageControl.hh,v 1.3 2002/12/01 13:41:57 rathnor Exp $ #ifndef IMAGECONTROL_HH #define IMAGECONTROL_HH

@@ -39,85 +39,85 @@ Holds screen info and color tables

*/ class BImageControl : public TimeoutHandler { public: - BImageControl(int screen_num, bool dither = false, int colors_per_channel = 4, - unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); - virtual ~BImageControl(); + BImageControl(int screen_num, bool dither = false, int colors_per_channel = 4, + unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l); + virtual ~BImageControl(); - inline bool doDither() const { return m_dither; } - inline int bitsPerPixel() const { return bits_per_pixel; } - inline int depth() const { return m_screen_depth; } - inline int colorsPerChannel() const { return m_colors_per_channel; } - int screenNum() const { return m_screen_num; } - Visual *visual() const { return m_visual; } - unsigned long getSqrt(unsigned int val) const; + inline bool doDither() const { return m_dither; } + inline int bitsPerPixel() const { return bits_per_pixel; } + inline int depth() const { return m_screen_depth; } + inline int colorsPerChannel() const { return m_colors_per_channel; } + int screenNum() const { return m_screen_num; } + Visual *visual() const { return m_visual; } + unsigned long getSqrt(unsigned int val) const; - /** - Render to pixmap - @param width width of pixmap - @param height height of pixmap - @param src_texture texture type to render - @return pixmap of the rendered image, on failure None - */ - Pixmap renderImage(unsigned int width, unsigned int height, - const FbTk::Texture &src_texture); + /** + Render to pixmap + @param width width of pixmap + @param height height of pixmap + @param src_texture texture type to render + @return pixmap of the rendered image, on failure None + */ + Pixmap renderImage(unsigned int width, unsigned int height, + const FbTk::Texture &src_texture); - void installRootColormap(); - void removeImage(Pixmap thepix); - void colorTables(const unsigned char **, const unsigned char **, const unsigned char **, - int *, int *, int *, int *, int *, int *) const; - void getXColorTable(XColor **, int *); - void getGradientBuffers(unsigned int, unsigned int, - unsigned int **, unsigned int **); - void setDither(bool d) { m_dither = d; } - void setColorsPerChannel(int cpc); + void installRootColormap(); + void removeImage(Pixmap thepix); + void colorTables(const unsigned char **, const unsigned char **, const unsigned char **, + int *, int *, int *, int *, int *, int *) const; + void getXColorTable(XColor **, int *); + void getGradientBuffers(unsigned int, unsigned int, + unsigned int **, unsigned int **); + void setDither(bool d) { m_dither = d; } + void setColorsPerChannel(int cpc); - virtual void timeout(); + virtual void timeout(); private: - /** - Search cache for a specific pixmap - @return None if no cache was found - */ - Pixmap searchCache(unsigned int width, unsigned int height, unsigned long texture_type, - const FbTk::Color &color, const FbTk::Color &color_to) const; + /** + Search cache for a specific pixmap + @return None if no cache was found + */ + Pixmap searchCache(unsigned int width, unsigned int height, unsigned long texture_type, + const FbTk::Color &color, const FbTk::Color &color_to) const; - void createColorTable(); - bool m_dither; + void createColorTable(); + bool m_dither; - BTimer m_timer; + BTimer m_timer; - Colormap m_colormap; + Colormap m_colormap; - Window m_root_window; + Window m_root_window; - XColor *m_colors; ///< color table - unsigned int m_num_colors; ///< number of colors in color table + XColor *m_colors; ///< color table + unsigned int m_num_colors; ///< number of colors in color table - Visual *m_visual; + Visual *m_visual; - int bits_per_pixel, red_offset, green_offset, blue_offset, - red_bits, green_bits, blue_bits; - int m_colors_per_channel; ///< number of colors per channel - int m_screen_depth; ///< bit depth of screen - int m_screen_num; ///< screen number - unsigned char red_color_table[256], green_color_table[256], - blue_color_table[256]; - unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width, - grad_buffer_height; + int bits_per_pixel, red_offset, green_offset, blue_offset, + red_bits, green_bits, blue_bits; + int m_colors_per_channel; ///< number of colors per channel + int m_screen_depth; ///< bit depth of screen + int m_screen_num; ///< screen number + unsigned char red_color_table[256], green_color_table[256], + blue_color_table[256]; + unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width, + grad_buffer_height; - static unsigned long *sqrt_table; /// sqrt lookup table + static unsigned long *sqrt_table; /// sqrt lookup table - typedef struct Cache { - Pixmap pixmap; + typedef struct Cache { + Pixmap pixmap; - unsigned int count, width, height; - unsigned long pixel1, pixel2, texture; - } Cache; + unsigned int count, width, height; + unsigned long pixel1, pixel2, texture; + } Cache; - unsigned long cache_max; - typedef std::list<Cache *> CacheList; + unsigned long cache_max; + typedef std::list<Cache *> CacheList; - mutable CacheList cache; + mutable CacheList cache; };
M src/Keys.ccsrc/Keys.cc

@@ -19,7 +19,7 @@ // 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. -//$Id: Keys.cc,v 1.20 2002/11/13 14:34:24 fluxgen Exp $ +//$Id: Keys.cc,v 1.21 2002/12/01 13:41:57 rathnor Exp $ #include "Keys.hh"

@@ -69,103 +69,103 @@

using namespace std; Keys::t_actionstr Keys::m_actionlist[] = { - {"Minimize", ICONIFY}, - {"Raise", RAISE}, - {"Lower", LOWER}, - {"Close", CLOSE}, - {"AbortKeychain", ABORTKEYCHAIN}, - {"Workspace", WORKSPACE}, - {"Workspace1", WORKSPACE1}, - {"Workspace2", WORKSPACE2}, - {"Workspace3", WORKSPACE3}, - {"Workspace4", WORKSPACE4}, - {"Workspace5", WORKSPACE5}, - {"Workspace6", WORKSPACE6}, - {"Workspace7", WORKSPACE7}, - {"Workspace8", WORKSPACE8}, - {"Workspace9", WORKSPACE9}, - {"Workspace10", WORKSPACE10}, - {"Workspace11", WORKSPACE11}, - {"Workspace12", WORKSPACE12}, - {"SendToWorkspace", SENDTOWORKSPACE}, - {"NextWorkspace", NEXTWORKSPACE}, - {"PrevWorkspace", PREVWORKSPACE}, - {"LeftWorkspace", LEFTWORKSPACE}, - {"RightWorkspace", RIGHTWORKSPACE}, - {"KillWindow", KILLWINDOW}, - {"NextWindow", NEXTWINDOW}, - {"PrevWindow", PREVWINDOW}, - {"NextTab", NEXTTAB}, - {"PrevTab", PREVTAB}, - {"FirstTab", FIRSTTAB}, - {"LastTab", LASTTAB}, - {"MoveTabPrev", MOVETABPREV}, - {"MoveTabNext", MOVETABNEXT}, - {"ShadeWindow", SHADE}, - {"MaximizeWindow", MAXIMIZE}, - {"StickWindow", STICK}, - {"ExecCommand", EXECUTE}, - {"MaximizeVertical", VERTMAX}, - {"MaximizeHorizontal", HORIZMAX}, - {"NudgeRight", NUDGERIGHT}, - {"NudgeLeft", NUDGELEFT}, - {"NudgeUp", NUDGEUP}, - {"NudgeDown", NUDGEDOWN}, - {"BigNudgeRight", BIGNUDGERIGHT}, - {"BigNudgeLeft", BIGNUDGELEFT}, - {"BigNudgeUp", BIGNUDGEUP}, - {"BigNudgeDown", BIGNUDGEDOWN}, - {"HorizontalIncrement", HORIZINC}, - {"VerticalIncrement", VERTINC}, - {"HorizontalDecrement", HORIZDEC}, - {"VerticalDecrement", VERTDEC}, - {"ToggleDecor", TOGGLEDECOR}, - {"ToggleTab", TOGGLETAB}, - {"RootMenu", ROOTMENU}, - {0, LASTKEYGRAB} - }; + {"Minimize", ICONIFY}, + {"Raise", RAISE}, + {"Lower", LOWER}, + {"Close", CLOSE}, + {"AbortKeychain", ABORTKEYCHAIN}, + {"Workspace", WORKSPACE}, + {"Workspace1", WORKSPACE1}, + {"Workspace2", WORKSPACE2}, + {"Workspace3", WORKSPACE3}, + {"Workspace4", WORKSPACE4}, + {"Workspace5", WORKSPACE5}, + {"Workspace6", WORKSPACE6}, + {"Workspace7", WORKSPACE7}, + {"Workspace8", WORKSPACE8}, + {"Workspace9", WORKSPACE9}, + {"Workspace10", WORKSPACE10}, + {"Workspace11", WORKSPACE11}, + {"Workspace12", WORKSPACE12}, + {"SendToWorkspace", SENDTOWORKSPACE}, + {"NextWorkspace", NEXTWORKSPACE}, + {"PrevWorkspace", PREVWORKSPACE}, + {"LeftWorkspace", LEFTWORKSPACE}, + {"RightWorkspace", RIGHTWORKSPACE}, + {"KillWindow", KILLWINDOW}, + {"NextWindow", NEXTWINDOW}, + {"PrevWindow", PREVWINDOW}, + {"NextTab", NEXTTAB}, + {"PrevTab", PREVTAB}, + {"FirstTab", FIRSTTAB}, + {"LastTab", LASTTAB}, + {"MoveTabPrev", MOVETABPREV}, + {"MoveTabNext", MOVETABNEXT}, + {"ShadeWindow", SHADE}, + {"MaximizeWindow", MAXIMIZE}, + {"StickWindow", STICK}, + {"ExecCommand", EXECUTE}, + {"MaximizeVertical", VERTMAX}, + {"MaximizeHorizontal", HORIZMAX}, + {"NudgeRight", NUDGERIGHT}, + {"NudgeLeft", NUDGELEFT}, + {"NudgeUp", NUDGEUP}, + {"NudgeDown", NUDGEDOWN}, + {"BigNudgeRight", BIGNUDGERIGHT}, + {"BigNudgeLeft", BIGNUDGELEFT}, + {"BigNudgeUp", BIGNUDGEUP}, + {"BigNudgeDown", BIGNUDGEDOWN}, + {"HorizontalIncrement", HORIZINC}, + {"VerticalIncrement", VERTINC}, + {"HorizontalDecrement", HORIZDEC}, + {"VerticalDecrement", VERTDEC}, + {"ToggleDecor", TOGGLEDECOR}, + {"ToggleTab", TOGGLETAB}, + {"RootMenu", ROOTMENU}, + {0, LASTKEYGRAB} +}; Keys::Keys(Display *display, const char *filename): -m_capslock_mod(0), -m_numlock_mod(0), -m_scrolllock_mod(0), -m_abortkey(0), -m_display(display) + m_capslock_mod(0), + m_numlock_mod(0), + m_scrolllock_mod(0), + m_abortkey(0), + m_display(display) { - determineModmap(); - assert(display); - if (filename != 0) - load(filename); + determineModmap(); + assert(display); + if (filename != 0) + load(filename); } Keys::~Keys() { - ungrabKeys(); - deleteTree(); + ungrabKeys(); + deleteTree(); } //--------- deleteTree ----------- // Destroys the keytree and m_abortkey //-------------------------------- void Keys::deleteTree() { - while (!m_keylist.empty()) { - if (m_keylist.back() && m_keylist.back() != 0) - delete m_keylist.back(); - m_keylist.pop_back(); - } - if (m_abortkey) { - delete m_abortkey; - m_abortkey=0; - } + while (!m_keylist.empty()) { + if (m_keylist.back() && m_keylist.back() != 0) + delete m_keylist.back(); + m_keylist.pop_back(); + } + if (m_abortkey) { + delete m_abortkey; + m_abortkey=0; + } } //-------- ungrabKeys --------- // Ungrabs the keys //----------------------------- void Keys::ungrabKeys() { - for (int screen=0; screen<ScreenCount(m_display); screen++) { - XUngrabKey(m_display, AnyKey, AnyModifier, - RootWindow(m_display, screen)); - } + for (int screen=0; screen<ScreenCount(m_display); screen++) { + XUngrabKey(m_display, AnyKey, AnyModifier, + RootWindow(m_display, screen)); + } } //-------------- load ----------------

@@ -174,180 +174,180 @@ // Returns true on success else false

// TODO: error checking //------------------------------------ bool Keys::load(const char *filename) { - if (!filename) - return false; + if (!filename) + return false; - //ungrab all keys - ungrabKeys(); + //ungrab all keys + ungrabKeys(); - //free memory of previous grabs - deleteTree(); + //free memory of previous grabs + deleteTree(); - XSync(m_display, False); + XSync(m_display, False); - //open the file - ifstream infile(filename); - if (!infile) - return false; // faild to open file + //open the file + ifstream infile(filename); + if (!infile) + return false; // faild to open file - int line=0;//current line, so we can tell the user where the fault is + int line=0;//current line, so we can tell the user where the fault is - while (!infile.eof()) { - string linebuffer; + while (!infile.eof()) { + string linebuffer; - getline(infile, linebuffer); + getline(infile, linebuffer); - line++; - vector<string> val; - //Parse arguments - StringUtil::stringtok(val, linebuffer.c_str()); + line++; + vector<string> val; + //Parse arguments + StringUtil::stringtok(val, linebuffer.c_str()); - //must have at least 1 argument - if (val.size() <= 0) - continue; + //must have at least 1 argument + if (val.size() <= 0) + continue; - if (val[0][0] == '#') //the line is commented - continue; + if (val[0][0] == '#') //the line is commented + continue; - unsigned int key=0, mod=0; - char keyarg=0; - t_key *current_key=0, *last_key=0; + unsigned int key=0, mod=0; + char keyarg=0; + t_key *current_key=0, *last_key=0; - for (unsigned int argc=0; argc<val.size(); argc++) { + for (unsigned int argc=0; argc<val.size(); argc++) { - if (val[argc][0]!=':') { - keyarg++; - if (keyarg==1) //first arg is modifier - mod = getModifier(val[argc].c_str()); - else if (keyarg>1) { + if (val[argc][0]!=':') { + keyarg++; + if (keyarg==1) //first arg is modifier + mod = getModifier(val[argc].c_str()); + else if (keyarg>1) { - //keyarg=0; - int tmpmod=getModifier(val[argc].c_str()); - if(tmpmod) - mod|=tmpmod; //If it's a modifier - else { - key = getKey(val[argc].c_str()); // else get the key - if (key == 0) { - cerr<<"["<<filename<<"]: Invalid key/modifier on line("<< - line<<"): "<<linebuffer<<endl; - break; // get next line - } - if (!current_key) { - current_key = new t_key(key, mod); - last_key = current_key; - } else { - t_key *temp_key = new t_key(key, mod); - last_key->keylist.push_back(temp_key); - last_key = temp_key; - } - } - } + //keyarg=0; + int tmpmod=getModifier(val[argc].c_str()); + if(tmpmod) + mod|=tmpmod; //If it's a modifier + else { + key = getKey(val[argc].c_str()); // else get the key + if (key == 0) { + cerr<<"["<<filename<<"]: Invalid key/modifier on line("<< + line<<"): "<<linebuffer<<endl; + break; // get next line + } + if (!current_key) { + current_key = new t_key(key, mod); + last_key = current_key; + } else { + t_key *temp_key = new t_key(key, mod); + last_key->keylist.push_back(temp_key); + last_key = temp_key; + } + } + } - } else { + } else { - unsigned int i=0; + unsigned int i=0; - for (i=0; i< LASTKEYGRAB; i++) { - // +1 on the val[argc] because we dont want to compare the ':' - if (strcasecmp(m_actionlist[i].string, val[argc].c_str()+1) == 0) - break; - } + for (i=0; i< LASTKEYGRAB; i++) { + // +1 on the val[argc] because we dont want to compare the ':' + if (strcasecmp(m_actionlist[i].string, val[argc].c_str()+1) == 0) + break; + } - if (i < LASTKEYGRAB ) { - if (!current_key) { - cerr<<"Error on line: "<<line<<endl; - cerr<<linebuffer<<endl; - delete current_key; - current_key = 0; - last_key = 0; - break; //break out and read next line - } + if (i < LASTKEYGRAB ) { + if (!current_key) { + cerr<<"Error on line: "<<line<<endl; + cerr<<linebuffer<<endl; + delete current_key; + current_key = 0; + last_key = 0; + break; //break out and read next line + } - //special case for grabAbortKeychain - if (m_actionlist[i].action == ABORTKEYCHAIN) { - if (last_key!=current_key) - cerr<<"Keys: "<<m_actionlist[i].string<<" cant be in chained mode"<<endl; - else if (m_abortkey) - cerr<<"Keys: "<<m_actionlist[i].string<<" is already bound."<<endl; - else - m_abortkey = new t_key(current_key->key, current_key->mod, ABORTKEYCHAIN); + //special case for grabAbortKeychain + if (m_actionlist[i].action == ABORTKEYCHAIN) { + if (last_key!=current_key) + cerr<<"Keys: "<<m_actionlist[i].string<<" cant be in chained mode"<<endl; + else if (m_abortkey) + cerr<<"Keys: "<<m_actionlist[i].string<<" is already bound."<<endl; + else + m_abortkey = new t_key(current_key->key, current_key->mod, ABORTKEYCHAIN); - delete current_key; - current_key = 0; - last_key = 0; - break; //break out and read next line - } + delete current_key; + current_key = 0; + last_key = 0; + break; //break out and read next line + } - last_key->action = m_actionlist[i].action; - switch(last_key->action) { - case Keys::EXECUTE: - last_key->execcommand = - const_cast<char *> - (StringUtil::strcasestr(linebuffer.c_str(), - getActionStr(Keys::EXECUTE))+ - strlen(getActionStr(Keys::EXECUTE))); - break; - case WORKSPACE: - case SENDTOWORKSPACE: - if (argc + 1 < val.size()) - last_key->param = atoi( val[argc+1].c_str()); - else - last_key->param = 0; - break; - case NEXTWINDOW: - case PREVWINDOW: - if (argc + 1 < val.size()) - last_key->param = atoi( val[argc+1].c_str()); - else - last_key->param = 0; - break; - case LEFTWORKSPACE: - case RIGHTWORKSPACE: - case NEXTWORKSPACE: - case PREVWORKSPACE: - if (argc + 1 < val.size()) - last_key->param = atoi( val[argc+1].c_str()); - else - last_key->param = 1; - break; - case NUDGERIGHT: - case NUDGELEFT: - case NUDGEUP: - case NUDGEDOWN: - if (argc + 1 < val.size()) - last_key->param = atoi( val[argc+1].c_str()); - else - last_key->param = 2; - break; - default: - break; - } + last_key->action = m_actionlist[i].action; + switch(last_key->action) { + case Keys::EXECUTE: + last_key->execcommand = + const_cast<char *> + (StringUtil::strcasestr(linebuffer.c_str(), + getActionStr(Keys::EXECUTE))+ + strlen(getActionStr(Keys::EXECUTE))); + break; + case WORKSPACE: + case SENDTOWORKSPACE: + if (argc + 1 < val.size()) + last_key->param = atoi( val[argc+1].c_str()); + else + last_key->param = 0; + break; + case NEXTWINDOW: + case PREVWINDOW: + if (argc + 1 < val.size()) + last_key->param = atoi( val[argc+1].c_str()); + else + last_key->param = 0; + break; + case LEFTWORKSPACE: + case RIGHTWORKSPACE: + case NEXTWORKSPACE: + case PREVWORKSPACE: + if (argc + 1 < val.size()) + last_key->param = atoi( val[argc+1].c_str()); + else + last_key->param = 1; + break; + case NUDGERIGHT: + case NUDGELEFT: + case NUDGEUP: + case NUDGEDOWN: + if (argc + 1 < val.size()) + last_key->param = atoi( val[argc+1].c_str()); + else + last_key->param = 2; + break; + default: + break; + } - //add the keychain to list - if (!mergeTree(current_key)) - cerr<<"Keys: Failed to merge keytree!"<<endl; + //add the keychain to list + if (!mergeTree(current_key)) + cerr<<"Keys: Failed to merge keytree!"<<endl; - //clear keypointers now that we have them in m_keylist - delete current_key; - current_key = 0; - last_key = 0; + //clear keypointers now that we have them in m_keylist + delete current_key; + current_key = 0; + last_key = 0; - } else { //destroy list if no action is found + } else { //destroy list if no action is found #ifdef DEBUG - cerr<<"Didnt find action="<<val[argc]<<endl; + cerr<<"Didnt find action="<<val[argc]<<endl; #endif // DEBUG - //destroy current_key ... this will also destroy the last_key - delete current_key; - current_key = 0; - last_key = 0; - } + //destroy current_key ... this will also destroy the last_key + delete current_key; + current_key = 0; + last_key = 0; + } - break; //dont process this linebuffer more - } - } - } + break; //dont process this linebuffer more + } + } + } - return true; + return true; } //--------- grabKey ---------------------

@@ -356,50 +356,50 @@ // and with numlock,capslock and scrollock

//---------------------------------------- void Keys::grabKey(unsigned int key, unsigned int mod) { - for (int screen=0; screen<ScreenCount(m_display); screen++) { + for (int screen=0; screen<ScreenCount(m_display); screen++) { - Window root = RootWindow(m_display, screen); + Window root = RootWindow(m_display, screen); - XGrabKey(m_display, key, mod, - root, True, - GrabModeAsync, GrabModeAsync); + XGrabKey(m_display, key, mod, + root, True, + GrabModeAsync, GrabModeAsync); - // Grab with numlock, capslock and scrlock + // Grab with numlock, capslock and scrlock - //numlock - XGrabKey(m_display, key, mod|m_numlock_mod, - root, True, - GrabModeAsync, GrabModeAsync); - //scrolllock - XGrabKey(m_display, key, mod|m_scrolllock_mod, - root, True, - GrabModeAsync, GrabModeAsync); - //capslock - XGrabKey(m_display, key, mod|m_capslock_mod, - root, True, - GrabModeAsync, GrabModeAsync); + //numlock + XGrabKey(m_display, key, mod|m_numlock_mod, + root, True, + GrabModeAsync, GrabModeAsync); + //scrolllock + XGrabKey(m_display, key, mod|m_scrolllock_mod, + root, True, + GrabModeAsync, GrabModeAsync); + //capslock + XGrabKey(m_display, key, mod|m_capslock_mod, + root, True, + GrabModeAsync, GrabModeAsync); - //capslock+numlock - XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, - root, True, - GrabModeAsync, GrabModeAsync); + //capslock+numlock + XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, + root, True, + GrabModeAsync, GrabModeAsync); - //capslock+scrolllock - XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, - root, True, - GrabModeAsync, GrabModeAsync); + //capslock+scrolllock + XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, + root, True, + GrabModeAsync, GrabModeAsync); - //capslock+numlock+scrolllock - XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, - root, True, - GrabModeAsync, GrabModeAsync); + //capslock+numlock+scrolllock + XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, + root, True, + GrabModeAsync, GrabModeAsync); - //numlock+scrollLock - XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, - root, True, - GrabModeAsync, GrabModeAsync); + //numlock+scrollLock + XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, + root, True, + GrabModeAsync, GrabModeAsync); - } + } }

@@ -409,32 +409,32 @@ // else zero on failure.

// TODO fix more masks //---------------------------------------- unsigned int Keys::getModifier(const char *modstr) { - if (!modstr) - return 0; - struct t_modlist{ - char *string; - unsigned int mask; - bool operator == (const char *modstr) { - return (strcasecmp(string, modstr) == 0 && mask !=0); - } - } modlist[] = { - {"SHIFT", ShiftMask}, - {"CONTROL", ControlMask}, - {"MOD1", Mod1Mask}, - {"MOD2", Mod2Mask}, - {"MOD3", Mod3Mask}, - {"MOD4", Mod4Mask}, - {"MOD5", Mod5Mask}, - {0, 0} - }; + if (!modstr) + return 0; + struct t_modlist{ + char *string; + unsigned int mask; + bool operator == (const char *modstr) { + return (strcasecmp(string, modstr) == 0 && mask !=0); + } + } modlist[] = { + {"SHIFT", ShiftMask}, + {"CONTROL", ControlMask}, + {"MOD1", Mod1Mask}, + {"MOD2", Mod2Mask}, + {"MOD3", Mod3Mask}, + {"MOD4", Mod4Mask}, + {"MOD5", Mod5Mask}, + {0, 0} + }; - // find mod mask string - for (unsigned int i=0; modlist[i].string!=0; i++) { - if (modlist[i] == modstr) - return modlist[i].mask; - } + // find mod mask string + for (unsigned int i=0; modlist[i].string!=0; i++) { + if (modlist[i] == modstr) + return modlist[i].mask; + } - return 0; + return 0; } //----------- getKey ----------------

@@ -442,63 +442,63 @@ // Returns keycode of keystr on success

// else it returns zero //----------------------------------- unsigned int Keys::getKey(const char *keystr) { - if (!keystr) - return 0; - return XKeysymToKeycode(m_display, - XStringToKeysym(keystr)); + if (!keystr) + return 0; + return XKeysymToKeycode(m_display, + XStringToKeysym(keystr)); } //--------- getAction ----------------- // returns the KeyAction of the XKeyEvent //------------------------------------- Keys::KeyAction Keys::getAction(XKeyEvent *ke) { - static t_key *next_key = 0; - //remove numlock, capslock and scrolllock - ke->state &= ~Mod2Mask & ~Mod5Mask & ~LockMask; + static t_key *next_key = 0; + //remove numlock, capslock and scrolllock + ke->state &= ~Mod2Mask & ~Mod5Mask & ~LockMask; - if (m_abortkey && *m_abortkey==ke) { //abort current keychain - next_key = 0; - return m_abortkey->action; - } + if (m_abortkey && *m_abortkey==ke) { //abort current keychain + next_key = 0; + return m_abortkey->action; + } - if (!next_key) { + if (!next_key) { - for (unsigned int i=0; i<m_keylist.size(); i++) { - if (*m_keylist[i] == ke) { - if (m_keylist[i]->keylist.size()) { - next_key = m_keylist[i]; - break; //end for-loop - } else { - if (m_keylist[i]->action == Keys::EXECUTE) - m_execcmdstring = m_keylist[i]->execcommand; //update execcmdstring if action is grabExecute - m_param = m_keylist[i]->param; - return m_keylist[i]->action; - } - } - } + for (unsigned int i=0; i<m_keylist.size(); i++) { + if (*m_keylist[i] == ke) { + if (m_keylist[i]->keylist.size()) { + next_key = m_keylist[i]; + break; //end for-loop + } else { + if (m_keylist[i]->action == Keys::EXECUTE) + m_execcmdstring = m_keylist[i]->execcommand; //update execcmdstring if action is grabExecute + m_param = m_keylist[i]->param; + return m_keylist[i]->action; + } + } + } - } else { //check the nextkey - t_key *temp_key = next_key->find(ke); - if (temp_key) { - if (temp_key->keylist.size()) { - next_key = temp_key; - } else { - next_key = 0; - if (temp_key->action == Keys::EXECUTE) - m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute - return temp_key->action; - } - } else { - temp_key = next_key; - next_key = 0; - if (temp_key->action == Keys::EXECUTE) - m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute - return temp_key->action; - } + } else { //check the nextkey + t_key *temp_key = next_key->find(ke); + if (temp_key) { + if (temp_key->keylist.size()) { + next_key = temp_key; + } else { + next_key = 0; + if (temp_key->action == Keys::EXECUTE) + m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute + return temp_key->action; + } + } else { + temp_key = next_key; + next_key = 0; + if (temp_key->action == Keys::EXECUTE) + m_execcmdstring = temp_key->execcommand; //update execcmdstring if action is grabExecute + return temp_key->action; + } - } + } - return Keys::LASTKEYGRAB; + return Keys::LASTKEYGRAB; } //--------- reconfigure -------------

@@ -506,8 +506,8 @@ // deletes the tree and load configuration

// returns true on success else false //----------------------------------- bool Keys::reconfigure(const char *filename) { - deleteTree(); - return load(filename); + deleteTree(); + return load(filename); } //------------- getActionStr ------------------

@@ -516,12 +516,12 @@ // Returns actionstring on success else

// 0 on failure //--------------------------------------------- const char *Keys::getActionStr(KeyAction action) { - for (unsigned int i=0; m_actionlist[i].string!=0 ; i++) { - if (m_actionlist[i].action == action) - return m_actionlist[i].string; - } + for (unsigned int i=0; m_actionlist[i].string!=0 ; i++) { + if (m_actionlist[i].action == action) + return m_actionlist[i].string; + } - return 0; + return 0; } #ifdef DEBUG

@@ -531,29 +531,29 @@ // keytree. Starts with the

// rootlist //------------------------------ void Keys::showTree() { - for (unsigned int i=0; i<m_keylist.size(); i++) { - if (m_keylist[i]) { - cerr<<i<<" "; - showKeyTree(m_keylist[i]); - } else - cerr<<"Null @ "<<i<<endl; - } + for (unsigned int i=0; i<m_keylist.size(); i++) { + if (m_keylist[i]) { + cerr<<i<<" "; + showKeyTree(m_keylist[i]); + } else + cerr<<"Null @ "<<i<<endl; + } } //---------- showKeyTree -------- // Debug function to show t_key tree //------------------------------- void Keys::showKeyTree(t_key *key, unsigned int w) { - for (unsigned int i=0; i<w+1; i++) - cerr<<"-"; - if (!key->keylist.empty()) { - for (unsigned int i=0; i<key->keylist.size(); i++) { - cerr<<"( "<<(int)key->key<<" "<<(int)key->mod<<" )"; - showKeyTree(key->keylist[i], 4); - cerr<<endl; - } - } else - cerr<<"( "<<(int)key->key<<" "<<(int)key->mod<<" ) {"<<getActionStr(key->action)<<"}"<<endl; + for (unsigned int i=0; i<w+1; i++) + cerr<<"-"; + if (!key->keylist.empty()) { + for (unsigned int i=0; i<key->keylist.size(); i++) { + cerr<<"( "<<(int)key->key<<" "<<(int)key->mod<<" )"; + showKeyTree(key->keylist[i], 4); + cerr<<endl; + } + } else + cerr<<"( "<<(int)key->key<<" "<<(int)key->mod<<" ) {"<<getActionStr(key->action)<<"}"<<endl; } #endif //DEBUG

@@ -562,113 +562,113 @@ // Merges two chains and binds new keys

// Returns true on success else false. //--------------------------------------- bool Keys::mergeTree(t_key *newtree, t_key *basetree) { - if (basetree==0) { - unsigned int baselist_i=0; - for (; baselist_i<m_keylist.size(); baselist_i++) { - if (m_keylist[baselist_i]->mod == newtree->mod && - m_keylist[baselist_i]->key == newtree->key) { - if (newtree->keylist.size() && m_keylist[baselist_i]->action == LASTKEYGRAB) { - //assumes the newtree only have one branch - return mergeTree(newtree->keylist[0], m_keylist[baselist_i]); - } else - break; - } - } + if (basetree==0) { + unsigned int baselist_i=0; + for (; baselist_i<m_keylist.size(); baselist_i++) { + if (m_keylist[baselist_i]->mod == newtree->mod && + m_keylist[baselist_i]->key == newtree->key) { + if (newtree->keylist.size() && m_keylist[baselist_i]->action == LASTKEYGRAB) { + //assumes the newtree only have one branch + return mergeTree(newtree->keylist[0], m_keylist[baselist_i]); + } else + break; + } + } - if (baselist_i == m_keylist.size()) { - grabKey(newtree->key, newtree->mod); - m_keylist.push_back(new t_key(newtree)); - if (newtree->keylist.size()) - return mergeTree(newtree->keylist[0], m_keylist.back()); - return true; - } + if (baselist_i == m_keylist.size()) { + grabKey(newtree->key, newtree->mod); + m_keylist.push_back(new t_key(newtree)); + if (newtree->keylist.size()) + return mergeTree(newtree->keylist[0], m_keylist.back()); + return true; + } - } else { - unsigned int baselist_i = 0; - for (; baselist_i<basetree->keylist.size(); baselist_i++) { - if (basetree->keylist[baselist_i]->mod == newtree->mod && - basetree->keylist[baselist_i]->key == newtree->key) { - if (newtree->keylist.size()) { - //assumes the newtree only have on branch - return mergeTree(newtree->keylist[0], basetree->keylist[baselist_i]); - } else - return false; - } - } - //if it wasn't in the list grab the key and add it to the list - if (baselist_i==basetree->keylist.size()) { - grabKey(newtree->key, newtree->mod); - basetree->keylist.push_back(new t_key(newtree)); - if (newtree->keylist.size()) - return mergeTree(newtree->keylist[0], basetree->keylist.back()); - return true; - } - } + } else { + unsigned int baselist_i = 0; + for (; baselist_i<basetree->keylist.size(); baselist_i++) { + if (basetree->keylist[baselist_i]->mod == newtree->mod && + basetree->keylist[baselist_i]->key == newtree->key) { + if (newtree->keylist.size()) { + //assumes the newtree only have on branch + return mergeTree(newtree->keylist[0], basetree->keylist[baselist_i]); + } else + return false; + } + } + //if it wasn't in the list grab the key and add it to the list + if (baselist_i==basetree->keylist.size()) { + grabKey(newtree->key, newtree->mod); + basetree->keylist.push_back(new t_key(newtree)); + if (newtree->keylist.size()) + return mergeTree(newtree->keylist[0], basetree->keylist.back()); + return true; + } + } - return false; + return false; } Keys::t_key::t_key(unsigned int key_, unsigned int mod_, KeyAction action_) { - action = action_; - key = key_; - mod = mod_; - param = 0; + action = action_; + key = key_; + mod = mod_; + param = 0; } Keys::t_key::t_key(t_key *k) { - action = k->action; - key = k->key; - mod = k->mod; - execcommand = k->execcommand; - param = k-> param; + action = k->action; + key = k->key; + mod = k->mod; + execcommand = k->execcommand; + param = k-> param; } Keys::t_key::~t_key() { - while (!keylist.empty()) { - t_key *k = keylist.back(); - if (k != 0) { // make sure we don't have a bad key pointer - delete k; - keylist.pop_back(); - } - } + while (!keylist.empty()) { + t_key *k = keylist.back(); + if (k != 0) { // make sure we don't have a bad key pointer + delete k; + keylist.pop_back(); + } + } } void Keys::determineModmap() { - // mask to use for modifier - int mods[] = { - ShiftMask, - LockMask, - ControlMask, - Mod1Mask, - Mod2Mask, - Mod3Mask, - Mod4Mask, - Mod5Mask, - 0 - }; + // mask to use for modifier + int mods[] = { + ShiftMask, + LockMask, + ControlMask, + Mod1Mask, + Mod2Mask, + Mod3Mask, + Mod4Mask, + Mod5Mask, + 0 + }; - XModifierKeymap *map = XGetModifierMapping(m_display); - // find modifiers and set them - for (int i=0, realkey=0; i<8; ++i) { - for (int key=0; key<map->max_keypermod; ++key, ++realkey) { + XModifierKeymap *map = XGetModifierMapping(m_display); + // find modifiers and set them + for (int i=0, realkey=0; i<8; ++i) { + for (int key=0; key<map->max_keypermod; ++key, ++realkey) { - if (map->modifiermap[realkey] == 0) - continue; + if (map->modifiermap[realkey] == 0) + continue; - KeySym ks = XKeycodeToKeysym(m_display, map->modifiermap[realkey], 0); + KeySym ks = XKeycodeToKeysym(m_display, map->modifiermap[realkey], 0); - switch (ks) { - case XK_Caps_Lock: - m_capslock_mod = mods[i]; - break; - case XK_Scroll_Lock: - m_scrolllock_mod = mods[i]; - break; - case XK_Num_Lock: - m_numlock_mod = mods[i]; - break; - } - } - } - XFreeModifiermap(map); + switch (ks) { + case XK_Caps_Lock: + m_capslock_mod = mods[i]; + break; + case XK_Scroll_Lock: + m_scrolllock_mod = mods[i]; + break; + case XK_Num_Lock: + m_numlock_mod = mods[i]; + break; + } + } + } + XFreeModifiermap(map); }
M src/Keys.hhsrc/Keys.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Keys.hh,v 1.17 2002/11/27 22:07:42 fluxgen Exp $ +// $Id: Keys.hh,v 1.18 2002/12/01 13:41:57 rathnor Exp $ #ifndef KEYS_HH #define KEYS_HH

@@ -31,157 +31,157 @@

class Keys { public: - /** - Key actions - */ - enum KeyAction{ - ICONIFY=0, - RAISE, LOWER, - CLOSE, - ABORTKEYCHAIN, - WORKSPACE, - WORKSPACE1, WORKSPACE2, WORKSPACE3, WORKSPACE4, - WORKSPACE5, WORKSPACE6, WORKSPACE7, WORKSPACE8, - WORKSPACE9, WORKSPACE10, WORKSPACE11, WORKSPACE12, - SENDTOWORKSPACE, // Send window to a workspace - NEXTWORKSPACE, PREVWORKSPACE, - LEFTWORKSPACE, RIGHTWORKSPACE, - KILLWINDOW, NEXTWINDOW, PREVWINDOW, - NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT, - SHADE, MAXIMIZE, - STICK, // Make Sticky - EXECUTE, // Run command - VERTMAX, // Maximize vertical - HORIZMAX, // Maximize horizontal - NUDGERIGHT, NUDGELEFT,NUDGEUP, NUDGEDOWN, - BIGNUDGERIGHT, BIGNUDGELEFT, BIGNUDGEUP, BIGNUDGEDOWN, - HORIZINC, VERTINC, HORIZDEC, VERTDEC, - TOGGLEDECOR,// toggle visibility of decor (title, frame, handles) - TOGGLETAB, // toggle visibilty of tab - ROOTMENU, // pop up rootmenu - LASTKEYGRAB //mark end of keygrabbs - }; - /** - Constructor - @param display display connection - @param filename file to load, default none - */ - Keys(Display *display, const char *filename=0); - /// destructor - ~Keys(); - /** - Load configuration from file - @return true on success, else false - */ - bool load(const char *filename=0); - /** - Determine action from XKeyEvent - @return KeyAction value - */ - KeyAction getAction(XKeyEvent *ke); - /** - Reload configuration from filename - @return true on success, else false - */ - bool reconfigure(const char *filename); - /** - Get string value of the KeyAction enum value - @return string of action - */ - const char *getActionStr(KeyAction action); - /** - Get command to execute (key action EXECUTE) - @return string to command - */ - const std::string &getExecCommand() { return m_execcmdstring; } - /** - @return number of parameters - */ - int getParam() const { return m_param; } + /** + Key actions + */ + enum KeyAction{ + ICONIFY=0, + RAISE, LOWER, + CLOSE, + ABORTKEYCHAIN, + WORKSPACE, + WORKSPACE1, WORKSPACE2, WORKSPACE3, WORKSPACE4, + WORKSPACE5, WORKSPACE6, WORKSPACE7, WORKSPACE8, + WORKSPACE9, WORKSPACE10, WORKSPACE11, WORKSPACE12, + SENDTOWORKSPACE, // Send window to a workspace + NEXTWORKSPACE, PREVWORKSPACE, + LEFTWORKSPACE, RIGHTWORKSPACE, + KILLWINDOW, NEXTWINDOW, PREVWINDOW, + NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT, + SHADE, MAXIMIZE, + STICK, // Make Sticky + EXECUTE, // Run command + VERTMAX, // Maximize vertical + HORIZMAX, // Maximize horizontal + NUDGERIGHT, NUDGELEFT,NUDGEUP, NUDGEDOWN, + BIGNUDGERIGHT, BIGNUDGELEFT, BIGNUDGEUP, BIGNUDGEDOWN, + HORIZINC, VERTINC, HORIZDEC, VERTDEC, + TOGGLEDECOR,// toggle visibility of decor (title, frame, handles) + TOGGLETAB, // toggle visibilty of tab + ROOTMENU, // pop up rootmenu + LASTKEYGRAB //mark end of keygrabbs + }; + /** + Constructor + @param display display connection + @param filename file to load, default none + */ + Keys(Display *display, const char *filename=0); + /// destructor + ~Keys(); + /** + Load configuration from file + @return true on success, else false + */ + bool load(const char *filename=0); + /** + Determine action from XKeyEvent + @return KeyAction value + */ + KeyAction getAction(XKeyEvent *ke); + /** + Reload configuration from filename + @return true on success, else false + */ + bool reconfigure(const char *filename); + /** + Get string value of the KeyAction enum value + @return string of action + */ + const char *getActionStr(KeyAction action); + /** + Get command to execute (key action EXECUTE) + @return string to command + */ + const std::string &getExecCommand() { return m_execcmdstring; } + /** + @return number of parameters + */ + int getParam() const { return m_param; } private: - void deleteTree(); - void ungrabKeys(); - void bindKey(unsigned int key, unsigned int mod); - /** - @param modstr modifier string (i.e Mod4, Mod5) - @return modifier number that match modstr - */ - unsigned int getModifier(const char *modstr); - /** - @param keystr a key string (i.e F1, Enter) - @return key number that match keystr - */ - unsigned int getKey(const char *keystr); - /** - grab a key - @param key the key - @param mod the modifier - */ - void grabKey(unsigned int key, unsigned int mod); - std::string filename; + void deleteTree(); + void ungrabKeys(); + void bindKey(unsigned int key, unsigned int mod); + /** + @param modstr modifier string (i.e Mod4, Mod5) + @return modifier number that match modstr + */ + unsigned int getModifier(const char *modstr); + /** + @param keystr a key string (i.e F1, Enter) + @return key number that match keystr + */ + unsigned int getKey(const char *keystr); + /** + grab a key + @param key the key + @param mod the modifier + */ + void grabKey(unsigned int key, unsigned int mod); + std::string filename; - class t_key { - public: - t_key(unsigned int key, unsigned int mod, KeyAction action_ = Keys::LASTKEYGRAB); - t_key(t_key *k); - ~t_key(); + class t_key { + public: + t_key(unsigned int key, unsigned int mod, KeyAction action_ = Keys::LASTKEYGRAB); + t_key(t_key *k); + ~t_key(); - inline t_key *find(unsigned int key_, unsigned int mod_) { - for (unsigned int i=0; i<keylist.size(); i++) { - if (keylist[i]->key == key_ && keylist[i]->mod == mod_) - return keylist[i]; - } - return 0; - } - inline t_key *find(XKeyEvent *ke) { - for (unsigned int i=0; i<keylist.size(); i++) { - if (keylist[i]->key == ke->keycode && keylist[i]->mod == ke->state) - return keylist[i]; - } - return 0; - } + inline t_key *find(unsigned int key_, unsigned int mod_) { + for (unsigned int i=0; i<keylist.size(); i++) { + if (keylist[i]->key == key_ && keylist[i]->mod == mod_) + return keylist[i]; + } + return 0; + } + inline t_key *find(XKeyEvent *ke) { + for (unsigned int i=0; i<keylist.size(); i++) { + if (keylist[i]->key == ke->keycode && keylist[i]->mod == ke->state) + return keylist[i]; + } + return 0; + } - inline bool operator == (XKeyEvent *ke) { - return (mod == ke->state && key == ke->keycode); - } + inline bool operator == (XKeyEvent *ke) { + return (mod == ke->state && key == ke->keycode); + } - KeyAction action; - unsigned int key; - unsigned int mod; - std::vector<t_key *> keylist; - std::string execcommand; + KeyAction action; + unsigned int key; + unsigned int mod; + std::vector<t_key *> keylist; + std::string execcommand; int param; // parameter to comands - }; - /** - merge two linked list - @return true on success, else false - */ - bool mergeTree(t_key *newtree, t_key *basetree=0); + }; + /** + merge two linked list + @return true on success, else false + */ + bool mergeTree(t_key *newtree, t_key *basetree=0); #ifdef DEBUG - /// debug function - void showTree(); - /// debug function - void showKeyTree(t_key *key, unsigned int w=0); + /// debug function + void showTree(); + /// debug function + void showKeyTree(t_key *key, unsigned int w=0); #endif //DEBUG - /// determine key modifier maps for caps-, num- and scrolllock - void determineModmap(); + /// determine key modifier maps for caps-, num- and scrolllock + void determineModmap(); - struct t_actionstr{ - const char *string; - KeyAction action; - }; + struct t_actionstr{ + const char *string; + KeyAction action; + }; - int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers + int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers - static t_actionstr m_actionlist[]; + static t_actionstr m_actionlist[]; - std::vector<t_key *> m_keylist; - t_key *m_abortkey; ///< abortkey for keygrabbing chain - std::string m_execcmdstring; ///< copy of the execcommandstring + std::vector<t_key *> m_keylist; + t_key *m_abortkey; ///< abortkey for keygrabbing chain + std::string m_execcmdstring; ///< copy of the execcommandstring int m_param; ///< copy of the param argument - Display *m_display; ///< display connection + Display *m_display; ///< display connection }; #endif // _KEYS_HH_
M src/Netizen.ccsrc/Netizen.cc

@@ -25,84 +25,84 @@ #include "Screen.hh"

#include "FbAtoms.hh" Netizen::Netizen(const BScreen * const scr, Window win): -m_screen(scr), -m_display(BaseDisplay::getXDisplay()), -window(win) { - window = win; + m_screen(scr), + m_display(BaseDisplay::getXDisplay()), + window(win) { + window = win; - event.type = ClientMessage; - event.xclient.message_type = FbAtoms::instance()->getFluxboxStructureMessagesAtom(); - event.xclient.display = m_display; - event.xclient.window = window; - event.xclient.format = 32; - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyStartupAtom(); - event.xclient.data.l[1] = event.xclient.data.l[2] = + event.type = ClientMessage; + event.xclient.message_type = FbAtoms::instance()->getFluxboxStructureMessagesAtom(); + event.xclient.display = m_display; + event.xclient.window = window; + event.xclient.format = 32; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyStartupAtom(); + event.xclient.data.l[1] = event.xclient.data.l[2] = event.xclient.data.l[3] = event.xclient.data.l[4] = 0l; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendWorkspaceCount() { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWorkspaceCountAtom(); - event.xclient.data.l[1] = m_screen->getCount(); + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWorkspaceCountAtom(); + event.xclient.data.l[1] = m_screen->getCount(); - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendCurrentWorkspace() { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyCurrentWorkspaceAtom(); - event.xclient.data.l[1] = m_screen->getCurrentWorkspaceID(); + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyCurrentWorkspaceAtom(); + event.xclient.data.l[1] = m_screen->getCurrentWorkspaceID(); - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendWindowFocus(Window w) { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowFocusAtom(); - event.xclient.data.l[1] = w; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowFocusAtom(); + event.xclient.data.l[1] = w; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendWindowAdd(Window w, unsigned long p) { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowAddAtom(); - event.xclient.data.l[1] = w; - event.xclient.data.l[2] = p; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowAddAtom(); + event.xclient.data.l[1] = w; + event.xclient.data.l[2] = p; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); - event.xclient.data.l[2] = 0l; + event.xclient.data.l[2] = 0l; } void Netizen::sendWindowDel(Window w) { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowDelAtom(); - event.xclient.data.l[1] = w; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowDelAtom(); + event.xclient.data.l[1] = w; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendWindowRaise(Window w) { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowRaiseAtom(); - event.xclient.data.l[1] = w; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowRaiseAtom(); + event.xclient.data.l[1] = w; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendWindowLower(Window w) { - event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowLowerAtom(); - event.xclient.data.l[1] = w; + event.xclient.data.l[0] = FbAtoms::instance()->getFluxboxNotifyWindowLowerAtom(); + event.xclient.data.l[1] = w; - XSendEvent(m_display, window, False, NoEventMask, &event); + XSendEvent(m_display, window, False, NoEventMask, &event); } void Netizen::sendConfigNotify(XEvent *e) { - XSendEvent(m_display, window, False, StructureNotifyMask, e); + XSendEvent(m_display, window, False, StructureNotifyMask, e); }
M src/Netizen.hhsrc/Netizen.hh

@@ -30,25 +30,25 @@ class BScreen;

class Netizen { public: - Netizen(const BScreen * const scr, Window w); + Netizen(const BScreen * const scr, Window w); - inline Window getWindowID() const { return window; } + inline Window getWindowID() const { return window; } - void sendWorkspaceCount(); - void sendCurrentWorkspace(); + void sendWorkspaceCount(); + void sendCurrentWorkspace(); - void sendWindowFocus(Window w); - void sendWindowAdd(Window w, unsigned long p); - void sendWindowDel(Window w); - void sendWindowRaise(Window w); - void sendWindowLower(Window w); + void sendWindowFocus(Window w); + void sendWindowAdd(Window w, unsigned long p); + void sendWindowDel(Window w); + void sendWindowRaise(Window w); + void sendWindowLower(Window w); - void sendConfigNotify(XEvent *xe); + void sendConfigNotify(XEvent *xe); private: - const BScreen * const m_screen; - Display *m_display; ///< display connection - Window window; - XEvent event; + const BScreen * const m_screen; + Display *m_display; ///< display connection + Window window; + XEvent event; };
M src/Observer.ccsrc/Observer.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Observer.cc,v 1.1 2002/09/07 20:30:45 fluxgen Exp $ +// $Id: Observer.cc,v 1.2 2002/12/01 13:41:58 rathnor Exp $ #include "Observer.hh" #include "Subject.hh"

@@ -27,7 +27,7 @@

namespace FbTk { Observer::~Observer() { - Subject::removeObserver(this); // make sure no subject has this observer attached + Subject::removeObserver(this); // make sure no subject has this observer attached } };
M src/Observer.hhsrc/Observer.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Observer.hh,v 1.1 2002/09/07 20:30:45 fluxgen Exp $ +// $Id: Observer.hh,v 1.2 2002/12/01 13:41:58 rathnor Exp $ #ifndef FBTK_OBSERVER_HH #define FBTK_OBSERVER_HH

@@ -30,8 +30,8 @@ class Subject;

class Observer { public: - virtual ~Observer(); - virtual void update(Subject *changedSubj) = 0; + virtual ~Observer(); + virtual void update(Subject *changedSubj) = 0; }; }; // end namespace FBTK
M src/Resource.ccsrc/Resource.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Resource.cc,v 1.3 2002/07/20 09:51:26 fluxgen Exp $ +// $Id: Resource.cc,v 1.4 2002/12/01 13:41:58 rathnor Exp $ #include "Resource.hh" #include "XrmDatabaseHelper.hh"

@@ -37,35 +37,35 @@ // returns true on success

// else false //------------------------- bool ResourceManager::load(const char *filename) { - assert(filename); + assert(filename); - ensureXrmIsInitialize(); + ensureXrmIsInitialize(); - XrmDatabaseHelper database; - database = XrmGetFileDatabase(filename); - if (database==0) - return false; + XrmDatabaseHelper database; + database = XrmGetFileDatabase(filename); + if (database==0) + return false; - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - //get list and go throu all the resources and load them - ResourceList::iterator i = m_resourcelist.begin(); - ResourceList::iterator i_end = m_resourcelist.end(); - for (; i != i_end; ++i) { + //get list and go throu all the resources and load them + ResourceList::iterator i = m_resourcelist.begin(); + ResourceList::iterator i_end = m_resourcelist.end(); + for (; i != i_end; ++i) { - Resource_base *resource = *i; - if (XrmGetResource(*database, resource->name().c_str(), - resource->altName().c_str(), &value_type, &value)) - resource->setFromString(value.addr); - else { - cerr<<"Failed to read: "<<resource->name()<<endl; - cerr<<"Setting default value"<<endl; - resource->setDefaultValue(); - } - } + Resource_base *resource = *i; + if (XrmGetResource(*database, resource->name().c_str(), + resource->altName().c_str(), &value_type, &value)) + resource->setFromString(value.addr); + else { + cerr<<"Failed to read: "<<resource->name()<<endl; + cerr<<"Setting default value"<<endl; + resource->setDefaultValue(); + } + } - return true; + return true; } //-------------- save -----------------

@@ -75,45 +75,45 @@ // else negative value representing

// the error //------------------------------------- bool ResourceManager::save(const char *filename, const char *mergefilename) { - assert(filename); + assert(filename); - ensureXrmIsInitialize(); + ensureXrmIsInitialize(); - XrmDatabaseHelper database; + XrmDatabaseHelper database; - string rc_string; - ResourceList::iterator i = m_resourcelist.begin(); - ResourceList::iterator i_end = m_resourcelist.end(); - //write all resources to database - for (; i != i_end; ++i) { - Resource_base *resource = *i; - rc_string = resource->name() + string(": ") + resource->getString(); - XrmPutLineResource(&*database, rc_string.c_str()); - } + string rc_string; + ResourceList::iterator i = m_resourcelist.begin(); + ResourceList::iterator i_end = m_resourcelist.end(); + //write all resources to database + for (; i != i_end; ++i) { + Resource_base *resource = *i; + rc_string = resource->name() + string(": ") + resource->getString(); + XrmPutLineResource(&*database, rc_string.c_str()); + } - if (database==0) - return false; + if (database==0) + return false; - //check if we want to merge a database - if (mergefilename) { - XrmDatabaseHelper olddatabase(mergefilename); - if (olddatabase == 0) // did we load the file? - return false; + //check if we want to merge a database + if (mergefilename) { + XrmDatabaseHelper olddatabase(mergefilename); + if (olddatabase == 0) // did we load the file? + return false; - XrmMergeDatabases(*database, &*olddatabase); // merge databases - XrmPutFileDatabase(*olddatabase, filename); // save database to file + XrmMergeDatabases(*database, &*olddatabase); // merge databases + XrmPutFileDatabase(*olddatabase, filename); // save database to file - *database = 0; // don't try to destroy the database - } else // save database to file - XrmPutFileDatabase(*database, filename); + *database = 0; // don't try to destroy the database + } else // save database to file + XrmPutFileDatabase(*database, filename); - return true; + return true; } void ResourceManager::ensureXrmIsInitialize() { - if (!m_init) { - XrmInitialize(); - m_init = true; - } + if (!m_init) { + XrmInitialize(); + m_init = true; + } }
M src/Resource.hhsrc/Resource.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Resource.hh,v 1.8 2002/11/26 16:37:18 fluxgen Exp $ +// $Id: Resource.hh,v 1.9 2002/12/01 13:41:58 rathnor Exp $ #ifndef RESOURCE_HH #define RESOURCE_HH

@@ -33,27 +33,27 @@ */

class Resource_base:private FbTk::NotCopyable { public: - virtual ~Resource_base() { }; + virtual ~Resource_base() { }; - /// set from string value - virtual void setFromString(char const *strval) = 0; - /// set default value - virtual void setDefaultValue() = 0; - /// get string value - virtual std::string getString() = 0; - /// get alternative name of this resource - inline const std::string& altName() const { return m_altname; } - /// get name of this resource - inline const std::string& name() const { return m_name; } + /// set from string value + virtual void setFromString(char const *strval) = 0; + /// set default value + virtual void setDefaultValue() = 0; + /// get string value + virtual std::string getString() = 0; + /// get alternative name of this resource + inline const std::string& altName() const { return m_altname; } + /// get name of this resource + inline const std::string& name() const { return m_name; } protected: - Resource_base(const std::string &name, const std::string &altname): + Resource_base(const std::string &name, const std::string &altname): m_name(name), m_altname(altname) { } private: - std::string m_name; ///< name of this resource - std::string m_altname; ///< alternative name + std::string m_name; ///< name of this resource + std::string m_altname; ///< alternative name }; class ResourceManager;

@@ -65,68 +65,68 @@ template <typename T>

class Resource:public Resource_base { public: - Resource(ResourceManager &rm, T val, - const std::string &name, const std::string &altname): + Resource(ResourceManager &rm, T val, + const std::string &name, const std::string &altname): Resource_base(name, altname), m_value(val), m_defaultval(val), m_rm(rm) { - m_rm.addResource(*this); // add this to resource handler + m_rm.addResource(*this); // add this to resource handler } - virtual ~Resource() { - m_rm.removeResource(*this); // remove this from resource handler - } + virtual ~Resource() { + m_rm.removeResource(*this); // remove this from resource handler + } - inline void setDefaultValue() { m_value = m_defaultval; } - void setFromString(const char *strval); - inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;} + inline void setDefaultValue() { m_value = m_defaultval; } + void setFromString(const char *strval); + inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;} - std::string getString(); - inline T& operator*() { return m_value; } - inline const T& operator*() const { return m_value; } - inline T *operator->() { return &m_value; } - inline const T *operator->() const { return &m_value; } + std::string getString(); + inline T& operator*() { return m_value; } + inline const T& operator*() const { return m_value; } + inline T *operator->() { return &m_value; } + inline const T *operator->() const { return &m_value; } private: - T m_value, m_defaultval; - ResourceManager &m_rm; + T m_value, m_defaultval; + ResourceManager &m_rm; }; class ResourceManager { public: - typedef std::list<Resource_base *> ResourceList; + typedef std::list<Resource_base *> ResourceList; - ResourceManager() { } - virtual ~ResourceManager() {} - /** - load all resouces registered to this class - */ - virtual bool load(const char *filename); - /** - save all resouces registered to this class - */ - virtual bool save(const char *filename, const char *mergefilename=0); - /** - add resource to list - */ - template <class T> - void addResource(Resource<T> &r) { - m_resourcelist.push_back(&r); - m_resourcelist.unique(); - } - /** - Remove a specific resource - */ - template <class T> - void removeResource(Resource<T> &r) { - m_resourcelist.remove(&r); - } + ResourceManager() { } + virtual ~ResourceManager() {} + /** + load all resouces registered to this class + */ + virtual bool load(const char *filename); + /** + save all resouces registered to this class + */ + virtual bool save(const char *filename, const char *mergefilename=0); + /** + add resource to list + */ + template <class T> + void addResource(Resource<T> &r) { + m_resourcelist.push_back(&r); + m_resourcelist.unique(); + } + /** + Remove a specific resource + */ + template <class T> + void removeResource(Resource<T> &r) { + m_resourcelist.remove(&r); + } protected: - static inline void ensureXrmIsInitialize(); + static inline void ensureXrmIsInitialize(); private: - static bool m_init; - ResourceList m_resourcelist; + static bool m_init; + ResourceList m_resourcelist; }; #endif //_RESOURCE_HH_
M src/Rootmenu.ccsrc/Rootmenu.cc

@@ -53,8 +53,8 @@ #endif // MAXPATHLEN

Rootmenu::Rootmenu(BScreen *scrn) -: Basemenu(scrn), - auto_group_window(0) + : Basemenu(scrn), + auto_group_window(0) { }

@@ -62,97 +62,97 @@

void Rootmenu::itemSelected(int button, unsigned int index) { - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - if (button == 1) { - BasemenuItem *item = find(index); + if (button == 1) { + BasemenuItem *item = find(index); - if (item->function()) { - switch (item->function()) { - case BScreen::EXECUTE: - if (item->exec().size()) { + if (item->function()) { + switch (item->function()) { + case BScreen::EXECUTE: + if (item->exec().size()) { #ifndef __EMX__ - char displaystring[MAXPATHLEN]; - sprintf(displaystring, "DISPLAY=%s", - DisplayString(screen()->getBaseDisplay()->getXDisplay())); - sprintf(displaystring + strlen(displaystring) - 1, "%d", - screen()->getScreenNumber()); + char displaystring[MAXPATHLEN]; + sprintf(displaystring, "DISPLAY=%s", + DisplayString(screen()->getBaseDisplay()->getXDisplay())); + sprintf(displaystring + strlen(displaystring) - 1, "%d", + screen()->getScreenNumber()); - screen()->setAutoGroupWindow(useAutoGroupWindow()); + screen()->setAutoGroupWindow(useAutoGroupWindow()); - bexec(item->exec().c_str(), displaystring); + bexec(item->exec().c_str(), displaystring); #else // __EMX__ - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); + spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); #endif // !__EMX__ - } - break; + } + break; - case BScreen::RESTART: - fluxbox->restart(); - break; + case BScreen::RESTART: + fluxbox->restart(); + break; - case BScreen::RESTARTOTHER: - if (item->exec().size()) - fluxbox->restart(item->exec().c_str()); - break; + case BScreen::RESTARTOTHER: + if (item->exec().size()) + fluxbox->restart(item->exec().c_str()); + break; - case BScreen::EXIT: - fluxbox->shutdown(); - break; + case BScreen::EXIT: + fluxbox->shutdown(); + break; - case BScreen::SETSTYLE: - if (item->exec().size()) { - fluxbox->saveStyleFilename(item->exec().c_str()); - fluxbox->reconfigureTabs(); - } - fluxbox->reconfigure(); - fluxbox->save_rc(); - break; - case BScreen::RECONFIGURE: - fluxbox->reconfigure(); - return; - } - if (! (screen()->getRootmenu()->isTorn() || isTorn()) && - item->function() != BScreen::RECONFIGURE && - item->function() != BScreen::SETSTYLE) - hide(); - } - } + case BScreen::SETSTYLE: + if (item->exec().size()) { + fluxbox->saveStyleFilename(item->exec().c_str()); + fluxbox->reconfigureTabs(); + } + fluxbox->reconfigure(); + fluxbox->save_rc(); + break; + case BScreen::RECONFIGURE: + fluxbox->reconfigure(); + return; + } + if (! (screen()->getRootmenu()->isTorn() || isTorn()) && + item->function() != BScreen::RECONFIGURE && + item->function() != BScreen::SETSTYLE) + hide(); + } + } } void Rootmenu::setAutoGroupWindow(Window window) { - auto_group_window = window; + auto_group_window = window; } void Rootmenu::show() { - Basemenu::show(); - // make sure it's full visible + Basemenu::show(); + // make sure it's full visible - int newx = x(), newy = y(); - if (x() < 0) - newx = 0; - else if (x() + width() > screen()->getWidth()) - newx = screen()->getWidth() - width(); - if (y() < 0) - newy = 0; - else if (y() + height() > screen()->getHeight()) - newy = screen()->getHeight() - height(); + int newx = x(), newy = y(); + if (x() < 0) + newx = 0; + else if (x() + width() > screen()->getWidth()) + newx = screen()->getWidth() - width(); + if (y() < 0) + newy = 0; + else if (y() + height() > screen()->getHeight()) + newy = screen()->getHeight() - height(); - move(newx, newy); + move(newx, newy); } Window Rootmenu::useAutoGroupWindow() { - // Return and clear the auto-grouping state. - Window w = auto_group_window; - if (w) - auto_group_window = 0; // clear it immediately - // If not set check the parent and the parent's parent, ... - else if (parent()) { - // TODO: dynamic_cast throws std::bad_cast! - Rootmenu *p = dynamic_cast<Rootmenu*>(parent()); - w = p->useAutoGroupWindow(); - } - return w; + // Return and clear the auto-grouping state. + Window w = auto_group_window; + if (w) + auto_group_window = 0; // clear it immediately + // If not set check the parent and the parent's parent, ... + else if (parent()) { + // TODO: dynamic_cast throws std::bad_cast! + Rootmenu *p = dynamic_cast<Rootmenu*>(parent()); + w = p->useAutoGroupWindow(); + } + return w; }
M src/Rootmenu.hhsrc/Rootmenu.hh

@@ -29,16 +29,16 @@ #include "Basemenu.hh"

class Rootmenu: public Basemenu { public: - explicit Rootmenu(BScreen *scr); - void setAutoGroupWindow(Window window); - void show(); + explicit Rootmenu(BScreen *scr); + void setAutoGroupWindow(Window window); + void show(); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); private: - Window useAutoGroupWindow(); - Window auto_group_window; + Window useAutoGroupWindow(); + Window auto_group_window; };
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Screen.cc,v 1.88 2002/11/30 20:55:23 fluxgen Exp $ +// $Id: Screen.cc,v 1.89 2002/12/01 13:41:58 rathnor Exp $ #include "Screen.hh"

@@ -110,21 +110,21 @@ static bool running = true;

namespace { int anotherWMRunning(Display *display, XErrorEvent *) { - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning, - "BScreen::BScreen: an error occured while querying the X server.\n" - " another window manager already running on display %s.\n"), - DisplayString(display)); + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning, + "BScreen::BScreen: an error occured while querying the X server.\n" + " another window manager already running on display %s.\n"), + DisplayString(display)); - running = false; + running = false; - return(-1); + return(-1); } int dcmp(const void *one, const void *two) { - return (strcmp((*(char **) one), (*(char **) two))); + return (strcmp((*(char **) one), (*(char **) two))); } };

@@ -133,1574 +133,1574 @@ //---------- resource manipulators ---------

template<> void Resource<Tab::Alignment>:: setFromString(const char *strval) { - m_value = Tab::getTabAlignmentNum(strval); + m_value = Tab::getTabAlignmentNum(strval); } template<> void Resource<Tab::Placement>:: setFromString(const char *strval) { - m_value = Tab::getTabPlacementNum(strval); + m_value = Tab::getTabPlacementNum(strval); } template<> void Resource<Toolbar::Placement>:: setFromString(const char *strval) { - if (strcasecmp(strval, "TopLeft")==0) - m_value = Toolbar::TOPLEFT; - else if (strcasecmp(strval, "BottomLeft")==0) - m_value = Toolbar::BOTTOMLEFT; - else if (strcasecmp(strval, "TopCenter")==0) - m_value = Toolbar::TOPCENTER; - else if (strcasecmp(strval, "BottomCenter")==0) - m_value = Toolbar::BOTTOMCENTER; - else if (strcasecmp(strval, "TopRight")==0) - m_value = Toolbar::TOPRIGHT; - else if (strcasecmp(strval, "BottomRight")==0) - m_value = Toolbar::BOTTOMRIGHT; - else - setDefaultValue(); + if (strcasecmp(strval, "TopLeft")==0) + m_value = Toolbar::TOPLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Toolbar::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Toolbar::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Toolbar::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Toolbar::TOPRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Toolbar::BOTTOMRIGHT; + else + setDefaultValue(); } //--------- resource accessors -------------- template<> string Resource<Tab::Alignment>:: getString() { - return Tab::getTabAlignmentString(m_value); + return Tab::getTabAlignmentString(m_value); } template<> string Resource<Tab::Placement>:: getString() { - return Tab::getTabPlacementString(m_value); + return Tab::getTabPlacementString(m_value); } template<> string Resource<Toolbar::Placement>:: getString() { - switch (m_value) { - case Toolbar::TOPLEFT: - return string("TopLeft"); - break; - case Toolbar::BOTTOMLEFT: - return string("BottomLeft"); - break; - case Toolbar::TOPCENTER: - return string("TopCenter"); - break; - case Toolbar::BOTTOMCENTER: - return string("BottomCenter"); - break; - case Toolbar::TOPRIGHT: - return string("TopRight"); - break; - case Toolbar::BOTTOMRIGHT: - return string("BottomRight"); - break; - } - //default string - return string("BottomCenter"); + switch (m_value) { + case Toolbar::TOPLEFT: + return string("TopLeft"); + break; + case Toolbar::BOTTOMLEFT: + return string("BottomLeft"); + break; + case Toolbar::TOPCENTER: + return string("TopCenter"); + break; + case Toolbar::BOTTOMCENTER: + return string("BottomCenter"); + break; + case Toolbar::TOPRIGHT: + return string("TopRight"); + break; + case Toolbar::BOTTOMRIGHT: + return string("BottomRight"); + break; + } + //default string + return string("BottomCenter"); } BScreen::ScreenResource::ScreenResource(ResourceManager &rm, - const std::string &scrname, const std::string &altscrname): -toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"), -toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"), -image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), -opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), -full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), -max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"), -tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"), -sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), -workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), -desktop_wheeling(rm, true, scrname+".desktopwheeling", altscrname+".DesktopWheeling"), -show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), -focus_last(rm, true, scrname+".focusLastWindow", altscrname+".FocusLastWindow"), -focus_new(rm, true, scrname+".focusNewWindows", altscrname+".FocusNewWindows"), -antialias(rm, false, scrname+".antialias", altscrname+".Antialias"), -rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), -workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), -toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"), -edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), -tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"), -tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), -tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), -tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), -toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), -toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") + const std::string &scrname, const std::string &altscrname): + toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"), + toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"), + image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"), + opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"), + full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"), + max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"), + tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"), + sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"), + workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"), + desktop_wheeling(rm, true, scrname+".desktopwheeling", altscrname+".DesktopWheeling"), + show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"), + focus_last(rm, true, scrname+".focusLastWindow", altscrname+".FocusLastWindow"), + focus_new(rm, true, scrname+".focusNewWindows", altscrname+".FocusNewWindows"), + antialias(rm, false, scrname+".antialias", altscrname+".Antialias"), + rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), + workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), + toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"), + edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), + tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"), + tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"), + tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), + tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), + toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), + toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") { }; BScreen::BScreen(ResourceManager &rm, - const string &screenname, const string &altscreenname, - int scrn) : ScreenInfo(scrn), -m_clientlist_sig(*this), // client signal -m_workspacecount_sig(*this), // workspace count signal -m_workspacenames_sig(*this), // workspace names signal -m_currentworkspace_sig(*this), // current workspace signal -theme(0), -resource(rm, screenname, altscreenname) + const string &screenname, const string &altscreenname, + int scrn) : ScreenInfo(scrn), + m_clientlist_sig(*this), // client signal + m_workspacecount_sig(*this), // workspace count signal + m_workspacenames_sig(*this), // workspace names signal + m_currentworkspace_sig(*this), // current workspace signal + theme(0), + resource(rm, screenname, altscreenname) { - Display *disp = BaseDisplay::getXDisplay(); + Display *disp = BaseDisplay::getXDisplay(); - event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | - SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; + event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | + SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; - XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); - XSelectInput(disp, getRootWindow(), event_mask); - XSync(disp, False); - XSetErrorHandler((XErrorHandler) old); + XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); + XSelectInput(disp, getRootWindow(), event_mask); + XSync(disp, False); + XSetErrorHandler((XErrorHandler) old); - managed = running; - if (! managed) - return; + managed = running; + if (! managed) + return; - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenManagingScreen, - "BScreen::BScreen: managing screen %d " - "using visual 0x%lx, depth %d\n"), - getScreenNumber(), XVisualIDFromVisual(getVisual()), - getDepth()); + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenManagingScreen, + "BScreen::BScreen: managing screen %d " + "using visual 0x%lx, depth %d\n"), + getScreenNumber(), XVisualIDFromVisual(getVisual()), + getDepth()); - rootmenu = 0; - Fluxbox * const fluxbox = Fluxbox::instance(); + rootmenu = 0; + Fluxbox * const fluxbox = Fluxbox::instance(); #ifdef HAVE_GETPID - pid_t bpid = getpid(); + pid_t bpid = getpid(); - XChangeProperty(disp, getRootWindow(), - Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL, - sizeof(pid_t) * 8, PropModeReplace, - (unsigned char *) &bpid, 1); + XChangeProperty(disp, getRootWindow(), + Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL, + sizeof(pid_t) * 8, PropModeReplace, + (unsigned char *) &bpid, 1); #endif // HAVE_GETPID - XDefineCursor(disp, getRootWindow(), fluxbox->getSessionCursor()); + XDefineCursor(disp, getRootWindow(), fluxbox->getSessionCursor()); - image_control = - new BImageControl(scrn, true, fluxbox->colorsPerChannel(), - fluxbox->getCacheLife(), fluxbox->getCacheMax()); - image_control->installRootColormap(); - root_colormap_installed = true; + image_control = + new BImageControl(scrn, true, fluxbox->colorsPerChannel(), + fluxbox->getCacheLife(), fluxbox->getCacheMax()); + image_control->installRootColormap(); + root_colormap_installed = true; - fluxbox->load_rc(this); + fluxbox->load_rc(this); - image_control->setDither(*resource.image_dither); - theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), - fluxbox->getStyleFilename(), getRootCommand().c_str()); + image_control->setDither(*resource.image_dither); + theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), + fluxbox->getStyleFilename(), getRootCommand().c_str()); - theme->reconfigure(*resource.antialias); - // special case for tab rotated - if (*resource.tab_rotate_vertical && - ( *resource.tab_placement == Tab::PLEFT || *resource.tab_placement == Tab::PRIGHT)) { - theme->getWindowStyle().tab.font.rotate(90); - } else { - theme->getWindowStyle().tab.font.rotate(0); - } + theme->reconfigure(*resource.antialias); + // special case for tab rotated + if (*resource.tab_rotate_vertical && + ( *resource.tab_placement == Tab::PLEFT || *resource.tab_placement == Tab::PRIGHT)) { + theme->getWindowStyle().tab.font.rotate(90); + } else { + theme->getWindowStyle().tab.font.rotate(0); + } - const char *s = i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenPositionLength, - "W: 0000 x H: 0000"); // W is wide! + const char *s = i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenPositionLength, + "W: 0000 x H: 0000"); // W is wide! - int l = strlen(s); + int l = strlen(s); - geom_h = theme->getWindowStyle().font.height(); - geom_w = theme->getWindowStyle().font.textWidth(s, l); + geom_h = theme->getWindowStyle().font.height(); + geom_w = theme->getWindowStyle().font.textWidth(s, l); - geom_w += getBevelWidth()*2; - geom_h += getBevelWidth()*2; + geom_w += getBevelWidth()*2; + geom_h += getBevelWidth()*2; - XSetWindowAttributes attrib; - unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder; - attrib.border_pixel = getBorderColor()->pixel(); - attrib.colormap = colormap(); - attrib.save_under = true; + XSetWindowAttributes attrib; + unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder; + attrib.border_pixel = getBorderColor()->pixel(); + attrib.colormap = colormap(); + attrib.save_under = true; - geom_window = - XCreateWindow(disp, getRootWindow(), - 0, 0, geom_w, geom_h, theme->getBorderWidth(), getDepth(), - InputOutput, getVisual(), mask, &attrib); - geom_visible = false; + geom_window = + XCreateWindow(disp, getRootWindow(), + 0, 0, geom_w, geom_h, theme->getBorderWidth(), getDepth(), + InputOutput, getVisual(), mask, &attrib); + geom_visible = false; - if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) { - if (theme->getWindowStyle().t_focus.type() == - (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - geom_pixmap = None; - XSetWindowBackground(disp, geom_window, + if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) { + if (theme->getWindowStyle().t_focus.type() == + (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + geom_pixmap = None; + XSetWindowBackground(disp, geom_window, theme->getWindowStyle().t_focus.color().pixel()); - } else { - geom_pixmap = image_control->renderImage(geom_w, geom_h, - theme->getWindowStyle().t_focus); - XSetWindowBackgroundPixmap(disp, geom_window, geom_pixmap); - } - } else { - if (theme->getWindowStyle().l_focus.type() == - (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - geom_pixmap = None; - XSetWindowBackground(disp, geom_window, + } else { + geom_pixmap = image_control->renderImage(geom_w, geom_h, + theme->getWindowStyle().t_focus); + XSetWindowBackgroundPixmap(disp, geom_window, geom_pixmap); + } + } else { + if (theme->getWindowStyle().l_focus.type() == + (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + geom_pixmap = None; + XSetWindowBackground(disp, geom_window, theme->getWindowStyle().l_focus.color().pixel()); - } else { - geom_pixmap = image_control->renderImage(geom_w, geom_h, - theme->getWindowStyle().l_focus); - XSetWindowBackgroundPixmap(disp, geom_window, geom_pixmap); - } - } + } else { + geom_pixmap = image_control->renderImage(geom_w, geom_h, + theme->getWindowStyle().l_focus); + XSetWindowBackgroundPixmap(disp, geom_window, geom_pixmap); + } + } - workspacemenu = new Workspacemenu(this); - m_iconmenu = new Iconmenu(this); - configmenu = new Configmenu(this); + workspacemenu = new Workspacemenu(this); + m_iconmenu = new Iconmenu(this); + configmenu = new Configmenu(this); - Workspace *wkspc = (Workspace *) 0; - if (*resource.workspaces != 0) { - for (int i = 0; i < *resource.workspaces; ++i) { - wkspc = new Workspace(this, workspacesList.size()); - workspacesList.push_back(wkspc); - workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); - } - } else { - wkspc = new Workspace(this, workspacesList.size()); - workspacesList.push_back(wkspc); - workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); - } + Workspace *wkspc = (Workspace *) 0; + if (*resource.workspaces != 0) { + for (int i = 0; i < *resource.workspaces; ++i) { + wkspc = new Workspace(this, workspacesList.size()); + workspacesList.push_back(wkspc); + workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); + } + } else { + wkspc = new Workspace(this, workspacesList.size()); + workspacesList.push_back(wkspc); + workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); + } - workspacemenu->insert(i18n-> - getMessage( - FBNLS::IconSet, FBNLS::IconIcons, - "Icons"), - m_iconmenu); - workspacemenu->update(); + workspacemenu->insert(i18n-> + getMessage( + FBNLS::IconSet, FBNLS::IconIcons, + "Icons"), + m_iconmenu); + workspacemenu->update(); - current_workspace = workspacesList.front(); - workspacemenu->setItemSelected(2, true); + current_workspace = workspacesList.front(); + workspacemenu->setItemSelected(2, true); - m_toolbar.reset(new Toolbar(this)); + m_toolbar.reset(new Toolbar(this)); #ifdef SLIT - m_slit.reset(new Slit(this)); + m_slit.reset(new Slit(this)); #endif // SLIT - initMenu(); + initMenu(); - raiseWindows(Workspace::Stack()); + raiseWindows(Workspace::Stack()); - //update menus - rootmenu->update(); + //update menus + rootmenu->update(); - if (m_slit.get()) - m_slit->reconfigure(); + if (m_slit.get()) + m_slit->reconfigure(); - // start with workspace 0 - changeWorkspaceID(0); - updateNetizenWorkspaceCount(); + // start with workspace 0 + changeWorkspaceID(0); + updateNetizenWorkspaceCount(); - int i; - unsigned int nchild; - Window r, p, *children; - XQueryTree(disp, getRootWindow(), &r, &p, &children, &nchild); + int i; + unsigned int nchild; + Window r, p, *children; + XQueryTree(disp, getRootWindow(), &r, &p, &children, &nchild); - // preen the window list of all icon windows... for better dockapp support - for (i = 0; i < (int) nchild; i++) { + // preen the window list of all icon windows... for better dockapp support + for (i = 0; i < (int) nchild; i++) { - if (children[i] == None) continue; + if (children[i] == None) continue; - XWMHints *wmhints = XGetWMHints(getBaseDisplay()->getXDisplay(), - children[i]); + XWMHints *wmhints = XGetWMHints(getBaseDisplay()->getXDisplay(), + children[i]); - if (wmhints) { - if ((wmhints->flags & IconWindowHint) && - (wmhints->icon_window != children[i])) - for (int j = 0; j < (int) nchild; j++) { - if (children[j] == wmhints->icon_window) { - children[j] = None; - break; - } - } - XFree(wmhints); - } - } + if (wmhints) { + if ((wmhints->flags & IconWindowHint) && + (wmhints->icon_window != children[i])) + for (int j = 0; j < (int) nchild; j++) { + if (children[j] == wmhints->icon_window) { + children[j] = None; + break; + } + } + XFree(wmhints); + } + } - // manage shown windows - for (i = 0; i < (int) nchild; ++i) { - if (children[i] == None || (! fluxbox->validateWindow(children[i]))) - continue; + // manage shown windows + for (i = 0; i < (int) nchild; ++i) { + if (children[i] == None || (! fluxbox->validateWindow(children[i]))) + continue; - XWindowAttributes attrib; - if (XGetWindowAttributes(disp, children[i], - &attrib)) { - if (attrib.override_redirect) - continue; + XWindowAttributes attrib; + if (XGetWindowAttributes(disp, children[i], + &attrib)) { + if (attrib.override_redirect) + continue; - if (attrib.map_state != IsUnmapped) { + if (attrib.map_state != IsUnmapped) { - FluxboxWindow *win = new FluxboxWindow(children[i], this); - if (!win->isManaged()) { - delete win; - win = 0; - } else { - Fluxbox::instance()->attachSignals(*win); - } + FluxboxWindow *win = new FluxboxWindow(children[i], this); + if (!win->isManaged()) { + delete win; + win = 0; + } else { + Fluxbox::instance()->attachSignals(*win); + } - if (win) { - XMapRequestEvent mre; - mre.window = children[i]; - win->restoreAttributes(); - win->mapRequestEvent(&mre); - } - } - } - } + if (win) { + XMapRequestEvent mre; + mre.window = children[i]; + win->restoreAttributes(); + win->mapRequestEvent(&mre); + } + } + } + } - if (! resource.sloppy_focus) { - XSetInputFocus(disp, m_toolbar->getWindowID(), - RevertToParent, CurrentTime); - } + if (! resource.sloppy_focus) { + XSetInputFocus(disp, m_toolbar->getWindowID(), + RevertToParent, CurrentTime); + } - XFree(children); - XFlush(disp); + XFree(children); + XFlush(disp); } BScreen::~BScreen() { - if (! managed) - return; + if (! managed) + return; - if (geom_pixmap != None) - image_control->removeImage(geom_pixmap); + if (geom_pixmap != None) + image_control->removeImage(geom_pixmap); - if (geom_window != None) - XDestroyWindow(getBaseDisplay()->getXDisplay(), geom_window); + if (geom_window != None) + XDestroyWindow(getBaseDisplay()->getXDisplay(), geom_window); - removeWorkspaceNames(); + removeWorkspaceNames(); - Workspaces::iterator w_it = workspacesList.begin(); - Workspaces::iterator w_it_end = workspacesList.end(); - for(; w_it != w_it_end; ++w_it) { - delete (*w_it); - } - workspacesList.clear(); + Workspaces::iterator w_it = workspacesList.begin(); + Workspaces::iterator w_it_end = workspacesList.end(); + for(; w_it != w_it_end; ++w_it) { + delete (*w_it); + } + workspacesList.clear(); - Icons::iterator i_it = iconList.begin(); - Icons::iterator i_it_end = iconList.end(); - for(; i_it != i_it_end; ++i_it) { - delete (*i_it); - } - iconList.clear(); + Icons::iterator i_it = iconList.begin(); + Icons::iterator i_it_end = iconList.end(); + for(; i_it != i_it_end; ++i_it) { + delete (*i_it); + } + iconList.clear(); - Netizens::iterator n_it = netizenList.begin(); - Netizens::iterator n_it_end = netizenList.end(); - for(; n_it != n_it_end; ++n_it) { - delete (*n_it); - } - netizenList.clear(); + Netizens::iterator n_it = netizenList.begin(); + Netizens::iterator n_it_end = netizenList.end(); + for(; n_it != n_it_end; ++n_it) { + delete (*n_it); + } + netizenList.clear(); - delete rootmenu; - delete workspacemenu; - delete m_iconmenu; - delete configmenu; + delete rootmenu; + delete workspacemenu; + delete m_iconmenu; + delete configmenu; - delete image_control; + delete image_control; - delete theme; + delete theme; } void BScreen::iconUpdate() { - m_iconmenu->update(); + m_iconmenu->update(); } void BScreen::reconfigure() { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; #endif // DEBUG - Fluxbox::instance()->loadRootCommand(this); - theme->setRootCommand(getRootCommand()); - theme->load(Fluxbox::instance()->getStyleFilename()); - theme->reconfigure(*resource.antialias); - // special case for tab rotated - if (*resource.tab_rotate_vertical && - ( *resource.tab_placement == Tab::PLEFT || *resource.tab_placement == Tab::PRIGHT)) { - theme->getWindowStyle().tab.font.rotate(90); - } else { - theme->getWindowStyle().tab.font.rotate(0); - } + Fluxbox::instance()->loadRootCommand(this); + theme->setRootCommand(getRootCommand()); + theme->load(Fluxbox::instance()->getStyleFilename()); + theme->reconfigure(*resource.antialias); + // special case for tab rotated + if (*resource.tab_rotate_vertical && + ( *resource.tab_placement == Tab::PLEFT || *resource.tab_placement == Tab::PRIGHT)) { + theme->getWindowStyle().tab.font.rotate(90); + } else { + theme->getWindowStyle().tab.font.rotate(0); + } - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - const char *s = i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenPositionLength, - "W: 0000 x H: 0000"); - int l = strlen(s); + const char *s = i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenPositionLength, + "W: 0000 x H: 0000"); + int l = strlen(s); - //TODO: repeat from somewhere else? - geom_h = theme->getWindowStyle().font.height(); - geom_w = theme->getWindowStyle().font.textWidth(s, l); - geom_w += getBevelWidth()*2; - geom_h += getBevelWidth()*2; + //TODO: repeat from somewhere else? + geom_h = theme->getWindowStyle().font.height(); + geom_w = theme->getWindowStyle().font.textWidth(s, l); + geom_w += getBevelWidth()*2; + geom_h += getBevelWidth()*2; - Pixmap tmp = geom_pixmap; - if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) { - if (theme->getWindowStyle().t_focus.type() == - (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - geom_pixmap = None; - XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window, - theme->getWindowStyle().t_focus.color().pixel()); - } else { - geom_pixmap = image_control->renderImage(geom_w, geom_h, - theme->getWindowStyle().t_focus); - XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(), - geom_window, geom_pixmap); - } - } else { - if (theme->getWindowStyle().l_focus.type() == - (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - geom_pixmap = None; - XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window, - theme->getWindowStyle().l_focus.color().pixel()); - } else { - geom_pixmap = image_control->renderImage(geom_w, geom_h, - theme->getWindowStyle().l_focus); - XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(), - geom_window, geom_pixmap); - } - } - if (tmp) image_control->removeImage(tmp); + Pixmap tmp = geom_pixmap; + if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) { + if (theme->getWindowStyle().t_focus.type() == + (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + geom_pixmap = None; + XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window, + theme->getWindowStyle().t_focus.color().pixel()); + } else { + geom_pixmap = image_control->renderImage(geom_w, geom_h, + theme->getWindowStyle().t_focus); + XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(), + geom_window, geom_pixmap); + } + } else { + if (theme->getWindowStyle().l_focus.type() == + (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + geom_pixmap = None; + XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window, + theme->getWindowStyle().l_focus.color().pixel()); + } else { + geom_pixmap = image_control->renderImage(geom_w, geom_h, + theme->getWindowStyle().l_focus); + XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(), + geom_window, geom_pixmap); + } + } + if (tmp) image_control->removeImage(tmp); - XSetWindowBorderWidth(getBaseDisplay()->getXDisplay(), geom_window, - theme->getBorderWidth()); - XSetWindowBorder(getBaseDisplay()->getXDisplay(), geom_window, - theme->getBorderColor().pixel()); + XSetWindowBorderWidth(getBaseDisplay()->getXDisplay(), geom_window, + theme->getBorderWidth()); + XSetWindowBorder(getBaseDisplay()->getXDisplay(), geom_window, + theme->getBorderColor().pixel()); - //reconfigure menus - workspacemenu->reconfigure(); - m_iconmenu->reconfigure(); + //reconfigure menus + workspacemenu->reconfigure(); + m_iconmenu->reconfigure(); - configmenu->reconfigure(); + configmenu->reconfigure(); - { - int remember_sub = rootmenu->currentSubmenu(); - initMenu(); - raiseWindows(Workspace::Stack()); - rootmenu->reconfigure(); - rootmenu->drawSubmenu(remember_sub); - } + { + int remember_sub = rootmenu->currentSubmenu(); + initMenu(); + raiseWindows(Workspace::Stack()); + rootmenu->reconfigure(); + rootmenu->drawSubmenu(remember_sub); + } - m_toolbar->reconfigure(); + m_toolbar->reconfigure(); - if (m_slit.get()) - m_slit->reconfigure(); + if (m_slit.get()) + m_slit->reconfigure(); - //reconfigure workspaces - Workspaces::iterator wit = workspacesList.begin(); - Workspaces::iterator wit_end = workspacesList.end(); - for (; wit != wit_end; ++wit) { - (*wit)->reconfigure(); - } + //reconfigure workspaces + Workspaces::iterator wit = workspacesList.begin(); + Workspaces::iterator wit_end = workspacesList.end(); + for (; wit != wit_end; ++wit) { + (*wit)->reconfigure(); + } - //reconfigure Icons - Icons::iterator iit = iconList.begin(); - Icons::iterator iit_end = iconList.end(); - for (; iit != iit_end; ++iit) { - if ((*iit)->validateClient()) - (*iit)->reconfigure(); - } + //reconfigure Icons + Icons::iterator iit = iconList.begin(); + Icons::iterator iit_end = iconList.end(); + for (; iit != iit_end; ++iit) { + if ((*iit)->validateClient()) + (*iit)->reconfigure(); + } - image_control->timeout(); + image_control->timeout(); } void BScreen::rereadMenu() { - initMenu(); - raiseWindows(Workspace::Stack()); + initMenu(); + raiseWindows(Workspace::Stack()); - rootmenu->reconfigure(); + rootmenu->reconfigure(); } void BScreen::removeWorkspaceNames() { - workspaceNames.erase(workspaceNames.begin(), workspaceNames.end()); + workspaceNames.erase(workspaceNames.begin(), workspaceNames.end()); } void BScreen::updateWorkspaceNamesAtom() { - m_workspacenames_sig.notify(); + m_workspacenames_sig.notify(); } void BScreen::addIcon(FluxboxWindow *w) { - if (! w) return; + if (! w) return; - w->setWorkspace(-1); - w->setWindowNumber(iconList.size()); + w->setWorkspace(-1); + w->setWindowNumber(iconList.size()); - iconList.push_back(w); + iconList.push_back(w); - m_iconmenu->insert(w->getIconTitle().c_str()); - m_iconmenu->update(); - m_toolbar->addIcon(w); + m_iconmenu->insert(w->getIconTitle().c_str()); + m_iconmenu->update(); + m_toolbar->addIcon(w); } void BScreen::removeIcon(FluxboxWindow *w) { - if (! w) - return; + if (! w) + return; - { + { Icons::iterator it = iconList.begin(); Icons::iterator it_end = iconList.end(); for (; it != it_end; ++it) { - if (*it == w) { - iconList.erase(it); - break; - } + if (*it == w) { + iconList.erase(it); + break; + } } - } + } - m_iconmenu->remove(w->getWindowNumber()); - m_iconmenu->update(); - m_toolbar->delIcon(w); + m_iconmenu->remove(w->getWindowNumber()); + m_iconmenu->update(); + m_toolbar->delIcon(w); - Icons::iterator it = iconList.begin(); - Icons::iterator it_end = iconList.end(); - for (int i = 0; it != it_end; ++it, ++i) { - (*it)->setWindowNumber(i); - } + Icons::iterator it = iconList.begin(); + Icons::iterator it_end = iconList.end(); + for (int i = 0; it != it_end; ++it, ++i) { + (*it)->setWindowNumber(i); + } } void BScreen::removeWindow(FluxboxWindow *win) { - Workspaces::iterator it = workspacesList.begin(); - Workspaces::iterator it_end = workspacesList.end(); - for (; it != it_end; ++it) { - (*it)->removeWindow(win); - } + Workspaces::iterator it = workspacesList.begin(); + Workspaces::iterator it_end = workspacesList.end(); + for (; it != it_end; ++it) { + (*it)->removeWindow(win); + } } FluxboxWindow *BScreen::getIcon(unsigned int index) { - if (index < iconList.size()) - return iconList[index]; + if (index < iconList.size()) + return iconList[index]; - return 0; + return 0; } void BScreen::setAntialias(bool value) { - if (*resource.antialias == value) - return; - resource.antialias = value; - reconfigure(); + if (*resource.antialias == value) + return; + resource.antialias = value; + reconfigure(); } int BScreen::addWorkspace() { - Workspace *wkspc = new Workspace(this, workspacesList.size()); - workspacesList.push_back(wkspc); - addWorkspaceName(wkspc->name().c_str()); // update names - //add workspace to workspacemenu - workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu(), - wkspc->workspaceID() + 2); //+2 so we add it after "remove last" + Workspace *wkspc = new Workspace(this, workspacesList.size()); + workspacesList.push_back(wkspc); + addWorkspaceName(wkspc->name().c_str()); // update names + //add workspace to workspacemenu + workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu(), + wkspc->workspaceID() + 2); //+2 so we add it after "remove last" - workspacemenu->update(); - saveWorkspaces(workspacesList.size()); - m_toolbar->reconfigure(); + workspacemenu->update(); + saveWorkspaces(workspacesList.size()); + m_toolbar->reconfigure(); - updateNetizenWorkspaceCount(); + updateNetizenWorkspaceCount(); - return workspacesList.size(); + return workspacesList.size(); } /// removes last workspace /// @return number of desktops left int BScreen::removeLastWorkspace() { - if (workspacesList.size() <= 1) - return 0; - Workspace *wkspc = workspacesList.back(); + if (workspacesList.size() <= 1) + return 0; + Workspace *wkspc = workspacesList.back(); - if (current_workspace->workspaceID() == wkspc->workspaceID()) - changeWorkspaceID(current_workspace->workspaceID() - 1); + if (current_workspace->workspaceID() == wkspc->workspaceID()) + changeWorkspaceID(current_workspace->workspaceID() - 1); - wkspc->removeAll(); + wkspc->removeAll(); - workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts - workspacemenu->update(); + workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts + workspacemenu->update(); - //remove last workspace - workspacesList.pop_back(); - delete wkspc; + //remove last workspace + workspacesList.pop_back(); + delete wkspc; - m_toolbar->reconfigure(); + m_toolbar->reconfigure(); - updateNetizenWorkspaceCount(); - saveWorkspaces(workspacesList.size()); + updateNetizenWorkspaceCount(); + saveWorkspaces(workspacesList.size()); - return workspacesList.size(); + return workspacesList.size(); } void BScreen::changeWorkspaceID(unsigned int id) { - if (! current_workspace || id >= workspacesList.size()) - return; + if (! current_workspace || id >= workspacesList.size()) + return; - if (id != current_workspace->workspaceID()) { - XSync(BaseDisplay::getXDisplay(), true); - FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); + if (id != current_workspace->workspaceID()) { + XSync(BaseDisplay::getXDisplay(), true); + FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); #ifdef DEBUG - cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; + cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; #endif // DEBUG - if (focused && focused->isMoving()) { - reassociateGroup(focused, id, true); - focused->pauseMoving(); - } + if (focused && focused->isMoving()) { + reassociateGroup(focused, id, true); + focused->pauseMoving(); + } - Workspace *wksp = getCurrentWorkspace(); - Workspace::Windows wins = wksp->getWindowList(); - Workspace::Windows::iterator it = wins.begin(); - for (; it != wins.end(); ++it) { - if ((*it)->isStuck()) { - reassociateGroup(*it,id,true); - } - } + Workspace *wksp = getCurrentWorkspace(); + Workspace::Windows wins = wksp->getWindowList(); + Workspace::Windows::iterator it = wins.begin(); + for (; it != wins.end(); ++it) { + if ((*it)->isStuck()) { + reassociateGroup(*it,id,true); + } + } - current_workspace->hideAll(); + current_workspace->hideAll(); - workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false); + workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false); - if (focused && focused->getScreen() == this && - (! focused->isStuck()) && (!focused->isMoving())) { - current_workspace->setLastFocusedWindow(focused); - Fluxbox::instance()->setFocusedWindow(0); // set focused window to none - } + if (focused && focused->getScreen() == this && + (! focused->isStuck()) && (!focused->isMoving())) { + current_workspace->setLastFocusedWindow(focused); + Fluxbox::instance()->setFocusedWindow(0); // set focused window to none + } - // set new workspace - current_workspace = getWorkspace(id); + // set new workspace + current_workspace = getWorkspace(id); - workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); - m_toolbar->redrawWorkspaceLabel(true); + workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); + m_toolbar->redrawWorkspaceLabel(true); - current_workspace->showAll(); + current_workspace->showAll(); - if (*resource.focus_last && current_workspace->getLastFocusedWindow() && - !(focused && focused->isMoving())) { - current_workspace->getLastFocusedWindow()->setInputFocus(); + if (*resource.focus_last && current_workspace->getLastFocusedWindow() && + !(focused && focused->isMoving())) { + current_workspace->getLastFocusedWindow()->setInputFocus(); - } else if (focused && focused->isStuck()) { - focused->setInputFocus(); - } + } else if (focused && focused->isStuck()) { + focused->setInputFocus(); + } - if (focused && focused->isMoving()) { - focused->resumeMoving(); - } - } + if (focused && focused->isMoving()) { + focused->resumeMoving(); + } + } - updateNetizenCurrentWorkspace(); + updateNetizenCurrentWorkspace(); } void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS) { - if (! current_workspace || id >= workspacesList.size()) - return; + if (! current_workspace || id >= workspacesList.size()) + return; - if (!win) - win = Fluxbox::instance()->getFocusedWindow(); + if (!win) + win = Fluxbox::instance()->getFocusedWindow(); - if (id != current_workspace->workspaceID()) { - XSync(BaseDisplay::getXDisplay(), True); + if (id != current_workspace->workspaceID()) { + XSync(BaseDisplay::getXDisplay(), True); - if (win && win->getScreen() == this && - (! win->isStuck())) { + if (win && win->getScreen() == this && + (! win->isStuck())) { - if ( win->getTab() ) { - Tab *tab = win->getTab(); - tab->disconnect(); - tab->setPosition(); - } + if ( win->getTab() ) { + Tab *tab = win->getTab(); + tab->disconnect(); + tab->setPosition(); + } - if (win->isIconic()) { - win->deiconify(); - } + if (win->isIconic()) { + win->deiconify(); + } - win->withdraw(); - reassociateWindow(win, id, true); + win->withdraw(); + reassociateWindow(win, id, true); - // change workspace ? - if (changeWS) { - changeWorkspaceID(id); - win->setInputFocus(); - } + // change workspace ? + if (changeWS) { + changeWorkspaceID(id); + win->setInputFocus(); + } #ifdef DEBUG - cerr<<"Sending to id = "<<id<<endl; - cerr<<"win->workspaceId="<<win->getWorkspaceNumber()<<endl; + cerr<<"Sending to id = "<<id<<endl; + cerr<<"win->workspaceId="<<win->getWorkspaceNumber()<<endl; #endif //DEBUG - } + } - } + } } void BScreen::addNetizen(Netizen *n) { - netizenList.push_back(n); + netizenList.push_back(n); - n->sendWorkspaceCount(); - n->sendCurrentWorkspace(); + n->sendWorkspaceCount(); + n->sendCurrentWorkspace(); - Workspaces::iterator it = workspacesList.begin(); - Workspaces::iterator it_end = workspacesList.end(); - for (; it != it_end; ++it) { - for (int i = 0; i < (*it)->getCount(); ++i) { - n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(), - (*it)->workspaceID()); - } - } + Workspaces::iterator it = workspacesList.begin(); + Workspaces::iterator it_end = workspacesList.end(); + for (; it != it_end; ++it) { + for (int i = 0; i < (*it)->getCount(); ++i) { + n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(), + (*it)->workspaceID()); + } + } - Window f = ((Fluxbox::instance()->getFocusedWindow()) ? + Window f = ((Fluxbox::instance()->getFocusedWindow()) ? Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None); - n->sendWindowFocus(f); + n->sendWindowFocus(f); } void BScreen::removeNetizen(Window w) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - if ((*it)->getWindowID() == w) { - Netizen *n = *it; - delete n; - netizenList.erase(it); - break; - } - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + if ((*it)->getWindowID() == w) { + Netizen *n = *it; + delete n; + netizenList.erase(it); + break; + } + } } void BScreen::updateNetizenCurrentWorkspace() { - m_currentworkspace_sig.notify(); + m_currentworkspace_sig.notify(); - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendCurrentWorkspace(); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendCurrentWorkspace(); + } } void BScreen::updateNetizenWorkspaceCount() { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendWorkspaceCount(); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendWorkspaceCount(); + } - m_workspacecount_sig.notify(); + m_workspacecount_sig.notify(); } void BScreen::updateNetizenWindowFocus() { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - Window f = ((Fluxbox::instance()->getFocusedWindow()) ? - Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None); - for (; it != it_end; ++it) { - (*it)->sendWindowFocus(f); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + Window f = ((Fluxbox::instance()->getFocusedWindow()) ? + Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None); + for (; it != it_end; ++it) { + (*it)->sendWindowFocus(f); + } } void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowAdd(w, p); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendWindowAdd(w, p); + } - m_clientlist_sig.notify(); + m_clientlist_sig.notify(); } void BScreen::updateNetizenWindowDel(Window w) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowDel(w); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendWindowDel(w); + } - m_clientlist_sig.notify(); + m_clientlist_sig.notify(); } void BScreen::updateNetizenWindowRaise(Window w) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowRaise(w); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendWindowRaise(w); + } } void BScreen::updateNetizenWindowLower(Window w) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendWindowLower(w); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendWindowLower(w); + } } void BScreen::updateNetizenConfigNotify(XEvent *e) { - Netizens::iterator it = netizenList.begin(); - Netizens::iterator it_end = netizenList.end(); - for (; it != it_end; ++it) { - (*it)->sendConfigNotify(e); - } + Netizens::iterator it = netizenList.begin(); + Netizens::iterator it_end = netizenList.end(); + for (; it != it_end; ++it) { + (*it)->sendConfigNotify(e); + } } void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { - Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; - int i = 0; - XRaiseWindow(getBaseDisplay()->getXDisplay(), m_iconmenu->windowID()); - session_stack[i++] = m_iconmenu->windowID(); + Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; + int i = 0; + XRaiseWindow(getBaseDisplay()->getXDisplay(), m_iconmenu->windowID()); + session_stack[i++] = m_iconmenu->windowID(); - Workspaces::iterator wit = workspacesList.begin(); - Workspaces::iterator wit_end = workspacesList.end(); - for (; wit != wit_end; ++wit) { - session_stack[i++] = (*wit)->menu().windowID(); - } + Workspaces::iterator wit = workspacesList.begin(); + Workspaces::iterator wit_end = workspacesList.end(); + for (; wit != wit_end; ++wit) { + session_stack[i++] = (*wit)->menu().windowID(); + } - session_stack[i++] = workspacemenu->windowID(); + session_stack[i++] = workspacemenu->windowID(); - session_stack[i++] = configmenu->focusmenu().windowID(); - session_stack[i++] = configmenu->placementmenu().windowID(); - session_stack[i++] = configmenu->tabmenu().windowID(); - session_stack[i++] = configmenu->windowID(); + session_stack[i++] = configmenu->focusmenu().windowID(); + session_stack[i++] = configmenu->placementmenu().windowID(); + session_stack[i++] = configmenu->tabmenu().windowID(); + session_stack[i++] = configmenu->windowID(); #ifdef SLIT - session_stack[i++] = m_slit->menu().getDirectionmenu().windowID(); - session_stack[i++] = m_slit->menu().getPlacementmenu().windowID(); + session_stack[i++] = m_slit->menu().getDirectionmenu().windowID(); + session_stack[i++] = m_slit->menu().getPlacementmenu().windowID(); #ifdef XINERAMA - if (hasXinerama()) { - session_stack[i++] = m_slit->menu().getHeadmenu()->windowID(); - } + if (hasXinerama()) { + session_stack[i++] = m_slit->menu().getHeadmenu()->windowID(); + } #endif // XINERAMA - session_stack[i++] = m_slit->menu().windowID(); + session_stack[i++] = m_slit->menu().windowID(); #endif // SLIT - session_stack[i++] = - m_toolbar->menu().placementmenu()->windowID(); + session_stack[i++] = + m_toolbar->menu().placementmenu()->windowID(); #ifdef XINERAMA - if (hasXinerama()) { - session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID(); - } + if (hasXinerama()) { + session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID(); + } #endif // XINERAMA - session_stack[i++] = m_toolbar->menu().windowID(); + session_stack[i++] = m_toolbar->menu().windowID(); - Rootmenus::iterator rit = rootmenuList.begin(); - Rootmenus::iterator rit_end = rootmenuList.end(); - for (; rit != rit_end; ++rit) { - session_stack[i++] = (*rit)->windowID(); - } - session_stack[i++] = rootmenu->windowID(); + Rootmenus::iterator rit = rootmenuList.begin(); + Rootmenus::iterator rit_end = rootmenuList.end(); + for (; rit != rit_end; ++rit) { + session_stack[i++] = (*rit)->windowID(); + } + session_stack[i++] = rootmenu->windowID(); - if (m_toolbar->isOnTop()) - session_stack[i++] = m_toolbar->getWindowID(); + if (m_toolbar->isOnTop()) + session_stack[i++] = m_toolbar->getWindowID(); #ifdef SLIT - if (m_slit->isOnTop()) - session_stack[i++] = m_slit->getWindowID(); + if (m_slit->isOnTop()) + session_stack[i++] = m_slit->getWindowID(); #endif // SLIT - if (!workspace_stack.empty()) { - Workspace::Stack::const_reverse_iterator it = workspace_stack.rbegin(); - Workspace::Stack::const_reverse_iterator it_end = workspace_stack.rend(); - for (; it != it_end; ++it) - session_stack[i++] = (*it); - } + if (!workspace_stack.empty()) { + Workspace::Stack::const_reverse_iterator it = workspace_stack.rbegin(); + Workspace::Stack::const_reverse_iterator it_end = workspace_stack.rend(); + for (; it != it_end; ++it) + session_stack[i++] = (*it); + } - XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i); + XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i); } void BScreen::saveStrftimeFormat(const char *format) { - //make sure std::string don't get 0 string - resource.strftime_format = (format ? format : ""); + //make sure std::string don't get 0 string + resource.strftime_format = (format ? format : ""); } void BScreen::addWorkspaceName(const char *name) { - workspaceNames.push_back(name); + workspaceNames.push_back(name); } string BScreen::getNameOfWorkspace(unsigned int workspace) const { - if (workspace < workspaceNames.size()) { - return workspaceNames[workspace]; - } else { - return ""; - } + if (workspace < workspaceNames.size()) { + return workspaceNames[workspace]; + } else { + return ""; + } } void BScreen::reassociateGroup(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) { - if (w->hasTab() && (w->getTab()->next() || w->getTab()->prev())) { - Tab *tab_it = w->getTab()->first(); - for (; tab_it; tab_it = tab_it->next()) { - reassociateWindow(tab_it->getWindow(), wkspc_id, ignore_sticky); - } - } else { - // no tab, juts move this one - reassociateWindow(w, wkspc_id, ignore_sticky); - } + if (w->hasTab() && (w->getTab()->next() || w->getTab()->prev())) { + Tab *tab_it = w->getTab()->first(); + for (; tab_it; tab_it = tab_it->next()) { + reassociateWindow(tab_it->getWindow(), wkspc_id, ignore_sticky); + } + } else { + // no tab, juts move this one + reassociateWindow(w, wkspc_id, ignore_sticky); + } } void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) { - if (! w) return; + if (! w) return; - if (wkspc_id >= getCount()) { - wkspc_id = current_workspace->workspaceID(); + if (wkspc_id >= getCount()) { + wkspc_id = current_workspace->workspaceID(); #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): wkspc_id >= getCount()"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): wkspc_id >= getCount()"<<endl; #endif // DEBUG - } + } - if (w->getWorkspaceNumber() == wkspc_id) - return; + if (w->getWorkspaceNumber() == wkspc_id) + return; - if (w->isIconic()) { - removeIcon(w); - getWorkspace(wkspc_id)->addWindow(w); - } else if (ignore_sticky || ! w->isStuck()) { - getWorkspace(w->getWorkspaceNumber())->removeWindow(w); - getWorkspace(wkspc_id)->addWindow(w); - } + if (w->isIconic()) { + removeIcon(w); + getWorkspace(wkspc_id)->addWindow(w); + } else if (ignore_sticky || ! w->isStuck()) { + getWorkspace(w->getWorkspaceNumber())->removeWindow(w); + getWorkspace(wkspc_id)->addWindow(w); + } } void BScreen::nextFocus(int opts) { - bool have_focused = false; - int focused_window_number = -1; - FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); - const int num_windows = getCurrentWorkspace()->getCount(); + bool have_focused = false; + int focused_window_number = -1; + FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); + const int num_windows = getCurrentWorkspace()->getCount(); - if (focused != 0) { - if (focused->getScreen()->getScreenNumber() == - getScreenNumber()) { - have_focused = true; - focused_window_number = focused->getWindowNumber(); - } - } + if (focused != 0) { + if (focused->getScreen()->getScreenNumber() == + getScreenNumber()) { + have_focused = true; + focused_window_number = focused->getWindowNumber(); + } + } - if (num_windows >= 1) { - Workspace *wksp = getCurrentWorkspace(); - Workspace::Windows &wins = wksp->getWindowList(); - Workspace::Windows::iterator it = wins.begin(); + if (num_windows >= 1) { + Workspace *wksp = getCurrentWorkspace(); + Workspace::Windows &wins = wksp->getWindowList(); + Workspace::Windows::iterator it = wins.begin(); - if (!have_focused) { - focused = *it; - } else { - for (; *it != focused; ++it) //get focused window iterator - continue; - } - do { - ++it; - if (it == wins.end()) - it = wins.begin(); - // see if the window should be skipped - if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) ) - break; - } while (*it != focused); + if (!have_focused) { + focused = *it; + } else { + for (; *it != focused; ++it) //get focused window iterator + continue; + } + do { + ++it; + if (it == wins.end()) + it = wins.begin(); + // see if the window should be skipped + if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) ) + break; + } while (*it != focused); - if (*it != focused && it != wins.end()) - wksp->raiseWindow(*it); + if (*it != focused && it != wins.end()) + wksp->raiseWindow(*it); - } + } } void BScreen::prevFocus(int opts) { - bool have_focused = false; - int focused_window_number = -1; - FluxboxWindow *focused; - int num_windows = getCurrentWorkspace()->getCount(); + bool have_focused = false; + int focused_window_number = -1; + FluxboxWindow *focused; + int num_windows = getCurrentWorkspace()->getCount(); - if ((focused = Fluxbox::instance()->getFocusedWindow())) { - if (focused->getScreen()->getScreenNumber() == - getScreenNumber()) { - have_focused = true; - focused_window_number = focused->getWindowNumber(); - } - } + if ((focused = Fluxbox::instance()->getFocusedWindow())) { + if (focused->getScreen()->getScreenNumber() == + getScreenNumber()) { + have_focused = true; + focused_window_number = focused->getWindowNumber(); + } + } - if (num_windows >= 1) { - Workspace *wksp = getCurrentWorkspace(); - Workspace::Windows &wins = wksp->getWindowList(); - Workspace::Windows::iterator it = wins.begin(); + if (num_windows >= 1) { + Workspace *wksp = getCurrentWorkspace(); + Workspace::Windows &wins = wksp->getWindowList(); + Workspace::Windows::iterator it = wins.begin(); - if (!have_focused) { - focused = *it; - } else { - for (; *it != focused; ++it) //get focused window iterator - continue; - } + if (!have_focused) { + focused = *it; + } else { + for (; *it != focused; ++it) //get focused window iterator + continue; + } - do { - if (it == wins.begin()) - it = wins.end(); - --it; - // see if the window should be skipped - if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) ) - break; - } while (*it != focused); + do { + if (it == wins.begin()) + it = wins.end(); + --it; + // see if the window should be skipped + if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) ) + break; + } while (*it != focused); - if (*it != focused && it != wins.end()) - wksp->raiseWindow(*it); + if (*it != focused && it != wins.end()) + wksp->raiseWindow(*it); - } + } } //--------- raiseFocus ----------- // Raise the current focused window //-------------------------------- void BScreen::raiseFocus() { - bool have_focused = false; - int focused_window_number = -1; - Fluxbox * const fb = Fluxbox::instance(); + bool have_focused = false; + int focused_window_number = -1; + Fluxbox * const fb = Fluxbox::instance(); - if (fb->getFocusedWindow()) - if (fb->getFocusedWindow()->getScreen()->getScreenNumber() == - getScreenNumber()) { - have_focused = true; - focused_window_number = fb->getFocusedWindow()->getWindowNumber(); - } + if (fb->getFocusedWindow()) + if (fb->getFocusedWindow()->getScreen()->getScreenNumber() == + getScreenNumber()) { + have_focused = true; + focused_window_number = fb->getFocusedWindow()->getWindowNumber(); + } - if ((getCurrentWorkspace()->getCount() > 1) && have_focused) - getWorkspace(fb->getFocusedWindow()->getWorkspaceNumber())-> - raiseWindow(fb->getFocusedWindow()); + if ((getCurrentWorkspace()->getCount() > 1) && have_focused) + getWorkspace(fb->getFocusedWindow()->getWorkspaceNumber())-> + raiseWindow(fb->getFocusedWindow()); } void BScreen::initMenu() { - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - if (rootmenu) { - rootmenuList.erase(rootmenuList.begin(), rootmenuList.end()); + if (rootmenu) { + rootmenuList.erase(rootmenuList.begin(), rootmenuList.end()); - while (rootmenu->numberOfItems()) - rootmenu->remove(0); - } else - rootmenu = new Rootmenu(this); + while (rootmenu->numberOfItems()) + rootmenu->remove(0); + } else + rootmenu = new Rootmenu(this); - bool defaultMenu = true; - Fluxbox * const fb = Fluxbox::instance(); - if (fb->getMenuFilename()) { - ifstream menu_file(fb->getMenuFilename()); + bool defaultMenu = true; + Fluxbox * const fb = Fluxbox::instance(); + if (fb->getMenuFilename()) { + ifstream menu_file(fb->getMenuFilename()); - if (!menu_file.fail()) { - if (! menu_file.eof()) { - string line; - int row = 0; - while (getline(menu_file, line) && ! menu_file.eof()) { - row++; - if (line[0] != '#') { - string key; - int pos=0; - int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']'); + if (!menu_file.fail()) { + if (! menu_file.eof()) { + string line; + int row = 0; + while (getline(menu_file, line) && ! menu_file.eof()) { + row++; + if (line[0] != '#') { + string key; + int pos=0; + int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']'); - if (key == "begin") { - pos += err; - string label; - err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')'); - if (err>0) { - rootmenu->setLabel(label.c_str()); - defaultMenu = parseMenuFile(menu_file, rootmenu, row); - } else - cerr<<"Error in menufile. Line("<<row<<")"<<endl; - break; - } - } - } - } else { - fprintf(stderr, - i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, - "%s: Empty menu file"), - fb->getMenuFilename()); - } - menu_file.close(); - } else - perror(fb->getMenuFilename()); - } + if (key == "begin") { + pos += err; + string label; + err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')'); + if (err>0) { + rootmenu->setLabel(label.c_str()); + defaultMenu = parseMenuFile(menu_file, rootmenu, row); + } else + cerr<<"Error in menufile. Line("<<row<<")"<<endl; + break; + } + } + } + } else { + fprintf(stderr, + i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, + "%s: Empty menu file"), + fb->getMenuFilename()); + } + menu_file.close(); + } else + perror(fb->getMenuFilename()); + } - if (defaultMenu) { - rootmenu->setInternalMenu(); - rootmenu->insert(i18n->getMessage( - FBNLS::ScreenSet, FBNLS::Screenxterm, - "xterm"), - BScreen::EXECUTE, - i18n->getMessage( - FBNLS::ScreenSet, FBNLS::Screenxterm, - "xterm")); - rootmenu->insert(i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenRestart, - "Restart"), - BScreen::RESTART); - rootmenu->insert(i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenExit, - "Exit"), - BScreen::EXIT); - } else - fb->saveMenuFilename(fb->getMenuFilename()); + if (defaultMenu) { + rootmenu->setInternalMenu(); + rootmenu->insert(i18n->getMessage( + FBNLS::ScreenSet, FBNLS::Screenxterm, + "xterm"), + BScreen::EXECUTE, + i18n->getMessage( + FBNLS::ScreenSet, FBNLS::Screenxterm, + "xterm")); + rootmenu->insert(i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenRestart, + "Restart"), + BScreen::RESTART); + rootmenu->insert(i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenExit, + "Exit"), + BScreen::EXIT); + } else + fb->saveMenuFilename(fb->getMenuFilename()); } // looks through a menufile and adds correct items to the root-menu. bool BScreen::parseMenuFile(ifstream &file, Rootmenu *menu, int &row) { - string line; + string line; - while (! file.eof()) { + while (! file.eof()) { - if (getline(file, line)) { - row++; - if (line[0] != '#') { //the line is commented - int parse_pos = 0, err = 0; + if (getline(file, line)) { + row++; + if (line[0] != '#') { //the line is commented + int parse_pos = 0, err = 0; - std::string str_key, str_label, str_cmd; + std::string str_key, str_label, str_cmd; - err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']'); - if (err > 0 ) { - parse_pos += err; - err = StringUtil::getStringBetween(str_label, line.c_str() + parse_pos, '(', ')'); - if (err>0) { - parse_pos += err; - StringUtil::getStringBetween(str_cmd, line.c_str() + parse_pos, '{', '}'); - } - } else - continue; //read next line + err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']'); + if (err > 0 ) { + parse_pos += err; + err = StringUtil::getStringBetween(str_label, line.c_str() + parse_pos, '(', ')'); + if (err>0) { + parse_pos += err; + StringUtil::getStringBetween(str_cmd, line.c_str() + parse_pos, '{', '}'); + } + } else + continue; //read next line - if (!str_key.size()) - continue; //read next line + if (!str_key.size()) + continue; //read next line - I18n *i18n = I18n::instance(); - if (str_key == "end") { - return ((menu->numberOfItems() == 0) ? true : false); - } else if (str_key == "nop") { - menu->insert(str_label.c_str()); - } else if (str_key == "exec") { // exec - if (!(str_label.size() && str_cmd.size())) { - fprintf(stderr, - i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenEXECError, - "BScreen::parseMenuFile: [exec] error, " - "no menu label and/or command defined\n")); - cerr<<"Row: "<<row<<endl; - } else - menu->insert(str_label.c_str(), BScreen::EXECUTE, str_cmd.c_str()); + I18n *i18n = I18n::instance(); + if (str_key == "end") { + return ((menu->numberOfItems() == 0) ? true : false); + } else if (str_key == "nop") { + menu->insert(str_label.c_str()); + } else if (str_key == "exec") { // exec + if (!(str_label.size() && str_cmd.size())) { + fprintf(stderr, + i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenEXECError, + "BScreen::parseMenuFile: [exec] error, " + "no menu label and/or command defined\n")); + cerr<<"Row: "<<row<<endl; + } else + menu->insert(str_label.c_str(), BScreen::EXECUTE, str_cmd.c_str()); - } else if (str_key == "exit") { // exit - if (!str_label.size()) { - fprintf(stderr, - i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenEXITError, - "BScreen::parseMenuFile: [exit] error, " - "no menu label defined\n")); - cerr<<"Row: "<<row<<endl; - } else - menu->insert(str_label.c_str(), BScreen::EXIT); - } // end of exit - else if (str_key == "style") { // style - if (!( str_label.size() && str_cmd.size())) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSTYLEError, - "BScreen::parseMenuFile: [style] error, " - "no menu label and/or filename defined\n")); - cerr<<"Row: "<<row<<endl; - } else { - // perform shell style ~ home directory expansion - // and insert style - menu->insert(str_label.c_str(), BScreen::SETSTYLE, - StringUtil::expandFilename(str_cmd).c_str()); + } else if (str_key == "exit") { // exit + if (!str_label.size()) { + fprintf(stderr, + i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenEXITError, + "BScreen::parseMenuFile: [exit] error, " + "no menu label defined\n")); + cerr<<"Row: "<<row<<endl; + } else + menu->insert(str_label.c_str(), BScreen::EXIT); + } // end of exit + else if (str_key == "style") { // style + if (!( str_label.size() && str_cmd.size())) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenSTYLEError, + "BScreen::parseMenuFile: [style] error, " + "no menu label and/or filename defined\n")); + cerr<<"Row: "<<row<<endl; + } else { + // perform shell style ~ home directory expansion + // and insert style + menu->insert(str_label.c_str(), BScreen::SETSTYLE, + StringUtil::expandFilename(str_cmd).c_str()); - } - } // end of style + } + } // end of style - else if (str_key == "config") { - if (! str_label.size()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenCONFIGError, - "BScreen::parseMenufile: [config] error, " - "no label defined")); - cerr<<"Row: "<<row<<endl; - } else - menu->insert(str_label.c_str(), configmenu); - } // end of config - else if ( str_key == "include") { // include - if (!str_label.size()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError, - "BScreen::parseMenuFile: [include] error, " - "no filename defined\n")); - cerr<<"Row: "<<row<<endl; - } else { // start of else 'x' - // perform shell style ~ home directory expansion - string newfile(StringUtil::expandFilename(str_label)); + else if (str_key == "config") { + if (! str_label.size()) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenCONFIGError, + "BScreen::parseMenufile: [config] error, " + "no label defined")); + cerr<<"Row: "<<row<<endl; + } else + menu->insert(str_label.c_str(), configmenu); + } // end of config + else if ( str_key == "include") { // include + if (!str_label.size()) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError, + "BScreen::parseMenuFile: [include] error, " + "no filename defined\n")); + cerr<<"Row: "<<row<<endl; + } else { // start of else 'x' + // perform shell style ~ home directory expansion + string newfile(StringUtil::expandFilename(str_label)); - if (newfile.size() != 0) { - FILE *submenufile = fopen(newfile.c_str(), "r"); + if (newfile.size() != 0) { + FILE *submenufile = fopen(newfile.c_str(), "r"); - if (submenufile) { - struct stat buf; - if (fstat(fileno(submenufile), &buf) || - (! S_ISREG(buf.st_mode))) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenINCLUDEErrorReg, - "BScreen::parseMenuFile: [include] error: " - "'%s' is not a regular file\n"), newfile.c_str()); - cerr<<"Row: "<<row<<endl; - } + if (submenufile) { + struct stat buf; + if (fstat(fileno(submenufile), &buf) || + (! S_ISREG(buf.st_mode))) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenINCLUDEErrorReg, + "BScreen::parseMenuFile: [include] error: " + "'%s' is not a regular file\n"), newfile.c_str()); + cerr<<"Row: "<<row<<endl; + } - if (! feof(submenufile)) { - fclose(submenufile); - ifstream subfile(newfile.c_str()); - if (! parseMenuFile(subfile, menu, row)) - Fluxbox::instance()->saveMenuFilename(newfile.c_str()); - } - } else - perror(newfile.c_str()); - } - } // end of else 'x' - } // end of include - else if (str_key == "submenu") { // sub - if (!str_label.size()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSUBMENUError, - "BScreen::parseMenuFile: [submenu] error, " - "no menu label defined\n")); - cerr<<"Row: "<<row<<endl; - } else { - Rootmenu *submenu = new Rootmenu(this); + if (! feof(submenufile)) { + fclose(submenufile); + ifstream subfile(newfile.c_str()); + if (! parseMenuFile(subfile, menu, row)) + Fluxbox::instance()->saveMenuFilename(newfile.c_str()); + } + } else + perror(newfile.c_str()); + } + } // end of else 'x' + } // end of include + else if (str_key == "submenu") { // sub + if (!str_label.size()) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenSUBMENUError, + "BScreen::parseMenuFile: [submenu] error, " + "no menu label defined\n")); + cerr<<"Row: "<<row<<endl; + } else { + Rootmenu *submenu = new Rootmenu(this); - if (str_cmd.size()) - submenu->setLabel(str_cmd.c_str()); - else - submenu->setLabel(str_label.c_str()); + if (str_cmd.size()) + submenu->setLabel(str_cmd.c_str()); + else + submenu->setLabel(str_label.c_str()); - parseMenuFile(file, submenu, row); - submenu->update(); - menu->insert(str_label.c_str(), submenu); - rootmenuList.push_back(submenu); + parseMenuFile(file, submenu, row); + submenu->update(); + menu->insert(str_label.c_str(), submenu); + rootmenuList.push_back(submenu); - } - } // end of sub - else if (str_key == "restart") { - if (!str_label.size()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenRESTARTError, - "BScreen::parseMenuFile: [restart] error, " - "no menu label defined\n")); - cerr<<"Row: "<<row<<endl; - } else { - if (str_cmd.size()) - menu->insert(str_label.c_str(), BScreen::RESTARTOTHER, str_cmd.c_str()); - else - menu->insert(str_label.c_str(), BScreen::RESTART); - } - } // end of restart - else if (str_key == "reconfig") { // reconf - if (!str_label.c_str()) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenRECONFIGError, - "BScreen::parseMenuFile: [reconfig] error, " - "no menu label defined\n")); - cerr<<"Row: "<<row<<endl; - } else - menu->insert(str_label.c_str(), BScreen::RECONFIGURE); - } // end of reconf - else if (str_key == "stylesdir" || str_key == "stylesmenu") { - bool newmenu = (str_key == "stylesmenu"); - if (!( str_label.size() && str_cmd.size()) && newmenu) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRError, - "BScreen::parseMenuFile: [stylesdir/stylesmenu]" - " error, no directory defined\n")); - cerr<<"Row: "<<row<<endl; - } else { // else 'y' - createStyleMenu(menu, newmenu, str_label.c_str(), (newmenu) ? str_cmd.c_str() : str_label.c_str()); - } // end of else 'y' - } // end of stylesdir - else if (str_key == "workspaces") { - if (!str_label.size()) { - fprintf(stderr, - i18n->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenWORKSPACESError, - "BScreen:parseMenuFile: [workspaces] error, " - "no menu label defined\n")); - cerr<<"Row: "<<row<<endl; - } else - menu->insert(str_label.c_str(), workspacemenu); - } // end of work - } - } - } + } + } // end of sub + else if (str_key == "restart") { + if (!str_label.size()) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenRESTARTError, + "BScreen::parseMenuFile: [restart] error, " + "no menu label defined\n")); + cerr<<"Row: "<<row<<endl; + } else { + if (str_cmd.size()) + menu->insert(str_label.c_str(), BScreen::RESTARTOTHER, str_cmd.c_str()); + else + menu->insert(str_label.c_str(), BScreen::RESTART); + } + } // end of restart + else if (str_key == "reconfig") { // reconf + if (!str_label.c_str()) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenRECONFIGError, + "BScreen::parseMenuFile: [reconfig] error, " + "no menu label defined\n")); + cerr<<"Row: "<<row<<endl; + } else + menu->insert(str_label.c_str(), BScreen::RECONFIGURE); + } // end of reconf + else if (str_key == "stylesdir" || str_key == "stylesmenu") { + bool newmenu = (str_key == "stylesmenu"); + if (!( str_label.size() && str_cmd.size()) && newmenu) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRError, + "BScreen::parseMenuFile: [stylesdir/stylesmenu]" + " error, no directory defined\n")); + cerr<<"Row: "<<row<<endl; + } else { // else 'y' + createStyleMenu(menu, newmenu, str_label.c_str(), (newmenu) ? str_cmd.c_str() : str_label.c_str()); + } // end of else 'y' + } // end of stylesdir + else if (str_key == "workspaces") { + if (!str_label.size()) { + fprintf(stderr, + i18n->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenWORKSPACESError, + "BScreen:parseMenuFile: [workspaces] error, " + "no menu label defined\n")); + cerr<<"Row: "<<row<<endl; + } else + menu->insert(str_label.c_str(), workspacemenu); + } // end of work + } + } + } - return ((menu->numberOfItems() == 0) ? true : false); + return ((menu->numberOfItems() == 0) ? true : false); } void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, const char *directory) { - // perform shell style ~ home directory expansion - string stylesdir(StringUtil::expandFilename(directory ? directory : "")); + // perform shell style ~ home directory expansion + string stylesdir(StringUtil::expandFilename(directory ? directory : "")); - I18n *i18n = I18n::instance(); - struct stat statbuf; + I18n *i18n = I18n::instance(); + struct stat statbuf; - if (! stat(stylesdir.c_str(), &statbuf)) { // stat - if (S_ISDIR(statbuf.st_mode)) { // dir - Rootmenu *stylesmenu; - if (newmenu) - stylesmenu = new Rootmenu(this); - else - stylesmenu = menu; + if (! stat(stylesdir.c_str(), &statbuf)) { // stat + if (S_ISDIR(statbuf.st_mode)) { // dir + Rootmenu *stylesmenu; + if (newmenu) + stylesmenu = new Rootmenu(this); + else + stylesmenu = menu; - DIR *d = opendir(stylesdir.c_str()); - int entries = 0; - struct dirent *p; + DIR *d = opendir(stylesdir.c_str()); + int entries = 0; + struct dirent *p; - // get the total number of directory entries - while ((p = readdir(d))) entries++; + // get the total number of directory entries + while ((p = readdir(d))) entries++; - rewinddir(d); + rewinddir(d); - char **ls = new char* [entries]; - int index = 0; - while ((p = readdir(d))) - ls[index++] = StringUtil::strdup(p->d_name); + char **ls = new char* [entries]; + int index = 0; + while ((p = readdir(d))) + ls[index++] = StringUtil::strdup(p->d_name); - qsort(ls, entries, sizeof(char *), dcmp); + qsort(ls, entries, sizeof(char *), dcmp); - int n, slen = strlen(stylesdir.c_str()); - for (n = 0; n < entries; n++) { // for - int nlen = strlen(ls[n]); - char style[MAXPATHLEN + 1]; - strncpy(style, stylesdir.c_str(), slen); - *(style + slen) = '/'; - strncpy(style + slen + 1, ls[n], nlen + 1); - if ((! stat(style, &statbuf)) && S_ISREG(statbuf.st_mode)) - stylesmenu->insert(ls[n], BScreen::SETSTYLE, style); - delete [] ls[n]; - } + int n, slen = strlen(stylesdir.c_str()); + for (n = 0; n < entries; n++) { // for + int nlen = strlen(ls[n]); + char style[MAXPATHLEN + 1]; + strncpy(style, stylesdir.c_str(), slen); + *(style + slen) = '/'; + strncpy(style + slen + 1, ls[n], nlen + 1); + if ((! stat(style, &statbuf)) && S_ISREG(statbuf.st_mode)) + stylesmenu->insert(ls[n], BScreen::SETSTYLE, style); + delete [] ls[n]; + } - delete [] ls; + delete [] ls; - stylesmenu->update(); - if (newmenu) { - stylesmenu->setLabel(label); - menu->insert(label, stylesmenu); - rootmenuList.push_back(stylesmenu); - } + stylesmenu->update(); + if (newmenu) { + stylesmenu->setLabel(label); + menu->insert(label, stylesmenu); + rootmenuList.push_back(stylesmenu); + } - Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); - } else { // dir - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNotDir, - "BScreen::parseMenuFile:" - " [stylesdir/stylesmenu] error, %s is not a" - " directory\n"), stylesdir.c_str()); - } // end of 'dir' - } else { // stat - fprintf(stderr, + Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); + } else { // dir + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNotDir, + "BScreen::parseMenuFile:" + " [stylesdir/stylesmenu] error, %s is not a" + " directory\n"), stylesdir.c_str()); + } // end of 'dir' + } else { // stat + fprintf(stderr, i18n-> getMessage( - FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNoExist, - "BScreen::parseMenuFile: [stylesdir/stylesmenu]" - " error, %s does not exist\n"), stylesdir.c_str()); - } // end of 'stat' + FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNoExist, + "BScreen::parseMenuFile: [stylesdir/stylesmenu]" + " error, %s does not exist\n"), stylesdir.c_str()); + } // end of 'stat' } void BScreen::shutdown() { - XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); - XSync(getBaseDisplay()->getXDisplay(), False); + XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); + XSync(getBaseDisplay()->getXDisplay(), False); - { - Workspaces::iterator it = workspacesList.begin(); - Workspaces::iterator it_end = workspacesList.end(); - for (; it != it_end; ++it) { - (*it)->shutdown(); - } - } + { + Workspaces::iterator it = workspacesList.begin(); + Workspaces::iterator it_end = workspacesList.end(); + for (; it != it_end; ++it) { + (*it)->shutdown(); + } + } - { - while (!iconList.empty()) { - iconList.back()->restore(true); // restore with remap - delete iconList.back(); // the window removes it self from iconlist - } - } + { + while (!iconList.empty()) { + iconList.back()->restore(true); // restore with remap + delete iconList.back(); // the window removes it self from iconlist + } + } - if (m_slit.get()) - m_slit->shutdown(); + if (m_slit.get()) + m_slit->shutdown(); } void BScreen::showPosition(int x, int y) { - if (! geom_visible) { + if (! geom_visible) { #ifdef XINERAMA - unsigned int head = hasXinerama() ? getCurrHead() : 0; + unsigned int head = hasXinerama() ? getCurrHead() : 0; - XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, - getHeadX(head) + (getHeadWidth(head) - geom_w) / 2, - getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h); + XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, + getHeadX(head) + (getHeadWidth(head) - geom_w) / 2, + getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h); #else // !XINERMA - XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, - (getWidth() - geom_w) / 2, - (getHeight() - geom_h) / 2, geom_w, geom_h); + XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, + (getWidth() - geom_w) / 2, + (getHeight() - geom_h) / 2, geom_w, geom_h); #endif // XINERAMA - XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); - XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window); + XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); + XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window); - geom_visible = true; - } - const int label_size = 1024; - char label[label_size]; + geom_visible = true; + } + const int label_size = 1024; + char label[label_size]; - snprintf(label, label_size, - I18n::instance()->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenPositionFormat, - "X: %4d x Y: %4d"), x, y); + snprintf(label, label_size, + I18n::instance()->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenPositionFormat, + "X: %4d x Y: %4d"), x, y); - XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); + XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); - theme->getWindowStyle().font.drawText( - geom_window, - getScreenNumber(), - theme->getWindowStyle().l_text_focus_gc, - label, strlen(label), - theme->getBevelWidth(), theme->getBevelWidth() + - theme->getWindowStyle().font.ascent()); + theme->getWindowStyle().font.drawText( + geom_window, + getScreenNumber(), + theme->getWindowStyle().l_text_focus_gc, + label, strlen(label), + theme->getBevelWidth(), theme->getBevelWidth() + + theme->getWindowStyle().font.ascent()); } void BScreen::showGeometry(unsigned int gx, unsigned int gy) { - if (! geom_visible) { + if (! geom_visible) { #ifdef XINERAMA - unsigned int head = hasXinerama() ? getCurrHead() : 0; + unsigned int head = hasXinerama() ? getCurrHead() : 0; - XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, - getHeadX(head) + (getHeadWidth(head) - geom_w) / 2, - getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h); + XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, + getHeadX(head) + (getHeadWidth(head) - geom_w) / 2, + getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h); #else // !XINERMA - XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, - (getWidth() - geom_w) / 2, - (getHeight() - geom_h) / 2, geom_w, geom_h); + XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, + (getWidth() - geom_w) / 2, + (getHeight() - geom_h) / 2, geom_w, geom_h); #endif // XINERAMA - XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); - XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window); + XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); + XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window); - geom_visible = true; - } + geom_visible = true; + } - char label[1024]; + char label[1024]; - sprintf(label, - I18n::instance()->getMessage( - FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat, - "W: %4d x H: %4d"), gx, gy); + sprintf(label, + I18n::instance()->getMessage( + FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat, + "W: %4d x H: %4d"), gx, gy); - XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); + XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); - //TODO: geom window again?! repeated - theme->getWindowStyle().font.drawText( - geom_window, - getScreenNumber(), - theme->getWindowStyle().l_text_focus_gc, - label, strlen(label), - theme->getBevelWidth(), theme->getBevelWidth() + - theme->getWindowStyle().font.ascent()); + //TODO: geom window again?! repeated + theme->getWindowStyle().font.drawText( + geom_window, + getScreenNumber(), + theme->getWindowStyle().l_text_focus_gc, + label, strlen(label), + theme->getBevelWidth(), theme->getBevelWidth() + + theme->getWindowStyle().font.ascent()); } void BScreen::hideGeometry() { - if (geom_visible) { - XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window); - geom_visible = false; - } + if (geom_visible) { + XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window); + geom_visible = false; + } } /** Goes to the workspace "right" of the current */ void BScreen::nextWorkspace(const int delta) { - changeWorkspaceID( (getCurrentWorkspaceID()+delta) % getCount()); + changeWorkspaceID( (getCurrentWorkspaceID()+delta) % getCount()); } /** Goes to the workspace "left" of the current */ void BScreen::prevWorkspace(const int delta) { - changeWorkspaceID( (getCurrentWorkspaceID()-delta+getCount()) % getCount()); + changeWorkspaceID( (getCurrentWorkspaceID()-delta+getCount()) % getCount()); } /** Goes to the workspace "right" of the current */ void BScreen::rightWorkspace(const int delta) { - if (getCurrentWorkspaceID()+delta < getCount()) - changeWorkspaceID(getCurrentWorkspaceID()+delta); + if (getCurrentWorkspaceID()+delta < getCount()) + changeWorkspaceID(getCurrentWorkspaceID()+delta); } /** Goes to the workspace "left" of the current */ void BScreen::leftWorkspace(const int delta) { - if (getCurrentWorkspaceID() >= static_cast<unsigned int>(delta)) - changeWorkspaceID(getCurrentWorkspaceID()-delta); + if (getCurrentWorkspaceID() >= static_cast<unsigned int>(delta)) + changeWorkspaceID(getCurrentWorkspaceID()-delta); } /** @return true if the windows should be skiped else false */ bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) { - return ((opts & CYCLESKIPSTUCK) != 0 && w->isStuck() || // skip if stuck - (opts & CYCLESKIPLOWERTABS) != 0 && w->isLowerTab() || // skip if lower tab - (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded + return ((opts & CYCLESKIPSTUCK) != 0 && w->isStuck() || // skip if stuck + (opts & CYCLESKIPLOWERTABS) != 0 && w->isLowerTab() || // skip if lower tab + (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded } /** Access and clear the auto-group window */ FluxboxWindow* BScreen::useAutoGroupWindow() { - Window w = auto_group_window; - auto_group_window = 0; - return w ? Fluxbox::instance()->searchWindow(w) : 0; + Window w = auto_group_window; + auto_group_window = 0; + return w ? Fluxbox::instance()->searchWindow(w) : 0; }
M src/Screen.hhsrc/Screen.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Screen.hh,v 1.52 2002/11/27 21:53:55 fluxgen Exp $ +// $Id: Screen.hh,v 1.53 2002/12/01 13:41:58 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH

@@ -53,253 +53,253 @@ class Slit;

class BScreen : public ScreenInfo { public: - typedef std::vector<Workspace *> Workspaces; - typedef std::vector<std::string> WorkspaceNames; + typedef std::vector<Workspace *> Workspaces; + typedef std::vector<std::string> WorkspaceNames; - BScreen(ResourceManager &rm, - const std::string &screenname, const std::string &altscreenname, - int scrn); - ~BScreen(); + BScreen(ResourceManager &rm, + const std::string &screenname, const std::string &altscreenname, + int scrn); + ~BScreen(); - inline bool isToolbarOnTop() const { return *resource.toolbar_on_top; } - inline bool doToolbarAutoHide() const { return *resource.toolbar_auto_hide; } - inline bool isSloppyFocus() const { return resource.sloppy_focus; } - inline bool isSemiSloppyFocus() const { return resource.semi_sloppy_focus; } - inline bool isRootColormapInstalled() const { return root_colormap_installed; } - inline bool isScreenManaged() const { return managed; } - inline bool isTabRotateVertical() const { return *resource.tab_rotate_vertical; } - inline bool isSloppyWindowGrouping() const { return *resource.sloppy_window_grouping; } - inline bool isWorkspaceWarping() const { return *resource.workspace_warping; } - inline bool isDesktopWheeling() const { return *resource.desktop_wheeling; } - inline bool doAutoRaise() const { return resource.auto_raise; } - inline bool doImageDither() const { return *resource.image_dither; } - inline bool doMaxOverSlit() const { return *resource.max_over_slit; } - inline bool doOpaqueMove() const { return *resource.opaque_move; } - inline bool doFullMax() const { return *resource.full_max; } - inline bool doFocusNew() const { return *resource.focus_new; } - inline bool doFocusLast() const { return *resource.focus_last; } - inline bool doShowWindowPos() const { return *resource.show_window_pos; } - bool antialias() const { return *resource.antialias; } - inline GC getOpGC() const { return theme->getOpGC(); } + inline bool isToolbarOnTop() const { return *resource.toolbar_on_top; } + inline bool doToolbarAutoHide() const { return *resource.toolbar_auto_hide; } + inline bool isSloppyFocus() const { return resource.sloppy_focus; } + inline bool isSemiSloppyFocus() const { return resource.semi_sloppy_focus; } + inline bool isRootColormapInstalled() const { return root_colormap_installed; } + inline bool isScreenManaged() const { return managed; } + inline bool isTabRotateVertical() const { return *resource.tab_rotate_vertical; } + inline bool isSloppyWindowGrouping() const { return *resource.sloppy_window_grouping; } + inline bool isWorkspaceWarping() const { return *resource.workspace_warping; } + inline bool isDesktopWheeling() const { return *resource.desktop_wheeling; } + inline bool doAutoRaise() const { return resource.auto_raise; } + inline bool doImageDither() const { return *resource.image_dither; } + inline bool doMaxOverSlit() const { return *resource.max_over_slit; } + inline bool doOpaqueMove() const { return *resource.opaque_move; } + inline bool doFullMax() const { return *resource.full_max; } + inline bool doFocusNew() const { return *resource.focus_new; } + inline bool doFocusLast() const { return *resource.focus_last; } + inline bool doShowWindowPos() const { return *resource.show_window_pos; } + bool antialias() const { return *resource.antialias; } + inline GC getOpGC() const { return theme->getOpGC(); } - inline const FbTk::Color *getBorderColor() const { return &theme->getBorderColor(); } - inline BImageControl *getImageControl() { return image_control; } - const Rootmenu * const getRootmenu() const { return rootmenu; } - Rootmenu * const getRootmenu() { return rootmenu; } + inline const FbTk::Color *getBorderColor() const { return &theme->getBorderColor(); } + inline BImageControl *getImageControl() { return image_control; } + const Rootmenu * const getRootmenu() const { return rootmenu; } + Rootmenu * const getRootmenu() { return rootmenu; } - inline const std::string &getRootCommand() const { return *resource.rootcommand; } + inline const std::string &getRootCommand() const { return *resource.rootcommand; } - inline bool isSlitOnTop() const { return resource.slit_on_top; } - inline bool doSlitAutoHide() const { return resource.slit_auto_hide; } - inline Slit *getSlit() { return m_slit.get(); } - inline const Slit *getSlit() const { return m_slit.get(); } - inline int getSlitPlacement() const { return resource.slit_placement; } - inline int getSlitDirection() const { return resource.slit_direction; } - inline void saveSlitPlacement(int p) { resource.slit_placement = p; } - inline void saveSlitDirection(int d) { resource.slit_direction = d; } - inline void saveSlitOnTop(bool t) { resource.slit_on_top = t; } - inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } + inline bool isSlitOnTop() const { return resource.slit_on_top; } + inline bool doSlitAutoHide() const { return resource.slit_auto_hide; } + inline Slit *getSlit() { return m_slit.get(); } + inline const Slit *getSlit() const { return m_slit.get(); } + inline int getSlitPlacement() const { return resource.slit_placement; } + inline int getSlitDirection() const { return resource.slit_direction; } + inline void saveSlitPlacement(int p) { resource.slit_placement = p; } + inline void saveSlitDirection(int d) { resource.slit_direction = d; } + inline void saveSlitOnTop(bool t) { resource.slit_on_top = t; } + inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } - inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } - inline void saveSlitOnHead(unsigned int h) { resource.slit_on_head = h; } + inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } + inline void saveSlitOnHead(unsigned int h) { resource.slit_on_head = h; } - inline const Toolbar * const getToolbar() const { return m_toolbar.get(); } - inline Toolbar * const getToolbar() { return m_toolbar.get(); } + inline const Toolbar * const getToolbar() const { return m_toolbar.get(); } + inline Toolbar * const getToolbar() { return m_toolbar.get(); } - inline Workspace *getWorkspace(unsigned int w) { return ( w < workspacesList.size() ? workspacesList[w] : 0); } - inline Workspace *getCurrentWorkspace() { return current_workspace; } + inline Workspace *getWorkspace(unsigned int w) { return ( w < workspacesList.size() ? workspacesList[w] : 0); } + inline Workspace *getCurrentWorkspace() { return current_workspace; } - const Workspacemenu * const getWorkspacemenu() const { return workspacemenu; } - Workspacemenu * const getWorkspacemenu() { return workspacemenu; } + const Workspacemenu * const getWorkspacemenu() const { return workspacemenu; } + Workspacemenu * const getWorkspacemenu() { return workspacemenu; } - inline unsigned int getHandleWidth() const { return theme->getHandleWidth(); } - inline unsigned int getBevelWidth() const { return theme->getBevelWidth(); } - inline unsigned int getFrameWidth() const { return theme->getFrameWidth(); } - inline unsigned int getBorderWidth() const { return theme->getBorderWidth(); } - inline unsigned int getBorderWidth2x() const { return theme->getBorderWidth()*2; } - inline unsigned int getCurrentWorkspaceID() const { return current_workspace->workspaceID(); } + inline unsigned int getHandleWidth() const { return theme->getHandleWidth(); } + inline unsigned int getBevelWidth() const { return theme->getBevelWidth(); } + inline unsigned int getFrameWidth() const { return theme->getFrameWidth(); } + inline unsigned int getBorderWidth() const { return theme->getBorderWidth(); } + inline unsigned int getBorderWidth2x() const { return theme->getBorderWidth()*2; } + inline unsigned int getCurrentWorkspaceID() const { return current_workspace->workspaceID(); } typedef std::vector<FluxboxWindow *> Icons; - /// @return number of workspaces - inline unsigned int getCount() const { return workspacesList.size(); } - /// @return number of icons - inline unsigned int getIconCount() const { return iconList.size(); } - inline const Icons &getIconList() const { return iconList; } - inline Icons &getIconList() { return iconList; } - const Workspaces &getWorkspacesList() const { return workspacesList; } - const WorkspaceNames &getWorkspaceNames() const { return workspaceNames; } + /// @return number of workspaces + inline unsigned int getCount() const { return workspacesList.size(); } + /// @return number of icons + inline unsigned int getIconCount() const { return iconList.size(); } + inline const Icons &getIconList() const { return iconList; } + inline Icons &getIconList() { return iconList; } + const Workspaces &getWorkspacesList() const { return workspacesList; } + const WorkspaceNames &getWorkspaceNames() const { return workspaceNames; } - /// client list signal - FbTk::Subject &clientListSig() { return m_clientlist_sig; } - /// workspace count signal - FbTk::Subject &workspaceCountSig() { return m_workspacecount_sig; } - /// workspace names signal - FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; } - /// current workspace signal - FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; } + /// client list signal + FbTk::Subject &clientListSig() { return m_clientlist_sig; } + /// workspace count signal + FbTk::Subject &workspaceCountSig() { return m_workspacecount_sig; } + /// workspace names signal + FbTk::Subject &workspaceNamesSig() { return m_workspacenames_sig; } + /// current workspace signal + FbTk::Subject &currentWorkspaceSig() { return m_currentworkspace_sig; } - /// @return the resource value of number of workspace - inline int getNumberOfWorkspaces() const { return *resource.workspaces; } - inline Toolbar::Placement getToolbarPlacement() const { return *resource.toolbar_placement; } + /// @return the resource value of number of workspace + inline int getNumberOfWorkspaces() const { return *resource.workspaces; } + inline Toolbar::Placement getToolbarPlacement() const { return *resource.toolbar_placement; } - inline int getToolbarOnHead() { return *resource.toolbar_on_head; } + inline int getToolbarOnHead() { return *resource.toolbar_on_head; } - inline int getToolbarWidthPercent() const { return *resource.toolbar_width_percent; } - inline int getPlacementPolicy() const { return resource.placement_policy; } - inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } - inline int getRowPlacementDirection() const { return resource.row_direction; } - inline int getColPlacementDirection() const { return resource.col_direction; } - inline unsigned int getTabWidth() const { return *resource.tab_width; } - inline unsigned int getTabHeight() const { return *resource.tab_height; } - inline Tab::Placement getTabPlacement() const { return *resource.tab_placement; } - inline Tab::Alignment getTabAlignment() const { return *resource.tab_alignment; } + inline int getToolbarWidthPercent() const { return *resource.toolbar_width_percent; } + inline int getPlacementPolicy() const { return resource.placement_policy; } + inline int getEdgeSnapThreshold() const { return *resource.edge_snap_threshold; } + inline int getRowPlacementDirection() const { return resource.row_direction; } + inline int getColPlacementDirection() const { return resource.col_direction; } + inline unsigned int getTabWidth() const { return *resource.tab_width; } + inline unsigned int getTabHeight() const { return *resource.tab_height; } + inline Tab::Placement getTabPlacement() const { return *resource.tab_placement; } + inline Tab::Alignment getTabAlignment() const { return *resource.tab_alignment; } - inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; } - inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } - inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; } - inline void saveSemiSloppyFocus(bool s) { resource.semi_sloppy_focus = s; } - inline void saveAutoRaise(bool a) { resource.auto_raise = a; } - inline void saveWorkspaces(int w) { *resource.workspaces = w; } - inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; } - inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } - inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } - inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; } + inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; } + inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } + inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; } + inline void saveSemiSloppyFocus(bool s) { resource.semi_sloppy_focus = s; } + inline void saveAutoRaise(bool a) { resource.auto_raise = a; } + inline void saveWorkspaces(int w) { *resource.workspaces = w; } + inline void saveToolbarOnTop(bool r) { *resource.toolbar_on_top = r; } + inline void saveToolbarAutoHide(bool r) { *resource.toolbar_auto_hide = r; } + inline void saveToolbarWidthPercent(int w) { *resource.toolbar_width_percent = w; } + inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; } - inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; } + inline void saveToolbarOnHead(int head) { *resource.toolbar_on_head = head; } - inline void savePlacementPolicy(int p) { resource.placement_policy = p; } - inline void saveRowPlacementDirection(int d) { resource.row_direction = d; } - inline void saveColPlacementDirection(int d) { resource.col_direction = d; } - inline void saveEdgeSnapThreshold(int t) { resource.edge_snap_threshold = t; } - inline void saveImageDither(bool d) { resource.image_dither = d; } - inline void saveMaxOverSlit(bool m) { resource.max_over_slit = m; } - inline void saveOpaqueMove(bool o) { resource.opaque_move = o; } - inline void saveFullMax(bool f) { resource.full_max = f; } - inline void saveFocusNew(bool f) { resource.focus_new = f; } - inline void saveFocusLast(bool f) { resource.focus_last = f; } - inline void saveTabWidth(unsigned int w) { resource.tab_width = w; } - inline void saveTabHeight(unsigned int h) { resource.tab_height = h; } - inline void saveTabPlacement(Tab::Placement p) { *resource.tab_placement = p; } - inline void saveTabAlignment(Tab::Alignment a) { *resource.tab_alignment = a; } - inline void saveTabRotateVertical(bool r) { resource.tab_rotate_vertical = r; } - inline void saveSloppyWindowGrouping(bool s) { resource.sloppy_window_grouping = s; } - inline void saveWorkspaceWarping(bool s) { resource.workspace_warping = s; } - inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; } - void iconUpdate(); - inline const Iconmenu *getIconmenu() const { return m_iconmenu; } - inline void setAutoGroupWindow(Window w = 0) { auto_group_window = w; } - void setAntialias(bool value); + inline void savePlacementPolicy(int p) { resource.placement_policy = p; } + inline void saveRowPlacementDirection(int d) { resource.row_direction = d; } + inline void saveColPlacementDirection(int d) { resource.col_direction = d; } + inline void saveEdgeSnapThreshold(int t) { resource.edge_snap_threshold = t; } + inline void saveImageDither(bool d) { resource.image_dither = d; } + inline void saveMaxOverSlit(bool m) { resource.max_over_slit = m; } + inline void saveOpaqueMove(bool o) { resource.opaque_move = o; } + inline void saveFullMax(bool f) { resource.full_max = f; } + inline void saveFocusNew(bool f) { resource.focus_new = f; } + inline void saveFocusLast(bool f) { resource.focus_last = f; } + inline void saveTabWidth(unsigned int w) { resource.tab_width = w; } + inline void saveTabHeight(unsigned int h) { resource.tab_height = h; } + inline void saveTabPlacement(Tab::Placement p) { *resource.tab_placement = p; } + inline void saveTabAlignment(Tab::Alignment a) { *resource.tab_alignment = a; } + inline void saveTabRotateVertical(bool r) { resource.tab_rotate_vertical = r; } + inline void saveSloppyWindowGrouping(bool s) { resource.sloppy_window_grouping = s; } + inline void saveWorkspaceWarping(bool s) { resource.workspace_warping = s; } + inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; } + void iconUpdate(); + inline const Iconmenu *getIconmenu() const { return m_iconmenu; } + inline void setAutoGroupWindow(Window w = 0) { auto_group_window = w; } + void setAntialias(bool value); - inline const char *getStrftimeFormat() { return resource.strftime_format.c_str(); } - void saveStrftimeFormat(const char *format); + inline const char *getStrftimeFormat() { return resource.strftime_format.c_str(); } + void saveStrftimeFormat(const char *format); - inline int getDateFormat() { return resource.date_format; } - inline void saveDateFormat(int f) { resource.date_format = f; } - inline bool isClock24Hour() { return resource.clock24hour; } - inline void saveClock24Hour(bool c) { resource.clock24hour = c; } + inline int getDateFormat() { return resource.date_format; } + inline void saveDateFormat(int f) { resource.date_format = f; } + inline bool isClock24Hour() { return resource.clock24hour; } + inline void saveClock24Hour(bool c) { resource.clock24hour = c; } - inline Theme::WindowStyle *getWindowStyle() { return &theme->getWindowStyle(); } - inline Theme::MenuStyle *getMenuStyle() { return &theme->getMenuStyle(); } - inline Theme::ToolbarStyle *getToolbarStyle() { return &theme->getToolbarStyle(); } - const Theme *getTheme() const { return theme; } - FluxboxWindow *getIcon(unsigned int index); + inline Theme::WindowStyle *getWindowStyle() { return &theme->getWindowStyle(); } + inline Theme::MenuStyle *getMenuStyle() { return &theme->getMenuStyle(); } + inline Theme::ToolbarStyle *getToolbarStyle() { return &theme->getToolbarStyle(); } + const Theme *getTheme() const { return theme; } + FluxboxWindow *getIcon(unsigned int index); - int addWorkspace(); - int removeLastWorkspace(); - //scroll workspaces - void nextWorkspace(const int delta); - void prevWorkspace(const int delta); - void rightWorkspace(const int delta); - void leftWorkspace(const int delta); + int addWorkspace(); + int removeLastWorkspace(); + //scroll workspaces + void nextWorkspace(const int delta); + void prevWorkspace(const int delta); + void rightWorkspace(const int delta); + void leftWorkspace(const int delta); - void removeWorkspaceNames(); - void updateWorkspaceNamesAtom(); + void removeWorkspaceNames(); + void updateWorkspaceNamesAtom(); - void addWorkspaceName(const char *name); - void addNetizen(Netizen *net); - void removeNetizen(Window win); - void addIcon(FluxboxWindow *win); - void removeIcon(FluxboxWindow *win); - // remove window - void removeWindow(FluxboxWindow *win); + void addWorkspaceName(const char *name); + void addNetizen(Netizen *net); + void removeNetizen(Window win); + void addIcon(FluxboxWindow *win); + void removeIcon(FluxboxWindow *win); + // remove window + void removeWindow(FluxboxWindow *win); - std::string getNameOfWorkspace(unsigned int workspace) const; - void changeWorkspaceID(unsigned int); - void sendToWorkspace(unsigned int workspace, FluxboxWindow *win=0, bool changeworkspace=true); - void raiseWindows(const Workspace::Stack &workspace_stack); - void reassociateGroup(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); - void reassociateWindow(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); - void prevFocus(int = 0); - void nextFocus(int = 0); - void raiseFocus(); - void reconfigure(); - void rereadMenu(); - void shutdown(); - void showPosition(int x, int y); - void showGeometry(unsigned int, unsigned int); - void hideGeometry(); + std::string getNameOfWorkspace(unsigned int workspace) const; + void changeWorkspaceID(unsigned int); + void sendToWorkspace(unsigned int workspace, FluxboxWindow *win=0, bool changeworkspace=true); + void raiseWindows(const Workspace::Stack &workspace_stack); + void reassociateGroup(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); + void reassociateWindow(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); + void prevFocus(int = 0); + void nextFocus(int = 0); + void raiseFocus(); + void reconfigure(); + void rereadMenu(); + void shutdown(); + void showPosition(int x, int y); + void showGeometry(unsigned int, unsigned int); + void hideGeometry(); - FluxboxWindow* useAutoGroupWindow(); + FluxboxWindow* useAutoGroupWindow(); - void updateNetizenCurrentWorkspace(); - void updateNetizenWorkspaceCount(); - void updateNetizenWindowFocus(); - void updateNetizenWindowAdd(Window, unsigned long); - void updateNetizenWindowDel(Window); - void updateNetizenConfigNotify(XEvent *); - void updateNetizenWindowRaise(Window); - void updateNetizenWindowLower(Window); + void updateNetizenCurrentWorkspace(); + void updateNetizenWorkspaceCount(); + void updateNetizenWindowFocus(); + void updateNetizenWindowAdd(Window, unsigned long); + void updateNetizenWindowDel(Window); + void updateNetizenConfigNotify(XEvent *); + void updateNetizenWindowRaise(Window); + void updateNetizenWindowLower(Window); - enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT, LEFTRIGHT, - RIGHTLEFT, TOPBOTTOM, BOTTOMTOP }; - enum { LEFTJUSTIFY = 1, RIGHTJUSTIFY, CENTERJUSTIFY }; - enum { ROUNDBULLET = 1, TRIANGELBULLET, SQUAERBULLET, NOBULLET }; - enum { RESTART = 1, RESTARTOTHER, EXIT, SHUTDOWN, EXECUTE, RECONFIGURE, - WINDOWSHADE, WINDOWICONIFY, WINDOWMAXIMIZE, WINDOWCLOSE, WINDOWRAISE, - WINDOWLOWER, WINDOWSTICK, WINDOWKILL, SETSTYLE, WINDOWTAB}; - // prevFocus/nextFocus option bits - enum { CYCLESKIPLOWERTABS = 0x01, CYCLESKIPSTUCK = 0x02, CYCLESKIPSHADED = 0x04, - CYCLEDEFAULT = 0x00 }; + enum { ROWSMARTPLACEMENT = 1, COLSMARTPLACEMENT, CASCADEPLACEMENT, LEFTRIGHT, + RIGHTLEFT, TOPBOTTOM, BOTTOMTOP }; + enum { LEFTJUSTIFY = 1, RIGHTJUSTIFY, CENTERJUSTIFY }; + enum { ROUNDBULLET = 1, TRIANGELBULLET, SQUAERBULLET, NOBULLET }; + enum { RESTART = 1, RESTARTOTHER, EXIT, SHUTDOWN, EXECUTE, RECONFIGURE, + WINDOWSHADE, WINDOWICONIFY, WINDOWMAXIMIZE, WINDOWCLOSE, WINDOWRAISE, + WINDOWLOWER, WINDOWSTICK, WINDOWKILL, SETSTYLE, WINDOWTAB}; + // prevFocus/nextFocus option bits + enum { CYCLESKIPLOWERTABS = 0x01, CYCLESKIPSTUCK = 0x02, CYCLESKIPSHADED = 0x04, + CYCLEDEFAULT = 0x00 }; - class ScreenSubject:public FbTk::Subject { - public: - ScreenSubject(BScreen &scr):m_scr(scr) { } - const BScreen &screen() const { return m_scr; } - BScreen &screen() { return m_scr; } - private: - BScreen &m_scr; - }; + class ScreenSubject:public FbTk::Subject { + public: + ScreenSubject(BScreen &scr):m_scr(scr) { } + const BScreen &screen() const { return m_scr; } + BScreen &screen() { return m_scr; } + private: + BScreen &m_scr; + }; private: - void createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, const char *directory); + void createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, const char *directory); - bool parseMenuFile(std::ifstream &, Rootmenu *, int&); + bool parseMenuFile(std::ifstream &, Rootmenu *, int&); - void initMenu(); + void initMenu(); - bool doSkipWindow(const FluxboxWindow *w, int options); + bool doSkipWindow(const FluxboxWindow *w, int options); - ScreenSubject - m_clientlist_sig, ///< client signal - m_workspacecount_sig, ///< workspace count signal - m_workspacenames_sig, ///< workspace names signal - m_currentworkspace_sig; ///< current workspace signal + ScreenSubject + m_clientlist_sig, ///< client signal + m_workspacecount_sig, ///< workspace count signal + m_workspacenames_sig, ///< workspace names signal + m_currentworkspace_sig; ///< current workspace signal - Theme *theme; + Theme *theme; - Bool root_colormap_installed, managed, geom_visible; - GC opGC; - Pixmap geom_pixmap; - Window geom_window; + Bool root_colormap_installed, managed, geom_visible; + GC opGC; + Pixmap geom_pixmap; + Window geom_window; - BImageControl *image_control; - Configmenu *configmenu; - Iconmenu *m_iconmenu; + BImageControl *image_control; + Configmenu *configmenu; + Iconmenu *m_iconmenu; - Rootmenu *rootmenu; + Rootmenu *rootmenu; typedef std::list<Rootmenu *> Rootmenus; typedef std::list<Netizen *> Netizens;

@@ -308,58 +308,58 @@ Rootmenus rootmenuList;

Netizens netizenList; Icons iconList; - std::auto_ptr<Slit> m_slit; + std::auto_ptr<Slit> m_slit; - std::auto_ptr<Toolbar> m_toolbar; - Workspace *current_workspace; - Workspacemenu *workspacemenu; + std::auto_ptr<Toolbar> m_toolbar; + Workspace *current_workspace; + Workspacemenu *workspacemenu; - unsigned int geom_w, geom_h; - unsigned long event_mask; + unsigned int geom_w, geom_h; + unsigned long event_mask; WorkspaceNames workspaceNames; Workspaces workspacesList; - Window auto_group_window; + Window auto_group_window; - struct ScreenResource { - ScreenResource(ResourceManager &rm, const std::string &scrname, - const std::string &altscrname); + struct ScreenResource { + ScreenResource(ResourceManager &rm, const std::string &scrname, + const std::string &altscrname); - Resource<bool> toolbar_on_top, toolbar_auto_hide, - image_dither, opaque_move, full_max, - max_over_slit, tab_rotate_vertical, - sloppy_window_grouping, workspace_warping, - desktop_wheeling, show_window_pos, - focus_last, focus_new, - antialias; - Resource<std::string> rootcommand; - bool auto_raise, sloppy_focus, semi_sloppy_focus, - ordered_dither; - Resource<int> workspaces, toolbar_width_percent, edge_snap_threshold, - tab_width, tab_height; - int placement_policy, row_direction, col_direction; + Resource<bool> toolbar_on_top, toolbar_auto_hide, + image_dither, opaque_move, full_max, + max_over_slit, tab_rotate_vertical, + sloppy_window_grouping, workspace_warping, + desktop_wheeling, show_window_pos, + focus_last, focus_new, + antialias; + Resource<std::string> rootcommand; + bool auto_raise, sloppy_focus, semi_sloppy_focus, + ordered_dither; + Resource<int> workspaces, toolbar_width_percent, edge_snap_threshold, + tab_width, tab_height; + int placement_policy, row_direction, col_direction; - Resource<Tab::Placement> tab_placement; - Resource<Tab::Alignment> tab_alignment; - Resource<int> toolbar_on_head; + Resource<Tab::Placement> tab_placement; + Resource<Tab::Alignment> tab_alignment; + Resource<int> toolbar_on_head; - Resource<Toolbar::Placement> toolbar_placement; + Resource<Toolbar::Placement> toolbar_placement; - bool slit_on_top, slit_auto_hide; - int slit_placement, slit_direction; + bool slit_on_top, slit_auto_hide; + int slit_placement, slit_direction; - unsigned int slit_on_head; + unsigned int slit_on_head; - std::string strftime_format; + std::string strftime_format; - bool clock24hour; - int date_format; + bool clock24hour; + int date_format; - } resource; + } resource; };
M src/Slit.ccsrc/Slit.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Slit.cc,v 1.29 2002/11/30 20:28:32 fluxgen Exp $ +// $Id: Slit.cc,v 1.30 2002/12/01 13:41:59 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -57,835 +57,835 @@ // Utility method for extracting name from window

namespace { void getWMName(BScreen *screen, Window window, std::string& name) { - name = ""; + name = ""; - if (screen == 0 || window == None) - return; + if (screen == 0 || window == None) + return; - Display *display = BaseDisplay::getXDisplay(); + Display *display = BaseDisplay::getXDisplay(); - XTextProperty text_prop; - char **list; - int num; - I18n *i18n = I18n::instance(); + XTextProperty text_prop; + char **list; + int num; + I18n *i18n = I18n::instance(); - if (XGetWMName(display, window, &text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding != XA_STRING) { + if (XGetWMName(display, window, &text_prop)) { + if (text_prop.value && text_prop.nitems > 0) { + if (text_prop.encoding != XA_STRING) { - text_prop.nitems = strlen((char *) text_prop.value); + text_prop.nitems = strlen((char *) text_prop.value); - if ((XmbTextPropertyToTextList(display, &text_prop, - &list, &num) == Success) && - (num > 0) && *list) { - name = static_cast<char *>(*list); - XFreeStringList(list); - } else - name = (char *)text_prop.value; + if ((XmbTextPropertyToTextList(display, &text_prop, + &list, &num) == Success) && + (num > 0) && *list) { + name = static_cast<char *>(*list); + XFreeStringList(list); + } else + name = (char *)text_prop.value; - } else - name = (char *)text_prop.value; - } else { // default name - name = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - } else { - // default name - name = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } + } else + name = (char *)text_prop.value; + } else { // default name + name = i18n->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnnamed, + "Unnamed"); + } + } else { + // default name + name = i18n->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnnamed, + "Unnamed"); + } } }; // End anonymous namespace Slit::Slit(BScreen *scr):m_screen(scr), timer(this), slitmenu(*this) { - assert(scr); - Fluxbox * const fluxbox = Fluxbox::instance(); + assert(scr); + Fluxbox * const fluxbox = Fluxbox::instance(); - on_top = screen()->isSlitOnTop(); - hidden = do_auto_hide = screen()->doSlitAutoHide(); + on_top = screen()->isSlitOnTop(); + hidden = do_auto_hide = screen()->doSlitAutoHide(); - frame.window = frame.pixmap = None; + frame.window = frame.pixmap = None; - timer.setTimeout(fluxbox->getAutoRaiseDelay()); - timer.fireOnce(True); + timer.setTimeout(fluxbox->getAutoRaiseDelay()); + timer.fireOnce(True); - XSetWindowAttributes attrib; - unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - screen()->getBorderColor()->pixel(); - attrib.colormap = screen()->colormap(); - attrib.override_redirect = True; - attrib.event_mask = SubstructureRedirectMask | ButtonPressMask | - EnterWindowMask | LeaveWindowMask; + XSetWindowAttributes attrib; + unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | + CWColormap | CWOverrideRedirect | CWEventMask; + attrib.background_pixmap = None; + attrib.background_pixel = attrib.border_pixel = + screen()->getBorderColor()->pixel(); + attrib.colormap = screen()->colormap(); + attrib.override_redirect = True; + attrib.event_mask = SubstructureRedirectMask | ButtonPressMask | + EnterWindowMask | LeaveWindowMask; - frame.x = frame.y = 0; - frame.width = frame.height = 1; + frame.x = frame.y = 0; + frame.width = frame.height = 1; - frame.window = - XCreateWindow(BaseDisplay::getXDisplay(), screen()->getRootWindow(), frame.x, frame.y, - frame.width, frame.height, screen()->getBorderWidth(), - screen()->getDepth(), InputOutput, screen()->getVisual(), - create_mask, &attrib); - fluxbox->saveSlitSearch(frame.window, this); + frame.window = + XCreateWindow(BaseDisplay::getXDisplay(), screen()->getRootWindow(), frame.x, frame.y, + frame.width, frame.height, screen()->getBorderWidth(), + screen()->getDepth(), InputOutput, screen()->getVisual(), + create_mask, &attrib); + fluxbox->saveSlitSearch(frame.window, this); - // Get client list for sorting purposes - loadClientList(); + // Get client list for sorting purposes + loadClientList(); - reconfigure(); + reconfigure(); } Slit::~Slit() { - screen()->getImageControl()->removeImage(frame.pixmap); + screen()->getImageControl()->removeImage(frame.pixmap); - Fluxbox::instance()->removeSlitSearch(frame.window); + Fluxbox::instance()->removeSlitSearch(frame.window); - XDestroyWindow(BaseDisplay::getXDisplay(), frame.window); + XDestroyWindow(BaseDisplay::getXDisplay(), frame.window); } void Slit::addClient(Window w) { - //Can't add non existent window - if (w == None) - return; + //Can't add non existent window + if (w == None) + return; - if (!Fluxbox::instance()->validateWindow(w)) - return; + if (!Fluxbox::instance()->validateWindow(w)) + return; - // Look for slot in client list by name - SlitClient *client = 0; - std::string match_name; - ::getWMName(screen(), w, match_name); - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - bool found_match = false; - for (; it != it_end; ++it) { - // If the name matches... - if ((*it)->match_name == match_name) { - // Use the slot if no window is assigned - if ((*it)->window == None) { - client = (*it); - client->initialize(screen(), w); - break; - } - // Otherwise keep looking for an unused match or a non-match - found_match = true; // Possibly redundant + // Look for slot in client list by name + SlitClient *client = 0; + std::string match_name; + ::getWMName(screen(), w, match_name); + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + bool found_match = false; + for (; it != it_end; ++it) { + // If the name matches... + if ((*it)->match_name == match_name) { + // Use the slot if no window is assigned + if ((*it)->window == None) { + client = (*it); + client->initialize(screen(), w); + break; + } + // Otherwise keep looking for an unused match or a non-match + found_match = true; // Possibly redundant - } else if (found_match) { - // Insert before first non-match after a previously found match? - client = new SlitClient(screen(), w); - clientList.insert(it, client); - break; - } - } - // Append to client list? - if (client == 0) { - client = new SlitClient(screen(), w); - clientList.push_back(client); - } - Display *disp = BaseDisplay::getXDisplay(); - XWMHints *wmhints = XGetWMHints(disp, w); + } else if (found_match) { + // Insert before first non-match after a previously found match? + client = new SlitClient(screen(), w); + clientList.insert(it, client); + break; + } + } + // Append to client list? + if (client == 0) { + client = new SlitClient(screen(), w); + clientList.push_back(client); + } + Display *disp = BaseDisplay::getXDisplay(); + XWMHints *wmhints = XGetWMHints(disp, w); - if (wmhints) { - if ((wmhints->flags & IconWindowHint) && - (wmhints->icon_window != None)) { - XMoveWindow(disp, client->client_window, screen()->getWidth() + 10, - screen()->getHeight() + 10); - XMapWindow(disp, client->client_window); - client->icon_window = wmhints->icon_window; - client->window = client->icon_window; - } else { - client->icon_window = None; - client->window = client->client_window; - } + if (wmhints) { + if ((wmhints->flags & IconWindowHint) && + (wmhints->icon_window != None)) { + XMoveWindow(disp, client->client_window, screen()->getWidth() + 10, + screen()->getHeight() + 10); + XMapWindow(disp, client->client_window); + client->icon_window = wmhints->icon_window; + client->window = client->icon_window; + } else { + client->icon_window = None; + client->window = client->client_window; + } - XFree(wmhints); - } else { - client->icon_window = None; - client->window = client->client_window; - } - XWindowAttributes attrib; + XFree(wmhints); + } else { + client->icon_window = None; + client->window = client->client_window; + } + XWindowAttributes attrib; #ifdef KDE - Fluxbox *fluxbox = Fluxbox::instance(); - //Check and see if new client is a KDE dock applet - //If so force reasonable size - bool iskdedockapp=false; - Atom ajunk; - int ijunk; - unsigned long *data = (unsigned long *) 0, uljunk; + Fluxbox *fluxbox = Fluxbox::instance(); + //Check and see if new client is a KDE dock applet + //If so force reasonable size + bool iskdedockapp=false; + Atom ajunk; + int ijunk; + unsigned long *data = (unsigned long *) 0, uljunk; - // Check if KDE v2.x dock applet - if (XGetWindowProperty(disp, w, - fluxbox->getKWM2DockwindowAtom(), 0l, 1l, False, - fluxbox->getKWM2DockwindowAtom(), - &ajunk, &ijunk, &uljunk, &uljunk, - (unsigned char **) &data) == Success) { - iskdedockapp = (data && data[0] != 0); - XFree((char *) data); - } + // Check if KDE v2.x dock applet + if (XGetWindowProperty(disp, w, + fluxbox->getKWM2DockwindowAtom(), 0l, 1l, False, + fluxbox->getKWM2DockwindowAtom(), + &ajunk, &ijunk, &uljunk, &uljunk, + (unsigned char **) &data) == Success) { + iskdedockapp = (data && data[0] != 0); + XFree((char *) data); + } - // Check if KDE v1.x dock applet - if (!iskdedockapp) { - if (XGetWindowProperty(disp, w, - fluxbox->getKWM1DockwindowAtom(), 0l, 1l, False, - fluxbox->getKWM1DockwindowAtom(), - &ajunk, &ijunk, &uljunk, &uljunk, - (unsigned char **) &data) == Success) { - iskdedockapp = (data && data[0] != 0); - XFree((char *) data); - } - } + // Check if KDE v1.x dock applet + if (!iskdedockapp) { + if (XGetWindowProperty(disp, w, + fluxbox->getKWM1DockwindowAtom(), 0l, 1l, False, + fluxbox->getKWM1DockwindowAtom(), + &ajunk, &ijunk, &uljunk, &uljunk, + (unsigned char **) &data) == Success) { + iskdedockapp = (data && data[0] != 0); + XFree((char *) data); + } + } - if (iskdedockapp) - client->width = client->height = 24; - else + if (iskdedockapp) + client->width = client->height = 24; + else #endif // KDE { - if (XGetWindowAttributes(disp, client->window, &attrib)) { - client->width = attrib.width; - client->height = attrib.height; - } else { - client->width = client->height = 64; - } + if (XGetWindowAttributes(disp, client->window, &attrib)) { + client->width = attrib.width; + client->height = attrib.height; + } else { + client->width = client->height = 64; + } } - XSetWindowBorderWidth(disp, client->window, 0); + XSetWindowBorderWidth(disp, client->window, 0); - XSelectInput(disp, frame.window, NoEventMask); - XSelectInput(disp, client->window, NoEventMask); + XSelectInput(disp, frame.window, NoEventMask); + XSelectInput(disp, client->window, NoEventMask); - XReparentWindow(disp, client->window, frame.window, 0, 0); - XMapRaised(disp, client->window); - XChangeSaveSet(disp, client->window, SetModeInsert); + XReparentWindow(disp, client->window, frame.window, 0, 0); + XMapRaised(disp, client->window); + XChangeSaveSet(disp, client->window, SetModeInsert); - XSelectInput(disp, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); - XSelectInput(disp, client->window, StructureNotifyMask | - SubstructureNotifyMask | EnterWindowMask); - XFlush(disp); + XSelectInput(disp, frame.window, SubstructureRedirectMask | + ButtonPressMask | EnterWindowMask | LeaveWindowMask); + XSelectInput(disp, client->window, StructureNotifyMask | + SubstructureNotifyMask | EnterWindowMask); + XFlush(disp); - Fluxbox::instance()->saveSlitSearch(client->client_window, this); - Fluxbox::instance()->saveSlitSearch(client->icon_window, this); - reconfigure(); + Fluxbox::instance()->saveSlitSearch(client->client_window, this); + Fluxbox::instance()->saveSlitSearch(client->icon_window, this); + reconfigure(); - saveClientList(); + saveClientList(); } void Slit::removeClient(SlitClient *client, bool remap, bool destroy) { - Fluxbox::instance()->removeSlitSearch(client->client_window); - Fluxbox::instance()->removeSlitSearch(client->icon_window); + Fluxbox::instance()->removeSlitSearch(client->client_window); + Fluxbox::instance()->removeSlitSearch(client->icon_window); - // Destructive removal? - if (destroy) - clientList.remove(client); - else // Clear the window info, but keep around to help future sorting? - client->initialize(); + // Destructive removal? + if (destroy) + clientList.remove(client); + else // Clear the window info, but keep around to help future sorting? + client->initialize(); - screen()->removeNetizen(client->window); + screen()->removeNetizen(client->window); - if (remap && Fluxbox::instance()->validateWindow(client->window)) { - Display *disp = BaseDisplay::getXDisplay(); - XSelectInput(disp, frame.window, NoEventMask); - XSelectInput(disp, client->window, NoEventMask); - XReparentWindow(disp, client->window, screen()->getRootWindow(), + if (remap && Fluxbox::instance()->validateWindow(client->window)) { + Display *disp = BaseDisplay::getXDisplay(); + XSelectInput(disp, frame.window, NoEventMask); + XSelectInput(disp, client->window, NoEventMask); + XReparentWindow(disp, client->window, screen()->getRootWindow(), client->x, client->y); - XChangeSaveSet(disp, client->window, SetModeDelete); - XSelectInput(disp, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); - XFlush(disp); - } + XChangeSaveSet(disp, client->window, SetModeDelete); + XSelectInput(disp, frame.window, SubstructureRedirectMask | + ButtonPressMask | EnterWindowMask | LeaveWindowMask); + XFlush(disp); + } - // Destructive removal? - if (destroy) - delete client; + // Destructive removal? + if (destroy) + delete client; } void Slit::removeClient(Window w, bool remap) { - bool reconf = false; + bool reconf = false; - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { - if ((*it)->window == w) { - removeClient((*it), remap, false); - reconf = true; + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + if ((*it)->window == w) { + removeClient((*it), remap, false); + reconf = true; - break; - } - } - if (reconf) - reconfigure(); + break; + } + } + if (reconf) + reconfigure(); } void Slit::reconfigure() { - frame.width = 0; - frame.height = 0; + frame.width = 0; + frame.height = 0; - // Need to count windows because not all client list entries - // actually correspond to mapped windows. - int num_windows = 0; + // Need to count windows because not all client list entries + // actually correspond to mapped windows. + int num_windows = 0; - switch (screen()->getSlitDirection()) { - case VERTICAL: - { - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { + switch (screen()->getSlitDirection()) { + case VERTICAL: + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { //client created window? - if ((*it)->window != None) { - num_windows++; - frame.height += (*it)->height + screen()->getBevelWidth(); + if ((*it)->window != None) { + num_windows++; + frame.height += (*it)->height + screen()->getBevelWidth(); - //frame width < client window? - if (frame.width < (*it)->width) - frame.width = (*it)->width; - } - } - } + //frame width < client window? + if (frame.width < (*it)->width) + frame.width = (*it)->width; + } + } + } - if (frame.width < 1) - frame.width = 1; - else - frame.width += (screen()->getBevelWidth() * 2); + if (frame.width < 1) + frame.width = 1; + else + frame.width += (screen()->getBevelWidth() * 2); - if (frame.height < 1) - frame.height = 1; - else - frame.height += screen()->getBevelWidth(); + if (frame.height < 1) + frame.height = 1; + else + frame.height += screen()->getBevelWidth(); - break; + break; - case HORIZONTAL: - { - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { + case HORIZONTAL: + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { //client created window? - if ((*it)->window != None) { - num_windows++; - frame.width += (*it)->width + screen()->getBevelWidth(); - //frame height < client height? - if (frame.height < (*it)->height) - frame.height = (*it)->height; - } - } - } + if ((*it)->window != None) { + num_windows++; + frame.width += (*it)->width + screen()->getBevelWidth(); + //frame height < client height? + if (frame.height < (*it)->height) + frame.height = (*it)->height; + } + } + } - if (frame.width < 1) - frame.width = 1; - else - frame.width += screen()->getBevelWidth(); + if (frame.width < 1) + frame.width = 1; + else + frame.width += screen()->getBevelWidth(); - if (frame.height < 1) - frame.height = 1; - else - frame.height += (screen()->getBevelWidth() * 2); + if (frame.height < 1) + frame.height = 1; + else + frame.height += (screen()->getBevelWidth() * 2); - break; - } + break; + } - reposition(); - Display *disp = BaseDisplay::getXDisplay(); + reposition(); + Display *disp = BaseDisplay::getXDisplay(); - XSetWindowBorderWidth(disp, frame.window, screen()->getBorderWidth()); - XSetWindowBorder(disp, frame.window, - screen()->getBorderColor()->pixel()); + XSetWindowBorderWidth(disp, frame.window, screen()->getBorderWidth()); + XSetWindowBorder(disp, frame.window, + screen()->getBorderColor()->pixel()); - //did we actually use slit slots - if (num_windows == 0) - XUnmapWindow(disp, frame.window); - else - XMapWindow(disp, frame.window); + //did we actually use slit slots + if (num_windows == 0) + XUnmapWindow(disp, frame.window); + else + XMapWindow(disp, frame.window); - Pixmap tmp = frame.pixmap; - BImageControl *image_ctrl = screen()->getImageControl(); - const FbTk::Texture &texture = screen()->getTheme()->getSlitTexture(); - if (texture.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.pixmap = None; - XSetWindowBackground(disp, frame.window, texture.color().pixel()); - } else { - frame.pixmap = image_ctrl->renderImage(frame.width, frame.height, - texture); - XSetWindowBackgroundPixmap(disp, frame.window, frame.pixmap); - } + Pixmap tmp = frame.pixmap; + BImageControl *image_ctrl = screen()->getImageControl(); + const FbTk::Texture &texture = screen()->getTheme()->getSlitTexture(); + if (texture.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.pixmap = None; + XSetWindowBackground(disp, frame.window, texture.color().pixel()); + } else { + frame.pixmap = image_ctrl->renderImage(frame.width, frame.height, + texture); + XSetWindowBackgroundPixmap(disp, frame.window, frame.pixmap); + } - if (tmp) - image_ctrl->removeImage(tmp); - XClearWindow(disp, frame.window); + if (tmp) + image_ctrl->removeImage(tmp); + XClearWindow(disp, frame.window); - int x, y; + int x, y; - switch (screen()->getSlitDirection()) { - case VERTICAL: - x = 0; - y = screen()->getBevelWidth(); + switch (screen()->getSlitDirection()) { + case VERTICAL: + x = 0; + y = screen()->getBevelWidth(); - { - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { //client created window? - if ((*it)->window == None) - continue; + if ((*it)->window == None) + continue; - x = (frame.width - (*it)->width) / 2; - Display *disp = BaseDisplay::getXDisplay(); - XMoveResizeWindow(disp, (*it)->window, x, y, - (*it)->width, (*it)->height); - XMapWindow(disp, (*it)->window); + x = (frame.width - (*it)->width) / 2; + Display *disp = BaseDisplay::getXDisplay(); + XMoveResizeWindow(disp, (*it)->window, x, y, + (*it)->width, (*it)->height); + XMapWindow(disp, (*it)->window); // for ICCCM compliance - (*it)->x = x; - (*it)->y = y; + (*it)->x = x; + (*it)->y = y; - XEvent event; - event.type = ConfigureNotify; + XEvent event; + event.type = ConfigureNotify; - event.xconfigure.display = disp; - event.xconfigure.event = (*it)->window; - event.xconfigure.window = (*it)->window; - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = (*it)->width; - event.xconfigure.height = (*it)->height; - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; + event.xconfigure.display = disp; + event.xconfigure.event = (*it)->window; + event.xconfigure.window = (*it)->window; + event.xconfigure.x = x; + event.xconfigure.y = y; + event.xconfigure.width = (*it)->width; + event.xconfigure.height = (*it)->height; + event.xconfigure.border_width = 0; + event.xconfigure.above = frame.window; + event.xconfigure.override_redirect = False; - XSendEvent(disp, (*it)->window, False, StructureNotifyMask, - &event); + XSendEvent(disp, (*it)->window, False, StructureNotifyMask, + &event); - y += (*it)->height + screen()->getBevelWidth(); - } - } + y += (*it)->height + screen()->getBevelWidth(); + } + } - break; + break; - case HORIZONTAL: - x = screen()->getBevelWidth(); - y = 0; + case HORIZONTAL: + x = screen()->getBevelWidth(); + y = 0; - { - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { //client created window? - if ((*it)->window == None) - continue; + if ((*it)->window == None) + continue; - y = (frame.height - (*it)->height) / 2; + y = (frame.height - (*it)->height) / 2; - XMoveResizeWindow(disp, (*it)->window, x, y, - (*it)->width, (*it)->height); - XMapWindow(disp, (*it)->window); + XMoveResizeWindow(disp, (*it)->window, x, y, + (*it)->width, (*it)->height); + XMapWindow(disp, (*it)->window); // for ICCCM compliance - (*it)->x = x; - (*it)->y = y; + (*it)->x = x; + (*it)->y = y; - XEvent event; - event.type = ConfigureNotify; + XEvent event; + event.type = ConfigureNotify; - event.xconfigure.display = disp; - event.xconfigure.event = (*it)->window; - event.xconfigure.window = (*it)->window; - event.xconfigure.x = frame.x + x + screen()->getBorderWidth(); - event.xconfigure.y = frame.y + y + screen()->getBorderWidth(); - event.xconfigure.width = (*it)->width; - event.xconfigure.height = (*it)->height; - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; + event.xconfigure.display = disp; + event.xconfigure.event = (*it)->window; + event.xconfigure.window = (*it)->window; + event.xconfigure.x = frame.x + x + screen()->getBorderWidth(); + event.xconfigure.y = frame.y + y + screen()->getBorderWidth(); + event.xconfigure.width = (*it)->width; + event.xconfigure.height = (*it)->height; + event.xconfigure.border_width = 0; + event.xconfigure.above = frame.window; + event.xconfigure.override_redirect = False; - XSendEvent(disp, (*it)->window, False, StructureNotifyMask, - &event); + XSendEvent(disp, (*it)->window, False, StructureNotifyMask, + &event); - x += (*it)->width + screen()->getBevelWidth(); - } - } + x += (*it)->width + screen()->getBevelWidth(); + } + } - break; - } + break; + } - slitmenu.reconfigure(); + slitmenu.reconfigure(); } void Slit::reposition() { - int head_x = 0, - head_y = 0, - head_w, - head_h; + int head_x = 0, + head_y = 0, + head_w, + head_h; #ifdef XINERAMA - if (screen()->hasXinerama()) { - unsigned int head = screen()->getSlitOnHead(); + if (screen()->hasXinerama()) { + unsigned int head = screen()->getSlitOnHead(); - head_x = screen()->getHeadX(head); - head_y = screen()->getHeadY(head); - head_w = screen()->getHeadWidth(head); - head_h = screen()->getHeadHeight(head); - } else { - head_w = screen()->getWidth(); - head_h = screen()->getHeight(); - } + head_x = screen()->getHeadX(head); + head_y = screen()->getHeadY(head); + head_w = screen()->getHeadWidth(head); + head_h = screen()->getHeadHeight(head); + } else { + head_w = screen()->getWidth(); + head_h = screen()->getHeight(); + } #else // !XINERAMA - head_w = screen()->getWidth(); - head_h = screen()->getHeight(); + head_w = screen()->getWidth(); + head_h = screen()->getHeight(); #endif // XINERAMA - // place the slit in the appropriate place - switch (screen()->getSlitPlacement()) { - case TOPLEFT: - frame.x = head_x; - frame.y = head_y; - if (screen()->getSlitDirection() == VERTICAL) { - frame.x_hidden = screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.width; - frame.y_hidden = head_y; - } else { - frame.x_hidden = head_x; - frame.y_hidden = screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.height; - } - break; + // place the slit in the appropriate place + switch (screen()->getSlitPlacement()) { + case TOPLEFT: + frame.x = head_x; + frame.y = head_y; + if (screen()->getSlitDirection() == VERTICAL) { + frame.x_hidden = screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.width; + frame.y_hidden = head_y; + } else { + frame.x_hidden = head_x; + frame.y_hidden = screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.height; + } + break; - case CENTERLEFT: - frame.x = head_x; - frame.y = head_y + (head_h - frame.height) / 2; - frame.x_hidden = head_x + screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.width; - frame.y_hidden = frame.y; - break; + case CENTERLEFT: + frame.x = head_x; + frame.y = head_y + (head_h - frame.height) / 2; + frame.x_hidden = head_x + screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.width; + frame.y_hidden = frame.y; + break; - case BOTTOMLEFT: - frame.x = head_x; - frame.y = head_h - frame.height - screen()->getBorderWidth2x(); - if (screen()->getSlitDirection() == VERTICAL) { - frame.x_hidden = head_x + screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.width; - frame.y_hidden = frame.y; - } else { - frame.x_hidden = head_x; - frame.y_hidden = head_y + head_h - - screen()->getBevelWidth() - screen()->getBorderWidth(); - } - break; + case BOTTOMLEFT: + frame.x = head_x; + frame.y = head_h - frame.height - screen()->getBorderWidth2x(); + if (screen()->getSlitDirection() == VERTICAL) { + frame.x_hidden = head_x + screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.width; + frame.y_hidden = frame.y; + } else { + frame.x_hidden = head_x; + frame.y_hidden = head_y + head_h - + screen()->getBevelWidth() - screen()->getBorderWidth(); + } + break; - case TOPCENTER: - frame.x = head_x + ((head_w - frame.width) / 2); - frame.y = head_y; - frame.x_hidden = frame.x; - frame.y_hidden = head_y + screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.height; - break; + case TOPCENTER: + frame.x = head_x + ((head_w - frame.width) / 2); + frame.y = head_y; + frame.x_hidden = frame.x; + frame.y_hidden = head_y + screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.height; + break; - case BOTTOMCENTER: - frame.x = head_x + ((head_w - frame.width) / 2); - frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); - frame.x_hidden = frame.x; - frame.y_hidden = head_y + head_h - - screen()->getBevelWidth() - screen()->getBorderWidth(); - break; + case BOTTOMCENTER: + frame.x = head_x + ((head_w - frame.width) / 2); + frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); + frame.x_hidden = frame.x; + frame.y_hidden = head_y + head_h - + screen()->getBevelWidth() - screen()->getBorderWidth(); + break; - case TOPRIGHT: - frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); - frame.y = head_y; - if (screen()->getSlitDirection() == VERTICAL) { - frame.x_hidden = head_x + head_w - - screen()->getBevelWidth() - screen()->getBorderWidth(); - frame.y_hidden = head_y; - } else { - frame.x_hidden = frame.x; - frame.y_hidden = head_y + screen()->getBevelWidth() - - screen()->getBorderWidth() - frame.height; - } - break; + case TOPRIGHT: + frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); + frame.y = head_y; + if (screen()->getSlitDirection() == VERTICAL) { + frame.x_hidden = head_x + head_w - + screen()->getBevelWidth() - screen()->getBorderWidth(); + frame.y_hidden = head_y; + } else { + frame.x_hidden = frame.x; + frame.y_hidden = head_y + screen()->getBevelWidth() - + screen()->getBorderWidth() - frame.height; + } + break; - case CENTERRIGHT: - default: - frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); - frame.y = head_y + ((head_h - frame.height) / 2); - frame.x_hidden = head_x + head_w - - screen()->getBevelWidth() - screen()->getBorderWidth(); - frame.y_hidden = frame.y; - break; + case CENTERRIGHT: + default: + frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); + frame.y = head_y + ((head_h - frame.height) / 2); + frame.x_hidden = head_x + head_w - + screen()->getBevelWidth() - screen()->getBorderWidth(); + frame.y_hidden = frame.y; + break; - case BOTTOMRIGHT: - frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); - frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); - if (screen()->getSlitDirection() == VERTICAL) { - frame.x_hidden = head_x + head_w - - screen()->getBevelWidth() - screen()->getBorderWidth(); - frame.y_hidden = frame.y; - } else { - frame.x_hidden = frame.x; - frame.y_hidden = head_y + head_h - - screen()->getBevelWidth() - screen()->getBorderWidth(); - } - break; - } + case BOTTOMRIGHT: + frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); + frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); + if (screen()->getSlitDirection() == VERTICAL) { + frame.x_hidden = head_x + head_w - + screen()->getBevelWidth() - screen()->getBorderWidth(); + frame.y_hidden = frame.y; + } else { + frame.x_hidden = frame.x; + frame.y_hidden = head_y + head_h - + screen()->getBevelWidth() - screen()->getBorderWidth(); + } + break; + } - const Toolbar * const tbar = screen()->getToolbar(); - int sw = frame.width + screen()->getBorderWidth2x(), - sh = frame.height + screen()->getBorderWidth2x(), - tw = tbar->width() + screen()->getBorderWidth(), - th = tbar->height() + screen()->getBorderWidth(); + const Toolbar * const tbar = screen()->getToolbar(); + int sw = frame.width + screen()->getBorderWidth2x(), + sh = frame.height + screen()->getBorderWidth2x(), + tw = tbar->width() + screen()->getBorderWidth(), + th = tbar->height() + screen()->getBorderWidth(); - if (tbar->x() < frame.x + sw && tbar->x() + tw > frame.x && - tbar->y() < frame.y + sh && tbar->y() + th > frame.y) { - if (frame.y < th) { - frame.y += tbar->exposedHeight(); - if (screen()->getSlitDirection() == VERTICAL) - frame.y_hidden += tbar->exposedHeight(); - else - frame.y_hidden = frame.y; - } else { - frame.y -= tbar->exposedHeight(); - if (screen()->getSlitDirection() == VERTICAL) - frame.y_hidden -= tbar->exposedHeight(); - else - frame.y_hidden = frame.y; - } - } + if (tbar->x() < frame.x + sw && tbar->x() + tw > frame.x && + tbar->y() < frame.y + sh && tbar->y() + th > frame.y) { + if (frame.y < th) { + frame.y += tbar->exposedHeight(); + if (screen()->getSlitDirection() == VERTICAL) + frame.y_hidden += tbar->exposedHeight(); + else + frame.y_hidden = frame.y; + } else { + frame.y -= tbar->exposedHeight(); + if (screen()->getSlitDirection() == VERTICAL) + frame.y_hidden -= tbar->exposedHeight(); + else + frame.y_hidden = frame.y; + } + } - Display *disp = BaseDisplay::getXDisplay(); + Display *disp = BaseDisplay::getXDisplay(); - if (hidden) { - XMoveResizeWindow(disp, frame.window, frame.x_hidden, - frame.y_hidden, frame.width, frame.height); - } else { - XMoveResizeWindow(disp, frame.window, frame.x, - frame.y, frame.width, frame.height); - } + if (hidden) { + XMoveResizeWindow(disp, frame.window, frame.x_hidden, + frame.y_hidden, frame.width, frame.height); + } else { + XMoveResizeWindow(disp, frame.window, frame.x, + frame.y, frame.width, frame.height); + } } void Slit::shutdown() { - saveClientList(); - while (clientList.size() != 0) - removeClient(clientList.front(), true, true); + saveClientList(); + while (clientList.size() != 0) + removeClient(clientList.front(), true, true); } void Slit::buttonPressEvent(XButtonEvent *e) { - if (e->window != frame.window) - return; + if (e->window != frame.window) + return; - if (e->button == Button1 && (! on_top)) { - Workspace::Stack st; - st.push_back(frame.window); - screen()->raiseWindows(st); - } else if (e->button == Button2 && (! on_top)) { - XLowerWindow(BaseDisplay::getXDisplay(), frame.window); - } else if (e->button == Button3) { - if (! slitmenu.isVisible()) { - int x = e->x_root - (slitmenu.width() / 2), - y = e->y_root - (slitmenu.height() / 2); + if (e->button == Button1 && (! on_top)) { + Workspace::Stack st; + st.push_back(frame.window); + screen()->raiseWindows(st); + } else if (e->button == Button2 && (! on_top)) { + XLowerWindow(BaseDisplay::getXDisplay(), frame.window); + } else if (e->button == Button3) { + if (! slitmenu.isVisible()) { + int x = e->x_root - (slitmenu.width() / 2), + y = e->y_root - (slitmenu.height() / 2); - if (x < 0) - x = 0; - else if (x + slitmenu.width() > screen()->getWidth()) - x = screen()->getWidth() - slitmenu.width(); + if (x < 0) + x = 0; + else if (x + slitmenu.width() > screen()->getWidth()) + x = screen()->getWidth() - slitmenu.width(); - if (y < 0) - y = 0; - else if (y + slitmenu.height() > screen()->getHeight()) - y = screen()->getHeight() - slitmenu.height(); + if (y < 0) + y = 0; + else if (y + slitmenu.height() > screen()->getHeight()) + y = screen()->getHeight() - slitmenu.height(); - slitmenu.move(x, y); - slitmenu.show(); - } else - slitmenu.hide(); - } + slitmenu.move(x, y); + slitmenu.show(); + } else + slitmenu.hide(); + } } void Slit::enterNotifyEvent(XCrossingEvent *) { - if (! do_auto_hide) - return; + if (! do_auto_hide) + return; - if (hidden) { - if (! timer.isTiming()) - timer.start(); - } else { - if (timer.isTiming()) - timer.stop(); - } + if (hidden) { + if (! timer.isTiming()) + timer.start(); + } else { + if (timer.isTiming()) + timer.stop(); + } } void Slit::leaveNotifyEvent(XCrossingEvent *) { - if (! do_auto_hide) - return; + if (! do_auto_hide) + return; - if (hidden) { - if (timer.isTiming()) - timer.stop(); - } else if (! slitmenu.isVisible()) { - if (! timer.isTiming()) - timer.start(); - } + if (hidden) { + if (timer.isTiming()) + timer.stop(); + } else if (! slitmenu.isVisible()) { + if (! timer.isTiming()) + timer.start(); + } } void Slit::configureRequestEvent(XConfigureRequestEvent *e) { - if (!Fluxbox::instance()->validateWindow(e->window)) - return; + if (!Fluxbox::instance()->validateWindow(e->window)) + return; - bool reconf = false; - XWindowChanges xwc; + bool reconf = false; + XWindowChanges xwc; - xwc.x = e->x; - xwc.y = e->y; - xwc.width = e->width; - xwc.height = e->height; - xwc.border_width = 0; - xwc.sibling = e->above; - xwc.stack_mode = e->detail; + xwc.x = e->x; + xwc.y = e->y; + xwc.width = e->width; + xwc.height = e->height; + xwc.border_width = 0; + xwc.sibling = e->above; + xwc.stack_mode = e->detail; - XConfigureWindow(BaseDisplay::getXDisplay(), e->window, e->value_mask, &xwc); + XConfigureWindow(BaseDisplay::getXDisplay(), e->window, e->value_mask, &xwc); - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - for (; it != it_end; ++it) { - if ((*it)->window == e->window) { - if ((*it)->width != ((unsigned) e->width) || - (*it)->height != ((unsigned) e->height)) { - (*it)->width = (unsigned) e->width; - (*it)->height = (unsigned) e->height; + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + if ((*it)->window == e->window) { + if ((*it)->width != ((unsigned) e->width) || + (*it)->height != ((unsigned) e->height)) { + (*it)->width = (unsigned) e->width; + (*it)->height = (unsigned) e->height; - reconf = true; //requires reconfiguration + reconf = true; //requires reconfiguration - break; - } - } - } + break; + } + } + } - if (reconf) - reconfigure(); + if (reconf) + reconfigure(); } void Slit::timeout() { - hidden = ! hidden; - Display *disp = BaseDisplay::getXDisplay(); - if (hidden) - XMoveWindow(disp, frame.window, frame.x_hidden, frame.y_hidden); - else - XMoveWindow(disp, frame.window, frame.x, frame.y); + hidden = ! hidden; + Display *disp = BaseDisplay::getXDisplay(); + if (hidden) + XMoveWindow(disp, frame.window, frame.x_hidden, frame.y_hidden); + else + XMoveWindow(disp, frame.window, frame.x, frame.y); } void Slit::loadClientList() { - const std::string &filename = Fluxbox::instance()->getSlitlistFilename(); - struct stat buf; - if (!stat(filename.c_str(), &buf)) { - std::ifstream file(Fluxbox::instance()->getSlitlistFilename().c_str()); - std::string name; - while (! file.eof()) { - name = ""; - std::getline(file, name); // get the entire line - if (name.size() > 0) { - SlitClient *client = new SlitClient(name.c_str()); - clientList.push_back(client); - } - } - } + const std::string &filename = Fluxbox::instance()->getSlitlistFilename(); + struct stat buf; + if (!stat(filename.c_str(), &buf)) { + std::ifstream file(Fluxbox::instance()->getSlitlistFilename().c_str()); + std::string name; + while (! file.eof()) { + name = ""; + std::getline(file, name); // get the entire line + if (name.size() > 0) { + SlitClient *client = new SlitClient(name.c_str()); + clientList.push_back(client); + } + } + } } void Slit::saveClientList() { - const std::string &filename = Fluxbox::instance()->getSlitlistFilename(); - std::ofstream file(filename.c_str()); - SlitClients::iterator it = clientList.begin(); - SlitClients::iterator it_end = clientList.end(); - std::string prevName; - std::string name; - for (; it != it_end; ++it) { - name = (*it)->match_name; - if (name != prevName) - file << name.c_str() << std::endl; + const std::string &filename = Fluxbox::instance()->getSlitlistFilename(); + std::ofstream file(filename.c_str()); + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + std::string prevName; + std::string name; + for (; it != it_end; ++it) { + name = (*it)->match_name; + if (name != prevName) + file << name.c_str() << std::endl; - prevName = name; - } + prevName = name; + } } void Slit::setOnTop(bool val) { - on_top = val; - screen()->saveSlitOnTop(val); + on_top = val; + screen()->saveSlitOnTop(val); - if (isOnTop()) - screen()->raiseWindows(Workspace::Stack()); + if (isOnTop()) + screen()->raiseWindows(Workspace::Stack()); } void Slit::setAutoHide(bool val) { - do_auto_hide = val; - screen()->saveSlitAutoHide(val); + do_auto_hide = val; + screen()->saveSlitAutoHide(val); } Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen()), -slit(sl), + slit(sl), #ifdef XINERAMA -m_headmenu(0), + m_headmenu(0), #endif // XINERAMA -m_placementmenu(*this), -m_directionmenu(*this) { + m_placementmenu(*this), + m_directionmenu(*this) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - SlitSet, SlitSlitTitle, - "Slit")); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + SlitSet, SlitSlitTitle, + "Slit")); + setInternalMenu(); #ifdef XINERAMA - if (screen()->hasXinerama()) { // only create if we need - m_headmenu.reset(new Headmenu(*this)); - } + if (screen()->hasXinerama()) { // only create if we need + m_headmenu.reset(new Headmenu(*this)); + } #endif // XINERAMA - insert(i18n->getMessage( - CommonSet, CommonDirectionTitle, - "Direction"), - &m_directionmenu); - insert(i18n->getMessage( - CommonSet, CommonPlacementTitle, - "Placement"), - &m_placementmenu); + insert(i18n->getMessage( + CommonSet, CommonDirectionTitle, + "Direction"), + &m_directionmenu); + insert(i18n->getMessage( + CommonSet, CommonPlacementTitle, + "Placement"), + &m_placementmenu); #ifdef XINERAMA - if (screen()->hasXinerama()) { - insert(i18n->getMessage(0, 0, "Place on Head"), m_headmenu.get()); - } + if (screen()->hasXinerama()) { + insert(i18n->getMessage(0, 0, "Place on Head"), m_headmenu.get()); + } #endif // XINERAMA - insert(i18n->getMessage( - CommonSet, CommonAlwaysOnTop, - "Always on top"), 1); - insert(i18n->getMessage( - CommonSet, CommonAutoHide, - "Auto hide"), 2); + insert(i18n->getMessage( + CommonSet, CommonAlwaysOnTop, + "Always on top"), 1); + insert(i18n->getMessage( + CommonSet, CommonAutoHide, + "Auto hide"), 2); - setItemSelected(2, slit.isOnTop()); - setItemSelected(3, slit.doAutoHide()); + setItemSelected(2, slit.isOnTop()); + setItemSelected(3, slit.doAutoHide()); - update(); + update(); }

@@ -896,216 +896,216 @@ }

void Slitmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (! item) return; + if (button == 1) { + BasemenuItem *item = find(index); + if (! item) return; - switch (item->function()) { - case 1: - // toggle on top - slit.setOnTop(slit.isOnTop() ? false : true); - setItemSelected(2, slit.isOnTop()); - break; - case 2: // auto hide - slit.setAutoHide(slit.doAutoHide() ? false : true); - setItemSelected(3, slit.doAutoHide()); - break; - } + switch (item->function()) { + case 1: + // toggle on top + slit.setOnTop(slit.isOnTop() ? false : true); + setItemSelected(2, slit.isOnTop()); + break; + case 2: // auto hide + slit.setAutoHide(slit.doAutoHide() ? false : true); + setItemSelected(3, slit.doAutoHide()); + break; + } - //save the new configuration - Fluxbox::instance()->save_rc(); - update(); - } + //save the new configuration + Fluxbox::instance()->save_rc(); + update(); + } } void Slitmenu::internal_hide() { - Basemenu::internal_hide(); - if (slit.doAutoHide()) - slit.timeout(); + Basemenu::internal_hide(); + if (slit.doAutoHide()) + slit.timeout(); } void Slitmenu::reconfigure() { - m_directionmenu.reconfigure(); - m_placementmenu.reconfigure(); + m_directionmenu.reconfigure(); + m_placementmenu.reconfigure(); #ifdef XINERAMA - if (m_headmenu.get() != 0) { - m_headmenu->reconfigure(); - } + if (m_headmenu.get() != 0) { + m_headmenu->reconfigure(); + } #endif // XINERAMA - setItemSelected(2, slit.isOnTop()); - setItemSelected(3, slit.doAutoHide()); + setItemSelected(2, slit.isOnTop()); + setItemSelected(3, slit.doAutoHide()); - Basemenu::reconfigure(); + Basemenu::reconfigure(); } Slitmenu::Directionmenu::Directionmenu(Slitmenu &sm) : Basemenu(sm.screen()), -slitmenu(sm) { + slitmenu(sm) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - SlitSet, SlitSlitDirection, - "Slit Direction")); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + SlitSet, SlitSlitDirection, + "Slit Direction")); + setInternalMenu(); - insert(i18n->getMessage( - CommonSet, CommonDirectionHoriz, - "Horizontal"), - Slit::HORIZONTAL); - insert(i18n->getMessage( - CommonSet, CommonDirectionVert, - "Vertical"), - Slit::VERTICAL); + insert(i18n->getMessage( + CommonSet, CommonDirectionHoriz, + "Horizontal"), + Slit::HORIZONTAL); + insert(i18n->getMessage( + CommonSet, CommonDirectionVert, + "Vertical"), + Slit::VERTICAL); - update(); + update(); - if (screen()->getSlitDirection() == Slit::HORIZONTAL) - setItemSelected(0, true); - else - setItemSelected(1, true); + if (screen()->getSlitDirection() == Slit::HORIZONTAL) + setItemSelected(0, true); + else + setItemSelected(1, true); } void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (item == 0) - return; + if (button == 1) { + BasemenuItem *item = find(index); + if (item == 0) + return; - screen()->saveSlitDirection(item->function()); + screen()->saveSlitDirection(item->function()); - if (item->function() == Slit::HORIZONTAL) { - setItemSelected(0, true); - setItemSelected(1, false); - } else { - setItemSelected(0, false); - setItemSelected(1, true); - } - Fluxbox::instance()->save_rc(); - hide(); - slitmenu.slit.reconfigure(); - } + if (item->function() == Slit::HORIZONTAL) { + setItemSelected(0, true); + setItemSelected(1, false); + } else { + setItemSelected(0, false); + setItemSelected(1, true); + } + Fluxbox::instance()->save_rc(); + hide(); + slitmenu.slit.reconfigure(); + } } Slitmenu::Placementmenu::Placementmenu(Slitmenu &sm) : Basemenu(sm.screen()), -slitmenu(sm) { + slitmenu(sm) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - SlitSet, SlitSlitPlacement, - "Slit Placement")); - setMinimumSublevels(3); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + SlitSet, SlitSlitPlacement, + "Slit Placement")); + setMinimumSublevels(3); + setInternalMenu(); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopLeft, - "Top Left"), - Slit::TOPLEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementCenterLeft, - "Center Left"), - Slit::CENTERLEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomLeft, - "Bottom Left"), - Slit::BOTTOMLEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopCenter, - "Top Center"), - Slit::TOPCENTER); - insert(""); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomCenter, - "Bottom Center"), - Slit::BOTTOMCENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopRight, - "Top Right"), - Slit::TOPRIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementCenterRight, - "Center Right"), - Slit::CENTERRIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomRight, - "Bottom Right"), - Slit::BOTTOMRIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopLeft, + "Top Left"), + Slit::TOPLEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementCenterLeft, + "Center Left"), + Slit::CENTERLEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomLeft, + "Bottom Left"), + Slit::BOTTOMLEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopCenter, + "Top Center"), + Slit::TOPCENTER); + insert(""); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomCenter, + "Bottom Center"), + Slit::BOTTOMCENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopRight, + "Top Right"), + Slit::TOPRIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementCenterRight, + "Center Right"), + Slit::CENTERRIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomRight, + "Bottom Right"), + Slit::BOTTOMRIGHT); - update(); + update(); } void Slitmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (! item) return; + if (button == 1) { + BasemenuItem *item = find(index); + if (! item) return; - if (item->function()) { - screen()->saveSlitPlacement(item->function()); - hide(); - slitmenu.slit.reconfigure(); - Fluxbox::instance()->save_rc(); - } - } + if (item->function()) { + screen()->saveSlitPlacement(item->function()); + hide(); + slitmenu.slit.reconfigure(); + Fluxbox::instance()->save_rc(); + } + } } #ifdef XINERAMA Slitmenu::Headmenu::Headmenu(Slitmenu &sm): Basemenu(sm.screen()), -slitmenu(sm) { + slitmenu(sm) { - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS - setInternalMenu(); + setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS + setInternalMenu(); - int numHeads = screen()->getNumHeads(); - // fill menu with head entries - for (int i = 0; i < numHeads; i++) { - char headName[32]; - sprintf(headName, "Head %i", i+1); //TODO: NLS - insert(i18n->getMessage(0, 0, headName), i); - } + int numHeads = screen()->getNumHeads(); + // fill menu with head entries + for (int i = 0; i < numHeads; i++) { + char headName[32]; + sprintf(headName, "Head %i", i+1); //TODO: NLS + insert(i18n->getMessage(0, 0, headName), i); + } - update(); + update(); } void Slitmenu::Headmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (! item) - return; + if (button == 1) { + BasemenuItem *item = find(index); + if (! item) + return; - screen()->saveSlitOnHead(item->function()); - hide(); - slitmenu.slit.reconfigure(); - Fluxbox::instance()->save_rc(); - } + screen()->saveSlitOnHead(item->function()); + hide(); + slitmenu.slit.reconfigure(); + Fluxbox::instance()->save_rc(); + } } #endif // XINERAMA Slit::SlitClient::SlitClient(const char *name) { - initialize(); - match_name = (name == 0 ? "" : name); + initialize(); + match_name = (name == 0 ? "" : name); } Slit::SlitClient::SlitClient(BScreen *screen, Window w) { - initialize(screen, w); + initialize(screen, w); } void Slit::SlitClient::initialize(BScreen *screen, Window w) { - client_window = w; - window = icon_window = None; - x = y = 0; - width = height = 0; - if (match_name.size() == 0) - getWMName(screen, client_window, match_name); + client_window = w; + window = icon_window = None; + x = y = 0; + width = height = 0; + if (match_name.size() == 0) + getWMName(screen, client_window, match_name); } #endif // SLIT
M src/Slit.hhsrc/Slit.hh

@@ -39,163 +39,163 @@ class Slit;

class Slitmenu : public Basemenu { public: - explicit Slitmenu(Slit &theslist); - virtual ~Slitmenu(); + explicit Slitmenu(Slit &theslist); + virtual ~Slitmenu(); - const Basemenu &getDirectionmenu() const { return m_directionmenu; } - const Basemenu &getPlacementmenu() const { return m_placementmenu; } + const Basemenu &getDirectionmenu() const { return m_directionmenu; } + const Basemenu &getPlacementmenu() const { return m_placementmenu; } #ifdef XINERAMA - const Basemenu *getHeadmenu() const { return m_headmenu.get(); } + const Basemenu *getHeadmenu() const { return m_headmenu.get(); } #endif // XINERAMA - void reconfigure(); + void reconfigure(); protected: - virtual void itemSelected(int button, unsigned int index); - virtual void internal_hide(); + virtual void itemSelected(int button, unsigned int index); + virtual void internal_hide(); private: - class Directionmenu : public Basemenu { - public: - Directionmenu(Slitmenu &sm); + class Directionmenu : public Basemenu { + public: + Directionmenu(Slitmenu &sm); - protected: - virtual void itemSelected(int button, unsigned int index); + protected: + virtual void itemSelected(int button, unsigned int index); - private: - Slitmenu &slitmenu; - }; + private: + Slitmenu &slitmenu; + }; - class Placementmenu : public Basemenu { - public: - Placementmenu(Slitmenu &sm); + class Placementmenu : public Basemenu { + public: + Placementmenu(Slitmenu &sm); - protected: - virtual void itemSelected(int button, unsigned int index); + protected: + virtual void itemSelected(int button, unsigned int index); - private: - Slitmenu &slitmenu; - }; + private: + Slitmenu &slitmenu; + }; - Slit &slit; + Slit &slit; #ifdef XINERAMA - class Headmenu : public Basemenu { - public: - Headmenu(Slitmenu &sm); - protected: - virtual void itemSelected(int button, unsigned int index); - private: - Slitmenu &slitmenu; - }; - friend class Headmenu; - std::auto_ptr<Headmenu> m_headmenu; + class Headmenu : public Basemenu { + public: + Headmenu(Slitmenu &sm); + protected: + virtual void itemSelected(int button, unsigned int index); + private: + Slitmenu &slitmenu; + }; + friend class Headmenu; + std::auto_ptr<Headmenu> m_headmenu; #endif // XINERAMA - Placementmenu m_placementmenu; - Directionmenu m_directionmenu; + Placementmenu m_placementmenu; + Directionmenu m_directionmenu; - friend class Directionmenu; - friend class Placementmenu; + friend class Directionmenu; + friend class Placementmenu; }; class Slit : public TimeoutHandler { public: - explicit Slit(BScreen *screen); - virtual ~Slit(); + explicit Slit(BScreen *screen); + virtual ~Slit(); - inline bool isOnTop() const { return on_top; } - inline bool isHidden() const { return hidden; } - inline bool doAutoHide() const { return do_auto_hide; } + inline bool isOnTop() const { return on_top; } + inline bool isHidden() const { return hidden; } + inline bool doAutoHide() const { return do_auto_hide; } - Slitmenu &menu() { return slitmenu; } + Slitmenu &menu() { return slitmenu; } - inline const Window &getWindowID() const { return frame.window; } + inline const Window &getWindowID() const { return frame.window; } - inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); } - inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); } + inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); } + inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); } - inline unsigned int width() const { return frame.width; } - inline unsigned int height() const { return frame.height; } - void setOnTop(bool val); - void setAutoHide(bool val); - void addClient(Window clientwin); - void removeClient(Window clientwin, bool = true); - void reconfigure(); - void reposition(); - void shutdown(); - void saveClientList(); - BScreen *screen() { return m_screen; } - const BScreen *screen() const { return m_screen; } - /** - @name eventhandlers - */ - //@{ - void buttonPressEvent(XButtonEvent *bp); - void enterNotifyEvent(XCrossingEvent *en); - void leaveNotifyEvent(XCrossingEvent *ln); - void configureRequestEvent(XConfigureRequestEvent *cr); - //@} + inline unsigned int width() const { return frame.width; } + inline unsigned int height() const { return frame.height; } + void setOnTop(bool val); + void setAutoHide(bool val); + void addClient(Window clientwin); + void removeClient(Window clientwin, bool = true); + void reconfigure(); + void reposition(); + void shutdown(); + void saveClientList(); + BScreen *screen() { return m_screen; } + const BScreen *screen() const { return m_screen; } + /** + @name eventhandlers + */ + //@{ + void buttonPressEvent(XButtonEvent *bp); + void enterNotifyEvent(XCrossingEvent *en); + void leaveNotifyEvent(XCrossingEvent *ln); + void configureRequestEvent(XConfigureRequestEvent *cr); + //@} - virtual void timeout(); + virtual void timeout(); - /** - Client alignment - */ - enum { VERTICAL = 1, HORIZONTAL }; - /** - Screen placement - */ - enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, - TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; + /** + Client alignment + */ + enum { VERTICAL = 1, HORIZONTAL }; + /** + Screen placement + */ + enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, + TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; private: - class SlitClient { - public: - SlitClient(BScreen *screen, Window client_window); // For adding an actual window - SlitClient(const char *name); // For adding a placeholder + class SlitClient { + public: + SlitClient(BScreen *screen, Window client_window); // For adding an actual window + SlitClient(const char *name); // For adding a placeholder - // Now we pre-initialize a list of slit clients with names for - // comparison with incoming client windows. This allows the slit - // to maintain a sorted order based on a saved window name list. - // Incoming windows not found in the list are appended. Matching - // duplicates are inserted after the last found instance of the - // matching name. - std::string match_name; + // Now we pre-initialize a list of slit clients with names for + // comparison with incoming client windows. This allows the slit + // to maintain a sorted order based on a saved window name list. + // Incoming windows not found in the list are appended. Matching + // duplicates are inserted after the last found instance of the + // matching name. + std::string match_name; - Window window, client_window, icon_window; + Window window, client_window, icon_window; - int x, y; - unsigned int width, height; + int x, y; + unsigned int width, height; - void initialize(BScreen *screen = 0, Window client_window= None); - }; + void initialize(BScreen *screen = 0, Window client_window= None); + }; - void removeClient(SlitClient *client, bool remap, bool destroy); - void loadClientList(); + void removeClient(SlitClient *client, bool remap, bool destroy); + void loadClientList(); - bool on_top, hidden, do_auto_hide; + bool on_top, hidden, do_auto_hide; - BScreen *m_screen; - BTimer timer; + BScreen *m_screen; + BTimer timer; - typedef std::list<SlitClient *> SlitClients; + typedef std::list<SlitClient *> SlitClients; - SlitClients clientList; - Slitmenu slitmenu; - std::string clientListPath; + SlitClients clientList; + Slitmenu slitmenu; + std::string clientListPath; - struct frame { - Pixmap pixmap; - Window window; + struct frame { + Pixmap pixmap; + Window window; - int x, y, x_hidden, y_hidden; - unsigned int width, height; - } frame; + int x, y, x_hidden, y_hidden; + unsigned int width, height; + } frame; };
M src/StringUtil.ccsrc/StringUtil.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: StringUtil.cc,v 1.13 2002/10/15 09:51:56 fluxgen Exp $ +// $Id: StringUtil.cc,v 1.14 2002/12/01 13:41:59 rathnor Exp $ #include "StringUtil.hh"

@@ -41,10 +41,10 @@ // creates a new string n, copies s to n and

// returns a pointer to n. //---------------------------------------- char *strdup(const char *s) { - int l = strlen(s) + 1; - char *n = new char[l]; - strncpy(n, s, l); - return n; + int l = strlen(s) + 1; + char *n = new char[l]; + strncpy(n, s, l); + return n; } //------- strcasestr --------------

@@ -53,14 +53,14 @@ // ignoring the case of the characters

// Returns 0 on success else pointer to str. //--------------------------------- const char *strcasestr(const char *str, const char *ptn) { - const char *s2, *p2; - for( ; *str; str++) { - for(s2=str, p2=ptn; ; s2++,p2++) { - if (!*p2) return str; // check if we reached the end of ptn, if so, return str - if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case) - } - } - return 0; + const char *s2, *p2; + for( ; *str; str++) { + for(s2=str, p2=ptn; ; s2++,p2++) { + if (!*p2) return str; // check if we reached the end of ptn, if so, return str + if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case) + } + } + return 0; } //------------- expandFilename ----------------------

@@ -69,18 +69,18 @@ // returns expanded filename

//--------------------------------------------------- string expandFilename(const std::string &filename) { - string retval; - size_t pos = filename.find_first_not_of(" \t"); - if (pos != std::string::npos && filename[pos] == '~') { + string retval; + size_t pos = filename.find_first_not_of(" \t"); + if (pos != std::string::npos && filename[pos] == '~') { retval = getenv("HOME"); - if (pos != filename.size()) { - // copy from the character after '~' - retval += static_cast<const char *>(filename.c_str() + pos + 1); - } - } else - return filename; //return unmodified value + if (pos != filename.size()) { + // copy from the character after '~' + retval += static_cast<const char *>(filename.c_str() + pos + 1); + } + } else + return filename; //return unmodified value - return retval; + return retval; } //------------- getStringBetween -----------

@@ -94,48 +94,48 @@ // for the position + 1 in the in-string where the "last"-char value

// was found. //------------------------------------------ int getStringBetween(std::string& out, const char *instr, const char first, const char last, - const char *ok_chars) { - assert(first); - assert(last); - assert(instr); + const char *ok_chars) { + assert(first); + assert(last); + assert(instr); - std::string::size_type i = 0, - total_add=0; //used to add extra if there is a \last to skip - std::string in(instr); + std::string::size_type i = 0, + total_add=0; //used to add extra if there is a \last to skip + std::string in(instr); - // eat leading whitespace - i = in.find_first_not_of(ok_chars); - if (i == std::string::npos) - return -in.size(); // nothing left but whitespace + // eat leading whitespace + i = in.find_first_not_of(ok_chars); + if (i == std::string::npos) + return -in.size(); // nothing left but whitespace - if (in[i]!=first) - return -i; //return position to error + if (in[i]!=first) + return -i; //return position to error - // find the end of the token - std::string::size_type j = i; - while (1) { - j = in.find_first_of(last, j+1); - if (j==std::string::npos) - return -in.size(); //send negative size + // find the end of the token + std::string::size_type j = i; + while (1) { + j = in.find_first_of(last, j+1); + if (j==std::string::npos) + return -in.size(); //send negative size - //we found the last char, check so it doesn't have a '\' before - if (j>1 && in[j-1] != '\\') - break; - else if (j>1) { - in.erase(j-1, 1); //remove the '\' - j--; - total_add++; //save numchars removed so we can calculate totalpos - } - } + //we found the last char, check so it doesn't have a '\' before + if (j>1 && in[j-1] != '\\') + break; + else if (j>1) { + in.erase(j-1, 1); //remove the '\' + j--; + total_add++; //save numchars removed so we can calculate totalpos + } + } - out = in.substr(i+1, j-i-1); //copy the string between first and last - //return value to last character - return (j+1+total_add); + out = in.substr(i+1, j-i-1); //copy the string between first and last + //return value to last character + return (j+1+total_add); } void toLower(char * const conv) { - for (size_t byte_pos = 0; byte_pos < strlen(conv); ++byte_pos) - conv[byte_pos] = tolower(conv[byte_pos]); + for (size_t byte_pos = 0; byte_pos < strlen(conv); ++byte_pos) + conv[byte_pos] = tolower(conv[byte_pos]); } }; //end namespace StringUtil
M src/StringUtil.hhsrc/StringUtil.hh

@@ -19,7 +19,7 @@ // 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. -//$Id: StringUtil.hh,v 1.10 2002/09/15 09:40:26 fluxgen Exp $ +//$Id: StringUtil.hh,v 1.11 2002/12/01 13:41:59 rathnor Exp $ #ifndef STRINGUTIL_HH #define STRINGUTIL_HH

@@ -36,7 +36,7 @@ const char *strcasestr(const char *str, const char *ptn);

std::string expandFilename(const std::string &filename); int getStringBetween(std::string& out, const char *instr, const char first, const char last, - const char *ok_chars=" \t\n"); + const char *ok_chars=" \t\n"); void toLower(char * const conv);

@@ -46,30 +46,30 @@ //--------------------------------------------------

template <typename Container> static void stringtok (Container &container, std::string const &in, - const char * const delimiters = " \t\n") + const char * const delimiters = " \t\n") { - const std::string::size_type len = in.length(); - std::string::size_type i = 0; + const std::string::size_type len = in.length(); + std::string::size_type i = 0; - while ( i < len ) { - // eat leading whitespace - i = in.find_first_not_of(delimiters, i); - if (i == std::string::npos) - return; // nothing left but white space + while ( i < len ) { + // eat leading whitespace + i = in.find_first_not_of(delimiters, i); + if (i == std::string::npos) + return; // nothing left but white space - // find the end of the token - std::string::size_type j = in.find_first_of(delimiters, i); + // find the end of the token + std::string::size_type j = in.find_first_of(delimiters, i); - // push token - if (j == std::string::npos) { - container.push_back(in.substr(i)); - return; - } else - container.push_back(in.substr(i, j-i)); + // push token + if (j == std::string::npos) { + container.push_back(in.substr(i)); + return; + } else + container.push_back(in.substr(i, j-i)); - // set up for next loop - i = j + 1; - } + // set up for next loop + i = j + 1; + } } };//end namespace StringUtil
M src/Subject.ccsrc/Subject.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Subject.cc,v 1.1 2002/09/07 20:30:45 fluxgen Exp $ +// $Id: Subject.cc,v 1.2 2002/12/01 13:41:59 rathnor Exp $ #include "Subject.hh" #include "Observer.hh"

@@ -32,49 +32,49 @@

Subject::SubjectList Subject::s_subjectlist; Subject::Subject() { - s_subjectlist.push_back(this); + s_subjectlist.push_back(this); } Subject::~Subject() { - SubjectList::iterator it = s_subjectlist.begin(); - SubjectList::iterator it_end = s_subjectlist.end(); - for (; it != it_end; ++it) { - if (this == (*it)) { - s_subjectlist.erase(it); - break; - } - } + SubjectList::iterator it = s_subjectlist.begin(); + SubjectList::iterator it_end = s_subjectlist.end(); + for (; it != it_end; ++it) { + if (this == (*it)) { + s_subjectlist.erase(it); + break; + } + } } void Subject::attach(Observer *obj) { - m_observerlist.push_back(obj); - // no need to have more than one instance of an observer - std::unique(m_observerlist.begin(), m_observerlist.end()); + m_observerlist.push_back(obj); + // no need to have more than one instance of an observer + std::unique(m_observerlist.begin(), m_observerlist.end()); } void Subject::detach(Observer *obj) { - ObserverList::iterator it = m_observerlist.begin(); - ObserverList::iterator it_end = m_observerlist.end(); - for (; it != it_end; ++it) { - if (obj == (*it)) { - m_observerlist.erase(it); - break; - } - } + ObserverList::iterator it = m_observerlist.begin(); + ObserverList::iterator it_end = m_observerlist.end(); + for (; it != it_end; ++it) { + if (obj == (*it)) { + m_observerlist.erase(it); + break; + } + } } void Subject::notify() { - ObserverList::iterator it = m_observerlist.begin(); - for (; it != m_observerlist.end(); ++it) { - (*it)->update(this); - } + ObserverList::iterator it = m_observerlist.begin(); + for (; it != m_observerlist.end(); ++it) { + (*it)->update(this); + } } void Subject::removeObserver(Observer *obj) { - SubjectList::iterator it = s_subjectlist.begin(); - for(; it != s_subjectlist.end(); ++it) { - (*it)->detach(obj); - } + SubjectList::iterator it = s_subjectlist.begin(); + for(; it != s_subjectlist.end(); ++it) { + (*it)->detach(obj); + } } }; // end namespace FbTk
M src/Subject.hhsrc/Subject.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Subject.hh,v 1.1 2002/09/07 20:30:45 fluxgen Exp $ +// $Id: Subject.hh,v 1.2 2002/12/01 13:42:00 rathnor Exp $ #ifndef FBTK_SUBJECT_HH #define FBTK_SUBJECT_HH

@@ -32,21 +32,21 @@ class Observer;

class Subject { public: - Subject(); - virtual ~Subject(); - /// attach an observer - void attach(Observer *obs); - /// detach an observer - void detach(Observer *obs); - /// notify all attached observers - void notify(); - static void removeObserver(Observer *obs); + Subject(); + virtual ~Subject(); + /// attach an observer + void attach(Observer *obs); + /// detach an observer + void detach(Observer *obs); + /// notify all attached observers + void notify(); + static void removeObserver(Observer *obs); private: - typedef std::vector<Observer *> ObserverList; - ObserverList m_observerlist; + typedef std::vector<Observer *> ObserverList; + ObserverList m_observerlist; - typedef std::vector<Subject *> SubjectList; - static SubjectList s_subjectlist; + typedef std::vector<Subject *> SubjectList; + static SubjectList s_subjectlist; }; }; // end namespace FbTk
M src/Tab.ccsrc/Tab.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: Tab.cc,v 1.46 2002/11/30 20:56:54 fluxgen Exp $ +// $Id: Tab.cc,v 1.47 2002/12/01 13:42:00 rathnor Exp $ #include "Tab.hh"

@@ -35,53 +35,53 @@ using namespace std;

bool Tab::m_stoptabs = false; Tab::t_tabplacementlist Tab::m_tabplacementlist[] = { - {PTOP, "Top"}, - {PBOTTOM, "Bottom"}, - {PLEFT, "Left"}, - {PRIGHT, "Right"}, - {PNONE, "none"} - }; + {PTOP, "Top"}, + {PBOTTOM, "Bottom"}, + {PLEFT, "Left"}, + {PRIGHT, "Right"}, + {PNONE, "none"} +}; Tab::t_tabplacementlist Tab::m_tabalignmentlist[] = { - {ALEFT, "Left"}, - {ACENTER, "Center"}, - {ARIGHT, "Right"}, - {ARELATIVE, "Relative"}, - {ANONE, "none"} - }; + {ALEFT, "Left"}, + {ACENTER, "Center"}, + {ARIGHT, "Right"}, + {ARELATIVE, "Relative"}, + {ANONE, "none"} +}; Tab::Tab(FluxboxWindow *win, Tab *prev, Tab *next) { - //set default values + //set default values - m_focus = m_moving = false; - m_configured = true; // only set to false before Fluxbox::reconfigure - m_move_x = m_move_y = 0; - m_prev = prev; m_next = next; - m_win = win; - m_display = BaseDisplay::getXDisplay(); + m_focus = m_moving = false; + m_configured = true; // only set to false before Fluxbox::reconfigure + m_move_x = m_move_y = 0; + m_prev = prev; m_next = next; + m_win = win; + m_display = BaseDisplay::getXDisplay(); - if ((m_win->getScreen()->getTabPlacement() == PLEFT || - m_win->getScreen()->getTabPlacement() == PRIGHT) && - m_win->getScreen()->isTabRotateVertical() && - !m_win->isShaded()) { - m_size_w = m_win->getScreen()->getTabHeight(); - m_size_h = m_win->getScreen()->getTabWidth(); - } else { - m_size_w = m_win->getScreen()->getTabWidth(); - m_size_h = m_win->getScreen()->getTabHeight(); - } + if ((m_win->getScreen()->getTabPlacement() == PLEFT || + m_win->getScreen()->getTabPlacement() == PRIGHT) && + m_win->getScreen()->isTabRotateVertical() && + !m_win->isShaded()) { + m_size_w = m_win->getScreen()->getTabHeight(); + m_size_h = m_win->getScreen()->getTabWidth(); + } else { + m_size_w = m_win->getScreen()->getTabWidth(); + m_size_h = m_win->getScreen()->getTabHeight(); + } - createTabWindow(); + createTabWindow(); - calcIncrease(); + calcIncrease(); } Tab::~Tab() { - disconnect(); + disconnect(); - Fluxbox::instance()->removeTabSearch(m_tabwin); - XDestroyWindow(m_display, m_tabwin); + Fluxbox::instance()->removeTabSearch(m_tabwin); + XDestroyWindow(m_display, m_tabwin); }

@@ -91,40 +91,40 @@ // Creates the Window for tab to be above the title window.

// This should only be called by the constructor. //------------------------------------------------- void Tab::createTabWindow() { - unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - XSetWindowAttributes attrib; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - m_win->getScreen()->getWindowStyle()->tab.border_color.pixel(); - attrib.colormap = m_win->getScreen()->colormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask | EnterWindowMask; - //Notice that m_size_w gets the TOTAL width of tabs INCLUDING borders - m_tabwin = XCreateWindow(m_display, m_win->getScreen()->getRootWindow(), - -30000, -30000, //TODO: So that it wont flicker or - // appear before the window do - m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, - m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, - m_win->getScreen()->getWindowStyle()->tab.border_width, - m_win->getScreen()->getDepth(), InputOutput, - m_win->getScreen()->getVisual(), attrib_mask, &attrib); + unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | + CWColormap | CWOverrideRedirect | CWEventMask; + XSetWindowAttributes attrib; + attrib.background_pixmap = None; + attrib.background_pixel = attrib.border_pixel = + m_win->getScreen()->getWindowStyle()->tab.border_color.pixel(); + attrib.colormap = m_win->getScreen()->colormap(); + attrib.override_redirect = True; + attrib.event_mask = ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | ExposureMask | EnterWindowMask; + //Notice that m_size_w gets the TOTAL width of tabs INCLUDING borders + m_tabwin = XCreateWindow(m_display, m_win->getScreen()->getRootWindow(), + -30000, -30000, //TODO: So that it wont flicker or + // appear before the window do + m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, + m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, + m_win->getScreen()->getWindowStyle()->tab.border_width, + m_win->getScreen()->getDepth(), InputOutput, + m_win->getScreen()->getVisual(), attrib_mask, &attrib); - //set grab - XGrabButton(m_display, Button1, Mod1Mask, m_tabwin, True, + //set grab + XGrabButton(m_display, Button1, Mod1Mask, m_tabwin, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, Fluxbox::instance()->getMoveCursor()); - //save to tabsearch - Fluxbox::instance()->saveTabSearch(m_tabwin, this); + //save to tabsearch + Fluxbox::instance()->saveTabSearch(m_tabwin, this); - XMapSubwindows(m_display, m_tabwin); - // don't show if the window is iconified - if (!m_win->isIconic()) - XMapWindow(m_display, m_tabwin); + XMapSubwindows(m_display, m_tabwin); + // don't show if the window is iconified + if (!m_win->isIconic()) + XMapWindow(m_display, m_tabwin); - decorate(); + decorate(); } //-------------- focus --------------------

@@ -133,33 +133,33 @@ // updates pixmap or color and draws the tab

//----------------------------------------- void Tab::focus() { - if (m_win->isFocused()) { - if (m_focus_pm) - XSetWindowBackgroundPixmap(m_display, m_tabwin, m_focus_pm); - else - XSetWindowBackground(m_display, m_tabwin, m_focus_pixel); - } else { - if (m_unfocus_pm) - XSetWindowBackgroundPixmap(m_display, m_tabwin, m_unfocus_pm); - else - XSetWindowBackground(m_display, m_tabwin, m_unfocus_pixel); - } - XClearWindow(m_display, m_tabwin); - draw(false); + if (m_win->isFocused()) { + if (m_focus_pm) + XSetWindowBackgroundPixmap(m_display, m_tabwin, m_focus_pm); + else + XSetWindowBackground(m_display, m_tabwin, m_focus_pixel); + } else { + if (m_unfocus_pm) + XSetWindowBackgroundPixmap(m_display, m_tabwin, m_unfocus_pm); + else + XSetWindowBackground(m_display, m_tabwin, m_unfocus_pixel); + } + XClearWindow(m_display, m_tabwin); + draw(false); } //-------------- raise -------------------- // Raises the tabs in the tablist //----------------------------------------- void Tab::raise() { - //get first tab - Tab *tab = 0; - //raise tabs - Workspace::Stack st; - for (tab = getFirst(this); tab!=0; tab = tab->m_next) { - st.push_back(tab->m_tabwin); - } - m_win->getScreen()->raiseWindows(st); + //get first tab + Tab *tab = 0; + //raise tabs + Workspace::Stack st; + for (tab = getFirst(this); tab!=0; tab = tab->m_next) { + st.push_back(tab->m_tabwin); + } + m_win->getScreen()->raiseWindows(st); } //-------------- lower --------------------

@@ -167,20 +167,20 @@ // Lowers the tabs in the tablist AND

// the windows the tabs relate to //----------------------------------------- void Tab::lower() { - Tab *current = this; - FluxboxWindow *win = 0; //convenience - //this have to be done in the correct order, otherwise we'll switch the window - //being ontop in the group - do { - XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window - win = current->getWindow(); - win->getScreen()->getWorkspace(win->getWorkspaceNumber())->lowerWindow(win); + Tab *current = this; + FluxboxWindow *win = 0; //convenience + //this have to be done in the correct order, otherwise we'll switch the window + //being ontop in the group + do { + XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window + win = current->getWindow(); + win->getScreen()->getWorkspace(win->getWorkspaceNumber())->lowerWindow(win); - current = current->next(); //get next - if (current == 0) - current = getFirst(this); //there weren't any after, get the first + current = current->next(); //get next + if (current == 0) + current = getFirst(this); //there weren't any after, get the first - } while (current != this); + } while (current != this); } //-------------- loadTheme -----------------

@@ -190,64 +190,64 @@ // vertical and relative tab modes

// TODO optimize this //------------------------------------------ void Tab::loadTheme() { - BImageControl *image_ctrl = m_win->getScreen()->getImageControl(); - Pixmap tmp = m_focus_pm; - const FbTk::Texture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus); + BImageControl *image_ctrl = m_win->getScreen()->getImageControl(); + Pixmap tmp = m_focus_pm; + const FbTk::Texture *texture = &(m_win->getScreen()->getWindowStyle()->tab.l_focus); - if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { - const FbTk::Texture &pt = m_win->getScreen()->getWindowStyle()->tab.t_focus; - if (pt.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - m_focus_pm = None; - m_focus_pixel = pt.color().pixel(); - } else - m_focus_pm = - image_ctrl->renderImage(m_size_w, m_size_h, pt); + if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { + const FbTk::Texture &pt = m_win->getScreen()->getWindowStyle()->tab.t_focus; + if (pt.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + m_focus_pm = None; + m_focus_pixel = pt.color().pixel(); + } else + m_focus_pm = + image_ctrl->renderImage(m_size_w, m_size_h, pt); - if (tmp) image_ctrl->removeImage(tmp); + if (tmp) image_ctrl->removeImage(tmp); - } else { - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - m_focus_pm = None; - m_focus_pixel = texture->color().pixel(); - } else - m_focus_pm = - image_ctrl->renderImage(m_size_w, m_size_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); - } + } else { + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + m_focus_pm = None; + m_focus_pixel = texture->color().pixel(); + } else + m_focus_pm = + image_ctrl->renderImage(m_size_w, m_size_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); + } - tmp = m_unfocus_pm; - texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus); + tmp = m_unfocus_pm; + texture = &(m_win->getScreen()->getWindowStyle()->tab.l_unfocus); - if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { - const FbTk::Texture &pt = m_win->getScreen()->getWindowStyle()->tab.t_unfocus; - if (pt.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - m_unfocus_pm = None; - m_unfocus_pixel = pt.color().pixel(); - } else - m_unfocus_pm = - image_ctrl->renderImage(m_size_w, m_size_h, pt); - } else { - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - m_unfocus_pm = None; - m_unfocus_pixel = texture->color().pixel(); - } else - m_unfocus_pm = - image_ctrl->renderImage(m_size_w, m_size_h, *texture); - } + if (texture->type() & FbTk::Texture::PARENTRELATIVE ) { + const FbTk::Texture &pt = m_win->getScreen()->getWindowStyle()->tab.t_unfocus; + if (pt.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + m_unfocus_pm = None; + m_unfocus_pixel = pt.color().pixel(); + } else + m_unfocus_pm = + image_ctrl->renderImage(m_size_w, m_size_h, pt); + } else { + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + m_unfocus_pm = None; + m_unfocus_pixel = texture->color().pixel(); + } else + m_unfocus_pm = + image_ctrl->renderImage(m_size_w, m_size_h, *texture); + } - if (tmp) image_ctrl->removeImage(tmp); + if (tmp) image_ctrl->removeImage(tmp); } //-------------- decorate -------------------- // decorates the tab with current theme //-------------------------------------------- void Tab::decorate() { - loadTheme(); + loadTheme(); - XSetWindowBorderWidth(m_display, m_tabwin, - m_win->getScreen()->getWindowStyle()->tab.border_width); - XSetWindowBorder(m_display, m_tabwin, - m_win->getScreen()->getWindowStyle()->tab.border_color.pixel()); + XSetWindowBorderWidth(m_display, m_tabwin, + m_win->getScreen()->getWindowStyle()->tab.border_width); + XSetWindowBorder(m_display, m_tabwin, + m_win->getScreen()->getWindowStyle()->tab.border_color.pixel()); } //-------------- deiconify -----------------

@@ -255,7 +255,7 @@ // Deiconifies the tab

// Used from FluxboxWindow to deiconify the tab when the window is deiconfied //------------------------------------------ void Tab::deiconify() { - XMapWindow(m_display, m_tabwin); + XMapWindow(m_display, m_tabwin); } //------------- iconify --------------------

@@ -264,49 +264,49 @@ // Used from FluxboxWindow to hide tab win when window is iconified

// disconnects itself from the list //------------------------------------------ void Tab::iconify() { - disconnect(); - withdraw(); - if(!Fluxbox::instance()->useTabs() && !m_next && !m_prev)//if we don't want to use tabs that much - m_win->setTab(false);//let's get rid of this loner tab + disconnect(); + withdraw(); + if(!Fluxbox::instance()->useTabs() && !m_next && !m_prev)//if we don't want to use tabs that much + m_win->setTab(false);//let's get rid of this loner tab } //------------ withdraw -------------- // Unmaps the tab from display //------------------------------------ void Tab::withdraw() { - XUnmapWindow(m_display, m_tabwin); + XUnmapWindow(m_display, m_tabwin); } //------------ stick -------------------- // Set/reset the the sticky on all windows in the list //--------------------------------------- void Tab::stick() { - Tab *tab; + Tab *tab; - bool wasstuck = m_win->isStuck(); + bool wasstuck = m_win->isStuck(); - //now do stick for all windows in the list - for (tab = getFirst(this); tab != 0; tab = tab->m_next) { - FluxboxWindow *win = tab->m_win; //just for convenience - if (wasstuck) { - win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; - win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; - win->stuck = false; + //now do stick for all windows in the list + for (tab = getFirst(this); tab != 0; tab = tab->m_next) { + FluxboxWindow *win = tab->m_win; //just for convenience + if (wasstuck) { + win->blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; + win->blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; + win->stuck = false; - } else { - win->stuck = true; - BScreen *screen = win->getScreen(); - if (!win->isIconic() && !(win->getWorkspaceNumber() != - screen->getCurrentWorkspaceID())) { - screen->reassociateWindow(win, screen->getCurrentWorkspaceID(), true); - } + } else { + win->stuck = true; + BScreen *screen = win->getScreen(); + if (!win->isIconic() && !(win->getWorkspaceNumber() != + screen->getCurrentWorkspaceID())) { + screen->reassociateWindow(win, screen->getCurrentWorkspaceID(), true); + } - win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT; - win->blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT; - } + win->blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT; + win->blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT; + } - win->setState(win->current_state); - } + win->setState(win->current_state); + } }

@@ -314,43 +314,43 @@ //------------- resize -------------

// Resize the window's in the tablist //---------------------------------- void Tab::resize() { - Tab *tab; + Tab *tab; - //now move and resize the windows in the list - for (tab = getFirst(this); tab != 0; tab = tab->m_next) { - if (tab!=this) { - tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), - m_win->getWidth(), m_win->getHeight()); - } - } + //now move and resize the windows in the list + for (tab = getFirst(this); tab != 0; tab = tab->m_next) { + if (tab!=this) { + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + m_win->getWidth(), m_win->getHeight()); + } + } - // need to resize tabs if in relative mode - if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { - calcIncrease(); - setPosition(); - } + // need to resize tabs if in relative mode + if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { + calcIncrease(); + setPosition(); + } } //----------- shade -------------- // Shades the windows in the tablist //-------------------------------- void Tab::shade() { - Tab *tab; + Tab *tab; - for(tab = getFirst(this); tab != 0; tab = tab->m_next) { - if (tab==this) - continue; - tab->m_win->shade(); - } + for(tab = getFirst(this); tab != 0; tab = tab->m_next) { + if (tab==this) + continue; + tab->m_win->shade(); + } - if (m_win->getScreen()->getTabPlacement() == PLEFT || - m_win->getScreen()->getTabPlacement() == PRIGHT) { - resizeGroup(); - calcIncrease(); - } + if (m_win->getScreen()->getTabPlacement() == PLEFT || + m_win->getScreen()->getTabPlacement() == PRIGHT) { + resizeGroup(); + calcIncrease(); + } - if (!(m_win->getScreen()->getTabPlacement() == PTOP)) - setPosition(); + if (!(m_win->getScreen()->getTabPlacement() == PTOP)) + setPosition(); } //------------ draw -----------------

@@ -360,40 +360,40 @@ // mode else it draws it in normal mode

// TODO: the "draw in pressed mode" //----------------------------------- void Tab::draw(bool pressed) const { - XClearWindow(m_display, m_tabwin); + XClearWindow(m_display, m_tabwin); - if (m_win->getTitle().size() == 0) // we don't have anything to draw - return; + if (m_win->getTitle().size() == 0) // we don't have anything to draw + return; - GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc : - m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc); + GC gc = ((m_win->isFocused()) ? m_win->getScreen()->getWindowStyle()->tab.l_text_focus_gc : + m_win->getScreen()->getWindowStyle()->tab.l_text_unfocus_gc); - Theme::WindowStyle *winstyle = m_win->getScreen()->getWindowStyle(); - size_t dlen = m_win->getTitle().size(); + Theme::WindowStyle *winstyle = m_win->getScreen()->getWindowStyle(); + size_t dlen = m_win->getTitle().size(); - size_t max_width = m_size_w; // special cases in rotated mode - if (winstyle->tab.font.isRotated()) - max_width = m_size_h; + size_t max_width = m_size_w; // special cases in rotated mode + if (winstyle->tab.font.isRotated()) + max_width = m_size_h; - int dx = DrawUtil::doAlignment(max_width, m_win->frame.bevel_w, - winstyle->tab.justify, - winstyle->tab.font, - m_win->getTitle().c_str(), m_win->getTitle().size(), dlen); + int dx = DrawUtil::doAlignment(max_width, m_win->frame.bevel_w, + winstyle->tab.justify, + winstyle->tab.font, + m_win->getTitle().c_str(), m_win->getTitle().size(), dlen); - int dy = winstyle->tab.font.ascent() + m_win->frame.bevel_w; - // swap dx and dy if we're rotated - if (winstyle->tab.font.isRotated()) { - int tmp = dy; - dy = m_size_h - dx; // upside down (reverse direction) - dx = tmp; - } + int dy = winstyle->tab.font.ascent() + m_win->frame.bevel_w; + // swap dx and dy if we're rotated + if (winstyle->tab.font.isRotated()) { + int tmp = dy; + dy = m_size_h - dx; // upside down (reverse direction) + dx = tmp; + } - winstyle->tab.font.drawText( - m_tabwin, - m_win->getScreen()->getScreenNumber(), - gc, - m_win->getTitle().c_str(), dlen, - dx, dy); + winstyle->tab.font.drawText( + m_tabwin, + m_win->getScreen()->getScreenNumber(), + gc, + m_win->getTitle().c_str(), dlen, + dx, dy); }

@@ -404,13 +404,13 @@ //according to shading in cases PBOTTOM and

//isShaded() //----------------------------------------------- int Tab::setPositionShadingHelper(bool shaded) { - if (shaded) { - return m_win->getYFrame() + m_win->getTitleHeight() + - m_win->getScreen()->getBorderWidth2x(); - } else { - return m_win->getYFrame() + m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x(); - } + if (shaded) { + return m_win->getYFrame() + m_win->getTitleHeight() + + m_win->getScreen()->getBorderWidth2x(); + } else { + return m_win->getYFrame() + m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x(); + } } //-----------------------------------------------

@@ -421,49 +421,49 @@ //alignment, the 1st for cases PTOP and PBOTTOM

//the 2nd for cases PLEFT and PRIGHT //----------------------------------------------- int Tab::setPositionTBAlignHelper(Alignment align) { - switch(align) { + switch(align) { - case ARELATIVE: - case ALEFT: - return m_win->getXFrame(); - break; - case ACENTER: - return calcCenterXPos(); - break; - case ARIGHT: - return m_win->getXFrame() + m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x() - m_size_w; - default: + case ARELATIVE: + case ALEFT: + return m_win->getXFrame(); + break; + case ACENTER: + return calcCenterXPos(); + break; + case ARIGHT: + return m_win->getXFrame() + m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x() - m_size_w; + default: #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Unsupported Alignment" << endl; + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Unsupported Alignment" << endl; #endif //DEBUG - return 0; - break; - } + return 0; + break; + } } int Tab::setPositionLRAlignHelper(Alignment align) { - switch(align) { - case ALEFT: - return m_win->getYFrame() - m_size_h + m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x(); - break; - case ACENTER: - return calcCenterYPos(); - break; - case ARELATIVE: - case ARIGHT: - return m_win->getYFrame(); - break; - default: + switch(align) { + case ALEFT: + return m_win->getYFrame() - m_size_h + m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x(); + break; + case ACENTER: + return calcCenterYPos(); + break; + case ARELATIVE: + case ARIGHT: + return m_win->getYFrame(); + break; + default: #ifdef DEBUG - cerr << __FILE__ << ":"<< __LINE__ << ": " << - "Unsupported Alignment" << endl; + cerr << __FILE__ << ":"<< __LINE__ << ": " << + "Unsupported Alignment" << endl; #endif //DEBUG - return 0; - break; - } + return 0; + break; + } } //------------- setPosition -----------------

@@ -472,86 +472,86 @@ // (and resize)

// Set new position of the other tabs in the chain //------------------------------------------- void Tab::setPosition() { - //don't do anything if the tablist is freezed - if (m_stoptabs) - return; + //don't do anything if the tablist is freezed + if (m_stoptabs) + return; - Tab *tab; - int pos_x = 0, pos_y = 0; + Tab *tab; + int pos_x = 0, pos_y = 0; - m_stoptabs = true; //freeze tablist + m_stoptabs = true; //freeze tablist - //and check for max tabs + //and check for max tabs - //Tab placement + alignment - switch (m_win->getScreen()->getTabPlacement()) { - case PTOP: - pos_y = m_win->getYFrame() - m_size_h; - pos_x = setPositionTBAlignHelper( - m_win->getScreen()->getTabAlignment()); - break; - case PBOTTOM: - pos_y = setPositionShadingHelper(m_win->isShaded()); - pos_x = setPositionTBAlignHelper( - m_win->getScreen()->getTabAlignment()); - break; - case PLEFT: - pos_x = m_win->isShaded() ? - setPositionTBAlignHelper(m_win->getScreen()->getTabAlignment()) : - m_win->getXFrame() - m_size_w; - pos_y = m_win->isShaded() ? - setPositionShadingHelper(true) : - setPositionLRAlignHelper(m_win->getScreen()->getTabAlignment()); - break; - case PRIGHT: - pos_x = m_win->isShaded() ? - setPositionTBAlignHelper(m_win->getScreen()->getTabAlignment()) : - m_win->getXFrame() + m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x(); - pos_y = m_win->isShaded() ? - setPositionShadingHelper(true) : - setPositionLRAlignHelper(m_win->getScreen()->getTabAlignment()); - break; - default: - if(m_win->isShaded()) { - pos_y = setPositionShadingHelper(true); - pos_x = setPositionTBAlignHelper( - m_win->getScreen()->getTabAlignment()); - } else { - setPositionShadingHelper(false); - } - break; - } + //Tab placement + alignment + switch (m_win->getScreen()->getTabPlacement()) { + case PTOP: + pos_y = m_win->getYFrame() - m_size_h; + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + case PBOTTOM: + pos_y = setPositionShadingHelper(m_win->isShaded()); + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + break; + case PLEFT: + pos_x = m_win->isShaded() ? + setPositionTBAlignHelper(m_win->getScreen()->getTabAlignment()) : + m_win->getXFrame() - m_size_w; + pos_y = m_win->isShaded() ? + setPositionShadingHelper(true) : + setPositionLRAlignHelper(m_win->getScreen()->getTabAlignment()); + break; + case PRIGHT: + pos_x = m_win->isShaded() ? + setPositionTBAlignHelper(m_win->getScreen()->getTabAlignment()) : + m_win->getXFrame() + m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x(); + pos_y = m_win->isShaded() ? + setPositionShadingHelper(true) : + setPositionLRAlignHelper(m_win->getScreen()->getTabAlignment()); + break; + default: + if(m_win->isShaded()) { + pos_y = setPositionShadingHelper(true); + pos_x = setPositionTBAlignHelper( + m_win->getScreen()->getTabAlignment()); + } else { + setPositionShadingHelper(false); + } + break; + } - for (tab = getFirst(this); - tab!=0; - pos_x += tab->m_inc_x, pos_y += tab->m_inc_y, - tab = tab->m_next){ + for (tab = getFirst(this); + tab!=0; + pos_x += tab->m_inc_x, pos_y += tab->m_inc_y, + tab = tab->m_next){ - XMoveWindow(m_display, tab->m_tabwin, pos_x, pos_y); + XMoveWindow(m_display, tab->m_tabwin, pos_x, pos_y); - //dont move FluxboxWindow if the iterator = this - if (tab!=this) { - tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), - m_win->getWidth(), m_win->getHeight()); - } - } + //dont move FluxboxWindow if the iterator = this + if (tab!=this) { + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + m_win->getWidth(), m_win->getHeight()); + } + } - m_stoptabs = false;//thaw tablist + m_stoptabs = false;//thaw tablist } //Moves the tab to the left void Tab::movePrev() { - insert(m_prev); + insert(m_prev); } //Moves the tab to the next tab if m_next != 0 void Tab::moveNext() { - if(m_next == 0) - return; - Tab *tmp = m_next; - disconnect(); - tmp->insert(this); + if(m_next == 0) + return; + Tab *tmp = m_next; + disconnect(); + tmp->insert(this); }

@@ -560,118 +560,118 @@ // calculates m_inc_x and m_inc_y for tabs

// used for positioning the tabs. //------------------------------------------- void Tab::calcIncrease() { - Tab *tab; - int inc_x = 0, inc_y = 0; - unsigned int i = 0, tabs = numObjects(); + Tab *tab; + int inc_x = 0, inc_y = 0; + unsigned int i = 0, tabs = numObjects(); - if (m_win->getScreen()->getTabPlacement() == PTOP || - m_win->getScreen()->getTabPlacement() == PBOTTOM || - m_win->isShaded()) { - inc_y = 0; + if (m_win->getScreen()->getTabPlacement() == PTOP || + m_win->getScreen()->getTabPlacement() == PBOTTOM || + m_win->isShaded()) { + inc_y = 0; - switch(m_win->getScreen()->getTabAlignment()) { - case ALEFT: - inc_x = m_size_w; - break; - case ACENTER: - inc_x = m_size_w; - break; - case ARIGHT: - inc_x = -m_size_w; - break; - case ARELATIVE: - inc_x = calcRelativeWidth(); - break; - default: - break; - } - } else if (m_win->getScreen()->getTabPlacement() == PLEFT || - m_win->getScreen()->getTabPlacement() == PRIGHT) { - inc_x = 0; + switch(m_win->getScreen()->getTabAlignment()) { + case ALEFT: + inc_x = m_size_w; + break; + case ACENTER: + inc_x = m_size_w; + break; + case ARIGHT: + inc_x = -m_size_w; + break; + case ARELATIVE: + inc_x = calcRelativeWidth(); + break; + default: + break; + } + } else if (m_win->getScreen()->getTabPlacement() == PLEFT || + m_win->getScreen()->getTabPlacement() == PRIGHT) { + inc_x = 0; - switch(m_win->getScreen()->getTabAlignment()) { - case ALEFT: - inc_y = -m_size_h; - break; - case ACENTER: - inc_y = m_size_h; - break; - case ARIGHT: - inc_y = m_size_h; - break; - case ARELATIVE: - inc_y = calcRelativeHeight(); - break; - default: - break; - } - } + switch(m_win->getScreen()->getTabAlignment()) { + case ALEFT: + inc_y = -m_size_h; + break; + case ACENTER: + inc_y = m_size_h; + break; + case ARIGHT: + inc_y = m_size_h; + break; + case ARELATIVE: + inc_y = calcRelativeHeight(); + break; + default: + break; + } + } - for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++) { + for (tab = getFirst(this); tab!=0; tab = tab->m_next, i++) { //TODO: move this out from here? - if ((m_win->getScreen()->getTabPlacement() == PTOP || - m_win->getScreen()->getTabPlacement() == PBOTTOM || - m_win->isShaded()) && - m_win->getScreen()->getTabAlignment() == ARELATIVE) { - if (!((m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x()) % tabs) || - i >= ((m_win->getWidth() + - m_win->getScreen()->getBorderWidth2x()) % tabs)) { - tab->setTabWidth(inc_x); - tab->m_inc_x = inc_x; - } else { // adding 1 extra pixel to get tabs like win width - tab->setTabWidth(inc_x + 1); - tab->m_inc_x = inc_x + 1; - } - tab->m_inc_y = inc_y; - } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { - if (!((m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x()) % tabs) || - i >= ((m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x()) % tabs)) { + if ((m_win->getScreen()->getTabPlacement() == PTOP || + m_win->getScreen()->getTabPlacement() == PBOTTOM || + m_win->isShaded()) && + m_win->getScreen()->getTabAlignment() == ARELATIVE) { + if (!((m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x()) % tabs) || + i >= ((m_win->getWidth() + + m_win->getScreen()->getBorderWidth2x()) % tabs)) { + tab->setTabWidth(inc_x); + tab->m_inc_x = inc_x; + } else { // adding 1 extra pixel to get tabs like win width + tab->setTabWidth(inc_x + 1); + tab->m_inc_x = inc_x + 1; + } + tab->m_inc_y = inc_y; + } else if (m_win->getScreen()->getTabAlignment() == ARELATIVE) { + if (!((m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x()) % tabs) || + i >= ((m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x()) % tabs)) { - tab->setTabHeight(inc_y); - tab->m_inc_y = inc_y; - } else { + tab->setTabHeight(inc_y); + tab->m_inc_y = inc_y; + } else { // adding 1 extra pixel to get tabs match window width - tab->setTabHeight(inc_y + 1); - tab->m_inc_y = inc_y + 1; - } - tab->m_inc_x = inc_x; - } else { // non relative modes - tab->m_inc_x = inc_x; - tab->m_inc_y = inc_y; - } - } + tab->setTabHeight(inc_y + 1); + tab->m_inc_y = inc_y + 1; + } + tab->m_inc_x = inc_x; + } else { // non relative modes + tab->m_inc_x = inc_x; + tab->m_inc_y = inc_y; + } + } } //------------- buttonPressEvent ----------- // Handle button press event here. //------------------------------------------ void Tab::buttonPressEvent(XButtonEvent *be) { - //draw in pressed mode - draw(true); + //draw in pressed mode + draw(true); - //invoke root menu with auto-glueing? - if (be->button == 3) { - BScreen *screen = m_win->getScreen(); - Rootmenu *rootmenu = screen->getRootmenu(); - if (! rootmenu->isVisible()) { - Fluxbox::instance()->checkMenu(); - screen->getRootmenu()->move(be->x_root, be->y_root-rootmenu->titleHeight()); - rootmenu->setAutoGroupWindow(m_win->getClientWindow()); - rootmenu->show(); - } - } - //otherwise let the window handle the event - else { - //set window to titlewindow so we can take advantage of drag function - be->window = m_win->frame.title; + //invoke root menu with auto-glueing? + if (be->button == 3) { + BScreen *screen = m_win->getScreen(); + Rootmenu *rootmenu = screen->getRootmenu(); + if (! rootmenu->isVisible()) { + Fluxbox::instance()->checkMenu(); + screen->getRootmenu()->move(be->x_root, be->y_root-rootmenu->titleHeight()); + rootmenu->setAutoGroupWindow(m_win->getClientWindow()); + rootmenu->show(); + } + } + //otherwise let the window handle the event + else { + //set window to titlewindow so we can take advantage of drag function + be->window = m_win->frame.title; - //call windows buttonpress eventhandler - m_win->buttonPressEvent(be); - } + //call windows buttonpress eventhandler + m_win->buttonPressEvent(be); + } } //----------- buttonReleaseEvent ----------

@@ -681,109 +681,109 @@ // the window where the tab where dropped.

//----------------------------------------- void Tab::buttonReleaseEvent(XButtonEvent *be) { - if (m_moving) { + if (m_moving) { - m_moving = false; + m_moving = false; - //erase tabmoving rectangle - XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), - m_win->getScreen()->getOpGC(), - m_move_x, m_move_y, - m_size_w, m_size_h); + //erase tabmoving rectangle + XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), + m_win->getScreen()->getOpGC(), + m_move_x, m_move_y, + m_size_w, m_size_h); - Fluxbox::instance()->ungrab(); - XUngrabPointer(m_display, CurrentTime); + Fluxbox::instance()->ungrab(); + XUngrabPointer(m_display, CurrentTime); - //storage of window and pos of window where we dropped the tab - Window child; - int dest_x = 0, dest_y = 0; + //storage of window and pos of window where we dropped the tab + Window child; + int dest_x = 0, dest_y = 0; - //find window on coordinates of buttonReleaseEvent - if (XTranslateCoordinates(m_display, m_win->getScreen()->getRootWindow(), - m_win->getScreen()->getRootWindow(), - be->x_root, be->y_root, &dest_x, &dest_y, &child)) { + //find window on coordinates of buttonReleaseEvent + if (XTranslateCoordinates(m_display, m_win->getScreen()->getRootWindow(), + m_win->getScreen()->getRootWindow(), + be->x_root, be->y_root, &dest_x, &dest_y, &child)) { - Tab *tab = Fluxbox::instance()->searchTab(child); - FluxboxWindow *win = Fluxbox::instance()->searchWindow(child); - if(win!=0 && m_win->getScreen()->isSloppyWindowGrouping()) - win->setTab(true); - //search tablist for a tabwindow - if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() && - (win!=0) && (tab = win->getTab())!=0)) { + Tab *tab = Fluxbox::instance()->searchTab(child); + FluxboxWindow *win = Fluxbox::instance()->searchWindow(child); + if(win!=0 && m_win->getScreen()->isSloppyWindowGrouping()) + win->setTab(true); + //search tablist for a tabwindow + if ( (tab!=0) || (m_win->getScreen()->isSloppyWindowGrouping() && + (win!=0) && (tab = win->getTab())!=0)) { - if (tab == this) // inserting ourself to ourself causes a disconnect - return; + if (tab == this) // inserting ourself to ourself causes a disconnect + return; // do only attach a hole chain if we dropped the // first tab in the dropped chain... - if (m_prev) - disconnect(); + if (m_prev) + disconnect(); // attach this tabwindow chain to the tabwindow chain we found. - tab->insert(this); + tab->insert(this); - } else { //Dropped nowhere - disconnect(); + } else { //Dropped nowhere + disconnect(); // convenience - unsigned int placement = m_win->getScreen()->getTabPlacement(); + unsigned int placement = m_win->getScreen()->getTabPlacement(); // (ab)using dest_x and dest_y - dest_x = be->x_root; - dest_y = be->y_root; + dest_x = be->x_root; + dest_y = be->y_root; - if (placement == PTOP || placement == PBOTTOM || m_win->isShaded()) { - if (placement == PBOTTOM && !m_win->isShaded()) - dest_y -= m_win->getHeight(); - else if (placement != PTOP && m_win->isShaded()) - dest_y -= m_win->getTitleHeight(); - else // PTOP - dest_y += m_win->getTitleHeight(); + if (placement == PTOP || placement == PBOTTOM || m_win->isShaded()) { + if (placement == PBOTTOM && !m_win->isShaded()) + dest_y -= m_win->getHeight(); + else if (placement != PTOP && m_win->isShaded()) + dest_y -= m_win->getTitleHeight(); + else // PTOP + dest_y += m_win->getTitleHeight(); - switch(m_win->getScreen()->getTabAlignment()) { - case ACENTER: - dest_x -= (m_win->getWidth() / 2) - (m_size_w / 2); - break; - case ARIGHT: - dest_x -= m_win->getWidth() - m_size_w; - break; - default: - break; - } + switch(m_win->getScreen()->getTabAlignment()) { + case ACENTER: + dest_x -= (m_win->getWidth() / 2) - (m_size_w / 2); + break; + case ARIGHT: + dest_x -= m_win->getWidth() - m_size_w; + break; + default: + break; + } - } else { // PLEFT & PRIGHT - if (placement == PRIGHT) - dest_x = be->x_root - m_win->getWidth(); + } else { // PLEFT & PRIGHT + if (placement == PRIGHT) + dest_x = be->x_root - m_win->getWidth(); - switch(m_win->getScreen()->getTabAlignment()) { - case ACENTER: - dest_y -= (m_win->getHeight() / 2) - (m_size_h / 2); - break; - case ALEFT: - dest_y -= m_win->getHeight() - m_size_h; - break; - default: - break; - } - } + switch(m_win->getScreen()->getTabAlignment()) { + case ACENTER: + dest_y -= (m_win->getHeight() / 2) - (m_size_h / 2); + break; + case ALEFT: + dest_y -= m_win->getHeight() - m_size_h; + break; + default: + break; + } + } //TODO: this causes an calculate increase event, even if we // only are moving a window - m_win->configure(dest_x, dest_y, m_win->getWidth(), m_win->getHeight()); - if(!Fluxbox::instance()->useTabs()) - m_win->setTab(0);//Remove tab from window, as it is now alone... - } - } - } else { + m_win->configure(dest_x, dest_y, m_win->getWidth(), m_win->getHeight()); + if(!Fluxbox::instance()->useTabs()) + m_win->setTab(0);//Remove tab from window, as it is now alone... + } + } + } else { - //raise this tabwindow - raise(); + //raise this tabwindow + raise(); - //set window to title window soo we can use m_win handler for menu - be->window = m_win->frame.title; + //set window to title window soo we can use m_win handler for menu + be->window = m_win->frame.title; - //call windows buttonrelease event handler so it can popup a menu if needed - m_win->buttonReleaseEvent(be); - } + //call windows buttonrelease event handler so it can popup a menu if needed + m_win->buttonReleaseEvent(be); + } }

@@ -792,7 +792,7 @@ // Handle expose event here.

// Draws the tab unpressed //-------------------------------------- void Tab::exposeEvent(XExposeEvent *ee) { - draw(false); + draw(false); } //----------- motionNotifyEvent --------

@@ -801,85 +801,85 @@ // Draws the rectangle of moving tab

//-------------------------------------- void Tab::motionNotifyEvent(XMotionEvent *me) { - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - //if mousebutton 2 is pressed - if (me->state & Button2Mask) { - if (!m_moving) { - m_moving = true; + //if mousebutton 2 is pressed + if (me->state & Button2Mask) { + if (!m_moving) { + m_moving = true; - XGrabPointer(m_display, me->window, False, Button2MotionMask | - ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - None, fluxbox->getMoveCursor(), CurrentTime); + XGrabPointer(m_display, me->window, False, Button2MotionMask | + ButtonReleaseMask, GrabModeAsync, GrabModeAsync, + None, fluxbox->getMoveCursor(), CurrentTime); - fluxbox->grab(); + fluxbox->grab(); - m_move_x = me->x_root - 1; - m_move_y = me->y_root - 1; + m_move_x = me->x_root - 1; + m_move_y = me->y_root - 1; - XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), - m_win->getScreen()->getOpGC(), - m_move_x, m_move_y, - m_size_w, m_size_h); + XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), + m_win->getScreen()->getOpGC(), + m_move_x, m_move_y, + m_size_w, m_size_h); - } else { + } else { - int dx = me->x_root - 1, dy = me->y_root - 1; + int dx = me->x_root - 1, dy = me->y_root - 1; - dx -= m_win->getScreen()->getBorderWidth(); - dy -= m_win->getScreen()->getBorderWidth(); + dx -= m_win->getScreen()->getBorderWidth(); + dy -= m_win->getScreen()->getBorderWidth(); - if (m_win->getScreen()->getEdgeSnapThreshold()) { - int drx = m_win->getScreen()->getWidth() - (dx + 1); + if (m_win->getScreen()->getEdgeSnapThreshold()) { + int drx = m_win->getScreen()->getWidth() - (dx + 1); - if (dx > 0 && dx < drx && dx < m_win->getScreen()->getEdgeSnapThreshold()) - dx = 0; - else if (drx > 0 && drx < m_win->getScreen()->getEdgeSnapThreshold()) - dx = m_win->getScreen()->getWidth() - 1; + if (dx > 0 && dx < drx && dx < m_win->getScreen()->getEdgeSnapThreshold()) + dx = 0; + else if (drx > 0 && drx < m_win->getScreen()->getEdgeSnapThreshold()) + dx = m_win->getScreen()->getWidth() - 1; - int dtty, dbby, dty, dby; + int dtty, dbby, dty, dby; - switch (m_win->getScreen()->getToolbarPlacement()) { - case Toolbar::TOPLEFT: - case Toolbar::TOPCENTER: - case Toolbar::TOPRIGHT: - dtty = m_win->getScreen()->getToolbar()->exposedHeight() + - m_win->getScreen()->getBorderWidth(); - dbby = m_win->getScreen()->getHeight(); - break; + switch (m_win->getScreen()->getToolbarPlacement()) { + case Toolbar::TOPLEFT: + case Toolbar::TOPCENTER: + case Toolbar::TOPRIGHT: + dtty = m_win->getScreen()->getToolbar()->exposedHeight() + + m_win->getScreen()->getBorderWidth(); + dbby = m_win->getScreen()->getHeight(); + break; - default: - dtty = 0; - dbby = m_win->getScreen()->getToolbar()->y(); - break; - } + default: + dtty = 0; + dbby = m_win->getScreen()->getToolbar()->y(); + break; + } - dty = dy - dtty; - dby = dbby - (dy + 1); + dty = dy - dtty; + dby = dbby - (dy + 1); - if (dy > 0 && dty < m_win->getScreen()->getEdgeSnapThreshold()) - dy = dtty; - else if (dby > 0 && dby < m_win->getScreen()->getEdgeSnapThreshold()) - dy = dbby - 1; + if (dy > 0 && dty < m_win->getScreen()->getEdgeSnapThreshold()) + dy = dtty; + else if (dby > 0 && dby < m_win->getScreen()->getEdgeSnapThreshold()) + dy = dbby - 1; - } + } - //erase rectangle - XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), - m_win->getScreen()->getOpGC(), - m_move_x, m_move_y, - m_size_w, m_size_h); + //erase rectangle + XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), + m_win->getScreen()->getOpGC(), + m_move_x, m_move_y, + m_size_w, m_size_h); - //redraw rectangle at new pos - m_move_x = dx; - m_move_y = dy; - XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), - m_win->getScreen()->getOpGC(), - m_move_x, m_move_y, - m_size_w, m_size_h); + //redraw rectangle at new pos + m_move_x = dx; + m_move_y = dy; + XDrawRectangle(m_display, m_win->getScreen()->getRootWindow(), + m_win->getScreen()->getOpGC(), + m_move_x, m_move_y, + m_size_w, m_size_h); - } - } + } + } } //-------------- getFirst() ---------

@@ -887,13 +887,13 @@ // Returns the first Tab in the chain

// of currentchain. //----------------------------------- Tab *Tab::getFirst(Tab *current) { - if (!current) - return 0; + if (!current) + return 0; - Tab *i=current; + Tab *i=current; - for (; i->m_prev != 0; i = i->m_prev); - return i; + for (; i->m_prev != 0; i = i->m_prev); + return i; } //-------------- getLast() ---------

@@ -901,12 +901,12 @@ // Returns the last Tab in the chain

// of currentchain. //----------------------------------- Tab *Tab::getLast(Tab *current) { - if (!current) - return 0; - Tab *i=current; + if (!current) + return 0; + Tab *i=current; - for (; i->m_next != 0; i = i->m_next); - return i; + for (; i->m_next != 0; i = i->m_next); + return i; } //-------------- insert ------------

@@ -915,162 +915,162 @@ // Inserts a tab in the chain

//---------------------------------- void Tab::insert(Tab *tab) { - if (!tab || tab == this) //dont insert if the tab = 0 or the tab = this - return; + if (!tab || tab == this) //dont insert if the tab = 0 or the tab = this + return; - Tab *first = getFirst(this); + Tab *first = getFirst(this); - //if the tab already in chain then disconnect it - for (; first!=0; first = first->m_next) { - if (first==tab) { - #ifdef DEBUG - cerr<<"Tab already in chain. Disconnecting!"<<endl; - #endif // DEBUG - tab->disconnect(); - break; - } - } + //if the tab already in chain then disconnect it + for (; first!=0; first = first->m_next) { + if (first==tab) { +#ifdef DEBUG + cerr<<"Tab already in chain. Disconnecting!"<<endl; +#endif // DEBUG + tab->disconnect(); + break; + } + } - //get last tab in the chain to be inserted - Tab *last = tab; - for (; last->m_next!=0; last=last->m_next); - //do sticky before we connect it to the chain - //sticky bit on window - if (m_win->isStuck() != tab->m_win->isStuck()) { - tab->m_win->stuck = !m_win->stuck; // it will toggle - tab->stick(); //this will set all the m_wins in the list - } + //get last tab in the chain to be inserted + Tab *last = tab; + for (; last->m_next!=0; last=last->m_next); + //do sticky before we connect it to the chain + //sticky bit on window + if (m_win->isStuck() != tab->m_win->isStuck()) { + tab->m_win->stuck = !m_win->stuck; // it will toggle + tab->stick(); //this will set all the m_wins in the list + } - //connect the tab to this chain + //connect the tab to this chain - if (m_next) - m_next->m_prev = last; - tab->m_prev = this; - last->m_next = m_next; + if (m_next) + m_next->m_prev = last; + tab->m_prev = this; + last->m_next = m_next; - m_next = tab; + m_next = tab; - bool resize_tabs = false; + bool resize_tabs = false; - //TODO: cleanup and optimize - //move and resize all windows in the tablist we inserted - //only from first tab of the inserted chain to the last - for (; tab!=last->m_next; tab=tab->m_next) { - if (m_win->isShaded() != tab->m_win->isShaded()) { - tab->m_stoptabs = true; // we don't want any actions performed on the - // tabs, just the tab windows! - if (m_win->getScreen()->getTabPlacement() == PLEFT || - m_win->getScreen()->getTabPlacement() == PRIGHT) - resize_tabs = true; + //TODO: cleanup and optimize + //move and resize all windows in the tablist we inserted + //only from first tab of the inserted chain to the last + for (; tab!=last->m_next; tab=tab->m_next) { + if (m_win->isShaded() != tab->m_win->isShaded()) { + tab->m_stoptabs = true; // we don't want any actions performed on the + // tabs, just the tab windows! + if (m_win->getScreen()->getTabPlacement() == PLEFT || + m_win->getScreen()->getTabPlacement() == PRIGHT) + resize_tabs = true; - // if the window we are grouping to, we need to shade the tab window - // _after_ reconfigure - if(m_win->isShaded()) { - tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), - m_win->getWidth(), m_win->getHeight()); - tab->m_win->shade(); - } else { - tab->m_win->shade(); // switch to correct shade state - tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), - m_win->getWidth(), m_win->getHeight()); - } + // if the window we are grouping to, we need to shade the tab window + // _after_ reconfigure + if(m_win->isShaded()) { + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + m_win->getWidth(), m_win->getHeight()); + tab->m_win->shade(); + } else { + tab->m_win->shade(); // switch to correct shade state + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + m_win->getWidth(), m_win->getHeight()); + } - tab->m_stoptabs = false; + tab->m_stoptabs = false; - // both window have the same shaded state and have different sizes, - // checking this so that I'll only do shade on windows if configure did - // anything. - } else if ((m_win->getWidth() != tab->m_win->getWidth()) || - (m_win->getHeight() != tab->m_win->getHeight())) { + // both window have the same shaded state and have different sizes, + // checking this so that I'll only do shade on windows if configure did + // anything. + } else if ((m_win->getWidth() != tab->m_win->getWidth()) || + (m_win->getHeight() != tab->m_win->getHeight())) { - tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), - m_win->getWidth(), m_win->getHeight()); + tab->m_win->configure(m_win->getXFrame(), m_win->getYFrame(), + m_win->getWidth(), m_win->getHeight()); - // need to shade the tab window as configure will mess it up - if (m_win->isShaded()) - tab->m_win->shade(); - } - } + // need to shade the tab window as configure will mess it up + if (m_win->isShaded()) + tab->m_win->shade(); + } + } - // resize if in relative mode or resize_tabs is true - if(m_win->getScreen()->getTabAlignment() == ARELATIVE || - resize_tabs) { - resizeGroup(); - calcIncrease(); - } - // reposition tabs - setPosition(); + // resize if in relative mode or resize_tabs is true + if(m_win->getScreen()->getTabAlignment() == ARELATIVE || + resize_tabs) { + resizeGroup(); + calcIncrease(); + } + // reposition tabs + setPosition(); } //---------- disconnect() -------------- // Disconnects the tab from any chain //-------------------------------------- void Tab::disconnect() { - Tab *tmp = 0; + Tab *tmp = 0; - Fluxbox *fluxbox = Fluxbox::instance(); - if (m_prev) { //if this have a chain to "the left" (previous tab) then set it's next to this next - m_prev->m_next = m_next; - if(!m_next && !fluxbox->useTabs())//Only two tabs in list, remove tab from remaining window - m_prev->m_win->setTab(false); - else - tmp = m_prev; - } - if (m_next) { //if this have a chain to "the right" (next tab) then set it's prev to this prev - m_next->m_prev = m_prev; - if(!m_prev && !fluxbox->useTabs())//Only two tabs in list, remove tab from remaining window - m_next->m_win->setTab(false); - else - tmp = m_next; - } + Fluxbox *fluxbox = Fluxbox::instance(); + if (m_prev) { //if this have a chain to "the left" (previous tab) then set it's next to this next + m_prev->m_next = m_next; + if(!m_next && !fluxbox->useTabs())//Only two tabs in list, remove tab from remaining window + m_prev->m_win->setTab(false); + else + tmp = m_prev; + } + if (m_next) { //if this have a chain to "the right" (next tab) then set it's prev to this prev + m_next->m_prev = m_prev; + if(!m_prev && !fluxbox->useTabs())//Only two tabs in list, remove tab from remaining window + m_next->m_win->setTab(false); + else + tmp = m_next; + } - //mark as no chain, previous and next. - m_prev = 0; - m_next = 0; + //mark as no chain, previous and next. + m_prev = 0; + m_next = 0; - //reposition the tabs - if (tmp) { - if (m_win->getScreen()->getTabAlignment() == ARELATIVE) - tmp->calcIncrease(); - tmp->setPosition(); - } + //reposition the tabs + if (tmp) { + if (m_win->getScreen()->getTabAlignment() == ARELATIVE) + tmp->calcIncrease(); + tmp->setPosition(); + } - if (m_win->getScreen()->getTabAlignment() == ARELATIVE) - calcIncrease(); + if (m_win->getScreen()->getTabAlignment() == ARELATIVE) + calcIncrease(); - setPosition(); + setPosition(); } // ------------ setTabWidth -------------- // Sets Tab width _including_ borders // --------------------------------------- void Tab::setTabWidth(unsigned int w) { - if (w > m_win->getScreen()->getWindowStyle()->tab.border_width_2x && - w != m_size_w) { - m_size_w = w; - XResizeWindow(m_display, m_tabwin, - m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, - m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x); + if (w > m_win->getScreen()->getWindowStyle()->tab.border_width_2x && + w != m_size_w) { + m_size_w = w; + XResizeWindow(m_display, m_tabwin, + m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, + m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x); - loadTheme(); // rerender themes to right size - focus(); // redraw the window - } + loadTheme(); // rerender themes to right size + focus(); // redraw the window + } } // ------------ setTabHeight --------- // Sets Tab height _including_ borders // --------------------------------------- void Tab::setTabHeight(unsigned int h) { - if (h > m_win->getScreen()->getWindowStyle()->tab.border_width_2x && - h != m_size_h) { - m_size_h = h; - XResizeWindow(m_display, m_tabwin, - m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, - m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x); + if (h > m_win->getScreen()->getWindowStyle()->tab.border_width_2x && + h != m_size_h) { + m_size_h = h; + XResizeWindow(m_display, m_tabwin, + m_size_w - m_win->getScreen()->getWindowStyle()->tab.border_width_2x, + m_size_h - m_win->getScreen()->getWindowStyle()->tab.border_width_2x); - loadTheme(); // rerender themes to right size - focus(); // redraw the window - } + loadTheme(); // rerender themes to right size + focus(); // redraw the window + } } // ------------ resizeGroup --------------

@@ -1080,23 +1080,23 @@ // PLeft || PRight && isTabRotateVertical

// --------------------------------------- void Tab::resizeGroup() { #ifdef DEBUG - cerr <<__FILE__<<"("<<__LINE__<<"): Resizing group"<<endl; + cerr <<__FILE__<<"("<<__LINE__<<"): Resizing group"<<endl; #endif //DEBUG - Tab *first; - for (first = getFirst(this); first != 0; first = first->m_next) { - if ((m_win->getScreen()->getTabPlacement() == PLEFT || - m_win->getScreen()->getTabPlacement() == PRIGHT) && - m_win->getScreen()->isTabRotateVertical() && - !m_win->isShaded()) { - first->setTabWidth(m_win->getScreen()->getTabHeight()); - first->setTabHeight(m_win->getScreen()->getTabWidth()); - } else { - first->setTabWidth(m_win->getScreen()->getTabWidth()); - first->setTabHeight(m_win->getScreen()->getTabHeight()); - } - //TODO: do I have to set this all the time? - first->m_configured = true; //used in Fluxbox::reconfigure() - } + Tab *first; + for (first = getFirst(this); first != 0; first = first->m_next) { + if ((m_win->getScreen()->getTabPlacement() == PLEFT || + m_win->getScreen()->getTabPlacement() == PRIGHT) && + m_win->getScreen()->isTabRotateVertical() && + !m_win->isShaded()) { + first->setTabWidth(m_win->getScreen()->getTabHeight()); + first->setTabHeight(m_win->getScreen()->getTabWidth()); + } else { + first->setTabWidth(m_win->getScreen()->getTabWidth()); + first->setTabHeight(m_win->getScreen()->getTabHeight()); + } + //TODO: do I have to set this all the time? + first->m_configured = true; //used in Fluxbox::reconfigure() + } } //------------- calcRelativeWidth --------

@@ -1104,11 +1104,11 @@ // Returns: Calculated width for relative

// alignment //---------------------------------------- unsigned int Tab::calcRelativeWidth() { - unsigned int num=0; - //calculate num objs in list (extract this to a function?) - for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++); + unsigned int num=0; + //calculate num objs in list (extract this to a function?) + for (Tab *first=getFirst(this); first!=0; first=first->m_next, num++); - return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num); + return ((m_win->getWidth() + m_win->getScreen()->getBorderWidth2x())/num); } //--------------- numObjects -------------------

@@ -1116,9 +1116,9 @@ // Returns the number of objects in

// the TabGroup. //----------------------------------------------- unsigned int Tab::numObjects() { - unsigned int num = 0; - for (Tab *tab = getFirst(this); tab != 0; tab = tab->m_next, num++); - return num; + unsigned int num = 0; + for (Tab *tab = getFirst(this); tab != 0; tab = tab->m_next, num++); + return num; } //------------- calcRelativeHeight -------

@@ -1126,8 +1126,8 @@ // Returns: Calculated height for relative

// alignment //---------------------------------------- unsigned int Tab::calcRelativeHeight() { - return ((m_win->getHeight() + - m_win->getScreen()->getBorderWidth2x())/numObjects()); + return ((m_win->getHeight() + + m_win->getScreen()->getBorderWidth2x())/numObjects()); } //------------- calcCenterXPos -----------

@@ -1135,8 +1135,8 @@ // Returns: Calculated x position for

// centered alignment //---------------------------------------- unsigned int Tab::calcCenterXPos() { - return (m_win->getXFrame() + ((m_win->getWidth() - - (m_size_w * numObjects())) / 2)); + return (m_win->getXFrame() + ((m_win->getWidth() - + (m_size_w * numObjects())) / 2)); } //------------- calcCenterYPos -----------

@@ -1144,8 +1144,8 @@ // Returns: Calculated y position for

// centered alignment //---------------------------------------- unsigned int Tab::calcCenterYPos() { - return (m_win->getYFrame() + ((m_win->getHeight() - - (m_size_h * numObjects())) / 2)); + return (m_win->getYFrame() + ((m_win->getHeight() - + (m_size_h * numObjects())) / 2)); }

@@ -1154,11 +1154,11 @@ // Returns the tabplacement string of the

// tabplacement number on success else 0. //---------------------------------------- const char *Tab::getTabPlacementString(Tab::Placement placement) { - for (int i=0; i<(PNONE / 5); i++) { - if (m_tabplacementlist[i] == placement) - return m_tabplacementlist[i].string; - } - return 0; + for (int i=0; i<(PNONE / 5); i++) { + if (m_tabplacementlist[i] == placement) + return m_tabplacementlist[i].string; + } + return 0; } //------- getTabPlacementNum -------------

@@ -1167,12 +1167,12 @@ // tabplacement string on success else

// the type none on failure. //---------------------------------------- Tab::Placement Tab::getTabPlacementNum(const char *string) { - for (int i=0; i<(PNONE / 5); i ++) { - if (m_tabplacementlist[i] == string) { - return static_cast<Tab::Placement>(m_tabplacementlist[i].tp); - } - } - return PNONE; + for (int i=0; i<(PNONE / 5); i ++) { + if (m_tabplacementlist[i] == string) { + return static_cast<Tab::Placement>(m_tabplacementlist[i].tp); + } + } + return PNONE; } //------- getTabAlignmentString ----------

@@ -1180,11 +1180,11 @@ // Returns the tabplacement string of the

// tabplacement number on success else 0. //---------------------------------------- const char *Tab::getTabAlignmentString(Tab::Alignment alignment) { - for (int i=0; i<ANONE; i++) { - if (m_tabalignmentlist[i] == alignment) - return m_tabalignmentlist[i].string; - } - return 0; + for (int i=0; i<ANONE; i++) { + if (m_tabalignmentlist[i] == alignment) + return m_tabalignmentlist[i].string; + } + return 0; } //------- getTabAlignmentNum -------------

@@ -1193,12 +1193,12 @@ // tabplacement string on success else

// the type none on failure. //---------------------------------------- Tab::Alignment Tab::getTabAlignmentNum(const char *string) { - for (int i=0; i<ANONE; i++) { - if (m_tabalignmentlist[i] == string) { - return static_cast<Tab::Alignment>(m_tabalignmentlist[i].tp); - } - } - return ANONE; + for (int i=0; i<ANONE; i++) { + if (m_tabalignmentlist[i] == string) { + return static_cast<Tab::Alignment>(m_tabalignmentlist[i].tp); + } + } + return ANONE; } //---------- addWindowToGroup ------------

@@ -1206,11 +1206,11 @@ // Add a window the the tabbed group

//---------------------------------------- bool Tab::addWindowToGroup(FluxboxWindow *otherWindow) { - if (!otherWindow || otherWindow == m_win) - return false; - Tab *otherTab = otherWindow->getTab(); - if (!otherTab) - return false; - insert(otherTab); - return true; + if (!otherWindow || otherWindow == m_win) + return false; + Tab *otherTab = otherWindow->getTab(); + if (!otherTab) + return false; + insert(otherTab); + return true; }
M src/Tab.hhsrc/Tab.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: Tab.hh,v 1.16 2002/11/30 20:56:21 fluxgen Exp $ +// $Id: Tab.hh,v 1.17 2002/12/01 13:42:00 rathnor Exp $ #ifndef TAB_HH #define TAB_HH

@@ -33,118 +33,118 @@ Note: Tab is a friend of FluxboxWindow

*/ class Tab { public: - enum Placement{ PTOP = 0, PBOTTOM = 5, PLEFT = 10, PRIGHT = 15, PNONE = 20}; - enum Alignment{ ALEFT = 0, ACENTER, ARIGHT, ARELATIVE, ANONE }; + enum Placement{ PTOP = 0, PBOTTOM = 5, PLEFT = 10, PRIGHT = 15, PNONE = 20}; + enum Alignment{ ALEFT = 0, ACENTER, ARIGHT, ARELATIVE, ANONE }; - Tab(FluxboxWindow *win, Tab *prev=0, Tab *next=0); - ~Tab(); + Tab(FluxboxWindow *win, Tab *prev=0, Tab *next=0); + ~Tab(); - void setConfigured(bool value) { m_configured = value; } - Tab *next() { return m_next; } - Tab *prev() { return m_prev; } - Tab *last() { return getLast(this); } - Tab *first() { return getFirst(this); } - FluxboxWindow *getWindow() { return m_win; } + void setConfigured(bool value) { m_configured = value; } + Tab *next() { return m_next; } + Tab *prev() { return m_prev; } + Tab *last() { return getLast(this); } + Tab *first() { return getFirst(this); } + FluxboxWindow *getWindow() { return m_win; } - void focus(); - void decorate(); - void deiconify(); - void iconify(); - void raise(); - void lower(); - void withdraw(); - void stick(); - void resize(); - void shade(); - void setPosition(); //position tab to follow (FluxboxWindow *) m_win - void moveNext(); - void movePrev(); - void insert(Tab *next); + void focus(); + void decorate(); + void deiconify(); + void iconify(); + void raise(); + void lower(); + void withdraw(); + void stick(); + void resize(); + void shade(); + void setPosition(); //position tab to follow (FluxboxWindow *) m_win + void moveNext(); + void movePrev(); + void insert(Tab *next); - //event handlers - void buttonReleaseEvent(XButtonEvent *be); - void buttonPressEvent(XButtonEvent *be); - void exposeEvent(XExposeEvent *ee); - void motionNotifyEvent(XMotionEvent *me); + //event handlers + void buttonReleaseEvent(XButtonEvent *be); + void buttonPressEvent(XButtonEvent *be); + void exposeEvent(XExposeEvent *ee); + void motionNotifyEvent(XMotionEvent *me); - void disconnect(); + void disconnect(); - //accessors + //accessors - static const char *getTabPlacementString(Tab::Placement placement); - static Tab::Placement getTabPlacementNum(const char *string); - static const char *getTabAlignmentString(Tab::Alignment alignment); - static Tab::Alignment getTabAlignmentNum(const char *string); + static const char *getTabPlacementString(Tab::Placement placement); + static Tab::Placement getTabPlacementNum(const char *string); + static const char *getTabAlignmentString(Tab::Alignment alignment); + static Tab::Alignment getTabAlignmentNum(const char *string); - const Tab *next() const { return m_next; } - const Tab *prev() const { return m_prev; } - const Tab *last() const { return getLast(const_cast<Tab *>(this)); } - const Tab *first() const { return getFirst(const_cast<Tab *>(this)); } + const Tab *next() const { return m_next; } + const Tab *prev() const { return m_prev; } + const Tab *last() const { return getLast(const_cast<Tab *>(this)); } + const Tab *first() const { return getFirst(const_cast<Tab *>(this)); } - const FluxboxWindow *getWindow() const { return m_win; } - Window getTabWindow() const { return m_tabwin; } - unsigned int getTabWidth() const { return m_size_w; } - unsigned int getTabHeight() const { return m_size_h; } + const FluxboxWindow *getWindow() const { return m_win; } + Window getTabWindow() const { return m_tabwin; } + unsigned int getTabWidth() const { return m_size_w; } + unsigned int getTabHeight() const { return m_size_h; } - void resizeGroup(); // used when (un)shading windows - void calcIncrease(); - bool configured() const { return m_configured; } - void draw(bool pressed) const; + void resizeGroup(); // used when (un)shading windows + void calcIncrease(); + bool configured() const { return m_configured; } + void draw(bool pressed) const; - bool addWindowToGroup(FluxboxWindow *window); + bool addWindowToGroup(FluxboxWindow *window); - static Tab *getFirst(Tab *current); - static Tab *getLast(Tab *current); + static Tab *getFirst(Tab *current); + static Tab *getLast(Tab *current); private: - bool m_configured; + bool m_configured; - //The size of the tab - unsigned int m_size_w; - unsigned int m_size_h; - //Increasements - int m_inc_x; - int m_inc_y; - static const int m_max_tabs; - bool m_focus, m_moving; // moving and focus - void createTabWindow(); // creates the X win of tab - void loadTheme(); // loads the textures with right width and height - int setPositionShadingHelper(bool shaded); - int setPositionTBAlignHelper(Alignment align); - int setPositionLRAlignHelper(Alignment align); - void setTabWidth(unsigned int w); - void setTabHeight(unsigned int h); - unsigned int numObjects(); - unsigned int calcRelativeWidth(); - unsigned int calcRelativeHeight(); - unsigned int calcCenterXPos(); - unsigned int calcCenterYPos(); - int m_move_x, m_move_y; // Move coordinates, holds moving coordinates when draging - Tab *m_prev; - Tab *m_next; - FluxboxWindow *m_win; - Window m_tabwin; - Display *m_display; - Pixmap m_focus_pm, m_unfocus_pm; - unsigned long m_focus_pixel, m_unfocus_pixel; - static bool m_stoptabs; //used to "freeze" the tabs functions + //The size of the tab + unsigned int m_size_w; + unsigned int m_size_h; + //Increasements + int m_inc_x; + int m_inc_y; + static const int m_max_tabs; + bool m_focus, m_moving; // moving and focus + void createTabWindow(); // creates the X win of tab + void loadTheme(); // loads the textures with right width and height + int setPositionShadingHelper(bool shaded); + int setPositionTBAlignHelper(Alignment align); + int setPositionLRAlignHelper(Alignment align); + void setTabWidth(unsigned int w); + void setTabHeight(unsigned int h); + unsigned int numObjects(); + unsigned int calcRelativeWidth(); + unsigned int calcRelativeHeight(); + unsigned int calcCenterXPos(); + unsigned int calcCenterYPos(); + int m_move_x, m_move_y; // Move coordinates, holds moving coordinates when draging + Tab *m_prev; + Tab *m_next; + FluxboxWindow *m_win; + Window m_tabwin; + Display *m_display; + Pixmap m_focus_pm, m_unfocus_pm; + unsigned long m_focus_pixel, m_unfocus_pixel; + static bool m_stoptabs; //used to "freeze" the tabs functions - struct t_tabplacementlist{ - int tp; - const char *string; - inline bool operator == (int p) { - return (tp==p); - } - inline bool operator == (const char *str) { - if (strcasecmp(string, str) == 0) - return true; - return false; - } - }; - static t_tabplacementlist m_tabplacementlist[]; - static t_tabplacementlist m_tabalignmentlist[]; + struct t_tabplacementlist{ + int tp; + const char *string; + inline bool operator == (int p) { + return (tp==p); + } + inline bool operator == (const char *str) { + if (strcasecmp(string, str) == 0) + return true; + return false; + } + }; + static t_tabplacementlist m_tabplacementlist[]; + static t_tabplacementlist m_tabalignmentlist[]; };
M src/TextureRender.ccsrc/TextureRender.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: TextureRender.cc,v 1.2 2002/11/30 20:36:22 fluxgen Exp $ +// $Id: TextureRender.cc,v 1.3 2002/12/01 13:42:00 rathnor Exp $ #include "TextureRender.hh"

@@ -31,1724 +31,1724 @@ #include "i18n.hh"

#include "App.hh" TextureRender::TextureRender(BImageControl &imgctrl, unsigned int w, unsigned int h, - XColor *_colors, size_t num_colors): -control(imgctrl), -colors(_colors), -ncolors(ncolors), -xtable(0), ytable(0) { + XColor *_colors, size_t num_colors): + control(imgctrl), + colors(_colors), + ncolors(ncolors), + xtable(0), ytable(0) { - width = ((signed) w > 0) ? w : 1; - height = ((signed) h > 0) ? h : 1; + width = ((signed) w > 0) ? w : 1; + height = ((signed) h > 0) ? h : 1; - red = new unsigned char[width * height]; - green = new unsigned char[width * height]; - blue = new unsigned char[width * height]; + red = new unsigned char[width * height]; + green = new unsigned char[width * height]; + blue = new unsigned char[width * height]; - cpc = imgctrl.colorsPerChannel(); - cpccpc = cpc * cpc; + cpc = imgctrl.colorsPerChannel(); + cpccpc = cpc * cpc; - imgctrl.colorTables(&red_table, &green_table, &blue_table, - &red_offset, &green_offset, &blue_offset, - &red_bits, &green_bits, &blue_bits); + imgctrl.colorTables(&red_table, &green_table, &blue_table, + &red_offset, &green_offset, &blue_offset, + &red_bits, &green_bits, &blue_bits); } TextureRender::~TextureRender() { - if (red) delete [] red; - if (green) delete [] green; - if (blue) delete [] blue; + if (red) delete [] red; + if (green) delete [] green; + if (blue) delete [] blue; } Pixmap TextureRender::render(const FbTk::Texture &texture) { - if (texture.type() & FbTk::Texture::PARENTRELATIVE) - return ParentRelative; - else if (texture.type() & FbTk::Texture::SOLID) - return renderSolid(texture); - else if (texture.type() & FbTk::Texture::GRADIENT) - return renderGradient(texture); + if (texture.type() & FbTk::Texture::PARENTRELATIVE) + return ParentRelative; + else if (texture.type() & FbTk::Texture::SOLID) + return renderSolid(texture); + else if (texture.type() & FbTk::Texture::GRADIENT) + return renderGradient(texture); - return None; + return None; } Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { - Display *disp = FbTk::App::instance()->display(); + Display *disp = FbTk::App::instance()->display(); - Pixmap pixmap = XCreatePixmap(disp, - RootWindow(disp, control.screenNum()), width, - height, control.depth()); - if (pixmap == None) { - fprintf(stderr, - I18n::instance()->getMessage( - FBNLS::ImageSet, FBNLS::ImageErrorCreatingSolidPixmap, - "BImage::render_solid: error creating pixmap\n")); - return None; - } + Pixmap pixmap = XCreatePixmap(disp, + RootWindow(disp, control.screenNum()), width, + height, control.depth()); + if (pixmap == None) { + fprintf(stderr, + I18n::instance()->getMessage( + FBNLS::ImageSet, FBNLS::ImageErrorCreatingSolidPixmap, + "BImage::render_solid: error creating pixmap\n")); + return None; + } - XGCValues gcv; - GC gc, hgc, lgc; + XGCValues gcv; + GC gc, hgc, lgc; - gcv.foreground = texture.color().pixel(); - gcv.fill_style = FillSolid; - gc = XCreateGC(disp, pixmap, GCForeground | GCFillStyle, &gcv); + gcv.foreground = texture.color().pixel(); + gcv.fill_style = FillSolid; + gc = XCreateGC(disp, pixmap, GCForeground | GCFillStyle, &gcv); - gcv.foreground = texture.hiColor().pixel(); - hgc = XCreateGC(disp, pixmap, GCForeground, &gcv); + gcv.foreground = texture.hiColor().pixel(); + hgc = XCreateGC(disp, pixmap, GCForeground, &gcv); - gcv.foreground = texture.loColor().pixel(); - lgc = XCreateGC(disp, pixmap, GCForeground, &gcv); + gcv.foreground = texture.loColor().pixel(); + lgc = XCreateGC(disp, pixmap, GCForeground, &gcv); - XFillRectangle(disp, pixmap, gc, 0, 0, width, height); + XFillRectangle(disp, pixmap, gc, 0, 0, width, height); - using namespace FbTk; + using namespace FbTk; - if (texture.type() & Texture::INTERLACED) { - gcv.foreground = texture.colorTo().pixel(); - GC igc = XCreateGC(disp, pixmap, - GCForeground, &gcv); + if (texture.type() & Texture::INTERLACED) { + gcv.foreground = texture.colorTo().pixel(); + GC igc = XCreateGC(disp, pixmap, + GCForeground, &gcv); - register unsigned int i = 0; - for (; i < height; i += 2) - XDrawLine(disp, pixmap, igc, 0, i, width, i); + register unsigned int i = 0; + for (; i < height; i += 2) + XDrawLine(disp, pixmap, igc, 0, i, width, i); - XFreeGC(disp, igc); - } + XFreeGC(disp, igc); + } - if (texture.type() & Texture::BEVEL1) { - if (texture.type() & Texture::RAISED) { - XDrawLine(disp, pixmap, lgc, - 0, height - 1, width - 1, height - 1); - XDrawLine(disp, pixmap, lgc, - width - 1, height - 1, width - 1, 0); + if (texture.type() & Texture::BEVEL1) { + if (texture.type() & Texture::RAISED) { + XDrawLine(disp, pixmap, lgc, + 0, height - 1, width - 1, height - 1); + XDrawLine(disp, pixmap, lgc, + width - 1, height - 1, width - 1, 0); - XDrawLine(disp, pixmap, hgc, - 0, 0, width - 1, 0); - XDrawLine(disp, pixmap, hgc, - 0, height - 1, 0, 0); - } else if (texture.type() & Texture::SUNKEN) { - XDrawLine(disp, pixmap, hgc, - 0, height - 1, width - 1, height - 1); - XDrawLine(disp, pixmap, hgc, - width - 1, height - 1, width - 1, 0); + XDrawLine(disp, pixmap, hgc, + 0, 0, width - 1, 0); + XDrawLine(disp, pixmap, hgc, + 0, height - 1, 0, 0); + } else if (texture.type() & Texture::SUNKEN) { + XDrawLine(disp, pixmap, hgc, + 0, height - 1, width - 1, height - 1); + XDrawLine(disp, pixmap, hgc, + width - 1, height - 1, width - 1, 0); - XDrawLine(disp, pixmap, lgc, - 0, 0, width - 1, 0); - XDrawLine(disp, pixmap, lgc, - 0, height - 1, 0, 0); - } - } else if (texture.type() & Texture::BEVEL2) { - if (texture.type() & Texture::RAISED) { - XDrawLine(disp, pixmap, lgc, - 1, height - 3, width - 3, height - 3); - XDrawLine(disp, pixmap, lgc, - width - 3, height - 3, width - 3, 1); + XDrawLine(disp, pixmap, lgc, + 0, 0, width - 1, 0); + XDrawLine(disp, pixmap, lgc, + 0, height - 1, 0, 0); + } + } else if (texture.type() & Texture::BEVEL2) { + if (texture.type() & Texture::RAISED) { + XDrawLine(disp, pixmap, lgc, + 1, height - 3, width - 3, height - 3); + XDrawLine(disp, pixmap, lgc, + width - 3, height - 3, width - 3, 1); - XDrawLine(disp, pixmap, hgc, - 1, 1, width - 3, 1); - XDrawLine(disp, pixmap, hgc, - 1, height - 3, 1, 1); - } else if (texture.type() & Texture::SUNKEN) { - XDrawLine(disp, pixmap, hgc, - 1, height - 3, width - 3, height - 3); - XDrawLine(disp, pixmap, hgc, - width - 3, height - 3, width - 3, 1); + XDrawLine(disp, pixmap, hgc, + 1, 1, width - 3, 1); + XDrawLine(disp, pixmap, hgc, + 1, height - 3, 1, 1); + } else if (texture.type() & Texture::SUNKEN) { + XDrawLine(disp, pixmap, hgc, + 1, height - 3, width - 3, height - 3); + XDrawLine(disp, pixmap, hgc, + width - 3, height - 3, width - 3, 1); - XDrawLine(disp, pixmap, lgc, - 1, 1, width - 3, 1); - XDrawLine(disp, pixmap, lgc, - 1, height - 3, 1, 1); - } - } + XDrawLine(disp, pixmap, lgc, + 1, 1, width - 3, 1); + XDrawLine(disp, pixmap, lgc, + 1, height - 3, 1, 1); + } + } - XFreeGC(disp, gc); - XFreeGC(disp, hgc); - XFreeGC(disp, lgc); + XFreeGC(disp, gc); + XFreeGC(disp, hgc); + XFreeGC(disp, lgc); - return pixmap; + return pixmap; } Pixmap TextureRender::renderGradient(const FbTk::Texture &texture) { - bool inverted = false; + bool inverted = false; - using namespace FbTk; + using namespace FbTk; - interlaced = texture.type() & Texture::INTERLACED; + interlaced = texture.type() & Texture::INTERLACED; - if (texture.type() & Texture::SUNKEN) { - from = &(texture.colorTo()); - to = &(texture.color()); + if (texture.type() & Texture::SUNKEN) { + from = &(texture.colorTo()); + to = &(texture.color()); - if (! (texture.type() & Texture::INVERT)) - inverted = true; - } else { - from = &(texture.color()); - to = &(texture.colorTo()); + if (! (texture.type() & Texture::INVERT)) + inverted = true; + } else { + from = &(texture.color()); + to = &(texture.colorTo()); - if (texture.type() & Texture::INVERT) - inverted = true; - } + if (texture.type() & Texture::INVERT) + inverted = true; + } - control.getGradientBuffers(width, height, &xtable, &ytable); + control.getGradientBuffers(width, height, &xtable, &ytable); - if (texture.type() & Texture::DIAGONAL) - dgradient(); - else if (texture.type() & Texture::ELLIPTIC) - egradient(); - else if (texture.type() & Texture::HORIZONTAL) - hgradient(); - else if (texture.type() & Texture::PYRAMID) - pgradient(); - else if (texture.type() & Texture::RECTANGLE) - rgradient(); - else if (texture.type() & Texture::VERTICAL) - vgradient(); - else if (texture.type() & Texture::CROSSDIAGONAL) - cdgradient(); - else if (texture.type() & Texture::PIPECROSS) - pcgradient(); + if (texture.type() & Texture::DIAGONAL) + dgradient(); + else if (texture.type() & Texture::ELLIPTIC) + egradient(); + else if (texture.type() & Texture::HORIZONTAL) + hgradient(); + else if (texture.type() & Texture::PYRAMID) + pgradient(); + else if (texture.type() & Texture::RECTANGLE) + rgradient(); + else if (texture.type() & Texture::VERTICAL) + vgradient(); + else if (texture.type() & Texture::CROSSDIAGONAL) + cdgradient(); + else if (texture.type() & Texture::PIPECROSS) + pcgradient(); - if (texture.type() & Texture::BEVEL1) - bevel1(); - else if (texture.type() & Texture::BEVEL2) - bevel2(); + if (texture.type() & Texture::BEVEL1) + bevel1(); + else if (texture.type() & Texture::BEVEL2) + bevel2(); - if (inverted) - invert(); + if (inverted) + invert(); - return renderPixmap(); + return renderPixmap(); } XImage *TextureRender::renderXImage() { - I18n *i18n = I18n::instance(); - Display *disp = FbTk::App::instance()->display(); - XImage *image = - XCreateImage(disp, - DefaultVisual(disp, control.screenNum()), control.depth(), ZPixmap, 0, 0, - width, height, 32, 0); + I18n *i18n = I18n::instance(); + Display *disp = FbTk::App::instance()->display(); + XImage *image = + XCreateImage(disp, + DefaultVisual(disp, control.screenNum()), control.depth(), ZPixmap, 0, 0, + width, height, 32, 0); - if (! image) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageErrorCreatingXImage, - "BImage::renderXImage: error creating XImage\n")); - return 0; - } + if (! image) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageErrorCreatingXImage, + "BImage::renderXImage: error creating XImage\n")); + return 0; + } - image->data = 0; + image->data = 0; - unsigned char *d = new unsigned char[image->bytes_per_line * (height + 1)]; - register unsigned int x, y, dithx, dithy, r, g, b, o, er, eg, eb, offset; + unsigned char *d = new unsigned char[image->bytes_per_line * (height + 1)]; + register unsigned int x, y, dithx, dithy, r, g, b, o, er, eg, eb, offset; - unsigned char *pixel_data = d, *ppixel_data = d; - unsigned long pixel; + unsigned char *pixel_data = d, *ppixel_data = d; + unsigned long pixel; - o = image->bits_per_pixel + ((image->byte_order == MSBFirst) ? 1 : 0); + o = image->bits_per_pixel + ((image->byte_order == MSBFirst) ? 1 : 0); - if (control.doDither() && width > 1 && height > 1) { - unsigned char dither4[4][4] = { - {0, 4, 1, 5}, - {6, 2, 7, 3}, - {1, 5, 0, 4}, - {7, 3, 6, 2} }; + if (control.doDither() && width > 1 && height > 1) { + unsigned char dither4[4][4] = { + {0, 4, 1, 5}, + {6, 2, 7, 3}, + {1, 5, 0, 4}, + {7, 3, 6, 2} }; #ifdef ORDEREDPSEUDO - unsigned char dither8[8][8] = { - { 0, 32, 8, 40, 2, 34, 10, 42 }, - { 48, 16, 56, 24, 50, 18, 58, 26 }, - { 12, 44, 4, 36, 14, 46, 6, 38 }, - { 60, 28, 52, 20, 62, 30, 54, 22 }, - { 3, 35, 11, 43, 1, 33, 9, 41 }, - { 51, 19, 59, 27, 49, 17, 57, 25 }, - { 15, 47, 7, 39, 13, 45, 5, 37 }, - { 63, 31, 55, 23, 61, 29, 53, 21 } }; + unsigned char dither8[8][8] = { + { 0, 32, 8, 40, 2, 34, 10, 42 }, + { 48, 16, 56, 24, 50, 18, 58, 26 }, + { 12, 44, 4, 36, 14, 46, 6, 38 }, + { 60, 28, 52, 20, 62, 30, 54, 22 }, + { 3, 35, 11, 43, 1, 33, 9, 41 }, + { 51, 19, 59, 27, 49, 17, 57, 25 }, + { 15, 47, 7, 39, 13, 45, 5, 37 }, + { 63, 31, 55, 23, 61, 29, 53, 21 } }; #endif // ORDEREDPSEUDO - switch (control.visual()->c_class) { - case TrueColor: - // algorithm: ordered dithering... many many thanks to rasterman - // (raster@rasterman.com) for telling me about this... portions of this - // code is based off of his code in Imlib - for (y = 0, offset = 0; y < height; y++) { - dithy = y & 0x3; + switch (control.visual()->c_class) { + case TrueColor: + // algorithm: ordered dithering... many many thanks to rasterman + // (raster@rasterman.com) for telling me about this... portions of this + // code is based off of his code in Imlib + for (y = 0, offset = 0; y < height; y++) { + dithy = y & 0x3; - for (x = 0; x < width; x++, offset++) { - dithx = x & 0x3; - r = red[offset]; - g = green[offset]; - b = blue[offset]; + for (x = 0; x < width; x++, offset++) { + dithx = x & 0x3; + r = red[offset]; + g = green[offset]; + b = blue[offset]; - er = r & (red_bits - 1); - eg = g & (green_bits - 1); - eb = b & (blue_bits - 1); + er = r & (red_bits - 1); + eg = g & (green_bits - 1); + eb = b & (blue_bits - 1); - r = red_table[r]; - g = green_table[g]; - b = blue_table[b]; + r = red_table[r]; + g = green_table[g]; + b = blue_table[b]; - if ((dither4[dithy][dithx] < er) && (r < red_table[255])) r++; - if ((dither4[dithy][dithx] < eg) && (g < green_table[255])) g++; - if ((dither4[dithy][dithx] < eb) && (b < blue_table[255])) b++; + if ((dither4[dithy][dithx] < er) && (r < red_table[255])) r++; + if ((dither4[dithy][dithx] < eg) && (g < green_table[255])) g++; + if ((dither4[dithy][dithx] < eb) && (b < blue_table[255])) b++; - pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset); + pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset); - switch (o) { - case 8: // 8bpp - *pixel_data++ = pixel; - break; + switch (o) { + case 8: // 8bpp + *pixel_data++ = pixel; + break; - case 16: // 16bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - break; + case 16: // 16bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + break; - case 17: // 16bpp MSB - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; + case 17: // 16bpp MSB + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; - case 24: // 24bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel >> 16; - break; + case 24: // 24bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel >> 16; + break; - case 25: // 24bpp MSB - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; + case 25: // 24bpp MSB + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; - case 32: // 32bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 24; - break; + case 32: // 32bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 24; + break; - case 33: // 32bpp MSB - *pixel_data++ = pixel >> 24; - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; - } - } + case 33: // 32bpp MSB + *pixel_data++ = pixel >> 24; + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; + } + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } - break; + break; - case StaticColor: - case PseudoColor: { + case StaticColor: + case PseudoColor: { #ifndef ORDEREDPSEUDO - short *terr, - *rerr = new short[width + 2], - *gerr = new short[width + 2], - *berr = new short[width + 2], - *nrerr = new short[width + 2], - *ngerr = new short[width + 2], - *nberr = new short[width + 2]; - int rr, gg, bb, rer, ger, ber; - int dd = 255 / control.colorsPerChannel(); + short *terr, + *rerr = new short[width + 2], + *gerr = new short[width + 2], + *berr = new short[width + 2], + *nrerr = new short[width + 2], + *ngerr = new short[width + 2], + *nberr = new short[width + 2]; + int rr, gg, bb, rer, ger, ber; + int dd = 255 / control.colorsPerChannel(); - for (x = 0; x < width; x++) { - *(rerr + x) = *(red + x); - *(gerr + x) = *(green + x); - *(berr + x) = *(blue + x); - } + for (x = 0; x < width; x++) { + *(rerr + x) = *(red + x); + *(gerr + x) = *(green + x); + *(berr + x) = *(blue + x); + } - *(rerr + x) = *(gerr + x) = *(berr + x) = 0; + *(rerr + x) = *(gerr + x) = *(berr + x) = 0; #endif // ORDEREDPSEUDO - for (y = 0, offset = 0; y < height; y++) { + for (y = 0, offset = 0; y < height; y++) { #ifdef ORDEREDPSEUDO - dithy = y & 7; + dithy = y & 7; - for (x = 0; x < width; x++, offset++) { - dithx = x & 7; + for (x = 0; x < width; x++, offset++) { + dithx = x & 7; - r = red[offset]; - g = green[offset]; - b = blue[offset]; + r = red[offset]; + g = green[offset]; + b = blue[offset]; - er = r & (red_bits - 1); - eg = g & (green_bits - 1); - eb = b & (blue_bits - 1); + er = r & (red_bits - 1); + eg = g & (green_bits - 1); + eb = b & (blue_bits - 1); - r = red_table[r]; - g = green_table[g]; - b = blue_table[b]; + r = red_table[r]; + g = green_table[g]; + b = blue_table[b]; - if ((dither8[dithy][dithx] < er) && (r < red_table[255])) r++; - if ((dither8[dithy][dithx] < eg) && (g < green_table[255])) g++; - if ((dither8[dithy][dithx] < eb) && (b < blue_table[255])) b++; + if ((dither8[dithy][dithx] < er) && (r < red_table[255])) r++; + if ((dither8[dithy][dithx] < eg) && (g < green_table[255])) g++; + if ((dither8[dithy][dithx] < eb) && (b < blue_table[255])) b++; - pixel = (r * cpccpc) + (g * cpc) + b; - *(pixel_data++) = colors[pixel].pixel; - } + pixel = (r * cpccpc) + (g * cpc) + b; + *(pixel_data++) = colors[pixel].pixel; + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } #else // !ORDEREDPSEUDO - if (y < (height - 1)) { - int i = offset + width; - for (x = 0; x < width; x++, i++) { - *(nrerr + x) = *(red + i); - *(ngerr + x) = *(green + i); - *(nberr + x) = *(blue + i); - } + if (y < (height - 1)) { + int i = offset + width; + for (x = 0; x < width; x++, i++) { + *(nrerr + x) = *(red + i); + *(ngerr + x) = *(green + i); + *(nberr + x) = *(blue + i); + } - *(nrerr + x) = *(red + (--i)); - *(ngerr + x) = *(green + i); - *(nberr + x) = *(blue + i); - } + *(nrerr + x) = *(red + (--i)); + *(ngerr + x) = *(green + i); + *(nberr + x) = *(blue + i); + } - for (x = 0; x < width; x++) { - rr = rerr[x]; - gg = gerr[x]; - bb = berr[x]; + for (x = 0; x < width; x++) { + rr = rerr[x]; + gg = gerr[x]; + bb = berr[x]; - if (rr > 255) rr = 255; else if (rr < 0) rr = 0; - if (gg > 255) gg = 255; else if (gg < 0) gg = 0; - if (bb > 255) bb = 255; else if (bb < 0) bb = 0; + if (rr > 255) rr = 255; else if (rr < 0) rr = 0; + if (gg > 255) gg = 255; else if (gg < 0) gg = 0; + if (bb > 255) bb = 255; else if (bb < 0) bb = 0; - r = red_table[rr]; - g = green_table[gg]; - b = blue_table[bb]; + r = red_table[rr]; + g = green_table[gg]; + b = blue_table[bb]; - rer = rerr[x] - r*dd; - ger = gerr[x] - g*dd; - ber = berr[x] - b*dd; + rer = rerr[x] - r*dd; + ger = gerr[x] - g*dd; + ber = berr[x] - b*dd; - pixel = (r * cpccpc) + (g * cpc) + b; - *pixel_data++ = colors[pixel].pixel; + pixel = (r * cpccpc) + (g * cpc) + b; + *pixel_data++ = colors[pixel].pixel; - r = rer >> 1; - g = ger >> 1; - b = ber >> 1; - rerr[x+1] += r; - gerr[x+1] += g; - berr[x+1] += b; - nrerr[x] += r; - ngerr[x] += g; - nberr[x] += b; - } + r = rer >> 1; + g = ger >> 1; + b = ber >> 1; + rerr[x+1] += r; + gerr[x+1] += g; + berr[x+1] += b; + nrerr[x] += r; + ngerr[x] += g; + nberr[x] += b; + } - offset += width; + offset += width; - pixel_data = (ppixel_data += image->bytes_per_line); + pixel_data = (ppixel_data += image->bytes_per_line); - terr = rerr; - rerr = nrerr; - nrerr = terr; + terr = rerr; + rerr = nrerr; + nrerr = terr; - terr = gerr; - gerr = ngerr; - ngerr = terr; + terr = gerr; + gerr = ngerr; + ngerr = terr; - terr = berr; - berr = nberr; - nberr = terr; - } + terr = berr; + berr = nberr; + nberr = terr; + } - delete [] rerr; - delete [] gerr; - delete [] berr; - delete [] nrerr; - delete [] ngerr; - delete [] nberr; + delete [] rerr; + delete [] gerr; + delete [] berr; + delete [] nrerr; + delete [] ngerr; + delete [] nberr; #endif // ORDEREDPSUEDO - } break; + } break; - /* - case StaticGray: - case GrayScale: - for (y = 0, offset = 0; y < height; y++) { - dithy = y & 0x3; + /* + case StaticGray: + case GrayScale: + for (y = 0, offset = 0; y < height; y++) { + dithy = y & 0x3; - for (x = 0; x < width; x++, offset++) { - dithx = x & 0x3; + for (x = 0; x < width; x++, offset++) { + dithx = x & 0x3; - r = *(red + offset); - g = *(green + offset); - b = *(blue + offset); + r = *(red + offset); + g = *(green + offset); + b = *(blue + offset); - er = r & 0x7; - eg = g & 0x7; - eb = b & 0x7; + er = r & 0x7; + eg = g & 0x7; + eb = b & 0x7; - if ((dither[dithy][dithx] < er) && (r < (256 - 8))) - r += 8; - if ((dither[dithy][dithx] < (eg << 1)) && (g < (256 - 4))) - g += 4; - if ((dither[dithy][dithx] < eb) && (b < (256 - 8))) - b += 8; + if ((dither[dithy][dithx] < er) && (r < (256 - 8))) + r += 8; + if ((dither[dithy][dithx] < (eg << 1)) && (g < (256 - 4))) + g += 4; + if ((dither[dithy][dithx] < eb) && (b < (256 - 8))) + b += 8; - r = *(red_table + r); - g = *(green_table + g); - b = *(blue_table + b); + r = *(red_table + r); + g = *(green_table + g); + b = *(blue_table + b); - g = ((r * 30) + (g * 59) + (b * 11)) / 100; - *pixel_data++ = colors[g].pixel; - } + g = ((r * 30) + (g * 59) + (b * 11)) / 100; + *pixel_data++ = colors[g].pixel; + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } - break; - */ + break; + */ - default: - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageUnsupVisual, - "BImage::renderXImage: unsupported visual\n")); - delete [] d; - XDestroyImage(image); - return (XImage *) 0; - } - } else { - switch (control.visual()->c_class) { - case StaticColor: - case PseudoColor: - for (y = 0, offset = 0; y < height; y++) { - for (x = 0; x < width; x++, offset++) { - r = red_table[red[offset]]; - g = green_table[green[offset]]; - b = blue_table[blue[offset]]; + default: + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageUnsupVisual, + "BImage::renderXImage: unsupported visual\n")); + delete [] d; + XDestroyImage(image); + return (XImage *) 0; + } +} else { + switch (control.visual()->c_class) { + case StaticColor: + case PseudoColor: + for (y = 0, offset = 0; y < height; y++) { + for (x = 0; x < width; x++, offset++) { + r = red_table[red[offset]]; + g = green_table[green[offset]]; + b = blue_table[blue[offset]]; - pixel = (r * cpccpc) + (g * cpc) + b; - *pixel_data++ = colors[pixel].pixel; - } + pixel = (r * cpccpc) + (g * cpc) + b; + *pixel_data++ = colors[pixel].pixel; + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } - break; + break; - case TrueColor: - for (y = 0, offset = 0; y < height; y++) { - for (x = 0; x < width; x++, offset++) { - r = red_table[red[offset]]; - g = green_table[green[offset]]; - b = blue_table[blue[offset]]; + case TrueColor: + for (y = 0, offset = 0; y < height; y++) { + for (x = 0; x < width; x++, offset++) { + r = red_table[red[offset]]; + g = green_table[green[offset]]; + b = blue_table[blue[offset]]; - pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset); + pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset); - switch (o) { - case 8: // 8bpp - *pixel_data++ = pixel; - break; + switch (o) { + case 8: // 8bpp + *pixel_data++ = pixel; + break; - case 16: // 16bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - break; + case 16: // 16bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + break; - case 17: // 16bpp MSB - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; + case 17: // 16bpp MSB + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; - case 24: // 24bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel >> 16; - break; + case 24: // 24bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel >> 16; + break; - case 25: // 24bpp MSB - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; + case 25: // 24bpp MSB + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; - case 32: // 32bpp LSB - *pixel_data++ = pixel; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 24; - break; + case 32: // 32bpp LSB + *pixel_data++ = pixel; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 24; + break; - case 33: // 32bpp MSB - *pixel_data++ = pixel >> 24; - *pixel_data++ = pixel >> 16; - *pixel_data++ = pixel >> 8; - *pixel_data++ = pixel; - break; - } - } + case 33: // 32bpp MSB + *pixel_data++ = pixel >> 24; + *pixel_data++ = pixel >> 16; + *pixel_data++ = pixel >> 8; + *pixel_data++ = pixel; + break; + } + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } - break; + break; - case StaticGray: - case GrayScale: - for (y = 0, offset = 0; y < height; y++) { - for (x = 0; x < width; x++, offset++) { - r = *(red_table + *(red + offset)); - g = *(green_table + *(green + offset)); - b = *(blue_table + *(blue + offset)); + case StaticGray: + case GrayScale: + for (y = 0, offset = 0; y < height; y++) { + for (x = 0; x < width; x++, offset++) { + r = *(red_table + *(red + offset)); + g = *(green_table + *(green + offset)); + b = *(blue_table + *(blue + offset)); - g = ((r * 30) + (g * 59) + (b * 11)) / 100; - *pixel_data++ = colors[g].pixel; - } + g = ((r * 30) + (g * 59) + (b * 11)) / 100; + *pixel_data++ = colors[g].pixel; + } - pixel_data = (ppixel_data += image->bytes_per_line); - } + pixel_data = (ppixel_data += image->bytes_per_line); + } break; - default: - fprintf(stderr, - i18n-> - getMessage( - FBNLS::ImageSet, FBNLS::ImageUnsupVisual, - "BImage::renderXImage: unsupported visual\n")); - delete [] d; - XDestroyImage(image); - return (XImage *) 0; - } + default: + fprintf(stderr, + i18n-> + getMessage( + FBNLS::ImageSet, FBNLS::ImageUnsupVisual, + "BImage::renderXImage: unsupported visual\n")); + delete [] d; + XDestroyImage(image); + return (XImage *) 0; + } } - image->data = (char *) d; - return image; +image->data = (char *) d; +return image; } Pixmap TextureRender::renderPixmap() { - Display *disp = FbTk::App::instance()->display(); - I18n *i18n = I18n::instance(); - Pixmap pixmap = - XCreatePixmap(disp, - RootWindow(disp, control.screenNum()), width, height, control.depth()); +Display *disp = FbTk::App::instance()->display(); +I18n *i18n = I18n::instance(); +Pixmap pixmap = +XCreatePixmap(disp, + RootWindow(disp, control.screenNum()), width, height, control.depth()); - if (pixmap == None) { - fprintf(stderr, - i18n->getMessage( - FBNLS::ImageSet, FBNLS::ImageErrorCreatingPixmap, - "BImage::renderPixmap: error creating pixmap\n")); - return None; - } +if (pixmap == None) { +fprintf(stderr, + i18n->getMessage( +FBNLS::ImageSet, FBNLS::ImageErrorCreatingPixmap, + "BImage::renderPixmap: error creating pixmap\n")); +return None; +} - XImage *image = renderXImage(); +XImage *image = renderXImage(); - if (! image) { - XFreePixmap(disp, pixmap); - return None; - } else if (! image->data) { - XDestroyImage(image); - XFreePixmap(disp, pixmap); - return None; - } +if (! image) { +XFreePixmap(disp, pixmap); +return None; +} else if (! image->data) { +XDestroyImage(image); +XFreePixmap(disp, pixmap); +return None; +} - XPutImage(disp, pixmap, - DefaultGC(disp, control.screenNum()), - image, 0, 0, 0, 0, width, height); +XPutImage(disp, pixmap, + DefaultGC(disp, control.screenNum()), + image, 0, 0, 0, 0, width, height); - if (image->data != 0) { - delete [] image->data; - image->data = 0; - } +if (image->data != 0) { +delete [] image->data; +image->data = 0; +} - XDestroyImage(image); +XDestroyImage(image); - return pixmap; +return pixmap; } void TextureRender::bevel1() { - if (! (width > 2 && height > 2)) - return; +if (! (width > 2 && height > 2)) + return; - unsigned char *pr = red, *pg = green, *pb = blue; +unsigned char *pr = red, *pg = green, *pb = blue; - register unsigned char r, g, b, rr ,gg ,bb; - register unsigned int w = width, h = height - 1, wh = w * h; +register unsigned char r, g, b, rr ,gg ,bb; +register unsigned int w = width, h = height - 1, wh = w * h; - while (--w) { - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +while (--w) { +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; - r = *(pr + wh); - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *(pg + wh); - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *(pb + wh); - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *(pr + wh); +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *(pg + wh); +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *(pb + wh); +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *((pr++) + wh) = rr; - *((pg++) + wh) = gg; - *((pb++) + wh) = bb; - } +*((pr++) + wh) = rr; +*((pg++) + wh) = gg; +*((pb++) + wh) = bb; +} - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; - r = *(pr + wh); - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *(pg + wh); - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *(pb + wh); - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *(pr + wh); +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *(pg + wh); +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *(pb + wh); +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *(pr + wh) = rr; - *(pg + wh) = gg; - *(pb + wh) = bb; +*(pr + wh) = rr; +*(pg + wh) = gg; +*(pb + wh) = bb; - pr = red + width; - pg = green + width; - pb = blue + width; +pr = red + width; +pg = green + width; +pb = blue + width; - while (--h) { - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +while (--h) { +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; - pr += width - 1; - pg += width - 1; - pb += width - 1; +pr += width - 1; +pg += width - 1; +pb += width - 1; - r = *pr; - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *pg; - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *pb; - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *pr; +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *pg; +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *pb; +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *(pr++) = rr; - *(pg++) = gg; - *(pb++) = bb; - } +*(pr++) = rr; +*(pg++) = gg; +*(pb++) = bb; +} - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; - pr += width - 1; - pg += width - 1; - pb += width - 1; +pr += width - 1; +pg += width - 1; +pb += width - 1; - r = *pr; - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *pg; - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *pb; - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *pr; +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *pg; +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *pb; +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; } void TextureRender::bevel2() { - if (! (width > 4 && height > 4)) - return; +if (! (width > 4 && height > 4)) + return; - unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1, - *pg = green + width + 1, *pb = blue + width + 1; - unsigned int w = width - 2, h = height - 1, wh = width * (height - 3); +unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1, + *pg = green + width + 1, *pb = blue + width + 1; +unsigned int w = width - 2, h = height - 1, wh = width * (height - 3); - while (--w) { - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +while (--w) { +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *pr = rr; - *pg = gg; - *pb = bb; +*pr = rr; +*pg = gg; +*pb = bb; - r = *(pr + wh); - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *(pg + wh); - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *(pb + wh); - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *(pr + wh); +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *(pg + wh); +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *(pb + wh); +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *((pr++) + wh) = rr; - *((pg++) + wh) = gg; - *((pb++) + wh) = bb; - } +*((pr++) + wh) = rr; +*((pg++) + wh) = gg; +*((pb++) + wh) = bb; +} - pr = red + width; - pg = green + width; - pb = blue + width; +pr = red + width; +pg = green + width; +pb = blue + width; - while (--h) { - r = *pr; - rr = r + (r >> 1); - if (rr < r) rr = ~0; - g = *pg; - gg = g + (g >> 1); - if (gg < g) gg = ~0; - b = *pb; - bb = b + (b >> 1); - if (bb < b) bb = ~0; +while (--h) { +r = *pr; +rr = r + (r >> 1); +if (rr < r) rr = ~0; +g = *pg; +gg = g + (g >> 1); +if (gg < g) gg = ~0; +b = *pb; +bb = b + (b >> 1); +if (bb < b) bb = ~0; - *(++pr) = rr; - *(++pg) = gg; - *(++pb) = bb; +*(++pr) = rr; +*(++pg) = gg; +*(++pb) = bb; - pr += width - 3; - pg += width - 3; - pb += width - 3; +pr += width - 3; +pg += width - 3; +pb += width - 3; - r = *pr; - rr = (r >> 2) + (r >> 1); - if (rr > r) rr = 0; - g = *pg; - gg = (g >> 2) + (g >> 1); - if (gg > g) gg = 0; - b = *pb; - bb = (b >> 2) + (b >> 1); - if (bb > b) bb = 0; +r = *pr; +rr = (r >> 2) + (r >> 1); +if (rr > r) rr = 0; +g = *pg; +gg = (g >> 2) + (g >> 1); +if (gg > g) gg = 0; +b = *pb; +bb = (b >> 2) + (b >> 1); +if (bb > b) bb = 0; - *(pr++) = rr; - *(pg++) = gg; - *(pb++) = bb; +*(pr++) = rr; +*(pg++) = gg; +*(pb++) = bb; - pr++; pg++; pb++; - } +pr++; pg++; pb++; +} } void TextureRender::invert() { - register unsigned int i, j, wh = (width * height) - 1; - unsigned char tmp; +register unsigned int i, j, wh = (width * height) - 1; +unsigned char tmp; - for (i = 0, j = wh; j > i; j--, i++) { - tmp = *(red + j); - *(red + j) = *(red + i); - *(red + i) = tmp; +for (i = 0, j = wh; j > i; j--, i++) { +tmp = *(red + j); +*(red + j) = *(red + i); +*(red + i) = tmp; - tmp = *(green + j); - *(green + j) = *(green + i); - *(green + i) = tmp; +tmp = *(green + j); +*(green + j) = *(green + i); +*(green + i) = tmp; - tmp = *(blue + j); - *(blue + j) = *(blue + i); - *(blue + i) = tmp; - } +tmp = *(blue + j); +*(blue + j) = *(blue + i); +*(blue + i) = tmp; +} } void TextureRender::dgradient() { - // diagonal gradient code was written by Mike Cole <mike@mydot.com> - // modified for interlacing by Brad Hughes +// diagonal gradient code was written by Mike Cole <mike@mydot.com> +// modified for interlacing by Brad Hughes - float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0, - xr = (float) from->red(), - xg = (float) from->green(), - xb = (float) from->blue(); - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int w = width * 2, h = height * 2; - unsigned int *xt = xtable, *yt = ytable; +float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0, + xr = (float) from->red(), + xg = (float) from->green(), + xb = (float) from->blue(); +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int w = width * 2, h = height * 2; +unsigned int *xt = xtable, *yt = ytable; - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - // Create X table - drx /= w; - dgx /= w; - dbx /= w; +// Create X table +drx /= w; +dgx /= w; +dbx /= w; - for (x = 0; x < width; x++) { - *(xt++) = (unsigned char) (xr); - *(xt++) = (unsigned char) (xg); - *(xt++) = (unsigned char) (xb); +for (x = 0; x < width; x++) { +*(xt++) = (unsigned char) (xr); +*(xt++) = (unsigned char) (xg); +*(xt++) = (unsigned char) (xb); - xr += drx; - xg += dgx; - xb += dbx; - } +xr += drx; +xg += dgx; +xb += dbx; +} - // Create Y table - dry /= h; - dgy /= h; - dby /= h; +// Create Y table +dry /= h; +dgy /= h; +dby /= h; - for (y = 0; y < height; y++) { - *(yt++) = ((unsigned char) yr); - *(yt++) = ((unsigned char) yg); - *(yt++) = ((unsigned char) yb); +for (y = 0; y < height; y++) { +*(yt++) = ((unsigned char) yr); +*(yt++) = ((unsigned char) yg); +*(yt++) = ((unsigned char) yb); - yr += dry; - yg += dgy; - yb += dby; - } +yr += dry; +yg += dgy; +yb += dby; +} - // Combine tables to create gradient +// Combine tables to create gradient - if (! interlaced) { +if (! interlaced) { - // normal dgradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = *(xt++) + *(yt); - *(pg++) = *(xt++) + *(yt + 1); - *(pb++) = *(xt++) + *(yt + 2); - } - } +// normal dgradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = *(xt++) + *(yt); +*(pg++) = *(xt++) + *(yt + 1); +*(pb++) = *(xt++) + *(yt + 2); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = *(xt++) + *(yt); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = *(xt++) + *(yt); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = *(xt++) + *(yt + 1); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = *(xt++) + *(yt + 1); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = *(xt++) + *(yt + 2); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = *(xt++) + *(yt); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = *(xt++) + *(yt + 2); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = *(xt++) + *(yt); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = *(xt++) + *(yt + 1); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = *(xt++) + *(yt + 1); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = *(xt++) + *(yt + 2); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = *(xt++) + *(yt + 2); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} } void TextureRender::hgradient() { - float drx, dgx, dbx, - xr = (float) from->red(), - xg = (float) from->green(), - xb = (float) from->blue(); - unsigned char *pr = red, *pg = green, *pb = blue; +float drx, dgx, dbx, + xr = (float) from->red(), + xg = (float) from->green(), + xb = (float) from->blue(); +unsigned char *pr = red, *pg = green, *pb = blue; - register unsigned int x, y; +register unsigned int x, y; - drx = (float) (to->red() - from->red()); - dgx = (float) (to->green() - from->green()); - dbx = (float) (to->blue() - from->blue()); +drx = (float) (to->red() - from->red()); +dgx = (float) (to->green() - from->green()); +dbx = (float) (to->blue() - from->blue()); - drx /= width; - dgx /= width; - dbx /= width; +drx /= width; +dgx /= width; +dbx /= width; - if (interlaced && height > 2) { - // faked interlacing effect - unsigned char channel, channel2; +if (interlaced && height > 2) { +// faked interlacing effect +unsigned char channel, channel2; - for (x = 0; x < width; x++, pr++, pg++, pb++) { - channel = (unsigned char) xr; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *pr = channel2; +for (x = 0; x < width; x++, pr++, pg++, pb++) { +channel = (unsigned char) xr; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*pr = channel2; - channel = (unsigned char) xg; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *pg = channel2; +channel = (unsigned char) xg; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*pg = channel2; - channel = (unsigned char) xb; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *pb = channel2; +channel = (unsigned char) xb; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*pb = channel2; - channel = (unsigned char) xr; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr + width) = channel2; +channel = (unsigned char) xr; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr + width) = channel2; - channel = (unsigned char) xg; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg + width) = channel2; +channel = (unsigned char) xg; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg + width) = channel2; - channel = (unsigned char) xb; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb + width) = channel2; +channel = (unsigned char) xb; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb + width) = channel2; - xr += drx; - xg += dgx; - xb += dbx; - } +xr += drx; +xg += dgx; +xb += dbx; +} - pr += width; - pg += width; - pb += width; +pr += width; +pg += width; +pb += width; - int offset; +int offset; - for (y = 2; y < height; y++, pr += width, pg += width, pb += width) { - if (y & 1) offset = width; else offset = 0; +for (y = 2; y < height; y++, pr += width, pg += width, pb += width) { +if (y & 1) offset = width; else offset = 0; - memcpy(pr, (red + offset), width); - memcpy(pg, (green + offset), width); - memcpy(pb, (blue + offset), width); - } - } else { +memcpy(pr, (red + offset), width); +memcpy(pg, (green + offset), width); +memcpy(pb, (blue + offset), width); +} +} else { - // normal hgradient - for (x = 0; x < width; x++) { - *(pr++) = (unsigned char) (xr); - *(pg++) = (unsigned char) (xg); - *(pb++) = (unsigned char) (xb); +// normal hgradient +for (x = 0; x < width; x++) { +*(pr++) = (unsigned char) (xr); +*(pg++) = (unsigned char) (xg); +*(pb++) = (unsigned char) (xb); - xr += drx; - xg += dgx; - xb += dbx; - } +xr += drx; +xg += dgx; +xb += dbx; +} - for (y = 1; y < height; y++, pr += width, pg += width, pb += width) { - memcpy(pr, red, width); - memcpy(pg, green, width); - memcpy(pb, blue, width); - } +for (y = 1; y < height; y++, pr += width, pg += width, pb += width) { +memcpy(pr, red, width); +memcpy(pg, green, width); +memcpy(pb, blue, width); +} - } +} } void TextureRender::vgradient() { - float dry, dgy, dby, +float dry, dgy, dby, yr = (float) from->red(), yg = (float) from->green(), yb = (float) from->blue(); - unsigned char *pr = red, *pg = green, *pb = blue; +unsigned char *pr = red, *pg = green, *pb = blue; - register unsigned int y; +register unsigned int y; - dry = (float) (to->red() - from->red()); - dgy = (float) (to->green() - from->green()); - dby = (float) (to->blue() - from->blue()); +dry = (float) (to->red() - from->red()); +dgy = (float) (to->green() - from->green()); +dby = (float) (to->blue() - from->blue()); - dry /= height; - dgy /= height; - dby /= height; +dry /= height; +dgy /= height; +dby /= height; - if (interlaced) { - // faked interlacing effect - unsigned char channel, channel2; +if (interlaced) { +// faked interlacing effect +unsigned char channel, channel2; - for (y = 0; y < height; y++, pr += width, pg += width, pb += width) { - if (y & 1) { - channel = (unsigned char) yr; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - memset(pr, channel2, width); +for (y = 0; y < height; y++, pr += width, pg += width, pb += width) { +if (y & 1) { +channel = (unsigned char) yr; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +memset(pr, channel2, width); - channel = (unsigned char) yg; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - memset(pg, channel2, width); +channel = (unsigned char) yg; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +memset(pg, channel2, width); - channel = (unsigned char) yb; - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - memset(pb, channel2, width); - } else { - channel = (unsigned char) yr; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - memset(pr, channel2, width); +channel = (unsigned char) yb; +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +memset(pb, channel2, width); +} else { +channel = (unsigned char) yr; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +memset(pr, channel2, width); - channel = (unsigned char) yg; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - memset(pg, channel2, width); +channel = (unsigned char) yg; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +memset(pg, channel2, width); - channel = (unsigned char) yb; - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - memset(pb, channel2, width); - } +channel = (unsigned char) yb; +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +memset(pb, channel2, width); +} - yr += dry; - yg += dgy; - yb += dby; - } - } else { +yr += dry; +yg += dgy; +yb += dby; +} +} else { - // normal vgradient - for (y = 0; y < height; y++, pr += width, pg += width, pb += width) { - memset(pr, (unsigned char) yr, width); - memset(pg, (unsigned char) yg, width); - memset(pb, (unsigned char) yb, width); +// normal vgradient +for (y = 0; y < height; y++, pr += width, pg += width, pb += width) { +memset(pr, (unsigned char) yr, width); +memset(pg, (unsigned char) yg, width); +memset(pb, (unsigned char) yb, width); - yr += dry; - yg += dgy; - yb += dby; - } - } +yr += dry; +yg += dgy; +yb += dby; +} +} } void TextureRender::pgradient() { - // pyramid gradient - based on original dgradient, written by - // Mosfet (mosfet@kde.org) - // adapted from kde sources for Blackbox by Brad Hughes +// pyramid gradient - based on original dgradient, written by +// Mosfet (mosfet@kde.org) +// adapted from kde sources for Blackbox by Brad Hughes - float yr, yg, yb, drx, dgx, dbx, dry, dgy, dby, +float yr, yg, yb, drx, dgx, dbx, dry, dgy, dby, xr, xg, xb; - int rsign, gsign, bsign; - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int tr = to->red(), tg = to->green(), tb = to->blue(); - unsigned int *xt = xtable, *yt = ytable; +int rsign, gsign, bsign; +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int tr = to->red(), tg = to->green(), tb = to->blue(); +unsigned int *xt = xtable, *yt = ytable; - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - rsign = (drx < 0) ? -1 : 1; - gsign = (dgx < 0) ? -1 : 1; - bsign = (dbx < 0) ? -1 : 1; +rsign = (drx < 0) ? -1 : 1; +gsign = (dgx < 0) ? -1 : 1; +bsign = (dbx < 0) ? -1 : 1; - xr = yr = (drx / 2); - xg = yg = (dgx / 2); - xb = yb = (dbx / 2); +xr = yr = (drx / 2); +xg = yg = (dgx / 2); +xb = yb = (dbx / 2); - // Create X table - drx /= width; - dgx /= width; - dbx /= width; +// Create X table +drx /= width; +dgx /= width; +dbx /= width; - for (x = 0; x < width; x++) { - *(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); - *(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); - *(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); +for (x = 0; x < width; x++) { +*(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); +*(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); +*(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); - xr -= drx; - xg -= dgx; - xb -= dbx; - } +xr -= drx; +xg -= dgx; +xb -= dbx; +} - // Create Y table - dry /= height; - dgy /= height; - dby /= height; +// Create Y table +dry /= height; +dgy /= height; +dby /= height; - for (y = 0; y < height; y++) { - *(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); - *(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); - *(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); +for (y = 0; y < height; y++) { +*(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); +*(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); +*(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); - yr -= dry; - yg -= dgy; - yb -= dby; - } +yr -= dry; +yg -= dgy; +yb -= dby; +} - // Combine tables to create gradient +// Combine tables to create gradient - if (! interlaced) { +if (! interlaced) { - // normal pgradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); - *(pg++) = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); - *(pb++) = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); - } - } +// normal pgradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); +*(pg++) = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); +*(pb++) = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = (unsigned char) (tr - (rsign * (*(xt++) + *(yt)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (gsign * (*(xt++) + *(yt + 1)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = (unsigned char) (tb - (bsign * (*(xt++) + *(yt + 2)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} } void TextureRender::rgradient() { - // rectangle gradient - based on original dgradient, written by - // Mosfet (mosfet@kde.org) - // adapted from kde sources for Blackbox by Brad Hughes +// rectangle gradient - based on original dgradient, written by +// Mosfet (mosfet@kde.org) +// adapted from kde sources for Blackbox by Brad Hughes - float drx, dgx, dbx, dry, dgy, dby, xr, xg, xb, yr, yg, yb; - int rsign, gsign, bsign; - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int tr = to->red(), tg = to->green(), tb = to->blue(); - unsigned int *xt = xtable, *yt = ytable; +float drx, dgx, dbx, dry, dgy, dby, xr, xg, xb, yr, yg, yb; +int rsign, gsign, bsign; +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int tr = to->red(), tg = to->green(), tb = to->blue(); +unsigned int *xt = xtable, *yt = ytable; - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - rsign = (drx < 0) ? -2 : 2; - gsign = (dgx < 0) ? -2 : 2; - bsign = (dbx < 0) ? -2 : 2; +rsign = (drx < 0) ? -2 : 2; +gsign = (dgx < 0) ? -2 : 2; +bsign = (dbx < 0) ? -2 : 2; - xr = yr = (drx / 2); - xg = yg = (dgx / 2); - xb = yb = (dbx / 2); +xr = yr = (drx / 2); +xg = yg = (dgx / 2); +xb = yb = (dbx / 2); // Create X table - drx /= width; - dgx /= width; - dbx /= width; +drx /= width; +dgx /= width; +dbx /= width; - for (x = 0; x < width; x++) { - *(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); - *(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); - *(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); +for (x = 0; x < width; x++) { +*(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); +*(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); +*(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); - xr -= drx; - xg -= dgx; - xb -= dbx; - } +xr -= drx; +xg -= dgx; +xb -= dbx; +} - // Create Y table - dry /= height; - dgy /= height; - dby /= height; +// Create Y table +dry /= height; +dgy /= height; +dby /= height; - for (y = 0; y < height; y++) { - *(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); - *(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); - *(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); +for (y = 0; y < height; y++) { +*(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); +*(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); +*(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); - yr -= dry; - yg -= dgy; - yb -= dby; - } +yr -= dry; +yg -= dgy; +yb -= dby; +} - // Combine tables to create gradient +// Combine tables to create gradient - if (! interlaced) { +if (! interlaced) { - // normal rgradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); - *(pg++) = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); - *(pb++) = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); - } - } +// normal rgradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); +*(pg++) = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); +*(pb++) = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = (unsigned char) (tr - (rsign * std::max(*(xt++), *(yt)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (gsign * std::max(*(xt++), *(yt + 1)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = (unsigned char) (tb - (bsign * std::max(*(xt++), *(yt + 2)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} } void TextureRender::egradient() { - // elliptic gradient - based on original dgradient, written by - // Mosfet (mosfet@kde.org) - // adapted from kde sources for Blackbox by Brad Hughes +// elliptic gradient - based on original dgradient, written by +// Mosfet (mosfet@kde.org) +// adapted from kde sources for Blackbox by Brad Hughes - float drx, dgx, dbx, dry, dgy, dby, yr, yg, yb, xr, xg, xb; - int rsign, gsign, bsign; - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int *xt = xtable, *yt = ytable; - unsigned int tr = (unsigned long) to->red(), - tg = (unsigned long) to->green(), - tb = (unsigned long) to->blue(); +float drx, dgx, dbx, dry, dgy, dby, yr, yg, yb, xr, xg, xb; +int rsign, gsign, bsign; +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int *xt = xtable, *yt = ytable; +unsigned int tr = (unsigned long) to->red(), + tg = (unsigned long) to->green(), + tb = (unsigned long) to->blue(); - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - rsign = (drx < 0) ? -1 : 1; - gsign = (dgx < 0) ? -1 : 1; - bsign = (dbx < 0) ? -1 : 1; +rsign = (drx < 0) ? -1 : 1; +gsign = (dgx < 0) ? -1 : 1; +bsign = (dbx < 0) ? -1 : 1; - xr = yr = (drx / 2); - xg = yg = (dgx / 2); - xb = yb = (dbx / 2); +xr = yr = (drx / 2); +xg = yg = (dgx / 2); +xb = yb = (dbx / 2); // Create X table - drx /= width; - dgx /= width; - dbx /= width; +drx /= width; +dgx /= width; +dbx /= width; - for (x = 0; x < width; x++) { - *(xt++) = (unsigned long) (xr * xr); - *(xt++) = (unsigned long) (xg * xg); - *(xt++) = (unsigned long) (xb * xb); +for (x = 0; x < width; x++) { +*(xt++) = (unsigned long) (xr * xr); +*(xt++) = (unsigned long) (xg * xg); +*(xt++) = (unsigned long) (xb * xb); - xr -= drx; - xg -= dgx; - xb -= dbx; - } +xr -= drx; +xg -= dgx; +xb -= dbx; +} - // Create Y table - dry /= height; - dgy /= height; - dby /= height; +// Create Y table +dry /= height; +dgy /= height; +dby /= height; - for (y = 0; y < height; y++) { - *(yt++) = (unsigned long) (yr * yr); - *(yt++) = (unsigned long) (yg * yg); - *(yt++) = (unsigned long) (yb * yb); +for (y = 0; y < height; y++) { +*(yt++) = (unsigned long) (yr * yr); +*(yt++) = (unsigned long) (yg * yg); +*(yt++) = (unsigned long) (yb * yb); - yr -= dry; - yg -= dgy; - yb -= dby; - } +yr -= dry; +yg -= dgy; +yb -= dby; +} - // Combine tables to create gradient - if (! interlaced) { - // normal egradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) - (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); - *(pg++) = (unsigned char) - (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); - *(pb++) = (unsigned char) - (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); - } - } +// Combine tables to create gradient +if (! interlaced) { +// normal egradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = (unsigned char) + (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); +*(pg++) = (unsigned char) + (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); +*(pb++) = (unsigned char) + (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = (unsigned char) - (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = (unsigned char) + (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = (unsigned char) - (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = (unsigned char) + (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = (unsigned char) - (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = (unsigned char) - (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = (unsigned char) + (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = (unsigned char) + (tr - (rsign * control.getSqrt(*(xt++) + *(yt)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = (unsigned char) - (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = (unsigned char) + (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = (unsigned char) - (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = (unsigned char) + (tb - (bsign * control.getSqrt(*(xt++) + *(yt + 2)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} } void TextureRender::pcgradient() { - // pipe cross gradient - based on original dgradient, written by - // Mosfet (mosfet@kde.org) - // adapted from kde sources for Blackbox by Brad Hughes +// pipe cross gradient - based on original dgradient, written by +// Mosfet (mosfet@kde.org) +// adapted from kde sources for Blackbox by Brad Hughes - float drx, dgx, dbx, dry, dgy, dby, xr, xg, xb, yr, yg, yb; - int rsign, gsign, bsign; - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int *xt = xtable, *yt = ytable; - unsigned int tr = to->red(), - tg = to->green(), - tb = to->blue(); +float drx, dgx, dbx, dry, dgy, dby, xr, xg, xb, yr, yg, yb; +int rsign, gsign, bsign; +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int *xt = xtable, *yt = ytable; +unsigned int tr = to->red(), + tg = to->green(), + tb = to->blue(); - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - rsign = (drx < 0) ? -2 : 2; - gsign = (dgx < 0) ? -2 : 2; - bsign = (dbx < 0) ? -2 : 2; +rsign = (drx < 0) ? -2 : 2; +gsign = (dgx < 0) ? -2 : 2; +bsign = (dbx < 0) ? -2 : 2; - xr = yr = (drx / 2); - xg = yg = (dgx / 2); - xb = yb = (dbx / 2); +xr = yr = (drx / 2); +xg = yg = (dgx / 2); +xb = yb = (dbx / 2); // Create X table - drx /= width; - dgx /= width; - dbx /= width; +drx /= width; +dgx /= width; +dbx /= width; - for (x = 0; x < width; x++) { - *(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); - *(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); - *(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); +for (x = 0; x < width; x++) { +*(xt++) = (unsigned char) ((xr < 0) ? -xr : xr); +*(xt++) = (unsigned char) ((xg < 0) ? -xg : xg); +*(xt++) = (unsigned char) ((xb < 0) ? -xb : xb); - xr -= drx; - xg -= dgx; - xb -= dbx; - } +xr -= drx; +xg -= dgx; +xb -= dbx; +} - // Create Y table - dry /= height; - dgy /= height; - dby /= height; +// Create Y table +dry /= height; +dgy /= height; +dby /= height; - for (y = 0; y < height; y++) { - *(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); - *(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); - *(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); +for (y = 0; y < height; y++) { +*(yt++) = ((unsigned char) ((yr < 0) ? -yr : yr)); +*(yt++) = ((unsigned char) ((yg < 0) ? -yg : yg)); +*(yt++) = ((unsigned char) ((yb < 0) ? -yb : yb)); - yr -= dry; - yg -= dgy; - yb -= dby; - } +yr -= dry; +yg -= dgy; +yb -= dby; +} - // Combine tables to create gradient - if (! interlaced) { +// Combine tables to create gradient +if (! interlaced) { - // normal pcgradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); - *(pg++) = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); - *(pb++) = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); - } - } +// normal pcgradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); +*(pg++) = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); +*(pb++) = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (bsign * std::min(*(xt++), *(yt + 1)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (bsign * std::min(*(xt++), *(yt + 1)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (gsign * std::min(*(xt++), *(yt + 2)))); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = (unsigned char) (tb - (gsign * std::min(*(xt++), *(yt + 2)))); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = (unsigned char) (tr - (rsign * std::min(*(xt++), *(yt)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = (unsigned char) (tg - (gsign * std::min(*(xt++), *(yt + 1)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = (unsigned char) (tb - (bsign * std::min(*(xt++), *(yt + 2)))); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} } void TextureRender::cdgradient() { - // cross diagonal gradient - based on original dgradient, written by - // Mosfet (mosfet@kde.org) - // adapted from kde sources for Blackbox by Brad Hughes +// cross diagonal gradient - based on original dgradient, written by +// Mosfet (mosfet@kde.org) +// adapted from kde sources for Blackbox by Brad Hughes - float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0, - xr = (float) from->red(), - xg = (float) from->green(), - xb = (float) from->blue(); - unsigned char *pr = red, *pg = green, *pb = blue; - unsigned int w = width * 2, h = height * 2, *xt, *yt; +float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0, + xr = (float) from->red(), + xg = (float) from->green(), + xb = (float) from->blue(); +unsigned char *pr = red, *pg = green, *pb = blue; +unsigned int w = width * 2, h = height * 2, *xt, *yt; - register unsigned int x, y; +register unsigned int x, y; - dry = drx = (float) (to->red() - from->red()); - dgy = dgx = (float) (to->green() - from->green()); - dby = dbx = (float) (to->blue() - from->blue()); +dry = drx = (float) (to->red() - from->red()); +dgy = dgx = (float) (to->green() - from->green()); +dby = dbx = (float) (to->blue() - from->blue()); - // Create X table - drx /= w; - dgx /= w; - dbx /= w; +// Create X table +drx /= w; +dgx /= w; +dbx /= w; - for (xt = (xtable + (width * 3) - 1), x = 0; x < width; x++) { - *(xt--) = (unsigned char) xb; - *(xt--) = (unsigned char) xg; - *(xt--) = (unsigned char) xr; +for (xt = (xtable + (width * 3) - 1), x = 0; x < width; x++) { +*(xt--) = (unsigned char) xb; +*(xt--) = (unsigned char) xg; +*(xt--) = (unsigned char) xr; - xr += drx; - xg += dgx; - xb += dbx; - } +xr += drx; +xg += dgx; +xb += dbx; +} - // Create Y table - dry /= h; - dgy /= h; - dby /= h; +// Create Y table +dry /= h; +dgy /= h; +dby /= h; - for (yt = ytable, y = 0; y < height; y++) { - *(yt++) = (unsigned char) yr; - *(yt++) = (unsigned char) yg; - *(yt++) = (unsigned char) yb; +for (yt = ytable, y = 0; y < height; y++) { +*(yt++) = (unsigned char) yr; +*(yt++) = (unsigned char) yg; +*(yt++) = (unsigned char) yb; - yr += dry; - yg += dgy; - yb += dby; - } +yr += dry; +yg += dgy; +yb += dby; +} - // Combine tables to create gradient +// Combine tables to create gradient - if (! interlaced) { - // normal cdgradient - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - *(pr++) = *(xt++) + *(yt); - *(pg++) = *(xt++) + *(yt + 1); - *(pb++) = *(xt++) + *(yt + 2); - } - } +if (! interlaced) { +// normal cdgradient +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +*(pr++) = *(xt++) + *(yt); +*(pg++) = *(xt++) + *(yt + 1); +*(pb++) = *(xt++) + *(yt + 2); +} +} - } else { - // faked interlacing effect - unsigned char channel, channel2; +} else { +// faked interlacing effect +unsigned char channel, channel2; - for (yt = ytable, y = 0; y < height; y++, yt += 3) { - for (xt = xtable, x = 0; x < width; x++) { - if (y & 1) { - channel = *(xt++) + *(yt); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pr++) = channel2; +for (yt = ytable, y = 0; y < height; y++, yt += 3) { +for (xt = xtable, x = 0; x < width; x++) { +if (y & 1) { +channel = *(xt++) + *(yt); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pr++) = channel2; - channel = *(xt++) + *(yt + 1); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pg++) = channel2; +channel = *(xt++) + *(yt + 1); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pg++) = channel2; - channel = *(xt++) + *(yt + 2); - channel2 = (channel >> 1) + (channel >> 2); - if (channel2 > channel) channel2 = 0; - *(pb++) = channel2; - } else { - channel = *(xt++) + *(yt); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pr++) = channel2; +channel = *(xt++) + *(yt + 2); +channel2 = (channel >> 1) + (channel >> 2); +if (channel2 > channel) channel2 = 0; +*(pb++) = channel2; +} else { +channel = *(xt++) + *(yt); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pr++) = channel2; - channel = *(xt++) + *(yt + 1); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pg++) = channel2; +channel = *(xt++) + *(yt + 1); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pg++) = channel2; - channel = *(xt++) + *(yt + 2); - channel2 = channel + (channel >> 3); - if (channel2 < channel) channel2 = ~0; - *(pb++) = channel2; - } - } - } - } +channel = *(xt++) + *(yt + 2); +channel2 = channel + (channel >> 3); +if (channel2 < channel) channel2 = ~0; +*(pb++) = channel2; +} +} +} +} }
M src/TextureRender.hhsrc/TextureRender.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: TextureRender.hh,v 1.2 2002/11/30 20:36:22 fluxgen Exp $ +// $Id: TextureRender.hh,v 1.3 2002/12/01 13:42:00 rathnor Exp $ #ifndef TEXTURRENDER_HH #define TEXTURRENDER_HH

@@ -38,57 +38,57 @@ Renders texture to pixmap

*/ class TextureRender { public: - TextureRender(BImageControl &ic, unsigned int width, unsigned int height, - XColor *_colors=0, size_t num_colors=0); - ~TextureRender(); - /// render to pixmap - Pixmap render(const FbTk::Texture &src_texture); - /// render solid texture to pixmap - Pixmap renderSolid(const FbTk::Texture &src_texture); - /// render gradient texture to pixmap - Pixmap renderGradient(const FbTk::Texture &src_texture); + TextureRender(BImageControl &ic, unsigned int width, unsigned int height, + XColor *_colors=0, size_t num_colors=0); + ~TextureRender(); + /// render to pixmap + Pixmap render(const FbTk::Texture &src_texture); + /// render solid texture to pixmap + Pixmap renderSolid(const FbTk::Texture &src_texture); + /// render gradient texture to pixmap + Pixmap renderGradient(const FbTk::Texture &src_texture); private: - /** - Render to pixmap - @return rendered pixmap - */ - Pixmap renderPixmap(); - /** - Render to XImage - @returns allocated and rendered XImage, user is responsible to deallocate - */ - XImage *renderXImage(); - /** - @name render functions - */ - //@{ - void invert(); - void bevel1(); - void bevel2(); - void dgradient(); - void egradient(); - void hgradient(); - void pgradient(); - void rgradient(); - void vgradient(); - void cdgradient(); - void pcgradient(); - //@} - void makeGradientBuffers(); + /** + Render to pixmap + @return rendered pixmap + */ + Pixmap renderPixmap(); + /** + Render to XImage + @returns allocated and rendered XImage, user is responsible to deallocate + */ + XImage *renderXImage(); + /** + @name render functions + */ + //@{ + void invert(); + void bevel1(); + void bevel2(); + void dgradient(); + void egradient(); + void hgradient(); + void pgradient(); + void rgradient(); + void vgradient(); + void cdgradient(); + void pcgradient(); + //@} + void makeGradientBuffers(); - BImageControl &control; - bool interlaced; + BImageControl &control; + bool interlaced; - XColor *colors; // color table + XColor *colors; // color table - const FbTk::Color *from, *to; - int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits, - ncolors, cpc, cpccpc; - unsigned char *red, *green, *blue; - const unsigned char *red_table, *green_table, *blue_table; - unsigned int width, height; - unsigned int *xtable, *ytable; + const FbTk::Color *from, *to; + int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits, + ncolors, cpc, cpccpc; + unsigned char *red, *green, *blue; + const unsigned char *red_table, *green_table, *blue_table; + unsigned int width, height; + unsigned int *xtable, *ytable; }; #endif // TEXTURERENDER_HH
M src/Theme.ccsrc/Theme.cc

@@ -21,7 +21,7 @@ // 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. -// $Id: Theme.cc,v 1.37 2002/11/30 20:58:13 fluxgen Exp $ +// $Id: Theme.cc,v 1.38 2002/12/01 13:42:00 rathnor Exp $ #include "Theme.hh"

@@ -54,116 +54,116 @@ #include <iostream>

using namespace std; Theme::Theme(Display *display, Window rootwindow, Colormap colormap, - int screennum, const char *filename, const char *rootcommand): -m_display(display), -m_colormap(colormap), -m_screennum(screennum), -m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointer to std::string + int screennum, const char *filename, const char *rootcommand): + m_display(display), + m_colormap(colormap), + m_screennum(screennum), + m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointer to std::string { - load(filename); + load(filename); - //-------- create gc for the styles ------------ + //-------- create gc for the styles ------------ - XGCValues gcv; - unsigned long gc_value_mask = GCForeground; + XGCValues gcv; + unsigned long gc_value_mask = GCForeground; - gcv.foreground = WhitePixel(m_display, screennum)^BlackPixel(m_display, screennum); - gcv.function = GXxor; - gcv.subwindow_mode = IncludeInferiors; - m_opgc = XCreateGC(m_display, rootwindow, - GCForeground | GCFunction | GCSubwindowMode, &gcv); + gcv.foreground = WhitePixel(m_display, screennum)^BlackPixel(m_display, screennum); + gcv.function = GXxor; + gcv.subwindow_mode = IncludeInferiors; + m_opgc = XCreateGC(m_display, rootwindow, + GCForeground | GCFunction | GCSubwindowMode, &gcv); - gcv.foreground = m_windowstyle.l_text_focus.pixel(); - m_windowstyle.l_text_focus_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_windowstyle.l_text_focus.pixel(); + m_windowstyle.l_text_focus_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); - m_windowstyle.l_text_unfocus_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); + m_windowstyle.l_text_unfocus_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - //---- Tab - gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); + //---- Tab + gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); - m_windowstyle.tab.l_text_focus_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + m_windowstyle.tab.l_text_focus_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_windowstyle.tab.l_text_unfocus.pixel(); - m_windowstyle.tab.l_text_unfocus_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_windowstyle.tab.l_text_unfocus.pixel(); + m_windowstyle.tab.l_text_unfocus_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - //---end Tab + //---end Tab - gcv.foreground = m_windowstyle.b_pic_focus.pixel(); - m_windowstyle.b_pic_focus_gc = - XCreateGC(m_display, rootwindow, - GCForeground, &gcv); + gcv.foreground = m_windowstyle.b_pic_focus.pixel(); + m_windowstyle.b_pic_focus_gc = + XCreateGC(m_display, rootwindow, + GCForeground, &gcv); - gcv.foreground = m_windowstyle.b_pic_unfocus.pixel(); - m_windowstyle.b_pic_unfocus_gc = - XCreateGC(m_display, rootwindow, - GCForeground, &gcv); + gcv.foreground = m_windowstyle.b_pic_unfocus.pixel(); + m_windowstyle.b_pic_unfocus_gc = + XCreateGC(m_display, rootwindow, + GCForeground, &gcv); - gcv.foreground = m_menustyle.t_text.pixel(); + gcv.foreground = m_menustyle.t_text.pixel(); - m_menustyle.t_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + m_menustyle.t_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.f_text.pixel(); + gcv.foreground = m_menustyle.f_text.pixel(); - m_menustyle.f_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + m_menustyle.f_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.h_text.pixel(); - m_menustyle.h_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.h_text.pixel(); + m_menustyle.h_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.d_text.pixel(); - m_menustyle.d_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.d_text.pixel(); + m_menustyle.d_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.hilite.color().pixel(); - m_menustyle.hilite_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.hilite.color().pixel(); + m_menustyle.hilite_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.l_text.pixel(); + gcv.foreground = m_toolbarstyle.l_text.pixel(); - m_toolbarstyle.l_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + m_toolbarstyle.l_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.w_text.pixel(); - m_toolbarstyle.w_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.w_text.pixel(); + m_toolbarstyle.w_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.c_text.pixel(); - m_toolbarstyle.c_text_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.c_text.pixel(); + m_toolbarstyle.c_text_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.b_pic.pixel(); - m_toolbarstyle.b_pic_gc = - XCreateGC(m_display, rootwindow, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.b_pic.pixel(); + m_toolbarstyle.b_pic_gc = + XCreateGC(m_display, rootwindow, + gc_value_mask, &gcv); } Theme::~Theme() { - freeMenuStyle(); - freeWindowStyle(); - freeToolbarStyle(); - freeTabStyle(); + freeMenuStyle(); + freeWindowStyle(); + freeToolbarStyle(); + freeTabStyle(); } //----- freeMenuStyle -----

@@ -172,29 +172,29 @@ // should only be called from ~Theme

//-------------------- void Theme::freeMenuStyle() { - XFreeGC(m_display, m_menustyle.t_text_gc); - XFreeGC(m_display, m_menustyle.f_text_gc); - XFreeGC(m_display, m_menustyle.h_text_gc); - XFreeGC(m_display, m_menustyle.d_text_gc); - XFreeGC(m_display, m_menustyle.hilite_gc); + XFreeGC(m_display, m_menustyle.t_text_gc); + XFreeGC(m_display, m_menustyle.f_text_gc); + XFreeGC(m_display, m_menustyle.h_text_gc); + XFreeGC(m_display, m_menustyle.d_text_gc); + XFreeGC(m_display, m_menustyle.hilite_gc); } //----- freeWindowStyle ----- // free memory allocated for m_windowstyle //-------------------- void Theme::freeWindowStyle() { - XFreeGC(m_display, m_windowstyle.l_text_focus_gc); - XFreeGC(m_display, m_windowstyle.l_text_unfocus_gc); - XFreeGC(m_display, m_windowstyle.b_pic_focus_gc); - XFreeGC(m_display, m_windowstyle.b_pic_unfocus_gc); + XFreeGC(m_display, m_windowstyle.l_text_focus_gc); + XFreeGC(m_display, m_windowstyle.l_text_unfocus_gc); + XFreeGC(m_display, m_windowstyle.b_pic_focus_gc); + XFreeGC(m_display, m_windowstyle.b_pic_unfocus_gc); } //----- freeTabStyle ----- // free memory allocated for m_windowstyle.tab //-------------------- void Theme::freeTabStyle() { - XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc); - XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); + XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc); + XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); } //----- freeToolbarStyle -----

@@ -203,10 +203,10 @@ // should only be called from ~Theme

//-------------------- void Theme::freeToolbarStyle() { - XFreeGC(m_display, m_toolbarstyle.l_text_gc); - XFreeGC(m_display, m_toolbarstyle.w_text_gc); - XFreeGC(m_display, m_toolbarstyle.c_text_gc); - XFreeGC(m_display, m_toolbarstyle.b_pic_gc); + XFreeGC(m_display, m_toolbarstyle.l_text_gc); + XFreeGC(m_display, m_toolbarstyle.w_text_gc); + XFreeGC(m_display, m_toolbarstyle.c_text_gc); + XFreeGC(m_display, m_toolbarstyle.b_pic_gc); }

@@ -214,847 +214,847 @@ //---------- load ------------

// Loads a theme from a file //---------------------------- void Theme::load(const char *filename){ - m_database = XrmGetFileDatabase(filename); - if (!m_database) - m_database = XrmGetFileDatabase(DEFAULTSTYLE); + m_database = XrmGetFileDatabase(filename); + if (!m_database) + m_database = XrmGetFileDatabase(DEFAULTSTYLE); - loadMenuStyle(); - loadToolbarStyle(); - loadWindowStyle(); - loadTabStyle(); - loadRootCommand(); - loadMisc(); + loadMenuStyle(); + loadToolbarStyle(); + loadWindowStyle(); + loadTabStyle(); + loadRootCommand(); + loadMisc(); - XrmDestroyDatabase(m_database); + XrmDestroyDatabase(m_database); } void Theme::loadMenuStyle() { - readDatabaseTexture("menu.title", "Menu.Title", - &m_menustyle.title, - WhitePixel(m_display, m_screennum)); - readDatabaseTexture("menu.frame", "Menu.Frame", - &m_menustyle.frame, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("menu.hilite", "Menu.Hilite", - &m_menustyle.hilite, - WhitePixel(m_display, m_screennum)); - readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor", - &m_menustyle.t_text, - BlackPixel(m_display, m_screennum)); - readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor", - &m_menustyle.f_text, - WhitePixel(m_display, m_screennum)); - readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor", - &m_menustyle.d_text, - BlackPixel(m_display, m_screennum)); - readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor", - &m_menustyle.h_text, - BlackPixel(m_display, m_screennum)); + readDatabaseTexture("menu.title", "Menu.Title", + &m_menustyle.title, + WhitePixel(m_display, m_screennum)); + readDatabaseTexture("menu.frame", "Menu.Frame", + &m_menustyle.frame, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("menu.hilite", "Menu.Hilite", + &m_menustyle.hilite, + WhitePixel(m_display, m_screennum)); + readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor", + &m_menustyle.t_text, + BlackPixel(m_display, m_screennum)); + readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor", + &m_menustyle.f_text, + WhitePixel(m_display, m_screennum)); + readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor", + &m_menustyle.d_text, + BlackPixel(m_display, m_screennum)); + readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor", + &m_menustyle.h_text, + BlackPixel(m_display, m_screennum)); - XrmValue value; - char *value_type=0; + XrmValue value; + char *value_type=0; - if (XrmGetResource(m_database, "menu.title.justify", - "Menu.Title.Justify", &value_type, &value)) { + if (XrmGetResource(m_database, "menu.title.justify", + "Menu.Title.Justify", &value_type, &value)) { - if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_menustyle.titlefont_justify = DrawUtil::Font::RIGHT; - else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_menustyle.titlefont_justify = DrawUtil::Font::CENTER; - else - m_menustyle.titlefont_justify = DrawUtil::Font::LEFT; + if (strstr(value.addr, "right") || strstr(value.addr, "Right")) + m_menustyle.titlefont_justify = DrawUtil::Font::RIGHT; + else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) + m_menustyle.titlefont_justify = DrawUtil::Font::CENTER; + else + m_menustyle.titlefont_justify = DrawUtil::Font::LEFT; - } else - m_menustyle.titlefont_justify = DrawUtil::Font::LEFT; + } else + m_menustyle.titlefont_justify = DrawUtil::Font::LEFT; - if (XrmGetResource(m_database, "menu.frame.justify", - "Menu.Frame.Justify", &value_type, &value)) { + if (XrmGetResource(m_database, "menu.frame.justify", + "Menu.Frame.Justify", &value_type, &value)) { - if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_menustyle.framefont_justify = DrawUtil::Font::RIGHT; - else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_menustyle.framefont_justify = DrawUtil::Font::CENTER; - else - m_menustyle.framefont_justify = DrawUtil::Font::LEFT; + if (strstr(value.addr, "right") || strstr(value.addr, "Right")) + m_menustyle.framefont_justify = DrawUtil::Font::RIGHT; + else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) + m_menustyle.framefont_justify = DrawUtil::Font::CENTER; + else + m_menustyle.framefont_justify = DrawUtil::Font::LEFT; - } else - m_menustyle.framefont_justify = DrawUtil::Font::LEFT; + } else + m_menustyle.framefont_justify = DrawUtil::Font::LEFT; - if (XrmGetResource(m_database, "menu.bullet", "Menu.Bullet", - &value_type, &value)) { + if (XrmGetResource(m_database, "menu.bullet", "Menu.Bullet", + &value_type, &value)) { - if (! strncasecmp(value.addr, "empty", value.size)) - m_menustyle.bullet = Basemenu::EMPTY; - else if (! strncasecmp(value.addr, "square", value.size)) - m_menustyle.bullet = Basemenu::SQUARE; - else if (! strncasecmp(value.addr, "diamond", value.size)) - m_menustyle.bullet = Basemenu::DIAMOND; - else - m_menustyle.bullet = Basemenu::TRIANGLE; + if (! strncasecmp(value.addr, "empty", value.size)) + m_menustyle.bullet = Basemenu::EMPTY; + else if (! strncasecmp(value.addr, "square", value.size)) + m_menustyle.bullet = Basemenu::SQUARE; + else if (! strncasecmp(value.addr, "diamond", value.size)) + m_menustyle.bullet = Basemenu::DIAMOND; + else + m_menustyle.bullet = Basemenu::TRIANGLE; - } else - m_menustyle.bullet = Basemenu::TRIANGLE; + } else + m_menustyle.bullet = Basemenu::TRIANGLE; - if (XrmGetResource(m_database, "menu.bullet.position", - "Menu.Bullet.Position", &value_type, &value)) { + if (XrmGetResource(m_database, "menu.bullet.position", + "Menu.Bullet.Position", &value_type, &value)) { - if (! strncasecmp(value.addr, "right", value.size)) - m_menustyle.bullet_pos = Basemenu::RIGHT; - else - m_menustyle.bullet_pos = Basemenu::LEFT; + if (! strncasecmp(value.addr, "right", value.size)) + m_menustyle.bullet_pos = Basemenu::RIGHT; + else + m_menustyle.bullet_pos = Basemenu::LEFT; - } else - m_menustyle.bullet_pos = Basemenu::LEFT; + } else + m_menustyle.bullet_pos = Basemenu::LEFT; - //---------- font - loadFontFromDatabase(m_menustyle.framefont, "menu.frame.font", "Menu.Frame.Font"); - loadFontFromDatabase(m_menustyle.titlefont, "menu.title.font", "Menu.Title.Font"); + //---------- font + loadFontFromDatabase(m_menustyle.framefont, "menu.frame.font", "Menu.Frame.Font"); + loadFontFromDatabase(m_menustyle.titlefont, "menu.title.font", "Menu.Title.Font"); } void Theme::loadWindowStyle() { - //read textures + //read textures - readDatabaseTexture("window.title.focus", "Window.Title.Focus", - &m_windowstyle.t_focus, - WhitePixel(m_display, m_screennum)); - if ( (m_windowstyle.t_focus.type() & FbTk::Texture::PARENTRELATIVE) ) { - cerr<<"Warning: window.title.focus type is ParentRelative. Using flat solid!"<<endl; - m_windowstyle.t_focus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); - } - readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus", - &m_windowstyle.t_unfocus, - BlackPixel(m_display, m_screennum)); - if ( (m_windowstyle.t_unfocus.type() & FbTk::Texture::PARENTRELATIVE) ) { - cerr<<"Warning: window.title.unfocus type is ParentRelative. Using flat solid!"<<endl; - m_windowstyle.t_unfocus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); - } + readDatabaseTexture("window.title.focus", "Window.Title.Focus", + &m_windowstyle.t_focus, + WhitePixel(m_display, m_screennum)); + if ( (m_windowstyle.t_focus.type() & FbTk::Texture::PARENTRELATIVE) ) { + cerr<<"Warning: window.title.focus type is ParentRelative. Using flat solid!"<<endl; + m_windowstyle.t_focus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); + } + readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus", + &m_windowstyle.t_unfocus, + BlackPixel(m_display, m_screennum)); + if ( (m_windowstyle.t_unfocus.type() & FbTk::Texture::PARENTRELATIVE) ) { + cerr<<"Warning: window.title.unfocus type is ParentRelative. Using flat solid!"<<endl; + m_windowstyle.t_unfocus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); + } - readDatabaseTexture("window.label.focus", "Window.Label.Focus", - &m_windowstyle.l_focus, - WhitePixel(m_display, m_screennum)); - readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus", - &m_windowstyle.l_unfocus, - BlackPixel(m_display, m_screennum)); + readDatabaseTexture("window.label.focus", "Window.Label.Focus", + &m_windowstyle.l_focus, + WhitePixel(m_display, m_screennum)); + readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus", + &m_windowstyle.l_unfocus, + BlackPixel(m_display, m_screennum)); - readDatabaseTexture("window.handle.focus", "Window.Handle.Focus", - &m_windowstyle.h_focus, - WhitePixel(m_display, m_screennum)); - if ( (m_windowstyle.h_focus.type() & FbTk::Texture::PARENTRELATIVE) ) { - cerr<<"Warning: window.handle.focus is ParentReleative. Using flat solid instead."<<endl; - m_windowstyle.h_focus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); - } - readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus", - &m_windowstyle.h_unfocus, - BlackPixel(m_display, m_screennum)); - if ( (m_windowstyle.h_unfocus.type() & FbTk::Texture::PARENTRELATIVE) ) { - cerr<<"Warning: window.handle.unfocus is ParentReleative. Using flat solid instead."<<endl; - m_windowstyle.h_unfocus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); - } + readDatabaseTexture("window.handle.focus", "Window.Handle.Focus", + &m_windowstyle.h_focus, + WhitePixel(m_display, m_screennum)); + if ( (m_windowstyle.h_focus.type() & FbTk::Texture::PARENTRELATIVE) ) { + cerr<<"Warning: window.handle.focus is ParentReleative. Using flat solid instead."<<endl; + m_windowstyle.h_focus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); + } + readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus", + &m_windowstyle.h_unfocus, + BlackPixel(m_display, m_screennum)); + if ( (m_windowstyle.h_unfocus.type() & FbTk::Texture::PARENTRELATIVE) ) { + cerr<<"Warning: window.handle.unfocus is ParentReleative. Using flat solid instead."<<endl; + m_windowstyle.h_unfocus.setType(FbTk::Texture::FLAT|FbTk::Texture::SOLID); + } - readDatabaseTexture("window.grip.focus", "Window.Grip.Focus", - &m_windowstyle.g_focus, - WhitePixel(m_display, m_screennum)); - readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus", - &m_windowstyle.g_unfocus, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("window.button.focus", "Window.Button.Focus", - &m_windowstyle.b_focus, - WhitePixel(m_display, m_screennum)); - readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus", - &m_windowstyle.b_unfocus, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("window.button.pressed", "Window.Button.Pressed", - &m_windowstyle.b_pressed, - BlackPixel(m_display, m_screennum)); + readDatabaseTexture("window.grip.focus", "Window.Grip.Focus", + &m_windowstyle.g_focus, + WhitePixel(m_display, m_screennum)); + readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus", + &m_windowstyle.g_unfocus, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("window.button.focus", "Window.Button.Focus", + &m_windowstyle.b_focus, + WhitePixel(m_display, m_screennum)); + readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus", + &m_windowstyle.b_unfocus, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("window.button.pressed", "Window.Button.Pressed", + &m_windowstyle.b_pressed, + BlackPixel(m_display, m_screennum)); - // read colors + // read colors - readDatabaseColor("window.frame.focusColor", - "Window.Frame.FocusColor", - &m_windowstyle.f_focus, - WhitePixel(m_display, m_screennum)); - readDatabaseColor("window.frame.unfocusColor", - "Window.Frame.UnfocusColor", - &m_windowstyle.f_unfocus, - BlackPixel(m_display, m_screennum)); - readDatabaseColor("window.label.focus.textColor", - "Window.Label.Focus.TextColor", - &m_windowstyle.l_text_focus, - BlackPixel(m_display, m_screennum)); - readDatabaseColor("window.label.unfocus.textColor", - "Window.Label.Unfocus.TextColor", - &m_windowstyle.l_text_unfocus, - WhitePixel(m_display, m_screennum)); - readDatabaseColor("window.button.focus.picColor", - "Window.Button.Focus.PicColor", - &m_windowstyle.b_pic_focus, - BlackPixel(m_display, m_screennum)); - readDatabaseColor("window.button.unfocus.picColor", - "Window.Button.Unfocus.PicColor", - &m_windowstyle.b_pic_unfocus, - WhitePixel(m_display, m_screennum)); + readDatabaseColor("window.frame.focusColor", + "Window.Frame.FocusColor", + &m_windowstyle.f_focus, + WhitePixel(m_display, m_screennum)); + readDatabaseColor("window.frame.unfocusColor", + "Window.Frame.UnfocusColor", + &m_windowstyle.f_unfocus, + BlackPixel(m_display, m_screennum)); + readDatabaseColor("window.label.focus.textColor", + "Window.Label.Focus.TextColor", + &m_windowstyle.l_text_focus, + BlackPixel(m_display, m_screennum)); + readDatabaseColor("window.label.unfocus.textColor", + "Window.Label.Unfocus.TextColor", + &m_windowstyle.l_text_unfocus, + WhitePixel(m_display, m_screennum)); + readDatabaseColor("window.button.focus.picColor", + "Window.Button.Focus.PicColor", + &m_windowstyle.b_pic_focus, + BlackPixel(m_display, m_screennum)); + readDatabaseColor("window.button.unfocus.picColor", + "Window.Button.Unfocus.PicColor", + &m_windowstyle.b_pic_unfocus, + WhitePixel(m_display, m_screennum)); - //----- font - loadFontFromDatabase(m_windowstyle.font, "window.font", "Window.Font"); + //----- font + loadFontFromDatabase(m_windowstyle.font, "window.font", "Window.Font"); - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (XrmGetResource(m_database, "window.justify", "Window.Justify", - &value_type, &value)) { - if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_windowstyle.justify = DrawUtil::Font::RIGHT; - else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_windowstyle.justify = DrawUtil::Font::CENTER; - else - m_windowstyle.justify = DrawUtil::Font::LEFT; - } else - m_windowstyle.justify = DrawUtil::Font::LEFT; + if (XrmGetResource(m_database, "window.justify", "Window.Justify", + &value_type, &value)) { + if (strstr(value.addr, "right") || strstr(value.addr, "Right")) + m_windowstyle.justify = DrawUtil::Font::RIGHT; + else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) + m_windowstyle.justify = DrawUtil::Font::CENTER; + else + m_windowstyle.justify = DrawUtil::Font::LEFT; + } else + m_windowstyle.justify = DrawUtil::Font::LEFT; } void Theme::loadTabStyle() { - if (!readDatabaseTexture("window.tab.title.focus", "Window.Tab.Title.Focus", - &m_windowstyle.tab.t_focus, - WhitePixel(m_display, m_screennum))) - m_windowstyle.tab.t_focus = m_windowstyle.t_focus; + if (!readDatabaseTexture("window.tab.title.focus", "Window.Tab.Title.Focus", + &m_windowstyle.tab.t_focus, + WhitePixel(m_display, m_screennum))) + m_windowstyle.tab.t_focus = m_windowstyle.t_focus; - if (!readDatabaseTexture("window.tab.title.unfocus", "Window.Tab.Title.Unfocus", - &m_windowstyle.tab.t_unfocus, - BlackPixel(m_display, m_screennum))) - m_windowstyle.tab.t_unfocus = m_windowstyle.t_unfocus; + if (!readDatabaseTexture("window.tab.title.unfocus", "Window.Tab.Title.Unfocus", + &m_windowstyle.tab.t_unfocus, + BlackPixel(m_display, m_screennum))) + m_windowstyle.tab.t_unfocus = m_windowstyle.t_unfocus; - if (!readDatabaseTexture("window.tab.label.focus", "Window.Tab.Label.Focus", - &m_windowstyle.tab.l_focus, - WhitePixel(m_display, m_screennum))) - m_windowstyle.tab.l_focus = m_windowstyle.l_focus; + if (!readDatabaseTexture("window.tab.label.focus", "Window.Tab.Label.Focus", + &m_windowstyle.tab.l_focus, + WhitePixel(m_display, m_screennum))) + m_windowstyle.tab.l_focus = m_windowstyle.l_focus; - if (!readDatabaseTexture("window.tab.label.unfocus", "Window.Tab.Label.Unfocus", - &m_windowstyle.tab.l_unfocus, - BlackPixel(m_display, m_screennum))) - m_windowstyle.tab.l_unfocus = m_windowstyle.l_unfocus; + if (!readDatabaseTexture("window.tab.label.unfocus", "Window.Tab.Label.Unfocus", + &m_windowstyle.tab.l_unfocus, + BlackPixel(m_display, m_screennum))) + m_windowstyle.tab.l_unfocus = m_windowstyle.l_unfocus; - if (!readDatabaseColor("window.tab.label.focus.textColor", - "Window.Tab.Label.Focus.TextColor", - &m_windowstyle.tab.l_text_focus, - BlackPixel(m_display, m_screennum))) - m_windowstyle.tab.l_text_focus = m_windowstyle.l_text_focus; + if (!readDatabaseColor("window.tab.label.focus.textColor", + "Window.Tab.Label.Focus.TextColor", + &m_windowstyle.tab.l_text_focus, + BlackPixel(m_display, m_screennum))) + m_windowstyle.tab.l_text_focus = m_windowstyle.l_text_focus; - if (!readDatabaseColor("window.tab.label.unfocus.textColor", - "Window.Tab.Label.Unfocus.TextColor", - &m_windowstyle.tab.l_text_unfocus, - WhitePixel(m_display, m_screennum))) - m_windowstyle.tab.l_text_unfocus = m_windowstyle.l_text_unfocus; + if (!readDatabaseColor("window.tab.label.unfocus.textColor", + "Window.Tab.Label.Unfocus.TextColor", + &m_windowstyle.tab.l_text_unfocus, + WhitePixel(m_display, m_screennum))) + m_windowstyle.tab.l_text_unfocus = m_windowstyle.l_text_unfocus; - readDatabaseColor("window.tab.borderColor", "Window.Tab.BorderColor", - &m_windowstyle.tab.border_color, - BlackPixel(m_display, m_screennum)); + readDatabaseColor("window.tab.borderColor", "Window.Tab.BorderColor", + &m_windowstyle.tab.border_color, + BlackPixel(m_display, m_screennum)); - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (XrmGetResource(m_database, "window.tab.borderWidth", "Window.Tab.BorderWidth", - &value_type, &value)) { - if (sscanf(value.addr, "%u", &m_windowstyle.tab.border_width) != 1) - m_windowstyle.tab.border_width = 1; - } else - m_windowstyle.tab.border_width = 1; + if (XrmGetResource(m_database, "window.tab.borderWidth", "Window.Tab.BorderWidth", + &value_type, &value)) { + if (sscanf(value.addr, "%u", &m_windowstyle.tab.border_width) != 1) + m_windowstyle.tab.border_width = 1; + } else + m_windowstyle.tab.border_width = 1; - m_windowstyle.tab.border_width_2x = m_windowstyle.tab.border_width*2; + m_windowstyle.tab.border_width_2x = m_windowstyle.tab.border_width*2; - loadFontFromDatabase(m_windowstyle.tab.font, "window.tab.font", "Window.Tab.Font"); + loadFontFromDatabase(m_windowstyle.tab.font, "window.tab.font", "Window.Tab.Font"); - if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify", - &value_type, &value)) { - if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_windowstyle.tab.justify = DrawUtil::Font::RIGHT; - else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_windowstyle.tab.justify = DrawUtil::Font::CENTER; - else - m_windowstyle.tab.justify = DrawUtil::Font::LEFT; - } else - m_windowstyle.tab.justify = DrawUtil::Font::LEFT; + if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify", + &value_type, &value)) { + if (strstr(value.addr, "right") || strstr(value.addr, "Right")) + m_windowstyle.tab.justify = DrawUtil::Font::RIGHT; + else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) + m_windowstyle.tab.justify = DrawUtil::Font::CENTER; + else + m_windowstyle.tab.justify = DrawUtil::Font::LEFT; + } else + m_windowstyle.tab.justify = DrawUtil::Font::LEFT; } void Theme::loadToolbarStyle() { - readDatabaseTexture("toolbar", "Toolbar", - &m_toolbarstyle.toolbar, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("toolbar.label", "Toolbar.Label", - &m_toolbarstyle.label, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel", - &m_toolbarstyle.window, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("toolbar.button", "Toolbar.Button", - &m_toolbarstyle.button, - WhitePixel(m_display, m_screennum)); - readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed", - &m_toolbarstyle.pressed, - BlackPixel(m_display, m_screennum)); - readDatabaseTexture("toolbar.clock", "Toolbar.Clock", - &m_toolbarstyle.clock, - BlackPixel(m_display, m_screennum)); + readDatabaseTexture("toolbar", "Toolbar", + &m_toolbarstyle.toolbar, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("toolbar.label", "Toolbar.Label", + &m_toolbarstyle.label, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel", + &m_toolbarstyle.window, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("toolbar.button", "Toolbar.Button", + &m_toolbarstyle.button, + WhitePixel(m_display, m_screennum)); + readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed", + &m_toolbarstyle.pressed, + BlackPixel(m_display, m_screennum)); + readDatabaseTexture("toolbar.clock", "Toolbar.Clock", + &m_toolbarstyle.clock, + BlackPixel(m_display, m_screennum)); - readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor", - &m_toolbarstyle.l_text, - WhitePixel(m_display, m_screennum)); + readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor", + &m_toolbarstyle.l_text, + WhitePixel(m_display, m_screennum)); - readDatabaseColor("toolbar.windowLabel.textColor", - "Toolbar.WindowLabel.TextColor", - &m_toolbarstyle.w_text, - WhitePixel(m_display, m_screennum)); + readDatabaseColor("toolbar.windowLabel.textColor", + "Toolbar.WindowLabel.TextColor", + &m_toolbarstyle.w_text, + WhitePixel(m_display, m_screennum)); - readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor", - &m_toolbarstyle.c_text, - WhitePixel(m_display, m_screennum)); - readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor", - &m_toolbarstyle.b_pic, - BlackPixel(m_display, m_screennum)); + readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor", + &m_toolbarstyle.c_text, + WhitePixel(m_display, m_screennum)); + readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor", + &m_toolbarstyle.b_pic, + BlackPixel(m_display, m_screennum)); - // ----------- load font + // ----------- load font - loadFontFromDatabase(m_toolbarstyle.font, "toolbar.font", "Toolbar.Font"); + loadFontFromDatabase(m_toolbarstyle.font, "toolbar.font", "Toolbar.Font"); - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (XrmGetResource(m_database, "toolbar.justify", - "Toolbar.Justify", &value_type, &value)) { - if (strstr(value.addr, "right") || strstr(value.addr, "Right")) - m_toolbarstyle.justify = DrawUtil::Font::RIGHT; - else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) - m_toolbarstyle.justify = DrawUtil::Font::CENTER; - else - m_toolbarstyle.justify = DrawUtil::Font::LEFT; - } else - m_toolbarstyle.justify = DrawUtil::Font::LEFT; + if (XrmGetResource(m_database, "toolbar.justify", + "Toolbar.Justify", &value_type, &value)) { + if (strstr(value.addr, "right") || strstr(value.addr, "Right")) + m_toolbarstyle.justify = DrawUtil::Font::RIGHT; + else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) + m_toolbarstyle.justify = DrawUtil::Font::CENTER; + else + m_toolbarstyle.justify = DrawUtil::Font::LEFT; + } else + m_toolbarstyle.justify = DrawUtil::Font::LEFT; } void Theme::loadRootCommand() { - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (m_rootcommand.size()) { + if (m_rootcommand.size()) { #ifndef __EMX__ - char tmpstring[256]; //to hold m_screennum - tmpstring[0]=0; - sprintf(tmpstring, "%d", m_screennum); - string displaystring("DISPLAY="); - displaystring.append(DisplayString(m_display)); - displaystring.append(tmpstring); // append m_screennum + char tmpstring[256]; //to hold m_screennum + tmpstring[0]=0; + sprintf(tmpstring, "%d", m_screennum); + string displaystring("DISPLAY="); + displaystring.append(DisplayString(m_display)); + displaystring.append(tmpstring); // append m_screennum - bexec(m_rootcommand.c_str(), const_cast<char *>(displaystring.c_str())); + bexec(m_rootcommand.c_str(), const_cast<char *>(displaystring.c_str())); #else // __EMX__ - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_rootcommand.c_str(), 0); + spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_rootcommand.c_str(), 0); #endif // !__EMX__ - } else if (XrmGetResource(m_database, "rootCommand", "RootCommand", - &value_type, &value)) { + } else if (XrmGetResource(m_database, "rootCommand", "RootCommand", + &value_type, &value)) { #ifndef __EMX__ - char tmpstring[256]; //to hold m_screennum - tmpstring[0]=0; - sprintf(tmpstring, "%d", m_screennum); - string displaystring("DISPLAY="); - displaystring.append(DisplayString(m_display)); - displaystring.append(tmpstring); // append m_screennum + char tmpstring[256]; //to hold m_screennum + tmpstring[0]=0; + sprintf(tmpstring, "%d", m_screennum); + string displaystring("DISPLAY="); + displaystring.append(DisplayString(m_display)); + displaystring.append(tmpstring); // append m_screennum - bexec(value.addr, const_cast<char *>(displaystring.c_str())); + bexec(value.addr, const_cast<char *>(displaystring.c_str())); #else // __EMX__ - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", value.addr, 0); + spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", value.addr, 0); #endif // !__EMX__ - } - #ifdef DEBUG - else - cerr<<__FILE__<<"("<<__LINE__<<"): Didn't find rootCommand."<<endl; - #endif + } +#ifdef DEBUG + else + cerr<<__FILE__<<"("<<__LINE__<<"): Didn't find rootCommand."<<endl; +#endif } void Theme::loadMisc() { - unsigned int screen_width_div2 = WidthOfScreen(ScreenOfDisplay(m_display, m_screennum)) / 2; - XrmValue value; - char *value_type=0; + unsigned int screen_width_div2 = WidthOfScreen(ScreenOfDisplay(m_display, m_screennum)) / 2; + XrmValue value; + char *value_type=0; - if (XrmGetResource(m_database, "bevelWidth", "BevelWidth", - &value_type, &value)) { - if (sscanf(value.addr, "%u", &m_bevel_width) != 1 || - m_bevel_width > screen_width_div2 || - m_bevel_width == 0) - m_bevel_width = 3; - } else - m_bevel_width = 3; + if (XrmGetResource(m_database, "bevelWidth", "BevelWidth", + &value_type, &value)) { + if (sscanf(value.addr, "%u", &m_bevel_width) != 1 || + m_bevel_width > screen_width_div2 || + m_bevel_width == 0) + m_bevel_width = 3; + } else + m_bevel_width = 3; - if (XrmGetResource(m_database, "handleWidth", "HandleWidth", - &value_type, &value)) { - if (sscanf(value.addr, "%u", &m_handle_width) != 1 || - m_handle_width > screen_width_div2 || m_handle_width == 0) - m_handle_width = 6; - } else - m_handle_width = 6; + if (XrmGetResource(m_database, "handleWidth", "HandleWidth", + &value_type, &value)) { + if (sscanf(value.addr, "%u", &m_handle_width) != 1 || + m_handle_width > screen_width_div2 || m_handle_width == 0) + m_handle_width = 6; + } else + m_handle_width = 6; - if (XrmGetResource(m_database, "borderWidth", "BorderWidth", - &value_type, &value)) { - if (sscanf(value.addr, "%u", &m_border_width) != 1) - m_border_width = 1; - } else - m_border_width = 1; + if (XrmGetResource(m_database, "borderWidth", "BorderWidth", + &value_type, &value)) { + if (sscanf(value.addr, "%u", &m_border_width) != 1) + m_border_width = 1; + } else + m_border_width = 1; - if (XrmGetResource(m_database, "frameWidth", "FrameWidth", - &value_type, &value)) { - if (sscanf(value.addr, "%u", &m_frame_width) != 1 || - m_frame_width > screen_width_div2) - m_frame_width = m_bevel_width; - } else - m_frame_width = m_bevel_width; + if (XrmGetResource(m_database, "frameWidth", "FrameWidth", + &value_type, &value)) { + if (sscanf(value.addr, "%u", &m_frame_width) != 1 || + m_frame_width > screen_width_div2) + m_frame_width = m_bevel_width; + } else + m_frame_width = m_bevel_width; - readDatabaseColor("borderColor", "BorderColor", &m_border_color, - BlackPixel(m_display, m_screennum)); + readDatabaseColor("borderColor", "BorderColor", &m_border_color, + BlackPixel(m_display, m_screennum)); - // load slit style, if it wasn't found fall back to toolbarstyle - if (!readDatabaseTexture("slit", "Slit", - &m_slit_texture, - BlackPixel(m_display, m_screennum)) ) { - m_slit_texture = m_toolbarstyle.toolbar; - } + // load slit style, if it wasn't found fall back to toolbarstyle + if (!readDatabaseTexture("slit", "Slit", + &m_slit_texture, + BlackPixel(m_display, m_screennum)) ) { + m_slit_texture = m_toolbarstyle.toolbar; + } } bool Theme::readDatabaseTexture(char *rname, char *rclass, - FbTk::Texture *texture, - unsigned long default_pixel) + FbTk::Texture *texture, + unsigned long default_pixel) { - XrmValue value; - char *value_type; - bool retval = true;//return true as default + XrmValue value; + char *value_type; + bool retval = true;//return true as default - if (XrmGetResource(m_database, rname, rclass, &value_type, - &value)) - texture->setFromString(value.addr); - else - texture->setType(FbTk::Texture::SOLID | FbTk::Texture::FLAT); + if (XrmGetResource(m_database, rname, rclass, &value_type, + &value)) + texture->setFromString(value.addr); + else + texture->setType(FbTk::Texture::SOLID | FbTk::Texture::FLAT); - if (texture->type() & FbTk::Texture::SOLID) { - int clen = strlen(rclass) + 32, nlen = strlen(rname) + 32; + if (texture->type() & FbTk::Texture::SOLID) { + int clen = strlen(rclass) + 32, nlen = strlen(rname) + 32; - char *colorclass = new char[clen], *colorname = new char[nlen]; + char *colorclass = new char[clen], *colorname = new char[nlen]; - sprintf(colorclass, "%s.Color", rclass); - sprintf(colorname, "%s.color", rname); + sprintf(colorclass, "%s.Color", rclass); + sprintf(colorname, "%s.color", rname); - if (!readDatabaseColor(colorname, colorclass, &texture->color(), - default_pixel)) - retval = false; + if (!readDatabaseColor(colorname, colorclass, &texture->color(), + default_pixel)) + retval = false; #ifdef INTERLACE - sprintf(colorclass, "%s.ColorTo", rclass); - sprintf(colorname, "%s.colorTo", rname); + sprintf(colorclass, "%s.ColorTo", rclass); + sprintf(colorname, "%s.colorTo", rname); - readDatabaseColor(colorname, colorclass, &texture->colorTo(), default_pixel); + readDatabaseColor(colorname, colorclass, &texture->colorTo(), default_pixel); #endif // INTERLACE - delete [] colorclass; - delete [] colorname; + delete [] colorclass; + delete [] colorname; - if ((! texture->color().isAllocated()) || - (texture->type() & FbTk::Texture::FLAT)) - return retval; + if ((! texture->color().isAllocated()) || + (texture->type() & FbTk::Texture::FLAT)) + return retval; - XColor xcol; + XColor xcol; - xcol.red = (unsigned int) (texture->color().red() + - (texture->color().red() >> 1)); - if (xcol.red >= 0xff) xcol.red = 0xffff; - else xcol.red *= 0xff; - xcol.green = (unsigned int) (texture->color().green() + - (texture->color().green() >> 1)); - if (xcol.green >= 0xff) xcol.green = 0xffff; - else xcol.green *= 0xff; - xcol.blue = (unsigned int) (texture->color().blue() + - (texture->color().blue() >> 1)); - if (xcol.blue >= 0xff) xcol.blue = 0xffff; - else xcol.blue *= 0xff; + xcol.red = (unsigned int) (texture->color().red() + + (texture->color().red() >> 1)); + if (xcol.red >= 0xff) xcol.red = 0xffff; + else xcol.red *= 0xff; + xcol.green = (unsigned int) (texture->color().green() + + (texture->color().green() >> 1)); + if (xcol.green >= 0xff) xcol.green = 0xffff; + else xcol.green *= 0xff; + xcol.blue = (unsigned int) (texture->color().blue() + + (texture->color().blue() >> 1)); + if (xcol.blue >= 0xff) xcol.blue = 0xffff; + else xcol.blue *= 0xff; - if (! XAllocColor(m_display, m_colormap, &xcol)) - xcol.pixel = 0; + if (! XAllocColor(m_display, m_colormap, &xcol)) + xcol.pixel = 0; - texture->hiColor().setPixel(xcol.pixel); + texture->hiColor().setPixel(xcol.pixel); - xcol.red = - (unsigned int) ((texture->color().red() >> 2) + - (texture->color().red() >> 1)) * 0xff; - xcol.green = - (unsigned int) ((texture->color().green() >> 2) + - (texture->color().green() >> 1)) * 0xff; - xcol.blue = - (unsigned int) ((texture->color().blue() >> 2) + - (texture->color().blue() >> 1)) * 0xff; + xcol.red = + (unsigned int) ((texture->color().red() >> 2) + + (texture->color().red() >> 1)) * 0xff; + xcol.green = + (unsigned int) ((texture->color().green() >> 2) + + (texture->color().green() >> 1)) * 0xff; + xcol.blue = + (unsigned int) ((texture->color().blue() >> 2) + + (texture->color().blue() >> 1)) * 0xff; - if (! XAllocColor(m_display, m_colormap, &xcol)) - xcol.pixel = 0; + if (! XAllocColor(m_display, m_colormap, &xcol)) + xcol.pixel = 0; - texture->loColor().setPixel(xcol.pixel); - } else if (texture->type() & FbTk::Texture::GRADIENT) { - int clen = strlen(rclass) + 10, nlen = strlen(rname) + 10; + texture->loColor().setPixel(xcol.pixel); + } else if (texture->type() & FbTk::Texture::GRADIENT) { + int clen = strlen(rclass) + 10, nlen = strlen(rname) + 10; - char *colorclass = new char[clen], *colorname = new char[nlen], - *colortoclass = new char[clen], *colortoname = new char[nlen]; + char *colorclass = new char[clen], *colorname = new char[nlen], + *colortoclass = new char[clen], *colortoname = new char[nlen]; - sprintf(colorclass, "%s.Color", rclass); - sprintf(colorname, "%s.color", rname); + sprintf(colorclass, "%s.Color", rclass); + sprintf(colorname, "%s.color", rname); - sprintf(colortoclass, "%s.ColorTo", rclass); - sprintf(colortoname, "%s.colorTo", rname); + sprintf(colortoclass, "%s.ColorTo", rclass); + sprintf(colortoname, "%s.colorTo", rname); - if (!readDatabaseColor(colorname, colorclass, &texture->color(), - default_pixel)) - retval = false; //report failure in loading + if (!readDatabaseColor(colorname, colorclass, &texture->color(), + default_pixel)) + retval = false; //report failure in loading - readDatabaseColor(colortoname, colortoclass, &texture->colorTo(), default_pixel); + readDatabaseColor(colortoname, colortoclass, &texture->colorTo(), default_pixel); - delete [] colorclass; - delete [] colorname; - delete [] colortoclass; - delete [] colortoname; - } + delete [] colorclass; + delete [] colorname; + delete [] colortoclass; + delete [] colortoname; + } - if (!retval) - cerr<<"Failed to load texture for: "<<rname<<endl; + if (!retval) + cerr<<"Failed to load texture for: "<<rname<<endl; - return retval; + return retval; } bool Theme::readDatabaseColor(char *rname, char *rclass, FbTk::Color *color, - unsigned long default_pixel) + unsigned long default_pixel) { - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (XrmGetResource(m_database, rname, rclass, &value_type, - &value)) { - color->setFromString(value.addr, m_screennum); - } else { - color->setPixel(default_pixel); - return false; - } + if (XrmGetResource(m_database, rname, rclass, &value_type, + &value)) { + color->setFromString(value.addr, m_screennum); + } else { + color->setPixel(default_pixel); + return false; + } - return true; + return true; } void Theme::readDatabaseFontSet(char *rname, char *rclass, XFontSet *fontset) { - if (! fontset) return; + if (! fontset) return; - static char *defaultFont = "fixed"; + static char *defaultFont = "fixed"; - bool load_default = false; - XrmValue value; - char *value_type; + bool load_default = false; + XrmValue value; + char *value_type; - if (*fontset) - XFreeFontSet(m_display, *fontset); + if (*fontset) + XFreeFontSet(m_display, *fontset); - if (XrmGetResource(m_database, rname, rclass, &value_type, &value)) { - char *fontname = value.addr; - if (! (*fontset = createFontSet(fontname))) - load_default = true; - } else - load_default = true; + if (XrmGetResource(m_database, rname, rclass, &value_type, &value)) { + char *fontname = value.addr; + if (! (*fontset = createFontSet(fontname))) + load_default = true; + } else + load_default = true; - if (load_default) { - *fontset = createFontSet(defaultFont); + if (load_default) { + *fontset = createFontSet(defaultFont); - if (! *fontset) { - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, - "BScreen::LoadStyle(): couldn't load default font.\n")); - throw 2; - } - } + if (! *fontset) { + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, + "BScreen::LoadStyle(): couldn't load default font.\n")); + throw 2; + } + } } void Theme::readDatabaseFont(char *rname, char *rclass, XFontStruct **font) { - if (! font) return; + if (! font) return; - static char *defaultFont = "fixed"; + static char *defaultFont = "fixed"; - bool load_default = false; - XrmValue value; - char *value_type; + bool load_default = false; + XrmValue value; + char *value_type; - if (*font) - XFreeFont(m_display, *font); + if (*font) + XFreeFont(m_display, *font); - if (XrmGetResource(m_database, rname, rclass, &value_type, &value)) { - #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<endl; - #endif - if ((*font = XLoadQueryFont(m_display, value.addr)) == 0) { - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenFontLoadFail, - "BScreen::LoadStyle(): couldn't load font '%s'\n"), - value.addr); + if (XrmGetResource(m_database, rname, rclass, &value_type, &value)) { +#ifdef DEBUG + cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<endl; +#endif + if ((*font = XLoadQueryFont(m_display, value.addr)) == 0) { + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenFontLoadFail, + "BScreen::LoadStyle(): couldn't load font '%s'\n"), + value.addr); - load_default = true; - } - } else - load_default = true; + load_default = true; + } + } else + load_default = true; - if (load_default) { - if ((*font = XLoadQueryFont(m_display, defaultFont)) == 0) { - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, - "BScreen::LoadStyle(): couldn't load default font.\n")); - throw 2; //fatal! - } - } + if (load_default) { + if ((*font = XLoadQueryFont(m_display, defaultFont)) == 0) { + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, + "BScreen::LoadStyle(): couldn't load default font.\n")); + throw 2; //fatal! + } + } } void Theme::reconfigure(bool antialias) { - XGCValues gcv; - unsigned long gc_value_mask = GCForeground; + XGCValues gcv; + unsigned long gc_value_mask = GCForeground; - XChangeGC(m_display, m_opgc, - GCForeground | GCFunction | GCSubwindowMode, &gcv); + XChangeGC(m_display, m_opgc, + GCForeground | GCFunction | GCSubwindowMode, &gcv); - gcv.foreground = WhitePixel(m_display, m_screennum); - gcv.function = GXinvert; - gcv.subwindow_mode = IncludeInferiors; - XChangeGC(m_display, m_opgc, - GCForeground | GCFunction | GCSubwindowMode, &gcv); + gcv.foreground = WhitePixel(m_display, m_screennum); + gcv.function = GXinvert; + gcv.subwindow_mode = IncludeInferiors; + XChangeGC(m_display, m_opgc, + GCForeground | GCFunction | GCSubwindowMode, &gcv); - gcv.foreground = m_windowstyle.l_text_focus.pixel(); - if (m_windowstyle.font.isAntialias() != antialias) - m_windowstyle.font.setAntialias(antialias); + gcv.foreground = m_windowstyle.l_text_focus.pixel(); + if (m_windowstyle.font.isAntialias() != antialias) + m_windowstyle.font.setAntialias(antialias); - XChangeGC(m_display, m_windowstyle.l_text_focus_gc, - gc_value_mask, &gcv); + XChangeGC(m_display, m_windowstyle.l_text_focus_gc, + gc_value_mask, &gcv); - gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); - XChangeGC(m_display, m_windowstyle.l_text_unfocus_gc, - gc_value_mask, &gcv); + gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); + XChangeGC(m_display, m_windowstyle.l_text_unfocus_gc, + gc_value_mask, &gcv); - //---- Tab - gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); - if (m_windowstyle.tab.font.isAntialias() != antialias) - m_windowstyle.tab.font.setAntialias(antialias); - XChangeGC(m_display, m_windowstyle.tab.l_text_focus_gc, - gc_value_mask, &gcv); + //---- Tab + gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); + if (m_windowstyle.tab.font.isAntialias() != antialias) + m_windowstyle.tab.font.setAntialias(antialias); + XChangeGC(m_display, m_windowstyle.tab.l_text_focus_gc, + gc_value_mask, &gcv); - gcv.foreground = m_windowstyle.tab.l_text_unfocus.pixel(); - XChangeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc, - gc_value_mask, &gcv); + gcv.foreground = m_windowstyle.tab.l_text_unfocus.pixel(); + XChangeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc, + gc_value_mask, &gcv); - //--- end tab + //--- end tab - gcv.foreground = m_windowstyle.b_pic_focus.pixel(); - XChangeGC(m_display, m_windowstyle.b_pic_focus_gc, - GCForeground, &gcv); + gcv.foreground = m_windowstyle.b_pic_focus.pixel(); + XChangeGC(m_display, m_windowstyle.b_pic_focus_gc, + GCForeground, &gcv); - gcv.foreground = m_windowstyle.b_pic_unfocus.pixel(); - XChangeGC(m_display, m_windowstyle.b_pic_unfocus_gc, - GCForeground, &gcv); + gcv.foreground = m_windowstyle.b_pic_unfocus.pixel(); + XChangeGC(m_display, m_windowstyle.b_pic_unfocus_gc, + GCForeground, &gcv); - gcv.foreground = m_menustyle.t_text.pixel(); - if (m_menustyle.titlefont.isAntialias() != antialias) - m_menustyle.titlefont.setAntialias(antialias); + gcv.foreground = m_menustyle.t_text.pixel(); + if (m_menustyle.titlefont.isAntialias() != antialias) + m_menustyle.titlefont.setAntialias(antialias); - XChangeGC(m_display, m_menustyle.t_text_gc, - gc_value_mask|GCForeground, &gcv); + XChangeGC(m_display, m_menustyle.t_text_gc, + gc_value_mask|GCForeground, &gcv); - gcv.foreground = m_menustyle.f_text.pixel(); - if (m_menustyle.framefont.isAntialias() != antialias) - m_menustyle.framefont.setAntialias(antialias); + gcv.foreground = m_menustyle.f_text.pixel(); + if (m_menustyle.framefont.isAntialias() != antialias) + m_menustyle.framefont.setAntialias(antialias); - XChangeGC(m_display, m_menustyle.f_text_gc, - gc_value_mask, &gcv); + XChangeGC(m_display, m_menustyle.f_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.h_text.pixel(); - XChangeGC(m_display, m_menustyle.h_text_gc, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.h_text.pixel(); + XChangeGC(m_display, m_menustyle.h_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.d_text.pixel(); - XChangeGC(m_display, m_menustyle.d_text_gc, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.d_text.pixel(); + XChangeGC(m_display, m_menustyle.d_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_menustyle.hilite.color().pixel(); - XChangeGC(m_display, m_menustyle.hilite_gc, - gc_value_mask, &gcv); + gcv.foreground = m_menustyle.hilite.color().pixel(); + XChangeGC(m_display, m_menustyle.hilite_gc, + gc_value_mask, &gcv); - // set antialias ? - if (m_toolbarstyle.font.isAntialias() != antialias) - m_toolbarstyle.font.setAntialias(antialias); + // set antialias ? + if (m_toolbarstyle.font.isAntialias() != antialias) + m_toolbarstyle.font.setAntialias(antialias); - gcv.foreground = m_toolbarstyle.l_text.pixel(); - XChangeGC(m_display, m_toolbarstyle.l_text_gc, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.l_text.pixel(); + XChangeGC(m_display, m_toolbarstyle.l_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.w_text.pixel(); - XChangeGC(m_display, m_toolbarstyle.w_text_gc, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.w_text.pixel(); + XChangeGC(m_display, m_toolbarstyle.w_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.c_text.pixel(); - XChangeGC(m_display, m_toolbarstyle.c_text_gc, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.c_text.pixel(); + XChangeGC(m_display, m_toolbarstyle.c_text_gc, + gc_value_mask, &gcv); - gcv.foreground = m_toolbarstyle.b_pic.pixel(); - XChangeGC(m_display, m_toolbarstyle.b_pic_gc, - gc_value_mask, &gcv); + gcv.foreground = m_toolbarstyle.b_pic.pixel(); + XChangeGC(m_display, m_toolbarstyle.b_pic_gc, + gc_value_mask, &gcv); } XFontSet Theme::createFontSet(char *fontname) { - XFontSet fs; - const int FONT_ELEMENT_SIZE=50; - char **missing, *def = "-"; - int nmissing, pixel_size = 0, buf_size = 0; - char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; + XFontSet fs; + const int FONT_ELEMENT_SIZE=50; + char **missing, *def = "-"; + int nmissing, pixel_size = 0, buf_size = 0; + char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; - fs = XCreateFontSet(m_display, - fontname, &missing, &nmissing, &def); - if (fs && (! nmissing)) return fs; + fs = XCreateFontSet(m_display, + fontname, &missing, &nmissing, &def); + if (fs && (! nmissing)) return fs; #ifdef HAVE_SETLOCALE - if (! fs) { - if (nmissing) XFreeStringList(missing); + if (! fs) { + if (nmissing) XFreeStringList(missing); - setlocale(LC_CTYPE, "C"); - fs = XCreateFontSet(m_display, fontname, - &missing, &nmissing, &def); - setlocale(LC_CTYPE, ""); - } + setlocale(LC_CTYPE, "C"); + fs = XCreateFontSet(m_display, fontname, + &missing, &nmissing, &def); + setlocale(LC_CTYPE, ""); + } #endif // HAVE_SETLOCALE - if (fs) { - XFontStruct **fontstructs; - char **fontnames; - XFontsOfFontSet(fs, &fontstructs, &fontnames); - fontname = fontnames[0]; - } + if (fs) { + XFontStruct **fontstructs; + char **fontnames; + XFontsOfFontSet(fs, &fontstructs, &fontnames); + fontname = fontnames[0]; + } - getFontElement(fontname, weight, FONT_ELEMENT_SIZE, - "-medium-", "-bold-", "-demibold-", "-regular-", 0); - getFontElement(fontname, slant, FONT_ELEMENT_SIZE, - "-r-", "-i-", "-o-", "-ri-", "-ro-", 0); - getFontSize(fontname, &pixel_size); + getFontElement(fontname, weight, FONT_ELEMENT_SIZE, + "-medium-", "-bold-", "-demibold-", "-regular-", 0); + getFontElement(fontname, slant, FONT_ELEMENT_SIZE, + "-r-", "-i-", "-o-", "-ri-", "-ro-", 0); + getFontSize(fontname, &pixel_size); - if (! strcmp(weight, "*")) - strncpy(weight, "medium", FONT_ELEMENT_SIZE); - if (! strcmp(slant, "*")) - strncpy(slant, "r", FONT_ELEMENT_SIZE); - if (pixel_size < 3) - pixel_size = 3; - else if (pixel_size > 97) - pixel_size = 97; + if (! strcmp(weight, "*")) + strncpy(weight, "medium", FONT_ELEMENT_SIZE); + if (! strcmp(slant, "*")) + strncpy(slant, "r", FONT_ELEMENT_SIZE); + if (pixel_size < 3) + pixel_size = 3; + else if (pixel_size > 97) + pixel_size = 97; - buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64; - char *pattern2 = new char[buf_size]; - snprintf(pattern2, buf_size - 1, - "%s," - "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*," - "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*", - fontname, weight, slant, pixel_size, pixel_size); - fontname = pattern2; + buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64; + char *pattern2 = new char[buf_size]; + snprintf(pattern2, buf_size - 1, + "%s," + "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*," + "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*", + fontname, weight, slant, pixel_size, pixel_size); + fontname = pattern2; - if (nmissing) - XFreeStringList(missing); - if (fs) - XFreeFontSet(m_display, fs); + if (nmissing) + XFreeStringList(missing); + if (fs) + XFreeFontSet(m_display, fs); - fs = XCreateFontSet(m_display, fontname, - &missing, &nmissing, &def); - delete [] pattern2; + fs = XCreateFontSet(m_display, fontname, + &missing, &nmissing, &def); + delete [] pattern2; - return fs; + return fs; } const char *Theme::getFontSize(const char *pattern, int *size) { - const char *p; - const char *p2=0; - int n=0; + const char *p; + const char *p2=0; + int n=0; - for (p=pattern; 1; p++) { - if (!*p) { - if (p2!=0 && n>1 && n<72) { - *size = n; return p2+1; - } else { - *size = 16; return 0; - } - } else if (*p=='-') { - if (n>1 && n<72 && p2!=0) { - *size = n; - return p2+1; - } - p2=p; n=0; - } else if (*p>='0' && *p<='9' && p2!=0) { - n *= 10; - n += *p-'0'; - } else { - p2=0; n=0; - } - } + for (p=pattern; 1; p++) { + if (!*p) { + if (p2!=0 && n>1 && n<72) { + *size = n; return p2+1; + } else { + *size = 16; return 0; + } + } else if (*p=='-') { + if (n>1 && n<72 && p2!=0) { + *size = n; + return p2+1; + } + p2=p; n=0; + } else if (*p>='0' && *p<='9' && p2!=0) { + n *= 10; + n += *p-'0'; + } else { + p2=0; n=0; + } + } } const char *Theme::getFontElement(const char *pattern, char *buf, int bufsiz, ...) { - const char *p, *v; - char *p2; - va_list va; + const char *p, *v; + char *p2; + va_list va; - va_start(va, bufsiz); - buf[bufsiz-1] = 0; - buf[bufsiz-2] = '*'; - while((v = va_arg(va, char *)) != 0) { - p = StringUtil::strcasestr(pattern, v); - if (p) { - strncpy(buf, p+1, bufsiz-2); - p2 = strchr(buf, '-'); - if (p2) *p2=0; - va_end(va); - return p; - } - } - va_end(va); - strncpy(buf, "*", bufsiz); - return 0; + va_start(va, bufsiz); + buf[bufsiz-1] = 0; + buf[bufsiz-2] = '*'; + while((v = va_arg(va, char *)) != 0) { + p = StringUtil::strcasestr(pattern, v); + if (p) { + strncpy(buf, p+1, bufsiz-2); + p2 = strchr(buf, '-'); + if (p2) *p2=0; + va_end(va); + return p; + } + } + va_end(va); + strncpy(buf, "*", bufsiz); + return 0; } void Theme::loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname) { - assert(name); - assert(altname); + assert(name); + assert(altname); - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (XrmGetResource(m_database, name, altname, &value_type, &value)) { + if (XrmGetResource(m_database, name, altname, &value_type, &value)) { #ifdef DEBUG - std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl; + std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl; #endif // DEBUG - if (!dest.load(value.addr)) - cerr<<"Failed to load font: "<<value.addr<<endl; - } + if (!dest.load(value.addr)) + cerr<<"Failed to load font: "<<value.addr<<endl; + } }
M src/Theme.hhsrc/Theme.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Theme.hh,v 1.20 2002/11/30 20:57:35 fluxgen Exp $ +// $Id: Theme.hh,v 1.21 2002/12/01 13:42:00 rathnor Exp $ #ifndef THEME_HH #define THEME_HH

@@ -44,113 +44,113 @@ */

class Theme { public: - Theme(Display *display, Window rootwindow, Colormap colormap, - int screennum, const char *filename, const char *rootcommand); - ~Theme(); + Theme(Display *display, Window rootwindow, Colormap colormap, + int screennum, const char *filename, const char *rootcommand); + ~Theme(); - typedef struct MenuStyle { - MenuStyle():titlefont("fixed"), - framefont("fixed") { } - FbTk::Color t_text, f_text, h_text, d_text; - FbTk::Texture title, frame, hilite; - GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; - FbTk::Font titlefont, framefont; - DrawUtil::Font::FontJustify framefont_justify; - DrawUtil::Font::FontJustify titlefont_justify; - int bullet, bullet_pos; - } MenuStyle; + typedef struct MenuStyle { + MenuStyle():titlefont("fixed"), + framefont("fixed") { } + FbTk::Color t_text, f_text, h_text, d_text; + FbTk::Texture title, frame, hilite; + GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; + FbTk::Font titlefont, framefont; + DrawUtil::Font::FontJustify framefont_justify; + DrawUtil::Font::FontJustify titlefont_justify; + int bullet, bullet_pos; + } MenuStyle; - typedef struct LabelStyle { - LabelStyle(const char *fontname="fixed"):font(fontname) { } + typedef struct LabelStyle { + LabelStyle(const char *fontname="fixed"):font(fontname) { } - FbTk::Texture l_focus, l_unfocus, - t_focus, t_unfocus; - GC l_text_focus_gc, l_text_unfocus_gc; - FbTk::Font font; - DrawUtil::Font::FontJustify justify; - FbTk::Color l_text_focus, l_text_unfocus; - } LabelStyle; + FbTk::Texture l_focus, l_unfocus, + t_focus, t_unfocus; + GC l_text_focus_gc, l_text_unfocus_gc; + FbTk::Font font; + DrawUtil::Font::FontJustify justify; + FbTk::Color l_text_focus, l_text_unfocus; + } LabelStyle; - typedef struct WindowStyle:public LabelStyle { - FbTk::Color f_focus, f_unfocus, b_pic_focus, - b_pic_unfocus; - FbTk::Texture h_focus, h_unfocus, - b_focus, b_unfocus, b_pressed, g_focus, g_unfocus; - GC b_pic_focus_gc, b_pic_unfocus_gc; + typedef struct WindowStyle:public LabelStyle { + FbTk::Color f_focus, f_unfocus, b_pic_focus, + b_pic_unfocus; + FbTk::Texture h_focus, h_unfocus, + b_focus, b_unfocus, b_pressed, g_focus, g_unfocus; + GC b_pic_focus_gc, b_pic_unfocus_gc; - struct t_tab:public LabelStyle { - FbTk::Color border_color; - unsigned int border_width; - unsigned int border_width_2x; - } tab; + struct t_tab:public LabelStyle { + FbTk::Color border_color; + unsigned int border_width; + unsigned int border_width_2x; + } tab; - } WindowStyle; + } WindowStyle; - typedef struct ToolbarStyle { - ToolbarStyle():font("fixed") { } // default font 'fixed' - FbTk::Color l_text, w_text, c_text, b_pic; - FbTk::Texture toolbar, label, window, button, pressed, clock; - GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc; - FbTk::Font font; - DrawUtil::Font::FontJustify justify; - } ToolbarStyle; + typedef struct ToolbarStyle { + ToolbarStyle():font("fixed") { } // default font 'fixed' + FbTk::Color l_text, w_text, c_text, b_pic; + FbTk::Texture toolbar, label, window, button, pressed, clock; + GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc; + FbTk::Font font; + DrawUtil::Font::FontJustify justify; + } ToolbarStyle; - inline WindowStyle &getWindowStyle() { return m_windowstyle; } - inline MenuStyle &getMenuStyle() { return m_menustyle; } - inline ToolbarStyle &getToolbarStyle() { return m_toolbarstyle; } - inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; } - inline unsigned int getBevelWidth() const { return m_bevel_width; } - inline unsigned int getBorderWidth() const { return m_border_width; } - inline unsigned int getHandleWidth() const { return m_handle_width; } - inline unsigned int getFrameWidth() const { return m_frame_width; } - inline GC getOpGC() const { return m_opgc; } - inline const FbTk::Color &getBorderColor() const { return m_border_color; } - void load(const char *filename); - void reconfigure(bool antialias = false); + inline WindowStyle &getWindowStyle() { return m_windowstyle; } + inline MenuStyle &getMenuStyle() { return m_menustyle; } + inline ToolbarStyle &getToolbarStyle() { return m_toolbarstyle; } + inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; } + inline unsigned int getBevelWidth() const { return m_bevel_width; } + inline unsigned int getBorderWidth() const { return m_border_width; } + inline unsigned int getHandleWidth() const { return m_handle_width; } + inline unsigned int getFrameWidth() const { return m_frame_width; } + inline GC getOpGC() const { return m_opgc; } + inline const FbTk::Color &getBorderColor() const { return m_border_color; } + void load(const char *filename); + void reconfigure(bool antialias = false); - inline void setRootCommand(const std::string &command) { m_rootcommand = command; } + inline void setRootCommand(const std::string &command) { m_rootcommand = command; } private: - void loadMenuStyle(); - void loadWindowStyle(); - void loadTabStyle(); - void loadToolbarStyle(); - void loadRootCommand(); - void loadMisc(); - void freeMenuStyle(); - void freeWindowStyle(); - void freeTabStyle(); - void freeToolbarStyle(); - void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname); - bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long); - bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long); + void loadMenuStyle(); + void loadWindowStyle(); + void loadTabStyle(); + void loadToolbarStyle(); + void loadRootCommand(); + void loadMisc(); + void freeMenuStyle(); + void freeWindowStyle(); + void freeTabStyle(); + void freeToolbarStyle(); + void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname); + bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long); + bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long); - void readDatabaseFontSet(char *, char *, XFontSet *); - XFontSet createFontSet(char *); - void readDatabaseFont(char *, char *, XFontStruct **); + void readDatabaseFontSet(char *, char *, XFontSet *); + XFontSet createFontSet(char *); + void readDatabaseFont(char *, char *, XFontStruct **); - static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...); - static const char *getFontSize(const char *pattern, int *size); + static const char *getFontElement(const char *pattern, char *buf, int bufsiz, ...); + static const char *getFontSize(const char *pattern, int *size); - WindowStyle m_windowstyle; - MenuStyle m_menustyle; - ToolbarStyle m_toolbarstyle; - unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; - FbTk::Color m_border_color; - GC m_opgc; - Display *m_display; - XrmDatabase m_database; - Colormap m_colormap; - int m_screennum; - std::string m_rootcommand; - FbTk::Texture m_slit_texture; + WindowStyle m_windowstyle; + MenuStyle m_menustyle; + ToolbarStyle m_toolbarstyle; + unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; + FbTk::Color m_border_color; + GC m_opgc; + Display *m_display; + XrmDatabase m_database; + Colormap m_colormap; + int m_screennum; + std::string m_rootcommand; + FbTk::Texture m_slit_texture; };
M src/Timer.ccsrc/Timer.cc

@@ -39,139 +39,139 @@ //static var

BTimer::TimerList BTimer::m_timerlist; BTimer::BTimer(TimeoutHandler *h): -m_handler(h), -m_timing(false), -m_once(false) { + m_handler(h), + m_timing(false), + m_once(false) { } BTimer::~BTimer() { - if (isTiming()) stop(); + if (isTiming()) stop(); } void BTimer::setTimeout(long t) { - m_timeout.tv_sec = t / 1000; - m_timeout.tv_usec = t; - m_timeout.tv_usec -= (m_timeout.tv_sec * 1000); - m_timeout.tv_usec *= 1000; + m_timeout.tv_sec = t / 1000; + m_timeout.tv_usec = t; + m_timeout.tv_usec -= (m_timeout.tv_sec * 1000); + m_timeout.tv_usec *= 1000; } void BTimer::setTimeout(timeval t) { - m_timeout.tv_sec = t.tv_sec; - m_timeout.tv_usec = t.tv_usec; + m_timeout.tv_sec = t.tv_sec; + m_timeout.tv_usec = t.tv_usec; } void BTimer::start() { - gettimeofday(&m_start, 0); + gettimeofday(&m_start, 0); - if (! m_timing) { - m_timing = true; - addTimer(this); //add us to the list - } + if (! m_timing) { + m_timing = true; + addTimer(this); //add us to the list + } } void BTimer::stop() { - m_timing = false; - removeTimer(this); //remove us from the list + m_timing = false; + removeTimer(this); //remove us from the list } void BTimer::fireTimeout() { - if (m_handler) m_handler->timeout(); + if (m_handler) m_handler->timeout(); } void BTimer::updateTimers(int fd) { - fd_set rfds; - timeval now, tm, *timeout = 0; + fd_set rfds; + timeval now, tm, *timeout = 0; - FD_ZERO(&rfds); - FD_SET(fd, &rfds); + FD_ZERO(&rfds); + FD_SET(fd, &rfds); - if (m_timerlist.size() > 0) { - gettimeofday(&now, 0); + if (m_timerlist.size() > 0) { + gettimeofday(&now, 0); - tm.tv_sec = tm.tv_usec = 0l; + tm.tv_sec = tm.tv_usec = 0l; - BTimer *timer = m_timerlist.front(); + BTimer *timer = m_timerlist.front(); - tm.tv_sec = timer->getStartTime().tv_sec + - timer->getTimeout().tv_sec - now.tv_sec; - tm.tv_usec = timer->getStartTime().tv_usec + - timer->getTimeout().tv_usec - now.tv_usec; + tm.tv_sec = timer->getStartTime().tv_sec + + timer->getTimeout().tv_sec - now.tv_sec; + tm.tv_usec = timer->getStartTime().tv_usec + + timer->getTimeout().tv_usec - now.tv_usec; - while (tm.tv_usec >= 1000000) { - tm.tv_sec++; - tm.tv_usec -= 1000000; - } + while (tm.tv_usec >= 1000000) { + tm.tv_sec++; + tm.tv_usec -= 1000000; + } - while (tm.tv_usec < 0) { - if (tm.tv_sec > 0) { - tm.tv_sec--; - tm.tv_usec += 1000000; - } else { - tm.tv_usec = 0; - break; - } - } + while (tm.tv_usec < 0) { + if (tm.tv_sec > 0) { + tm.tv_sec--; + tm.tv_usec += 1000000; + } else { + tm.tv_usec = 0; + break; + } + } - timeout = &tm; - } + timeout = &tm; + } - select(fd + 1, &rfds, 0, 0, timeout); + select(fd + 1, &rfds, 0, 0, timeout); - // check for timer timeout - gettimeofday(&now, 0); + // check for timer timeout + gettimeofday(&now, 0); - TimerList::iterator it = m_timerlist.begin(); - //must check end ...the timer might remove - //it self from the list (should be fixed in the future) - for(; it != m_timerlist.end(); ++it) { - //This is to make sure we don't get an invalid iterator - //when we do fireTimeout - BTimer &t = *(*it); - tm.tv_sec = t.getStartTime().tv_sec + - t.getTimeout().tv_sec; - tm.tv_usec = t.getStartTime().tv_usec + - t.getTimeout().tv_usec; + TimerList::iterator it = m_timerlist.begin(); + //must check end ...the timer might remove + //it self from the list (should be fixed in the future) + for(; it != m_timerlist.end(); ++it) { + //This is to make sure we don't get an invalid iterator + //when we do fireTimeout + BTimer &t = *(*it); + tm.tv_sec = t.getStartTime().tv_sec + + t.getTimeout().tv_sec; + tm.tv_usec = t.getStartTime().tv_usec + + t.getTimeout().tv_usec; - if ((now.tv_sec < tm.tv_sec) || - (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) - break; + if ((now.tv_sec < tm.tv_sec) || + (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) + break; - t.fireTimeout(); - // restart the current timer so that the start time is updated - if (! t.doOnce()) - t.start(); - else { - t.stop(); - it--; - } - } + t.fireTimeout(); + // restart the current timer so that the start time is updated + if (! t.doOnce()) + t.start(); + else { + t.stop(); + it--; + } + } } void BTimer::addTimer(BTimer *timer) { - assert(timer); + assert(timer); - TimerList::iterator it = m_timerlist.begin(); - TimerList::iterator it_end = m_timerlist.end(); - int index = 0; - for (; it != it_end; ++it, ++index) { - if (((*it)->getTimeout().tv_sec > timer->getTimeout().tv_sec) || - (((*it)->getTimeout().tv_sec == timer->getTimeout().tv_sec) && - ((*it)->getTimeout().tv_usec >= timer->getTimeout().tv_usec))) { - break; - } - } - m_timerlist.insert(it, timer); + TimerList::iterator it = m_timerlist.begin(); + TimerList::iterator it_end = m_timerlist.end(); + int index = 0; + for (; it != it_end; ++it, ++index) { + if (((*it)->getTimeout().tv_sec > timer->getTimeout().tv_sec) || + (((*it)->getTimeout().tv_sec == timer->getTimeout().tv_sec) && + ((*it)->getTimeout().tv_usec >= timer->getTimeout().tv_usec))) { + break; + } + } + m_timerlist.insert(it, timer); } void BTimer::removeTimer(BTimer *timer) { - assert(timer); - m_timerlist.remove(timer); + assert(timer); + m_timerlist.remove(timer); }
M src/Timer.hhsrc/Timer.hh

@@ -34,8 +34,8 @@ timeout function when the time is out

*/ class TimeoutHandler { public: - /// called when the time is out - virtual void timeout() = 0; + /// called when the time is out + virtual void timeout() = 0; }; /**

@@ -43,47 +43,47 @@ Handles TimeoutHandles

*/ class BTimer { public: - explicit BTimer(TimeoutHandler *handler); - virtual ~BTimer(); + explicit BTimer(TimeoutHandler *handler); + virtual ~BTimer(); - inline int isTiming() const { return m_timing; } - inline int doOnce() const { return m_once; } + inline int isTiming() const { return m_timing; } + inline int doOnce() const { return m_once; } - inline const timeval &getTimeout() const { return m_timeout; } - inline const timeval &getStartTime() const { return m_start; } + inline const timeval &getTimeout() const { return m_timeout; } + inline const timeval &getStartTime() const { return m_start; } - inline void fireOnce(bool once) { m_once = once; } - /// set timeout - void setTimeout(long val); - /// set timeout - void setTimeout(timeval val); - /// start timing - void start(); - /// stop timing - void stop(); - /// update all timers - static void updateTimers(int file_descriptor); + inline void fireOnce(bool once) { m_once = once; } + /// set timeout + void setTimeout(long val); + /// set timeout + void setTimeout(timeval val); + /// start timing + void start(); + /// stop timing + void stop(); + /// update all timers + static void updateTimers(int file_descriptor); protected: - /// force a timeout - void fireTimeout(); + /// force a timeout + void fireTimeout(); private: - /// add a timer to the static list - static void addTimer(BTimer *timer); - /// remove a timer from the static list - static void removeTimer(BTimer *timer); + /// add a timer to the static list + static void addTimer(BTimer *timer); + /// remove a timer from the static list + static void removeTimer(BTimer *timer); - typedef std::list<BTimer *> TimerList; + typedef std::list<BTimer *> TimerList; static TimerList m_timerlist; ///< list of all timers - TimeoutHandler *m_handler; ///< handler + TimeoutHandler *m_handler; ///< handler - bool m_timing; ///< clock running? - bool m_once; ///< do timeout only once? + bool m_timing; ///< clock running? + bool m_once; ///< do timeout only once? - timeval m_start; ///< start time - timeval m_timeout; ///< time length + timeval m_start; ///< start time + timeval m_timeout; ///< time length };
M src/Toolbar.ccsrc/Toolbar.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Toolbar.cc,v 1.44 2002/11/30 20:29:27 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.45 2002/12/01 13:42:01 rathnor Exp $ #include "Toolbar.hh"

@@ -68,1051 +68,1051 @@

using namespace std; Toolbar::Toolbar(BScreen *scrn): -on_top(scrn->isToolbarOnTop()), -editing(false), -hidden(scrn->doToolbarAutoHide()), -do_auto_hide(scrn->doToolbarAutoHide()), -m_screen(scrn), -image_ctrl(scrn->getImageControl()), -clock_timer(this), // get the clock updating every minute -hide_timer(&hide_handler), -m_toolbarmenu(*this) { - timeval delay; - delay.tv_sec = 1; - delay.tv_usec = 0; - clock_timer.setTimeout(delay); - clock_timer.start(); + on_top(scrn->isToolbarOnTop()), + editing(false), + hidden(scrn->doToolbarAutoHide()), + do_auto_hide(scrn->doToolbarAutoHide()), + m_screen(scrn), + image_ctrl(scrn->getImageControl()), + clock_timer(this), // get the clock updating every minute + hide_timer(&hide_handler), + m_toolbarmenu(*this) { + timeval delay; + delay.tv_sec = 1; + delay.tv_usec = 0; + clock_timer.setTimeout(delay); + clock_timer.start(); - hide_handler.toolbar = this; - hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); - hide_timer.fireOnce(true); + hide_handler.toolbar = this; + hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); + hide_timer.fireOnce(true); - frame.grab_x = frame.grab_y = 0; + frame.grab_x = frame.grab_y = 0; - display = BaseDisplay::getXDisplay(); - XSetWindowAttributes attrib; - unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; + display = BaseDisplay::getXDisplay(); + XSetWindowAttributes attrib; + unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | + CWColormap | CWOverrideRedirect | CWEventMask; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - m_screen->getBorderColor()->pixel(); - attrib.colormap = m_screen->colormap(); - attrib.override_redirect = true; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask; + attrib.background_pixmap = None; + attrib.background_pixel = attrib.border_pixel = + m_screen->getBorderColor()->pixel(); + attrib.colormap = m_screen->colormap(); + attrib.override_redirect = true; + attrib.event_mask = ButtonPressMask | ButtonReleaseMask | + EnterWindowMask | LeaveWindowMask; - Fluxbox * const fluxbox = Fluxbox::instance(); - int depth = m_screen->getDepth(); - Visual *vis = m_screen->getVisual(); - frame.window = - XCreateWindow(display, m_screen->getRootWindow(), 0, 0, 1, 1, 0, - depth, InputOutput, vis, - create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.window, this); + Fluxbox * const fluxbox = Fluxbox::instance(); + int depth = m_screen->getDepth(); + Visual *vis = m_screen->getVisual(); + frame.window = + XCreateWindow(display, m_screen->getRootWindow(), 0, 0, 1, 1, 0, + depth, InputOutput, vis, + create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.window, this); - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | - KeyPressMask | EnterWindowMask; + attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | + KeyPressMask | EnterWindowMask; - frame.workspace_label = - XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.workspace_label, this); + frame.workspace_label = + XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.workspace_label, this); - frame.window_label = - XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.window_label, this); + frame.window_label = + XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.window_label, this); - frame.clock = - XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.clock, this); + frame.clock = + XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.clock, this); - frame.psbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.psbutton, this); + frame.psbutton = + XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.psbutton, this); - frame.nsbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.nsbutton, this); + frame.nsbutton = + XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.nsbutton, this); - frame.pwbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.pwbutton, this); + frame.pwbutton = + XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.pwbutton, this); - frame.nwbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, - InputOutput, vis, create_mask, &attrib); - fluxbox->saveToolbarSearch(frame.nwbutton, this); + frame.nwbutton = + XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, depth, + InputOutput, vis, create_mask, &attrib); + fluxbox->saveToolbarSearch(frame.nwbutton, this); - frame.base = frame.label = frame.wlabel = frame.clk = frame.button = - frame.pbutton = None; + frame.base = frame.label = frame.wlabel = frame.clk = frame.button = + frame.pbutton = None; - if (Fluxbox::instance()->useIconBar()) - m_iconbar.reset(new IconBar(screen(), frame.window_label)); + if (Fluxbox::instance()->useIconBar()) + m_iconbar.reset(new IconBar(screen(), frame.window_label)); - XMapSubwindows(display, frame.window); - XMapWindow(display, frame.window); + XMapSubwindows(display, frame.window); + XMapWindow(display, frame.window); - reconfigure(); + reconfigure(); } Toolbar::~Toolbar() { - XUnmapWindow(display, frame.window); + XUnmapWindow(display, frame.window); - if (frame.base) image_ctrl->removeImage(frame.base); - if (frame.label) image_ctrl->removeImage(frame.label); - if (frame.wlabel) image_ctrl->removeImage(frame.wlabel); - if (frame.clk) image_ctrl->removeImage(frame.clk); - if (frame.button) image_ctrl->removeImage(frame.button); - if (frame.pbutton) image_ctrl->removeImage(frame.pbutton); + if (frame.base) image_ctrl->removeImage(frame.base); + if (frame.label) image_ctrl->removeImage(frame.label); + if (frame.wlabel) image_ctrl->removeImage(frame.wlabel); + if (frame.clk) image_ctrl->removeImage(frame.clk); + if (frame.button) image_ctrl->removeImage(frame.button); + if (frame.pbutton) image_ctrl->removeImage(frame.pbutton); - Fluxbox * const fluxbox = Fluxbox::instance(); - fluxbox->removeToolbarSearch(frame.window); + Fluxbox * const fluxbox = Fluxbox::instance(); + fluxbox->removeToolbarSearch(frame.window); - fluxbox->removeToolbarSearch(frame.workspace_label); - fluxbox->removeToolbarSearch(frame.window_label); - fluxbox->removeToolbarSearch(frame.clock); - fluxbox->removeToolbarSearch(frame.psbutton); - fluxbox->removeToolbarSearch(frame.nsbutton); - fluxbox->removeToolbarSearch(frame.pwbutton); - fluxbox->removeToolbarSearch(frame.nwbutton); + fluxbox->removeToolbarSearch(frame.workspace_label); + fluxbox->removeToolbarSearch(frame.window_label); + fluxbox->removeToolbarSearch(frame.clock); + fluxbox->removeToolbarSearch(frame.psbutton); + fluxbox->removeToolbarSearch(frame.nsbutton); + fluxbox->removeToolbarSearch(frame.pwbutton); + fluxbox->removeToolbarSearch(frame.nwbutton); - XDestroyWindow(display, frame.workspace_label); - XDestroyWindow(display, frame.window_label); - XDestroyWindow(display, frame.clock); + XDestroyWindow(display, frame.workspace_label); + XDestroyWindow(display, frame.window_label); + XDestroyWindow(display, frame.clock); - XDestroyWindow(display, frame.window); + XDestroyWindow(display, frame.window); } void Toolbar::addIcon(FluxboxWindow *w) { - if (m_iconbar.get() != 0) - Fluxbox::instance()->saveToolbarSearch(m_iconbar->addIcon(w), this); + if (m_iconbar.get() != 0) + Fluxbox::instance()->saveToolbarSearch(m_iconbar->addIcon(w), this); } void Toolbar::delIcon(FluxboxWindow *w) { - if (m_iconbar.get() != 0) - Fluxbox::instance()->removeToolbarSearch(m_iconbar->delIcon(w)); + if (m_iconbar.get() != 0) + Fluxbox::instance()->removeToolbarSearch(m_iconbar->delIcon(w)); } void Toolbar::reconfigure() { - int head_x = 0, - head_y = 0, - head_w, - head_h; + int head_x = 0, + head_y = 0, + head_w, + head_h; - frame.bevel_w = screen()->getBevelWidth(); + frame.bevel_w = screen()->getBevelWidth(); #ifdef XINERAMA - int head = (screen->hasXinerama()) - ? screen->getToolbarOnHead() - : -1; + int head = (screen->hasXinerama()) + ? screen->getToolbarOnHead() + : -1; - if (head >= 0) { // toolbar on head nr, if -1 then over ALL heads - head_x = screen()->getHeadX(head); - head_y = screen()->getHeadY(head); - head_w = screen()->getHeadWidth(head); - head_h = screen()->getHeadHeight(head); + if (head >= 0) { // toolbar on head nr, if -1 then over ALL heads + head_x = screen()->getHeadX(head); + head_y = screen()->getHeadY(head); + head_w = screen()->getHeadWidth(head); + head_h = screen()->getHeadHeight(head); - frame.width = - (screen()->getHeadWidth(head) * screen()->getToolbarWidthPercent() / 100); - } else { - head_w = screen->getWidth(); - head_h = screen->getHeight(); + frame.width = + (screen()->getHeadWidth(head) * screen()->getToolbarWidthPercent() / 100); + } else { + head_w = screen->getWidth(); + head_h = screen->getHeight(); - frame.width = screen()->getWidth() * screen()->getToolbarWidthPercent() / 100; - } + frame.width = screen()->getWidth() * screen()->getToolbarWidthPercent() / 100; + } #else // !XINERAMA - head_w = screen()->getWidth(); - head_h = screen()->getHeight(); + head_w = screen()->getWidth(); + head_h = screen()->getHeight(); - frame.width = screen()->getWidth() * screen()->getToolbarWidthPercent() / 100; + frame.width = screen()->getWidth() * screen()->getToolbarWidthPercent() / 100; #endif // XINERAMA - frame.height = screen()->getToolbarStyle()->font.height(); - frame.button_w = frame.height; - frame.height += 2; - frame.label_h = frame.height; - frame.height += (frame.bevel_w * 2); + frame.height = screen()->getToolbarStyle()->font.height(); + frame.button_w = frame.height; + frame.height += 2; + frame.label_h = frame.height; + frame.height += (frame.bevel_w * 2); - switch (screen()->getToolbarPlacement()) { - case TOPLEFT: - frame.x = head_x; - frame.y = head_y; - frame.x_hidden = head_x; - frame.y_hidden = head_y + - screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; - break; + switch (screen()->getToolbarPlacement()) { + case TOPLEFT: + frame.x = head_x; + frame.y = head_y; + frame.x_hidden = head_x; + frame.y_hidden = head_y + + screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; + break; - case BOTTOMLEFT: - frame.x = head_x; - frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); - frame.x_hidden = head_x; - frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - - screen()->getBorderWidth(); - break; + case BOTTOMLEFT: + frame.x = head_x; + frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); + frame.x_hidden = head_x; + frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - + screen()->getBorderWidth(); + break; - case TOPCENTER: - frame.x = head_x + ((head_w - frame.width) / 2); - frame.y = head_y; - frame.x_hidden = frame.x; - frame.y_hidden = head_y + - screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; - break; + case TOPCENTER: + frame.x = head_x + ((head_w - frame.width) / 2); + frame.y = head_y; + frame.x_hidden = frame.x; + frame.y_hidden = head_y + + screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; + break; - case BOTTOMCENTER: - default: - frame.x = head_x + ((head_w - frame.width) / 2); - frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); - frame.x_hidden = frame.x; - frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - - screen()->getBorderWidth(); - break; + case BOTTOMCENTER: + default: + frame.x = head_x + ((head_w - frame.width) / 2); + frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); + frame.x_hidden = frame.x; + frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - + screen()->getBorderWidth(); + break; - case TOPRIGHT: - frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); - frame.y = head_y; - frame.x_hidden = frame.x; - frame.y_hidden = head_y + - screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; - break; + case TOPRIGHT: + frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); + frame.y = head_y; + frame.x_hidden = frame.x; + frame.y_hidden = head_y + + screen()->getBevelWidth() - screen()->getBorderWidth() - frame.height; + break; - case BOTTOMRIGHT: - frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); - frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); - frame.x_hidden = frame.x; - frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - - screen()->getBorderWidth(); - break; - } + case BOTTOMRIGHT: + frame.x = head_x + head_w - frame.width - screen()->getBorderWidth2x(); + frame.y = head_y + head_h - frame.height - screen()->getBorderWidth2x(); + frame.x_hidden = frame.x; + frame.y_hidden = head_y + head_h - screen()->getBevelWidth() - + screen()->getBorderWidth(); + break; + } #ifdef HAVE_STRFTIME - time_t ttmp = time(0); - struct tm *tt = 0; + time_t ttmp = time(0); + struct tm *tt = 0; - if (ttmp != -1) { - tt = localtime(&ttmp); - if (tt) { - char t[1024], *time_string = (char *) 0; - int len = strftime(t, 1024, screen()->getStrftimeFormat(), tt); + if (ttmp != -1) { + tt = localtime(&ttmp); + if (tt) { + char t[1024], *time_string = (char *) 0; + int len = strftime(t, 1024, screen()->getStrftimeFormat(), tt); - time_string = new char[len + 1]; + time_string = new char[len + 1]; - memset(time_string, '0', len); - *(time_string + len) = '\0'; + memset(time_string, '0', len); + *(time_string + len) = '\0'; - frame.clock_w = screen()->getToolbarStyle()->font.textWidth(time_string, len); - frame.clock_w += (frame.bevel_w * 4); + frame.clock_w = screen()->getToolbarStyle()->font.textWidth(time_string, len); + frame.clock_w += (frame.bevel_w * 4); - delete [] time_string; - } else - frame.clock_w = 0; - } else - frame.clock_w = 0; + delete [] time_string; + } else + frame.clock_w = 0; + } else + frame.clock_w = 0; #else // !HAVE_STRFTIME - frame.clock_w = screen()->getToolbarStyle()->font.textWidth( - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeLength, - "00:00000"), - strlen(i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeLength, - "00:00000"))) + (frame.bevel_w * 4); + frame.clock_w = screen()->getToolbarStyle()->font.textWidth( + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeLength, + "00:00000"), + strlen(i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeLength, + "00:00000"))) + (frame.bevel_w * 4); #endif // HAVE_STRFTIME - unsigned int i; - unsigned int w = 0; - frame.workspace_label_w = 0; + unsigned int i; + unsigned int w = 0; + frame.workspace_label_w = 0; - for (i = 0; i < screen()->getCount(); i++) { - w = screen()->getToolbarStyle()->font.textWidth( - screen()->getWorkspace(i)->name().c_str(), - screen()->getWorkspace(i)->name().size()); + for (i = 0; i < screen()->getCount(); i++) { + w = screen()->getToolbarStyle()->font.textWidth( + screen()->getWorkspace(i)->name().c_str(), + screen()->getWorkspace(i)->name().size()); - w += (frame.bevel_w * 4); + w += (frame.bevel_w * 4); - if (w > frame.workspace_label_w) - frame.workspace_label_w = w; - } + if (w > frame.workspace_label_w) + frame.workspace_label_w = w; + } - if (frame.workspace_label_w < frame.clock_w) - frame.workspace_label_w = frame.clock_w; - else if (frame.workspace_label_w > frame.clock_w) - frame.clock_w = frame.workspace_label_w; + if (frame.workspace_label_w < frame.clock_w) + frame.workspace_label_w = frame.clock_w; + else if (frame.workspace_label_w > frame.clock_w) + frame.clock_w = frame.workspace_label_w; - frame.window_label_w = - (frame.width - (frame.clock_w + (frame.button_w * 4) + - frame.workspace_label_w + (frame.bevel_w * 8) + 6)); + frame.window_label_w = + (frame.width - (frame.clock_w + (frame.button_w * 4) + + frame.workspace_label_w + (frame.bevel_w * 8) + 6)); - if (hidden) - XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden, - frame.width, frame.height); - else - XMoveResizeWindow(display, frame.window, frame.x, frame.y, - frame.width, frame.height); + if (hidden) + XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden, + frame.width, frame.height); + else + XMoveResizeWindow(display, frame.window, frame.x, frame.y, + frame.width, frame.height); - XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w, - frame.bevel_w, frame.workspace_label_w, - frame.label_h); - XMoveResizeWindow(display, frame.psbutton, (frame.bevel_w * 2) + - frame.workspace_label_w + 1, frame.bevel_w + 1, - frame.button_w, frame.button_w); - XMoveResizeWindow(display ,frame.nsbutton, (frame.bevel_w * 3) + - frame.workspace_label_w + frame.button_w + 2, - frame.bevel_w + 1, frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.window_label, (frame.bevel_w * 4) + - (frame.button_w * 2) + frame.workspace_label_w + 3, - frame.bevel_w, frame.window_label_w, frame.label_h); - XMoveResizeWindow(display, frame.pwbutton, (frame.bevel_w * 5) + - (frame.button_w * 2) + frame.workspace_label_w + - frame.window_label_w + 4, frame.bevel_w + 1, - frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.nwbutton, (frame.bevel_w * 6) + - (frame.button_w * 3) + frame.workspace_label_w + - frame.window_label_w + 5, frame.bevel_w + 1, - frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.clock, frame.width - frame.clock_w - - frame.bevel_w, frame.bevel_w, frame.clock_w, - frame.label_h); + XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w, + frame.bevel_w, frame.workspace_label_w, + frame.label_h); + XMoveResizeWindow(display, frame.psbutton, (frame.bevel_w * 2) + + frame.workspace_label_w + 1, frame.bevel_w + 1, + frame.button_w, frame.button_w); + XMoveResizeWindow(display ,frame.nsbutton, (frame.bevel_w * 3) + + frame.workspace_label_w + frame.button_w + 2, + frame.bevel_w + 1, frame.button_w, frame.button_w); + XMoveResizeWindow(display, frame.window_label, (frame.bevel_w * 4) + + (frame.button_w * 2) + frame.workspace_label_w + 3, + frame.bevel_w, frame.window_label_w, frame.label_h); + XMoveResizeWindow(display, frame.pwbutton, (frame.bevel_w * 5) + + (frame.button_w * 2) + frame.workspace_label_w + + frame.window_label_w + 4, frame.bevel_w + 1, + frame.button_w, frame.button_w); + XMoveResizeWindow(display, frame.nwbutton, (frame.bevel_w * 6) + + (frame.button_w * 3) + frame.workspace_label_w + + frame.window_label_w + 5, frame.bevel_w + 1, + frame.button_w, frame.button_w); + XMoveResizeWindow(display, frame.clock, frame.width - frame.clock_w - + frame.bevel_w, frame.bevel_w, frame.clock_w, + frame.label_h); - Pixmap tmp = frame.base; - const FbTk::Texture *texture = &(screen()->getToolbarStyle()->toolbar); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.base = None; - XSetWindowBackground(display, frame.window, - texture->color().pixel()); - } else { - frame.base = - image_ctrl->renderImage(frame.width, frame.height, *texture); - XSetWindowBackgroundPixmap(display, frame.window, frame.base); - } - if (tmp) image_ctrl->removeImage(tmp); + Pixmap tmp = frame.base; + const FbTk::Texture *texture = &(screen()->getToolbarStyle()->toolbar); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.base = None; + XSetWindowBackground(display, frame.window, + texture->color().pixel()); + } else { + frame.base = + image_ctrl->renderImage(frame.width, frame.height, *texture); + XSetWindowBackgroundPixmap(display, frame.window, frame.base); + } + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.label; - texture = &(screen()->getToolbarStyle()->window); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.label = None; - XSetWindowBackground(display, frame.window_label, - texture->color().pixel()); - } else { - frame.label = - image_ctrl->renderImage(frame.window_label_w, frame.label_h, *texture); - XSetWindowBackgroundPixmap(display, frame.window_label, frame.label); - } - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.label; + texture = &(screen()->getToolbarStyle()->window); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.label = None; + XSetWindowBackground(display, frame.window_label, + texture->color().pixel()); + } else { + frame.label = + image_ctrl->renderImage(frame.window_label_w, frame.label_h, *texture); + XSetWindowBackgroundPixmap(display, frame.window_label, frame.label); + } + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.wlabel; - texture = &(screen()->getToolbarStyle()->label); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.wlabel = None; - XSetWindowBackground(display, frame.workspace_label, - texture->color().pixel()); - } else { - frame.wlabel = - image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, *texture); - XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel); - } - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.wlabel; + texture = &(screen()->getToolbarStyle()->label); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.wlabel = None; + XSetWindowBackground(display, frame.workspace_label, + texture->color().pixel()); + } else { + frame.wlabel = + image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, *texture); + XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel); + } + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.clk; - texture = &(screen()->getToolbarStyle()->clock); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.clk = None; - XSetWindowBackground(display, frame.clock, texture->color().pixel()); - } else { - frame.clk = - image_ctrl->renderImage(frame.clock_w, frame.label_h, *texture); - XSetWindowBackgroundPixmap(display, frame.clock, frame.clk); - } - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.clk; + texture = &(screen()->getToolbarStyle()->clock); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.clk = None; + XSetWindowBackground(display, frame.clock, texture->color().pixel()); + } else { + frame.clk = + image_ctrl->renderImage(frame.clock_w, frame.label_h, *texture); + XSetWindowBackgroundPixmap(display, frame.clock, frame.clk); + } + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.button; - texture = &(screen()->getToolbarStyle()->button); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.button = None; + tmp = frame.button; + texture = &(screen()->getToolbarStyle()->button); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.button = None; - frame.button_pixel = texture->color().pixel(); - XSetWindowBackground(display, frame.psbutton, frame.button_pixel); - XSetWindowBackground(display, frame.nsbutton, frame.button_pixel); - XSetWindowBackground(display, frame.pwbutton, frame.button_pixel); - XSetWindowBackground(display, frame.nwbutton, frame.button_pixel); - } else { - frame.button = - image_ctrl->renderImage(frame.button_w, frame.button_w, *texture); + frame.button_pixel = texture->color().pixel(); + XSetWindowBackground(display, frame.psbutton, frame.button_pixel); + XSetWindowBackground(display, frame.nsbutton, frame.button_pixel); + XSetWindowBackground(display, frame.pwbutton, frame.button_pixel); + XSetWindowBackground(display, frame.nwbutton, frame.button_pixel); + } else { + frame.button = + image_ctrl->renderImage(frame.button_w, frame.button_w, *texture); - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); - } - if (tmp) - image_ctrl->removeImage(tmp); + XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); + XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); + XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); + XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); + } + if (tmp) + image_ctrl->removeImage(tmp); - tmp = frame.pbutton; - texture = &(screen()->getToolbarStyle()->pressed); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.pbutton = None; - frame.pbutton_pixel = texture->color().pixel(); - } else - frame.pbutton = - image_ctrl->renderImage(frame.button_w, frame.button_w, *texture); - if (tmp) - image_ctrl->removeImage(tmp); + tmp = frame.pbutton; + texture = &(screen()->getToolbarStyle()->pressed); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.pbutton = None; + frame.pbutton_pixel = texture->color().pixel(); + } else + frame.pbutton = + image_ctrl->renderImage(frame.button_w, frame.button_w, *texture); + if (tmp) + image_ctrl->removeImage(tmp); - XSetWindowBorder(display, frame.window, - screen()->getBorderColor()->pixel()); - XSetWindowBorderWidth(display, frame.window, screen()->getBorderWidth()); + XSetWindowBorder(display, frame.window, + screen()->getBorderColor()->pixel()); + XSetWindowBorderWidth(display, frame.window, screen()->getBorderWidth()); - XClearWindow(display, frame.window); - XClearWindow(display, frame.workspace_label); - XClearWindow(display, frame.window_label); - XClearWindow(display, frame.clock); - XClearWindow(display, frame.psbutton); - XClearWindow(display, frame.nsbutton); - XClearWindow(display, frame.pwbutton); - XClearWindow(display, frame.nwbutton); + XClearWindow(display, frame.window); + XClearWindow(display, frame.workspace_label); + XClearWindow(display, frame.window_label); + XClearWindow(display, frame.clock); + XClearWindow(display, frame.psbutton); + XClearWindow(display, frame.nsbutton); + XClearWindow(display, frame.pwbutton); + XClearWindow(display, frame.nwbutton); - redrawWindowLabel(); - redrawWorkspaceLabel(); - redrawPrevWorkspaceButton(); - redrawNextWorkspaceButton(); - redrawPrevWindowButton(); - redrawNextWindowButton(); - checkClock(true); + redrawWindowLabel(); + redrawWorkspaceLabel(); + redrawPrevWorkspaceButton(); + redrawNextWorkspaceButton(); + redrawPrevWindowButton(); + redrawNextWindowButton(); + checkClock(true); - m_toolbarmenu.reconfigure(); + m_toolbarmenu.reconfigure(); - //iconbar, no iconbar? - if (Fluxbox::instance()->useIconBar()) { - if (m_iconbar.get() == 0) { // create new iconbar if we don't have one - m_iconbar.reset(new IconBar(screen(), frame.window_label)); - if (screen()->getIconCount()) { - BScreen::Icons & l = screen()->getIconList(); - BScreen::Icons::iterator it = l.begin(); - BScreen::Icons::iterator it_end = l.end(); - for(; it != it_end; ++it) { - addIcon(*it); - } - } + //iconbar, no iconbar? + if (Fluxbox::instance()->useIconBar()) { + if (m_iconbar.get() == 0) { // create new iconbar if we don't have one + m_iconbar.reset(new IconBar(screen(), frame.window_label)); + if (screen()->getIconCount()) { + BScreen::Icons & l = screen()->getIconList(); + BScreen::Icons::iterator it = l.begin(); + BScreen::Icons::iterator it_end = l.end(); + for(; it != it_end; ++it) { + addIcon(*it); + } + } - } else - m_iconbar->reconfigure(); - } else if (m_iconbar.get() != 0) { - BScreen::Icons & l = screen()->getIconList(); - BScreen::Icons::iterator it = l.begin(); - BScreen::Icons::iterator it_end = l.end(); - for(; it != it_end; ++it) - delIcon(*it); + } else + m_iconbar->reconfigure(); + } else if (m_iconbar.get() != 0) { + BScreen::Icons & l = screen()->getIconList(); + BScreen::Icons::iterator it = l.begin(); + BScreen::Icons::iterator it_end = l.end(); + for(; it != it_end; ++it) + delIcon(*it); - m_iconbar.reset(0); // destroy iconbar - } + m_iconbar.reset(0); // destroy iconbar + } } void Toolbar::checkClock(bool redraw, bool date) { - time_t tmp = 0; - struct tm *tt = 0; + time_t tmp = 0; + struct tm *tt = 0; - if ((tmp = time(NULL)) != -1) { - if (! (tt = localtime(&tmp))) { - cerr<<__FILE__<<"("<<__LINE__<<"): ! localtime(&tmp)"<<endl; - return; - } - if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) { - frame.hour = tt->tm_hour; - frame.minute = tt->tm_min; - XClearWindow(display, frame.clock); - redraw = true; - } - } else - cerr<<__FILE__<<"("<<__LINE__<<"): time(null)<0"<<endl; + if ((tmp = time(NULL)) != -1) { + if (! (tt = localtime(&tmp))) { + cerr<<__FILE__<<"("<<__LINE__<<"): ! localtime(&tmp)"<<endl; + return; + } + if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) { + frame.hour = tt->tm_hour; + frame.minute = tt->tm_min; + XClearWindow(display, frame.clock); + redraw = true; + } + } else + cerr<<__FILE__<<"("<<__LINE__<<"): time(null)<0"<<endl; - if (redraw) { - XClearWindow(display, frame.clock); + if (redraw) { + XClearWindow(display, frame.clock); #ifdef HAVE_STRFTIME - char t[1024]; - if (! strftime(t, 1024, screen()->getStrftimeFormat(), tt)) - return; + char t[1024]; + if (! strftime(t, 1024, screen()->getStrftimeFormat(), tt)) + return; #else // !HAVE_STRFTIME - char t[9]; - if (date) { - // format the date... with special consideration for y2k ;) - if (screen()->getDateFormat() == Blackbox::B_EuropeanDate) { - sprintf(t, - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeDateFormatEu, - "%02d.%02d.%02d"), - tt->tm_mday, tt->tm_mon + 1, - (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); - } else { - sprintf(t, - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeDateFormat, - "%02d/%02d/%02d"), - tt->tm_mon + 1, tt->tm_mday, - (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); - } - } else { - if (screen()->isClock24Hour()) { - sprintf(t, - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeTimeFormat24, - " %02d:%02d "), - frame.hour, frame.minute); - } else { - sprintf(t, - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeTimeFormat12, - "%02d:%02d %sm"), - ((frame.hour > 12) ? frame.hour - 12 : - ((frame.hour == 0) ? 12 : frame.hour)), frame.minute, - ((frame.hour >= 12) ? - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeTimeFormatP, - "p") : - i18n->getMessage( - ToolbarSet, ToolbarNoStrftimeTimeFormatA, - "a"))); - } - } + char t[9]; + if (date) { + // format the date... with special consideration for y2k ;) + if (screen()->getDateFormat() == Blackbox::B_EuropeanDate) { + sprintf(t, + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeDateFormatEu, + "%02d.%02d.%02d"), + tt->tm_mday, tt->tm_mon + 1, + (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); + } else { + sprintf(t, + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeDateFormat, + "%02d/%02d/%02d"), + tt->tm_mon + 1, tt->tm_mday, + (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); + } + } else { + if (screen()->isClock24Hour()) { + sprintf(t, + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeTimeFormat24, + " %02d:%02d "), + frame.hour, frame.minute); + } else { + sprintf(t, + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeTimeFormat12, + "%02d:%02d %sm"), + ((frame.hour > 12) ? frame.hour - 12 : + ((frame.hour == 0) ? 12 : frame.hour)), frame.minute, + ((frame.hour >= 12) ? + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeTimeFormatP, + "p") : + i18n->getMessage( + ToolbarSet, ToolbarNoStrftimeTimeFormatA, + "a"))); + } + } #endif // HAVE_STRFTIME - size_t newlen = strlen(t); - int dx = DrawUtil::doAlignment(frame.clock_w, - frame.bevel_w*2, - screen()->getToolbarStyle()->justify, - screen()->getToolbarStyle()->font, - t, strlen(t), newlen); + size_t newlen = strlen(t); + int dx = DrawUtil::doAlignment(frame.clock_w, + frame.bevel_w*2, + screen()->getToolbarStyle()->justify, + screen()->getToolbarStyle()->font, + t, strlen(t), newlen); - screen()->getToolbarStyle()->font.drawText( - frame.clock, - screen()->getScreenNumber(), - screen()->getToolbarStyle()->c_text_gc, - t, newlen, - dx, 1 + screen()->getToolbarStyle()->font.ascent()); - } + screen()->getToolbarStyle()->font.drawText( + frame.clock, + screen()->getScreenNumber(), + screen()->getToolbarStyle()->c_text_gc, + t, newlen, + dx, 1 + screen()->getToolbarStyle()->font.ascent()); + } } void Toolbar::redrawWindowLabel(bool redraw) { - if (Fluxbox::instance()->getFocusedWindow()) { - if (redraw) - XClearWindow(display, frame.window_label); + if (Fluxbox::instance()->getFocusedWindow()) { + if (redraw) + XClearWindow(display, frame.window_label); - FluxboxWindow *foc = Fluxbox::instance()->getFocusedWindow(); - if (foc->getScreen() != screen() || foc->getTitle().size() == 0) - return; + FluxboxWindow *foc = Fluxbox::instance()->getFocusedWindow(); + if (foc->getScreen() != screen() || foc->getTitle().size() == 0) + return; - size_t newlen = foc->getTitle().size(); - int dx = DrawUtil::doAlignment(frame.window_label_w, frame.bevel_w*2, - screen()->getToolbarStyle()->justify, - screen()->getToolbarStyle()->font, - foc->getTitle().c_str(), foc->getTitle().size(), newlen); + size_t newlen = foc->getTitle().size(); + int dx = DrawUtil::doAlignment(frame.window_label_w, frame.bevel_w*2, + screen()->getToolbarStyle()->justify, + screen()->getToolbarStyle()->font, + foc->getTitle().c_str(), foc->getTitle().size(), newlen); - screen()->getToolbarStyle()->font.drawText( - frame.window_label, - screen()->getScreenNumber(), - screen()->getToolbarStyle()->w_text_gc, - foc->getTitle().c_str(), newlen, - dx, 1 + screen()->getToolbarStyle()->font.ascent()); - } else - XClearWindow(display, frame.window_label); + screen()->getToolbarStyle()->font.drawText( + frame.window_label, + screen()->getScreenNumber(), + screen()->getToolbarStyle()->w_text_gc, + foc->getTitle().c_str(), newlen, + dx, 1 + screen()->getToolbarStyle()->font.ascent()); + } else + XClearWindow(display, frame.window_label); } void Toolbar::redrawWorkspaceLabel(bool redraw) { - if (screen()->getCurrentWorkspace()->name().size()==0) - return; + if (screen()->getCurrentWorkspace()->name().size()==0) + return; - if (redraw) - XClearWindow(display, frame.workspace_label); + if (redraw) + XClearWindow(display, frame.workspace_label); - const char *text = screen()->getCurrentWorkspace()->name().c_str(); - size_t textlen = screen()->getCurrentWorkspace()->name().size(); - size_t newlen = textlen; - int dx = DrawUtil::doAlignment(frame.workspace_label_w, frame.bevel_w, - screen()->getToolbarStyle()->justify, - screen()->getToolbarStyle()->font, - text, textlen, newlen); + const char *text = screen()->getCurrentWorkspace()->name().c_str(); + size_t textlen = screen()->getCurrentWorkspace()->name().size(); + size_t newlen = textlen; + int dx = DrawUtil::doAlignment(frame.workspace_label_w, frame.bevel_w, + screen()->getToolbarStyle()->justify, + screen()->getToolbarStyle()->font, + text, textlen, newlen); - screen()->getToolbarStyle()->font.drawText( - frame.workspace_label, - screen()->getScreenNumber(), - screen()->getToolbarStyle()->l_text_gc, - text, newlen, - dx, 1 + screen()->getToolbarStyle()->font.ascent()); + screen()->getToolbarStyle()->font.drawText( + frame.workspace_label, + screen()->getScreenNumber(), + screen()->getToolbarStyle()->l_text_gc, + text, newlen, + dx, 1 + screen()->getToolbarStyle()->font.ascent()); } void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); - else - XSetWindowBackground(display, frame.psbutton, frame.button_pixel); - } - XClearWindow(display, frame.psbutton); - } + if (redraw) { + if (pressed) { + if (frame.pbutton) + XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton); + else + XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel); + } else { + if (frame.button) + XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); + else + XSetWindowBackground(display, frame.psbutton, frame.button_pixel); + } + XClearWindow(display, frame.psbutton); + } - int hh = frame.button_w / 2, hw = frame.button_w / 2; + int hh = frame.button_w / 2, hw = frame.button_w / 2; - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = 0; pts[2].y = -4; + XPoint pts[3]; + pts[0].x = hw - 2; pts[0].y = hh; + pts[1].x = 4; pts[1].y = 2; + pts[2].x = 0; pts[2].y = -4; - XFillPolygon(display, frame.psbutton, screen()->getToolbarStyle()->b_pic_gc, - pts, 3, Convex, CoordModePrevious); + XFillPolygon(display, frame.psbutton, screen()->getToolbarStyle()->b_pic_gc, + pts, 3, Convex, CoordModePrevious); } void Toolbar::redrawNextWorkspaceButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); - else - XSetWindowBackground(display, frame.nsbutton, frame.button_pixel); - } - XClearWindow(display, frame.nsbutton); - } + if (redraw) { + if (pressed) { + if (frame.pbutton) + XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton); + else + XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel); + } else { + if (frame.button) + XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); + else + XSetWindowBackground(display, frame.nsbutton, frame.button_pixel); + } + XClearWindow(display, frame.nsbutton); + } - int hh = frame.button_w / 2, hw = frame.button_w / 2; + int hh = frame.button_w / 2, hw = frame.button_w / 2; - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh - 2; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = -4; pts[2].y = 2; + XPoint pts[3]; + pts[0].x = hw - 2; pts[0].y = hh - 2; + pts[1].x = 4; pts[1].y = 2; + pts[2].x = -4; pts[2].y = 2; - XFillPolygon(display, frame.nsbutton, screen()->getToolbarStyle()->b_pic_gc, - pts, 3, Convex, CoordModePrevious); + XFillPolygon(display, frame.nsbutton, screen()->getToolbarStyle()->b_pic_gc, + pts, 3, Convex, CoordModePrevious); } void Toolbar::redrawPrevWindowButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); - else - XSetWindowBackground(display, frame.pwbutton, frame.button_pixel); - } - XClearWindow(display, frame.pwbutton); - } + if (redraw) { + if (pressed) { + if (frame.pbutton) + XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton); + else + XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel); + } else { + if (frame.button) + XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); + else + XSetWindowBackground(display, frame.pwbutton, frame.button_pixel); + } + XClearWindow(display, frame.pwbutton); + } - int hh = frame.button_w / 2, hw = frame.button_w / 2; + int hh = frame.button_w / 2, hw = frame.button_w / 2; - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = 0; pts[2].y = -4; + XPoint pts[3]; + pts[0].x = hw - 2; pts[0].y = hh; + pts[1].x = 4; pts[1].y = 2; + pts[2].x = 0; pts[2].y = -4; - XFillPolygon(display, frame.pwbutton, screen()->getToolbarStyle()->b_pic_gc, - pts, 3, Convex, CoordModePrevious); + XFillPolygon(display, frame.pwbutton, screen()->getToolbarStyle()->b_pic_gc, + pts, 3, Convex, CoordModePrevious); } void Toolbar::redrawNextWindowButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); - else - XSetWindowBackground(display, frame.nwbutton, frame.button_pixel); - } - XClearWindow(display, frame.nwbutton); - } + if (redraw) { + if (pressed) { + if (frame.pbutton) + XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton); + else + XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel); + } else { + if (frame.button) + XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); + else + XSetWindowBackground(display, frame.nwbutton, frame.button_pixel); + } + XClearWindow(display, frame.nwbutton); + } - int hh = frame.button_w / 2, hw = frame.button_w / 2; + int hh = frame.button_w / 2, hw = frame.button_w / 2; - XPoint pts[3]; - pts[0].x = hw - 2; pts[0].y = hh - 2; - pts[1].x = 4; pts[1].y = 2; - pts[2].x = -4; pts[2].y = 2; + XPoint pts[3]; + pts[0].x = hw - 2; pts[0].y = hh - 2; + pts[1].x = 4; pts[1].y = 2; + pts[2].x = -4; pts[2].y = 2; - XFillPolygon(display, frame.nwbutton, screen()->getToolbarStyle()->b_pic_gc, - pts, 3, Convex, CoordModePrevious); + XFillPolygon(display, frame.nwbutton, screen()->getToolbarStyle()->b_pic_gc, + pts, 3, Convex, CoordModePrevious); } void Toolbar::edit() { - Window window; - int foo; + Window window; + int foo; - editing = true; //mark for editing + editing = true; //mark for editing - //workspace labe already got intput focus ? - if (XGetInputFocus(display, &window, &foo) && - window == frame.workspace_label) - return; + //workspace labe already got intput focus ? + if (XGetInputFocus(display, &window, &foo) && + window == frame.workspace_label) + return; - //set input focus to workspace label - XSetInputFocus(display, frame.workspace_label, - ((screen()->isSloppyFocus() || screen()->isSemiSloppyFocus()) ? - RevertToPointerRoot : RevertToParent), CurrentTime); + //set input focus to workspace label + XSetInputFocus(display, frame.workspace_label, + ((screen()->isSloppyFocus() || screen()->isSemiSloppyFocus()) ? + RevertToPointerRoot : RevertToParent), CurrentTime); - XClearWindow(display, frame.workspace_label); //clear workspace text - Fluxbox * const fluxbox = Fluxbox::instance(); - fluxbox->setNoFocus(true); - if (fluxbox->getFocusedWindow()) //disable focus on current focused window - fluxbox->getFocusedWindow()->setFocusFlag(false); + XClearWindow(display, frame.workspace_label); //clear workspace text + Fluxbox * const fluxbox = Fluxbox::instance(); + fluxbox->setNoFocus(true); + if (fluxbox->getFocusedWindow()) //disable focus on current focused window + fluxbox->getFocusedWindow()->setFocusFlag(false); - XDrawRectangle(display, frame.workspace_label, - screen()->getWindowStyle()->l_text_focus_gc, - frame.workspace_label_w / 2, 0, 1, - frame.label_h - 1); + XDrawRectangle(display, frame.workspace_label, + screen()->getWindowStyle()->l_text_focus_gc, + frame.workspace_label_w / 2, 0, 1, + frame.label_h - 1); } void Toolbar::buttonPressEvent(XButtonEvent *be) { - FluxboxWindow *fluxboxwin=0; - if (be->button == 1) { - if (be->window == frame.psbutton) - redrawPrevWorkspaceButton(true, true); - else if (be->window == frame.nsbutton) - redrawNextWorkspaceButton(true, true); - else if (be->window == frame.pwbutton) - redrawPrevWindowButton(true, true); - else if (be->window == frame.nwbutton) - redrawNextWindowButton(true, true); - else if ( m_iconbar.get() != 0 ) { - if ( (fluxboxwin = m_iconbar->findWindow(be->window)) ) - fluxboxwin->deiconify(); - } + FluxboxWindow *fluxboxwin=0; + if (be->button == 1) { + if (be->window == frame.psbutton) + redrawPrevWorkspaceButton(true, true); + else if (be->window == frame.nsbutton) + redrawNextWorkspaceButton(true, true); + else if (be->window == frame.pwbutton) + redrawPrevWindowButton(true, true); + else if (be->window == frame.nwbutton) + redrawNextWindowButton(true, true); + else if ( m_iconbar.get() != 0 ) { + if ( (fluxboxwin = m_iconbar->findWindow(be->window)) ) + fluxboxwin->deiconify(); + } #ifndef HAVE_STRFTIME - else if (be->window == frame.clock) { - XClearWindow(display, frame.clock); - checkClock(true, true); - } + else if (be->window == frame.clock) { + XClearWindow(display, frame.clock); + checkClock(true, true); + } #endif // HAVE_STRFTIME - else if (! on_top) { - Workspace::Stack st; - st.push_back(frame.window); - screen()->raiseWindows(st); - } - } else if (be->button == 2 && (! on_top)) { - XLowerWindow(display, frame.window); - } else if (be->button == 3) { - FluxboxWindow *fluxboxwin = 0; - // if we clicked on a icon then show window menu - if ( m_iconbar.get() != 0 && (fluxboxwin = m_iconbar->findWindow(be->window)) ) { - const Windowmenu * const wm = fluxboxwin->getWindowmenu(); - if (wm != 0) { - int menu_y = be->y_root - wm->height(); - int menu_x = be->x_root; + else if (! on_top) { + Workspace::Stack st; + st.push_back(frame.window); + screen()->raiseWindows(st); + } + } else if (be->button == 2 && (! on_top)) { + XLowerWindow(display, frame.window); + } else if (be->button == 3) { + FluxboxWindow *fluxboxwin = 0; + // if we clicked on a icon then show window menu + if ( m_iconbar.get() != 0 && (fluxboxwin = m_iconbar->findWindow(be->window)) ) { + const Windowmenu * const wm = fluxboxwin->getWindowmenu(); + if (wm != 0) { + int menu_y = be->y_root - wm->height(); + int menu_x = be->x_root; // make sure the menu is visible - if (menu_y < 0) { - menu_y = 0; - } - if (menu_x < 0) { - menu_x = 0; - } else if (menu_x + wm->width() > screen()->getWidth()) { - menu_x = screen()->getWidth() - wm->width(); - } - fluxboxwin->showMenu(menu_x, menu_y); - } - } else if (! m_toolbarmenu.isVisible()) { - int x, y; + if (menu_y < 0) { + menu_y = 0; + } + if (menu_x < 0) { + menu_x = 0; + } else if (menu_x + wm->width() > screen()->getWidth()) { + menu_x = screen()->getWidth() - wm->width(); + } + fluxboxwin->showMenu(menu_x, menu_y); + } + } else if (! m_toolbarmenu.isVisible()) { + int x, y; - x = be->x_root - (m_toolbarmenu.width() / 2); - y = be->y_root - (m_toolbarmenu.height() / 2); + x = be->x_root - (m_toolbarmenu.width() / 2); + y = be->y_root - (m_toolbarmenu.height() / 2); - if (x < 0) - x = 0; - else if (x + m_toolbarmenu.width() > screen()->getWidth()) - x = screen()->getWidth() - m_toolbarmenu.width(); + if (x < 0) + x = 0; + else if (x + m_toolbarmenu.width() > screen()->getWidth()) + x = screen()->getWidth() - m_toolbarmenu.width(); - if (y < 0) - y = 0; - else if (y + m_toolbarmenu.height() > screen()->getHeight()) - y = screen()->getHeight() - m_toolbarmenu.height(); + if (y < 0) + y = 0; + else if (y + m_toolbarmenu.height() > screen()->getHeight()) + y = screen()->getHeight() - m_toolbarmenu.height(); - m_toolbarmenu.move(x, y); - m_toolbarmenu.show(); - } else - m_toolbarmenu.hide(); + m_toolbarmenu.move(x, y); + m_toolbarmenu.show(); + } else + m_toolbarmenu.hide(); - } + } } void Toolbar::buttonReleaseEvent(XButtonEvent *re) { - if (re->button == 1) { - if (re->window == frame.psbutton) { - redrawPrevWorkspaceButton(false, true); + if (re->button == 1) { + if (re->window == frame.psbutton) { + redrawPrevWorkspaceButton(false, true); - if (re->x >= 0 && re->x < (signed) frame.button_w && - re->y >= 0 && re->y < (signed) frame.button_w) - screen()->prevWorkspace(1); - } else if (re->window == frame.nsbutton) { - redrawNextWorkspaceButton(false, true); + if (re->x >= 0 && re->x < (signed) frame.button_w && + re->y >= 0 && re->y < (signed) frame.button_w) + screen()->prevWorkspace(1); + } else if (re->window == frame.nsbutton) { + redrawNextWorkspaceButton(false, true); - if (re->x >= 0 && re->x < (signed) frame.button_w && - re->y >= 0 && re->y < (signed) frame.button_w) - screen()->nextWorkspace(1); - } else if (re->window == frame.pwbutton) { - redrawPrevWindowButton(false, true); + if (re->x >= 0 && re->x < (signed) frame.button_w && + re->y >= 0 && re->y < (signed) frame.button_w) + screen()->nextWorkspace(1); + } else if (re->window == frame.pwbutton) { + redrawPrevWindowButton(false, true); - if (re->x >= 0 && re->x < (signed) frame.button_w && - re->y >= 0 && re->y < (signed) frame.button_w) - screen()->prevFocus(); - } else if (re->window == frame.nwbutton) { - redrawNextWindowButton(false, true); + if (re->x >= 0 && re->x < (signed) frame.button_w && + re->y >= 0 && re->y < (signed) frame.button_w) + screen()->prevFocus(); + } else if (re->window == frame.nwbutton) { + redrawNextWindowButton(false, true); - if (re->x >= 0 && re->x < (signed) frame.button_w && - re->y >= 0 && re->y < (signed) frame.button_w) - screen()->nextFocus(); - } else if (re->window == frame.workspace_label) { - Basemenu *menu = screen()->getWorkspacemenu(); - //move the workspace label and make it visible - menu->move(re->x_root, re->y_root); - // make sure the entire menu is visible (TODO: this is repeated by other menus, make a function!) - int newx = menu->x(); // new x position of menu - int newy = menu->y(); // new y position of menu - if (menu->x() < 0) - newx = 0; - else if (menu->x() + menu->width() > screen()->getWidth()) - newx = screen()->getWidth() - menu->width(); + if (re->x >= 0 && re->x < (signed) frame.button_w && + re->y >= 0 && re->y < (signed) frame.button_w) + screen()->nextFocus(); + } else if (re->window == frame.workspace_label) { + Basemenu *menu = screen()->getWorkspacemenu(); + //move the workspace label and make it visible + menu->move(re->x_root, re->y_root); + // make sure the entire menu is visible (TODO: this is repeated by other menus, make a function!) + int newx = menu->x(); // new x position of menu + int newy = menu->y(); // new y position of menu + if (menu->x() < 0) + newx = 0; + else if (menu->x() + menu->width() > screen()->getWidth()) + newx = screen()->getWidth() - menu->width(); - if (menu->y() < 0) - newy = 0; - else if (menu->y() + menu->height() > screen()->getHeight()) - newy = screen()->getHeight() - menu->height(); - // move and show menu - menu->move(newx, newy); - menu->show(); - } else if (re->window == frame.window_label) - screen()->raiseFocus(); + if (menu->y() < 0) + newy = 0; + else if (menu->y() + menu->height() > screen()->getHeight()) + newy = screen()->getHeight() - menu->height(); + // move and show menu + menu->move(newx, newy); + menu->show(); + } else if (re->window == frame.window_label) + screen()->raiseFocus(); #ifndef HAVE_STRFTIME - else if (re->window == frame.clock) { - XClearWindow(display, frame.clock); - checkClock(true); - } + else if (re->window == frame.clock) { + XClearWindow(display, frame.clock); + checkClock(true); + } #endif // HAVE_STRFTIME - } else if (re->button == 4) //mousewheel scroll up - screen()->nextWorkspace(1); - else if (re->button == 5) //mousewheel scroll down - screen()->prevWorkspace(1); + } else if (re->button == 4) //mousewheel scroll up + screen()->nextWorkspace(1); + else if (re->button == 5) //mousewheel scroll down + screen()->prevWorkspace(1); } void Toolbar::enterNotifyEvent(XCrossingEvent *) { - if (! do_auto_hide) - return; + if (! do_auto_hide) + return; - if (hidden) { - if (! hide_timer.isTiming()) - hide_timer.start(); - } else { - if (hide_timer.isTiming()) - hide_timer.stop(); - } + if (hidden) { + if (! hide_timer.isTiming()) + hide_timer.start(); + } else { + if (hide_timer.isTiming()) + hide_timer.stop(); + } } void Toolbar::leaveNotifyEvent(XCrossingEvent *) { - if (! do_auto_hide) - return; + if (! do_auto_hide) + return; - if (hidden) { - if (hide_timer.isTiming()) - hide_timer.stop(); - } else if (! m_toolbarmenu.isVisible() && ! hide_timer.isTiming()) - hide_timer.start(); + if (hidden) { + if (hide_timer.isTiming()) + hide_timer.stop(); + } else if (! m_toolbarmenu.isVisible() && ! hide_timer.isTiming()) + hide_timer.start(); } void Toolbar::exposeEvent(XExposeEvent *ee) { - if (ee->window == frame.clock) - checkClock(true); - else if (ee->window == frame.workspace_label && (! editing)) - redrawWorkspaceLabel(); - else if (ee->window == frame.window_label) redrawWindowLabel(); - else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton(); - else if (ee->window == frame.nsbutton) redrawNextWorkspaceButton(); - else if (ee->window == frame.pwbutton) redrawPrevWindowButton(); - else if (ee->window == frame.nwbutton) redrawNextWindowButton(); - else if (m_iconbar.get() != 0) - m_iconbar->exposeEvent(ee); + if (ee->window == frame.clock) + checkClock(true); + else if (ee->window == frame.workspace_label && (! editing)) + redrawWorkspaceLabel(); + else if (ee->window == frame.window_label) redrawWindowLabel(); + else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton(); + else if (ee->window == frame.nsbutton) redrawNextWorkspaceButton(); + else if (ee->window == frame.pwbutton) redrawPrevWindowButton(); + else if (ee->window == frame.nwbutton) redrawNextWindowButton(); + else if (m_iconbar.get() != 0) + m_iconbar->exposeEvent(ee); } void Toolbar::keyPressEvent(XKeyEvent *ke) { - if (ke->window == frame.workspace_label && editing) { + if (ke->window == frame.workspace_label && editing) { - KeySym ks; - char keychar[1]; - XLookupString(ke, keychar, 1, &ks, 0); + KeySym ks; + char keychar[1]; + XLookupString(ke, keychar, 1, &ks, 0); - if (ks == XK_Return || ks == XK_Escape) { + if (ks == XK_Return || ks == XK_Escape) { - editing = false; - Fluxbox * const fluxbox = Fluxbox::instance(); - fluxbox->setNoFocus(false); - if (fluxbox->getFocusedWindow()) { - fluxbox->getFocusedWindow()->setInputFocus(); - fluxbox->getFocusedWindow()->setFocusFlag(true); - } else - XSetInputFocus(display, PointerRoot, None, CurrentTime); + editing = false; + Fluxbox * const fluxbox = Fluxbox::instance(); + fluxbox->setNoFocus(false); + if (fluxbox->getFocusedWindow()) { + fluxbox->getFocusedWindow()->setInputFocus(); + fluxbox->getFocusedWindow()->setFocusFlag(true); + } else + XSetInputFocus(display, PointerRoot, None, CurrentTime); - if (ks == XK_Return) //change workspace name if keypress = Return - screen()->getCurrentWorkspace()->setName(new_workspace_name.c_str()); + if (ks == XK_Return) //change workspace name if keypress = Return + screen()->getCurrentWorkspace()->setName(new_workspace_name.c_str()); - new_workspace_name.erase(); //erase temporary workspace name + new_workspace_name.erase(); //erase temporary workspace name - screen()->getCurrentWorkspace()->menu().hide(); - screen()->getWorkspacemenu()-> - remove(screen()->getCurrentWorkspace()->workspaceID() + 2); - screen()->getWorkspacemenu()-> - insert(screen()->getCurrentWorkspace()->name().c_str(), - &screen()->getCurrentWorkspace()->menu(), - screen()->getCurrentWorkspace()->workspaceID() + 2); - screen()->getWorkspacemenu()->update(); + screen()->getCurrentWorkspace()->menu().hide(); + screen()->getWorkspacemenu()-> + remove(screen()->getCurrentWorkspace()->workspaceID() + 2); + screen()->getWorkspacemenu()-> + insert(screen()->getCurrentWorkspace()->name().c_str(), + &screen()->getCurrentWorkspace()->menu(), + screen()->getCurrentWorkspace()->workspaceID() + 2); + screen()->getWorkspacemenu()->update(); - reconfigure(); - //save workspace names - Fluxbox::instance()->save_rc(); + reconfigure(); + //save workspace names + Fluxbox::instance()->save_rc(); - } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) { + } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) { - if (ks == XK_BackSpace && new_workspace_name.size()) - new_workspace_name.erase(new_workspace_name.size()-1); - else - new_workspace_name += keychar[0]; + if (ks == XK_BackSpace && new_workspace_name.size()) + new_workspace_name.erase(new_workspace_name.size()-1); + else + new_workspace_name += keychar[0]; - XClearWindow(display, frame.workspace_label); - int l = new_workspace_name.size(), tw, x; + XClearWindow(display, frame.workspace_label); + int l = new_workspace_name.size(), tw, x; - tw = screen()->getToolbarStyle()->font.textWidth(new_workspace_name.c_str(), l); - x = (frame.workspace_label_w - tw) / 2; + tw = screen()->getToolbarStyle()->font.textWidth(new_workspace_name.c_str(), l); + x = (frame.workspace_label_w - tw) / 2; - if (x < (signed) frame.bevel_w) - x = frame.bevel_w; + if (x < (signed) frame.bevel_w) + x = frame.bevel_w; - screen()->getToolbarStyle()->font.drawText( - frame.workspace_label, - screen()->getScreenNumber(), - screen()->getWindowStyle()->l_text_focus_gc, - new_workspace_name.c_str(), l, - x, 1 + screen()->getToolbarStyle()->font.ascent()); + screen()->getToolbarStyle()->font.drawText( + frame.workspace_label, + screen()->getScreenNumber(), + screen()->getWindowStyle()->l_text_focus_gc, + new_workspace_name.c_str(), l, + x, 1 + screen()->getToolbarStyle()->font.ascent()); - XDrawRectangle(display, frame.workspace_label, - screen()->getWindowStyle()->l_text_focus_gc, x + tw, 0, 1, - frame.label_h - 1); - } + XDrawRectangle(display, frame.workspace_label, + screen()->getWindowStyle()->l_text_focus_gc, x + tw, 0, 1, + frame.label_h - 1); + } - } + } } void Toolbar::timeout() { - checkClock(true); + checkClock(true); - timeval delay; - delay.tv_sec = 1; - delay.tv_usec = 0; - clock_timer.setTimeout(delay); + timeval delay; + delay.tv_sec = 1; + delay.tv_usec = 0; + clock_timer.setTimeout(delay); } void Toolbar::HideHandler::timeout() { - if (toolbar->isEditing()) { // don't hide if we're editing workspace label - toolbar->hide_timer.fireOnce(false); - toolbar->hide_timer.start(); // restart timer and try next timeout - return; - } - toolbar->hide_timer.fireOnce(true); + if (toolbar->isEditing()) { // don't hide if we're editing workspace label + toolbar->hide_timer.fireOnce(false); + toolbar->hide_timer.start(); // restart timer and try next timeout + return; + } + toolbar->hide_timer.fireOnce(true); - toolbar->hidden = ! toolbar->hidden; - if (toolbar->hidden) { - XMoveWindow(toolbar->display, toolbar->frame.window, - toolbar->frame.x_hidden, toolbar->frame.y_hidden); - } else { - XMoveWindow(toolbar->display, toolbar->frame.window, - toolbar->frame.x, toolbar->frame.y); - } + toolbar->hidden = ! toolbar->hidden; + if (toolbar->hidden) { + XMoveWindow(toolbar->display, toolbar->frame.window, + toolbar->frame.x_hidden, toolbar->frame.y_hidden); + } else { + XMoveWindow(toolbar->display, toolbar->frame.window, + toolbar->frame.x, toolbar->frame.y); + } } Toolbarmenu::Toolbarmenu(Toolbar &tb) : Basemenu(tb.screen()), m_toolbar(tb), -m_placementmenu(*this) { + m_placementmenu(*this) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - ToolbarSet, ToolbarToolbarTitle, - "Toolbar")); - setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + ToolbarSet, ToolbarToolbarTitle, + "Toolbar")); + setInternalMenu(); #ifdef XINERAMA - if (m_toolbar.screen()->hasXinerama()) { // only create if we need it - m_headmenu.reset(new Headmenu(this)); - } + if (m_toolbar.screen()->hasXinerama()) { // only create if we need it + m_headmenu.reset(new Headmenu(this)); + } #endif // XINERAMA - insert(i18n->getMessage( - CommonSet, CommonPlacementTitle, - "Placement"), - &m_placementmenu); + insert(i18n->getMessage( + CommonSet, CommonPlacementTitle, + "Placement"), + &m_placementmenu); - if (m_headmenu.get()) { //TODO: NLS - insert(i18n->getMessage(0, 0, "Place on Head"), m_headmenu.get()); - } + if (m_headmenu.get()) { //TODO: NLS + insert(i18n->getMessage(0, 0, "Place on Head"), m_headmenu.get()); + } - insert(i18n->getMessage( - CommonSet, CommonAlwaysOnTop, - "Always on top"), - 1); - insert(i18n->getMessage( - CommonSet, CommonAutoHide, - "Auto hide"), - 2); - insert(i18n->getMessage( - ToolbarSet, ToolbarEditWkspcName, - "Edit current workspace name"), - 3); + insert(i18n->getMessage( + CommonSet, CommonAlwaysOnTop, + "Always on top"), + 1); + insert(i18n->getMessage( + CommonSet, CommonAutoHide, + "Auto hide"), + 2); + insert(i18n->getMessage( + ToolbarSet, ToolbarEditWkspcName, + "Edit current workspace name"), + 3); - update(); + update(); - if (m_toolbar.isOnTop()) - setItemSelected(1, true); - if (m_toolbar.doAutoHide()) - setItemSelected(2, true); + if (m_toolbar.isOnTop()) + setItemSelected(1, true); + if (m_toolbar.doAutoHide()) + setItemSelected(2, true); }

@@ -1122,168 +1122,168 @@ }

void Toolbarmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (item == 0) - return; + if (button == 1) { + BasemenuItem *item = find(index); + if (item == 0) + return; - switch (item->function()) { - case 1: {// always on top - bool change = ((m_toolbar.isOnTop()) ? false : true); - m_toolbar.on_top = change; - screen()->saveToolbarOnTop(m_toolbar.on_top); - setItemSelected(1, change); + switch (item->function()) { + case 1: {// always on top + bool change = ((m_toolbar.isOnTop()) ? false : true); + m_toolbar.on_top = change; + screen()->saveToolbarOnTop(m_toolbar.on_top); + setItemSelected(1, change); - if (m_toolbar.isOnTop()) - m_toolbar.screen()->raiseWindows(Workspace::Stack()); + if (m_toolbar.isOnTop()) + m_toolbar.screen()->raiseWindows(Workspace::Stack()); - Fluxbox::instance()->save_rc(); - break; - } + Fluxbox::instance()->save_rc(); + break; + } - case 2: { // auto hide - bool change = ((m_toolbar.doAutoHide()) ? false : true); - m_toolbar.do_auto_hide = change; - screen()->saveToolbarAutoHide(m_toolbar.do_auto_hide); - setItemSelected(2, change); + case 2: { // auto hide + bool change = ((m_toolbar.doAutoHide()) ? false : true); + m_toolbar.do_auto_hide = change; + screen()->saveToolbarAutoHide(m_toolbar.do_auto_hide); + setItemSelected(2, change); #ifdef SLIT - m_toolbar.screen()->getSlit()->reposition(); + m_toolbar.screen()->getSlit()->reposition(); #endif // SLIT - Fluxbox::instance()->save_rc(); - break; - } + Fluxbox::instance()->save_rc(); + break; + } - case 3: // edit current workspace name - m_toolbar.edit(); //set edit mode - hide(); //dont show menu while editing name + case 3: // edit current workspace name + m_toolbar.edit(); //set edit mode + hide(); //dont show menu while editing name - break; - } - } + break; + } + } } void Toolbarmenu::internal_hide() { - Basemenu::internal_hide(); - if (m_toolbar.doAutoHide() && ! m_toolbar.isEditing()) - m_toolbar.hide_handler.timeout(); + Basemenu::internal_hide(); + if (m_toolbar.doAutoHide() && ! m_toolbar.isEditing()) + m_toolbar.hide_handler.timeout(); } void Toolbarmenu::reconfigure() { - m_placementmenu.reconfigure(); + m_placementmenu.reconfigure(); - if (m_headmenu.get()) { - m_headmenu->reconfigure(); - } + if (m_headmenu.get()) { + m_headmenu->reconfigure(); + } - Basemenu::reconfigure(); + Basemenu::reconfigure(); } Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm) - : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) { + : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - ToolbarSet, ToolbarToolbarPlacement, - "Toolbar Placement")); - setInternalMenu(); - setMinimumSublevels(3); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + ToolbarSet, ToolbarToolbarPlacement, + "Toolbar Placement")); + setInternalMenu(); + setMinimumSublevels(3); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopLeft, - "Top Left"), - Toolbar::TOPLEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomLeft, - "Bottom Left"), - Toolbar::BOTTOMLEFT); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopCenter, - "Top Center"), - Toolbar::TOPCENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomCenter, - "Bottom Center"), - Toolbar::BOTTOMCENTER); - insert(i18n->getMessage( - CommonSet, CommonPlacementTopRight, - "Top Right"), - Toolbar::TOPRIGHT); - insert(i18n->getMessage( - CommonSet, CommonPlacementBottomRight, - "Bottom Right"), - Toolbar::BOTTOMRIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopLeft, + "Top Left"), + Toolbar::TOPLEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomLeft, + "Bottom Left"), + Toolbar::BOTTOMLEFT); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopCenter, + "Top Center"), + Toolbar::TOPCENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomCenter, + "Bottom Center"), + Toolbar::BOTTOMCENTER); + insert(i18n->getMessage( + CommonSet, CommonPlacementTopRight, + "Top Right"), + Toolbar::TOPRIGHT); + insert(i18n->getMessage( + CommonSet, CommonPlacementBottomRight, + "Bottom Right"), + Toolbar::BOTTOMRIGHT); - update(); + update(); } void Toolbarmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (! item) - return; + if (button == 1) { + BasemenuItem *item = find(index); + if (! item) + return; - m_toolbarmenu.m_toolbar.screen()->saveToolbarPlacement( - static_cast<Toolbar::Placement>(item->function())); - hide(); - m_toolbarmenu.m_toolbar.reconfigure(); + m_toolbarmenu.m_toolbar.screen()->saveToolbarPlacement( + static_cast<Toolbar::Placement>(item->function())); + hide(); + m_toolbarmenu.m_toolbar.reconfigure(); #ifdef SLIT - // reposition the slit as well to make sure it doesn't intersect the - // toolbar - m_toolbarmenu.m_toolbar.screen()->getSlit()->reposition(); + // reposition the slit as well to make sure it doesn't intersect the + // toolbar + m_toolbarmenu.m_toolbar.screen()->getSlit()->reposition(); #endif // SLIT - } + } } #ifdef XINERAMA Toolbarmenu::Headmenu::Headmenu(Toolbarmenu &tm) - : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) { + : Basemenu(tm.m_toolbar.screen()), m_toolbarmenu(tm) { - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS - setInternalMenu(); + setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS + setInternalMenu(); - int numHeads = toolbarmenu->toolbar->screen->getNumHeads(); - // fill menu with head entries - for (int i = 0; i < numHeads; i++) { - char headName[32]; - sprintf(headName, "Head %i", i+1); //TODO: NLS - insert(i18n->getMessage(0, 0, headName), i); - } + int numHeads = toolbarmenu->toolbar->screen->getNumHeads(); + // fill menu with head entries + for (int i = 0; i < numHeads; i++) { + char headName[32]; + sprintf(headName, "Head %i", i+1); //TODO: NLS + insert(i18n->getMessage(0, 0, headName), i); + } - insert(i18n->getMessage(0, 0, "All Heads"), -1); //TODO: NLS + insert(i18n->getMessage(0, 0, "All Heads"), -1); //TODO: NLS - update(); + update(); } void Toolbarmenu::Headmenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - BasemenuItem *item = find(index); - if (! item) - return; + if (button == 1) { + BasemenuItem *item = find(index); + if (! item) + return; - m_toolbarmenu.m_toolbar.screen()->saveToolbarOnHead( - static_cast<int>(item->function())); - hide(); - m_toolbarmenu.m_toolbar.reconfigure(); + m_toolbarmenu.m_toolbar.screen()->saveToolbarOnHead( + static_cast<int>(item->function())); + hide(); + m_toolbarmenu.m_toolbar.reconfigure(); #ifdef SLIT - // reposition the slit as well to make sure it doesn't intersect the - // toolbar - m_toolbarmenu.m_toolbar.screen()->getSlit()->reposition(); + // reposition the slit as well to make sure it doesn't intersect the + // toolbar + m_toolbarmenu.m_toolbar.screen()->getSlit()->reposition(); #endif // SLIT - } + } } #endif // XINERAMA
M src/Toolbar.hhsrc/Toolbar.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Toolbar.hh,v 1.14 2002/11/27 12:20:23 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.15 2002/12/01 13:42:02 rathnor Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH

@@ -41,48 +41,48 @@ @see Toolbar

*/ class Toolbarmenu:public Basemenu { public: - explicit Toolbarmenu(Toolbar &tb); - ~Toolbarmenu(); + explicit Toolbarmenu(Toolbar &tb); + ~Toolbarmenu(); - inline const Basemenu *headmenu() const { return m_headmenu.get(); } + inline const Basemenu *headmenu() const { return m_headmenu.get(); } - inline Basemenu *placementmenu() { return &m_placementmenu; } - inline const Basemenu *placementmenu() const { return &m_placementmenu; } + inline Basemenu *placementmenu() { return &m_placementmenu; } + inline const Basemenu *placementmenu() const { return &m_placementmenu; } - void reconfigure(); + void reconfigure(); protected: - virtual void itemSelected(int button, unsigned int index); - virtual void internal_hide(); + virtual void itemSelected(int button, unsigned int index); + virtual void internal_hide(); private: - class Placementmenu : public Basemenu { - public: - Placementmenu(Toolbarmenu &tm); - protected: - virtual void itemSelected(int button, unsigned int index); - private: - Toolbarmenu &m_toolbarmenu; - }; - friend class Placementmenu; + class Placementmenu : public Basemenu { + public: + Placementmenu(Toolbarmenu &tm); + protected: + virtual void itemSelected(int button, unsigned int index); + private: + Toolbarmenu &m_toolbarmenu; + }; + friend class Placementmenu; - class Headmenu : public Basemenu { - public: - Headmenu(Toolbarmenu &tm); - protected: - virtual void itemSelected(int button, unsigned int index); - private: - Toolbarmenu &m_toolbarmenu; - }; - std::auto_ptr<Headmenu> m_headmenu; - friend class Headmenu; + class Headmenu : public Basemenu { + public: + Headmenu(Toolbarmenu &tm); + protected: + virtual void itemSelected(int button, unsigned int index); + private: + Toolbarmenu &m_toolbarmenu; + }; + std::auto_ptr<Headmenu> m_headmenu; + friend class Headmenu; - Toolbar &m_toolbar; - Placementmenu m_placementmenu; + Toolbar &m_toolbar; + Placementmenu m_placementmenu; - friend class Toolbar; + friend class Toolbar; };

@@ -91,106 +91,106 @@ the toolbar.

*/ class Toolbar : public TimeoutHandler { public: - /** - Toolbar placement on the screen - */ - enum Placement{ TOPLEFT = 1, BOTTOMLEFT, TOPCENTER, - BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT }; + /** + Toolbar placement on the screen + */ + enum Placement{ TOPLEFT = 1, BOTTOMLEFT, TOPCENTER, + BOTTOMCENTER, TOPRIGHT, BOTTOMRIGHT }; - explicit Toolbar(BScreen *screen); - virtual ~Toolbar(); + explicit Toolbar(BScreen *screen); + virtual ~Toolbar(); - /// add icon to iconbar - void addIcon(FluxboxWindow *w); - /// remove icon from iconbar - void delIcon(FluxboxWindow *w); + /// add icon to iconbar + void addIcon(FluxboxWindow *w); + /// remove icon from iconbar + void delIcon(FluxboxWindow *w); - inline const Toolbarmenu &menu() const { return m_toolbarmenu; } - /// are we in workspacename editing? - inline bool isEditing() const { return editing; } - /// always on top? - inline bool isOnTop() const { return on_top; } - /// are we hidden? - inline bool isHidden() const { return hidden; } - /// do we auto hide the toolbar? - inline bool doAutoHide() const { return do_auto_hide; } - /// @return X window of the toolbar - inline Window getWindowID() const { return frame.window; } - inline BScreen *screen() { return m_screen; } - inline const BScreen *screen() const { return m_screen; } - inline unsigned int width() const { return frame.width; } - inline unsigned int height() const { return frame.height; } - inline unsigned int exposedHeight() const { return ((do_auto_hide) ? frame.bevel_w : frame.height); } - inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); } - inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); } - /// @return pointer to iconbar if it got one, else 0 - inline const IconBar *iconBar() const { return m_iconbar.get(); } - /** - @name eventhandlers - */ - //@{ - void buttonPressEvent(XButtonEvent *be); - void buttonReleaseEvent(XButtonEvent *be); - void enterNotifyEvent(XCrossingEvent *ce); - void leaveNotifyEvent(XCrossingEvent *ce); - void exposeEvent(XExposeEvent *ee); - void keyPressEvent(XKeyEvent *ke); - //@} + inline const Toolbarmenu &menu() const { return m_toolbarmenu; } + /// are we in workspacename editing? + inline bool isEditing() const { return editing; } + /// always on top? + inline bool isOnTop() const { return on_top; } + /// are we hidden? + inline bool isHidden() const { return hidden; } + /// do we auto hide the toolbar? + inline bool doAutoHide() const { return do_auto_hide; } + /// @return X window of the toolbar + inline Window getWindowID() const { return frame.window; } + inline BScreen *screen() { return m_screen; } + inline const BScreen *screen() const { return m_screen; } + inline unsigned int width() const { return frame.width; } + inline unsigned int height() const { return frame.height; } + inline unsigned int exposedHeight() const { return ((do_auto_hide) ? frame.bevel_w : frame.height); } + inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); } + inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); } + /// @return pointer to iconbar if it got one, else 0 + inline const IconBar *iconBar() const { return m_iconbar.get(); } + /** + @name eventhandlers + */ + //@{ + void buttonPressEvent(XButtonEvent *be); + void buttonReleaseEvent(XButtonEvent *be); + void enterNotifyEvent(XCrossingEvent *ce); + void leaveNotifyEvent(XCrossingEvent *ce); + void exposeEvent(XExposeEvent *ee); + void keyPressEvent(XKeyEvent *ke); + //@} - void redrawWindowLabel(bool redraw= false); - void redrawWorkspaceLabel(bool redraw= false); - void redrawPrevWorkspaceButton(bool pressed = false, bool redraw = false); - void redrawNextWorkspaceButton(bool pressed = false, bool redraw = false); - void redrawPrevWindowButton(bool pressed = false, bool redraw = false); - void redrawNextWindowButton(bool pressed = false, bool redraw = false); - /// enter edit mode on workspace label - void edit(); - void reconfigure(); + void redrawWindowLabel(bool redraw= false); + void redrawWorkspaceLabel(bool redraw= false); + void redrawPrevWorkspaceButton(bool pressed = false, bool redraw = false); + void redrawNextWorkspaceButton(bool pressed = false, bool redraw = false); + void redrawPrevWindowButton(bool pressed = false, bool redraw = false); + void redrawNextWindowButton(bool pressed = false, bool redraw = false); + /// enter edit mode on workspace label + void edit(); + void reconfigure(); - void checkClock(bool redraw = false, bool date = false); + void checkClock(bool redraw = false, bool date = false); - virtual void timeout(); + virtual void timeout(); private: - bool on_top; ///< always on top - bool editing; ///< edit workspace label mode - bool hidden; ///< hidden state - bool do_auto_hide; ///< do we auto hide - Display *display; ///< display connection + bool on_top; ///< always on top + bool editing; ///< edit workspace label mode + bool hidden; ///< hidden state + bool do_auto_hide; ///< do we auto hide + Display *display; ///< display connection - struct frame { - unsigned long button_pixel, pbutton_pixel; - Pixmap base, label, wlabel, clk, button, pbutton; - Window window, workspace_label, window_label, clock, psbutton, nsbutton, - pwbutton, nwbutton; + struct frame { + unsigned long button_pixel, pbutton_pixel; + Pixmap base, label, wlabel, clk, button, pbutton; + Window window, workspace_label, window_label, clock, psbutton, nsbutton, + pwbutton, nwbutton; - int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y; - unsigned int width, height, window_label_w, workspace_label_w, clock_w, - button_w, bevel_w, label_h; - } frame; + int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y; + unsigned int width, height, window_label_w, workspace_label_w, clock_w, + button_w, bevel_w, label_h; + } frame; - class HideHandler : public TimeoutHandler { - public: - Toolbar *toolbar; + class HideHandler : public TimeoutHandler { + public: + Toolbar *toolbar; - virtual void timeout(); - } hide_handler; + virtual void timeout(); + } hide_handler; - BScreen *m_screen; - BImageControl *image_ctrl; - BTimer clock_timer; ///< timer to update clock - BTimer hide_timer; ///< timer to for auto hide toolbar - Toolbarmenu m_toolbarmenu; - std::auto_ptr<IconBar> m_iconbar; + BScreen *m_screen; + BImageControl *image_ctrl; + BTimer clock_timer; ///< timer to update clock + BTimer hide_timer; ///< timer to for auto hide toolbar + Toolbarmenu m_toolbarmenu; + std::auto_ptr<IconBar> m_iconbar; - std::string new_workspace_name; ///< temp variable in edit workspace name mode + std::string new_workspace_name; ///< temp variable in edit workspace name mode - friend class HideHandler; - friend class Toolbarmenu; - friend class Toolbarmenu::Placementmenu; + friend class HideHandler; + friend class Toolbarmenu; + friend class Toolbarmenu::Placementmenu; - friend class Toolbarmenu::Headmenu; + friend class Toolbarmenu::Headmenu; };
M src/Window.ccsrc/Window.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Window.cc,v 1.105 2002/11/30 20:39:42 fluxgen Exp $ +// $Id: Window.cc,v 1.106 2002/12/01 13:42:03 rathnor Exp $ #include "Window.hh"

@@ -59,1501 +59,1501 @@

using namespace std; FluxboxWindow::FluxboxWindow(Window w, BScreen *s): -m_hintsig(*this), -m_statesig(*this), -m_workspacesig(*this), -image_ctrl(0), -moving(false), resizing(false), shaded(false), maximized(false), -visible(false), iconic(false), transient(false), focused(false), -stuck(false), modal(false), send_focus_message(false), managed(false), -screen(0), -timer(this), -display(0), -lastButtonPressTime(0), -m_windowmenu(0), -m_layer(LAYER_NORMAL), -tab(0) { + m_hintsig(*this), + m_statesig(*this), + m_workspacesig(*this), + image_ctrl(0), + moving(false), resizing(false), shaded(false), maximized(false), + visible(false), iconic(false), transient(false), focused(false), + stuck(false), modal(false), send_focus_message(false), managed(false), + screen(0), + timer(this), + display(0), + lastButtonPressTime(0), + m_windowmenu(0), + m_layer(LAYER_NORMAL), + tab(0) { - lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0; + lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0; #ifdef DEBUG - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::WindowSet, FBNLS::WindowCreating, - "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), - w); + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::WindowSet, FBNLS::WindowCreating, + "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), + w); #endif //DEBUG - Fluxbox *fluxbox = Fluxbox::instance(); - display = fluxbox->getXDisplay(); + Fluxbox *fluxbox = Fluxbox::instance(); + display = fluxbox->getXDisplay(); - blackbox_attrib.workspace = workspace_number = window_number = -1; + blackbox_attrib.workspace = workspace_number = window_number = -1; - blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l; - blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; - blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0; - //use tab as default - decorations.tab = true; - decorations.enabled = true; - client.window = w; - frame.window = frame.plate = frame.title = frame.handle = None; - frame.right_grip = frame.left_grip = None; + blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l; + blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; + blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0; + //use tab as default + decorations.tab = true; + decorations.enabled = true; + client.window = w; + frame.window = frame.plate = frame.title = frame.handle = None; + frame.right_grip = frame.left_grip = None; - frame.utitle = frame.ftitle = frame.uhandle = frame.fhandle = None; - frame.ulabel = frame.flabel = frame.ubutton = frame.fbutton = None; - frame.pbutton = frame.ugrip = frame.fgrip = None; + frame.utitle = frame.ftitle = frame.uhandle = frame.fhandle = None; + frame.ulabel = frame.flabel = frame.ubutton = frame.fbutton = None; + frame.pbutton = frame.ugrip = frame.fgrip = None; - //get decorations - vector<Fluxbox::Titlebar> dir = fluxbox->getTitlebarLeft(); - for (char c=0; c<2; c++) { - for (unsigned int i=0; i<dir.size(); i++) { - switch (dir[i]) { - case Fluxbox::SHADE: - decorations.shade = true; - break; - case Fluxbox::MAXIMIZE: - decorations.maximize = true; - break; - case Fluxbox::MINIMIZE: - decorations.iconify = true; - break; - case Fluxbox::STICK: - decorations.sticky = true; - break; - case Fluxbox::CLOSE: - decorations.close = true; - break; - case Fluxbox::MENU: - decorations.menu = true; - break; - default: - break; - } - } - //next right - dir = fluxbox->getTitlebarRight(); - } + //get decorations + vector<Fluxbox::Titlebar> dir = fluxbox->getTitlebarLeft(); + for (char c=0; c<2; c++) { + for (unsigned int i=0; i<dir.size(); i++) { + switch (dir[i]) { + case Fluxbox::SHADE: + decorations.shade = true; + break; + case Fluxbox::MAXIMIZE: + decorations.maximize = true; + break; + case Fluxbox::MINIMIZE: + decorations.iconify = true; + break; + case Fluxbox::STICK: + decorations.sticky = true; + break; + case Fluxbox::CLOSE: + decorations.close = true; + break; + case Fluxbox::MENU: + decorations.menu = true; + break; + default: + break; + } + } + //next right + dir = fluxbox->getTitlebarRight(); + } - decorations.menu = true; //override menu option + decorations.menu = true; //override menu option - decorations.titlebar = decorations.border = decorations.handle = true; - functions.resize = functions.move = functions.iconify = functions.maximize = true; - functions.close = decorations.close = false; + decorations.titlebar = decorations.border = decorations.handle = true; + functions.resize = functions.move = functions.iconify = functions.maximize = true; + functions.close = decorations.close = false; - client.wm_hint_flags = client.normal_hint_flags = 0; - client.transient_for = 0; - client.mwm_hint = (MwmHints *) 0; - client.blackbox_hint = 0; + client.wm_hint_flags = client.normal_hint_flags = 0; + client.transient_for = 0; + client.mwm_hint = (MwmHints *) 0; + client.blackbox_hint = 0; - fluxbox->grab(); - if (! validateClient()) - return; + fluxbox->grab(); + if (! validateClient()) + return; - // fetch client size and placement - XWindowAttributes wattrib; - if ((! XGetWindowAttributes(display, client.window, &wattrib)) || - (! wattrib.screen) || wattrib.override_redirect) { - fluxbox->ungrab(); - return; - } + // fetch client size and placement + XWindowAttributes wattrib; + if ((! XGetWindowAttributes(display, client.window, &wattrib)) || + (! wattrib.screen) || wattrib.override_redirect) { + fluxbox->ungrab(); + return; + } - if (s) - screen = s; - else - screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); + if (s) + screen = s; + else + screen = fluxbox->searchScreen(RootWindowOfScreen(wattrib.screen)); - if (!screen) { - fluxbox->ungrab(); - return; - } + if (!screen) { + fluxbox->ungrab(); + return; + } - image_ctrl = screen->getImageControl(); + image_ctrl = screen->getImageControl(); - client.x = wattrib.x; - client.y = wattrib.y; - client.width = wattrib.width; - client.height = wattrib.height; - client.old_bw = wattrib.border_width; + client.x = wattrib.x; + client.y = wattrib.y; + client.width = wattrib.width; + client.height = wattrib.height; + client.old_bw = wattrib.border_width; - timer.setTimeout(fluxbox->getAutoRaiseDelay()); - timer.fireOnce(true); + timer.setTimeout(fluxbox->getAutoRaiseDelay()); + timer.fireOnce(true); - getBlackboxHints(); - if (! client.blackbox_hint) - getMWMHints(); + getBlackboxHints(); + if (! client.blackbox_hint) + getMWMHints(); - // get size, aspect, minimum/maximum size and other hints set by the - // client - getWMProtocols(); - getWMHints(); - getWMNormalHints(); + // get size, aspect, minimum/maximum size and other hints set by the + // client + getWMProtocols(); + getWMHints(); + getWMNormalHints(); #ifdef SLIT - if (client.initial_state == WithdrawnState) { - screen->getSlit()->addClient(client.window); - fluxbox->ungrab(); - return; - } + if (client.initial_state == WithdrawnState) { + screen->getSlit()->addClient(client.window); + fluxbox->ungrab(); + return; + } #endif // SLIT - managed = true; //mark for usage + managed = true; //mark for usage - fluxbox->saveWindowSearch(client.window, this); + fluxbox->saveWindowSearch(client.window, this); - // determine if this is a transient window - checkTransient(); + // determine if this is a transient window + checkTransient(); - // adjust the window decorations based on transience and window sizes - if (transient) { - decorations.maximize = functions.maximize = false; - decorations.handle = decorations.border = false; - } + // adjust the window decorations based on transience and window sizes + if (transient) { + decorations.maximize = functions.maximize = false; + decorations.handle = decorations.border = false; + } - if ((client.normal_hint_flags & PMinSize) && - (client.normal_hint_flags & PMaxSize) && - client.max_width != 0 && client.max_width <= client.min_width && - client.max_height != 0 && client.max_height <= client.min_height) { - decorations.maximize = decorations.handle = - functions.resize = functions.maximize = false; - decorations.tab = false; //no tab for this window - } + if ((client.normal_hint_flags & PMinSize) && + (client.normal_hint_flags & PMaxSize) && + client.max_width != 0 && client.max_width <= client.min_width && + client.max_height != 0 && client.max_height <= client.min_height) { + decorations.maximize = decorations.handle = + functions.resize = functions.maximize = false; + decorations.tab = false; //no tab for this window + } - upsize(); + upsize(); - bool place_window = true; - if (fluxbox->isStartup() || transient || - client.normal_hint_flags & (PPosition|USPosition)) { - setGravityOffsets(); + bool place_window = true; + if (fluxbox->isStartup() || transient || + client.normal_hint_flags & (PPosition|USPosition)) { + setGravityOffsets(); - if (! fluxbox->isStartup()) { + if (! fluxbox->isStartup()) { #ifdef XINERAMA - unsigned int head = 0; - if (screen->hasXinerama()) { - head = screen->getHead(frame.x, frame.y); - } + unsigned int head = 0; + if (screen->hasXinerama()) { + head = screen->getHead(frame.x, frame.y); + } #endif // XINERAMA - int real_x = frame.x; - int real_y = frame.y; + int real_x = frame.x; + int real_y = frame.y; - if (decorations.tab) { - if (screen->getTabPlacement() == Tab::PTOP) { - real_y -= screen->getTabHeight(); - } else if (screen->getTabPlacement() == Tab::PLEFT) { - real_x -= (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - } - } + if (decorations.tab) { + if (screen->getTabPlacement() == Tab::PTOP) { + real_y -= screen->getTabHeight(); + } else if (screen->getTabPlacement() == Tab::PLEFT) { + real_x -= (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + } + } #ifdef XINERAMA - // check is within the current head, so it won't overlap heads - if (real_x >= screen->getHeadX(head) && - real_y + frame.y_border >= screen->getHeadY(head) && - (real_x + frame.width) <= - (screen->getHeadX(head) + screen->getHeadWidth(head)) && - (real_y + frame.height) <= - (screen->getHeadY(head) + screen->getHeadHeight(head)) ) - place_window = false; + // check is within the current head, so it won't overlap heads + if (real_x >= screen->getHeadX(head) && + real_y + frame.y_border >= screen->getHeadY(head) && + (real_x + frame.width) <= + (screen->getHeadX(head) + screen->getHeadWidth(head)) && + (real_y + frame.height) <= + (screen->getHeadY(head) + screen->getHeadHeight(head)) ) + place_window = false; #else // !XINERAMA - if (real_x >= 0 && - real_y + frame.y_border >= 0 && - real_x <= (signed) screen->getWidth() && - real_y <= (signed) screen->getHeight()) - place_window = false; + if (real_x >= 0 && + real_y + frame.y_border >= 0 && + real_x <= (signed) screen->getWidth() && + real_y <= (signed) screen->getHeight()) + place_window = false; #endif // XIENRAMA - } else - place_window = false; + } else + place_window = false; - } + } - frame.window = createToplevelWindow(frame.x, frame.y, frame.width, - frame.height, - screen->getBorderWidth()); //create frame window + frame.window = createToplevelWindow(frame.x, frame.y, frame.width, + frame.height, + screen->getBorderWidth()); //create frame window - fluxbox->saveWindowSearch(frame.window, this); //save frame window + fluxbox->saveWindowSearch(frame.window, this); //save frame window - frame.plate = createChildWindow(frame.window); //Create plate window - fluxbox->saveWindowSearch(frame.plate, this); //save plate window + frame.plate = createChildWindow(frame.window); //Create plate window + fluxbox->saveWindowSearch(frame.plate, this); //save plate window - createTitlebar(); - createHandle(); + createTitlebar(); + createHandle(); - associateClientWindow(); + associateClientWindow(); - grabButtons(); + grabButtons(); - positionWindows(); + positionWindows(); - // use tab? and don't create a tab on windows that's not - // maximizable as default (such as dialogs) - if (decorations.tab && fluxbox->useTabs() && isGroupable()) - tab = new Tab(this, 0, 0); + // use tab? and don't create a tab on windows that's not + // maximizable as default (such as dialogs) + if (decorations.tab && fluxbox->useTabs() && isGroupable()) + tab = new Tab(this, 0, 0); - decorate(); + decorate(); - XRaiseWindow(display, frame.plate); - XMapSubwindows(display, frame.plate); - if (decorations.titlebar) - XMapSubwindows(display, frame.title); + XRaiseWindow(display, frame.plate); + XMapSubwindows(display, frame.plate); + if (decorations.titlebar) + XMapSubwindows(display, frame.title); - XMapSubwindows(display, frame.window); + XMapSubwindows(display, frame.window); - if (decorations.menu) { - std::auto_ptr<Windowmenu> tmp(new Windowmenu(*this)); - m_windowmenu = tmp; - } + if (decorations.menu) { + std::auto_ptr<Windowmenu> tmp(new Windowmenu(*this)); + m_windowmenu = tmp; + } - if (workspace_number < 0 || workspace_number >= screen->getCount()) - screen->getCurrentWorkspace()->addWindow(this, place_window); - else - screen->getWorkspace(workspace_number)->addWindow(this, place_window); + if (workspace_number < 0 || workspace_number >= screen->getCount()) + screen->getCurrentWorkspace()->addWindow(this, place_window); + else + screen->getWorkspace(workspace_number)->addWindow(this, place_window); - configure(frame.x, frame.y, frame.width, frame.height); + configure(frame.x, frame.y, frame.width, frame.height); - if (shaded) { - shaded = false; - shade(); - } + if (shaded) { + shaded = false; + shade(); + } - if (maximized && functions.maximize) { - int m = maximized; - maximized = false; - maximize(m); - } + if (maximized && functions.maximize) { + int m = maximized; + maximized = false; + maximize(m); + } - if (stuck) { - stuck = false; - stick(); - deiconify(); //omnipresent, so show it - } + if (stuck) { + stuck = false; + stick(); + deiconify(); //omnipresent, so show it + } - setFocusFlag(false); + setFocusFlag(false); #ifdef DEBUG - fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); + fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); #endif // DEBUG - fluxbox->ungrab(); + fluxbox->ungrab(); } FluxboxWindow::~FluxboxWindow() { - if (screen == 0) //the window wasn't created - return; - timer.stop(); + if (screen == 0) //the window wasn't created + return; + timer.stop(); - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - if (moving || resizing) { - screen->hideGeometry(); - XUngrabPointer(display, CurrentTime); - } + if (moving || resizing) { + screen->hideGeometry(); + XUngrabPointer(display, CurrentTime); + } - if (!iconic) { - Workspace *workspace = screen->getWorkspace(workspace_number); - if (workspace) - workspace->removeWindow(this); - } else //it's iconic - screen->removeIcon(this); + if (!iconic) { + Workspace *workspace = screen->getWorkspace(workspace_number); + if (workspace) + workspace->removeWindow(this); + } else //it's iconic + screen->removeIcon(this); - if (tab != 0) { - delete tab; - tab = 0; - } + if (tab != 0) { + delete tab; + tab = 0; + } - if (client.mwm_hint != 0) { - XFree(client.mwm_hint); - client.mwm_hint = 0; - } + if (client.mwm_hint != 0) { + XFree(client.mwm_hint); + client.mwm_hint = 0; + } - if (client.blackbox_hint != 0) { - XFree(client.blackbox_hint); - client.blackbox_hint = 0; - } + if (client.blackbox_hint != 0) { + XFree(client.blackbox_hint); + client.blackbox_hint = 0; + } - if (client.transient_for != 0) { - if (client.transient_for == this) { - client.transient_for = 0; - } + if (client.transient_for != 0) { + if (client.transient_for == this) { + client.transient_for = 0; + } - fluxbox->setFocusedWindow(client.transient_for); + fluxbox->setFocusedWindow(client.transient_for); - if (client.transient_for) { - client.transient_for->client.transients.remove(this); - client.transient_for->setInputFocus(); - client.transient_for = 0; - } - } + if (client.transient_for) { + client.transient_for->client.transients.remove(this); + client.transient_for->setInputFocus(); + client.transient_for = 0; + } + } - while (!client.transients.empty()) { - client.transients.back()->client.transient_for = 0; - client.transients.pop_back(); - } + while (!client.transients.empty()) { + client.transients.back()->client.transient_for = 0; + client.transients.pop_back(); + } - if (client.window_group) { - fluxbox->removeGroupSearch(client.window_group); - client.window_group = 0; - } + if (client.window_group) { + fluxbox->removeGroupSearch(client.window_group); + client.window_group = 0; + } - destroyTitlebar(); + destroyTitlebar(); - destroyHandle(); + destroyHandle(); - if (frame.fbutton) { - image_ctrl->removeImage(frame.fbutton); - frame.fbutton = 0; - } + if (frame.fbutton) { + image_ctrl->removeImage(frame.fbutton); + frame.fbutton = 0; + } - if (frame.ubutton) { - image_ctrl->removeImage(frame.ubutton); - frame.ubutton = 0; - } + if (frame.ubutton) { + image_ctrl->removeImage(frame.ubutton); + frame.ubutton = 0; + } - if (frame.pbutton) { - image_ctrl->removeImage(frame.pbutton); - frame.pbutton = 0; - } + if (frame.pbutton) { + image_ctrl->removeImage(frame.pbutton); + frame.pbutton = 0; + } - if (frame.plate) { - fluxbox->removeWindowSearch(frame.plate); - XDestroyWindow(display, frame.plate); - frame.plate = 0; - } + if (frame.plate) { + fluxbox->removeWindowSearch(frame.plate); + XDestroyWindow(display, frame.plate); + frame.plate = 0; + } - if (frame.window) { - fluxbox->removeWindowSearch(frame.window); - XDestroyWindow(display, frame.window); - frame.window = 0; - } + if (frame.window) { + fluxbox->removeWindowSearch(frame.window); + XDestroyWindow(display, frame.window); + frame.window = 0; + } - fluxbox->removeWindowSearch(client.window); + fluxbox->removeWindowSearch(client.window); #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; #endif // DEBUG } bool FluxboxWindow::isGroupable() const { - if (isResizable() && isMaximizable() && !isTransient()) - return true; - return false; + if (isResizable() && isMaximizable() && !isTransient()) + return true; + return false; } Window FluxboxWindow::createToplevelWindow( - int x, int y, unsigned int width, - unsigned int height, - unsigned int borderwidth) + int x, int y, unsigned int width, + unsigned int height, + unsigned int borderwidth) { - XSetWindowAttributes attrib_create; - unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap | - CWOverrideRedirect | CWEventMask; + XSetWindowAttributes attrib_create; + unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap | + CWOverrideRedirect | CWEventMask; - attrib_create.background_pixmap = None; - attrib_create.colormap = screen->colormap(); - attrib_create.override_redirect = True; - attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask; + attrib_create.background_pixmap = None; + attrib_create.colormap = screen->colormap(); + attrib_create.override_redirect = True; + attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask; - return (XCreateWindow(display, screen->getRootWindow(), x, y, width, height, - borderwidth, screen->getDepth(), InputOutput, - screen->getVisual(), create_mask, - &attrib_create)); + return (XCreateWindow(display, screen->getRootWindow(), x, y, width, height, + borderwidth, screen->getDepth(), InputOutput, + screen->getVisual(), create_mask, + &attrib_create)); } Window FluxboxWindow::createChildWindow(Window parent, Cursor cursor) { - XSetWindowAttributes attrib_create; - unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask; + XSetWindowAttributes attrib_create; + unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask; - attrib_create.background_pixmap = None; - attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask | - EnterWindowMask | LeaveWindowMask; + attrib_create.background_pixmap = None; + attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | ExposureMask | + EnterWindowMask | LeaveWindowMask; - if (cursor) { - create_mask |= CWCursor; - attrib_create.cursor = cursor; - } + if (cursor) { + create_mask |= CWCursor; + attrib_create.cursor = cursor; + } - return (XCreateWindow(display, parent, 0, 0, 1, 1, 0, - screen->getDepth(), InputOutput, screen->getVisual(), - create_mask, &attrib_create)); + return (XCreateWindow(display, parent, 0, 0, 1, 1, 0, + screen->getDepth(), InputOutput, screen->getVisual(), + create_mask, &attrib_create)); } void FluxboxWindow::associateClientWindow() { - XSetWindowBorderWidth(display, client.window, 0); - getWMName(); - getWMIconName(); + XSetWindowBorderWidth(display, client.window, 0); + getWMName(); + getWMIconName(); - XChangeSaveSet(display, client.window, SetModeInsert); - XSetWindowAttributes attrib_set; + XChangeSaveSet(display, client.window, SetModeInsert); + XSetWindowAttributes attrib_set; - XSelectInput(display, frame.plate, NoEventMask); - XReparentWindow(display, client.window, frame.plate, 0, 0); - XSelectInput(display, frame.plate, SubstructureRedirectMask); + XSelectInput(display, frame.plate, NoEventMask); + XReparentWindow(display, client.window, frame.plate, 0, 0); + XSelectInput(display, frame.plate, SubstructureRedirectMask); - XFlush(display); + XFlush(display); - attrib_set.event_mask = - PropertyChangeMask | StructureNotifyMask | FocusChangeMask; - attrib_set.do_not_propagate_mask = - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; + attrib_set.event_mask = + PropertyChangeMask | StructureNotifyMask | FocusChangeMask; + attrib_set.do_not_propagate_mask = + ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; - XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate, - &attrib_set); + XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate, + &attrib_set); #ifdef SHAPE - if (Fluxbox::instance()->hasShapeExtensions()) { - XShapeSelectInput(display, client.window, ShapeNotifyMask); + if (Fluxbox::instance()->hasShapeExtensions()) { + XShapeSelectInput(display, client.window, ShapeNotifyMask); - int foo; - unsigned int ufoo; + int foo; + unsigned int ufoo; - XShapeQueryExtents(display, client.window, &frame.shaped, &foo, &foo, - &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo); + XShapeQueryExtents(display, client.window, &frame.shaped, &foo, &foo, + &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo); - if (frame.shaped) { - XShapeCombineShape(display, frame.window, ShapeBounding, - frame.mwm_border_w, frame.y_border + - frame.mwm_border_w, client.window, - ShapeBounding, ShapeSet); + if (frame.shaped) { + XShapeCombineShape(display, frame.window, ShapeBounding, + frame.mwm_border_w, frame.y_border + + frame.mwm_border_w, client.window, + ShapeBounding, ShapeSet); - int num = 1; - XRectangle xrect[2]; - xrect[0].x = xrect[0].y = 0; - xrect[0].width = frame.width; - xrect[0].height = frame.y_border; + int num = 1; + XRectangle xrect[2]; + xrect[0].x = xrect[0].y = 0; + xrect[0].width = frame.width; + xrect[0].height = frame.y_border; - if (decorations.handle) { - xrect[1].x = 0; - xrect[1].y = frame.y_handle; - xrect[1].width = frame.width; - xrect[1].height = frame.handle_h + screen->getBorderWidth(); - num++; - } + if (decorations.handle) { + xrect[1].x = 0; + xrect[1].y = frame.y_handle; + xrect[1].width = frame.width; + xrect[1].height = frame.handle_h + screen->getBorderWidth(); + num++; + } - XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, - xrect, num, ShapeUnion, Unsorted); - } - } + XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, + xrect, num, ShapeUnion, Unsorted); + } + } #endif // SHAPE - //create the buttons - if (decorations.iconify) - createButton(Fluxbox::MINIMIZE, FluxboxWindow::iconifyPressed_cb, - FluxboxWindow::iconifyButton_cb, FluxboxWindow::iconifyDraw_cb); - if (decorations.maximize) - createButton(Fluxbox::MAXIMIZE, FluxboxWindow::maximizePressed_cb, - FluxboxWindow::maximizeButton_cb, FluxboxWindow::maximizeDraw_cb); - if (decorations.close) - createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb, - FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb); - if (decorations.sticky) - createButton(Fluxbox::STICK, FluxboxWindow::stickyPressed_cb, - FluxboxWindow::stickyButton_cb, FluxboxWindow::stickyDraw_cb); + //create the buttons + if (decorations.iconify) + createButton(Fluxbox::MINIMIZE, FluxboxWindow::iconifyPressed_cb, + FluxboxWindow::iconifyButton_cb, FluxboxWindow::iconifyDraw_cb); + if (decorations.maximize) + createButton(Fluxbox::MAXIMIZE, FluxboxWindow::maximizePressed_cb, + FluxboxWindow::maximizeButton_cb, FluxboxWindow::maximizeDraw_cb); + if (decorations.close) + createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb, + FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb); + if (decorations.sticky) + createButton(Fluxbox::STICK, FluxboxWindow::stickyPressed_cb, + FluxboxWindow::stickyButton_cb, FluxboxWindow::stickyDraw_cb); - if (decorations.menu)//TODO - createButton(Fluxbox::MENU, 0, 0, 0); + if (decorations.menu)//TODO + createButton(Fluxbox::MENU, 0, 0, 0); - if (decorations.shade) - createButton(Fluxbox::SHADE, 0, FluxboxWindow::shadeButton_cb, FluxboxWindow::shadeDraw_cb); + if (decorations.shade) + createButton(Fluxbox::SHADE, 0, FluxboxWindow::shadeButton_cb, FluxboxWindow::shadeDraw_cb); - if (frame.ubutton) { - for (unsigned int i=0; i<buttonlist.size(); i++) - XSetWindowBackgroundPixmap(display, buttonlist[i].win, frame.ubutton); + if (frame.ubutton) { + for (unsigned int i=0; i<buttonlist.size(); i++) + XSetWindowBackgroundPixmap(display, buttonlist[i].win, frame.ubutton); - } else { - for (unsigned int i=0; i<buttonlist.size(); i++) - XSetWindowBackground(display, buttonlist[i].win, frame.ubutton_pixel); - } + } else { + for (unsigned int i=0; i<buttonlist.size(); i++) + XSetWindowBackground(display, buttonlist[i].win, frame.ubutton_pixel); + } } void FluxboxWindow::decorate() { - if (tab) - tab->decorate(); + if (tab) + tab->decorate(); - Pixmap tmp = frame.fbutton; - const FbTk::Texture *texture = &(screen->getWindowStyle()->b_focus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.fbutton = None; - frame.fbutton_pixel = texture->color().pixel(); - } else - frame.fbutton = - image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + Pixmap tmp = frame.fbutton; + const FbTk::Texture *texture = &(screen->getWindowStyle()->b_focus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.fbutton = None; + frame.fbutton_pixel = texture->color().pixel(); + } else + frame.fbutton = + image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.ubutton; - texture = &(screen->getWindowStyle()->b_unfocus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.ubutton = None; - frame.ubutton_pixel = texture->color().pixel(); - } else - frame.ubutton = - image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.ubutton; + texture = &(screen->getWindowStyle()->b_unfocus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.ubutton = None; + frame.ubutton_pixel = texture->color().pixel(); + } else + frame.ubutton = + image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.pbutton; - texture = &(screen->getWindowStyle()->b_pressed); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.pbutton = None; - frame.pbutton_pixel = texture->color().pixel(); - } else - frame.pbutton = - image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.pbutton; + texture = &(screen->getWindowStyle()->b_pressed); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.pbutton = None; + frame.pbutton_pixel = texture->color().pixel(); + } else + frame.pbutton = + image_ctrl->renderImage(frame.button_w, frame.button_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - if (decorations.titlebar) { - tmp = frame.ftitle; - texture = &(screen->getWindowStyle()->t_focus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.ftitle = None; - frame.ftitle_pixel = texture->color().pixel(); - } else - frame.ftitle = - image_ctrl->renderImage(frame.width, frame.title_h, *texture); + if (decorations.titlebar) { + tmp = frame.ftitle; + texture = &(screen->getWindowStyle()->t_focus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.ftitle = None; + frame.ftitle_pixel = texture->color().pixel(); + } else + frame.ftitle = + image_ctrl->renderImage(frame.width, frame.title_h, *texture); - if (tmp) - image_ctrl->removeImage(tmp); + if (tmp) + image_ctrl->removeImage(tmp); - tmp = frame.utitle; - texture = &(screen->getWindowStyle()->t_unfocus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.utitle = None; - frame.utitle_pixel = texture->color().pixel(); - } else - frame.utitle = - image_ctrl->renderImage(frame.width, frame.title_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.utitle; + texture = &(screen->getWindowStyle()->t_unfocus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.utitle = None; + frame.utitle_pixel = texture->color().pixel(); + } else + frame.utitle = + image_ctrl->renderImage(frame.width, frame.title_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - XSetWindowBorder(display, frame.title, + XSetWindowBorder(display, frame.title, screen->getBorderColor()->pixel()); - decorateLabel(); + decorateLabel(); - } + } - if (decorations.border) { - frame.fborder_pixel = screen->getWindowStyle()->f_focus.pixel(); - frame.uborder_pixel = screen->getWindowStyle()->f_unfocus.pixel(); - } + if (decorations.border) { + frame.fborder_pixel = screen->getWindowStyle()->f_focus.pixel(); + frame.uborder_pixel = screen->getWindowStyle()->f_unfocus.pixel(); + } - if (decorations.handle) { - tmp = frame.fhandle; - texture = &(screen->getWindowStyle()->h_focus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.fhandle = None; - frame.fhandle_pixel = texture->color().pixel(); - } else - frame.fhandle = - image_ctrl->renderImage(frame.width, frame.handle_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + if (decorations.handle) { + tmp = frame.fhandle; + texture = &(screen->getWindowStyle()->h_focus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.fhandle = None; + frame.fhandle_pixel = texture->color().pixel(); + } else + frame.fhandle = + image_ctrl->renderImage(frame.width, frame.handle_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.uhandle; - texture = &(screen->getWindowStyle()->h_unfocus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.uhandle = None; - frame.uhandle_pixel = texture->color().pixel(); - } else - frame.uhandle = - image_ctrl->renderImage(frame.width, frame.handle_h, *texture); - if (tmp) - image_ctrl->removeImage(tmp); + tmp = frame.uhandle; + texture = &(screen->getWindowStyle()->h_unfocus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.uhandle = None; + frame.uhandle_pixel = texture->color().pixel(); + } else + frame.uhandle = + image_ctrl->renderImage(frame.width, frame.handle_h, *texture); + if (tmp) + image_ctrl->removeImage(tmp); - tmp = frame.fgrip; - texture = &(screen->getWindowStyle()->g_focus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.fgrip = None; - frame.fgrip_pixel = texture->color().pixel(); - } else - frame.fgrip = - image_ctrl->renderImage(frame.grip_w, frame.grip_h, *texture); - if (tmp) - image_ctrl->removeImage(tmp); + tmp = frame.fgrip; + texture = &(screen->getWindowStyle()->g_focus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.fgrip = None; + frame.fgrip_pixel = texture->color().pixel(); + } else + frame.fgrip = + image_ctrl->renderImage(frame.grip_w, frame.grip_h, *texture); + if (tmp) + image_ctrl->removeImage(tmp); - tmp = frame.ugrip; - texture = &(screen->getWindowStyle()->g_unfocus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.ugrip = None; - frame.ugrip_pixel = texture->color().pixel(); - } else - frame.ugrip = - image_ctrl->renderImage(frame.grip_w, frame.grip_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + tmp = frame.ugrip; + texture = &(screen->getWindowStyle()->g_unfocus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.ugrip = None; + frame.ugrip_pixel = texture->color().pixel(); + } else + frame.ugrip = + image_ctrl->renderImage(frame.grip_w, frame.grip_h, *texture); + if (tmp) image_ctrl->removeImage(tmp); - XSetWindowBorder(display, frame.handle, - screen->getBorderColor()->pixel()); - XSetWindowBorder(display, frame.left_grip, - screen->getBorderColor()->pixel()); - XSetWindowBorder(display, frame.right_grip, - screen->getBorderColor()->pixel()); - } + XSetWindowBorder(display, frame.handle, + screen->getBorderColor()->pixel()); + XSetWindowBorder(display, frame.left_grip, + screen->getBorderColor()->pixel()); + XSetWindowBorder(display, frame.right_grip, + screen->getBorderColor()->pixel()); + } - XSetWindowBorder(display, frame.window, - screen->getBorderColor()->pixel()); + XSetWindowBorder(display, frame.window, + screen->getBorderColor()->pixel()); } void FluxboxWindow::decorateLabel() { - Pixmap tmp = frame.flabel; - FbTk::Texture *texture = &(screen->getWindowStyle()->l_focus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.flabel = None; - frame.flabel_pixel = texture->color().pixel(); - } else - frame.flabel = image_ctrl->renderImage(frame.label_w, frame.label_h, *texture); + Pixmap tmp = frame.flabel; + FbTk::Texture *texture = &(screen->getWindowStyle()->l_focus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.flabel = None; + frame.flabel_pixel = texture->color().pixel(); + } else + frame.flabel = image_ctrl->renderImage(frame.label_w, frame.label_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + if (tmp) image_ctrl->removeImage(tmp); - tmp = frame.ulabel; - texture = &(screen->getWindowStyle()->l_unfocus); - if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - frame.ulabel = None; - frame.ulabel_pixel = texture->color().pixel(); - } else - frame.ulabel = image_ctrl->renderImage(frame.label_w, frame.label_h, *texture); + tmp = frame.ulabel; + texture = &(screen->getWindowStyle()->l_unfocus); + if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { + frame.ulabel = None; + frame.ulabel_pixel = texture->color().pixel(); + } else + frame.ulabel = image_ctrl->renderImage(frame.label_w, frame.label_h, *texture); - if (tmp) image_ctrl->removeImage(tmp); + if (tmp) image_ctrl->removeImage(tmp); } void FluxboxWindow::grabButtons() { - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - XGrabButton(display, Button1, AnyModifier, + XGrabButton(display, Button1, AnyModifier, frame.plate, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None); - XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, frame.plate); + XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, frame.plate); - XGrabButton(display, Button1, Mod1Mask, frame.window, True, + XGrabButton(display, Button1, Mod1Mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, fluxbox->getMoveCursor()); - //----grab with "all" modifiers - grabButton(display, Button1, frame.window, fluxbox->getMoveCursor()); + //----grab with "all" modifiers + grabButton(display, Button1, frame.window, fluxbox->getMoveCursor()); - XGrabButton(display, Button2, Mod1Mask, frame.window, True, + XGrabButton(display, Button2, Mod1Mask, frame.window, True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); - XGrabButton(display, Button3, Mod1Mask, frame.window, True, + XGrabButton(display, Button3, Mod1Mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, fluxbox->getLowerRightAngleCursor()); - //---grab with "all" modifiers - grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); + //---grab with "all" modifiers + grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); } void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventProc released, ButtonDrawProc draw) { - Button b; - b.win = createChildWindow(frame.title); - Fluxbox::instance()->saveWindowSearch(b.win, this); - b.type = type; - b.used = true; - b.draw = draw; - b.pressed = pressed; - b.released = released; - buttonlist.push_back(b); + Button b; + b.win = createChildWindow(frame.title); + Fluxbox::instance()->saveWindowSearch(b.win, this); + b.type = type; + b.used = true; + b.draw = draw; + b.pressed = pressed; + b.released = released; + buttonlist.push_back(b); } Window FluxboxWindow::findTitleButton(int type) { - for (unsigned int i=0; i<buttonlist.size(); i++) { - if (buttonlist[i].type == type) - return buttonlist[i].win; - } - return 0; + for (unsigned int i=0; i<buttonlist.size(); i++) { + if (buttonlist[i].type == type) + return buttonlist[i].win; + } + return 0; } void FluxboxWindow::stickyButton_cb(FluxboxWindow *t, XButtonEvent *be) { - t->stick(); - FluxboxWindow::stickyDraw_cb(t, be->window, false); + t->stick(); + FluxboxWindow::stickyDraw_cb(t, be->window, false); } void FluxboxWindow::stickyPressed_cb(FluxboxWindow *t, XButtonEvent *be) { - FluxboxWindow::stickyDraw_cb(t, be->window, true); + FluxboxWindow::stickyDraw_cb(t, be->window, true); } void FluxboxWindow::iconifyButton_cb(FluxboxWindow *t, XButtonEvent *be) { - t->iconify(); - FluxboxWindow::iconifyDraw_cb(t, be->window, false); + t->iconify(); + FluxboxWindow::iconifyDraw_cb(t, be->window, false); } void FluxboxWindow::iconifyPressed_cb(FluxboxWindow *t, XButtonEvent *be) { - t->screen->getWorkspace(t->workspace_number)->lowerWindow(t); - FluxboxWindow::iconifyDraw_cb(t, be->window, true); + t->screen->getWorkspace(t->workspace_number)->lowerWindow(t); + FluxboxWindow::iconifyDraw_cb(t, be->window, true); } void FluxboxWindow::maximizeButton_cb(FluxboxWindow *t, XButtonEvent *be) { - FluxboxWindow::maximizeDraw_cb(t, be->window, false); - t->maximize(be->button); + FluxboxWindow::maximizeDraw_cb(t, be->window, false); + t->maximize(be->button); } void FluxboxWindow::maximizePressed_cb(FluxboxWindow *t, XButtonEvent *be) { - FluxboxWindow::maximizeDraw_cb(t, be->window, true); + FluxboxWindow::maximizeDraw_cb(t, be->window, true); } void FluxboxWindow::closeButton_cb(FluxboxWindow *t, XButtonEvent *be) { - t->close(); - FluxboxWindow::closeDraw_cb(t, be->window, false); + t->close(); + FluxboxWindow::closeDraw_cb(t, be->window, false); } void FluxboxWindow::closePressed_cb(FluxboxWindow *t, XButtonEvent *be) { - FluxboxWindow::closeDraw_cb(t, be->window, true); + FluxboxWindow::closeDraw_cb(t, be->window, true); } void FluxboxWindow::shadeButton_cb(FluxboxWindow *t, XButtonEvent *be) { - FluxboxWindow::shadeDraw_cb(t, be->window, false); - t->shade(); - if (t->tab) - t->tab->shade(); + FluxboxWindow::shadeDraw_cb(t, be->window, false); + t->shade(); + if (t->tab) + t->tab->shade(); } void FluxboxWindow::stickyDraw_cb(FluxboxWindow *t, Window w, bool pressed) { - t->drawButtonBase(w, pressed); - if (t->stuck) { - XFillRectangle(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->drawButtonBase(w, pressed); + if (t->stuck) { + XFillRectangle(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : t->screen->getWindowStyle()->b_pic_unfocus_gc), - t->frame.button_w/2-t->frame.button_w/4, t->frame.button_h/2-t->frame.button_h/4, - t->frame.button_w/2, t->frame.button_h/2); - } else { - XFillRectangle(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->frame.button_w/2-t->frame.button_w/4, t->frame.button_h/2-t->frame.button_h/4, + t->frame.button_w/2, t->frame.button_h/2); + } else { + XFillRectangle(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : t->screen->getWindowStyle()->b_pic_unfocus_gc), - t->frame.button_w/2, t->frame.button_h/2, - t->frame.button_w/5, t->frame.button_h/5); - } + t->frame.button_w/2, t->frame.button_h/2, + t->frame.button_w/5, t->frame.button_h/5); + } } void FluxboxWindow::iconifyDraw_cb(FluxboxWindow *t, Window w, bool pressed) { - t->drawButtonBase(w, pressed); - XDrawRectangle(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : - t->screen->getWindowStyle()->b_pic_unfocus_gc), - 2, t->frame.button_h - 5, t->frame.button_w - 5, 2); + t->drawButtonBase(w, pressed); + XDrawRectangle(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->screen->getWindowStyle()->b_pic_unfocus_gc), + 2, t->frame.button_h - 5, t->frame.button_w - 5, 2); } void FluxboxWindow::maximizeDraw_cb(FluxboxWindow *t, Window w, bool pressed) { - t->drawButtonBase(w, pressed); - XDrawRectangle(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : - t->screen->getWindowStyle()->b_pic_unfocus_gc), - 2, 2, t->frame.button_w - 5, t->frame.button_h - 5); - XDrawLine(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : - t->screen->getWindowStyle()->b_pic_unfocus_gc), - 2, 3, t->frame.button_w - 3, 3); + t->drawButtonBase(w, pressed); + XDrawRectangle(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->screen->getWindowStyle()->b_pic_unfocus_gc), + 2, 2, t->frame.button_w - 5, t->frame.button_h - 5); + XDrawLine(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->screen->getWindowStyle()->b_pic_unfocus_gc), + 2, 3, t->frame.button_w - 3, 3); } void FluxboxWindow::closeDraw_cb(FluxboxWindow *t, Window w, bool pressed) { - t->drawButtonBase(w, pressed); - XDrawLine(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : - t->screen->getWindowStyle()->b_pic_unfocus_gc), 2, 2, - t->frame.button_w - 3, t->frame.button_h - 3); - XDrawLine(t->display, w, - ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : - t->screen->getWindowStyle()->b_pic_unfocus_gc), 2, - t->frame.button_h - 3, - t->frame.button_w - 3, 2); + t->drawButtonBase(w, pressed); + XDrawLine(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->screen->getWindowStyle()->b_pic_unfocus_gc), 2, 2, + t->frame.button_w - 3, t->frame.button_h - 3); + XDrawLine(t->display, w, + ((t->focused) ? t->screen->getWindowStyle()->b_pic_focus_gc : + t->screen->getWindowStyle()->b_pic_unfocus_gc), 2, + t->frame.button_h - 3, + t->frame.button_w - 3, 2); } void FluxboxWindow::shadeDraw_cb(FluxboxWindow *t, Window w, bool pressed) { - t->drawButtonBase(w, pressed); + t->drawButtonBase(w, pressed); } void FluxboxWindow::grabButton(Display *display, unsigned int button, - Window window, Cursor cursor) { + Window window, Cursor cursor) { - //numlock - XGrabButton(display, button, Mod1Mask|Mod2Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); - //scrolllock - XGrabButton(display, button, Mod1Mask|Mod5Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //numlock + XGrabButton(display, button, Mod1Mask|Mod2Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); + //scrolllock + XGrabButton(display, button, Mod1Mask|Mod5Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); - //capslock - XGrabButton(display, button, Mod1Mask|LockMask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //capslock + XGrabButton(display, button, Mod1Mask|LockMask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); - //capslock+numlock - XGrabButton(display, Button1, Mod1Mask|LockMask|Mod2Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //capslock+numlock + XGrabButton(display, Button1, Mod1Mask|LockMask|Mod2Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); - //capslock+scrolllock - XGrabButton(display, button, Mod1Mask|LockMask|Mod5Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //capslock+scrolllock + XGrabButton(display, button, Mod1Mask|LockMask|Mod5Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); - //capslock+numlock+scrolllock - XGrabButton(display, button, Mod1Mask|LockMask|Mod2Mask|Mod5Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //capslock+numlock+scrolllock + XGrabButton(display, button, Mod1Mask|LockMask|Mod2Mask|Mod5Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); - //numlock+scrollLock - XGrabButton(display, button, Mod1Mask|Mod2Mask|Mod5Mask, window, True, - ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, - GrabModeAsync, None, cursor); + //numlock+scrollLock + XGrabButton(display, button, Mod1Mask|Mod2Mask|Mod5Mask, window, True, + ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, + GrabModeAsync, None, cursor); } void FluxboxWindow::drawButtonBase(Window w, bool pressed) { - if (! pressed) { - if (focused) { - if (frame.fbutton) - XSetWindowBackgroundPixmap(display, w, frame.fbutton); - else - XSetWindowBackground(display, w, frame.fbutton_pixel); - } else { - if (frame.ubutton) - XSetWindowBackgroundPixmap(display, w, frame.ubutton); - else - XSetWindowBackground(display, w, frame.ubutton_pixel); - } - } else { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, w, frame.pbutton); - else - XSetWindowBackground(display, w, frame.pbutton_pixel); - } - XClearWindow(display, w); + if (! pressed) { + if (focused) { + if (frame.fbutton) + XSetWindowBackgroundPixmap(display, w, frame.fbutton); + else + XSetWindowBackground(display, w, frame.fbutton_pixel); + } else { + if (frame.ubutton) + XSetWindowBackgroundPixmap(display, w, frame.ubutton); + else + XSetWindowBackground(display, w, frame.ubutton_pixel); + } + } else { + if (frame.pbutton) + XSetWindowBackgroundPixmap(display, w, frame.pbutton); + else + XSetWindowBackground(display, w, frame.pbutton_pixel); + } + XClearWindow(display, w); } void FluxboxWindow::positionButtons(bool redecorate_label) { - unsigned int bw = frame.button_w + frame.bevel_w + 1, - by = frame.bevel_w + 1, lx = by, lw = frame.width - by; - Fluxbox *fluxbox = Fluxbox::instance(); - vector<Fluxbox::Titlebar> left = fluxbox->getTitlebarLeft(); - vector<Fluxbox::Titlebar> right = fluxbox->getTitlebarRight(); + unsigned int bw = frame.button_w + frame.bevel_w + 1, + by = frame.bevel_w + 1, lx = by, lw = frame.width - by; + Fluxbox *fluxbox = Fluxbox::instance(); + vector<Fluxbox::Titlebar> left = fluxbox->getTitlebarLeft(); + vector<Fluxbox::Titlebar> right = fluxbox->getTitlebarRight(); - //left side buttons - for (unsigned int i=0; i<left.size(); i++) { - Window w = findTitleButton(left[i]); //get Window of button - if (w) { - XMoveResizeWindow(display, w, lx, by, - frame.button_w, frame.button_h); - XMapWindow(display, w); - XClearWindow(display, w); - lx += bw; - lw -= bw; - } - } + //left side buttons + for (unsigned int i=0; i<left.size(); i++) { + Window w = findTitleButton(left[i]); //get Window of button + if (w) { + XMoveResizeWindow(display, w, lx, by, + frame.button_w, frame.button_h); + XMapWindow(display, w); + XClearWindow(display, w); + lx += bw; + lw -= bw; + } + } - int bx = frame.width - bw; + int bx = frame.width - bw; - //right side buttons - for (int i=right.size()-1; i>=0; i--) { - Window w = findTitleButton(right[i]); //get window of button - if (w) { - XMoveResizeWindow(display, w, bx, by, - frame.button_w, frame.button_h); - XMapWindow(display, w); - XClearWindow(display, w); - bx -= bw; - lw -= bw; - } - } + //right side buttons + for (int i=right.size()-1; i>=0; i--) { + Window w = findTitleButton(right[i]); //get window of button + if (w) { + XMoveResizeWindow(display, w, bx, by, + frame.button_w, frame.button_h); + XMapWindow(display, w); + XClearWindow(display, w); + bx -= bw; + lw -= bw; + } + } - //Draw the label - frame.label_w = lw - by; - XMoveResizeWindow(display, frame.label, lx, frame.bevel_w, - frame.label_w, frame.label_h); - if (redecorate_label) - decorateLabel(); - if (tab) { - tab->setPosition(); - tab->draw(false); - } - redrawLabel(); - redrawAllButtons(); + //Draw the label + frame.label_w = lw - by; + XMoveResizeWindow(display, frame.label, lx, frame.bevel_w, + frame.label_w, frame.label_h); + if (redecorate_label) + decorateLabel(); + if (tab) { + tab->setPosition(); + tab->draw(false); + } + redrawLabel(); + redrawAllButtons(); } void FluxboxWindow::reconfigure() { - upsize(); + upsize(); - if (Fluxbox::instance()->useTabs()) { - //no tab and we allowed to use tab? then create it - if (!tab && isGroupable()) { - tab = new Tab(this, 0, 0); - if (current_state == IconicState) - tab->iconify(); - else if (current_state == WithdrawnState) - tab->withdraw(); - } - } else { - if (tab != 0) { //got a tab? then destroy it - delete tab; - tab = 0; - } - } + if (Fluxbox::instance()->useTabs()) { + //no tab and we allowed to use tab? then create it + if (!tab && isGroupable()) { + tab = new Tab(this, 0, 0); + if (current_state == IconicState) + tab->iconify(); + else if (current_state == WithdrawnState) + tab->withdraw(); + } + } else { + if (tab != 0) { //got a tab? then destroy it + delete tab; + tab = 0; + } + } - client.x = frame.x + frame.mwm_border_w + screen->getBorderWidth(); - client.y = frame.y + frame.y_border + frame.mwm_border_w + - screen->getBorderWidth(); + client.x = frame.x + frame.mwm_border_w + screen->getBorderWidth(); + client.y = frame.y + frame.y_border + frame.mwm_border_w + + screen->getBorderWidth(); - if (getTitle().size() > 0) { - client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); + if (getTitle().size() > 0) { + client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); - client.title_text_w += (frame.bevel_w * 4); - } + client.title_text_w += (frame.bevel_w * 4); + } - positionWindows(); - decorate(); + positionWindows(); + decorate(); - XClearWindow(display, frame.window); - setFocusFlag(focused); + XClearWindow(display, frame.window); + setFocusFlag(focused); - configure(frame.x, frame.y, frame.width, frame.height); + configure(frame.x, frame.y, frame.width, frame.height); - grabButtons(); + grabButtons(); - if (m_windowmenu.get()) { - m_windowmenu->move(m_windowmenu->x(), frame.y + frame.title_h); - m_windowmenu->reconfigure(); - } + if (m_windowmenu.get()) { + m_windowmenu->move(m_windowmenu->x(), frame.y + frame.title_h); + m_windowmenu->reconfigure(); + } } void FluxboxWindow::positionWindows() { - XResizeWindow(display, frame.window, frame.width, - ((shaded) ? frame.title_h : frame.height)); - XSetWindowBorderWidth(display, frame.window, screen->getBorderWidth()); - XSetWindowBorderWidth(display, frame.plate, screen->getFrameWidth() * - decorations.border); - XMoveResizeWindow(display, frame.plate, 0, frame.y_border, - client.width, client.height); - XMoveResizeWindow(display, client.window, 0, 0, client.width, client.height); + XResizeWindow(display, frame.window, frame.width, + ((shaded) ? frame.title_h : frame.height)); + XSetWindowBorderWidth(display, frame.window, screen->getBorderWidth()); + XSetWindowBorderWidth(display, frame.plate, screen->getFrameWidth() * + decorations.border); + XMoveResizeWindow(display, frame.plate, 0, frame.y_border, + client.width, client.height); + XMoveResizeWindow(display, client.window, 0, 0, client.width, client.height); - if (decorations.titlebar) { - XSetWindowBorderWidth(display, frame.title, screen->getBorderWidth()); - XMoveResizeWindow(display, frame.title, -screen->getBorderWidth(), - -screen->getBorderWidth(), frame.width, frame.title_h); + if (decorations.titlebar) { + XSetWindowBorderWidth(display, frame.title, screen->getBorderWidth()); + XMoveResizeWindow(display, frame.title, -screen->getBorderWidth(), + -screen->getBorderWidth(), frame.width, frame.title_h); - positionButtons(); - } else if (frame.title) - XUnmapWindow(display, frame.title); + positionButtons(); + } else if (frame.title) + XUnmapWindow(display, frame.title); - if (decorations.handle) { - XSetWindowBorderWidth(display, frame.handle, screen->getBorderWidth()); - XSetWindowBorderWidth(display, frame.left_grip, screen->getBorderWidth()); - XSetWindowBorderWidth(display, frame.right_grip, screen->getBorderWidth()); + if (decorations.handle) { + XSetWindowBorderWidth(display, frame.handle, screen->getBorderWidth()); + XSetWindowBorderWidth(display, frame.left_grip, screen->getBorderWidth()); + XSetWindowBorderWidth(display, frame.right_grip, screen->getBorderWidth()); - XMoveResizeWindow(display, frame.handle, -screen->getBorderWidth(), - frame.y_handle - screen->getBorderWidth(), - frame.width, frame.handle_h); - XMoveResizeWindow(display, frame.left_grip, -screen->getBorderWidth(), - -screen->getBorderWidth(), frame.grip_w, frame.grip_h); - XMoveResizeWindow(display, frame.right_grip, - frame.width - frame.grip_w - screen->getBorderWidth(), - -screen->getBorderWidth(), frame.grip_w, frame.grip_h); - XMapSubwindows(display, frame.handle); - } else if (frame.handle) - XUnmapWindow(display, frame.handle); - if (tab) - tab->setPosition(); + XMoveResizeWindow(display, frame.handle, -screen->getBorderWidth(), + frame.y_handle - screen->getBorderWidth(), + frame.width, frame.handle_h); + XMoveResizeWindow(display, frame.left_grip, -screen->getBorderWidth(), + -screen->getBorderWidth(), frame.grip_w, frame.grip_h); + XMoveResizeWindow(display, frame.right_grip, + frame.width - frame.grip_w - screen->getBorderWidth(), + -screen->getBorderWidth(), frame.grip_w, frame.grip_h); + XMapSubwindows(display, frame.handle); + } else if (frame.handle) + XUnmapWindow(display, frame.handle); + if (tab) + tab->setPosition(); } void FluxboxWindow::getWMName() { - XTextProperty text_prop; - char **list; - int num; - I18n *i18n = I18n::instance(); + XTextProperty text_prop; + char **list; + int num; + I18n *i18n = I18n::instance(); - if (XGetWMName(display, client.window, &text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding != XA_STRING) { + if (XGetWMName(display, client.window, &text_prop)) { + if (text_prop.value && text_prop.nitems > 0) { + if (text_prop.encoding != XA_STRING) { - text_prop.nitems = strlen((char *) text_prop.value); + text_prop.nitems = strlen((char *) text_prop.value); - if ((XmbTextPropertyToTextList(display, &text_prop, - &list, &num) == Success) && - (num > 0) && *list) { - client.title = static_cast<char *>(*list); - XFreeStringList(list); - } else - client.title = (char *)text_prop.value; + if ((XmbTextPropertyToTextList(display, &text_prop, + &list, &num) == Success) && + (num > 0) && *list) { + client.title = static_cast<char *>(*list); + XFreeStringList(list); + } else + client.title = (char *)text_prop.value; - } else - client.title = (char *)text_prop.value; - XFree((char *) text_prop.value); - } else - client.title = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } else { - client.title = i18n->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); - } - //Note: repeated? - client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); - client.title_text_w += (frame.bevel_w * 4); + } else + client.title = (char *)text_prop.value; + XFree((char *) text_prop.value); + } else + client.title = i18n->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnnamed, + "Unnamed"); + } else { + client.title = i18n->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnnamed, + "Unnamed"); + } + //Note: repeated? + client.title_text_w = screen->getWindowStyle()->font.textWidth(getTitle().c_str(), getTitle().size()); + client.title_text_w += (frame.bevel_w * 4); } void FluxboxWindow::getWMIconName() { - XTextProperty text_prop; - char **list; - int num; + XTextProperty text_prop; + char **list; + int num; - if (XGetWMIconName(display, client.window, &text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding != XA_STRING) { - text_prop.nitems = strlen((char *) text_prop.value); + if (XGetWMIconName(display, client.window, &text_prop)) { + if (text_prop.value && text_prop.nitems > 0) { + if (text_prop.encoding != XA_STRING) { + text_prop.nitems = strlen((char *) text_prop.value); - if ((XmbTextPropertyToTextList(display, &text_prop, - &list, &num) == Success) && - (num > 0) && *list) { - client.icon_title = (char *)*list; - XFreeStringList(list); - } else - client.icon_title = (char *)text_prop.value; - } else - client.icon_title = (char *)text_prop.value; + if ((XmbTextPropertyToTextList(display, &text_prop, + &list, &num) == Success) && + (num > 0) && *list) { + client.icon_title = (char *)*list; + XFreeStringList(list); + } else + client.icon_title = (char *)text_prop.value; + } else + client.icon_title = (char *)text_prop.value; - XFree((char *) text_prop.value); - } else - client.icon_title = getTitle(); - } else - client.icon_title = getTitle(); + XFree((char *) text_prop.value); + } else + client.icon_title = getTitle(); + } else + client.icon_title = getTitle(); } void FluxboxWindow::getWMProtocols() { - Atom *proto; - int num_return = 0; - Fluxbox *fluxbox = Fluxbox::instance(); + Atom *proto; + int num_return = 0; + Fluxbox *fluxbox = Fluxbox::instance(); - if (XGetWMProtocols(display, client.window, &proto, &num_return)) { - for (int i = 0; i < num_return; ++i) { - if (proto[i] == fluxbox->getWMDeleteAtom()) - functions.close = decorations.close = true; - else if (proto[i] == fluxbox->getWMTakeFocusAtom()) - send_focus_message = true; - else if (proto[i] == fluxbox->getFluxboxStructureMessagesAtom()) - screen->addNetizen(new Netizen(screen, client.window)); - } + if (XGetWMProtocols(display, client.window, &proto, &num_return)) { + for (int i = 0; i < num_return; ++i) { + if (proto[i] == fluxbox->getWMDeleteAtom()) + functions.close = decorations.close = true; + else if (proto[i] == fluxbox->getWMTakeFocusAtom()) + send_focus_message = true; + else if (proto[i] == fluxbox->getFluxboxStructureMessagesAtom()) + screen->addNetizen(new Netizen(screen, client.window)); + } - XFree(proto); - } + XFree(proto); + } } void FluxboxWindow::getWMHints() { - XWMHints *wmhint = XGetWMHints(display, client.window); - if (! wmhint) { - visible = true; - iconic = false; - focus_mode = F_PASSIVE; - client.window_group = None; - client.initial_state = NormalState; - } else { - client.wm_hint_flags = wmhint->flags; - if (wmhint->flags & InputHint) { - if (wmhint->input) { - if (send_focus_message) - focus_mode = F_LOCALLYACTIVE; - else - focus_mode = F_PASSIVE; - } else { - if (send_focus_message) - focus_mode = F_GLOBALLYACTIVE; - else - focus_mode = F_NOINPUT; - } - } else - focus_mode = F_PASSIVE; + XWMHints *wmhint = XGetWMHints(display, client.window); + if (! wmhint) { + visible = true; + iconic = false; + focus_mode = F_PASSIVE; + client.window_group = None; + client.initial_state = NormalState; + } else { + client.wm_hint_flags = wmhint->flags; + if (wmhint->flags & InputHint) { + if (wmhint->input) { + if (send_focus_message) + focus_mode = F_LOCALLYACTIVE; + else + focus_mode = F_PASSIVE; + } else { + if (send_focus_message) + focus_mode = F_GLOBALLYACTIVE; + else + focus_mode = F_NOINPUT; + } + } else + focus_mode = F_PASSIVE; - if (wmhint->flags & StateHint) - client.initial_state = wmhint->initial_state; - else - client.initial_state = NormalState; + if (wmhint->flags & StateHint) + client.initial_state = wmhint->initial_state; + else + client.initial_state = NormalState; - if (wmhint->flags & WindowGroupHint) { - if (! client.window_group) { - client.window_group = wmhint->window_group; - Fluxbox::instance()->saveGroupSearch(client.window_group, this); - } - } else - client.window_group = None; + if (wmhint->flags & WindowGroupHint) { + if (! client.window_group) { + client.window_group = wmhint->window_group; + Fluxbox::instance()->saveGroupSearch(client.window_group, this); + } + } else + client.window_group = None; - XFree(wmhint); - } + XFree(wmhint); + } } void FluxboxWindow::getWMNormalHints() { - long icccm_mask; - XSizeHints sizehint; - if (! XGetWMNormalHints(display, client.window, &sizehint, &icccm_mask)) { - client.min_width = client.min_height = - client.base_width = client.base_height = - client.width_inc = client.height_inc = 1; - client.max_width = 0; // unbounded - client.max_height = 0; - client.min_aspect_x = client.min_aspect_y = - client.max_aspect_x = client.max_aspect_y = 1; - client.win_gravity = NorthWestGravity; - } else { - client.normal_hint_flags = sizehint.flags; + long icccm_mask; + XSizeHints sizehint; + if (! XGetWMNormalHints(display, client.window, &sizehint, &icccm_mask)) { + client.min_width = client.min_height = + client.base_width = client.base_height = + client.width_inc = client.height_inc = 1; + client.max_width = 0; // unbounded + client.max_height = 0; + client.min_aspect_x = client.min_aspect_y = + client.max_aspect_x = client.max_aspect_y = 1; + client.win_gravity = NorthWestGravity; + } else { + client.normal_hint_flags = sizehint.flags; - if (sizehint.flags & PMinSize) { - client.min_width = sizehint.min_width; - client.min_height = sizehint.min_height; - } else - client.min_width = client.min_height = 1; + if (sizehint.flags & PMinSize) { + client.min_width = sizehint.min_width; + client.min_height = sizehint.min_height; + } else + client.min_width = client.min_height = 1; - if (sizehint.flags & PMaxSize) { - client.max_width = sizehint.max_width; - client.max_height = sizehint.max_height; - } else { - client.max_width = 0; // unbounded - client.max_height = 0; - } + if (sizehint.flags & PMaxSize) { + client.max_width = sizehint.max_width; + client.max_height = sizehint.max_height; + } else { + client.max_width = 0; // unbounded + client.max_height = 0; + } - if (sizehint.flags & PResizeInc) { - client.width_inc = sizehint.width_inc; - client.height_inc = sizehint.height_inc; - } else - client.width_inc = client.height_inc = 1; + if (sizehint.flags & PResizeInc) { + client.width_inc = sizehint.width_inc; + client.height_inc = sizehint.height_inc; + } else + client.width_inc = client.height_inc = 1; - if (sizehint.flags & PAspect) { - client.min_aspect_x = sizehint.min_aspect.x; - client.min_aspect_y = sizehint.min_aspect.y; - client.max_aspect_x = sizehint.max_aspect.x; - client.max_aspect_y = sizehint.max_aspect.y; - } else - client.min_aspect_x = client.min_aspect_y = - client.max_aspect_x = client.max_aspect_y = 1; + if (sizehint.flags & PAspect) { + client.min_aspect_x = sizehint.min_aspect.x; + client.min_aspect_y = sizehint.min_aspect.y; + client.max_aspect_x = sizehint.max_aspect.x; + client.max_aspect_y = sizehint.max_aspect.y; + } else + client.min_aspect_x = client.min_aspect_y = + client.max_aspect_x = client.max_aspect_y = 1; - if (sizehint.flags & PBaseSize) { - client.base_width = sizehint.base_width; - client.base_height = sizehint.base_height; - } else - client.base_width = client.base_height = 0; + if (sizehint.flags & PBaseSize) { + client.base_width = sizehint.base_width; + client.base_height = sizehint.base_height; + } else + client.base_width = client.base_height = 0; - if (sizehint.flags & PWinGravity) - client.win_gravity = sizehint.win_gravity; - else - client.win_gravity = NorthWestGravity; - } + if (sizehint.flags & PWinGravity) + client.win_gravity = sizehint.win_gravity; + else + client.win_gravity = NorthWestGravity; + } } void FluxboxWindow::getMWMHints() { - int format; - Atom atom_return; - unsigned long num, len; - Fluxbox *fluxbox = Fluxbox::instance(); - if (!XGetWindowProperty(display, client.window, - fluxbox->getMotifWMHintsAtom(), 0, - PropMwmHintsElements, false, - fluxbox->getMotifWMHintsAtom(), &atom_return, - &format, &num, &len, - (unsigned char **) &client.mwm_hint) == Success && - client.mwm_hint) { - return; - } - if (num != PropMwmHintsElements) - return; + int format; + Atom atom_return; + unsigned long num, len; + Fluxbox *fluxbox = Fluxbox::instance(); + if (!XGetWindowProperty(display, client.window, + fluxbox->getMotifWMHintsAtom(), 0, + PropMwmHintsElements, false, + fluxbox->getMotifWMHintsAtom(), &atom_return, + &format, &num, &len, + (unsigned char **) &client.mwm_hint) == Success && + client.mwm_hint) { + return; + } + if (num != PropMwmHintsElements) + return; - if (client.mwm_hint->flags & MwmHintsDecorations) { - if (client.mwm_hint->decorations & MwmDecorAll) { - decorations.titlebar = decorations.handle = decorations.border = - decorations.iconify = decorations.maximize = - decorations.close = decorations.menu = true; - } else { - decorations.titlebar = decorations.handle = decorations.border = - decorations.iconify = decorations.maximize = - decorations.close = decorations.tab = false; - decorations.menu = true; - if (client.mwm_hint->decorations & MwmDecorBorder) - decorations.border = true; - if (client.mwm_hint->decorations & MwmDecorHandle) - decorations.handle = true; - if (client.mwm_hint->decorations & MwmDecorTitle) - decorations.titlebar = decorations.tab = true; //only tab on windows with titlebar - if (client.mwm_hint->decorations & MwmDecorMenu) - decorations.menu = true; - if (client.mwm_hint->decorations & MwmDecorIconify) - decorations.iconify = true; - if (client.mwm_hint->decorations & MwmDecorMaximize) - decorations.maximize = true; - } - } + if (client.mwm_hint->flags & MwmHintsDecorations) { + if (client.mwm_hint->decorations & MwmDecorAll) { + decorations.titlebar = decorations.handle = decorations.border = + decorations.iconify = decorations.maximize = + decorations.close = decorations.menu = true; + } else { + decorations.titlebar = decorations.handle = decorations.border = + decorations.iconify = decorations.maximize = + decorations.close = decorations.tab = false; + decorations.menu = true; + if (client.mwm_hint->decorations & MwmDecorBorder) + decorations.border = true; + if (client.mwm_hint->decorations & MwmDecorHandle) + decorations.handle = true; + if (client.mwm_hint->decorations & MwmDecorTitle) + decorations.titlebar = decorations.tab = true; //only tab on windows with titlebar + if (client.mwm_hint->decorations & MwmDecorMenu) + decorations.menu = true; + if (client.mwm_hint->decorations & MwmDecorIconify) + decorations.iconify = true; + if (client.mwm_hint->decorations & MwmDecorMaximize) + decorations.maximize = true; + } + } - if (client.mwm_hint->flags & MwmHintsFunctions) { - if (client.mwm_hint->functions & MwmFuncAll) { - functions.resize = functions.move = functions.iconify = - functions.maximize = functions.close = true; - } else { - functions.resize = functions.move = functions.iconify = - functions.maximize = functions.close = false; + if (client.mwm_hint->flags & MwmHintsFunctions) { + if (client.mwm_hint->functions & MwmFuncAll) { + functions.resize = functions.move = functions.iconify = + functions.maximize = functions.close = true; + } else { + functions.resize = functions.move = functions.iconify = + functions.maximize = functions.close = false; - if (client.mwm_hint->functions & MwmFuncResize) - functions.resize = true; - if (client.mwm_hint->functions & MwmFuncMove) - functions.move = true; - if (client.mwm_hint->functions & MwmFuncIconify) - functions.iconify = true; - if (client.mwm_hint->functions & MwmFuncMaximize) - functions.maximize = true; - if (client.mwm_hint->functions & MwmFuncClose) - functions.close = true; - } - } + if (client.mwm_hint->functions & MwmFuncResize) + functions.resize = true; + if (client.mwm_hint->functions & MwmFuncMove) + functions.move = true; + if (client.mwm_hint->functions & MwmFuncIconify) + functions.iconify = true; + if (client.mwm_hint->functions & MwmFuncMaximize) + functions.maximize = true; + if (client.mwm_hint->functions & MwmFuncClose) + functions.close = true; + } + } } void FluxboxWindow::getBlackboxHints() { - int format; - Atom atom_return; - unsigned long num, len; - Fluxbox *fluxbox = Fluxbox::instance(); + int format; + Atom atom_return; + unsigned long num, len; + Fluxbox *fluxbox = Fluxbox::instance(); - if (XGetWindowProperty(display, client.window, - fluxbox->getFluxboxHintsAtom(), 0, - PropBlackboxHintsElements, False, - fluxbox->getFluxboxHintsAtom(), &atom_return, - &format, &num, &len, - (unsigned char **) &client.blackbox_hint) == Success && - client.blackbox_hint) { + if (XGetWindowProperty(display, client.window, + fluxbox->getFluxboxHintsAtom(), 0, + PropBlackboxHintsElements, False, + fluxbox->getFluxboxHintsAtom(), &atom_return, + &format, &num, &len, + (unsigned char **) &client.blackbox_hint) == Success && + client.blackbox_hint) { - if (num == PropBlackboxHintsElements) { - if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_SHADED) - shaded = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_SHADED); + if (num == PropBlackboxHintsElements) { + if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_SHADED) + shaded = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_SHADED); - if ((client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ) && - (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT)) - maximized = ((client.blackbox_hint->attrib & - (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? 1 : 0); - else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT) - maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); - else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ) - maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); + if ((client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ) && + (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT)) + maximized = ((client.blackbox_hint->attrib & + (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? 1 : 0); + else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXVERT) + maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); + else if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_MAXHORIZ) + maximized = ((client.blackbox_hint->attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); - if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_OMNIPRESENT) - stuck = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_OMNIPRESENT); + if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_OMNIPRESENT) + stuck = (client.blackbox_hint->attrib & BaseDisplay::ATTRIB_OMNIPRESENT); - if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_WORKSPACE) - workspace_number = client.blackbox_hint->workspace; + if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_WORKSPACE) + workspace_number = client.blackbox_hint->workspace; - if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_DECORATION) { - old_decoration = static_cast<Decoration>(client.blackbox_hint->decoration); - setDecoration(old_decoration); - } - } - } + if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_DECORATION) { + old_decoration = static_cast<Decoration>(client.blackbox_hint->decoration); + setDecoration(old_decoration); + } + } + } } void FluxboxWindow::configure(int dx, int dy, - unsigned int dw, unsigned int dh) { + unsigned int dw, unsigned int dh) { - //we don't want negative size - if (dw < 0 || dh < 0) - return; + //we don't want negative size + if (dw < 0 || dh < 0) + return; - bool send_event = (frame.x != dx || frame.y != dy); + bool send_event = (frame.x != dx || frame.y != dy); - if ((dw != frame.width) || (dh != frame.height)) { - if ((((signed) frame.width) + dx) < 0) - dx = 0; - if ((((signed) frame.height) + dy) < 0) - dy = 0; + if ((dw != frame.width) || (dh != frame.height)) { + if ((((signed) frame.width) + dx) < 0) + dx = 0; + if ((((signed) frame.height) + dy) < 0) + dy = 0; - frame.x = dx; - frame.y = dy; - frame.width = dw; - frame.height = dh; + frame.x = dx; + frame.y = dy; + frame.width = dw; + frame.height = dh; - downsize(); + downsize(); #ifdef SHAPE - if (Fluxbox::instance()->hasShapeExtensions() && frame.shaped) { - XShapeCombineShape(display, frame.window, ShapeBounding, - frame.mwm_border_w, frame.y_border + - frame.mwm_border_w, client.window, - ShapeBounding, ShapeSet); + if (Fluxbox::instance()->hasShapeExtensions() && frame.shaped) { + XShapeCombineShape(display, frame.window, ShapeBounding, + frame.mwm_border_w, frame.y_border + + frame.mwm_border_w, client.window, + ShapeBounding, ShapeSet); - int num = 1; - XRectangle xrect[2]; - xrect[0].x = xrect[0].y = 0; - xrect[0].width = frame.width; - xrect[0].height = frame.y_border; + int num = 1; + XRectangle xrect[2]; + xrect[0].x = xrect[0].y = 0; + xrect[0].width = frame.width; + xrect[0].height = frame.y_border; - if (decorations.handle) { - xrect[1].x = 0; - xrect[1].y = frame.y_handle; - xrect[1].width = frame.width; - xrect[1].height = frame.handle_h + screen->getBorderWidth(); - num++; - } + if (decorations.handle) { + xrect[1].x = 0; + xrect[1].y = frame.y_handle; + xrect[1].width = frame.width; + xrect[1].height = frame.handle_h + screen->getBorderWidth(); + num++; + } - XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, - xrect, num, ShapeUnion, Unsorted); - } + XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, + xrect, num, ShapeUnion, Unsorted); + } #endif // SHAPE - XMoveResizeWindow(display, frame.window, frame.x, frame.y, - frame.width, frame.height); - positionWindows(); - decorate(); - setFocusFlag(focused); - redrawAllButtons(); - shaded = false; - } else { - frame.x = dx; - frame.y = dy; + XMoveResizeWindow(display, frame.window, frame.x, frame.y, + frame.width, frame.height); + positionWindows(); + decorate(); + setFocusFlag(focused); + redrawAllButtons(); + shaded = false; + } else { + frame.x = dx; + frame.y = dy; - XMoveWindow(display, frame.window, frame.x, frame.y); - //move the tab and the chain - if (tab) - tab->setPosition(); + XMoveWindow(display, frame.window, frame.x, frame.y); + //move the tab and the chain + if (tab) + tab->setPosition(); - if (! moving) send_event = true; - } + if (! moving) send_event = true; + } - if (send_event && ! moving) { - client.x = dx + frame.mwm_border_w + screen->getBorderWidth(); - client.y = dy + frame.y_border + frame.mwm_border_w + - screen->getBorderWidth(); + if (send_event && ! moving) { + client.x = dx + frame.mwm_border_w + screen->getBorderWidth(); + client.y = dy + frame.y_border + frame.mwm_border_w + + screen->getBorderWidth(); - XEvent event; - event.type = ConfigureNotify; + XEvent event; + event.type = ConfigureNotify; - event.xconfigure.display = display; - event.xconfigure.event = client.window; - event.xconfigure.window = client.window; - event.xconfigure.x = client.x; - event.xconfigure.y = client.y; - event.xconfigure.width = client.width; - event.xconfigure.height = client.height; - event.xconfigure.border_width = client.old_bw; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = false; + event.xconfigure.display = display; + event.xconfigure.event = client.window; + event.xconfigure.window = client.window; + event.xconfigure.x = client.x; + event.xconfigure.y = client.y; + event.xconfigure.width = client.width; + event.xconfigure.height = client.height; + event.xconfigure.border_width = client.old_bw; + event.xconfigure.above = frame.window; + event.xconfigure.override_redirect = false; - XSendEvent(display, client.window, False, StructureNotifyMask, &event); + XSendEvent(display, client.window, False, StructureNotifyMask, &event); - screen->updateNetizenConfigNotify(&event); - } + screen->updateNetizenConfigNotify(&event); + } } bool FluxboxWindow::setInputFocus() { - //TODO hint skip focus + //TODO hint skip focus - if (((signed) (frame.x + frame.width)) < 0) { - if (((signed) (frame.y + frame.y_border)) < 0) - configure(screen->getBorderWidth(), screen->getBorderWidth(), - frame.width, frame.height); - else if (frame.y > (signed) screen->getHeight()) - configure(screen->getBorderWidth(), screen->getHeight() - frame.height, - frame.width, frame.height); - else - configure(screen->getBorderWidth(), frame.y + screen->getBorderWidth(), - frame.width, frame.height); - } else if (frame.x > (signed) screen->getWidth()) { - if (((signed) (frame.y + frame.y_border)) < 0) - configure(screen->getWidth() - frame.width, screen->getBorderWidth(), - frame.width, frame.height); - else if (frame.y > (signed) screen->getHeight()) - configure(screen->getWidth() - frame.width, - screen->getHeight() - frame.height, frame.width, frame.height); - else - configure(screen->getWidth() - frame.width, - frame.y + screen->getBorderWidth(), frame.width, frame.height); - } + if (((signed) (frame.x + frame.width)) < 0) { + if (((signed) (frame.y + frame.y_border)) < 0) + configure(screen->getBorderWidth(), screen->getBorderWidth(), + frame.width, frame.height); + else if (frame.y > (signed) screen->getHeight()) + configure(screen->getBorderWidth(), screen->getHeight() - frame.height, + frame.width, frame.height); + else + configure(screen->getBorderWidth(), frame.y + screen->getBorderWidth(), + frame.width, frame.height); + } else if (frame.x > (signed) screen->getWidth()) { + if (((signed) (frame.y + frame.y_border)) < 0) + configure(screen->getWidth() - frame.width, screen->getBorderWidth(), + frame.width, frame.height); + else if (frame.y > (signed) screen->getHeight()) + configure(screen->getWidth() - frame.width, + screen->getHeight() - frame.height, frame.width, frame.height); + else + configure(screen->getWidth() - frame.width, + frame.y + screen->getBorderWidth(), frame.width, frame.height); + } - if (! validateClient()) - return false; + if (! validateClient()) + return false; - bool ret = false; + bool ret = false; - if (client.transients.size() && modal) { - std::list<FluxboxWindow *>::iterator it = client.transients.begin(); - std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); - for (; it != it_end; ++it) { - if ((*it)->modal) - return (*it)->setInputFocus(); - } - } else { - if (focus_mode == F_LOCALLYACTIVE || focus_mode == F_PASSIVE) { - XSetInputFocus(display, client.window, - RevertToPointerRoot, CurrentTime); - } else { - return false; - } + if (client.transients.size() && modal) { + std::list<FluxboxWindow *>::iterator it = client.transients.begin(); + std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); + for (; it != it_end; ++it) { + if ((*it)->modal) + return (*it)->setInputFocus(); + } + } else { + if (focus_mode == F_LOCALLYACTIVE || focus_mode == F_PASSIVE) { + XSetInputFocus(display, client.window, + RevertToPointerRoot, CurrentTime); + } else { + return false; + } - Fluxbox *fb = Fluxbox::instance(); - fb->setFocusedWindow(this); + Fluxbox *fb = Fluxbox::instance(); + fb->setFocusedWindow(this); - if (send_focus_message) { - XEvent ce; - ce.xclient.type = ClientMessage; - ce.xclient.message_type = fb->getWMProtocolsAtom(); - ce.xclient.display = display; - ce.xclient.window = client.window; - ce.xclient.format = 32; - ce.xclient.data.l[0] = fb->getWMTakeFocusAtom(); - ce.xclient.data.l[1] = fb->getLastTime(); - ce.xclient.data.l[2] = 0l; - ce.xclient.data.l[3] = 0l; - ce.xclient.data.l[4] = 0l; - XSendEvent(display, client.window, false, NoEventMask, &ce); - } + if (send_focus_message) { + XEvent ce; + ce.xclient.type = ClientMessage; + ce.xclient.message_type = fb->getWMProtocolsAtom(); + ce.xclient.display = display; + ce.xclient.window = client.window; + ce.xclient.format = 32; + ce.xclient.data.l[0] = fb->getWMTakeFocusAtom(); + ce.xclient.data.l[1] = fb->getLastTime(); + ce.xclient.data.l[2] = 0l; + ce.xclient.data.l[3] = 0l; + ce.xclient.data.l[4] = 0l; + XSendEvent(display, client.window, false, NoEventMask, &ce); + } - if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) - && screen->doAutoRaise()) - timer.start(); + if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) + && screen->doAutoRaise()) + timer.start(); - ret = true; - } + ret = true; + } - return ret; + return ret; } //------------ setTab -------------- // Enables or disables the tab on the window //---------------------------------- void FluxboxWindow::setTab(bool flag) { - if (flag) { - if (!tab && isGroupable()) - tab = new Tab(this, 0, 0); + if (flag) { + if (!tab && isGroupable()) + tab = new Tab(this, 0, 0); - if (tab) { - tab->focus(); // draws the tab with correct texture - tab->setPosition(); // set tab windows position - } + if (tab) { + tab->focus(); // draws the tab with correct texture + tab->setPosition(); // set tab windows position + } - } else if (tab) { - delete tab; - tab = 0; - } - decorations.tab = flag; + } else if (tab) { + delete tab; + tab = 0; + } + decorations.tab = flag; } //------------- iconify ----------------

@@ -1561,144 +1561,144 @@ // Unmaps the window and removes it from workspace list

//-------------------------------------- void FluxboxWindow::iconify() { - if (iconic) - return; + if (iconic) + return; - if (m_windowmenu.get()) - m_windowmenu->hide(); + if (m_windowmenu.get()) + m_windowmenu->hide(); - setState(IconicState); + setState(IconicState); - XSelectInput(display, client.window, NoEventMask); - XUnmapWindow(display, client.window); - XSelectInput(display, client.window, - PropertyChangeMask | StructureNotifyMask | FocusChangeMask); + XSelectInput(display, client.window, NoEventMask); + XUnmapWindow(display, client.window); + XSelectInput(display, client.window, + PropertyChangeMask | StructureNotifyMask | FocusChangeMask); - XUnmapWindow(display, frame.window); - visible = false; - iconic = true; + XUnmapWindow(display, frame.window); + visible = false; + iconic = true; - screen->getWorkspace(workspace_number)->removeWindow(this); + screen->getWorkspace(workspace_number)->removeWindow(this); - if (client.transient_for) { - if (! client.transient_for->iconic) - client.transient_for->iconify(); - } - screen->addIcon(this); + if (client.transient_for) { + if (! client.transient_for->iconic) + client.transient_for->iconify(); + } + screen->addIcon(this); - if (tab) //if this window got a tab then iconify it too - tab->iconify(); + if (tab) //if this window got a tab then iconify it too + tab->iconify(); - if (client.transients.size()) { - std::list<FluxboxWindow *>::iterator it = client.transients.begin(); - std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); - for (; it != it_end; ++it) { - if (! (*it)->iconic) - (*it)->iconify(); - } - } + if (client.transients.size()) { + std::list<FluxboxWindow *>::iterator it = client.transients.begin(); + std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); + for (; it != it_end; ++it) { + if (! (*it)->iconic) + (*it)->iconify(); + } + } } void FluxboxWindow::deiconify(bool reassoc, bool raise) { - if (iconic || reassoc) { - screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false); - } else if (workspace_number != screen->getCurrentWorkspace()->workspaceID()) - return; + if (iconic || reassoc) { + screen->reassociateWindow(this, screen->getCurrentWorkspace()->workspaceID(), false); + } else if (workspace_number != screen->getCurrentWorkspace()->workspaceID()) + return; - setState(NormalState); + setState(NormalState); - XSelectInput(display, client.window, NoEventMask); - XMapWindow(display, client.window); - XSelectInput(display, client.window, - PropertyChangeMask | StructureNotifyMask | FocusChangeMask); + XSelectInput(display, client.window, NoEventMask); + XMapWindow(display, client.window); + XSelectInput(display, client.window, + PropertyChangeMask | StructureNotifyMask | FocusChangeMask); - XMapSubwindows(display, frame.window); - XMapWindow(display, frame.window); + XMapSubwindows(display, frame.window); + XMapWindow(display, frame.window); - if (iconic && screen->doFocusNew()) - setInputFocus(); + if (iconic && screen->doFocusNew()) + setInputFocus(); - visible = true; - iconic = false; + visible = true; + iconic = false; - if (reassoc && client.transients.size()) { - // deiconify all transients - std::list<FluxboxWindow *>::iterator it = client.transients.begin(); - std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); - for (; it != it_end; ++it) { - (*it)->deiconify(true, false); - } - } + if (reassoc && client.transients.size()) { + // deiconify all transients + std::list<FluxboxWindow *>::iterator it = client.transients.begin(); + std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); + for (; it != it_end; ++it) { + (*it)->deiconify(true, false); + } + } - if (tab) - tab->deiconify(); + if (tab) + tab->deiconify(); - if (raise) { - screen->getWorkspace(workspace_number)->raiseWindow(this); - if (tab) - tab->raise(); - } + if (raise) { + screen->getWorkspace(workspace_number)->raiseWindow(this); + if (tab) + tab->raise(); + } } void FluxboxWindow::close() { - Fluxbox *fluxbox = Fluxbox::instance(); - XEvent ce; - ce.xclient.type = ClientMessage; - ce.xclient.message_type = fluxbox->getWMProtocolsAtom(); - ce.xclient.display = display; - ce.xclient.window = client.window; - ce.xclient.format = 32; - ce.xclient.data.l[0] = fluxbox->getWMDeleteAtom(); - ce.xclient.data.l[1] = CurrentTime; - ce.xclient.data.l[2] = 0l; - ce.xclient.data.l[3] = 0l; - ce.xclient.data.l[4] = 0l; - XSendEvent(display, client.window, false, NoEventMask, &ce); + Fluxbox *fluxbox = Fluxbox::instance(); + XEvent ce; + ce.xclient.type = ClientMessage; + ce.xclient.message_type = fluxbox->getWMProtocolsAtom(); + ce.xclient.display = display; + ce.xclient.window = client.window; + ce.xclient.format = 32; + ce.xclient.data.l[0] = fluxbox->getWMDeleteAtom(); + ce.xclient.data.l[1] = CurrentTime; + ce.xclient.data.l[2] = 0l; + ce.xclient.data.l[3] = 0l; + ce.xclient.data.l[4] = 0l; + XSendEvent(display, client.window, false, NoEventMask, &ce); } void FluxboxWindow::withdraw() { - visible = false; - iconic = false; - if (isMoving()) - stopMoving(); - if (isResizing()) - stopResizing(); + visible = false; + iconic = false; + if (isMoving()) + stopMoving(); + if (isResizing()) + stopResizing(); - XUnmapWindow(display, frame.window); + XUnmapWindow(display, frame.window); - XSelectInput(display, client.window, NoEventMask); - XUnmapWindow(display, client.window); - XSelectInput(display, client.window, - PropertyChangeMask | StructureNotifyMask | FocusChangeMask); + XSelectInput(display, client.window, NoEventMask); + XUnmapWindow(display, client.window); + XSelectInput(display, client.window, + PropertyChangeMask | StructureNotifyMask | FocusChangeMask); - if (m_windowmenu.get()) - m_windowmenu->hide(); + if (m_windowmenu.get()) + m_windowmenu->hide(); - if (tab) - tab->withdraw(); + if (tab) + tab->withdraw(); } void FluxboxWindow::maximize(unsigned int button) { - // deiconify if we're iconic - if (isIconic()) - deiconify(); + // deiconify if we're iconic + if (isIconic()) + deiconify(); - if (! maximized) { - int dx, dy; - unsigned int dw, dh, slitModL = 0, slitModR = 0, slitModT = 0, slitModB = 0; + if (! maximized) { + int dx, dy; + unsigned int dw, dh, slitModL = 0, slitModR = 0, slitModT = 0, slitModB = 0; #ifdef XINERAMA - // get the head the window is on, taking the middle of the window to - // make it feel right, maybe someone will like client.x, client.y better - // tough? - unsigned int head = (screen->hasXinerama()) ? - screen->getHead(client.x + (client.width / 2), client.y + (client.height / 2)) - : 0; + // get the head the window is on, taking the middle of the window to + // make it feel right, maybe someone will like client.x, client.y better + // tough? + unsigned int head = (screen->hasXinerama()) ? + screen->getHead(client.x + (client.width / 2), client.y + (client.height / 2)) + : 0; #endif // XINERAMA

@@ -1710,58 +1710,58 @@ // (always true if we don't have xinerama

if (!screen->hasXinerama() || screen->getSlitOnHead() == head) { #endif // XINERAMA - Slit* mSlt = screen->getSlit(); + Slit* mSlt = screen->getSlit(); - if(!screen->doMaxOverSlit() && !screen->doFullMax() && (mSlt->width() > 1)) + if(!screen->doMaxOverSlit() && !screen->doFullMax() && (mSlt->width() > 1)) { - switch(screen->getSlitDirection()) + switch(screen->getSlitDirection()) { case Slit::VERTICAL: - switch(screen->getSlitPlacement()) + switch(screen->getSlitPlacement()) { case Slit::TOPRIGHT: case Slit::CENTERRIGHT: case Slit::BOTTOMRIGHT: - slitModR = mSlt->width() + screen->getBevelWidth(); - break; + slitModR = mSlt->width() + screen->getBevelWidth(); + break; default: - slitModL = mSlt->width() + screen->getBevelWidth(); - break; + slitModL = mSlt->width() + screen->getBevelWidth(); + break; } - break; + break; case Slit::HORIZONTAL: - switch(screen->getSlitPlacement()) + switch(screen->getSlitPlacement()) { case Slit::TOPLEFT: case Slit::TOPCENTER: case Slit::TOPRIGHT: - slitModT = mSlt->height() + screen->getBevelWidth(); - switch (screen->getToolbarPlacement()) { - case Toolbar::TOPLEFT: - case Toolbar::TOPCENTER: - case Toolbar::TOPRIGHT: - slitModT -= screen->getToolbar()->exposedHeight() + - screen->getBorderWidth(); - break; - default: - break; - } - break; + slitModT = mSlt->height() + screen->getBevelWidth(); + switch (screen->getToolbarPlacement()) { + case Toolbar::TOPLEFT: + case Toolbar::TOPCENTER: + case Toolbar::TOPRIGHT: + slitModT -= screen->getToolbar()->exposedHeight() + + screen->getBorderWidth(); + break; + default: + break; + } + break; default: - slitModB = mSlt->height() + screen->getBevelWidth(); - switch (screen->getToolbarPlacement()) { - case Toolbar::BOTTOMLEFT: - case Toolbar::BOTTOMCENTER: - case Toolbar::BOTTOMRIGHT: - slitModB -= screen->getToolbar()->exposedHeight() + - screen->getBorderWidth(); - break; - default: - break; - } - break; + slitModB = mSlt->height() + screen->getBevelWidth(); + switch (screen->getToolbarPlacement()) { + case Toolbar::BOTTOMLEFT: + case Toolbar::BOTTOMCENTER: + case Toolbar::BOTTOMRIGHT: + slitModB -= screen->getToolbar()->exposedHeight() + + screen->getBorderWidth(); + break; + default: + break; + } + break; } - break; + break; } } #ifdef XINERAMA

@@ -1770,810 +1770,810 @@ #endif // XINERAMA

#endif // SLIT - blackbox_attrib.premax_x = frame.x; - blackbox_attrib.premax_y = frame.y; - blackbox_attrib.premax_w = frame.width; - blackbox_attrib.premax_h = frame.height; + blackbox_attrib.premax_x = frame.x; + blackbox_attrib.premax_y = frame.y; + blackbox_attrib.premax_w = frame.width; + blackbox_attrib.premax_h = frame.height; #ifdef XINERAMA - dw = screen->getHeadWidth(head) - slitModL - slitModR; + dw = screen->getHeadWidth(head) - slitModL - slitModR; #else // !XINERAMA - dw = screen->getWidth() - slitModL - slitModR; + dw = screen->getWidth() - slitModL - slitModR; #endif // XINERAMA - dw -= screen->getBorderWidth2x(); - dw -= frame.mwm_border_w * 2; - dw -= client.base_width; + dw -= screen->getBorderWidth2x(); + dw -= frame.mwm_border_w * 2; + dw -= client.base_width; #ifdef XINERAMA - dh = screen->getHeadHeight(head) - slitModT - slitModB; + dh = screen->getHeadHeight(head) - slitModT - slitModB; #else // !XINERAMA - dh = screen->getHeight() - slitModT - slitModB; + dh = screen->getHeight() - slitModT - slitModB; #endif // XINERAMA - dh -= screen->getBorderWidth2x(); - dh -= frame.mwm_border_w * 2; - dh -= ((frame.handle_h + screen->getBorderWidth()) * decorations.handle); - dh -= client.base_height; - dh -= frame.y_border; + dh -= screen->getBorderWidth2x(); + dh -= frame.mwm_border_w * 2; + dh -= ((frame.handle_h + screen->getBorderWidth()) * decorations.handle); + dh -= client.base_height; + dh -= frame.y_border; - if (! screen->doFullMax()) { + if (! screen->doFullMax()) { #ifdef XINERAMA - if (screen->hasXinerama()) { + if (screen->hasXinerama()) { // is the toolbar on this head? - if ((screen->getToolbarOnHead() == (signed) head) || - (screen->getToolbarOnHead() < 0)) { - dh -= screen->getToolbar()->exposedHeight() + - screen->getBorderWidth2x(); - } - } else { - dh -= screen->getToolbar()->exposedHeight() + - screen->getBorderWidth2x(); - } + if ((screen->getToolbarOnHead() == (signed) head) || + (screen->getToolbarOnHead() < 0)) { + dh -= screen->getToolbar()->exposedHeight() + + screen->getBorderWidth2x(); + } + } else { + dh -= screen->getToolbar()->exposedHeight() + + screen->getBorderWidth2x(); + } #else // !XINERAMA - dh -= screen->getToolbar()->exposedHeight() + - screen->getBorderWidth2x(); + dh -= screen->getToolbar()->exposedHeight() + + screen->getBorderWidth2x(); #endif // XINERAMA - } + } - if (dw < client.min_width) dw = client.min_width; - if (dh < client.min_height) dh = client.min_height; - if (client.max_width != 0 && dw > client.max_width) dw = client.max_width; - if (client.max_height != 0 && dh > client.max_height) dh = client.max_height; + if (dw < client.min_width) dw = client.min_width; + if (dh < client.min_height) dh = client.min_height; + if (client.max_width != 0 && dw > client.max_width) dw = client.max_width; + if (client.max_height != 0 && dh > client.max_height) dh = client.max_height; - dw -= (dw % client.width_inc); - dw += client.base_width; - dh -= (dh % client.height_inc); - dh += client.base_height; + dw -= (dw % client.width_inc); + dw += client.base_width; + dh -= (dh % client.height_inc); + dh += client.base_height; - dw += frame.mwm_border_w * 2; + dw += frame.mwm_border_w * 2; - dh += frame.y_border; - dh += (frame.handle_h + screen->getBorderWidth()); - dh += frame.mwm_border_w * 2; + dh += frame.y_border; + dh += (frame.handle_h + screen->getBorderWidth()); + dh += frame.mwm_border_w * 2; #ifdef XINERAMA - dx = screen->getHeadX(head) + - ((screen->getHeadWidth(head) + slitModL - slitModR - dw) / 2) - - screen->getBorderWidth(); + dx = screen->getHeadX(head) + + ((screen->getHeadWidth(head) + slitModL - slitModR - dw) / 2) + - screen->getBorderWidth(); #else // !XINERAMA - dx = ((screen->getWidth()+ slitModL - slitModR - dw) / 2) - screen->getBorderWidth(); + dx = ((screen->getWidth()+ slitModL - slitModR - dw) / 2) - screen->getBorderWidth(); #endif // XINERAMA - if (screen->doFullMax()) { + if (screen->doFullMax()) { #ifdef XINERAMA - dy = screen->getHeadY(head) + - ((screen->getHeadHeight(head) - dh) / 2) - screen->getBorderWidth(); + dy = screen->getHeadY(head) + + ((screen->getHeadHeight(head) - dh) / 2) - screen->getBorderWidth(); #else // !XINERAMA - dy = ((screen->getHeight() - dh) / 2) - screen->getBorderWidth(); + dy = ((screen->getHeight() - dh) / 2) - screen->getBorderWidth(); #endif // XINERAMA - } else { + } else { #ifdef XINERAMA - if (screen->hasXinerama()) { // xinerama - dy = screen->getHeadY(head); + if (screen->hasXinerama()) { // xinerama + dy = screen->getHeadY(head); // is the toolbar on this head? - if ((screen->getToolbarOnHead() == (signed) head) || - (screen->getToolbarOnHead() < 0)) { - dy += (((screen->getHeadHeight(head) + slitModT - slitModB - - (screen->getToolbar()->exposedHeight())) - dh) / 2) - - screen->getBorderWidth2x(); - } else { - dy += ((screen->getHeadHeight(head) + slitModT - slitModB - dh) / 2) - - screen->getBorderWidth(); - } - } else { // no xinerama - dy = (((screen->getHeight() + slitModT - slitModB - - (screen->getToolbar()->exposedHeight())) - dh) / 2) - - screen->getBorderWidth2x(); - } + if ((screen->getToolbarOnHead() == (signed) head) || + (screen->getToolbarOnHead() < 0)) { + dy += (((screen->getHeadHeight(head) + slitModT - slitModB + - (screen->getToolbar()->exposedHeight())) - dh) / 2) + - screen->getBorderWidth2x(); + } else { + dy += ((screen->getHeadHeight(head) + slitModT - slitModB - dh) / 2) - + screen->getBorderWidth(); + } + } else { // no xinerama + dy = (((screen->getHeight() + slitModT - slitModB - + (screen->getToolbar()->exposedHeight())) - dh) / 2) - + screen->getBorderWidth2x(); + } #else // !XINERAMA - dy = (((screen->getHeight() + slitModT - slitModB - (screen->getToolbar()->exposedHeight())) - - dh) / 2) - screen->getBorderWidth2x(); + dy = (((screen->getHeight() + slitModT - slitModB - (screen->getToolbar()->exposedHeight())) + - dh) / 2) - screen->getBorderWidth2x(); #endif // XINERAMA - switch (screen->getToolbarPlacement()) { - case Toolbar::TOPLEFT: - case Toolbar::TOPCENTER: - case Toolbar::TOPRIGHT: + switch (screen->getToolbarPlacement()) { + case Toolbar::TOPLEFT: + case Toolbar::TOPCENTER: + case Toolbar::TOPRIGHT: #ifdef XINERAMA // if < 0 than it's over ALL heads, with no xinerama it's there too - if (!screen->hasXinerama() || - (screen->getToolbarOnHead() == (signed) head) || - (screen->getToolbarOnHead() < 0)) { - dy += screen->getToolbar()->exposedHeight() + - screen->getBorderWidth2x(); - } + if (!screen->hasXinerama() || + (screen->getToolbarOnHead() == (signed) head) || + (screen->getToolbarOnHead() < 0)) { + dy += screen->getToolbar()->exposedHeight() + + screen->getBorderWidth2x(); + } #else // !XINERAMA - dy += screen->getToolbar()->exposedHeight() + - screen->getBorderWidth2x(); + dy += screen->getToolbar()->exposedHeight() + + screen->getBorderWidth2x(); #endif // XINERAMA - break; - default: - break; - } - } + break; + default: + break; + } + } - if (hasTab()) { - switch(screen->getTabPlacement()) { - case Tab::PTOP: - dy += screen->getTabHeight(); - dh -= screen->getTabHeight(); - break; - case Tab::PLEFT: - if (screen->isTabRotateVertical()) { - dx += screen->getTabHeight(); - dw -= screen->getTabHeight(); - } else { - dx += screen->getTabWidth(); - dw -= screen->getTabWidth(); - } - break; - case Tab::PRIGHT: - if (screen->isTabRotateVertical()) - dw -= screen->getTabHeight(); - else - dw -= screen->getTabWidth(); - break; - case Tab::PBOTTOM: - dh -= screen->getTabHeight(); - break; - default: - dy += screen->getTabHeight(); - dh -= screen->getTabHeight(); - break; - } - } + if (hasTab()) { + switch(screen->getTabPlacement()) { + case Tab::PTOP: + dy += screen->getTabHeight(); + dh -= screen->getTabHeight(); + break; + case Tab::PLEFT: + if (screen->isTabRotateVertical()) { + dx += screen->getTabHeight(); + dw -= screen->getTabHeight(); + } else { + dx += screen->getTabWidth(); + dw -= screen->getTabWidth(); + } + break; + case Tab::PRIGHT: + if (screen->isTabRotateVertical()) + dw -= screen->getTabHeight(); + else + dw -= screen->getTabWidth(); + break; + case Tab::PBOTTOM: + dh -= screen->getTabHeight(); + break; + default: + dy += screen->getTabHeight(); + dh -= screen->getTabHeight(); + break; + } + } - if (button == 2) { //expand max width - dw = frame.width; - dx = frame.x; - } else if (button == 3) { //expand max height - dh = frame.height; - dy = frame.y; - } + if (button == 2) { //expand max width + dw = frame.width; + dx = frame.x; + } else if (button == 3) { //expand max height + dh = frame.height; + dy = frame.y; + } - switch(button) { - case 1: - blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT; - blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT; + switch(button) { + case 1: + blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT; + blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT; - break; + break; - case 2: - blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXVERT; - blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXVERT; + case 2: + blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXVERT; + blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXVERT; - break; + break; - case 3: - blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXHORIZ; - blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXHORIZ; + case 3: + blackbox_attrib.flags |= BaseDisplay::ATTRIB_MAXHORIZ; + blackbox_attrib.attrib |= BaseDisplay::ATTRIB_MAXHORIZ; - break; - } + break; + } - if (shaded) { - blackbox_attrib.flags ^= BaseDisplay::ATTRIB_SHADED; - blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_SHADED; - shaded = false; - if (hasTab()) - getTab()->shade(); - } + if (shaded) { + blackbox_attrib.flags ^= BaseDisplay::ATTRIB_SHADED; + blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_SHADED; + shaded = false; + if (hasTab()) + getTab()->shade(); + } - maximized = true; + maximized = true; - configure(dx, dy, dw, dh); - if (tab) - tab->raise(); - screen->getWorkspace(workspace_number)->raiseWindow(this); - setState(current_state); + configure(dx, dy, dw, dh); + if (tab) + tab->raise(); + screen->getWorkspace(workspace_number)->raiseWindow(this); + setState(current_state); - } else { - maximized = false; + } else { + maximized = false; - if (isShaded()) { - shade(); - if (hasTab()) - getTab()->shade(); - } + if (isShaded()) { + shade(); + if (hasTab()) + getTab()->shade(); + } - blackbox_attrib.flags &= ! (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT); - blackbox_attrib.attrib &= ! (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT); + blackbox_attrib.flags &= ! (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT); + blackbox_attrib.attrib &= ! (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT); - configure(blackbox_attrib.premax_x, blackbox_attrib.premax_y, - blackbox_attrib.premax_w, blackbox_attrib.premax_h); + configure(blackbox_attrib.premax_x, blackbox_attrib.premax_y, + blackbox_attrib.premax_w, blackbox_attrib.premax_h); - blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; - blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0; + blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; + blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0; - redrawAllButtons(); - setState(current_state); - } + redrawAllButtons(); + setState(current_state); + } - if (tab) //resize all the windows in the tab group - tab->resize(); + if (tab) //resize all the windows in the tab group + tab->resize(); } void FluxboxWindow::setWorkspace(int n) { - workspace_number = n; + workspace_number = n; - blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE; - blackbox_attrib.workspace = workspace_number; + blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE; + blackbox_attrib.workspace = workspace_number; - // notify workspace change + // notify workspace change #ifdef DEBUG - cerr<<this<<" notify workspace signal"<<endl; + cerr<<this<<" notify workspace signal"<<endl; #endif // DEBUG - m_workspacesig.notify(); + m_workspacesig.notify(); } void FluxboxWindow::shade() { - if (decorations.titlebar) { - if (shaded) { - XResizeWindow(display, frame.window, frame.width, frame.height); - shaded = false; - blackbox_attrib.flags ^= BaseDisplay::ATTRIB_SHADED; - blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_SHADED; + if (decorations.titlebar) { + if (shaded) { + XResizeWindow(display, frame.window, frame.width, frame.height); + shaded = false; + blackbox_attrib.flags ^= BaseDisplay::ATTRIB_SHADED; + blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_SHADED; - setState(NormalState); - } else { - XResizeWindow(display, frame.window, frame.width, frame.title_h); - shaded = true; - blackbox_attrib.flags |= BaseDisplay::ATTRIB_SHADED; - blackbox_attrib.attrib |= BaseDisplay::ATTRIB_SHADED; + setState(NormalState); + } else { + XResizeWindow(display, frame.window, frame.width, frame.title_h); + shaded = true; + blackbox_attrib.flags |= BaseDisplay::ATTRIB_SHADED; + blackbox_attrib.attrib |= BaseDisplay::ATTRIB_SHADED; - setState(IconicState); - } - } + setState(IconicState); + } + } } void FluxboxWindow::stick() { - if (tab) //if it got a tab then do tab's stick on all of the objects in the list - tab->stick(); //this window will stick too. - else if (stuck) { - blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; - blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; + if (tab) //if it got a tab then do tab's stick on all of the objects in the list + tab->stick(); //this window will stick too. + else if (stuck) { + blackbox_attrib.flags ^= BaseDisplay::ATTRIB_OMNIPRESENT; + blackbox_attrib.attrib ^= BaseDisplay::ATTRIB_OMNIPRESENT; - stuck = false; + stuck = false; - } else { - stuck = true; - if (screen->getCurrentWorkspaceID() != workspace_number) { - screen->reassociateWindow(this,screen->getCurrentWorkspaceID(), true); - } + } else { + stuck = true; + if (screen->getCurrentWorkspaceID() != workspace_number) { + screen->reassociateWindow(this,screen->getCurrentWorkspaceID(), true); + } - blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT; - blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT; + blackbox_attrib.flags |= BaseDisplay::ATTRIB_OMNIPRESENT; + blackbox_attrib.attrib |= BaseDisplay::ATTRIB_OMNIPRESENT; - } - //find a STICK button in window - redrawAllButtons(); - setState(current_state); + } + //find a STICK button in window + redrawAllButtons(); + setState(current_state); } void FluxboxWindow::setFocusFlag(bool focus) { - focused = focus; + focused = focus; - // Record focus timestamp for window cycling enhancements, such as skipping lower tabs - if (focused) - gettimeofday(&lastFocusTime, 0); + // Record focus timestamp for window cycling enhancements, such as skipping lower tabs + if (focused) + gettimeofday(&lastFocusTime, 0); - if (decorations.titlebar) { - if (focused) { - if (frame.ftitle) - XSetWindowBackgroundPixmap(display, frame.title, frame.ftitle); - else - XSetWindowBackground(display, frame.title, frame.ftitle_pixel); - } else { - if (frame.utitle) - XSetWindowBackgroundPixmap(display, frame.title, frame.utitle); - else - XSetWindowBackground(display, frame.title, frame.utitle_pixel); - } - XClearWindow(display, frame.title); + if (decorations.titlebar) { + if (focused) { + if (frame.ftitle) + XSetWindowBackgroundPixmap(display, frame.title, frame.ftitle); + else + XSetWindowBackground(display, frame.title, frame.ftitle_pixel); + } else { + if (frame.utitle) + XSetWindowBackgroundPixmap(display, frame.title, frame.utitle); + else + XSetWindowBackground(display, frame.title, frame.utitle_pixel); + } + XClearWindow(display, frame.title); - redrawLabel(); - redrawAllButtons(); - } + redrawLabel(); + redrawAllButtons(); + } - if (decorations.handle) { - if (focused) { - if (frame.fhandle) - XSetWindowBackgroundPixmap(display, frame.handle, frame.fhandle); - else - XSetWindowBackground(display, frame.handle, frame.fhandle_pixel); + if (decorations.handle) { + if (focused) { + if (frame.fhandle) + XSetWindowBackgroundPixmap(display, frame.handle, frame.fhandle); + else + XSetWindowBackground(display, frame.handle, frame.fhandle_pixel); - if (frame.fgrip) { - XSetWindowBackgroundPixmap(display, frame.right_grip, frame.fgrip); - XSetWindowBackgroundPixmap(display, frame.left_grip, frame.fgrip); - } else { - XSetWindowBackground(display, frame.right_grip, frame.fgrip_pixel); - XSetWindowBackground(display, frame.left_grip, frame.fgrip_pixel); - } - } else { - if (frame.uhandle) - XSetWindowBackgroundPixmap(display, frame.handle, frame.uhandle); - else - XSetWindowBackground(display, frame.handle, frame.uhandle_pixel); + if (frame.fgrip) { + XSetWindowBackgroundPixmap(display, frame.right_grip, frame.fgrip); + XSetWindowBackgroundPixmap(display, frame.left_grip, frame.fgrip); + } else { + XSetWindowBackground(display, frame.right_grip, frame.fgrip_pixel); + XSetWindowBackground(display, frame.left_grip, frame.fgrip_pixel); + } + } else { + if (frame.uhandle) + XSetWindowBackgroundPixmap(display, frame.handle, frame.uhandle); + else + XSetWindowBackground(display, frame.handle, frame.uhandle_pixel); - if (frame.ugrip) { - XSetWindowBackgroundPixmap(display, frame.right_grip, frame.ugrip); - XSetWindowBackgroundPixmap(display, frame.left_grip, frame.ugrip); - } else { - XSetWindowBackground(display, frame.right_grip, frame.ugrip_pixel); - XSetWindowBackground(display, frame.left_grip, frame.ugrip_pixel); - } - } - XClearWindow(display, frame.handle); - XClearWindow(display, frame.right_grip); - XClearWindow(display, frame.left_grip); - } + if (frame.ugrip) { + XSetWindowBackgroundPixmap(display, frame.right_grip, frame.ugrip); + XSetWindowBackgroundPixmap(display, frame.left_grip, frame.ugrip); + } else { + XSetWindowBackground(display, frame.right_grip, frame.ugrip_pixel); + XSetWindowBackground(display, frame.left_grip, frame.ugrip_pixel); + } + } + XClearWindow(display, frame.handle); + XClearWindow(display, frame.right_grip); + XClearWindow(display, frame.left_grip); + } - if (tab) - tab->focus(); + if (tab) + tab->focus(); - if (decorations.border) { - if (focused) - XSetWindowBorder(display, frame.plate, frame.fborder_pixel); - else - XSetWindowBorder(display, frame.plate, frame.uborder_pixel); - } + if (decorations.border) { + if (focused) + XSetWindowBorder(display, frame.plate, frame.fborder_pixel); + else + XSetWindowBorder(display, frame.plate, frame.uborder_pixel); + } - if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) && - screen->doAutoRaise()) - timer.stop(); + if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) && + screen->doAutoRaise()) + timer.stop(); } void FluxboxWindow::installColormap(bool install) { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); - if (! validateClient()) return; + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); + if (! validateClient()) return; - int i = 0, ncmap = 0; - Colormap *cmaps = XListInstalledColormaps(display, client.window, &ncmap); - XWindowAttributes wattrib; - if (cmaps) { - if (XGetWindowAttributes(display, client.window, &wattrib)) { - if (install) { + int i = 0, ncmap = 0; + Colormap *cmaps = XListInstalledColormaps(display, client.window, &ncmap); + XWindowAttributes wattrib; + if (cmaps) { + if (XGetWindowAttributes(display, client.window, &wattrib)) { + if (install) { // install the window's colormap - for (i = 0; i < ncmap; i++) { - if (*(cmaps + i) == wattrib.colormap) { - // this window is using an installed color map... do not install - install = false; - break; //end for-loop (we dont need to check more) - } - } + for (i = 0; i < ncmap; i++) { + if (*(cmaps + i) == wattrib.colormap) { + // this window is using an installed color map... do not install + install = false; + break; //end for-loop (we dont need to check more) + } + } // otherwise, install the window's colormap - if (install) - XInstallColormap(display, wattrib.colormap); - } else { - for (i = 0; i < ncmap; i++) // uninstall the window's colormap - if (*(cmaps + i) == wattrib.colormap) - XUninstallColormap(display, wattrib.colormap); // we found the colormap to uninstall - } - } + if (install) + XInstallColormap(display, wattrib.colormap); + } else { + for (i = 0; i < ncmap; i++) // uninstall the window's colormap + if (*(cmaps + i) == wattrib.colormap) + XUninstallColormap(display, wattrib.colormap); // we found the colormap to uninstall + } + } - XFree(cmaps); - } + XFree(cmaps); + } - fluxbox->ungrab(); + fluxbox->ungrab(); } void FluxboxWindow::setState(unsigned long new_state) { - current_state = new_state; - Fluxbox *fluxbox = Fluxbox::instance(); - unsigned long state[2]; - state[0] = (unsigned long) current_state; - state[1] = (unsigned long) None; - XChangeProperty(display, client.window, fluxbox->getWMStateAtom(), - fluxbox->getWMStateAtom(), 32, PropModeReplace, - (unsigned char *) state, 2); + current_state = new_state; + Fluxbox *fluxbox = Fluxbox::instance(); + unsigned long state[2]; + state[0] = (unsigned long) current_state; + state[1] = (unsigned long) None; + XChangeProperty(display, client.window, fluxbox->getWMStateAtom(), + fluxbox->getWMStateAtom(), 32, PropModeReplace, + (unsigned char *) state, 2); - XChangeProperty(display, client.window, fluxbox->getFluxboxAttributesAtom(), - fluxbox->getFluxboxAttributesAtom(), 32, PropModeReplace, - (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); + XChangeProperty(display, client.window, fluxbox->getFluxboxAttributesAtom(), + fluxbox->getFluxboxAttributesAtom(), 32, PropModeReplace, + (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); - //notify state changed - m_statesig.notify(); + //notify state changed + m_statesig.notify(); } //TODO: why ungrab in if-statement? bool FluxboxWindow::getState() { - current_state = 0; + current_state = 0; - Atom atom_return; - bool ret = false; - int foo; - unsigned long *state, ulfoo, nitems; - Fluxbox *fluxbox = Fluxbox::instance(); - if ((XGetWindowProperty(display, client.window, fluxbox->getWMStateAtom(), - 0l, 2l, false, fluxbox->getWMStateAtom(), - &atom_return, &foo, &nitems, &ulfoo, - (unsigned char **) &state) != Success) || - (! state)) { - fluxbox->ungrab(); - return false; - } + Atom atom_return; + bool ret = false; + int foo; + unsigned long *state, ulfoo, nitems; + Fluxbox *fluxbox = Fluxbox::instance(); + if ((XGetWindowProperty(display, client.window, fluxbox->getWMStateAtom(), + 0l, 2l, false, fluxbox->getWMStateAtom(), + &atom_return, &foo, &nitems, &ulfoo, + (unsigned char **) &state) != Success) || + (! state)) { + fluxbox->ungrab(); + return false; + } - if (nitems >= 1) { - current_state = static_cast<unsigned long>(state[0]); - ret = true; - } + if (nitems >= 1) { + current_state = static_cast<unsigned long>(state[0]); + ret = true; + } - XFree(static_cast<void *>(state)); + XFree(static_cast<void *>(state)); - return ret; + return ret; } void FluxboxWindow::setGravityOffsets() { - // translate x coordinate - switch (client.win_gravity) { - // handle Westward gravity - case NorthWestGravity: - case WestGravity: - case SouthWestGravity: - default: - frame.x = client.x; - break; + // translate x coordinate + switch (client.win_gravity) { + // handle Westward gravity + case NorthWestGravity: + case WestGravity: + case SouthWestGravity: + default: + frame.x = client.x; + break; - // handle Eastward gravity - case NorthEastGravity: - case EastGravity: - case SouthEastGravity: - frame.x = (client.x + client.width) - frame.width; - break; + // handle Eastward gravity + case NorthEastGravity: + case EastGravity: + case SouthEastGravity: + frame.x = (client.x + client.width) - frame.width; + break; - // no x translation desired - default - case StaticGravity: - case ForgetGravity: - case CenterGravity: - frame.x = client.x - frame.mwm_border_w + screen->getBorderWidth(); - } + // no x translation desired - default + case StaticGravity: + case ForgetGravity: + case CenterGravity: + frame.x = client.x - frame.mwm_border_w + screen->getBorderWidth(); + } - // translate y coordinate - switch (client.win_gravity) { - // handle Northbound gravity - case NorthWestGravity: - case NorthGravity: - case NorthEastGravity: - default: - frame.y = client.y; - break; + // translate y coordinate + switch (client.win_gravity) { + // handle Northbound gravity + case NorthWestGravity: + case NorthGravity: + case NorthEastGravity: + default: + frame.y = client.y; + break; - // handle Southbound gravity - case SouthWestGravity: - case SouthGravity: - case SouthEastGravity: - frame.y = (client.y + client.height) - frame.height; - break; + // handle Southbound gravity + case SouthWestGravity: + case SouthGravity: + case SouthEastGravity: + frame.y = (client.y + client.height) - frame.height; + break; - // no y translation desired - default - case StaticGravity: - case ForgetGravity: - case CenterGravity: - frame.y = client.y - frame.y_border - frame.mwm_border_w - - screen->getBorderWidth(); - break; - } + // no y translation desired - default + case StaticGravity: + case ForgetGravity: + case CenterGravity: + frame.y = client.y - frame.y_border - frame.mwm_border_w - + screen->getBorderWidth(); + break; + } } void FluxboxWindow::restoreAttributes() { - if (!getState()) - current_state = NormalState; + if (!getState()) + current_state = NormalState; - Atom atom_return; - int foo; - unsigned long ulfoo, nitems; - Fluxbox *fluxbox = Fluxbox::instance(); + Atom atom_return; + int foo; + unsigned long ulfoo, nitems; + Fluxbox *fluxbox = Fluxbox::instance(); - BaseDisplay::BlackboxAttributes *net; - if (XGetWindowProperty(display, client.window, - fluxbox->getFluxboxAttributesAtom(), 0l, - PropBlackboxAttributesElements, false, - fluxbox->getFluxboxAttributesAtom(), &atom_return, &foo, - &nitems, &ulfoo, (unsigned char **) &net) == - Success && net && nitems == PropBlackboxAttributesElements) { - blackbox_attrib.flags = net->flags; - blackbox_attrib.attrib = net->attrib; - blackbox_attrib.workspace = net->workspace; - blackbox_attrib.stack = net->stack; - blackbox_attrib.premax_x = net->premax_x; - blackbox_attrib.premax_y = net->premax_y; - blackbox_attrib.premax_w = net->premax_w; - blackbox_attrib.premax_h = net->premax_h; + BaseDisplay::BlackboxAttributes *net; + if (XGetWindowProperty(display, client.window, + fluxbox->getFluxboxAttributesAtom(), 0l, + PropBlackboxAttributesElements, false, + fluxbox->getFluxboxAttributesAtom(), &atom_return, &foo, + &nitems, &ulfoo, (unsigned char **) &net) == + Success && net && nitems == PropBlackboxAttributesElements) { + blackbox_attrib.flags = net->flags; + blackbox_attrib.attrib = net->attrib; + blackbox_attrib.workspace = net->workspace; + blackbox_attrib.stack = net->stack; + blackbox_attrib.premax_x = net->premax_x; + blackbox_attrib.premax_y = net->premax_y; + blackbox_attrib.premax_w = net->premax_w; + blackbox_attrib.premax_h = net->premax_h; - XFree(static_cast<void *>(net)); - } else - return; + XFree(static_cast<void *>(net)); + } else + return; - if (blackbox_attrib.flags & BaseDisplay::ATTRIB_SHADED && - blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) { - int save_state = - ((current_state == IconicState) ? NormalState : current_state); + if (blackbox_attrib.flags & BaseDisplay::ATTRIB_SHADED && + blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) { + int save_state = + ((current_state == IconicState) ? NormalState : current_state); - shaded = false; - shade(); - if (tab) - tab->shade(); + shaded = false; + shade(); + if (tab) + tab->shade(); - current_state = save_state; - } + current_state = save_state; + } - if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && - ( blackbox_attrib.workspace < screen->getCount())) { - screen->reassociateWindow(this, blackbox_attrib.workspace, true); + if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && + ( blackbox_attrib.workspace < screen->getCount())) { + screen->reassociateWindow(this, blackbox_attrib.workspace, true); - if (current_state == NormalState) current_state = WithdrawnState; - } else if (current_state == WithdrawnState) - current_state = NormalState; + if (current_state == NormalState) current_state = WithdrawnState; + } else if (current_state == WithdrawnState) + current_state = NormalState; - if (blackbox_attrib.flags & BaseDisplay::ATTRIB_OMNIPRESENT && - blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) { - stuck = false; - stick(); + if (blackbox_attrib.flags & BaseDisplay::ATTRIB_OMNIPRESENT && + blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) { + stuck = false; + stick(); - current_state = NormalState; - } + current_state = NormalState; + } - if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) || - (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) { - int x = blackbox_attrib.premax_x, y = blackbox_attrib.premax_y; - unsigned int w = blackbox_attrib.premax_w, h = blackbox_attrib.premax_h; - maximized = false; + if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) || + (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) { + int x = blackbox_attrib.premax_x, y = blackbox_attrib.premax_y; + unsigned int w = blackbox_attrib.premax_w, h = blackbox_attrib.premax_h; + maximized = false; - int m; - if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) && - (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) - m = ((blackbox_attrib.attrib & (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? - 1 : 0); - else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT) - m = ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); - else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) - m = ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); - else - m = 0; + int m; + if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) && + (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) + m = ((blackbox_attrib.attrib & (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? + 1 : 0); + else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT) + m = ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); + else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) + m = ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); + else + m = 0; - if (m) maximize(m); + if (m) maximize(m); - blackbox_attrib.premax_x = x; - blackbox_attrib.premax_y = y; - blackbox_attrib.premax_w = w; - blackbox_attrib.premax_h = h; - } + blackbox_attrib.premax_x = x; + blackbox_attrib.premax_y = y; + blackbox_attrib.premax_w = w; + blackbox_attrib.premax_h = h; + } - setState(current_state); + setState(current_state); } void FluxboxWindow::showMenu(int mx, int my) { - if (m_windowmenu.get() == 0) - return; - m_windowmenu->move(mx, my); - m_windowmenu->show(); - m_windowmenu->raise(); - m_windowmenu->getSendToMenu().raise(); - m_windowmenu->getSendGroupToMenu().raise(); + if (m_windowmenu.get() == 0) + return; + m_windowmenu->move(mx, my); + m_windowmenu->show(); + m_windowmenu->raise(); + m_windowmenu->getSendToMenu().raise(); + m_windowmenu->getSendGroupToMenu().raise(); } void FluxboxWindow::restoreGravity() { - // restore x coordinate - switch (client.win_gravity) { - // handle Westward gravity - case NorthWestGravity: - case WestGravity: - case SouthWestGravity: - default: - client.x = frame.x; - break; + // restore x coordinate + switch (client.win_gravity) { + // handle Westward gravity + case NorthWestGravity: + case WestGravity: + case SouthWestGravity: + default: + client.x = frame.x; + break; - // handle Eastward gravity - case NorthEastGravity: - case EastGravity: - case SouthEastGravity: - client.x = (frame.x + frame.width) - client.width; - break; - } + // handle Eastward gravity + case NorthEastGravity: + case EastGravity: + case SouthEastGravity: + client.x = (frame.x + frame.width) - client.width; + break; + } - // restore y coordinate - switch (client.win_gravity) { - // handle Northbound gravity - case NorthWestGravity: - case NorthGravity: - case NorthEastGravity: - default: - client.y = frame.y; - break; + // restore y coordinate + switch (client.win_gravity) { + // handle Northbound gravity + case NorthWestGravity: + case NorthGravity: + case NorthEastGravity: + default: + client.y = frame.y; + break; - // handle Southbound gravity - case SouthWestGravity: - case SouthGravity: - case SouthEastGravity: - client.y = (frame.y + frame.height) - client.height; - break; - } + // handle Southbound gravity + case SouthWestGravity: + case SouthGravity: + case SouthEastGravity: + client.y = (frame.y + frame.height) - client.height; + break; + } } bool FluxboxWindow::isLowerTab() const { - Tab* chkTab = (tab ? tab->first() : 0); - while (chkTab) { - const FluxboxWindow* chkWin = chkTab->getWindow(); - if (chkWin && chkWin != this && - timercmp(&chkWin->lastFocusTime, &lastFocusTime, >)) - return true; - chkTab = chkTab->next(); - } - return false; + Tab* chkTab = (tab ? tab->first() : 0); + while (chkTab) { + const FluxboxWindow* chkWin = chkTab->getWindow(); + if (chkWin && chkWin != this && + timercmp(&chkWin->lastFocusTime, &lastFocusTime, >)) + return true; + chkTab = chkTab->next(); + } + return false; } void FluxboxWindow::redrawLabel() { - if (focused) { - if (frame.flabel) - XSetWindowBackgroundPixmap(display, frame.label, frame.flabel); - else - XSetWindowBackground(display, frame.label, frame.flabel_pixel); - } else { - if (frame.ulabel) - XSetWindowBackgroundPixmap(display, frame.label, frame.ulabel); - else - XSetWindowBackground(display, frame.label, frame.ulabel_pixel); - } + if (focused) { + if (frame.flabel) + XSetWindowBackgroundPixmap(display, frame.label, frame.flabel); + else + XSetWindowBackground(display, frame.label, frame.flabel_pixel); + } else { + if (frame.ulabel) + XSetWindowBackgroundPixmap(display, frame.label, frame.ulabel); + else + XSetWindowBackground(display, frame.label, frame.ulabel_pixel); + } - XClearWindow(display, frame.label); + XClearWindow(display, frame.label); - //no need to draw the title if we don't have any - if (getTitle().size() == 0) - return; + //no need to draw the title if we don't have any + if (getTitle().size() == 0) + return; - GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc : - screen->getWindowStyle()->l_text_unfocus_gc); + GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc : + screen->getWindowStyle()->l_text_unfocus_gc); - size_t newlen = getTitle().size(); - const char *labeltext = getTitle().c_str(); - FbTk::Font &font = screen->getWindowStyle()->font; + size_t newlen = getTitle().size(); + const char *labeltext = getTitle().c_str(); + FbTk::Font &font = screen->getWindowStyle()->font; - int align_x = DrawUtil::doAlignment( - frame.label_w, frame.bevel_w*2, - screen->getWindowStyle()->justify, - font, - labeltext, newlen, newlen); + int align_x = DrawUtil::doAlignment( + frame.label_w, frame.bevel_w*2, + screen->getWindowStyle()->justify, + font, + labeltext, newlen, newlen); - font.drawText( - frame.label, - screen->getScreenNumber(), - gc, - labeltext, newlen, - align_x, font.ascent() + 1); + font.drawText( + frame.label, + screen->getScreenNumber(), + gc, + labeltext, newlen, + align_x, font.ascent() + 1); } void FluxboxWindow::redrawAllButtons() { - for (unsigned int i=0; i<buttonlist.size(); i++) { - if (buttonlist[i].draw) - buttonlist[i].draw(this, buttonlist[i].win, false); - } + for (unsigned int i=0; i<buttonlist.size(); i++) { + if (buttonlist[i].draw) + buttonlist[i].draw(this, buttonlist[i].win, false); + } } void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { #ifdef DEBUG - fprintf(stderr, - I18n::instance()->getMessage( - FBNLS::WindowSet, FBNLS::WindowMapRequest, - "FluxboxWindow::mapRequestEvent() for 0x%lx\n"), - client.window); + fprintf(stderr, + I18n::instance()->getMessage( + FBNLS::WindowSet, FBNLS::WindowMapRequest, + "FluxboxWindow::mapRequestEvent() for 0x%lx\n"), + client.window); #endif // DEBUG - if (re->window != client.window) - return; + if (re->window != client.window) + return; - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); - if (! validateClient()) - return; + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); + if (! validateClient()) + return; - bool get_state_ret = getState(); - if (! (get_state_ret && fluxbox->isStartup())) { - if ((client.wm_hint_flags & StateHint) && - (! (current_state == NormalState || current_state == IconicState))) { - current_state = client.initial_state; - } else - current_state = NormalState; - } else if (iconic) - current_state = NormalState; + bool get_state_ret = getState(); + if (! (get_state_ret && fluxbox->isStartup())) { + if ((client.wm_hint_flags & StateHint) && + (! (current_state == NormalState || current_state == IconicState))) { + current_state = client.initial_state; + } else + current_state = NormalState; + } else if (iconic) + current_state = NormalState; - switch (current_state) { - case IconicState: - iconify(); + switch (current_state) { + case IconicState: + iconify(); break; - case WithdrawnState: - withdraw(); + case WithdrawnState: + withdraw(); break; - case NormalState: - //check WM_CLASS only when we changed state to NormalState from - // WithdrawnState (ICCC 4.1.2.5) + case NormalState: + //check WM_CLASS only when we changed state to NormalState from + // WithdrawnState (ICCC 4.1.2.5) - XClassHint ch; + XClassHint ch; - if (XGetClassHint(display, getClientWindow(), &ch) == 0) { - cerr<<"Failed to read class hint!"<<endl; - } else { - if (ch.res_name != 0) { - m_instance_name = const_cast<char *>(ch.res_name); - XFree(ch.res_name); - } else - m_instance_name = ""; + if (XGetClassHint(display, getClientWindow(), &ch) == 0) { + cerr<<"Failed to read class hint!"<<endl; + } else { + if (ch.res_name != 0) { + m_instance_name = const_cast<char *>(ch.res_name); + XFree(ch.res_name); + } else + m_instance_name = ""; - if (ch.res_class != 0) { - m_class_name = const_cast<char *>(ch.res_class); - XFree(ch.res_class); - } else - m_class_name = ""; + if (ch.res_class != 0) { + m_class_name = const_cast<char *>(ch.res_class); + XFree(ch.res_class); + } else + m_class_name = ""; - Workspace *wsp = screen->getWorkspace(workspace_number); - // we must be resizable AND maximizable to be autogrouped - // TODO: there should be an isGroupable() function - if (wsp != 0 && isResizable() && isMaximizable()) { - wsp->checkGrouping(*this); - } - } + Workspace *wsp = screen->getWorkspace(workspace_number); + // we must be resizable AND maximizable to be autogrouped + // TODO: there should be an isGroupable() function + if (wsp != 0 && isResizable() && isMaximizable()) { + wsp->checkGrouping(*this); + } + } - deiconify(false); + deiconify(false); break; - case InactiveState: - case ZoomState: - default: - deiconify(false); - break; - } + case InactiveState: + case ZoomState: + default: + deiconify(false); + break; + } - fluxbox->ungrab(); + fluxbox->ungrab(); } void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) { - if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); - if (! validateClient()) - return; + if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); + if (! validateClient()) + return; - if (decorations.titlebar) - positionButtons(); + if (decorations.titlebar) + positionButtons(); - setState(NormalState); + setState(NormalState); - redrawAllButtons(); + redrawAllButtons(); - if (transient || screen->doFocusNew()) - setInputFocus(); - else - setFocusFlag(false); + if (transient || screen->doFocusNew()) + setInputFocus(); + else + setFocusFlag(false); - visible = true; - iconic = false; + visible = true; + iconic = false; - // Auto-group from tab? - if (!transient) { - // Grab and clear the auto-group window - FluxboxWindow* autoGroupWindow = screen->useAutoGroupWindow(); - if (autoGroupWindow) { - Tab *groupTab = autoGroupWindow->getTab(); - if (groupTab) - groupTab->addWindowToGroup(this); - } - } + // Auto-group from tab? + if (!transient) { + // Grab and clear the auto-group window + FluxboxWindow* autoGroupWindow = screen->useAutoGroupWindow(); + if (autoGroupWindow) { + Tab *groupTab = autoGroupWindow->getTab(); + if (groupTab) + groupTab->addWindowToGroup(this); + } + } - fluxbox->ungrab(); - } + fluxbox->ungrab(); + } } //------------------- unmapNotify ------------------

@@ -2583,20 +2583,20 @@ // Returns true if *this should die

// else false //------------------------------------------------- bool FluxboxWindow::unmapNotifyEvent(XUnmapEvent *ue) { - if (ue->window != client.window) - return false; + if (ue->window != client.window) + return false; #ifdef DEBUG - fprintf(stderr, - I18n::instance()->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnmapNotify, - "FluxboxWindow::unmapNotifyEvent() for 0x%lx\n"), - client.window); + fprintf(stderr, + I18n::instance()->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnmapNotify, + "FluxboxWindow::unmapNotifyEvent() for 0x%lx\n"), + client.window); #endif // DEBUG - restore(false); + restore(false); - return true; // make sure this one deletes + return true; // make sure this one deletes }

@@ -2606,1128 +2606,1128 @@ // Unmaps frame.window and returns true for destroy

// of this FluxboxWindow else returns false. //-------------------------------------------- bool FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) { - if (de->window == client.window) { + if (de->window == client.window) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<endl; #endif // DEBUG - XUnmapWindow(display, frame.window); - return true; - } - return false; + XUnmapWindow(display, frame.window); + return true; + } + return false; } void FluxboxWindow::propertyNotifyEvent(Atom atom) { - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - if (! validateClient()) - return; + if (! validateClient()) + return; - switch(atom) { - case XA_WM_CLASS: - case XA_WM_CLIENT_MACHINE: - case XA_WM_COMMAND: - break; + switch(atom) { + case XA_WM_CLASS: + case XA_WM_CLIENT_MACHINE: + case XA_WM_COMMAND: + break; - case XA_WM_TRANSIENT_FOR: - checkTransient(); - reconfigure(); + case XA_WM_TRANSIENT_FOR: + checkTransient(); + reconfigure(); - break; + break; - case XA_WM_HINTS: - getWMHints(); - break; + case XA_WM_HINTS: + getWMHints(); + break; - case XA_WM_ICON_NAME: - getWMIconName(); - if (iconic) - screen->iconUpdate(); - updateIcon(); - break; + case XA_WM_ICON_NAME: + getWMIconName(); + if (iconic) + screen->iconUpdate(); + updateIcon(); + break; - case XA_WM_NAME: - getWMName(); + case XA_WM_NAME: + getWMName(); - if (decorations.titlebar) - redrawLabel(); + if (decorations.titlebar) + redrawLabel(); - if (hasTab()) // update tab - getTab()->draw(false); + if (hasTab()) // update tab + getTab()->draw(false); - if (! iconic) - screen->getWorkspace(workspace_number)->update(); - else - updateIcon(); + if (! iconic) + screen->getWorkspace(workspace_number)->update(); + else + updateIcon(); - break; + break; - case XA_WM_NORMAL_HINTS: { - getWMNormalHints(); + case XA_WM_NORMAL_HINTS: { + getWMNormalHints(); - if ((client.normal_hint_flags & PMinSize) && - (client.normal_hint_flags & PMaxSize)) { + if ((client.normal_hint_flags & PMinSize) && + (client.normal_hint_flags & PMaxSize)) { - if (client.max_width != 0 && client.max_width <= client.min_width && - client.max_height != 0 && client.max_height <= client.min_height) { - decorations.maximize = false; - decorations.handle = false; - functions.resize=false; - functions.maximize=false; - } else { - if (! isTransient()) { - decorations.maximize = true; - decorations.handle = true; - functions.maximize = true; - } - functions.resize = true; - } + if (client.max_width != 0 && client.max_width <= client.min_width && + client.max_height != 0 && client.max_height <= client.min_height) { + decorations.maximize = false; + decorations.handle = false; + functions.resize=false; + functions.maximize=false; + } else { + if (! isTransient()) { + decorations.maximize = true; + decorations.handle = true; + functions.maximize = true; + } + functions.resize = true; + } } - int x = frame.x, y = frame.y; - unsigned int w = frame.width, h = frame.height; + int x = frame.x, y = frame.y; + unsigned int w = frame.width, h = frame.height; - upsize(); + upsize(); - if ((x != frame.x) || (y != frame.y) || - (w != frame.width) || (h != frame.height)) - reconfigure(); + if ((x != frame.x) || (y != frame.y) || + (w != frame.width) || (h != frame.height)) + reconfigure(); - break; - } + break; + } - default: - if (atom == fluxbox->getWMProtocolsAtom()) { - getWMProtocols(); + default: + if (atom == fluxbox->getWMProtocolsAtom()) { + getWMProtocols(); - if (decorations.close && !findTitleButton(Fluxbox::CLOSE)) { - createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb, - FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb); + if (decorations.close && !findTitleButton(Fluxbox::CLOSE)) { + createButton(Fluxbox::CLOSE, FluxboxWindow::closePressed_cb, + FluxboxWindow::closeButton_cb, FluxboxWindow::closeDraw_cb); - if (decorations.titlebar) - positionButtons(true); - if (m_windowmenu.get()) - m_windowmenu->reconfigure(); - } - } - break; - } + if (decorations.titlebar) + positionButtons(true); + if (m_windowmenu.get()) + m_windowmenu->reconfigure(); + } + } + break; + } } void FluxboxWindow::exposeEvent(XExposeEvent *ee) { - if (frame.label == ee->window && decorations.titlebar) - redrawLabel(); - else - redrawAllButtons(); + if (frame.label == ee->window && decorations.titlebar) + redrawLabel(); + else + redrawAllButtons(); } void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent *cr) { - if (cr->window == client.window) { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); - if (! validateClient()) - return; + if (cr->window == client.window) { + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); + if (! validateClient()) + return; - int cx = frame.x, cy = frame.y; - unsigned int cw = frame.width, ch = frame.height; + int cx = frame.x, cy = frame.y; + unsigned int cw = frame.width, ch = frame.height; - if (cr->value_mask & CWBorderWidth) - client.old_bw = cr->border_width; + if (cr->value_mask & CWBorderWidth) + client.old_bw = cr->border_width; - if (cr->value_mask & CWX) - cx = cr->x - frame.mwm_border_w - screen->getBorderWidth(); + if (cr->value_mask & CWX) + cx = cr->x - frame.mwm_border_w - screen->getBorderWidth(); - if (cr->value_mask & CWY) - cy = cr->y - frame.y_border - frame.mwm_border_w - - screen->getBorderWidth(); + if (cr->value_mask & CWY) + cy = cr->y - frame.y_border - frame.mwm_border_w - + screen->getBorderWidth(); - if (cr->value_mask & CWWidth) - cw = cr->width + (frame.mwm_border_w * 2); + if (cr->value_mask & CWWidth) + cw = cr->width + (frame.mwm_border_w * 2); - if (cr->value_mask & CWHeight) { - ch = cr->height + (frame.y_border + (frame.mwm_border_w * 2) + - screen->getBorderWidth()) * decorations.border + - frame.handle_h*decorations.handle; - } - if (frame.x != cx || frame.y != cy || - frame.width != cw || frame.height != ch) { - configure(cx, cy, cw, ch); - if (tab) - tab->resize(); - } - if (cr->value_mask & CWStackMode) { - switch (cr->detail) { - case Above: - case TopIf: - default: - if (iconic) - deiconify(); + if (cr->value_mask & CWHeight) { + ch = cr->height + (frame.y_border + (frame.mwm_border_w * 2) + + screen->getBorderWidth()) * decorations.border + + frame.handle_h*decorations.handle; + } + if (frame.x != cx || frame.y != cy || + frame.width != cw || frame.height != ch) { + configure(cx, cy, cw, ch); + if (tab) + tab->resize(); + } + if (cr->value_mask & CWStackMode) { + switch (cr->detail) { + case Above: + case TopIf: + default: + if (iconic) + deiconify(); //!!TODO check this and the line below.. // if (tab) // tab->raise(); - screen->getWorkspace(workspace_number)->raiseWindow(this); - break; + screen->getWorkspace(workspace_number)->raiseWindow(this); + break; - case Below: - case BottomIf: - if (iconic) - deiconify(); + case Below: + case BottomIf: + if (iconic) + deiconify(); // if (tab) // tab->raise(); - screen->getWorkspace(workspace_number)->lowerWindow(this); - break; - } - } + screen->getWorkspace(workspace_number)->lowerWindow(this); + break; + } + } - fluxbox->ungrab(); - } + fluxbox->ungrab(); + } } void FluxboxWindow::buttonPressEvent(XButtonEvent *be) { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); - if (! validateClient()) - return; + if (! validateClient()) + return; - if (be->button == 1 || (be->button == 3 && be->state == Mod1Mask)) { - if ((! focused) && (! screen->isSloppyFocus())) //check focus - setInputFocus(); + if (be->button == 1 || (be->button == 3 && be->state == Mod1Mask)) { + if ((! focused) && (! screen->isSloppyFocus())) //check focus + setInputFocus(); - //Redraw buttons - for (unsigned int i=0; i<buttonlist.size(); i++) { - if (be->window == buttonlist[i].win && buttonlist[i].draw) - buttonlist[i].draw(this, be->window, true); - } + //Redraw buttons + for (unsigned int i=0; i<buttonlist.size(); i++) { + if (be->window == buttonlist[i].win && buttonlist[i].draw) + buttonlist[i].draw(this, be->window, true); + } - if (frame.plate == be->window) { + if (frame.plate == be->window) { - if (m_windowmenu.get() && m_windowmenu->isVisible()) //hide menu if its visible - m_windowmenu->hide(); - //raise tab first, if there is any, so the focus on windows get - //right and dont "hide" the tab behind other windows - if (tab) - tab->raise(); + if (m_windowmenu.get() && m_windowmenu->isVisible()) //hide menu if its visible + m_windowmenu->hide(); + //raise tab first, if there is any, so the focus on windows get + //right and dont "hide" the tab behind other windows + if (tab) + tab->raise(); - screen->getWorkspace(workspace_number)->raiseWindow(this); + screen->getWorkspace(workspace_number)->raiseWindow(this); - XAllowEvents(display, ReplayPointer, be->time); + XAllowEvents(display, ReplayPointer, be->time); - } else { + } else { - if (frame.title == be->window || frame.label == be->window) { - if (((be->time - lastButtonPressTime) <= - fluxbox->getDoubleClickInterval()) || - (be->state & ControlMask)) { - lastButtonPressTime = 0; - shade(); - if (tab) //shade windows in the tablist too - tab->shade(); - } else - lastButtonPressTime = be->time; - } + if (frame.title == be->window || frame.label == be->window) { + if (((be->time - lastButtonPressTime) <= + fluxbox->getDoubleClickInterval()) || + (be->state & ControlMask)) { + lastButtonPressTime = 0; + shade(); + if (tab) //shade windows in the tablist too + tab->shade(); + } else + lastButtonPressTime = be->time; + } - frame.grab_x = be->x_root - frame.x - screen->getBorderWidth(); - frame.grab_y = be->y_root - frame.y - screen->getBorderWidth(); + frame.grab_x = be->x_root - frame.x - screen->getBorderWidth(); + frame.grab_y = be->y_root - frame.y - screen->getBorderWidth(); - if (m_windowmenu.get() && m_windowmenu->isVisible()) - m_windowmenu->hide(); - //raise tab first if there is any - if (hasTab()) - tab->raise(); + if (m_windowmenu.get() && m_windowmenu->isVisible()) + m_windowmenu->hide(); + //raise tab first if there is any + if (hasTab()) + tab->raise(); - screen->getWorkspace(workspace_number)->raiseWindow(this); - } - } else if (be->button == 2 && be->window == frame.label) { - screen->getWorkspace(workspace_number)->lowerWindow(this); - if (hasTab()) - getTab()->lower(); //lower the tab AND it's windows + screen->getWorkspace(workspace_number)->raiseWindow(this); + } + } else if (be->button == 2 && be->window == frame.label) { + screen->getWorkspace(workspace_number)->lowerWindow(this); + if (hasTab()) + getTab()->lower(); //lower the tab AND it's windows - } else if (m_windowmenu.get() && be->button == 3 && - (frame.title == be->window || frame.label == be->window || - frame.handle == be->window)) { + } else if (m_windowmenu.get() && be->button == 3 && + (frame.title == be->window || frame.label == be->window || + frame.handle == be->window)) { - int mx = 0, my = 0; + int mx = 0, my = 0; - if (frame.title == be->window || frame.label == be->window) { - mx = be->x_root - (m_windowmenu->width() / 2); - my = frame.y + frame.title_h; - } else if (frame.handle == be->window) { - mx = be->x_root - (m_windowmenu->width() / 2); - my = frame.y + frame.y_handle - m_windowmenu->height(); - } else { - bool buttonproc=false; + if (frame.title == be->window || frame.label == be->window) { + mx = be->x_root - (m_windowmenu->width() / 2); + my = frame.y + frame.title_h; + } else if (frame.handle == be->window) { + mx = be->x_root - (m_windowmenu->width() / 2); + my = frame.y + frame.y_handle - m_windowmenu->height(); + } else { + bool buttonproc=false; - if (buttonproc) - mx = be->x_root - (m_windowmenu->width() / 2); + if (buttonproc) + mx = be->x_root - (m_windowmenu->width() / 2); - if (be->y <= (signed) frame.bevel_w) - my = frame.y + frame.y_border; - else - my = be->y_root - (m_windowmenu->height() / 2); - } + if (be->y <= (signed) frame.bevel_w) + my = frame.y + frame.y_border; + else + my = be->y_root - (m_windowmenu->height() / 2); + } - if (mx > (signed) (frame.x + frame.width - m_windowmenu->width())) - mx = frame.x + frame.width - m_windowmenu->width(); - if (mx < frame.x) - mx = frame.x; + if (mx > (signed) (frame.x + frame.width - m_windowmenu->width())) + mx = frame.x + frame.width - m_windowmenu->width(); + if (mx < frame.x) + mx = frame.x; - if (my > (signed) (frame.y + frame.y_handle - m_windowmenu->height())) - my = frame.y + frame.y_handle - m_windowmenu->height(); - if (my < (signed) (frame.y + ((decorations.titlebar) ? frame.title_h : - frame.y_border))) - my = frame.y + - ((decorations.titlebar) ? frame.title_h : frame.y_border); + if (my > (signed) (frame.y + frame.y_handle - m_windowmenu->height())) + my = frame.y + frame.y_handle - m_windowmenu->height(); + if (my < (signed) (frame.y + ((decorations.titlebar) ? frame.title_h : + frame.y_border))) + my = frame.y + + ((decorations.titlebar) ? frame.title_h : frame.y_border); - if (m_windowmenu.get()) { - if (! m_windowmenu->isVisible()) { // if not window menu is visible then show it - showMenu(mx, my); - } else //else hide menu - m_windowmenu->hide(); - } + if (m_windowmenu.get()) { + if (! m_windowmenu->isVisible()) { // if not window menu is visible then show it + showMenu(mx, my); + } else //else hide menu + m_windowmenu->hide(); + } - } else if (be->button == 4) { //scroll to tab right - if (tab && tab->next()) { - tab->next()->getWindow()->setInputFocus(); - screen->getWorkspace(workspace_number)->raiseWindow(tab->next()->getWindow()); - } - } else if (be->button == 5) { //scroll to tab left - if (tab && tab->prev()) { - tab->prev()->getWindow()->setInputFocus(); - screen->getWorkspace(workspace_number)->raiseWindow(tab->prev()->getWindow()); - } - } + } else if (be->button == 4) { //scroll to tab right + if (tab && tab->next()) { + tab->next()->getWindow()->setInputFocus(); + screen->getWorkspace(workspace_number)->raiseWindow(tab->next()->getWindow()); + } + } else if (be->button == 5) { //scroll to tab left + if (tab && tab->prev()) { + tab->prev()->getWindow()->setInputFocus(); + screen->getWorkspace(workspace_number)->raiseWindow(tab->prev()->getWindow()); + } + } - fluxbox->ungrab(); + fluxbox->ungrab(); } void FluxboxWindow::buttonReleaseEvent(XButtonEvent *re) { - Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->grab(); + Fluxbox *fluxbox = Fluxbox::instance(); + fluxbox->grab(); - if (! validateClient()) - return; + if (! validateClient()) + return; - if (isMoving()) - stopMoving(); - else if (isResizing()) - stopResizing(); - else if (re->window == frame.window) { - if (re->button == 2 && re->state == Mod1Mask) - XUngrabPointer(display, CurrentTime); - } else { - if ((re->x >= 0) && ((unsigned) re->x <= frame.button_w) && - (re->y >= 0) && ((unsigned) re->y <= frame.button_h)) { - for (unsigned int i=0; i<buttonlist.size(); i++) { - if (re->window == buttonlist[i].win && - buttonlist[i].released) { - buttonlist[i].released(this, re); - break; - } - } - } - redrawAllButtons(); - } + if (isMoving()) + stopMoving(); + else if (isResizing()) + stopResizing(); + else if (re->window == frame.window) { + if (re->button == 2 && re->state == Mod1Mask) + XUngrabPointer(display, CurrentTime); + } else { + if ((re->x >= 0) && ((unsigned) re->x <= frame.button_w) && + (re->y >= 0) && ((unsigned) re->y <= frame.button_h)) { + for (unsigned int i=0; i<buttonlist.size(); i++) { + if (re->window == buttonlist[i].win && + buttonlist[i].released) { + buttonlist[i].released(this, re); + break; + } + } + } + redrawAllButtons(); + } - fluxbox->ungrab(); + fluxbox->ungrab(); } void FluxboxWindow::motionNotifyEvent(XMotionEvent *me) { - if ((me->state & Button1Mask) && functions.move && - (frame.title == me->window || frame.label == me->window || - frame.handle == me->window || frame.window == me->window) && !isResizing()) { + if ((me->state & Button1Mask) && functions.move && + (frame.title == me->window || frame.label == me->window || + frame.handle == me->window || frame.window == me->window) && !isResizing()) { - if (! isMoving()) { - startMoving(me->window); - } else { - int dx = me->x_root - frame.grab_x, dy = me->y_root - frame.grab_y; + if (! isMoving()) { + startMoving(me->window); + } else { + int dx = me->x_root - frame.grab_x, dy = me->y_root - frame.grab_y; - dx -= screen->getBorderWidth(); - dy -= screen->getBorderWidth(); + dx -= screen->getBorderWidth(); + dy -= screen->getBorderWidth(); - if (screen->getEdgeSnapThreshold()) { - int drx = screen->getWidth() - (dx + frame.snap_w); + if (screen->getEdgeSnapThreshold()) { + int drx = screen->getWidth() - (dx + frame.snap_w); - if (dx > 0 && dx < drx && dx < screen->getEdgeSnapThreshold()) - dx = 0; - else if (drx > 0 && drx < screen->getEdgeSnapThreshold()) - dx = screen->getWidth() - frame.snap_w; + if (dx > 0 && dx < drx && dx < screen->getEdgeSnapThreshold()) + dx = 0; + else if (drx > 0 && drx < screen->getEdgeSnapThreshold()) + dx = screen->getWidth() - frame.snap_w; - int dtty, dbby, dty, dby; - switch (screen->getToolbarPlacement()) { - case Toolbar::TOPLEFT: - case Toolbar::TOPCENTER: - case Toolbar::TOPRIGHT: - dtty = screen->getToolbar()->exposedHeight() + - screen->getBorderWidth(); - dbby = screen->getHeight(); - break; + int dtty, dbby, dty, dby; + switch (screen->getToolbarPlacement()) { + case Toolbar::TOPLEFT: + case Toolbar::TOPCENTER: + case Toolbar::TOPRIGHT: + dtty = screen->getToolbar()->exposedHeight() + + screen->getBorderWidth(); + dbby = screen->getHeight(); + break; - default: - dtty = 0; - dbby = screen->getToolbar()->y(); - break; - } + default: + dtty = 0; + dbby = screen->getToolbar()->y(); + break; + } - dty = dy - dtty; - dby = dbby - (dy + frame.snap_h); + dty = dy - dtty; + dby = dbby - (dy + frame.snap_h); - if (dy > 0 && dty < screen->getEdgeSnapThreshold()) - dy = dtty; - else if (dby > 0 && dby < screen->getEdgeSnapThreshold()) - dy = dbby - frame.snap_h; - } - // Warp to next or previous workspace?, must have moved sideways some - int moved_x=me->x_root - frame.resize_x; - // save last event point - frame.resize_x = me->x_root; - frame.resize_y = me->y_root; - if (moved_x && screen->isWorkspaceWarping()) { - int cur_id = screen->getCurrentWorkspaceID(); - int new_id = cur_id; - const int warpPad = screen->getEdgeSnapThreshold(); - if (me->x_root >= int(screen->getWidth()) - warpPad - 1 && - frame.x < int(me->x_root - frame.grab_x - screen->getBorderWidth())) { - //warp right - new_id = (cur_id + 1) % screen->getCount(); - dx = -me->x_root; - } else if (me->x_root <= warpPad && - frame.x > int(me->x_root - frame.grab_x - screen->getBorderWidth())) { - //warp left - new_id = (cur_id - 1 + screen->getCount()) % screen->getCount(); - dx = screen->getWidth() - me->x_root-1; - } - if (new_id != cur_id) { - XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0); + if (dy > 0 && dty < screen->getEdgeSnapThreshold()) + dy = dtty; + else if (dby > 0 && dby < screen->getEdgeSnapThreshold()) + dy = dbby - frame.snap_h; + } + // Warp to next or previous workspace?, must have moved sideways some + int moved_x=me->x_root - frame.resize_x; + // save last event point + frame.resize_x = me->x_root; + frame.resize_y = me->y_root; + if (moved_x && screen->isWorkspaceWarping()) { + int cur_id = screen->getCurrentWorkspaceID(); + int new_id = cur_id; + const int warpPad = screen->getEdgeSnapThreshold(); + if (me->x_root >= int(screen->getWidth()) - warpPad - 1 && + frame.x < int(me->x_root - frame.grab_x - screen->getBorderWidth())) { + //warp right + new_id = (cur_id + 1) % screen->getCount(); + dx = -me->x_root; + } else if (me->x_root <= warpPad && + frame.x > int(me->x_root - frame.grab_x - screen->getBorderWidth())) { + //warp left + new_id = (cur_id - 1 + screen->getCount()) % screen->getCount(); + dx = screen->getWidth() - me->x_root-1; + } + if (new_id != cur_id) { + XWarpPointer(display, None, None, 0, 0, 0, 0, dx, 0); - screen->changeWorkspaceID(new_id); + screen->changeWorkspaceID(new_id); - frame.resize_x = me->x_root+dx; - if (!screen->doOpaqueMove()) { - dx += frame.move_x; // for rectangle in correct position - } else { - dx += frame.x; // for window in correct position - } - } - } + frame.resize_x = me->x_root+dx; + if (!screen->doOpaqueMove()) { + dx += frame.move_x; // for rectangle in correct position + } else { + dx += frame.x; // for window in correct position + } + } + } - if (! screen->doOpaqueMove()) { - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, frame.resize_w, frame.resize_h); + if (! screen->doOpaqueMove()) { + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, frame.resize_w, frame.resize_h); - frame.move_x = dx; - frame.move_y = dy; + frame.move_x = dx; + frame.move_y = dy; - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, frame.resize_w, - frame.resize_h); - } else { - configure(dx, dy, frame.width, frame.height); - } + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, frame.resize_w, + frame.resize_h); + } else { + configure(dx, dy, frame.width, frame.height); + } - if (screen->doShowWindowPos()) - screen->showPosition(dx, dy); - } // end if moving - } else if (functions.resize && - (((me->state & Button1Mask) && (me->window == frame.right_grip || - me->window == frame.left_grip)) || - me->window == frame.window)) { - bool left = (me->window == frame.left_grip); + if (screen->doShowWindowPos()) + screen->showPosition(dx, dy); + } // end if moving + } else if (functions.resize && + (((me->state & Button1Mask) && (me->window == frame.right_grip || + me->window == frame.left_grip)) || + me->window == frame.window)) { + bool left = (me->window == frame.left_grip); - if (! resizing) { - startResizing(me, left); - } else if (resizing) { - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.resize_x, frame.resize_y, - frame.resize_w-1, frame.resize_h-1); + if (! resizing) { + startResizing(me, left); + } else if (resizing) { + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.resize_x, frame.resize_y, + frame.resize_w-1, frame.resize_h-1); - int gx, gy; + int gx, gy; - frame.resize_h = frame.height + (me->y - frame.grab_y); - if (frame.resize_h < 1) - frame.resize_h = 1; + frame.resize_h = frame.height + (me->y - frame.grab_y); + if (frame.resize_h < 1) + frame.resize_h = 1; - if (left) { - frame.resize_x = me->x_root - frame.grab_x; - if (frame.resize_x > (signed) (frame.x + frame.width)) - frame.resize_x = frame.resize_x + frame.width - 1; + if (left) { + frame.resize_x = me->x_root - frame.grab_x; + if (frame.resize_x > (signed) (frame.x + frame.width)) + frame.resize_x = frame.resize_x + frame.width - 1; - left_fixsize(&gx, &gy); - } else { - frame.resize_w = frame.width + (me->x - frame.grab_x); - if (frame.resize_w < 1) - frame.resize_w = 1; + left_fixsize(&gx, &gy); + } else { + frame.resize_w = frame.width + (me->x - frame.grab_x); + if (frame.resize_w < 1) + frame.resize_w = 1; - right_fixsize(&gx, &gy); - } + right_fixsize(&gx, &gy); + } - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.resize_x, frame.resize_y, - frame.resize_w-1, frame.resize_h-1); + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.resize_x, frame.resize_y, + frame.resize_w-1, frame.resize_h-1); - if (screen->doShowWindowPos()) - screen->showGeometry(gx, gy); - } - } + if (screen->doShowWindowPos()) + screen->showGeometry(gx, gy); + } + } } #ifdef SHAPE void FluxboxWindow::shapeEvent(XShapeEvent *) { - Fluxbox *fluxbox = Fluxbox::instance(); + Fluxbox *fluxbox = Fluxbox::instance(); - if (fluxbox->hasShapeExtensions()) { - if (frame.shaped) { - fluxbox->grab(); - if (! validateClient()) - return; - XShapeCombineShape(display, frame.window, ShapeBounding, - frame.mwm_border_w, frame.y_border + - frame.mwm_border_w, client.window, - ShapeBounding, ShapeSet); + if (fluxbox->hasShapeExtensions()) { + if (frame.shaped) { + fluxbox->grab(); + if (! validateClient()) + return; + XShapeCombineShape(display, frame.window, ShapeBounding, + frame.mwm_border_w, frame.y_border + + frame.mwm_border_w, client.window, + ShapeBounding, ShapeSet); - int num = 1; - XRectangle xrect[2]; - xrect[0].x = xrect[0].y = 0; - xrect[0].width = frame.width; - xrect[0].height = frame.y_border; + int num = 1; + XRectangle xrect[2]; + xrect[0].x = xrect[0].y = 0; + xrect[0].width = frame.width; + xrect[0].height = frame.y_border; - if (decorations.handle) { - xrect[1].x = 0; - xrect[1].y = frame.y_handle; - xrect[1].width = frame.width; - xrect[1].height = frame.handle_h + screen->getBorderWidth(); - num++; - } + if (decorations.handle) { + xrect[1].x = 0; + xrect[1].y = frame.y_handle; + xrect[1].width = frame.width; + xrect[1].height = frame.handle_h + screen->getBorderWidth(); + num++; + } - XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, - xrect, num, ShapeUnion, Unsorted); - fluxbox->ungrab(); - } - } + XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0, + xrect, num, ShapeUnion, Unsorted); + fluxbox->ungrab(); + } + } } #endif // SHAPE // TODO: functions should not be affected by decoration void FluxboxWindow::setDecoration(Decoration decoration) { - switch (decoration) { - case DECOR_NONE: - decorations.titlebar = decorations.border = decorations.handle = - decorations.iconify = decorations.maximize = - decorations.tab = false; //tab is also a decor - decorations.menu = true; // menu is present + switch (decoration) { + case DECOR_NONE: + decorations.titlebar = decorations.border = decorations.handle = + decorations.iconify = decorations.maximize = + decorations.tab = false; //tab is also a decor + decorations.menu = true; // menu is present // functions.iconify = functions.maximize = true; // functions.move = true; // We need to move even without decor // functions.resize = true; // We need to resize even without decor break; - default: - case DECOR_NORMAL: - decorations.titlebar = decorations.border = decorations.handle = - decorations.iconify = decorations.maximize = - decorations.menu = true; - functions.resize = functions.move = functions.iconify = - functions.maximize = true; - XMapSubwindows(display, frame.window); - XMapWindow(display, frame.window); + default: + case DECOR_NORMAL: + decorations.titlebar = decorations.border = decorations.handle = + decorations.iconify = decorations.maximize = + decorations.menu = true; + functions.resize = functions.move = functions.iconify = + functions.maximize = true; + XMapSubwindows(display, frame.window); + XMapWindow(display, frame.window); break; - case DECOR_TINY: - decorations.titlebar = decorations.iconify = decorations.menu = - functions.move = functions.iconify = true; - decorations.border = decorations.handle = decorations.maximize = - functions.resize = functions.maximize = false; - XMapSubwindows(display, frame.window); - XMapWindow(display, frame.window); + case DECOR_TINY: + decorations.titlebar = decorations.iconify = decorations.menu = + functions.move = functions.iconify = true; + decorations.border = decorations.handle = decorations.maximize = + functions.resize = functions.maximize = false; + XMapSubwindows(display, frame.window); + XMapWindow(display, frame.window); break; - case DECOR_TOOL: - decorations.titlebar = decorations.menu = functions.move = true; - decorations.iconify = decorations.border = decorations.handle = - decorations.maximize = functions.resize = functions.maximize = - functions.iconify = false; - decorate(); + case DECOR_TOOL: + decorations.titlebar = decorations.menu = functions.move = true; + decorations.iconify = decorations.border = decorations.handle = + decorations.maximize = functions.resize = functions.maximize = + functions.iconify = false; + decorate(); break; - } + } - reconfigure(); + reconfigure(); } void FluxboxWindow::toggleDecoration() { - //don't toggle decor if the window is shaded - if (isShaded()) - return; + //don't toggle decor if the window is shaded + if (isShaded()) + return; - if (decorations.enabled) { //remove decorations - setDecoration(DECOR_NONE); - decorations.enabled = false; - } else { //revert back to old decoration - setDecoration(old_decoration); - decorations.enabled = true; - } + if (decorations.enabled) { //remove decorations + setDecoration(DECOR_NONE); + decorations.enabled = false; + } else { //revert back to old decoration + setDecoration(old_decoration); + decorations.enabled = true; + } } bool FluxboxWindow::validateClient() { - XSync(display, false); + XSync(display, false); - XEvent e; - if (XCheckTypedWindowEvent(display, client.window, DestroyNotify, &e) || - XCheckTypedWindowEvent(display, client.window, UnmapNotify, &e)) { - XPutBackEvent(display, &e); - Fluxbox::instance()->ungrab(); + XEvent e; + if (XCheckTypedWindowEvent(display, client.window, DestroyNotify, &e) || + XCheckTypedWindowEvent(display, client.window, UnmapNotify, &e)) { + XPutBackEvent(display, &e); + Fluxbox::instance()->ungrab(); - return false; - } + return false; + } - return true; + return true; } void FluxboxWindow::startMoving(Window win) { - moving = true; - Fluxbox *fluxbox = Fluxbox::instance(); - XGrabPointer(display, win, False, Button1MotionMask | - ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - None, fluxbox->getMoveCursor(), CurrentTime); + moving = true; + Fluxbox *fluxbox = Fluxbox::instance(); + XGrabPointer(display, win, False, Button1MotionMask | + ButtonReleaseMask, GrabModeAsync, GrabModeAsync, + None, fluxbox->getMoveCursor(), CurrentTime); - if (m_windowmenu.get() && m_windowmenu->isVisible()) - m_windowmenu->hide(); + if (m_windowmenu.get() && m_windowmenu->isVisible()) + m_windowmenu->hide(); - fluxbox->maskWindowEvents(client.window, this); + fluxbox->maskWindowEvents(client.window, this); - if (! screen->doOpaqueMove()) { - fluxbox->grab(); + if (! screen->doOpaqueMove()) { + fluxbox->grab(); - frame.move_x = frame.x; - frame.move_y = frame.y; - frame.move_ws = screen->getCurrentWorkspaceID(); - frame.resize_w = frame.width + screen->getBorderWidth2x(); - frame.resize_h = ((shaded) ? frame.title_h : frame.height) + - screen->getBorderWidth2x(); + frame.move_x = frame.x; + frame.move_y = frame.y; + frame.move_ws = screen->getCurrentWorkspaceID(); + frame.resize_w = frame.width + screen->getBorderWidth2x(); + frame.resize_h = ((shaded) ? frame.title_h : frame.height) + + screen->getBorderWidth2x(); - if (screen->doShowWindowPos()) - screen->showPosition(frame.x, frame.y); + if (screen->doShowWindowPos()) + screen->showPosition(frame.x, frame.y); - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, - frame.resize_w, frame.resize_h); - } + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, + frame.resize_w, frame.resize_h); + } } void FluxboxWindow::stopMoving() { - moving = false; - Fluxbox *fluxbox = Fluxbox::instance(); + moving = false; + Fluxbox *fluxbox = Fluxbox::instance(); - fluxbox->maskWindowEvents(0, (FluxboxWindow *) 0); + fluxbox->maskWindowEvents(0, (FluxboxWindow *) 0); - if (! screen->doOpaqueMove()) { - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, frame.resize_w, - frame.resize_h); + if (! screen->doOpaqueMove()) { + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, frame.resize_w, + frame.resize_h); - configure(frame.move_x, frame.move_y, frame.width, frame.height); - fluxbox->ungrab(); - } else - configure(frame.x, frame.y, frame.width, frame.height); + configure(frame.move_x, frame.move_y, frame.width, frame.height); + fluxbox->ungrab(); + } else + configure(frame.x, frame.y, frame.width, frame.height); - screen->hideGeometry(); - XUngrabPointer(display, CurrentTime); + screen->hideGeometry(); + XUngrabPointer(display, CurrentTime); - XSync(display, False); //make sure the redraw is made before we continue + XSync(display, False); //make sure the redraw is made before we continue } void FluxboxWindow::pauseMoving() { - screen->hideGeometry(); // otherwise our window gets raised above it - if (screen->doOpaqueMove()) { - return; - } + screen->hideGeometry(); // otherwise our window gets raised above it + if (screen->doOpaqueMove()) { + return; + } - // remove old rectangle - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, frame.resize_w, frame.resize_h); + // remove old rectangle + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, frame.resize_w, frame.resize_h); - Fluxbox::instance()->ungrab(); - if (workspace_number != frame.move_ws) { - // get it out of view - frame.save_x = frame.x; - frame.save_y = frame.y; - frame.x = screen->getWidth()/2; - frame.y = screen->getHeight()+screen->getTabHeight()+10; // +10 to be safe - configure(frame.x, frame.y, frame.width, frame.height); - } + Fluxbox::instance()->ungrab(); + if (workspace_number != frame.move_ws) { + // get it out of view + frame.save_x = frame.x; + frame.save_y = frame.y; + frame.x = screen->getWidth()/2; + frame.y = screen->getHeight()+screen->getTabHeight()+10; // +10 to be safe + configure(frame.x, frame.y, frame.width, frame.height); + } } void FluxboxWindow::resumeMoving() { - if (screen->doOpaqueMove()) { - setInputFocus(); - screen->raiseFocus(); - if (screen->doShowWindowPos()) - screen->showPosition(frame.x, frame.y); - return; - } + if (screen->doOpaqueMove()) { + setInputFocus(); + screen->raiseFocus(); + if (screen->doShowWindowPos()) + screen->showPosition(frame.x, frame.y); + return; + } - if (workspace_number != frame.move_ws) { - frame.x = frame.save_x; - frame.y = frame.save_y; - } else { - // back on home workspace, display window - configure(frame.x, frame.y, frame.width, frame.height); - } - Fluxbox::instance()->grab(); - setInputFocus(); - screen->raiseFocus(); - if (screen->doShowWindowPos()) - screen->showPosition(frame.move_x, frame.move_y); - XSync(display, false); - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.move_x, frame.move_y, frame.resize_w, - frame.resize_h); + if (workspace_number != frame.move_ws) { + frame.x = frame.save_x; + frame.y = frame.save_y; + } else { + // back on home workspace, display window + configure(frame.x, frame.y, frame.width, frame.height); + } + Fluxbox::instance()->grab(); + setInputFocus(); + screen->raiseFocus(); + if (screen->doShowWindowPos()) + screen->showPosition(frame.move_x, frame.move_y); + XSync(display, false); + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.move_x, frame.move_y, frame.resize_w, + frame.resize_h); } void FluxboxWindow::startResizing(XMotionEvent *me, bool left) { - resizing = true; - Fluxbox *fluxbox = Fluxbox::instance(); - XGrabPointer(display, me->window, false, ButtonMotionMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, - ((left) ? fluxbox->getLowerLeftAngleCursor() : fluxbox->getLowerRightAngleCursor()), - CurrentTime); + resizing = true; + Fluxbox *fluxbox = Fluxbox::instance(); + XGrabPointer(display, me->window, false, ButtonMotionMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, + ((left) ? fluxbox->getLowerLeftAngleCursor() : fluxbox->getLowerRightAngleCursor()), + CurrentTime); - int gx, gy; - frame.grab_x = me->x - screen->getBorderWidth(); - frame.grab_y = me->y - screen->getBorderWidth2x(); - frame.resize_x = frame.x; - frame.resize_y = frame.y; - frame.resize_w = frame.width + screen->getBorderWidth2x(); - frame.resize_h = frame.height + screen->getBorderWidth2x(); + int gx, gy; + frame.grab_x = me->x - screen->getBorderWidth(); + frame.grab_y = me->y - screen->getBorderWidth2x(); + frame.resize_x = frame.x; + frame.resize_y = frame.y; + frame.resize_w = frame.width + screen->getBorderWidth2x(); + frame.resize_h = frame.height + screen->getBorderWidth2x(); - if (left) - left_fixsize(&gx, &gy); - else - right_fixsize(&gx, &gy); + if (left) + left_fixsize(&gx, &gy); + else + right_fixsize(&gx, &gy); - if (screen->doShowWindowPos()) - screen->showGeometry(gx, gy); + if (screen->doShowWindowPos()) + screen->showGeometry(gx, gy); - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.resize_x, frame.resize_y, - frame.resize_w-1, frame.resize_h-1); + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.resize_x, frame.resize_y, + frame.resize_w-1, frame.resize_h-1); } void FluxboxWindow::stopResizing(Window win) { - resizing = false; + resizing = false; - XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), - frame.resize_x, frame.resize_y, - frame.resize_w-1, frame.resize_h-1); + XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(), + frame.resize_x, frame.resize_y, + frame.resize_w-1, frame.resize_h-1); - screen->hideGeometry(); + screen->hideGeometry(); - if (win && win == frame.left_grip) - left_fixsize(); - else - right_fixsize(); + if (win && win == frame.left_grip) + left_fixsize(); + else + right_fixsize(); - configure(frame.resize_x, frame.resize_y, - frame.resize_w - screen->getBorderWidth2x(), - frame.resize_h - screen->getBorderWidth2x()); + configure(frame.resize_x, frame.resize_y, + frame.resize_w - screen->getBorderWidth2x(), + frame.resize_h - screen->getBorderWidth2x()); - if (tab) - tab->resize(); + if (tab) + tab->resize(); - Fluxbox::instance()->ungrab(); - XUngrabPointer(display, CurrentTime); + Fluxbox::instance()->ungrab(); + XUngrabPointer(display, CurrentTime); } //finds and redraw the icon label void FluxboxWindow::updateIcon() { - if (Fluxbox::instance()->useIconBar()) { - const IconBar *iconbar = 0; - const IconBarObj *icon = 0; - if ((iconbar = screen->getToolbar()->iconBar()) != 0) { - if ((icon = iconbar->findIcon(this)) != 0) - iconbar->draw(icon, icon->width()); - } - } + if (Fluxbox::instance()->useIconBar()) { + const IconBar *iconbar = 0; + const IconBarObj *icon = 0; + if ((iconbar = screen->getToolbar()->iconBar()) != 0) { + if ((icon = iconbar->findIcon(this)) != 0) + iconbar->draw(icon, icon->width()); + } + } } void FluxboxWindow::createTitlebar() { - frame.title = createChildWindow(frame.window); //create titlebar win - if (decorations.titlebar) { //have titlebar decorations? - Fluxbox *fb = Fluxbox::instance(); - fb->saveWindowSearch(frame.title, this); //save titlebar win - frame.label = createChildWindow(frame.title); //create label win in titlebar - fb->saveWindowSearch(frame.label, this); //save label win - } + frame.title = createChildWindow(frame.window); //create titlebar win + if (decorations.titlebar) { //have titlebar decorations? + Fluxbox *fb = Fluxbox::instance(); + fb->saveWindowSearch(frame.title, this); //save titlebar win + frame.label = createChildWindow(frame.title); //create label win in titlebar + fb->saveWindowSearch(frame.label, this); //save label win + } } void FluxboxWindow::destroyTitlebar() { - Fluxbox *fb = Fluxbox::instance(); + Fluxbox *fb = Fluxbox::instance(); - while ( !buttonlist.empty()) { //destroy all buttons on titlebar - fb->removeWindowSearch(buttonlist.back().win); - XDestroyWindow(display, buttonlist.back().win); - buttonlist.pop_back(); - } + while ( !buttonlist.empty()) { //destroy all buttons on titlebar + fb->removeWindowSearch(buttonlist.back().win); + XDestroyWindow(display, buttonlist.back().win); + buttonlist.pop_back(); + } - if (frame.title) { - if (frame.ftitle) { - image_ctrl->removeImage(frame.ftitle); - frame.ftitle = 0; - } + if (frame.title) { + if (frame.ftitle) { + image_ctrl->removeImage(frame.ftitle); + frame.ftitle = 0; + } - if (frame.utitle) { - image_ctrl->removeImage(frame.utitle); - frame.utitle = 0; - } + if (frame.utitle) { + image_ctrl->removeImage(frame.utitle); + frame.utitle = 0; + } - if (frame.flabel) { - image_ctrl->removeImage(frame.flabel); - frame.flabel = 0; - } + if (frame.flabel) { + image_ctrl->removeImage(frame.flabel); + frame.flabel = 0; + } - if( frame.ulabel) { - image_ctrl->removeImage(frame.ulabel); - frame.ulabel = 0; - } + if( frame.ulabel) { + image_ctrl->removeImage(frame.ulabel); + frame.ulabel = 0; + } - fb->removeWindowSearch(frame.label); - fb->removeWindowSearch(frame.title); + fb->removeWindowSearch(frame.label); + fb->removeWindowSearch(frame.title); - XDestroyWindow(display, frame.label); - frame.label = 0; - XDestroyWindow(display, frame.title); - frame.title = 0; - } + XDestroyWindow(display, frame.label); + frame.label = 0; + XDestroyWindow(display, frame.title); + frame.title = 0; + } } void FluxboxWindow::createHandle() { - if (!decorations.handle) - return; + if (!decorations.handle) + return; - Fluxbox *fluxbox = Fluxbox::instance(); - frame.handle = createChildWindow(frame.window); //create handle win - fluxbox->saveWindowSearch(frame.handle, this); //save handle win + Fluxbox *fluxbox = Fluxbox::instance(); + frame.handle = createChildWindow(frame.window); //create handle win + fluxbox->saveWindowSearch(frame.handle, this); //save handle win - frame.left_grip = // create left handle - createChildWindow(frame.handle, fluxbox->getLowerLeftAngleCursor()); - fluxbox->saveWindowSearch(frame.left_grip, this); //save left handle + frame.left_grip = // create left handle + createChildWindow(frame.handle, fluxbox->getLowerLeftAngleCursor()); + fluxbox->saveWindowSearch(frame.left_grip, this); //save left handle - frame.right_grip = // create right handle - createChildWindow(frame.handle, fluxbox->getLowerRightAngleCursor()); - fluxbox->saveWindowSearch(frame.right_grip, this); //save right handle + frame.right_grip = // create right handle + createChildWindow(frame.handle, fluxbox->getLowerRightAngleCursor()); + fluxbox->saveWindowSearch(frame.right_grip, this); //save right handle } void FluxboxWindow::destroyHandle() { - if (frame.fhandle) { - image_ctrl->removeImage(frame.fhandle); - frame.fhandle = 0; - } + if (frame.fhandle) { + image_ctrl->removeImage(frame.fhandle); + frame.fhandle = 0; + } - if (frame.uhandle) { - image_ctrl->removeImage(frame.uhandle); - frame.uhandle = 0; - } + if (frame.uhandle) { + image_ctrl->removeImage(frame.uhandle); + frame.uhandle = 0; + } - if (frame.fgrip) { - image_ctrl->removeImage(frame.fgrip); - frame.fgrip = 0; - } + if (frame.fgrip) { + image_ctrl->removeImage(frame.fgrip); + frame.fgrip = 0; + } - if (frame.ugrip) { - image_ctrl->removeImage(frame.ugrip); - frame.ugrip = 0; - } - Fluxbox *fluxbox = Fluxbox::instance(); + if (frame.ugrip) { + image_ctrl->removeImage(frame.ugrip); + frame.ugrip = 0; + } + Fluxbox *fluxbox = Fluxbox::instance(); - if (frame.right_grip != 0) { - fluxbox->removeWindowSearch(frame.right_grip); - XDestroyWindow(display, frame.right_grip); - frame.right_grip = 0; - } + if (frame.right_grip != 0) { + fluxbox->removeWindowSearch(frame.right_grip); + XDestroyWindow(display, frame.right_grip); + frame.right_grip = 0; + } - if (frame.left_grip != 0) { - fluxbox->removeWindowSearch(frame.left_grip); - XDestroyWindow(display, frame.left_grip); - frame.left_grip = 0; - } + if (frame.left_grip != 0) { + fluxbox->removeWindowSearch(frame.left_grip); + XDestroyWindow(display, frame.left_grip); + frame.left_grip = 0; + } - if (frame.handle != 0) { - fluxbox->removeWindowSearch(frame.handle); - XDestroyWindow(display, frame.handle); - frame.handle = 0; - } + if (frame.handle != 0) { + fluxbox->removeWindowSearch(frame.handle); + XDestroyWindow(display, frame.handle); + frame.handle = 0; + } } void FluxboxWindow::checkTransient() { - // remove us from parent - if (client.transient_for != 0) { - client.transient_for->client.transients.remove(this); - } - client.transient_for = 0; + // remove us from parent + if (client.transient_for != 0) { + client.transient_for->client.transients.remove(this); + } + client.transient_for = 0; // determine if this is a transient window - Window win; - if (!XGetTransientForHint(display, client.window, &win)) - return; + Window win; + if (!XGetTransientForHint(display, client.window, &win)) + return; - if (win == client.window) - return; + if (win == client.window) + return; - if (win == screen->getRootWindow() && win != 0) { - modal = true; - return; - } + if (win == screen->getRootWindow() && win != 0) { + modal = true; + return; + } - client.transient_for = Fluxbox::instance()->searchWindow(win); - if (client.transient_for != 0 && - client.window_group != None && win == client.window_group) { - client.transient_for = Fluxbox::instance()->searchGroup(win, this); - } + client.transient_for = Fluxbox::instance()->searchWindow(win); + if (client.transient_for != 0 && + client.window_group != None && win == client.window_group) { + client.transient_for = Fluxbox::instance()->searchGroup(win, this); + } - // make sure we don't have deadlock loop in transient chain - for (FluxboxWindow *w = this; w != 0; w = w->client.transient_for) { - if (w == w->client.transient_for) { - w->client.transient_for = 0; + // make sure we don't have deadlock loop in transient chain + for (FluxboxWindow *w = this; w != 0; w = w->client.transient_for) { + if (w == w->client.transient_for) { + w->client.transient_for = 0; #ifdef DEBUG - cerr<<"w = client.transient_for"; + cerr<<"w = client.transient_for"; #endif // DEBUG - break; - } - } + break; + } + } - if (client.transient_for != 0) { - client.transient_for->client.transients.push_back(this); - // make sure we only have on instance of this - client.transient_for->client.transients.unique(); - stuck = client.transient_for->stuck; - } + if (client.transient_for != 0) { + client.transient_for->client.transients.push_back(this); + // make sure we only have on instance of this + client.transient_for->client.transients.unique(); + stuck = client.transient_for->stuck; + } } void FluxboxWindow::restore(bool remap) { - XChangeSaveSet(display, client.window, SetModeDelete); - XSelectInput(display, client.window, NoEventMask); + XChangeSaveSet(display, client.window, SetModeDelete); + XSelectInput(display, client.window, NoEventMask); - restoreGravity(); + restoreGravity(); - XUnmapWindow(display, frame.window); - XUnmapWindow(display, client.window); + XUnmapWindow(display, frame.window); + XUnmapWindow(display, client.window); - XSetWindowBorderWidth(display, client.window, client.old_bw); - XEvent dummy; - if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify, - &dummy)) { + XSetWindowBorderWidth(display, client.window, client.old_bw); + XEvent dummy; + if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify, + &dummy)) { #ifdef DEBUG - fprintf(stderr, - I18n::instance()->getMessage( - FBNLS::WindowSet, FBNLS::WindowUnmapNotifyReparent, - "FluxboxWindow::restore: reparent 0x%lx to " - "root.\n"), client.window); + fprintf(stderr, + I18n::instance()->getMessage( + FBNLS::WindowSet, FBNLS::WindowUnmapNotifyReparent, + "FluxboxWindow::restore: reparent 0x%lx to " + "root.\n"), client.window); #endif // DEBUG - XReparentWindow(display, client.window, screen->getRootWindow(), + XReparentWindow(display, client.window, screen->getRootWindow(), client.x, client.y); - } + } - if (remap) - XMapWindow(display, client.window); + if (remap) + XMapWindow(display, client.window); } void FluxboxWindow::timeout() { - if (tab) - tab->raise(); - screen->getWorkspace(workspace_number)->raiseWindow(this); + if (tab) + tab->raise(); + screen->getWorkspace(workspace_number)->raiseWindow(this); } void FluxboxWindow::changeBlackboxHints(BaseDisplay::BlackboxHints *net) { - if ((net->flags & BaseDisplay::ATTRIB_SHADED) && - ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) != - (net->attrib & BaseDisplay::ATTRIB_SHADED))) - shade(); + if ((net->flags & BaseDisplay::ATTRIB_SHADED) && + ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_SHADED) != + (net->attrib & BaseDisplay::ATTRIB_SHADED))) + shade(); - if ((net->flags & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) && - ((blackbox_attrib.attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) != - (net->attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)))) { - if (maximized) { - maximize(0); - } else { - int m = 0; + if ((net->flags & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) && + ((blackbox_attrib.attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)) != + (net->attrib & (BaseDisplay::ATTRIB_MAXVERT | BaseDisplay::ATTRIB_MAXHORIZ)))) { + if (maximized) { + maximize(0); + } else { + int m = 0; - if ((net->flags & BaseDisplay::ATTRIB_MAXHORIZ) && (net->flags & BaseDisplay::ATTRIB_MAXVERT)) - m = ((net->attrib & (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? 1 : 0); - else if (net->flags & BaseDisplay::ATTRIB_MAXVERT) - m = ((net->attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); - else if (net->flags & BaseDisplay::ATTRIB_MAXHORIZ) - m = ((net->attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); + if ((net->flags & BaseDisplay::ATTRIB_MAXHORIZ) && (net->flags & BaseDisplay::ATTRIB_MAXVERT)) + m = ((net->attrib & (BaseDisplay::ATTRIB_MAXHORIZ | BaseDisplay::ATTRIB_MAXVERT)) ? 1 : 0); + else if (net->flags & BaseDisplay::ATTRIB_MAXVERT) + m = ((net->attrib & BaseDisplay::ATTRIB_MAXVERT) ? 2 : 0); + else if (net->flags & BaseDisplay::ATTRIB_MAXHORIZ) + m = ((net->attrib & BaseDisplay::ATTRIB_MAXHORIZ) ? 3 : 0); - maximize(m); - } - } + maximize(m); + } + } - if ((net->flags & BaseDisplay::ATTRIB_OMNIPRESENT) && - ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) != - (net->attrib & BaseDisplay::ATTRIB_OMNIPRESENT))) - stick(); + if ((net->flags & BaseDisplay::ATTRIB_OMNIPRESENT) && + ((blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) != + (net->attrib & BaseDisplay::ATTRIB_OMNIPRESENT))) + stick(); - if ((net->flags & BaseDisplay::ATTRIB_WORKSPACE) && - (workspace_number != net->workspace)) { + if ((net->flags & BaseDisplay::ATTRIB_WORKSPACE) && + (workspace_number != net->workspace)) { - if (getTab()) // disconnect from tab chain before sending it to another workspace - getTab()->disconnect(); + if (getTab()) // disconnect from tab chain before sending it to another workspace + getTab()->disconnect(); - screen->reassociateWindow(this, net->workspace, true); + screen->reassociateWindow(this, net->workspace, true); - if (screen->getCurrentWorkspaceID() != net->workspace) - withdraw(); - else - deiconify(); - } + if (screen->getCurrentWorkspaceID() != net->workspace) + withdraw(); + else + deiconify(); + } - if (net->flags & BaseDisplay::ATTRIB_DECORATION) { - old_decoration = static_cast<Decoration>(net->decoration); - setDecoration(old_decoration); - } + if (net->flags & BaseDisplay::ATTRIB_DECORATION) { + old_decoration = static_cast<Decoration>(net->decoration); + setDecoration(old_decoration); + } } void FluxboxWindow::upsize() { - // convert client.width/height into frame sizes + // convert client.width/height into frame sizes - frame.bevel_w = screen->getBevelWidth(); - frame.mwm_border_w = screen->getFrameWidth() * decorations.border; + frame.bevel_w = screen->getBevelWidth(); + frame.mwm_border_w = screen->getFrameWidth() * decorations.border; - frame.title_h = screen->getWindowStyle()->font.height() + - (frame.bevel_w*2 + 2)*decorations.titlebar; + frame.title_h = screen->getWindowStyle()->font.height() + + (frame.bevel_w*2 + 2)*decorations.titlebar; - frame.label_h = (frame.title_h - (frame.bevel_w * 2)) * decorations.titlebar; - frame.button_w = frame.button_h = frame.label_h - 2; + frame.label_h = (frame.title_h - (frame.bevel_w * 2)) * decorations.titlebar; + frame.button_w = frame.button_h = frame.label_h - 2; - frame.y_border = (frame.title_h + screen->getBorderWidth()) * decorations.titlebar; - frame.border_h = client.height + (frame.mwm_border_w * 2); + frame.y_border = (frame.title_h + screen->getBorderWidth()) * decorations.titlebar; + frame.border_h = client.height + (frame.mwm_border_w * 2); - frame.y_handle = frame.y_border + frame.border_h + - (screen->getBorderWidth() * decorations.handle); - frame.handle_h = decorations.handle * screen->getHandleWidth(); + frame.y_handle = frame.y_border + frame.border_h + + (screen->getBorderWidth() * decorations.handle); + frame.handle_h = decorations.handle * screen->getHandleWidth(); - frame.grip_w = (frame.button_h * 2) * decorations.handle; - frame.grip_h = screen->getHandleWidth() * decorations.handle; + frame.grip_w = (frame.button_h * 2) * decorations.handle; + frame.grip_h = screen->getHandleWidth() * decorations.handle; - frame.width = client.width + (frame.mwm_border_w * 2); - frame.height = frame.y_handle + frame.handle_h; + frame.width = client.width + (frame.mwm_border_w * 2); + frame.height = frame.y_handle + frame.handle_h; - frame.snap_w = frame.width + screen->getBorderWidth2x(); - frame.snap_h = frame.height + screen->getBorderWidth2x(); + frame.snap_w = frame.width + screen->getBorderWidth2x(); + frame.snap_h = frame.height + screen->getBorderWidth2x(); } void FluxboxWindow::downsize() { - // convert frame.width/height into client sizes + // convert frame.width/height into client sizes - frame.y_handle = frame.height - frame.handle_h; - frame.border_h = frame.y_handle - frame.y_border - - (screen->getBorderWidth() * decorations.handle); + frame.y_handle = frame.height - frame.handle_h; + frame.border_h = frame.y_handle - frame.y_border - + (screen->getBorderWidth() * decorations.handle); - client.x = frame.x + frame.mwm_border_w + screen->getBorderWidth(); - client.y = frame.y + frame.y_border + frame.mwm_border_w + - screen->getBorderWidth(); + client.x = frame.x + frame.mwm_border_w + screen->getBorderWidth(); + client.y = frame.y + frame.y_border + frame.mwm_border_w + + screen->getBorderWidth(); - client.width = frame.width - (frame.mwm_border_w * 2); - client.height = frame.height - frame.y_border - - (frame.mwm_border_w * 2) - frame.handle_h - - (screen->getBorderWidth() * decorations.handle); + client.width = frame.width - (frame.mwm_border_w * 2); + client.height = frame.height - frame.y_border - + (frame.mwm_border_w * 2) - frame.handle_h - + (screen->getBorderWidth() * decorations.handle); - frame.y_handle = frame.border_h + frame.y_border + screen->getBorderWidth(); + frame.y_handle = frame.border_h + frame.y_border + screen->getBorderWidth(); - frame.snap_w = frame.width + screen->getBorderWidth2x(); - frame.snap_h = frame.height + screen->getBorderWidth2x(); + frame.snap_w = frame.width + screen->getBorderWidth2x(); + frame.snap_h = frame.height + screen->getBorderWidth2x(); } void FluxboxWindow::right_fixsize(int *gx, int *gy) { - // calculate the size of the client window and conform it to the - // size specified by the size hints of the client window... - int dx = frame.resize_w - client.base_width - (frame.mwm_border_w * 2) - - screen->getBorderWidth2x(); - int dy = frame.resize_h - frame.y_border - client.base_height - - frame.handle_h - (screen->getBorderWidth() * (2+decorations.border)) - (frame.mwm_border_w * 2); + // calculate the size of the client window and conform it to the + // size specified by the size hints of the client window... + int dx = frame.resize_w - client.base_width - (frame.mwm_border_w * 2) - + screen->getBorderWidth2x(); + int dy = frame.resize_h - frame.y_border - client.base_height - + frame.handle_h - (screen->getBorderWidth() * (2+decorations.border)) - (frame.mwm_border_w * 2); - if (dx < (signed) client.min_width) - dx = client.min_width; - if (dy < (signed) client.min_height) - dy = client.min_height; - if (client.max_width > 0 && (unsigned) dx > client.max_width) - dx = client.max_width; - if (client.max_height > 0 && (unsigned) dy > client.max_height) - dy = client.max_height; + if (dx < (signed) client.min_width) + dx = client.min_width; + if (dy < (signed) client.min_height) + dy = client.min_height; + if (client.max_width > 0 && (unsigned) dx > client.max_width) + dx = client.max_width; + if (client.max_height > 0 && (unsigned) dy > client.max_height) + dy = client.max_height; - dx /= client.width_inc; - dy /= client.height_inc; + dx /= client.width_inc; + dy /= client.height_inc; - if (gx) *gx = dx; - if (gy) *gy = dy; + if (gx) *gx = dx; + if (gy) *gy = dy; - dx = (dx * client.width_inc) + client.base_width; - dy = (dy * client.height_inc) + client.base_height; + dx = (dx * client.width_inc) + client.base_width; + dy = (dy * client.height_inc) + client.base_height; - frame.resize_w = dx + (frame.mwm_border_w * 2) + screen->getBorderWidth2x(); - frame.resize_h = dy + frame.y_border + frame.handle_h + - (frame.mwm_border_w * 2) + (screen->getBorderWidth() * - (2+decorations.border)); + frame.resize_w = dx + (frame.mwm_border_w * 2) + screen->getBorderWidth2x(); + frame.resize_h = dy + frame.y_border + frame.handle_h + + (frame.mwm_border_w * 2) + (screen->getBorderWidth() * + (2+decorations.border)); } void FluxboxWindow::left_fixsize(int *gx, int *gy) { - // calculate the size of the client window and conform it to the - // size specified by the size hints of the client window... - int dx = frame.x + frame.width - frame.resize_x - client.base_width - - (frame.mwm_border_w * 2); - int dy = frame.resize_h - frame.y_border - client.base_height - - frame.handle_h - (screen->getBorderWidth() * (2+decorations.border)) - (frame.mwm_border_w * 2); + // calculate the size of the client window and conform it to the + // size specified by the size hints of the client window... + int dx = frame.x + frame.width - frame.resize_x - client.base_width - + (frame.mwm_border_w * 2); + int dy = frame.resize_h - frame.y_border - client.base_height - + frame.handle_h - (screen->getBorderWidth() * (2+decorations.border)) - (frame.mwm_border_w * 2); - if (dx < (signed) client.min_width) dx = client.min_width; - if (dy < (signed) client.min_height) dy = client.min_height; - if (client.max_width > 0 && (unsigned) dx > client.max_width) dx = client.max_width; - if (client.max_height > 0 && (unsigned) dy > client.max_height) dy = client.max_height; + if (dx < (signed) client.min_width) dx = client.min_width; + if (dy < (signed) client.min_height) dy = client.min_height; + if (client.max_width > 0 && (unsigned) dx > client.max_width) dx = client.max_width; + if (client.max_height > 0 && (unsigned) dy > client.max_height) dy = client.max_height; - dx /= client.width_inc; - dy /= client.height_inc; + dx /= client.width_inc; + dy /= client.height_inc; - if (gx) *gx = dx; - if (gy) *gy = dy; + if (gx) *gx = dx; + if (gy) *gy = dy; - dx = (dx * client.width_inc) + client.base_width; - dy = (dy * client.height_inc) + client.base_height; + dx = (dx * client.width_inc) + client.base_width; + dy = (dy * client.height_inc) + client.base_height; - frame.resize_w = dx + (frame.mwm_border_w * 2) + screen->getBorderWidth2x(); - frame.resize_x = frame.x + frame.width - frame.resize_w + - screen->getBorderWidth2x(); - frame.resize_h = dy + frame.y_border + frame.handle_h + - (frame.mwm_border_w * 2) + (screen->getBorderWidth() * - (2+decorations.border)); + frame.resize_w = dx + (frame.mwm_border_w * 2) + screen->getBorderWidth2x(); + frame.resize_x = frame.x + frame.width - frame.resize_w + + screen->getBorderWidth2x(); + frame.resize_h = dy + frame.y_border + frame.handle_h + + (frame.mwm_border_w * 2) + (screen->getBorderWidth() * + (2+decorations.border)); }
M src/Window.hhsrc/Window.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: Window.hh,v 1.37 2002/11/23 16:07:19 rathnor Exp $ +// $Id: Window.hh,v 1.38 2002/12/01 13:42:05 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH

@@ -55,343 +55,343 @@ */

class FluxboxWindow : public TimeoutHandler { public: - enum WinLayer { - LAYER_BOTTOM = 0x01, - LAYER_BELOW = 0x02, - LAYER_NORMAL = 0x04, - LAYER_TOP = 0x08 - }; + enum WinLayer { + LAYER_BOTTOM = 0x01, + LAYER_BELOW = 0x02, + LAYER_NORMAL = 0x04, + LAYER_TOP = 0x08 + }; - enum Decoration {DECOR_NONE=0, DECOR_NORMAL, DECOR_TINY, DECOR_TOOL}; + enum Decoration {DECOR_NONE=0, DECOR_NORMAL, DECOR_TINY, DECOR_TOOL}; - //Motif wm Hints - enum { - MwmHintsFunctions = (1l << 0), - MwmHintsDecorations = (1l << 1) - }; + //Motif wm Hints + enum { + MwmHintsFunctions = (1l << 0), + MwmHintsDecorations = (1l << 1) + }; - //Motif wm functions - enum MwmFunc{ - MwmFuncAll = (1l << 0), - MwmFuncResize = (1l << 1), - MwmFuncMove = (1l << 2), - MwmFuncIconify = (1l << 3), - MwmFuncMaximize = (1l << 4), - MwmFuncClose = (1l << 5) - }; - //Motif wm decorations - enum MwmDecor { - MwmDecorAll = (1l << 0), - MwmDecorBorder = (1l << 1), - MwmDecorHandle = (1l << 2), - MwmDecorTitle = (1l << 3), - MwmDecorMenu = (1l << 4), - MwmDecorIconify = (1l << 5), - MwmDecorMaximize = (1l << 6) - }; + //Motif wm functions + enum MwmFunc{ + MwmFuncAll = (1l << 0), + MwmFuncResize = (1l << 1), + MwmFuncMove = (1l << 2), + MwmFuncIconify = (1l << 3), + MwmFuncMaximize = (1l << 4), + MwmFuncClose = (1l << 5) + }; + //Motif wm decorations + enum MwmDecor { + MwmDecorAll = (1l << 0), + MwmDecorBorder = (1l << 1), + MwmDecorHandle = (1l << 2), + MwmDecorTitle = (1l << 3), + MwmDecorMenu = (1l << 4), + MwmDecorIconify = (1l << 5), + MwmDecorMaximize = (1l << 6) + }; - explicit FluxboxWindow(Window win, BScreen *scr = 0); - virtual ~FluxboxWindow(); - /** - @name accessors - */ - //@{ - bool isTransient() const { return ((client.transient_for) ? true : false); } - bool hasTransient() const { return ((client.transients.size()) ? true : false); } - bool isManaged() const { return managed; } - bool isFocused() const { return focused; } - bool isVisible() const { return visible; } - bool isIconic() const { return iconic; } - bool isShaded() const { return shaded; } - bool isMaximized() const { return maximized; } - bool isIconifiable() const { return functions.iconify; } - bool isMaximizable() const { return functions.maximize; } - bool isResizable() const { return functions.resize; } - bool isClosable() const { return functions.close; } - bool isStuck() const { return stuck; } - bool hasTitlebar() const { return decorations.titlebar; } - bool hasTab() const { return (tab!=0 ? true : false); } - bool isMoving() const { return moving; } - bool isResizing() const { return resizing; } - bool isGroupable() const; - const BScreen *getScreen() const { return screen; } - BScreen *getScreen() { return screen; } - const Tab *getTab() const { return tab; } - Tab *getTab() { return tab; } - const std::list<FluxboxWindow *> &getTransients() const { return client.transients; } - std::list<FluxboxWindow *> &getTransients() { return client.transients; } - const FluxboxWindow *getTransientFor() const { return client.transient_for; } - FluxboxWindow *getTransientFor() { return client.transient_for; } + explicit FluxboxWindow(Window win, BScreen *scr = 0); + virtual ~FluxboxWindow(); + /** + @name accessors + */ + //@{ + bool isTransient() const { return ((client.transient_for) ? true : false); } + bool hasTransient() const { return ((client.transients.size()) ? true : false); } + bool isManaged() const { return managed; } + bool isFocused() const { return focused; } + bool isVisible() const { return visible; } + bool isIconic() const { return iconic; } + bool isShaded() const { return shaded; } + bool isMaximized() const { return maximized; } + bool isIconifiable() const { return functions.iconify; } + bool isMaximizable() const { return functions.maximize; } + bool isResizable() const { return functions.resize; } + bool isClosable() const { return functions.close; } + bool isStuck() const { return stuck; } + bool hasTitlebar() const { return decorations.titlebar; } + bool hasTab() const { return (tab!=0 ? true : false); } + bool isMoving() const { return moving; } + bool isResizing() const { return resizing; } + bool isGroupable() const; + const BScreen *getScreen() const { return screen; } + BScreen *getScreen() { return screen; } + const Tab *getTab() const { return tab; } + Tab *getTab() { return tab; } + const std::list<FluxboxWindow *> &getTransients() const { return client.transients; } + std::list<FluxboxWindow *> &getTransients() { return client.transients; } + const FluxboxWindow *getTransientFor() const { return client.transient_for; } + FluxboxWindow *getTransientFor() { return client.transient_for; } - const Window &getFrameWindow() const { return frame.window; } - const Window &getClientWindow() const { return client.window; } + const Window &getFrameWindow() const { return frame.window; } + const Window &getClientWindow() const { return client.window; } - Windowmenu *getWindowmenu() { return m_windowmenu.get(); } - const Windowmenu *getWindowmenu() const { return m_windowmenu.get(); } + Windowmenu *getWindowmenu() { return m_windowmenu.get(); } + const Windowmenu *getWindowmenu() const { return m_windowmenu.get(); } - const std::string &getTitle() const { return client.title; } - const std::string &getIconTitle() const { return client.icon_title; } - int getXFrame() const { return frame.x; } - int getYFrame() const { return frame.y; } - int getXClient() const { return client.x; } - int getYClient() const { return client.y; } - unsigned int getWorkspaceNumber() const { return workspace_number; } - int getWindowNumber() const { return window_number; } - WinLayer getLayer() const { return m_layer; } - unsigned int getWidth() const { return frame.width; } - unsigned int getHeight() const { return frame.height; } - unsigned int getClientHeight() const { return client.height; } - unsigned int getClientWidth() const { return client.width; } - unsigned int getTitleHeight() const { return frame.title_h; } - const std::string &className() const { return m_class_name; } - const std::string &instanceName() const { return m_instance_name; } - bool isLowerTab() const; - /** - @name signals - */ - //@{ - FbTk::Subject &stateSig() { return m_statesig; } - const FbTk::Subject &stateSig() const { return m_statesig; } - FbTk::Subject &hintSig() { return m_hintsig; } - const FbTk::Subject &hintSig() const { return m_hintsig; } - FbTk::Subject &workspaceSig() { return m_workspacesig; } - const FbTk::Subject &workspaceSig() const { return m_workspacesig; } - //@} + const std::string &getTitle() const { return client.title; } + const std::string &getIconTitle() const { return client.icon_title; } + int getXFrame() const { return frame.x; } + int getYFrame() const { return frame.y; } + int getXClient() const { return client.x; } + int getYClient() const { return client.y; } + unsigned int getWorkspaceNumber() const { return workspace_number; } + int getWindowNumber() const { return window_number; } + WinLayer getLayer() const { return m_layer; } + unsigned int getWidth() const { return frame.width; } + unsigned int getHeight() const { return frame.height; } + unsigned int getClientHeight() const { return client.height; } + unsigned int getClientWidth() const { return client.width; } + unsigned int getTitleHeight() const { return frame.title_h; } + const std::string &className() const { return m_class_name; } + const std::string &instanceName() const { return m_instance_name; } + bool isLowerTab() const; + /** + @name signals + */ + //@{ + FbTk::Subject &stateSig() { return m_statesig; } + const FbTk::Subject &stateSig() const { return m_statesig; } + FbTk::Subject &hintSig() { return m_hintsig; } + const FbTk::Subject &hintSig() const { return m_hintsig; } + FbTk::Subject &workspaceSig() { return m_workspacesig; } + const FbTk::Subject &workspaceSig() const { return m_workspacesig; } + //@} - //@} + //@} - void setWindowNumber(int n) { window_number = n; } + void setWindowNumber(int n) { window_number = n; } - const timeval &getLastFocusTime() const {return lastFocusTime;} + const timeval &getLastFocusTime() const {return lastFocusTime;} - bool validateClient(); - bool setInputFocus(); - void setTab(bool flag); - void setFocusFlag(bool flag); - void iconify(); - void deiconify(bool = true, bool = true); - void close(); - void withdraw(); - void maximize(unsigned int); - /// toggles shade - void shade(); - /// toggles sticky - void stick(); - void reconfigure(); - void installColormap(bool); - void restore(bool remap); - void configure(int dx, int dy, unsigned int dw, unsigned int dh); - void setWorkspace(int n); - void changeBlackboxHints(BaseDisplay::BlackboxHints *bh); - void restoreAttributes(); - void showMenu(int mx, int my); - void pauseMoving(); - void resumeMoving(); - /** - @name event handlers - */ - //@{ - void buttonPressEvent(XButtonEvent *be); - void buttonReleaseEvent(XButtonEvent *be); - void motionNotifyEvent(XMotionEvent *me); - bool destroyNotifyEvent(XDestroyWindowEvent *dwe); - void mapRequestEvent(XMapRequestEvent *mre); - void mapNotifyEvent(XMapEvent *mapev); - bool unmapNotifyEvent(XUnmapEvent *unmapev); - void propertyNotifyEvent(Atom a); - void exposeEvent(XExposeEvent *ee); - void configureRequestEvent(XConfigureRequestEvent *ce); - //@} + bool validateClient(); + bool setInputFocus(); + void setTab(bool flag); + void setFocusFlag(bool flag); + void iconify(); + void deiconify(bool = true, bool = true); + void close(); + void withdraw(); + void maximize(unsigned int); + /// toggles shade + void shade(); + /// toggles sticky + void stick(); + void reconfigure(); + void installColormap(bool); + void restore(bool remap); + void configure(int dx, int dy, unsigned int dw, unsigned int dh); + void setWorkspace(int n); + void changeBlackboxHints(BaseDisplay::BlackboxHints *bh); + void restoreAttributes(); + void showMenu(int mx, int my); + void pauseMoving(); + void resumeMoving(); + /** + @name event handlers + */ + //@{ + void buttonPressEvent(XButtonEvent *be); + void buttonReleaseEvent(XButtonEvent *be); + void motionNotifyEvent(XMotionEvent *me); + bool destroyNotifyEvent(XDestroyWindowEvent *dwe); + void mapRequestEvent(XMapRequestEvent *mre); + void mapNotifyEvent(XMapEvent *mapev); + bool unmapNotifyEvent(XUnmapEvent *unmapev); + void propertyNotifyEvent(Atom a); + void exposeEvent(XExposeEvent *ee); + void configureRequestEvent(XConfigureRequestEvent *ce); + //@} - void setDecoration(Decoration decoration); - void toggleDecoration(); + void setDecoration(Decoration decoration); + void toggleDecoration(); #ifdef SHAPE - void shapeEvent(XShapeEvent *); + void shapeEvent(XShapeEvent *); #endif // SHAPE - virtual void timeout(); + virtual void timeout(); - // this structure only contains 3 elements... the Motif 2.0 structure contains - // 5... we only need the first 3... so that is all we will define - typedef struct MwmHints { - unsigned long flags; // Motif wm flags - unsigned long functions; // Motif wm functions - unsigned long decorations; // Motif wm decorations - } MwmHints; + // this structure only contains 3 elements... the Motif 2.0 structure contains + // 5... we only need the first 3... so that is all we will define + typedef struct MwmHints { + unsigned long flags; // Motif wm flags + unsigned long functions; // Motif wm functions + unsigned long decorations; // Motif wm decorations + } MwmHints; - class WinSubject: public FbTk::Subject { - public: - WinSubject(FluxboxWindow &w):m_win(w) { } - FluxboxWindow &win() { return m_win; } - const FluxboxWindow &win() const { return m_win; } - private: - FluxboxWindow &m_win; - }; + class WinSubject: public FbTk::Subject { + public: + WinSubject(FluxboxWindow &w):m_win(w) { } + FluxboxWindow &win() { return m_win; } + const FluxboxWindow &win() const { return m_win; } + private: + FluxboxWindow &m_win; + }; private: - // state and hint signals - WinSubject m_hintsig, m_statesig, m_workspacesig; + // state and hint signals + WinSubject m_hintsig, m_statesig, m_workspacesig; - BImageControl *image_ctrl; /// image control for rendering + BImageControl *image_ctrl; /// image control for rendering - std::string m_instance_name; /// instance name from WM_CLASS - std::string m_class_name; /// class name from WM_CLASS + std::string m_instance_name; /// instance name from WM_CLASS + std::string m_class_name; /// class name from WM_CLASS - //Window state - bool moving, resizing, shaded, maximized, visible, iconic, transient, - focused, stuck, modal, send_focus_message, managed; + //Window state + bool moving, resizing, shaded, maximized, visible, iconic, transient, + focused, stuck, modal, send_focus_message, managed; - BScreen *screen; /// screen on which this window exist - BTimer timer; - Display *display; /// display connection (obsolete by BaseDisplay singleton) - BaseDisplay::BlackboxAttributes blackbox_attrib; + BScreen *screen; /// screen on which this window exist + BTimer timer; + Display *display; /// display connection (obsolete by BaseDisplay singleton) + BaseDisplay::BlackboxAttributes blackbox_attrib; - Time lastButtonPressTime; - std::auto_ptr<Windowmenu> m_windowmenu; + Time lastButtonPressTime; + std::auto_ptr<Windowmenu> m_windowmenu; - timeval lastFocusTime; + timeval lastFocusTime; - int focus_mode, window_number; - unsigned int workspace_number; - unsigned long current_state; - WinLayer m_layer; - Decoration old_decoration; + int focus_mode, window_number; + unsigned int workspace_number; + unsigned long current_state; + WinLayer m_layer; + Decoration old_decoration; - struct _client { - FluxboxWindow *transient_for; // which window are we a transient for? - std::list<FluxboxWindow *> transients; // which windows are our transients? - Window window, window_group; + struct _client { + FluxboxWindow *transient_for; // which window are we a transient for? + std::list<FluxboxWindow *> transients; // which windows are our transients? + Window window, window_group; - std::string title, icon_title; - int x, y, old_bw; - unsigned int width, height, title_text_w, - min_width, min_height, max_width, max_height, width_inc, height_inc, - min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, - base_width, base_height, win_gravity; - unsigned long initial_state, normal_hint_flags, wm_hint_flags; + std::string title, icon_title; + int x, y, old_bw; + unsigned int width, height, title_text_w, + min_width, min_height, max_width, max_height, width_inc, height_inc, + min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, + base_width, base_height, win_gravity; + unsigned long initial_state, normal_hint_flags, wm_hint_flags; - MwmHints *mwm_hint; - BaseDisplay::BlackboxHints *blackbox_hint; + MwmHints *mwm_hint; + BaseDisplay::BlackboxHints *blackbox_hint; - } client; + } client; - struct _decorations { - bool titlebar, handle, border, iconify, - maximize, close, menu, sticky, shade, tab, enabled; - } decorations; + struct _decorations { + bool titlebar, handle, border, iconify, + maximize, close, menu, sticky, shade, tab, enabled; + } decorations; - struct _functions { - bool resize, move, iconify, maximize, close; - } functions; + struct _functions { + bool resize, move, iconify, maximize, close; + } functions; - Tab *tab; - friend class Tab; //TODO: Don't like long distant friendship + Tab *tab; + friend class Tab; //TODO: Don't like long distant friendship - typedef void (*ButtonDrawProc)(FluxboxWindow *, Window, bool); - typedef void (*ButtonEventProc)(FluxboxWindow *, XButtonEvent *); + typedef void (*ButtonDrawProc)(FluxboxWindow *, Window, bool); + typedef void (*ButtonEventProc)(FluxboxWindow *, XButtonEvent *); - struct Button { - int type; - Window win; - bool used; - ButtonEventProc pressed; - ButtonEventProc released; - ButtonDrawProc draw; - }; + struct Button { + int type; + Window win; + bool used; + ButtonEventProc pressed; + ButtonEventProc released; + ButtonDrawProc draw; + }; - std::vector<Button> buttonlist; + std::vector<Button> buttonlist; - struct _frame { - Bool shaped; - unsigned long ulabel_pixel, flabel_pixel, utitle_pixel, - ftitle_pixel, uhandle_pixel, fhandle_pixel, ubutton_pixel, - fbutton_pixel, pbutton_pixel, uborder_pixel, fborder_pixel, - ugrip_pixel, fgrip_pixel; - Pixmap ulabel, flabel, utitle, ftitle, uhandle, fhandle, - ubutton, fbutton, pbutton, ugrip, fgrip; + struct _frame { + Bool shaped; + unsigned long ulabel_pixel, flabel_pixel, utitle_pixel, + ftitle_pixel, uhandle_pixel, fhandle_pixel, ubutton_pixel, + fbutton_pixel, pbutton_pixel, uborder_pixel, fborder_pixel, + ugrip_pixel, fgrip_pixel; + Pixmap ulabel, flabel, utitle, ftitle, uhandle, fhandle, + ubutton, fbutton, pbutton, ugrip, fgrip; - Window window, plate, title, label, handle, - right_grip, left_grip; + Window window, plate, title, label, handle, + right_grip, left_grip; - int x, y, resize_x, resize_y, move_x, move_y, grab_x, grab_y, - y_border, y_handle, save_x, save_y; - unsigned int width, height, title_h, label_w, label_h, handle_h, - button_w, button_h, grip_w, grip_h, mwm_border_w, border_h, - bevel_w, resize_w, resize_h, snap_w, snap_h, move_ws; - } frame; + int x, y, resize_x, resize_y, move_x, move_y, grab_x, grab_y, + y_border, y_handle, save_x, save_y; + unsigned int width, height, title_h, label_w, label_h, handle_h, + button_w, button_h, grip_w, grip_h, mwm_border_w, border_h, + bevel_w, resize_w, resize_h, snap_w, snap_h, move_ws; + } frame; - enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE }; + enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE }; - void grabButtons(); + void grabButtons(); - void createButton(int type, ButtonEventProc, ButtonEventProc, ButtonDrawProc); - void startMoving(Window win); - void stopMoving(); - void startResizing(XMotionEvent *me, bool left); - void stopResizing(Window win=0); - void updateIcon(); + void createButton(int type, ButtonEventProc, ButtonEventProc, ButtonDrawProc); + void startMoving(Window win); + void stopMoving(); + void startResizing(XMotionEvent *me, bool left); + void stopResizing(Window win=0); + void updateIcon(); - // Decoration functions - void createTitlebar(); - void destroyTitlebar(); - void createHandle(); - void destroyHandle(); - void checkTransient(); + // Decoration functions + void createTitlebar(); + void destroyTitlebar(); + void createHandle(); + void destroyHandle(); + void checkTransient(); - Window findTitleButton(int type); + Window findTitleButton(int type); - //event callbacks - static void stickyButton_cb(FluxboxWindow *, XButtonEvent *); - static void stickyPressed_cb(FluxboxWindow *, XButtonEvent *); - static void iconifyButton_cb(FluxboxWindow *, XButtonEvent *); - static void iconifyPressed_cb(FluxboxWindow *, XButtonEvent *); - static void maximizeButton_cb(FluxboxWindow *, XButtonEvent *); - static void maximizePressed_cb(FluxboxWindow *, XButtonEvent *); - static void closeButton_cb(FluxboxWindow *, XButtonEvent *); - static void closePressed_cb(FluxboxWindow *, XButtonEvent *); - static void shadeButton_cb(FluxboxWindow *, XButtonEvent *); - //draw callbacks - static void stickyDraw_cb(FluxboxWindow *, Window, bool); - static void iconifyDraw_cb(FluxboxWindow *, Window, bool); - static void maximizeDraw_cb(FluxboxWindow *, Window, bool); - static void closeDraw_cb(FluxboxWindow *, Window, bool); - static void shadeDraw_cb(FluxboxWindow *, Window, bool); + //event callbacks + static void stickyButton_cb(FluxboxWindow *, XButtonEvent *); + static void stickyPressed_cb(FluxboxWindow *, XButtonEvent *); + static void iconifyButton_cb(FluxboxWindow *, XButtonEvent *); + static void iconifyPressed_cb(FluxboxWindow *, XButtonEvent *); + static void maximizeButton_cb(FluxboxWindow *, XButtonEvent *); + static void maximizePressed_cb(FluxboxWindow *, XButtonEvent *); + static void closeButton_cb(FluxboxWindow *, XButtonEvent *); + static void closePressed_cb(FluxboxWindow *, XButtonEvent *); + static void shadeButton_cb(FluxboxWindow *, XButtonEvent *); + //draw callbacks + static void stickyDraw_cb(FluxboxWindow *, Window, bool); + static void iconifyDraw_cb(FluxboxWindow *, Window, bool); + static void maximizeDraw_cb(FluxboxWindow *, Window, bool); + static void closeDraw_cb(FluxboxWindow *, Window, bool); + static void shadeDraw_cb(FluxboxWindow *, Window, bool); - static void grabButton(Display *display, unsigned int button, Window window, Cursor cursor); - //button base draw... background - void drawButtonBase(Window, bool); + static void grabButton(Display *display, unsigned int button, Window window, Cursor cursor); + //button base draw... background + void drawButtonBase(Window, bool); - bool getState(); - Window createToplevelWindow(int, int, unsigned int, unsigned int, - unsigned int); - Window createChildWindow(Window, Cursor = None); + bool getState(); + Window createToplevelWindow(int, int, unsigned int, unsigned int, + unsigned int); + Window createChildWindow(Window, Cursor = None); - void getWMName(); - void getWMIconName(); - void getWMNormalHints(); - void getWMProtocols(); - void getWMHints(); - void getMWMHints(); - void getBlackboxHints(); - void setNetWMAttributes(); - void associateClientWindow(); - void decorate(); - void decorateLabel(); - void positionButtons(bool redecorate_label = false); - void positionWindows(); + void getWMName(); + void getWMIconName(); + void getWMNormalHints(); + void getWMProtocols(); + void getWMHints(); + void getMWMHints(); + void getBlackboxHints(); + void setNetWMAttributes(); + void associateClientWindow(); + void decorate(); + void decorateLabel(); + void positionButtons(bool redecorate_label = false); + void positionWindows(); - void redrawLabel(); - void redrawAllButtons(); + void redrawLabel(); + void redrawAllButtons(); - void restoreGravity(); - void setGravityOffsets(); - void setState(unsigned long stateval); - void upsize(); - void downsize(); - void right_fixsize(int * = 0, int * = 0); - void left_fixsize(int * = 0, int * = 0); + void restoreGravity(); + void setGravityOffsets(); + void setState(unsigned long stateval); + void upsize(); + void downsize(); + void right_fixsize(int * = 0, int * = 0); + void left_fixsize(int * = 0, int * = 0); };
M src/Windowmenu.ccsrc/Windowmenu.cc

@@ -21,7 +21,7 @@ // 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. -// $Id: Windowmenu.cc,v 1.21 2002/10/23 22:02:13 fluxgen Exp $ +// $Id: Windowmenu.cc,v 1.22 2002/12/01 13:42:05 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -42,72 +42,72 @@

#include <cstring> Windowmenu::Windowmenu(FluxboxWindow &win) : Basemenu(win.getScreen()), -window(win), -screen(win.getScreen()), -sendToMenu(win), -sendGroupToMenu(win) { + window(win), + screen(win.getScreen()), + sendToMenu(win), + sendGroupToMenu(win) { - setTitleVisibility(False); - setMovable(False); - setInternalMenu(); + setTitleVisibility(False); + setMovable(False); + setInternalMenu(); - I18n *i18n = I18n::instance(); + I18n *i18n = I18n::instance(); - using namespace FBNLS; - insert(i18n->getMessage( - WindowmenuSet, WindowmenuSendTo, - "Send To ..."), - &sendToMenu); + using namespace FBNLS; + insert(i18n->getMessage( + WindowmenuSet, WindowmenuSendTo, + "Send To ..."), + &sendToMenu); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuSendGroupTo, - "Send Group To ..."), - &sendGroupToMenu); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuSendGroupTo, + "Send Group To ..."), + &sendGroupToMenu); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuShade, - "Shade"), - BScreen::WINDOWSHADE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuIconify, - "Iconify"), - BScreen::WINDOWICONIFY); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuMaximize, - "Maximize"), - BScreen::WINDOWMAXIMIZE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuRaise, - "Raise"), - BScreen::WINDOWRAISE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuLower, - "Lower"), - BScreen::WINDOWLOWER); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuStick, - "Stick"), - BScreen::WINDOWSTICK); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuKillClient, - "Kill Client"), - BScreen::WINDOWKILL); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuClose, - "Close"), - BScreen::WINDOWCLOSE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuTab, - "Tab"), - BScreen::WINDOWTAB); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuShade, + "Shade"), + BScreen::WINDOWSHADE); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuIconify, + "Iconify"), + BScreen::WINDOWICONIFY); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuMaximize, + "Maximize"), + BScreen::WINDOWMAXIMIZE); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuRaise, + "Raise"), + BScreen::WINDOWRAISE); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuLower, + "Lower"), + BScreen::WINDOWLOWER); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuStick, + "Stick"), + BScreen::WINDOWSTICK); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuKillClient, + "Kill Client"), + BScreen::WINDOWKILL); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuClose, + "Close"), + BScreen::WINDOWCLOSE); + insert(i18n->getMessage( + WindowmenuSet, WindowmenuTab, + "Tab"), + BScreen::WINDOWTAB); - update(); + update(); - setItemEnabled(2, window.hasTitlebar()); - setItemEnabled(3, window.isIconifiable()); - setItemEnabled(4, window.isMaximizable()); - setItemEnabled(9, window.isClosable()); - setItemEnabled(10, window.isGroupable()); // tab option + setItemEnabled(2, window.hasTitlebar()); + setItemEnabled(3, window.isIconifiable()); + setItemEnabled(4, window.isMaximizable()); + setItemEnabled(9, window.isClosable()); + setItemEnabled(10, window.isGroupable()); // tab option }

@@ -118,185 +118,185 @@ }

void Windowmenu::show() { - if (isItemEnabled(2)) - setItemSelected(2, window.isShaded()); - if (isItemEnabled(4)) - setItemSelected(4, window.isMaximized()); - if (isItemEnabled(7)) - setItemSelected(7, window.isStuck()); + if (isItemEnabled(2)) + setItemSelected(2, window.isShaded()); + if (isItemEnabled(4)) + setItemSelected(4, window.isMaximized()); + if (isItemEnabled(7)) + setItemSelected(7, window.isStuck()); - Basemenu::show(); + Basemenu::show(); } void Windowmenu::itemSelected(int button, unsigned int index) { - BasemenuItem *item = find(index); - hide(); - switch (item->function()) { - case BScreen::WINDOWSHADE: - if (window.isIconic()) - break; + BasemenuItem *item = find(index); + hide(); + switch (item->function()) { + case BScreen::WINDOWSHADE: + if (window.isIconic()) + break; - window.shade(); - if (window.hasTab()) - window.getTab()->shade(); + window.shade(); + if (window.hasTab()) + window.getTab()->shade(); break; - case BScreen::WINDOWICONIFY: - if (!window.isIconic()) - window.iconify(); - else - window.deiconify(); // restore window + case BScreen::WINDOWICONIFY: + if (!window.isIconic()) + window.iconify(); + else + window.deiconify(); // restore window break; - case BScreen::WINDOWMAXIMIZE: - window.maximize((unsigned int) button); + case BScreen::WINDOWMAXIMIZE: + window.maximize((unsigned int) button); break; - case BScreen::WINDOWCLOSE: - window.close(); + case BScreen::WINDOWCLOSE: + window.close(); break; - case BScreen::WINDOWRAISE: - if (window.isIconic()) - break; + case BScreen::WINDOWRAISE: + if (window.isIconic()) + break; - if (window.hasTab()) - window.getTab()->raise(); //raise tabs - screen->getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window); + if (window.hasTab()) + window.getTab()->raise(); //raise tabs + screen->getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window); break; - case BScreen::WINDOWLOWER: - if (window.isIconic()) - break; + case BScreen::WINDOWLOWER: + if (window.isIconic()) + break; - screen->getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window); - if (window.hasTab()) - window.getTab()->lower(); //lower tabs AND all it's windows - break; + screen->getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window); + if (window.hasTab()) + window.getTab()->lower(); //lower tabs AND all it's windows + break; - case BScreen::WINDOWSTICK: - window.stick(); - break; + case BScreen::WINDOWSTICK: + window.stick(); + break; - case BScreen::WINDOWKILL: - XKillClient(BaseDisplay::getXDisplay(), - window.getClientWindow()); - break; - case BScreen::WINDOWTAB: - window.setTab(!window.hasTab()); - break; - } + case BScreen::WINDOWKILL: + XKillClient(BaseDisplay::getXDisplay(), + window.getClientWindow()); + break; + case BScreen::WINDOWTAB: + window.setTab(!window.hasTab()); + break; + } } void Windowmenu::reconfigure() { - setItemEnabled(1, window.hasTitlebar()); - setItemEnabled(2, window.isIconifiable()); - setItemEnabled(3, window.isMaximizable()); - setItemEnabled(8, window.isClosable()); - setItemEnabled(10, window.isResizable()); // tab option only enabled if resizable + setItemEnabled(1, window.hasTitlebar()); + setItemEnabled(2, window.isIconifiable()); + setItemEnabled(3, window.isMaximizable()); + setItemEnabled(8, window.isClosable()); + setItemEnabled(10, window.isResizable()); // tab option only enabled if resizable - sendToMenu.reconfigure(); - sendGroupToMenu.reconfigure(); + sendToMenu.reconfigure(); + sendGroupToMenu.reconfigure(); - Basemenu::reconfigure(); + Basemenu::reconfigure(); } Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(FluxboxWindow &win): Basemenu(win.getScreen()), -m_fbwindow(win) + m_fbwindow(win) { - setTitleVisibility(false); - setMovable(false); - setInternalMenu(); - update(); + setTitleVisibility(false); + setMovable(false); + setInternalMenu(); + update(); } void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) { - if (button > 2) - return; + if (button > 2) + return; - if (index <= screen()->getCount()) { + if (index <= screen()->getCount()) { - // no need to send it to a workspace it already exist on - if (index == screen()->getCurrentWorkspaceID()) - return; + // no need to send it to a workspace it already exist on + if (index == screen()->getCurrentWorkspaceID()) + return; - if (button == 1) { // send to workspace without changing workspace - screen()->sendToWorkspace(index, &m_fbwindow, false); - } else if (button == 2) { // send to workspace and change workspace - screen()->sendToWorkspace(index, &m_fbwindow, true); - } - } + if (button == 1) { // send to workspace without changing workspace + screen()->sendToWorkspace(index, &m_fbwindow, false); + } else if (button == 2) { // send to workspace and change workspace + screen()->sendToWorkspace(index, &m_fbwindow, true); + } + } - hide(); + hide(); } void Windowmenu::SendtoWorkspacemenu::update() { - unsigned int i, r = numberOfItems(); + unsigned int i, r = numberOfItems(); - if (numberOfItems() != 0) { - for (i = 0; i < r; ++i) - remove(0); - } - for (i = 0; i < screen()->getCount(); ++i) - insert(screen()->getWorkspace(i)->name().c_str()); + if (numberOfItems() != 0) { + for (i = 0; i < r; ++i) + remove(0); + } + for (i = 0; i < screen()->getCount(); ++i) + insert(screen()->getWorkspace(i)->name().c_str()); - Basemenu::update(); + Basemenu::update(); } void Windowmenu::SendtoWorkspacemenu::show() { - update(); + update(); - Basemenu::show(); + Basemenu::show(); } Windowmenu::SendGroupToWorkspacemenu:: - SendGroupToWorkspacemenu(FluxboxWindow &win):SendtoWorkspacemenu(win) +SendGroupToWorkspacemenu(FluxboxWindow &win):SendtoWorkspacemenu(win) { } void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int index) { - if (button > 2) - return; + if (button > 2) + return; - if (index <= screen()->getCount()) { - if (index == screen()->getCurrentWorkspaceID()) - return; - if (fbwin().isStuck()) - fbwin().stick(); + if (index <= screen()->getCount()) { + if (index == screen()->getCurrentWorkspaceID()) + return; + if (fbwin().isStuck()) + fbwin().stick(); - // if the window is iconic, deiconify it - if (fbwin().isIconic()) - fbwin().deiconify(); + // if the window is iconic, deiconify it + if (fbwin().isIconic()) + fbwin().deiconify(); - if (button == 1) { - // TODO: use reassociateGroup from BScreen instead - if (fbwin().hasTab()) { - for (Tab *first = Tab::getFirst(fbwin().getTab()); - first!=0; first=first->next()) { - first->withdraw(); - first->getWindow()->withdraw(); - screen()->reassociateWindow(first->getWindow(), index, true); + if (button == 1) { + // TODO: use reassociateGroup from BScreen instead + if (fbwin().hasTab()) { + for (Tab *first = Tab::getFirst(fbwin().getTab()); + first!=0; first=first->next()) { + first->withdraw(); + first->getWindow()->withdraw(); + screen()->reassociateWindow(first->getWindow(), index, true); - } - } else { - fbwin().withdraw(); - screen()->reassociateWindow(&fbwin(), index, true); - } + } + } else { + fbwin().withdraw(); + screen()->reassociateWindow(&fbwin(), index, true); + } - } + } - if (button == 2) - screen()->changeWorkspaceID(index); - } - hide(); + if (button == 2) + screen()->changeWorkspaceID(index); + } + hide(); }
M src/Windowmenu.hhsrc/Windowmenu.hh

@@ -29,51 +29,51 @@

class Windowmenu : public Basemenu { public: - explicit Windowmenu(FluxboxWindow &fbwin); - virtual ~Windowmenu(); + explicit Windowmenu(FluxboxWindow &fbwin); + virtual ~Windowmenu(); - const Basemenu &getSendToMenu() const { return sendToMenu; } - Basemenu &getSendToMenu() { return sendToMenu; } - const Basemenu &getSendGroupToMenu() const { return sendGroupToMenu; } - Basemenu &getSendGroupToMenu() { return sendGroupToMenu; } + const Basemenu &getSendToMenu() const { return sendToMenu; } + Basemenu &getSendToMenu() { return sendToMenu; } + const Basemenu &getSendGroupToMenu() const { return sendGroupToMenu; } + Basemenu &getSendGroupToMenu() { return sendGroupToMenu; } - void reconfigure(); - void setClosable(); + void reconfigure(); + void setClosable(); - virtual void show(); + virtual void show(); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); private: - FluxboxWindow &window; - BScreen *screen; + FluxboxWindow &window; + BScreen *screen; - class SendtoWorkspacemenu : public Basemenu { - public: - SendtoWorkspacemenu(FluxboxWindow &win); - void update(); + class SendtoWorkspacemenu : public Basemenu { + public: + SendtoWorkspacemenu(FluxboxWindow &win); + void update(); - virtual void show(); - FluxboxWindow &fbwin() { return m_fbwindow; } - protected: - virtual void itemSelected(int button, unsigned int index); - private: - FluxboxWindow &m_fbwindow; - }; + virtual void show(); + FluxboxWindow &fbwin() { return m_fbwindow; } + protected: + virtual void itemSelected(int button, unsigned int index); + private: + FluxboxWindow &m_fbwindow; + }; - class SendGroupToWorkspacemenu : public SendtoWorkspacemenu { - public: - SendGroupToWorkspacemenu(FluxboxWindow &win); + class SendGroupToWorkspacemenu : public SendtoWorkspacemenu { + public: + SendGroupToWorkspacemenu(FluxboxWindow &win); - protected: - virtual void itemSelected(int button, unsigned int index); + protected: + virtual void itemSelected(int button, unsigned int index); - }; + }; - SendtoWorkspacemenu sendToMenu; - SendGroupToWorkspacemenu sendGroupToMenu; + SendtoWorkspacemenu sendToMenu; + SendGroupToWorkspacemenu sendGroupToMenu; };
M src/Workspace.ccsrc/Workspace.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: Workspace.cc,v 1.36 2002/11/15 12:17:44 fluxgen Exp $ +// $Id: Workspace.cc,v 1.37 2002/12/01 13:42:05 rathnor Exp $ #include "Workspace.hh"

@@ -58,16 +58,16 @@

namespace { // anonymous int countTransients(const FluxboxWindow &win) { - if (win.getTransients().size() == 0) - return 0; - // now go throu the entire tree and count transients - size_t ret = win.getTransients().size(); - std::list<FluxboxWindow *>::const_iterator it = win.getTransients().begin(); - std::list<FluxboxWindow *>::const_iterator it_end = win.getTransients().end(); - for (; it != it_end; ++it) - ret += countTransients(*(*it)); + if (win.getTransients().size() == 0) + return 0; + // now go throu the entire tree and count transients + size_t ret = win.getTransients().size(); + std::list<FluxboxWindow *>::const_iterator it = win.getTransients().begin(); + std::list<FluxboxWindow *>::const_iterator it_end = win.getTransients().end(); + for (; it != it_end; ++it) + ret += countTransients(*(*it)); - return ret; + return ret; } };

@@ -75,14 +75,14 @@

Workspace::GroupList Workspace::m_groups; Workspace::Workspace(BScreen *scrn, unsigned int i): -screen(scrn), -lastfocus(0), -m_clientmenu(*this), -m_name(""), -m_id(i), -cascade_x(32), cascade_y(32) { + screen(scrn), + lastfocus(0), + m_clientmenu(*this), + m_name(""), + m_id(i), + cascade_x(32), cascade_y(32) { - setName(screen->getNameOfWorkspace(m_id)); + setName(screen->getNameOfWorkspace(m_id)); }

@@ -92,258 +92,258 @@

} void Workspace::setLastFocusedWindow(FluxboxWindow *win) { - // make sure we have this window in the list - if (std::find(m_windowlist.begin(), m_windowlist.end(), win) != m_windowlist.end()) - lastfocus = win; - else - lastfocus = 0; + // make sure we have this window in the list + if (std::find(m_windowlist.begin(), m_windowlist.end(), win) != m_windowlist.end()) + lastfocus = win; + else + lastfocus = 0; } int Workspace::addWindow(FluxboxWindow *w, bool place) { - if (w == 0) - return -1; + if (w == 0) + return -1; - if (place) - placeWindow(w); + if (place) + placeWindow(w); - w->setWorkspace(m_id); - w->setWindowNumber(m_windowlist.size()); + w->setWorkspace(m_id); + w->setWindowNumber(m_windowlist.size()); - stackingList.push_front(w); + stackingList.push_front(w); - //insert window after the currently focused window - //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); + //insert window after the currently focused window + //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); - //if there isn't any window that's focused, just add it to the end of the list - /* - if (focused == 0) { - m_windowlist.push_back(w); - //Add client to clientmenu - m_clientmenu.insert(w->getTitle().c_str()); - } else { - Windows::iterator it = m_windowlist.begin(); - size_t client_insertpoint=0; - for (; it != m_windowlist.end(); ++it, ++client_insertpoint) { - if (*it == focused) { - ++it; - break; - } - } + //if there isn't any window that's focused, just add it to the end of the list + /* + if (focused == 0) { + m_windowlist.push_back(w); + //Add client to clientmenu + m_clientmenu.insert(w->getTitle().c_str()); + } else { + Windows::iterator it = m_windowlist.begin(); + size_t client_insertpoint=0; + for (; it != m_windowlist.end(); ++it, ++client_insertpoint) { + if (*it == focused) { + ++it; + break; + } + } - m_windowlist.insert(it, w); - //Add client to clientmenu - m_clientmenu.insert(w->getTitle().c_str(), client_insertpoint); + m_windowlist.insert(it, w); + //Add client to clientmenu + m_clientmenu.insert(w->getTitle().c_str(), client_insertpoint); - } - */ - //add to list - m_clientmenu.insert(w->getTitle().c_str()); - m_windowlist.push_back(w); + } + */ + //add to list + m_clientmenu.insert(w->getTitle().c_str()); + m_windowlist.push_back(w); - //update menugraphics - m_clientmenu.update(); + //update menugraphics + m_clientmenu.update(); - if (!w->isStuck()) - screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); + if (!w->isStuck()) + screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); - raiseWindow(w); + raiseWindow(w); - return w->getWindowNumber(); + return w->getWindowNumber(); } int Workspace::removeWindow(FluxboxWindow *w) { - if (w == 0) - return -1; + if (w == 0) + return -1; - if (lastfocus == w) { - lastfocus = 0; - } + if (lastfocus == w) { + lastfocus = 0; + } - stackingList.remove(w); + stackingList.remove(w); - if (w->isFocused()) { - if (screen->isSloppyFocus()) { - Fluxbox::instance()->setFocusedWindow(0); // set focused window to none - } else if (w->isTransient() && w->getTransientFor() && - w->getTransientFor()->isVisible()) { - /* TODO: check transient - if (w->getTransientFor() == w) { // FATAL ERROR, this should not happend - cerr<<"w->getTransientFor() == w: aborting!"<<endl; - abort(); - }*/ - w->getTransientFor()->setInputFocus(); - } else { - FluxboxWindow *top = 0; - if (stackingList.size() != 0) - top = stackingList.front(); + if (w->isFocused()) { + if (screen->isSloppyFocus()) { + Fluxbox::instance()->setFocusedWindow(0); // set focused window to none + } else if (w->isTransient() && w->getTransientFor() && + w->getTransientFor()->isVisible()) { + /* TODO: check transient + if (w->getTransientFor() == w) { // FATAL ERROR, this should not happend + cerr<<"w->getTransientFor() == w: aborting!"<<endl; + abort(); + }*/ + w->getTransientFor()->setInputFocus(); + } else { + FluxboxWindow *top = 0; + if (stackingList.size() != 0) + top = stackingList.front(); - if (top == 0|| !top->setInputFocus()) { - Fluxbox::instance()->setFocusedWindow(0); // set focused window to none - XSetInputFocus(Fluxbox::instance()->getXDisplay(), - screen->getToolbar()->getWindowID(), - RevertToParent, CurrentTime); - } - } - } + if (top == 0|| !top->setInputFocus()) { + Fluxbox::instance()->setFocusedWindow(0); // set focused window to none + XSetInputFocus(Fluxbox::instance()->getXDisplay(), + screen->getToolbar()->getWindowID(), + RevertToParent, CurrentTime); + } + } + } - Windows::iterator it = m_windowlist.begin(); - Windows::iterator it_end = m_windowlist.end(); - for (; it != it_end; ++it) { - if (*it == w) { - m_windowlist.erase(it); - break; - } - } + Windows::iterator it = m_windowlist.begin(); + Windows::iterator it_end = m_windowlist.end(); + for (; it != it_end; ++it) { + if (*it == w) { + m_windowlist.erase(it); + break; + } + } - m_clientmenu.remove(w->getWindowNumber()); - m_clientmenu.update(); + m_clientmenu.remove(w->getWindowNumber()); + m_clientmenu.update(); - if (!w->isStuck()) - screen->updateNetizenWindowDel(w->getClientWindow()); + if (!w->isStuck()) + screen->updateNetizenWindowDel(w->getClientWindow()); - { - Windows::iterator it = m_windowlist.begin(); - Windows::const_iterator it_end = m_windowlist.end(); - for (int i = 0; it != it_end; ++it, ++i) { - (*it)->setWindowNumber(i); - } - } + { + Windows::iterator it = m_windowlist.begin(); + Windows::const_iterator it_end = m_windowlist.end(); + for (int i = 0; it != it_end; ++it, ++i) { + (*it)->setWindowNumber(i); + } + } - if (lastfocus == w || m_windowlist.empty()) - lastfocus = 0; + if (lastfocus == w || m_windowlist.empty()) + lastfocus = 0; - return m_windowlist.size(); + return m_windowlist.size(); } void Workspace::showAll(void) { - WindowStack::iterator it = stackingList.begin(); - WindowStack::iterator it_end = stackingList.end(); - for (; it != it_end; ++it) { - (*it)->deiconify(false, false); - } + WindowStack::iterator it = stackingList.begin(); + WindowStack::iterator it_end = stackingList.end(); + for (; it != it_end; ++it) { + (*it)->deiconify(false, false); + } } void Workspace::hideAll(void) { - WindowStack::reverse_iterator it = stackingList.rbegin(); - WindowStack::reverse_iterator it_end = stackingList.rend(); - for (; it != it_end; ++it) { - if (! (*it)->isStuck()) - (*it)->withdraw(); - } + WindowStack::reverse_iterator it = stackingList.rbegin(); + WindowStack::reverse_iterator it_end = stackingList.rend(); + for (; it != it_end; ++it) { + if (! (*it)->isStuck()) + (*it)->withdraw(); + } } void Workspace::removeAll(void) { - Windows::iterator it = m_windowlist.begin(); - Windows::const_iterator it_end = m_windowlist.end(); - for (; it != it_end; ++it) { - (*it)->iconify(); - } + Windows::iterator it = m_windowlist.begin(); + Windows::const_iterator it_end = m_windowlist.end(); + for (; it != it_end; ++it) { + (*it)->iconify(); + } } void Workspace::raiseWindow(FluxboxWindow *w) { - FluxboxWindow *win = w; + FluxboxWindow *win = w; - while (win->getTransientFor()) { - win = win->getTransientFor(); - assert(win != win->getTransientFor()); - } + while (win->getTransientFor()) { + win = win->getTransientFor(); + assert(win != win->getTransientFor()); + } - int i = 1 + countTransients(*win); + int i = 1 + countTransients(*win); - Stack nstack(i); - Stack::iterator stackit = nstack.begin(); + Stack nstack(i); + Stack::iterator stackit = nstack.begin(); - *(stackit++) = win->getFrameWindow(); - screen->updateNetizenWindowRaise(win->getClientWindow()); - if (! win->isIconic()) { - Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); - wkspc->stackingList.remove(win); - wkspc->stackingList.push_front(win); - } + *(stackit++) = win->getFrameWindow(); + screen->updateNetizenWindowRaise(win->getClientWindow()); + if (! win->isIconic()) { + Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); + wkspc->stackingList.remove(win); + wkspc->stackingList.push_front(win); + } - raiseAndFillStack(stackit, *win); + raiseAndFillStack(stackit, *win); - screen->raiseWindows(nstack); + screen->raiseWindows(nstack); } void Workspace::lowerWindow(FluxboxWindow *w) { - FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; + FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; - while (bottom->getTransientFor()) { - bottom = bottom->getTransientFor(); - assert(bottom != bottom->getTransientFor()); - } + while (bottom->getTransientFor()) { + bottom = bottom->getTransientFor(); + assert(bottom != bottom->getTransientFor()); + } - win = bottom; - int i = 1 + countTransients(*win); + win = bottom; + int i = 1 + countTransients(*win); - Stack st(i); - Stack::iterator stackit = st.begin(); - lowerAndFillStack(stackit, *win); - (*stackit) = win->getFrameWindow(); + Stack st(i); + Stack::iterator stackit = st.begin(); + lowerAndFillStack(stackit, *win); + (*stackit) = win->getFrameWindow(); - screen->updateNetizenWindowLower(win->getClientWindow()); - if (! win->isIconic()) { - Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); - wkspc->stackingList.remove(win); - wkspc->stackingList.push_back(win); - } + screen->updateNetizenWindowLower(win->getClientWindow()); + if (! win->isIconic()) { + Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); + wkspc->stackingList.remove(win); + wkspc->stackingList.push_back(win); + } - XLowerWindow(BaseDisplay::getXDisplay(), st.front()); - XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size()); + XLowerWindow(BaseDisplay::getXDisplay(), st.front()); + XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size()); } void Workspace::reconfigure() { - m_clientmenu.reconfigure(); + m_clientmenu.reconfigure(); - Windows::iterator it = m_windowlist.begin(); - Windows::iterator it_end = m_windowlist.end(); - for (; it != it_end; ++it) { - if ((*it)->validateClient()) - (*it)->reconfigure(); - } + Windows::iterator it = m_windowlist.begin(); + Windows::iterator it_end = m_windowlist.end(); + for (; it != it_end; ++it) { + if ((*it)->validateClient()) + (*it)->reconfigure(); + } } const FluxboxWindow *Workspace::getWindow(unsigned int index) const { - if (index < m_windowlist.size()) - return m_windowlist[index]; - return 0; + if (index < m_windowlist.size()) + return m_windowlist[index]; + return 0; } FluxboxWindow *Workspace::getWindow(unsigned int index) { - if (index < m_windowlist.size()) - return m_windowlist[index]; - return 0; + if (index < m_windowlist.size()) + return m_windowlist[index]; + return 0; } int Workspace::getCount() const { - return m_windowlist.size(); + return m_windowlist.size(); } namespace { // helper class for checkGrouping class FindInGroup { public: - FindInGroup(const FluxboxWindow &w):m_w(w) { } - bool operator ()(const string &name) { - return (name == m_w.instanceName()); - } + FindInGroup(const FluxboxWindow &w):m_w(w) { } + bool operator ()(const string &name) { + return (name == m_w.instanceName()); + } private: - const FluxboxWindow &m_w; + const FluxboxWindow &m_w; }; };

@@ -351,111 +351,111 @@

//Note: this function doesn't check if the window is groupable void Workspace::checkGrouping(FluxboxWindow &win) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Checking grouping. ("<<win.instanceName()<<"/"<< - win.className()<<")"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): Checking grouping. ("<<win.instanceName()<<"/"<< + win.className()<<")"<<endl; #endif // DEBUG - if (!win.isGroupable()) { // make sure this window can hold a tab + if (!win.isGroupable()) { // make sure this window can hold a tab #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): window can't use a tab"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): window can't use a tab"<<endl; #endif // DEBUG - return; - } + return; + } - // go throu every group and search for matching win instancename - GroupList::iterator g(m_groups.begin()); - GroupList::iterator g_end(m_groups.end()); - for (; g != g_end; ++g) { - Group::iterator name((*g).begin()); - Group::iterator name_end((*g).end()); - for (; name != name_end; ++name) { + // go throu every group and search for matching win instancename + GroupList::iterator g(m_groups.begin()); + GroupList::iterator g_end(m_groups.end()); + for (; g != g_end; ++g) { + Group::iterator name((*g).begin()); + Group::iterator name_end((*g).end()); + for (; name != name_end; ++name) { - if ((*name) != win.instanceName()) - continue; + if ((*name) != win.instanceName()) + continue; - // find a window with the specific name - Windows::iterator wit(m_windowlist.begin()); - Windows::iterator wit_end(m_windowlist.end()); - for (; wit != wit_end; ++wit) { + // find a window with the specific name + Windows::iterator wit(m_windowlist.begin()); + Windows::iterator wit_end(m_windowlist.end()); + for (; wit != wit_end; ++wit) { #ifdef DEBUG - cerr<<__FILE__<<" check group with : "<<(*wit)->instanceName()<<endl; + cerr<<__FILE__<<" check group with : "<<(*wit)->instanceName()<<endl; #endif // DEBUG - if (find_if((*g).begin(), (*g).end(), FindInGroup(*(*wit))) != (*g).end()) { - // make sure the window is groupable - if ( !(*wit)->isGroupable()) - break; // try next name - //toggle tab on - if ((*wit)->getTab() == 0) - (*wit)->setTab(true); - if (win.getTab() == 0) - win.setTab(true); - // did we succefully set the tab? - if ((*wit)->getTab() == 0) - break; // try another window - (*wit)->getTab()->insert(win.getTab()); + if (find_if((*g).begin(), (*g).end(), FindInGroup(*(*wit))) != (*g).end()) { + // make sure the window is groupable + if ( !(*wit)->isGroupable()) + break; // try next name + //toggle tab on + if ((*wit)->getTab() == 0) + (*wit)->setTab(true); + if (win.getTab() == 0) + win.setTab(true); + // did we succefully set the tab? + if ((*wit)->getTab() == 0) + break; // try another window + (*wit)->getTab()->insert(win.getTab()); - return; // grouping done - } - } + return; // grouping done + } + } - } + } - } + } } bool Workspace::loadGroups(const std::string &filename) { - ifstream infile(filename.c_str()); - if (!infile) - return false; - m_groups.clear(); // erase old groups + ifstream infile(filename.c_str()); + if (!infile) + return false; + m_groups.clear(); // erase old groups - // load new groups - while (!infile.eof()) { - string line; - vector<string> names; - getline(infile, line); - StringUtil::stringtok(names, line); - m_groups.push_back(names); - } + // load new groups + while (!infile.eof()) { + string line; + vector<string> names; + getline(infile, line); + StringUtil::stringtok(names, line); + m_groups.push_back(names); + } - return true; + return true; } void Workspace::update() { - m_clientmenu.update(); - screen->getToolbar()->redrawWindowLabel(True); + m_clientmenu.update(); + screen->getToolbar()->redrawWindowLabel(True); } bool Workspace::isCurrent() const{ - return (m_id == screen->getCurrentWorkspaceID()); + return (m_id == screen->getCurrentWorkspaceID()); } bool Workspace::isLastWindow(FluxboxWindow *w) const{ - return (w == m_windowlist.back()); + return (w == m_windowlist.back()); } void Workspace::setCurrent() { - screen->changeWorkspaceID(m_id); + screen->changeWorkspaceID(m_id); } void Workspace::setName(const std::string &name) { - if (name.size() != 0) { - m_name = name; - } else { //if name == 0 then set default name from nls - char tname[128]; - sprintf(tname, I18n::instance()-> - getMessage( - FBNLS::WorkspaceSet, FBNLS::WorkspaceDefaultNameFormat, - "Workspace %d"), m_id + 1); //m_id starts at 0 - m_name = tname; - } + if (name.size() != 0) { + m_name = name; + } else { //if name == 0 then set default name from nls + char tname[128]; + sprintf(tname, I18n::instance()-> + getMessage( + FBNLS::WorkspaceSet, FBNLS::WorkspaceDefaultNameFormat, + "Workspace %d"), m_id + 1); //m_id starts at 0 + m_name = tname; + } - screen->updateWorkspaceNamesAtom(); + screen->updateWorkspaceNamesAtom(); - m_clientmenu.setLabel(m_name.c_str()); - m_clientmenu.update(); + m_clientmenu.setLabel(m_name.c_str()); + m_clientmenu.update(); } //------------ shutdown ---------

@@ -464,406 +464,406 @@ // on the workspace and then

// clears the m_windowlist //------------------------------- void Workspace::shutdown() { - // note: when the window dies it'll remove it self from the list - while (!m_windowlist.empty()) { - m_windowlist.back()->restore(true); // restore with remap - delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) - } + // note: when the window dies it'll remove it self from the list + while (!m_windowlist.empty()) { + m_windowlist.back()->restore(true); // restore with remap + delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) + } } void Workspace::placeWindow(FluxboxWindow *win) { - Bool placed = False; - int borderWidth4x = screen->getBorderWidth2x() * 2, + Bool placed = False; + int borderWidth4x = screen->getBorderWidth2x() * 2, #ifdef SLIT - slit_x = screen->getSlit()->x() - screen->getBorderWidth(), - slit_y = screen->getSlit()->y() - screen->getBorderWidth(), - slit_w = screen->getSlit()->width() + borderWidth4x, - slit_h = screen->getSlit()->height() + borderWidth4x, + slit_x = screen->getSlit()->x() - screen->getBorderWidth(), + slit_y = screen->getSlit()->y() - screen->getBorderWidth(), + slit_w = screen->getSlit()->width() + borderWidth4x, + slit_h = screen->getSlit()->height() + borderWidth4x, #endif // SLIT - toolbar_x = screen->getToolbar()->x() - screen->getBorderWidth(), - toolbar_y = screen->getToolbar()->y() - screen->getBorderWidth(), - toolbar_w = screen->getToolbar()->width() + borderWidth4x, - toolbar_h = screen->getToolbar()->height() + borderWidth4x, - place_x = 0, place_y = 0, change_x = 1, change_y = 1; + toolbar_x = screen->getToolbar()->x() - screen->getBorderWidth(), + toolbar_y = screen->getToolbar()->y() - screen->getBorderWidth(), + toolbar_w = screen->getToolbar()->width() + borderWidth4x, + toolbar_h = screen->getToolbar()->height() + borderWidth4x, + place_x = 0, place_y = 0, change_x = 1, change_y = 1; - if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) - change_y = -1; - if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) - change_x = -1; + if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) + change_y = -1; + if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) + change_x = -1; #ifdef XINERAMA - int head = 0, - head_x = 0, - head_y = 0; - int head_w, head_h; - if (screen->hasXinerama()) { - head = screen->getCurrHead(); - head_x = screen->getHeadX(head); - head_y = screen->getHeadY(head); - head_w = screen->getHeadWidth(head); - head_h = screen->getHeadHeight(head); + int head = 0, + head_x = 0, + head_y = 0; + int head_w, head_h; + if (screen->hasXinerama()) { + head = screen->getCurrHead(); + head_x = screen->getHeadX(head); + head_y = screen->getHeadY(head); + head_w = screen->getHeadWidth(head); + head_h = screen->getHeadHeight(head); - } else { // no xinerama - head_w = screen->getWidth(); - head_h = screen->getHeight(); - } + } else { // no xinerama + head_w = screen->getWidth(); + head_h = screen->getHeight(); + } #endif // XINERAMA - int win_w = win->getWidth() + screen->getBorderWidth2x(), - win_h = win->getHeight() + screen->getBorderWidth2x(); + int win_w = win->getWidth() + screen->getBorderWidth2x(), + win_h = win->getHeight() + screen->getBorderWidth2x(); - if (win->hasTab()) { - if ((! win->isShaded()) && - screen->getTabPlacement() == Tab::PLEFT || - screen->getTabPlacement() == Tab::PRIGHT) - win_w += (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - else // tab placement top or bottom or win is shaded - win_h += screen->getTabHeight(); - } + if (win->hasTab()) { + if ((! win->isShaded()) && + screen->getTabPlacement() == Tab::PLEFT || + screen->getTabPlacement() == Tab::PRIGHT) + win_w += (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + else // tab placement top or bottom or win is shaded + win_h += screen->getTabHeight(); + } - register int test_x, test_y, curr_x, curr_y, curr_w, curr_h; + register int test_x, test_y, curr_x, curr_y, curr_w, curr_h; - switch (screen->getPlacementPolicy()) { - case BScreen::ROWSMARTPLACEMENT: { - #ifdef XINERAMA - test_y = head_y; - #else // !XINERAMA - test_y = 0; - #endif // XINERAMA - if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) - #ifdef XINERAMA - test_y = (head_y + head_h) - win_h - test_y; - #else // !XINERAMA - test_y = screen->getHeight() - win_h - test_y; - #endif // XINERAMA + switch (screen->getPlacementPolicy()) { + case BScreen::ROWSMARTPLACEMENT: { +#ifdef XINERAMA + test_y = head_y; +#else // !XINERAMA + test_y = 0; +#endif // XINERAMA + if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) +#ifdef XINERAMA + test_y = (head_y + head_h) - win_h - test_y; +#else // !XINERAMA + test_y = screen->getHeight() - win_h - test_y; +#endif // XINERAMA - while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? - #ifdef XINERAMA - test_y >= head_y : test_y + win_h <= (head_y + head_h)) && - #else // !XINERAMA - test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && - #endif // XINERAMA - ! placed) { + while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? +#ifdef XINERAMA + test_y >= head_y : test_y + win_h <= (head_y + head_h)) && +#else // !XINERAMA + test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && +#endif // XINERAMA + ! placed) { - #ifdef XINERAMA - test_x = head_x; - #else // !XINERAMA - test_x = 0; - #endif // XINERAMA - if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) - #ifdef XINERAMA - test_x = (head_x + head_w) - win_w - test_x; - #else // !XINERAMA - test_x = screen->getWidth() - win_w - test_x; - #endif // XINERAMA +#ifdef XINERAMA + test_x = head_x; +#else // !XINERAMA + test_x = 0; +#endif // XINERAMA + if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) +#ifdef XINERAMA + test_x = (head_x + head_w) - win_w - test_x; +#else // !XINERAMA + test_x = screen->getWidth() - win_w - test_x; +#endif // XINERAMA - while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? - #ifdef XINERAMA - test_x >= head_x : test_x + win_w <= (head_x + head_w)) && - #else // !XINERAMA - test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && - #endif // XINERAMA - ! placed) { + while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? +#ifdef XINERAMA + test_x >= head_x : test_x + win_w <= (head_x + head_w)) && +#else // !XINERAMA + test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && +#endif // XINERAMA + ! placed) { - placed = True; + placed = True; - Windows::iterator it = m_windowlist.begin(); - Windows::iterator it_end = m_windowlist.end(); + Windows::iterator it = m_windowlist.begin(); + Windows::iterator it_end = m_windowlist.end(); - for (; it != it_end && placed; ++it) { - curr_x = (*it)->getXFrame(); - curr_y = (*it)->getYFrame(); - curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); - curr_h = - (((*it)->isShaded()) - ? (*it)->getTitleHeight() - : (*it)->getHeight()) + - screen->getBorderWidth2x(); + for (; it != it_end && placed; ++it) { + curr_x = (*it)->getXFrame(); + curr_y = (*it)->getYFrame(); + curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); + curr_h = + (((*it)->isShaded()) + ? (*it)->getTitleHeight() + : (*it)->getHeight()) + + screen->getBorderWidth2x(); - if ((*it)->hasTab()) { - if (! (*it)->isShaded()) { // not shaded window - switch(screen->getTabPlacement()) { - case Tab::PTOP: - curr_y -= screen->getTabHeight(); - case Tab::PBOTTOM: - curr_h += screen->getTabHeight(); - break; - case Tab::PLEFT: - curr_x -= (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - case Tab::PRIGHT: - curr_w += (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - break; - case Tab::PNONE: - break; - } - } else { // shaded window - if (screen->getTabPlacement() == Tab::PTOP) - curr_y -= screen->getTabHeight(); - curr_h += screen->getTabHeight(); - } - } // tab cheking done + if ((*it)->hasTab()) { + if (! (*it)->isShaded()) { // not shaded window + switch(screen->getTabPlacement()) { + case Tab::PTOP: + curr_y -= screen->getTabHeight(); + case Tab::PBOTTOM: + curr_h += screen->getTabHeight(); + break; + case Tab::PLEFT: + curr_x -= (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + case Tab::PRIGHT: + curr_w += (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + break; + case Tab::PNONE: + break; + } + } else { // shaded window + if (screen->getTabPlacement() == Tab::PTOP) + curr_y -= screen->getTabHeight(); + curr_h += screen->getTabHeight(); + } + } // tab cheking done - if (curr_x < test_x + win_w && - curr_x + curr_w > test_x && - curr_y < test_y + win_h && - curr_y + curr_h > test_y) { - placed = False; - } - } + if (curr_x < test_x + win_w && + curr_x + curr_w > test_x && + curr_y < test_y + win_h && + curr_y + curr_h > test_y) { + placed = False; + } + } - if ((toolbar_x < test_x + win_w && - toolbar_x + toolbar_w > test_x && - toolbar_y < test_y + win_h && - toolbar_y + toolbar_h > test_y) + if ((toolbar_x < test_x + win_w && + toolbar_x + toolbar_w > test_x && + toolbar_y < test_y + win_h && + toolbar_y + toolbar_h > test_y) #ifdef SLIT - || - (slit_x < test_x + win_w && - slit_x + slit_w > test_x && - slit_y < test_y + win_h && - slit_y + slit_h > test_y) + || + (slit_x < test_x + win_w && + slit_x + slit_w > test_x && + slit_y < test_y + win_h && + slit_y + slit_h > test_y) #endif // SLIT - ) - placed = False; + ) + placed = False; - if (placed) { - place_x = test_x; - place_y = test_y; + if (placed) { + place_x = test_x; + place_y = test_y; - break; - } + break; + } - test_x += change_x; - } + test_x += change_x; + } - test_y += change_y; - } + test_y += change_y; + } - break; } + break; } - case BScreen::COLSMARTPLACEMENT: { - #ifdef XINERAMA - test_x = head_x; - #else // !XINERAMA - test_x = 0; - #endif // XINERAMA - if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) - #ifdef XINERAMA - test_x = (head_x + head_w) - win_w - test_x; - #else // !XINERAMA - test_x = screen->getWidth() - win_w - test_x; - #endif // XINERAMA +case BScreen::COLSMARTPLACEMENT: { +#ifdef XINERAMA + test_x = head_x; +#else // !XINERAMA + test_x = 0; +#endif // XINERAMA + if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) +#ifdef XINERAMA + test_x = (head_x + head_w) - win_w - test_x; +#else // !XINERAMA + test_x = screen->getWidth() - win_w - test_x; +#endif // XINERAMA - while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? - #ifdef XINERAMA - test_x >= 0 : test_x + win_w <= (head_x + head_w)) && - #else // !XINERAMA - test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && - #endif // XINERAMA - ! placed) { + while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? +#ifdef XINERAMA + test_x >= 0 : test_x + win_w <= (head_x + head_w)) && +#else // !XINERAMA + test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && +#endif // XINERAMA + ! placed) { - #ifdef XINERAMA - test_y = head_y; - #else // !XINERAMA - test_y = 0; - #endif // XINERAMA - if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) - #ifdef XINERAMA - test_y = (head_y + head_h) - win_h - test_y; - #else // !XINERAMA - test_y = screen->getHeight() - win_h - test_y; - #endif // XINERAMA +#ifdef XINERAMA + test_y = head_y; +#else // !XINERAMA + test_y = 0; +#endif // XINERAMA + if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) +#ifdef XINERAMA + test_y = (head_y + head_h) - win_h - test_y; +#else // !XINERAMA + test_y = screen->getHeight() - win_h - test_y; +#endif // XINERAMA - while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? - #ifdef XINERAMA - test_y >= head_y : test_y + win_h <= (head_y + head_h)) && - #else // !XINERAMA - test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && - #endif // XINERAMA - ! placed) { - placed = True; + while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? +#ifdef XINERAMA + test_y >= head_y : test_y + win_h <= (head_y + head_h)) && +#else // !XINERAMA + test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && +#endif // XINERAMA + ! placed) { + placed = True; - Windows::iterator it = m_windowlist.begin(); - Windows::iterator it_end = m_windowlist.end(); - for (; it != it_end && placed; ++it) { - curr_x = (*it)->getXFrame(); - curr_y = (*it)->getYFrame(); - curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); - curr_h = - (((*it)->isShaded()) - ? (*it)->getTitleHeight() - : (*it)->getHeight()) + - screen->getBorderWidth2x();; + Windows::iterator it = m_windowlist.begin(); + Windows::iterator it_end = m_windowlist.end(); + for (; it != it_end && placed; ++it) { + curr_x = (*it)->getXFrame(); + curr_y = (*it)->getYFrame(); + curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); + curr_h = + (((*it)->isShaded()) + ? (*it)->getTitleHeight() + : (*it)->getHeight()) + + screen->getBorderWidth2x();; - if ((*it)->hasTab()) { - if (! (*it)->isShaded()) { // not shaded window - switch(screen->getTabPlacement()) { - case Tab::PTOP: - curr_y -= screen->getTabHeight(); - case Tab::PBOTTOM: - curr_h += screen->getTabHeight(); - break; - case Tab::PLEFT: - curr_x -= (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - case Tab::PRIGHT: - curr_w += (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - break; - default: - #ifdef DEBUG - cerr << __FILE__ << ":" <<__LINE__ << ": " << - "Unsupported Placement" << endl; - #endif // DEBUG - break; - } - } else { // shaded window - if (screen->getTabPlacement() == Tab::PTOP) - curr_y -= screen->getTabHeight(); - curr_h += screen->getTabHeight(); - } - } // tab cheking done + if ((*it)->hasTab()) { + if (! (*it)->isShaded()) { // not shaded window + switch(screen->getTabPlacement()) { + case Tab::PTOP: + curr_y -= screen->getTabHeight(); + case Tab::PBOTTOM: + curr_h += screen->getTabHeight(); + break; + case Tab::PLEFT: + curr_x -= (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + case Tab::PRIGHT: + curr_w += (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); + break; + default: +#ifdef DEBUG + cerr << __FILE__ << ":" <<__LINE__ << ": " << + "Unsupported Placement" << endl; +#endif // DEBUG + break; + } + } else { // shaded window + if (screen->getTabPlacement() == Tab::PTOP) + curr_y -= screen->getTabHeight(); + curr_h += screen->getTabHeight(); + } + } // tab cheking done - if (curr_x < test_x + win_w && - curr_x + curr_w > test_x && - curr_y < test_y + win_h && - curr_y + curr_h > test_y) { - placed = False; - } - } + if (curr_x < test_x + win_w && + curr_x + curr_w > test_x && + curr_y < test_y + win_h && + curr_y + curr_h > test_y) { + placed = False; + } + } - if ((toolbar_x < test_x + win_w && - toolbar_x + toolbar_w > test_x && - toolbar_y < test_y + win_h && - toolbar_y + toolbar_h > test_y) + if ((toolbar_x < test_x + win_w && + toolbar_x + toolbar_w > test_x && + toolbar_y < test_y + win_h && + toolbar_y + toolbar_h > test_y) #ifdef SLIT - || - (slit_x < test_x + win_w && - slit_x + slit_w > test_x && - slit_y < test_y + win_h && - slit_y + slit_h > test_y) + || + (slit_x < test_x + win_w && + slit_x + slit_w > test_x && + slit_y < test_y + win_h && + slit_y + slit_h > test_y) #endif // SLIT - ) - placed = False; + ) + placed = False; - if (placed) { - place_x = test_x; - place_y = test_y; - } + if (placed) { + place_x = test_x; + place_y = test_y; + } - test_y += change_y; - } + test_y += change_y; + } - test_x += change_x; - } +test_x += change_x; +} - break; } - } +break; } +} - // cascade placement or smart placement failed - if (! placed) { - #ifdef XINERAMA - if ((cascade_x > (head_w / 2)) || - (cascade_y > (head_h / 2))) - #else // !XINERAMA - if (((unsigned) cascade_x > (screen->getWidth() / 2)) || - ((unsigned) cascade_y > (screen->getHeight() / 2))) - #endif // XINERAMA +// cascade placement or smart placement failed +if (! placed) { +#ifdef XINERAMA +if ((cascade_x > (head_w / 2)) || +(cascade_y > (head_h / 2))) +#else // !XINERAMA + if (((unsigned) cascade_x > (screen->getWidth() / 2)) || + ((unsigned) cascade_y > (screen->getHeight() / 2))) +#endif // XINERAMA - cascade_x = cascade_y = 32; + cascade_x = cascade_y = 32; #ifdef XINERAMA - place_x = head_x + cascade_x; - place_y = head_y + cascade_y; +place_x = head_x + cascade_x; +place_y = head_y + cascade_y; #else // !XINERAMA - place_x = cascade_x; - place_y = cascade_y; +place_x = cascade_x; +place_y = cascade_y; #endif // XINERAMA - cascade_x += win->getTitleHeight(); - cascade_y += win->getTitleHeight(); - } +cascade_x += win->getTitleHeight(); +cascade_y += win->getTitleHeight(); +} #ifdef XINERAMA - if (place_x + win_w > (head_x + head_w)) - place_x = head_x + ((head_w - win_w) / 2); - if (place_y + win_h > (head_y + head_h)) - place_y = head_y + ((head_h - win_h) / 2); +if (place_x + win_w > (head_x + head_w)) + place_x = head_x + ((head_w - win_w) / 2); +if (place_y + win_h > (head_y + head_h)) + place_y = head_y + ((head_h - win_h) / 2); #else // !XINERAMA - if (place_x + win_w > (signed) screen->getWidth()) - place_x = (((signed) screen->getWidth()) - win_w) / 2; - if (place_y + win_h > (signed) screen->getHeight()) - place_y = (((signed) screen->getHeight()) - win_h) / 2; +if (place_x + win_w > (signed) screen->getWidth()) + place_x = (((signed) screen->getWidth()) - win_w) / 2; +if (place_y + win_h > (signed) screen->getHeight()) + place_y = (((signed) screen->getHeight()) - win_h) / 2; #endif // XINERAMA - // fix window placement, think of tabs - if (win->hasTab()) { - if (screen->getTabPlacement() == Tab::PTOP) - place_y += screen->getTabHeight(); - else if (screen->getTabPlacement() == Tab::PLEFT) - place_x += (screen->isTabRotateVertical()) - ? screen->getTabHeight() - : screen->getTabWidth(); - } +// fix window placement, think of tabs +if (win->hasTab()) { +if (screen->getTabPlacement() == Tab::PTOP) + place_y += screen->getTabHeight(); +else if (screen->getTabPlacement() == Tab::PLEFT) + place_x += (screen->isTabRotateVertical()) + ? screen->getTabHeight() + : screen->getTabWidth(); +} - win->configure(place_x, place_y, win->getWidth(), win->getHeight()); +win->configure(place_x, place_y, win->getWidth(), win->getHeight()); } void Workspace::raiseAndFillStack(Stack::iterator &stackit, const FluxboxWindow &w) { - if (w.getTransients().empty()) - return; +if (w.getTransients().empty()) + return; - std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin(); - std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end(); - for (; it != it_end; ++it) { - *stackit++ = (*it)->getFrameWindow(); +std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin(); +std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end(); +for (; it != it_end; ++it) { +*stackit++ = (*it)->getFrameWindow(); - screen->updateNetizenWindowRaise((*it)->getClientWindow()); +screen->updateNetizenWindowRaise((*it)->getClientWindow()); - if (! (*it)->isIconic()) { - Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); - wkspc->stackingList.remove((*it)); - wkspc->stackingList.push_front((*it)); - } +if (! (*it)->isIconic()) { +Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); +wkspc->stackingList.remove((*it)); +wkspc->stackingList.push_front((*it)); +} - } +} - it = w.getTransients().begin(); - for (; it != it_end; ++it) - raiseAndFillStack(stackit, *(*it)); +it = w.getTransients().begin(); +for (; it != it_end; ++it) + raiseAndFillStack(stackit, *(*it)); } void Workspace::lowerAndFillStack(Stack::iterator &stackit, const FluxboxWindow &win) { - if (win.getTransients().empty()) // nothing to lower and stack - return; +if (win.getTransients().empty()) // nothing to lower and stack + return; - std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin(); - std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend(); - for (; it != it_end; ++it) - lowerAndFillStack(stackit, *(*it)); +std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin(); +std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend(); +for (; it != it_end; ++it) + lowerAndFillStack(stackit, *(*it)); - it = win.getTransients().rbegin(); +it = win.getTransients().rbegin(); - for (; it != it_end; ++it) { - (*stackit) = (*it)->getFrameWindow(); - ++stackit; - screen->updateNetizenWindowLower((*it)->getClientWindow()); - if (! (*it)->isIconic()) { - Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); - wkspc->stackingList.remove((*it)); - wkspc->stackingList.push_back((*it)); - } - } +for (; it != it_end; ++it) { +(*stackit) = (*it)->getFrameWindow(); +++stackit; +screen->updateNetizenWindowLower((*it)->getClientWindow()); +if (! (*it)->isIconic()) { +Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); +wkspc->stackingList.remove((*it)); +wkspc->stackingList.push_back((*it)); +} +} }
M src/Workspace.hhsrc/Workspace.hh

@@ -43,80 +43,80 @@ Handles a single workspace

*/ class Workspace:private FbTk::NotCopyable { public: - typedef std::vector<FluxboxWindow *> Windows; - typedef std::vector<Window> Stack; + typedef std::vector<FluxboxWindow *> Windows; + typedef std::vector<Window> Stack; - explicit Workspace(BScreen *screen, unsigned int workspaceid = 0); - ~Workspace(); + explicit Workspace(BScreen *screen, unsigned int workspaceid = 0); + ~Workspace(); - void setLastFocusedWindow(FluxboxWindow *w); - /** - Set workspace name - */ - void setName(const std::string &name); - void showAll(); - void hideAll(); - void removeAll(); - void raiseWindow(FluxboxWindow *win); - void lowerWindow(FluxboxWindow *win); - void reconfigure(); - void update(); - void setCurrent(); - void shutdown(); - int addWindow(FluxboxWindow *win, bool place = false); - int removeWindow(FluxboxWindow *win); - BScreen *getScreen() { return screen; } - FluxboxWindow *getLastFocusedWindow() { return lastfocus; } + void setLastFocusedWindow(FluxboxWindow *w); + /** + Set workspace name + */ + void setName(const std::string &name); + void showAll(); + void hideAll(); + void removeAll(); + void raiseWindow(FluxboxWindow *win); + void lowerWindow(FluxboxWindow *win); + void reconfigure(); + void update(); + void setCurrent(); + void shutdown(); + int addWindow(FluxboxWindow *win, bool place = false); + int removeWindow(FluxboxWindow *win); + BScreen *getScreen() { return screen; } + FluxboxWindow *getLastFocusedWindow() { return lastfocus; } - const BScreen *getScreen() const { return screen; } - const FluxboxWindow *getLastFocusedWindow() const { return lastfocus; } - Clientmenu &menu() { return m_clientmenu; } - /// client menu - inline const Clientmenu &menu() const { return m_clientmenu; } - /// name of this workspace - inline const std::string &name() const { return m_name; } - /** - @return the number of this workspace, note: obsolete, should be in BScreen - */ - inline unsigned int workspaceID() const { return m_id; } - /** - @param id the window id number - @return window that match the id, else 0 - */ - FluxboxWindow *getWindow(unsigned int id); - const FluxboxWindow *getWindow(unsigned int id) const; - const Windows &getWindowList() const { return m_windowlist; } - Windows &getWindowList() { return m_windowlist; } + const BScreen *getScreen() const { return screen; } + const FluxboxWindow *getLastFocusedWindow() const { return lastfocus; } + Clientmenu &menu() { return m_clientmenu; } + /// client menu + inline const Clientmenu &menu() const { return m_clientmenu; } + /// name of this workspace + inline const std::string &name() const { return m_name; } + /** + @return the number of this workspace, note: obsolete, should be in BScreen + */ + inline unsigned int workspaceID() const { return m_id; } + /** + @param id the window id number + @return window that match the id, else 0 + */ + FluxboxWindow *getWindow(unsigned int id); + const FluxboxWindow *getWindow(unsigned int id) const; + const Windows &getWindowList() const { return m_windowlist; } + Windows &getWindowList() { return m_windowlist; } - bool isCurrent() const; - bool isLastWindow(FluxboxWindow *window) const; - int getCount() const; - void checkGrouping(FluxboxWindow &win); - static bool loadGroups(const std::string &filename); + bool isCurrent() const; + bool isLastWindow(FluxboxWindow *window) const; + int getCount() const; + void checkGrouping(FluxboxWindow &win); + static bool loadGroups(const std::string &filename); protected: - void placeWindow(FluxboxWindow *win); + void placeWindow(FluxboxWindow *win); private: - void raiseAndFillStack(Stack::iterator &it, const FluxboxWindow &win); - void lowerAndFillStack(Stack::iterator &it, const FluxboxWindow &win); + void raiseAndFillStack(Stack::iterator &it, const FluxboxWindow &win); + void lowerAndFillStack(Stack::iterator &it, const FluxboxWindow &win); - BScreen *screen; - FluxboxWindow *lastfocus; - Clientmenu m_clientmenu; + BScreen *screen; + FluxboxWindow *lastfocus; + Clientmenu m_clientmenu; - typedef std::list<FluxboxWindow *> WindowStack; - typedef std::vector<std::string> Group; - typedef std::vector<Group> GroupList; + typedef std::list<FluxboxWindow *> WindowStack; + typedef std::vector<std::string> Group; + typedef std::vector<Group> GroupList; - static GroupList m_groups; ///< handle auto groupings + static GroupList m_groups; ///< handle auto groupings - WindowStack stackingList; - Windows m_windowlist; + WindowStack stackingList; + Windows m_windowlist; - std::string m_name; ///< name of this workspace - unsigned int m_id; ///< id, obsolete, this should be in BScreen - int cascade_x, cascade_y; + std::string m_name; ///< name of this workspace + unsigned int m_id; ///< id, obsolete, this should be in BScreen + int cascade_x, cascade_y; };
M src/Workspacemenu.ccsrc/Workspacemenu.cc

@@ -21,7 +21,7 @@ // 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. -// $Id: Workspacemenu.cc,v 1.10 2002/10/25 21:15:49 fluxgen Exp $ +// $Id: Workspacemenu.cc,v 1.11 2002/12/01 13:42:06 rathnor Exp $ #include "Workspacemenu.hh"

@@ -44,36 +44,36 @@ #include <cassert>

Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) { - setInternalMenu(); - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuWorkspacesTitle, - "Workspaces")); - insert(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuNewWorkspace, - "New Workspace")); - insert(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuRemoveLast, - "Remove Last")); + setInternalMenu(); + I18n *i18n = I18n::instance(); + using namespace FBNLS; + setLabel(i18n->getMessage( + WorkspacemenuSet, WorkspacemenuWorkspacesTitle, + "Workspaces")); + insert(i18n->getMessage( + WorkspacemenuSet, WorkspacemenuNewWorkspace, + "New Workspace")); + insert(i18n->getMessage( + WorkspacemenuSet, WorkspacemenuRemoveLast, + "Remove Last")); } void Workspacemenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - if (index == 0) { - screen()->addWorkspace(); - Fluxbox::instance()->save_rc(); - } else if (index == 1) { - screen()->removeLastWorkspace(); - Fluxbox::instance()->save_rc(); - } else if ((screen()->getCurrentWorkspace()->workspaceID() != - (index - 2)) && ((index - 2) < screen()->getCount())) { - screen()->changeWorkspaceID(index - 2); - } + if (button == 1) { + if (index == 0) { + screen()->addWorkspace(); + Fluxbox::instance()->save_rc(); + } else if (index == 1) { + screen()->removeLastWorkspace(); + Fluxbox::instance()->save_rc(); + } else if ((screen()->getCurrentWorkspace()->workspaceID() != + (index - 2)) && ((index - 2) < screen()->getCount())) { + screen()->changeWorkspaceID(index - 2); + } - if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); - } + if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) + hide(); + } }
M src/Workspacemenu.hhsrc/Workspacemenu.hh

@@ -28,10 +28,10 @@ #include "Basemenu.hh"

class Workspacemenu : public Basemenu { public: - Workspacemenu(BScreen *screen); + Workspacemenu(BScreen *screen); protected: - virtual void itemSelected(int button, unsigned int index); + virtual void itemSelected(int button, unsigned int index); };
M src/XrmDatabaseHelper.hhsrc/XrmDatabaseHelper.hh

@@ -19,7 +19,7 @@ // 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. -// $Id: XrmDatabaseHelper.hh,v 1.5 2002/07/20 09:52:13 fluxgen Exp $ +// $Id: XrmDatabaseHelper.hh,v 1.6 2002/12/01 13:42:06 rathnor Exp $ // This is a helper for XrmDatabase // when database goes out of scope

@@ -37,27 +37,27 @@ */

class XrmDatabaseHelper { public: - XrmDatabaseHelper(char const * filename=0) + XrmDatabaseHelper(char const * filename=0) : m_database(filename == 0 ? 0 : XrmGetFileDatabase(filename)) { } - ~XrmDatabaseHelper() { - if (m_database!=0) - XrmDestroyDatabase(m_database); - } + ~XrmDatabaseHelper() { + if (m_database!=0) + XrmDestroyDatabase(m_database); + } - /// assignment operator - XrmDatabaseHelper& operator=(const XrmDatabase& database) { - if (m_database!=0) - XrmDestroyDatabase(m_database); - m_database = database; - return *this; - } - bool operator == (const XrmDatabase& database) { return m_database == database; } - XrmDatabase & operator*(void) { return m_database; } + /// assignment operator + XrmDatabaseHelper& operator=(const XrmDatabase& database) { + if (m_database!=0) + XrmDestroyDatabase(m_database); + m_database = database; + return *this; + } + bool operator == (const XrmDatabase& database) { return m_database == database; } + XrmDatabase & operator*(void) { return m_database; } private: - XrmDatabase m_database; + XrmDatabase m_database; }; #endif //_XRMDATABASEHELPER_HH_
M src/fluxbox.ccsrc/fluxbox.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: fluxbox.cc,v 1.83 2002/11/30 20:18:35 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.84 2002/12/01 13:42:06 rathnor Exp $ #include "fluxbox.hh"

@@ -128,14 +128,14 @@ #ifndef HAVE_BASENAME

namespace { char *basename (char *s) { - char *save = s; + char *save = s; - while (*s) { - if (*s++ == '/') - save = s; - } + while (*s) { + if (*s++ == '/') + save = s; + } - return save; + return save; } }; // end anonymous namespace

@@ -148,21 +148,21 @@

// X event scanner for enter/leave notifies - adapted from twm typedef struct scanargs { - Window w; - Bool leave, inferior, enter; + Window w; + Bool leave, inferior, enter; } scanargs; static Bool queueScanner(Display *, XEvent *e, char *args) { - if ((e->type == LeaveNotify) && - (e->xcrossing.window == ((scanargs *) args)->w) && - (e->xcrossing.mode == NotifyNormal)) { - ((scanargs *) args)->leave = True; - ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); - } else if ((e->type == EnterNotify) && - (e->xcrossing.mode == NotifyUngrab)) - ((scanargs *) args)->enter = True; + if ((e->type == LeaveNotify) && + (e->xcrossing.window == ((scanargs *) args)->w) && + (e->xcrossing.mode == NotifyNormal)) { + ((scanargs *) args)->leave = True; + ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior); + } else if ((e->type == EnterNotify) && + (e->xcrossing.mode == NotifyUngrab)) + ((scanargs *) args)->enter = True; - return False; + return False; } //----------------------------------------------------------------- //---- accessors for int, bool, and some enums with Resource ------

@@ -170,56 +170,56 @@ //-----------------------------------------------------------------

template<> void Resource<int>:: setFromString(const char* strval) { - int val; - if (sscanf(strval, "%d", &val)==1) - *this = val; + int val; + if (sscanf(strval, "%d", &val)==1) + *this = val; } template<> void Resource<std::string>:: setFromString(const char *strval) { - *this = strval; + *this = strval; } template<> void Resource<bool>:: setFromString(char const *strval) { - if (strcasecmp(strval, "true")==0) - *this = true; - else - *this = false; + if (strcasecmp(strval, "true")==0) + *this = true; + else + *this = false; } template<> void Resource<Fluxbox::TitlebarList>:: setFromString(char const *strval) { - vector<std::string> val; - StringUtil::stringtok(val, strval); - int size=val.size(); - //clear old values - m_value.clear(); + vector<std::string> val; + StringUtil::stringtok(val, strval); + int size=val.size(); + //clear old values + m_value.clear(); - for (int i=0; i<size; i++) { - if (strcasecmp(val[i].c_str(), "Maximize")==0) - m_value.push_back(Fluxbox::MAXIMIZE); - else if (strcasecmp(val[i].c_str(), "Minimize")==0) - m_value.push_back(Fluxbox::MINIMIZE); - else if (strcasecmp(val[i].c_str(), "Shade")==0) - m_value.push_back(Fluxbox::SHADE); - else if (strcasecmp(val[i].c_str(), "Stick")==0) - m_value.push_back(Fluxbox::STICK); - else if (strcasecmp(val[i].c_str(), "Menu")==0) - m_value.push_back(Fluxbox::MENU); - else if (strcasecmp(val[i].c_str(), "Close")==0) - m_value.push_back(Fluxbox::CLOSE); - } + for (int i=0; i<size; i++) { + if (strcasecmp(val[i].c_str(), "Maximize")==0) + m_value.push_back(Fluxbox::MAXIMIZE); + else if (strcasecmp(val[i].c_str(), "Minimize")==0) + m_value.push_back(Fluxbox::MINIMIZE); + else if (strcasecmp(val[i].c_str(), "Shade")==0) + m_value.push_back(Fluxbox::SHADE); + else if (strcasecmp(val[i].c_str(), "Stick")==0) + m_value.push_back(Fluxbox::STICK); + else if (strcasecmp(val[i].c_str(), "Menu")==0) + m_value.push_back(Fluxbox::MENU); + else if (strcasecmp(val[i].c_str(), "Close")==0) + m_value.push_back(Fluxbox::CLOSE); + } } template<> void Resource<unsigned int>:: setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); + if (sscanf(strval, "%ul", &m_value) != 1) + setDefaultValue(); } //-----------------------------------------------------------------

@@ -228,15 +228,15 @@ //-----------------------------------------------------------------

template<> std::string Resource<bool>:: getString() { - return std::string(**this == true ? "true" : "false"); + return std::string(**this == true ? "true" : "false"); } template<> std::string Resource<int>:: getString() { - char strval[256]; - sprintf(strval, "%d", **this); - return std::string(strval); + char strval[256]; + sprintf(strval, "%d", **this); + return std::string(strval); } template<>

@@ -246,43 +246,43 @@

template<> std::string Resource<Fluxbox::TitlebarList>:: getString() { - string retval; - int size=m_value.size(); - for (int i=0; i<size; i++) { - switch (m_value[i]) { - case Fluxbox::SHADE: - retval.append("Shade"); - break; - case Fluxbox::MINIMIZE: - retval.append("Minimize"); - break; - case Fluxbox::MAXIMIZE: - retval.append("Maximize"); - break; - case Fluxbox::CLOSE: - retval.append("Close"); - break; - case Fluxbox::STICK: - retval.append("Stick"); - break; - case Fluxbox::MENU: - retval.append("Menu"); - break; - default: - break; - } - retval.append(" "); - } + string retval; + int size=m_value.size(); + for (int i=0; i<size; i++) { + switch (m_value[i]) { + case Fluxbox::SHADE: + retval.append("Shade"); + break; + case Fluxbox::MINIMIZE: + retval.append("Minimize"); + break; + case Fluxbox::MAXIMIZE: + retval.append("Maximize"); + break; + case Fluxbox::CLOSE: + retval.append("Close"); + break; + case Fluxbox::STICK: + retval.append("Stick"); + break; + case Fluxbox::MENU: + retval.append("Menu"); + break; + default: + break; + } + retval.append(" "); + } - return retval; + return retval; } template<> string Resource<unsigned int>:: getString() { - char tmpstr[128]; - sprintf(tmpstr, "%ul", m_value); - return string(tmpstr); + char tmpstr[128]; + sprintf(tmpstr, "%ul", m_value); + return string(tmpstr); } //static singleton var

@@ -294,163 +294,163 @@ Fluxbox::Titlebar Fluxbox::m_titlebar_left[] = {STICK};

Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE}; Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc) -: BaseDisplay(m_argv[0], dpy_name), FbAtoms(getXDisplay()), -m_resourcemanager(), m_screen_rm(), -m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), -m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"), -m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"), -m_rc_stylefile(m_resourcemanager, "", "session.styleFile", "Session.StyleFile"), -m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), -m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), -m_rc_slitlistfile(m_resourcemanager, "", "session.slitlistFile", "Session.SlitlistFile"), -m_rc_groupfile(m_resourcemanager, "", "session.groupFile", "Session.GroupFile"), -m_rc_titlebar_left(m_resourcemanager, TitlebarList(&m_titlebar_left[0], &m_titlebar_left[1]), "session.titlebar.left", "Session.Titlebar.Left"), -m_rc_titlebar_right(m_resourcemanager, TitlebarList(&m_titlebar_right[0], &m_titlebar_right[3]), "session.titlebar.right", "Session.Titlebar.Right"), -m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), -m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), -focused_window(0), masked_window(0), -timer(this), -no_focus(false), -rc_file(rc ? rc : ""), -argv(m_argv), argc(m_argc), -key(0) + : BaseDisplay(m_argv[0], dpy_name), FbAtoms(getXDisplay()), + m_resourcemanager(), m_screen_rm(), + m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), + m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"), + m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"), + m_rc_stylefile(m_resourcemanager, "", "session.styleFile", "Session.StyleFile"), + m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), + m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), + m_rc_slitlistfile(m_resourcemanager, "", "session.slitlistFile", "Session.SlitlistFile"), + m_rc_groupfile(m_resourcemanager, "", "session.groupFile", "Session.GroupFile"), + m_rc_titlebar_left(m_resourcemanager, TitlebarList(&m_titlebar_left[0], &m_titlebar_left[1]), "session.titlebar.left", "Session.Titlebar.Left"), + m_rc_titlebar_right(m_resourcemanager, TitlebarList(&m_titlebar_right[0], &m_titlebar_right[3]), "session.titlebar.right", "Session.Titlebar.Right"), + m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), + m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), + focused_window(0), masked_window(0), + timer(this), + no_focus(false), + rc_file(rc ? rc : ""), + argv(m_argv), argc(m_argc), + key(0) { - if (singleton != 0) { - cerr<<"Fatal! There can only one instance of fluxbox class."<<endl; - abort(); - } + if (singleton != 0) { + cerr<<"Fatal! There can only one instance of fluxbox class."<<endl; + abort(); + } - //catch system signals - SignalHandler *sigh = SignalHandler::instance(); + //catch system signals + SignalHandler *sigh = SignalHandler::instance(); - sigh->registerHandler(SIGSEGV, this); - sigh->registerHandler(SIGFPE, this); - sigh->registerHandler(SIGTERM, this); - sigh->registerHandler(SIGINT, this); - sigh->registerHandler(SIGCHLD, this); - sigh->registerHandler(SIGHUP, this); - sigh->registerHandler(SIGUSR1, this); - sigh->registerHandler(SIGUSR2, this); + sigh->registerHandler(SIGSEGV, this); + sigh->registerHandler(SIGFPE, this); + sigh->registerHandler(SIGTERM, this); + sigh->registerHandler(SIGINT, this); + sigh->registerHandler(SIGCHLD, this); + sigh->registerHandler(SIGHUP, this); + sigh->registerHandler(SIGUSR1, this); + sigh->registerHandler(SIGUSR2, this); - //setup cursor bitmaps - cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr); - cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); - cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); - cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); + //setup cursor bitmaps + cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr); + cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur); + cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle); + cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle); - //singleton pointer - singleton = this; + //singleton pointer + singleton = this; - // setup atom handlers + // setup atom handlers #ifdef USE_GNOME - m_atomhandler.push_back(new Gnome()); // for gnome 1 atom support + m_atomhandler.push_back(new Gnome()); // for gnome 1 atom support #endif //USE_GNOME #ifdef USE_NEWWMSPEC - m_atomhandler.push_back(new Ewmh()); // for Extended window manager atom support + m_atomhandler.push_back(new Ewmh()); // for Extended window manager atom support #endif // USE_NEWWMSPEC - grab(); + grab(); - setupConfigFiles(); + setupConfigFiles(); - if (! XSupportsLocale()) - cerr<<"Warning: X server does not support locale"<<endl; + if (! XSupportsLocale()) + cerr<<"Warning: X server does not support locale"<<endl; - if (XSetLocaleModifiers("") == 0) - cerr<<"Warning: cannot set locale modifiers"<<endl; + if (XSetLocaleModifiers("") == 0) + cerr<<"Warning: cannot set locale modifiers"<<endl; // Set default values to member variables - resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0; + resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0; - masked = None; + masked = None; #ifdef SLIT #ifdef KDE - //For KDE dock applets - kwm1_dockwindow = XInternAtom(getXDisplay(), "KWM_DOCKWINDOW", False); //KDE v1.x - kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x + //For KDE dock applets + kwm1_dockwindow = XInternAtom(getXDisplay(), "KWM_DOCKWINDOW", False); //KDE v1.x + kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x #endif //KDE #endif // SLIT #ifdef HAVE_GETPID - fluxbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False); + fluxbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False); #endif // HAVE_GETPID - int i; - load_rc(); - //allocate screens - for (i = 0; i < getNumberOfScreens(); i++) { - char scrname[128], altscrname[128]; - sprintf(scrname, "session.screen%d", i); - sprintf(altscrname, "session.Screen%d", i); - BScreen *screen = new BScreen(m_screen_rm, scrname, altscrname, i); - if (! screen->isScreenManaged()) { - delete screen; - continue; - } - screenList.push_back(screen); + int i; + load_rc(); + //allocate screens + for (i = 0; i < getNumberOfScreens(); i++) { + char scrname[128], altscrname[128]; + sprintf(scrname, "session.screen%d", i); + sprintf(altscrname, "session.Screen%d", i); + BScreen *screen = new BScreen(m_screen_rm, scrname, altscrname, i); + if (! screen->isScreenManaged()) { + delete screen; + continue; + } + screenList.push_back(screen); - // attach screen signals to this - screen->currentWorkspaceSig().attach(this); - screen->workspaceCountSig().attach(this); - screen->workspaceNamesSig().attach(this); - screen->clientListSig().attach(this); + // attach screen signals to this + screen->currentWorkspaceSig().attach(this); + screen->workspaceCountSig().attach(this); + screen->workspaceNamesSig().attach(this); + screen->clientListSig().attach(this); - // initiate atomhandler for screen specific stuff - for (size_t atomh=0; atomh<m_atomhandler.size(); ++atomh) { - m_atomhandler[atomh]->initForScreen(*screen); - } + // initiate atomhandler for screen specific stuff + for (size_t atomh=0; atomh<m_atomhandler.size(); ++atomh) { + m_atomhandler[atomh]->initForScreen(*screen); + } - } + } - I18n *i18n = I18n::instance(); - if (screenList.size() == 0) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::blackboxSet, FBNLS::blackboxNoManagableScreens, - "Fluxbox::Fluxbox: no managable screens found, aborting.\n")); + I18n *i18n = I18n::instance(); + if (screenList.size() == 0) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::blackboxSet, FBNLS::blackboxNoManagableScreens, + "Fluxbox::Fluxbox: no managable screens found, aborting.\n")); - throw static_cast<int>(3); - } + throw static_cast<int>(3); + } - XSynchronize(getXDisplay(), False); - XSync(getXDisplay(), False); + XSynchronize(getXDisplay(), False); + XSync(getXDisplay(), False); - reconfigure_wait = reread_menu_wait = false; + reconfigure_wait = reread_menu_wait = false; - timer.setTimeout(0); - timer.fireOnce(True); + timer.setTimeout(0); + timer.fireOnce(True); - //create keybindings handler and load keys file - auto_ptr<Keys> tmp(new Keys(getXDisplay(), StringUtil::expandFilename(*m_rc_keyfile).c_str())); - key = tmp; + //create keybindings handler and load keys file + auto_ptr<Keys> tmp(new Keys(getXDisplay(), StringUtil::expandFilename(*m_rc_keyfile).c_str())); + key = tmp; - ungrab(); + ungrab(); } Fluxbox::~Fluxbox() { - // destroy atomhandlers - while (!m_atomhandler.empty()) { - delete m_atomhandler.back(); - m_atomhandler.pop_back(); - } + // destroy atomhandlers + while (!m_atomhandler.empty()) { + delete m_atomhandler.back(); + m_atomhandler.pop_back(); + } - std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); - for (; it != it_end; ++it) { - MenuTimestamp *ts = *it; + std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); + std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); + for (; it != it_end; ++it) { + MenuTimestamp *ts = *it; - if (ts->filename) - delete [] ts->filename; + if (ts->filename) + delete [] ts->filename; - delete ts; - } + delete ts; + } }

@@ -460,623 +460,623 @@ // home directory

//--------------------------------------- void Fluxbox::setupConfigFiles() { - bool createInit, createKeys, createMenu; - createInit = createKeys = createMenu = false; + bool createInit, createKeys, createMenu; + createInit = createKeys = createMenu = false; - string dirname = getenv("HOME")+string("/.")+string(RC_PATH) + "/"; - string initFile, keysFile, menuFile, slitlistFile; - initFile = dirname+RC_INIT_FILE; - keysFile = dirname+"keys"; - menuFile = dirname+"menu"; + string dirname = getenv("HOME")+string("/.")+string(RC_PATH) + "/"; + string initFile, keysFile, menuFile, slitlistFile; + initFile = dirname+RC_INIT_FILE; + keysFile = dirname+"keys"; + menuFile = dirname+"menu"; - struct stat buf; + struct stat buf; - // is file/dir already there? - if (! stat(dirname.c_str(), &buf)) { - /*TODO: this - if (! (buf.st_mode & S_IFDIR)) { - cerr << dirname.c_str() << "!" << endl; - return 1; - } - */ + // is file/dir already there? + if (! stat(dirname.c_str(), &buf)) { + /*TODO: this + if (! (buf.st_mode & S_IFDIR)) { + cerr << dirname.c_str() << "!" << endl; + return 1; + } + */ - // check if anything with those name exists, if not create new - if (stat(initFile.c_str(), &buf)) - createInit = true; - if (stat(keysFile.c_str(), &buf)) - createKeys = true; - if (stat(menuFile.c_str(), &buf)) - createMenu = true; + // check if anything with those name exists, if not create new + if (stat(initFile.c_str(), &buf)) + createInit = true; + if (stat(keysFile.c_str(), &buf)) + createKeys = true; + if (stat(menuFile.c_str(), &buf)) + createMenu = true; - } else { + } else { #ifdef DEBUG - cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl; + cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl; #endif // DEBUG - // create directory with perm 700 - if (mkdir(dirname.c_str(), 0700)) { - cerr << "Can't create " << dirname << " directory!" << endl; - return; - } + // create directory with perm 700 + if (mkdir(dirname.c_str(), 0700)) { + cerr << "Can't create " << dirname << " directory!" << endl; + return; + } - //mark creation of files - createInit = createKeys = createMenu = true; - } + //mark creation of files + createInit = createKeys = createMenu = true; + } - // should we copy key configuraion? - if (createKeys) { - ifstream from(DEFAULTKEYSFILE); - ofstream to(keysFile.c_str()); + // should we copy key configuraion? + if (createKeys) { + ifstream from(DEFAULTKEYSFILE); + ofstream to(keysFile.c_str()); - if (! to.good()) { - cerr << "Can't write file" << endl; - } else if (from.good()) { - #ifdef DEBUG - cerr << "Copying file: " << DEFAULTKEYSFILE << endl; - #endif // DEBUG - to<<from.rdbuf(); //copy file + if (! to.good()) { + cerr << "Can't write file" << endl; + } else if (from.good()) { +#ifdef DEBUG + cerr << "Copying file: " << DEFAULTKEYSFILE << endl; +#endif // DEBUG + to<<from.rdbuf(); //copy file - } else { - cerr<<"Can't copy default keys file."<<endl; - } - } + } else { + cerr<<"Can't copy default keys file."<<endl; + } + } - // should we copy menu configuraion? - if (createMenu) { - ifstream from(DEFAULTMENU); - ofstream to(menuFile.c_str()); + // should we copy menu configuraion? + if (createMenu) { + ifstream from(DEFAULTMENU); + ofstream to(menuFile.c_str()); - if (! to.good()) { - cerr << "Can't open " << menuFile.c_str() << "for writing" << endl; - } else if (from.good()) { - #ifdef DEBUG - cerr << "Copying file: " << DEFAULTMENU << endl; - #endif // DEBUG - to<<from.rdbuf(); //copy file + if (! to.good()) { + cerr << "Can't open " << menuFile.c_str() << "for writing" << endl; + } else if (from.good()) { +#ifdef DEBUG + cerr << "Copying file: " << DEFAULTMENU << endl; +#endif // DEBUG + to<<from.rdbuf(); //copy file - } else { - cerr<<"Can't copy default menu file."<<endl; - } - } + } else { + cerr<<"Can't copy default menu file."<<endl; + } + } - // should we copy default init file? - if (createInit) { - ifstream from(DEFAULT_INITFILE); - ofstream to(initFile.c_str()); + // should we copy default init file? + if (createInit) { + ifstream from(DEFAULT_INITFILE); + ofstream to(initFile.c_str()); - if (! to.good()) { - cerr << "Can't open " << initFile.c_str() << "for writing" << endl; - } else if (from.good()) { - #ifdef DEBUG - cerr << "Copying file: " << DEFAULT_INITFILE << endl; - #endif // DEBUG - to<<from.rdbuf(); //copy file - } else { - cerr<<"Can't copy default init file."<<endl; - } - } + if (! to.good()) { + cerr << "Can't open " << initFile.c_str() << "for writing" << endl; + } else if (from.good()) { +#ifdef DEBUG + cerr << "Copying file: " << DEFAULT_INITFILE << endl; +#endif // DEBUG + to<<from.rdbuf(); //copy file + } else { + cerr<<"Can't copy default init file."<<endl; + } + } } void Fluxbox::handleEvent(XEvent * const e) { - if ((masked == e->xany.window) && masked_window && - (e->type == MotionNotify)) { - last_time = e->xmotion.time; - masked_window->motionNotifyEvent(&e->xmotion); + if ((masked == e->xany.window) && masked_window && + (e->type == MotionNotify)) { + last_time = e->xmotion.time; + masked_window->motionNotifyEvent(&e->xmotion); - return; - } + return; + } - switch (e->type) { - case ButtonRelease: - case ButtonPress: - handleButtonEvent(e->xbutton); + switch (e->type) { + case ButtonRelease: + case ButtonPress: + handleButtonEvent(e->xbutton); break; - case ConfigureRequest: - { - FluxboxWindow *win = (FluxboxWindow *) 0; + case ConfigureRequest: + { + FluxboxWindow *win = (FluxboxWindow *) 0; #ifdef SLIT - Slit *slit = (Slit *) 0; + Slit *slit = (Slit *) 0; #endif // SLIT - if ((win = searchWindow(e->xconfigurerequest.window))) { - win->configureRequestEvent(&e->xconfigurerequest); + if ((win = searchWindow(e->xconfigurerequest.window))) { + win->configureRequestEvent(&e->xconfigurerequest); #ifdef SLIT - } else if ((slit = searchSlit(e->xconfigurerequest.window))) { - slit->configureRequestEvent(&e->xconfigurerequest); + } else if ((slit = searchSlit(e->xconfigurerequest.window))) { + slit->configureRequestEvent(&e->xconfigurerequest); #endif // SLIT - } else { - grab(); + } else { + grab(); - if (validateWindow(e->xconfigurerequest.window)) { - XWindowChanges xwc; + if (validateWindow(e->xconfigurerequest.window)) { + XWindowChanges xwc; - xwc.x = e->xconfigurerequest.x; - xwc.y = e->xconfigurerequest.y; - xwc.width = e->xconfigurerequest.width; - xwc.height = e->xconfigurerequest.height; - xwc.border_width = e->xconfigurerequest.border_width; - xwc.sibling = e->xconfigurerequest.above; - xwc.stack_mode = e->xconfigurerequest.detail; + xwc.x = e->xconfigurerequest.x; + xwc.y = e->xconfigurerequest.y; + xwc.width = e->xconfigurerequest.width; + xwc.height = e->xconfigurerequest.height; + xwc.border_width = e->xconfigurerequest.border_width; + xwc.sibling = e->xconfigurerequest.above; + xwc.stack_mode = e->xconfigurerequest.detail; - XConfigureWindow(getXDisplay(), e->xconfigurerequest.window, - e->xconfigurerequest.value_mask, &xwc); - } + XConfigureWindow(getXDisplay(), e->xconfigurerequest.window, + e->xconfigurerequest.value_mask, &xwc); + } - ungrab(); - } + ungrab(); + } - } - break; - case MapRequest: - { + } + break; + case MapRequest: + { #ifdef DEBUG - fprintf(stderr, - I18n::instance()-> - getMessage( - FBNLS::blackboxSet, FBNLS::blackboxMapRequest, - "Fluxbox::process_event(): MapRequest for 0x%lx\n"), - e->xmaprequest.window); + fprintf(stderr, + I18n::instance()-> + getMessage( + FBNLS::blackboxSet, FBNLS::blackboxMapRequest, + "Fluxbox::process_event(): MapRequest for 0x%lx\n"), + e->xmaprequest.window); #endif // DEBUG #ifdef SLIT #ifdef KDE - //Check and see if client is KDE dock applet. - //If so add to Slit - bool iskdedockapp = false; - Atom ajunk; - int ijunk; - unsigned long *data = (unsigned long *) 0, uljunk; + //Check and see if client is KDE dock applet. + //If so add to Slit + bool iskdedockapp = false; + Atom ajunk; + int ijunk; + unsigned long *data = (unsigned long *) 0, uljunk; - // Check if KDE v2.x dock applet - if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, - getKWM2DockwindowAtom(), 0l, 1l, False, - XA_WINDOW, &ajunk, &ijunk, &uljunk, - &uljunk, (unsigned char **) &data) == Success) { + // Check if KDE v2.x dock applet + if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, + getKWM2DockwindowAtom(), 0l, 1l, False, + XA_WINDOW, &ajunk, &ijunk, &uljunk, + &uljunk, (unsigned char **) &data) == Success) { - if (data) - iskdedockapp = True; - XFree((char *) data); + if (data) + iskdedockapp = True; + XFree((char *) data); - } + } - // Check if KDE v1.x dock applet - if (!iskdedockapp) { - if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, - getKWM1DockwindowAtom(), 0l, 1l, False, - getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk, - &uljunk, (unsigned char **) &data) == Success) { - iskdedockapp = (data && data[0] != 0); - XFree((char *) data); - } - } + // Check if KDE v1.x dock applet + if (!iskdedockapp) { + if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window, + getKWM1DockwindowAtom(), 0l, 1l, False, + getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk, + &uljunk, (unsigned char **) &data) == Success) { + iskdedockapp = (data && data[0] != 0); + XFree((char *) data); + } + } - if (iskdedockapp) { - XSelectInput(getXDisplay(), e->xmaprequest.window, StructureNotifyMask); - ScreenList::iterator it = screenList.begin(); - for (; (*it) == screenList.back(); ++it) { - (*it)->getSlit()->addClient(e->xmaprequest.window); - } - return; - } + if (iskdedockapp) { + XSelectInput(getXDisplay(), e->xmaprequest.window, StructureNotifyMask); + ScreenList::iterator it = screenList.begin(); + for (; (*it) == screenList.back(); ++it) { + (*it)->getSlit()->addClient(e->xmaprequest.window); + } + return; + } #endif //KDE #endif // SLIT - FluxboxWindow *win = searchWindow(e->xmaprequest.window); + FluxboxWindow *win = searchWindow(e->xmaprequest.window); - if (! win) { - win = new FluxboxWindow(e->xmaprequest.window); - if (!win->isManaged()) { - delete win; - win = 0; - } else { + if (! win) { + win = new FluxboxWindow(e->xmaprequest.window); + if (!win->isManaged()) { + delete win; + win = 0; + } else { // attach signals - attachSignals(*win); - } - } + attachSignals(*win); + } + } - if ((win = searchWindow(e->xmaprequest.window))) - win->mapRequestEvent(&e->xmaprequest); + if ((win = searchWindow(e->xmaprequest.window))) + win->mapRequestEvent(&e->xmaprequest); - } - break; - case MapNotify: - { - FluxboxWindow *win = searchWindow(e->xmap.window); - if (win != 0) - win->mapNotifyEvent(&e->xmap); + } + break; + case MapNotify: + { + FluxboxWindow *win = searchWindow(e->xmap.window); + if (win != 0) + win->mapNotifyEvent(&e->xmap); - } - break; + } + break; - case UnmapNotify: - handleUnmapNotify(e->xunmap); + case UnmapNotify: + handleUnmapNotify(e->xunmap); break; - case CreateNotify: + case CreateNotify: break; - case DestroyNotify: { - FluxboxWindow *win = (FluxboxWindow *) 0; + case DestroyNotify: { + FluxboxWindow *win = (FluxboxWindow *) 0; #ifdef SLIT - Slit *slit = 0; + Slit *slit = 0; #endif // SLIT - if ((win = searchWindow(e->xdestroywindow.window))) { - if (win->destroyNotifyEvent(&e->xdestroywindow)) { - delete win; - win = 0; - } + if ((win = searchWindow(e->xdestroywindow.window))) { + if (win->destroyNotifyEvent(&e->xdestroywindow)) { + delete win; + win = 0; + } - } + } #ifdef SLIT - else if ((slit = searchSlit(e->xdestroywindow.window))) { - slit->removeClient(e->xdestroywindow.window, false); + else if ((slit = searchSlit(e->xdestroywindow.window))) { + slit->removeClient(e->xdestroywindow.window, false); - } + } #endif // SLIT - } - break; - case MotionNotify: { - last_time = e->xmotion.time; + } + break; + case MotionNotify: { + last_time = e->xmotion.time; - FluxboxWindow *win = 0; - Basemenu *menu = 0; - Tab *tab = 0; + FluxboxWindow *win = 0; + Basemenu *menu = 0; + Tab *tab = 0; - if ((win = searchWindow(e->xmotion.window)) !=0) - win->motionNotifyEvent(&e->xmotion); - else if ((menu = searchMenu(e->xmotion.window)) !=0) - menu->motionNotifyEvent(&e->xmotion); - else if ((tab = searchTab(e->xmotion.window)) !=0) - tab->motionNotifyEvent(&e->xmotion); + if ((win = searchWindow(e->xmotion.window)) !=0) + win->motionNotifyEvent(&e->xmotion); + else if ((menu = searchMenu(e->xmotion.window)) !=0) + menu->motionNotifyEvent(&e->xmotion); + else if ((tab = searchTab(e->xmotion.window)) !=0) + tab->motionNotifyEvent(&e->xmotion); - } - break; - case PropertyNotify: { + } + break; + case PropertyNotify: { - last_time = e->xproperty.time; + last_time = e->xproperty.time; - if (e->xproperty.state != PropertyDelete) { - FluxboxWindow *win = searchWindow(e->xproperty.window); + if (e->xproperty.state != PropertyDelete) { + FluxboxWindow *win = searchWindow(e->xproperty.window); - if (win) - win->propertyNotifyEvent(e->xproperty.atom); - } + if (win) + win->propertyNotifyEvent(e->xproperty.atom); + } - } - break; - case EnterNotify: { - last_time = e->xcrossing.time; + } + break; + case EnterNotify: { + last_time = e->xcrossing.time; - BScreen *screen = (BScreen *) 0; - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; - Tab *tab = (Tab *) 0; - #ifdef SLIT - Slit *slit = (Slit *) 0; - #endif // SLIT + BScreen *screen = (BScreen *) 0; + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; + Tab *tab = (Tab *) 0; +#ifdef SLIT + Slit *slit = (Slit *) 0; +#endif // SLIT - if (e->xcrossing.mode == NotifyGrab) - break; + if (e->xcrossing.mode == NotifyGrab) + break; - XEvent dummy; - scanargs sa; - sa.w = e->xcrossing.window; - sa.enter = sa.leave = False; - XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa); + XEvent dummy; + scanargs sa; + sa.w = e->xcrossing.window; + sa.enter = sa.leave = False; + XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa); - if ((e->xcrossing.window == e->xcrossing.root) && - (screen = searchScreen(e->xcrossing.window))) { - screen->getImageControl()->installRootColormap(); - } else if ((win = searchWindow(e->xcrossing.window))) { - if ((win->getScreen()->isSloppyFocus() || - win->getScreen()->isSemiSloppyFocus()) && - (! win->isFocused()) && (! no_focus)) { + if ((e->xcrossing.window == e->xcrossing.root) && + (screen = searchScreen(e->xcrossing.window))) { + screen->getImageControl()->installRootColormap(); + } else if ((win = searchWindow(e->xcrossing.window))) { + if ((win->getScreen()->isSloppyFocus() || + win->getScreen()->isSemiSloppyFocus()) && + (! win->isFocused()) && (! no_focus)) { - grab(); + grab(); - if (((! sa.leave) || sa.inferior) && win->isVisible() && - win->setInputFocus()) - win->installColormap(True); + if (((! sa.leave) || sa.inferior) && win->isVisible() && + win->setInputFocus()) + win->installColormap(True); - ungrab(); - } - } else if ((menu = searchMenu(e->xcrossing.window))) - menu->enterNotifyEvent(&e->xcrossing); - else if ((tbar = searchToolbar(e->xcrossing.window))) - tbar->enterNotifyEvent(&e->xcrossing); - else if ((tab = searchTab(e->xcrossing.window))) { - win = tab->getWindow(); - if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) && - (! no_focus)) { - win->getScreen()->getWorkspace(win->getWorkspaceNumber())->raiseWindow(win); + ungrab(); + } + } else if ((menu = searchMenu(e->xcrossing.window))) + menu->enterNotifyEvent(&e->xcrossing); + else if ((tbar = searchToolbar(e->xcrossing.window))) + tbar->enterNotifyEvent(&e->xcrossing); + else if ((tab = searchTab(e->xcrossing.window))) { + win = tab->getWindow(); + if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) && + (! no_focus)) { + win->getScreen()->getWorkspace(win->getWorkspaceNumber())->raiseWindow(win); - grab(); + grab(); - if (((! sa.leave) || sa.inferior) && win->isVisible() && - win->setInputFocus()) - win->installColormap(True); + if (((! sa.leave) || sa.inferior) && win->isVisible() && + win->setInputFocus()) + win->installColormap(True); - ungrab(); - } - } + ungrab(); + } + } #ifdef SLIT - else if ((slit = searchSlit(e->xcrossing.window))) - slit->enterNotifyEvent(&e->xcrossing); + else if ((slit = searchSlit(e->xcrossing.window))) + slit->enterNotifyEvent(&e->xcrossing); #endif // SLIT - } - break; - case LeaveNotify: - { - last_time = e->xcrossing.time; + } + break; + case LeaveNotify: + { + last_time = e->xcrossing.time; - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; - #ifdef SLIT - Slit *slit = (Slit *) 0; - #endif // SLIT +#ifdef SLIT + Slit *slit = (Slit *) 0; +#endif // SLIT - if ((menu = searchMenu(e->xcrossing.window))) - menu->leaveNotifyEvent(&e->xcrossing); - else if ((win = searchWindow(e->xcrossing.window))) - win->installColormap(False); - else if ((tbar = searchToolbar(e->xcrossing.window))) - tbar->leaveNotifyEvent(&e->xcrossing); - #ifdef SLIT - else if ((slit = searchSlit(e->xcrossing.window))) - slit->leaveNotifyEvent(&e->xcrossing); - #endif // SLIT + if ((menu = searchMenu(e->xcrossing.window))) + menu->leaveNotifyEvent(&e->xcrossing); + else if ((win = searchWindow(e->xcrossing.window))) + win->installColormap(False); + else if ((tbar = searchToolbar(e->xcrossing.window))) + tbar->leaveNotifyEvent(&e->xcrossing); +#ifdef SLIT + else if ((slit = searchSlit(e->xcrossing.window))) + slit->leaveNotifyEvent(&e->xcrossing); +#endif // SLIT - } - break; - case Expose: - { - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; - Tab *tab = 0; + } + break; + case Expose: + { + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; + Tab *tab = 0; - if ((win = searchWindow(e->xexpose.window))) - win->exposeEvent(&e->xexpose); - else if ((menu = searchMenu(e->xexpose.window))) - menu->exposeEvent(&e->xexpose); - else if ((tbar = searchToolbar(e->xexpose.window))) - tbar->exposeEvent(&e->xexpose); - else if ((tab = searchTab(e->xexpose.window))) - tab->exposeEvent(&e->xexpose); + if ((win = searchWindow(e->xexpose.window))) + win->exposeEvent(&e->xexpose); + else if ((menu = searchMenu(e->xexpose.window))) + menu->exposeEvent(&e->xexpose); + else if ((tbar = searchToolbar(e->xexpose.window))) + tbar->exposeEvent(&e->xexpose); + else if ((tab = searchTab(e->xexpose.window))) + tab->exposeEvent(&e->xexpose); - } - break; - case KeyPress: - handleKeyEvent(e->xkey); + } + break; + case KeyPress: + handleKeyEvent(e->xkey); break; - case ColormapNotify: { - BScreen *screen = searchScreen(e->xcolormap.window); + case ColormapNotify: { + BScreen *screen = searchScreen(e->xcolormap.window); - if (screen != 0) { - screen->setRootColormapInstalled((e->xcolormap.state == - ColormapInstalled) ? True : False); - } - } - break; - case FocusIn: { - if (e->xfocus.mode == NotifyUngrab || - e->xfocus.detail == NotifyPointer) - break; + if (screen != 0) { + screen->setRootColormapInstalled((e->xcolormap.state == + ColormapInstalled) ? True : False); + } + } + break; + case FocusIn: { + if (e->xfocus.mode == NotifyUngrab || + e->xfocus.detail == NotifyPointer) + break; - FluxboxWindow *win = searchWindow(e->xfocus.window); - if (win && ! win->isFocused()) - setFocusedWindow(win); + FluxboxWindow *win = searchWindow(e->xfocus.window); + if (win && ! win->isFocused()) + setFocusedWindow(win); - } break; - case FocusOut: + } break; + case FocusOut: break; - case ClientMessage: - handleClientMessage(e->xclient); + case ClientMessage: + handleClientMessage(e->xclient); break; - default: { + default: { - #ifdef SHAPE - if (e->type == getShapeEventBase()) { - XShapeEvent *shape_event = (XShapeEvent *) e; - FluxboxWindow *win = (FluxboxWindow *) 0; +#ifdef SHAPE + if (e->type == getShapeEventBase()) { + XShapeEvent *shape_event = (XShapeEvent *) e; + FluxboxWindow *win = (FluxboxWindow *) 0; - if ((win = searchWindow(e->xany.window)) || - (shape_event->kind != ShapeBounding)) - win->shapeEvent(shape_event); - } - #endif // SHAPE + if ((win = searchWindow(e->xany.window)) || + (shape_event->kind != ShapeBounding)) + win->shapeEvent(shape_event); + } +#endif // SHAPE - } - } + } + } } void Fluxbox::handleButtonEvent(XButtonEvent &be) { - switch (be.type) { - case ButtonPress: - { - last_time = be.time; + switch (be.type) { + case ButtonPress: + { + last_time = be.time; - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; #ifdef SLIT - Slit *slit = (Slit *) 0; + Slit *slit = (Slit *) 0; #endif // SLIT - Toolbar *tbar = (Toolbar *) 0; - Tab *tab = 0; + Toolbar *tbar = (Toolbar *) 0; + Tab *tab = 0; - if ((win = searchWindow(be.window))) { + if ((win = searchWindow(be.window))) { - win->buttonPressEvent(&be); + win->buttonPressEvent(&be); - if (be.button == 1) - win->installColormap(True); + if (be.button == 1) + win->installColormap(True); - } else if ((menu = searchMenu(be.window))) { - menu->buttonPressEvent(&be); + } else if ((menu = searchMenu(be.window))) { + menu->buttonPressEvent(&be); #ifdef SLIT - } else if ((slit = searchSlit(be.window))) { - slit->buttonPressEvent(&be); + } else if ((slit = searchSlit(be.window))) { + slit->buttonPressEvent(&be); #endif // SLIT - } else if ((tbar = searchToolbar(be.window))) { - tbar->buttonPressEvent(&be); - } else if ((tab = searchTab(be.window))) { - tab->buttonPressEvent(&be); - } else { - ScreenList::iterator it = screenList.begin(); - ScreenList::iterator it_end = screenList.end(); + } else if ((tbar = searchToolbar(be.window))) { + tbar->buttonPressEvent(&be); + } else if ((tab = searchTab(be.window))) { + tab->buttonPressEvent(&be); + } else { + ScreenList::iterator it = screenList.begin(); + ScreenList::iterator it_end = screenList.end(); - for (; it != it_end; ++it) { + for (; it != it_end; ++it) { - BScreen *screen = *it; - if (be.window != screen->getRootWindow()) - continue; + BScreen *screen = *it; + if (be.window != screen->getRootWindow()) + continue; - if (be.button == 1) { - if (! screen->isRootColormapInstalled()) - screen->getImageControl()->installRootColormap(); + if (be.button == 1) { + if (! screen->isRootColormapInstalled()) + screen->getImageControl()->installRootColormap(); - if (screen->getWorkspacemenu()->isVisible()) - screen->getWorkspacemenu()->hide(); - if (screen->getRootmenu()->isVisible()) - screen->getRootmenu()->hide(); + if (screen->getWorkspacemenu()->isVisible()) + screen->getWorkspacemenu()->hide(); + if (screen->getRootmenu()->isVisible()) + screen->getRootmenu()->hide(); - } else if (be.button == 2) { - int mx = be.x_root - - (screen->getWorkspacemenu()->width() / 2); - int my = be.y_root - - (screen->getWorkspacemenu()->titleHeight() / 2); + } else if (be.button == 2) { + int mx = be.x_root - + (screen->getWorkspacemenu()->width() / 2); + int my = be.y_root - + (screen->getWorkspacemenu()->titleHeight() / 2); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + if (mx < 0) mx = 0; + if (my < 0) my = 0; - if (mx + screen->getWorkspacemenu()->width() > - screen->getWidth()) { - mx = screen->getWidth() - - screen->getWorkspacemenu()->width() - - screen->getBorderWidth(); - } + if (mx + screen->getWorkspacemenu()->width() > + screen->getWidth()) { + mx = screen->getWidth() - + screen->getWorkspacemenu()->width() - + screen->getBorderWidth(); + } - if (my + screen->getWorkspacemenu()->height() > - screen->getHeight()) { - my = screen->getHeight() - - screen->getWorkspacemenu()->height() - - screen->getBorderWidth(); - } - screen->getWorkspacemenu()->move(mx, my); + if (my + screen->getWorkspacemenu()->height() > + screen->getHeight()) { + my = screen->getHeight() - + screen->getWorkspacemenu()->height() - + screen->getBorderWidth(); + } + screen->getWorkspacemenu()->move(mx, my); - if (! screen->getWorkspacemenu()->isVisible()) { - screen->getWorkspacemenu()->removeParent(); - screen->getWorkspacemenu()->show(); - } - } else if (be.button == 3) { + if (! screen->getWorkspacemenu()->isVisible()) { + screen->getWorkspacemenu()->removeParent(); + screen->getWorkspacemenu()->show(); + } + } else if (be.button == 3) { //calculate placement of workspace menu //and show/hide it - int mx = be.x_root - - (screen->getRootmenu()->width() / 2); - int my = be.y_root - - (screen->getRootmenu()->titleHeight() / 2); + int mx = be.x_root - + (screen->getRootmenu()->width() / 2); + int my = be.y_root - + (screen->getRootmenu()->titleHeight() / 2); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + if (mx < 0) mx = 0; + if (my < 0) my = 0; - if (mx + screen->getRootmenu()->width() > screen->getWidth()) { - mx = screen->getWidth() - - screen->getRootmenu()->width() - - screen->getBorderWidth(); - } + if (mx + screen->getRootmenu()->width() > screen->getWidth()) { + mx = screen->getWidth() - + screen->getRootmenu()->width() - + screen->getBorderWidth(); + } - if (my + screen->getRootmenu()->height() > - screen->getHeight()) { - my = screen->getHeight() - - screen->getRootmenu()->height() - - screen->getBorderWidth(); - } - screen->getRootmenu()->move(mx, my); + if (my + screen->getRootmenu()->height() > + screen->getHeight()) { + my = screen->getHeight() - + screen->getRootmenu()->height() - + screen->getBorderWidth(); + } + screen->getRootmenu()->move(mx, my); - if (! screen->getRootmenu()->isVisible()) { - checkMenu(); - screen->getRootmenu()->show(); - } - } else if (screen->isDesktopWheeling() && be.button == 4) { - screen->nextWorkspace(1); - } else if (screen->isDesktopWheeling() && be.button == 5) { - screen->prevWorkspace(1); - } - } - } - } + if (! screen->getRootmenu()->isVisible()) { + checkMenu(); + screen->getRootmenu()->show(); + } + } else if (screen->isDesktopWheeling() && be.button == 4) { + screen->nextWorkspace(1); + } else if (screen->isDesktopWheeling() && be.button == 5) { + screen->prevWorkspace(1); + } + } + } + } - break; - case ButtonRelease: - { - last_time = be.time; - FluxboxWindow *win = (FluxboxWindow *) 0; - Basemenu *menu = (Basemenu *) 0; - Toolbar *tbar = (Toolbar *) 0; - Tab *tab = 0; + break; + case ButtonRelease: + { + last_time = be.time; + FluxboxWindow *win = (FluxboxWindow *) 0; + Basemenu *menu = (Basemenu *) 0; + Toolbar *tbar = (Toolbar *) 0; + Tab *tab = 0; - if ((win = searchWindow(be.window))) - win->buttonReleaseEvent(&be); - else if ((menu = searchMenu(be.window))) - menu->buttonReleaseEvent(&be); - else if ((tbar = searchToolbar(be.window))) - tbar->buttonReleaseEvent(&be); - else if ((tab = searchTab(be.window))) - tab->buttonReleaseEvent(&be); - } - break; - default: + if ((win = searchWindow(be.window))) + win->buttonReleaseEvent(&be); + else if ((menu = searchMenu(be.window))) + menu->buttonReleaseEvent(&be); + else if ((tbar = searchToolbar(be.window))) + tbar->buttonReleaseEvent(&be); + else if ((tab = searchTab(be.window))) + tab->buttonReleaseEvent(&be); + } + break; + default: break; - } + } } void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { - FluxboxWindow *win = 0; + FluxboxWindow *win = 0; #ifdef SLIT - Slit *slit = (Slit *) 0; + Slit *slit = (Slit *) 0; #endif // SLIT - BScreen *screen = searchScreen(ue.event); + BScreen *screen = searchScreen(ue.event); - if ( (ue.event != ue.window) && (screen != 0 || !ue.send_event)) - return; + if ( (ue.event != ue.window) && (screen != 0 || !ue.send_event)) + return; - if ((win = searchWindow(ue.window)) != 0) { + if ((win = searchWindow(ue.window)) != 0) { - if (win->unmapNotifyEvent(&ue)) { - delete win; - if (focused_window == win) // some extra checking - focused_window = 0; - win = 0; - } + if (win->unmapNotifyEvent(&ue)) { + delete win; + if (focused_window == win) // some extra checking + focused_window = 0; + win = 0; + } - } + } #ifdef SLIT - else if ((slit = searchSlit(ue.window))!=0) { - slit->removeClient(ue.window); - } + else if ((slit = searchSlit(ue.window))!=0) { + slit->removeClient(ue.window); + } #endif // SLIT }

@@ -1086,756 +1086,756 @@ // Handles XClientMessageEvent

//----------------------------------------- void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<<hex<<ce.data.l[0]<< + cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<<hex<<ce.data.l[0]<< " message_type=0x"<<ce.message_type<<dec<<endl; #endif // DEBUG - if (ce.format != 32) - return; + if (ce.format != 32) + return; - if (ce.message_type == getWMChangeStateAtom()) { - FluxboxWindow *win = searchWindow(ce.window); - if (! win || ! win->validateClient()) - return; + if (ce.message_type == getWMChangeStateAtom()) { + FluxboxWindow *win = searchWindow(ce.window); + if (! win || ! win->validateClient()) + return; - if (ce.data.l[0] == IconicState) - win->iconify(); - if (ce.data.l[0] == NormalState) - win->deiconify(); - } else if (ce.message_type == getFluxboxChangeWorkspaceAtom()) { - BScreen *screen = searchScreen(ce.window); + if (ce.data.l[0] == IconicState) + win->iconify(); + if (ce.data.l[0] == NormalState) + win->deiconify(); + } else if (ce.message_type == getFluxboxChangeWorkspaceAtom()) { + BScreen *screen = searchScreen(ce.window); - if (screen && ce.data.l[0] >= 0 && - ce.data.l[0] < (signed)screen->getCount()) - screen->changeWorkspaceID(ce.data.l[0]); + if (screen && ce.data.l[0] >= 0 && + ce.data.l[0] < (signed)screen->getCount()) + screen->changeWorkspaceID(ce.data.l[0]); - } else if (ce.message_type == getFluxboxChangeWindowFocusAtom()) { - FluxboxWindow *win = searchWindow(ce.window); - if (win && win->isVisible() && win->setInputFocus()) - win->installColormap(True); - } else if (ce.message_type == getFluxboxCycleWindowFocusAtom()) { - BScreen *screen = searchScreen(ce.window); + } else if (ce.message_type == getFluxboxChangeWindowFocusAtom()) { + FluxboxWindow *win = searchWindow(ce.window); + if (win && win->isVisible() && win->setInputFocus()) + win->installColormap(True); + } else if (ce.message_type == getFluxboxCycleWindowFocusAtom()) { + BScreen *screen = searchScreen(ce.window); - if (screen) { - if (! ce.data.l[0]) - screen->prevFocus(); - else - screen->nextFocus(); - } - } else if (ce.message_type == getFluxboxChangeAttributesAtom()) { + if (screen) { + if (! ce.data.l[0]) + screen->prevFocus(); + else + screen->nextFocus(); + } + } else if (ce.message_type == getFluxboxChangeAttributesAtom()) { - FluxboxWindow *win = searchWindow(ce.window); + FluxboxWindow *win = searchWindow(ce.window); - if (win && win->validateClient()) { - BlackboxHints net; - net.flags = ce.data.l[0]; - net.attrib = ce.data.l[1]; - net.workspace = ce.data.l[2]; - net.stack = ce.data.l[3]; - net.decoration = static_cast<int>(ce.data.l[4]); - win->changeBlackboxHints(&net); - } - } else { - FluxboxWindow *win = searchWindow(ce.window); - BScreen *screen = searchScreen(ce.window); + if (win && win->validateClient()) { + BlackboxHints net; + net.flags = ce.data.l[0]; + net.attrib = ce.data.l[1]; + net.workspace = ce.data.l[2]; + net.stack = ce.data.l[3]; + net.decoration = static_cast<int>(ce.data.l[4]); + win->changeBlackboxHints(&net); + } + } else { + FluxboxWindow *win = searchWindow(ce.window); + BScreen *screen = searchScreen(ce.window); - for (size_t i=0; i<m_atomhandler.size(); ++i) { - m_atomhandler[i]->checkClientMessage(ce, screen, win); - } - } + for (size_t i=0; i<m_atomhandler.size(); ++i) { + m_atomhandler[i]->checkClientMessage(ce, screen, win); + } + } } //----------- handleKeyEvent --------------- // Handles KeyRelease and KeyPress events //------------------------------------------ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { - switch (ke.type) { - case KeyPress: - { - Toolbar *tbar = searchToolbar(ke.window); - BScreen *screen = searchScreen(ke.window); + switch (ke.type) { + case KeyPress: + { + Toolbar *tbar = searchToolbar(ke.window); + BScreen *screen = searchScreen(ke.window); - if (tbar && tbar->isEditing()) - tbar->keyPressEvent(&ke); - else if (screen) { - #ifdef DEBUG - cerr<<"KeyEvent"<<endl; - #endif - //find action - Keys::KeyAction action = key->getAction(&ke); - #ifdef DEBUG - const char *actionstr = key->getActionStr(action); - if (actionstr) - cerr<<"KeyAction("<<actionstr<<")"<<endl; - #endif - if (action==Keys::LASTKEYGRAB) //if action not found end case - break; + if (tbar && tbar->isEditing()) + tbar->keyPressEvent(&ke); + else if (screen) { +#ifdef DEBUG + cerr<<"KeyEvent"<<endl; +#endif + //find action + Keys::KeyAction action = key->getAction(&ke); +#ifdef DEBUG + const char *actionstr = key->getActionStr(action); + if (actionstr) + cerr<<"KeyAction("<<actionstr<<")"<<endl; +#endif + if (action==Keys::LASTKEYGRAB) //if action not found end case + break; - // what to allow if moving - if (focused_window && focused_window->isMoving()) { - int allowed = false; - switch (action) { - case Keys::WORKSPACE: - case Keys::SENDTOWORKSPACE: - case Keys::WORKSPACE1: - case Keys::WORKSPACE2: - case Keys::WORKSPACE3: - case Keys::WORKSPACE4: - case Keys::WORKSPACE5: - case Keys::WORKSPACE6: - case Keys::WORKSPACE7: - case Keys::WORKSPACE8: - case Keys::WORKSPACE9: - case Keys::WORKSPACE10: - case Keys::WORKSPACE11: - case Keys::WORKSPACE12: - case Keys::NEXTWORKSPACE: - case Keys::PREVWORKSPACE: - case Keys::LEFTWORKSPACE: - case Keys::RIGHTWORKSPACE: - allowed = true; - break; - default: - allowed = false; - } - if (!allowed) break; - } + // what to allow if moving + if (focused_window && focused_window->isMoving()) { + int allowed = false; + switch (action) { + case Keys::WORKSPACE: + case Keys::SENDTOWORKSPACE: + case Keys::WORKSPACE1: + case Keys::WORKSPACE2: + case Keys::WORKSPACE3: + case Keys::WORKSPACE4: + case Keys::WORKSPACE5: + case Keys::WORKSPACE6: + case Keys::WORKSPACE7: + case Keys::WORKSPACE8: + case Keys::WORKSPACE9: + case Keys::WORKSPACE10: + case Keys::WORKSPACE11: + case Keys::WORKSPACE12: + case Keys::NEXTWORKSPACE: + case Keys::PREVWORKSPACE: + case Keys::LEFTWORKSPACE: + case Keys::RIGHTWORKSPACE: + allowed = true; + break; + default: + allowed = false; + } + if (!allowed) break; + } - switch (action) { - case Keys::WORKSPACE: + switch (action) { + case Keys::WORKSPACE: // Workspace1 has id 0, hence -1 - screen->changeWorkspaceID(key->getParam()-1); - break; - case Keys::SENDTOWORKSPACE: + screen->changeWorkspaceID(key->getParam()-1); + break; + case Keys::SENDTOWORKSPACE: // Workspace1 has id 0, hence -1 - screen->sendToWorkspace(key->getParam()-1); - break; - // NOTE!!! The WORKSPACEn commands are not needed anymore - case Keys::WORKSPACE1: - screen->changeWorkspaceID(0); - break; - case Keys::WORKSPACE2: - screen->changeWorkspaceID(1); - break; - case Keys::WORKSPACE3: - screen->changeWorkspaceID(2); - break; - case Keys::WORKSPACE4: - screen->changeWorkspaceID(3); - break; - case Keys::WORKSPACE5: - screen->changeWorkspaceID(4); - break; - case Keys::WORKSPACE6: - screen->changeWorkspaceID(5); - break; - case Keys::WORKSPACE7: - screen->changeWorkspaceID(6); - break; - case Keys::WORKSPACE8: - screen->changeWorkspaceID(7); - break; - case Keys::WORKSPACE9: - screen->changeWorkspaceID(8); - break; - case Keys::WORKSPACE10: - screen->changeWorkspaceID(9); - break; - case Keys::WORKSPACE11: - screen->changeWorkspaceID(10); - break; - case Keys::WORKSPACE12: - screen->changeWorkspaceID(11); - break; - case Keys::NEXTWORKSPACE: - screen->nextWorkspace(key->getParam()); - break; - case Keys::PREVWORKSPACE: - screen->prevWorkspace(key->getParam()); - break; - case Keys::LEFTWORKSPACE: - screen->leftWorkspace(key->getParam()); - break; - case Keys::RIGHTWORKSPACE: - screen->rightWorkspace(key->getParam()); - break; - case Keys::KILLWINDOW: //kill the current window - if (focused_window) { - XKillClient(screen->getBaseDisplay()->getXDisplay(), - focused_window->getClientWindow()); - } - break; - case Keys::NEXTWINDOW: //activate next window - screen->nextFocus(key->getParam()); - if (focused_window && focused_window->getTab()) - focused_window->getTab()->raise(); - break; - case Keys::PREVWINDOW: //activate prev window - screen->prevFocus(key->getParam()); - if (focused_window && focused_window->getTab()) - focused_window->getTab()->raise(); - break; - case Keys::NEXTTAB: - if (focused_window && focused_window->getTab()) { - Tab *tab = focused_window->getTab(); - if (tab->next()) { - screen->getCurrentWorkspace()->raiseWindow( - tab->next()->getWindow()); - tab->next()->getWindow()->setInputFocus(); - } else { - screen->getCurrentWorkspace()->raiseWindow( - tab->first()->getWindow()); - tab->first()->getWindow()->setInputFocus(); - } - } - break; - case Keys::PREVTAB: - if (focused_window && focused_window->getTab()) { - Tab *tab = focused_window->getTab(); - if (tab->prev()) { - screen->getCurrentWorkspace()->raiseWindow( - tab->prev()->getWindow()); - tab->prev()->getWindow()->setInputFocus(); - } else { - screen->getCurrentWorkspace()->raiseWindow( - tab->last()->getWindow()); - tab->last()->getWindow()->setInputFocus(); - } - } - break; - case Keys::FIRSTTAB: - if (focused_window && focused_window->getTab()) { - Tab *tab = focused_window->getTab(); - screen->getCurrentWorkspace()->raiseWindow( - tab->first()->getWindow()); - tab->first()->getWindow()->setInputFocus(); - } - break; - case Keys::LASTTAB: - if (focused_window && focused_window->getTab()) { - Tab *tab = focused_window->getTab(); - screen->getCurrentWorkspace()->raiseWindow( - tab->last()->getWindow()); - tab->last()->getWindow()->setInputFocus(); - } - break; - case Keys::MOVETABPREV: - if (focused_window && focused_window->getTab()) { - focused_window->getTab()->movePrev(); - } - break; - case Keys::MOVETABNEXT: - if (focused_window && focused_window->getTab()) { - focused_window->getTab()->moveNext(); - } - break; - case Keys::EXECUTE: //execute command on keypress - { - #ifndef __EMX__ - char displaystring[MAXPATHLEN]; - sprintf(displaystring, "DISPLAY=%s", - DisplayString(getXDisplay())); - sprintf(displaystring + strlen(displaystring) - 1, "%d", - screen->getScreenNumber()); + screen->sendToWorkspace(key->getParam()-1); + break; + // NOTE!!! The WORKSPACEn commands are not needed anymore + case Keys::WORKSPACE1: + screen->changeWorkspaceID(0); + break; + case Keys::WORKSPACE2: + screen->changeWorkspaceID(1); + break; + case Keys::WORKSPACE3: + screen->changeWorkspaceID(2); + break; + case Keys::WORKSPACE4: + screen->changeWorkspaceID(3); + break; + case Keys::WORKSPACE5: + screen->changeWorkspaceID(4); + break; + case Keys::WORKSPACE6: + screen->changeWorkspaceID(5); + break; + case Keys::WORKSPACE7: + screen->changeWorkspaceID(6); + break; + case Keys::WORKSPACE8: + screen->changeWorkspaceID(7); + break; + case Keys::WORKSPACE9: + screen->changeWorkspaceID(8); + break; + case Keys::WORKSPACE10: + screen->changeWorkspaceID(9); + break; + case Keys::WORKSPACE11: + screen->changeWorkspaceID(10); + break; + case Keys::WORKSPACE12: + screen->changeWorkspaceID(11); + break; + case Keys::NEXTWORKSPACE: + screen->nextWorkspace(key->getParam()); + break; + case Keys::PREVWORKSPACE: + screen->prevWorkspace(key->getParam()); + break; + case Keys::LEFTWORKSPACE: + screen->leftWorkspace(key->getParam()); + break; + case Keys::RIGHTWORKSPACE: + screen->rightWorkspace(key->getParam()); + break; + case Keys::KILLWINDOW: //kill the current window + if (focused_window) { + XKillClient(screen->getBaseDisplay()->getXDisplay(), + focused_window->getClientWindow()); + } + break; + case Keys::NEXTWINDOW: //activate next window + screen->nextFocus(key->getParam()); + if (focused_window && focused_window->getTab()) + focused_window->getTab()->raise(); + break; + case Keys::PREVWINDOW: //activate prev window + screen->prevFocus(key->getParam()); + if (focused_window && focused_window->getTab()) + focused_window->getTab()->raise(); + break; + case Keys::NEXTTAB: + if (focused_window && focused_window->getTab()) { + Tab *tab = focused_window->getTab(); + if (tab->next()) { + screen->getCurrentWorkspace()->raiseWindow( + tab->next()->getWindow()); + tab->next()->getWindow()->setInputFocus(); + } else { + screen->getCurrentWorkspace()->raiseWindow( + tab->first()->getWindow()); + tab->first()->getWindow()->setInputFocus(); + } + } + break; + case Keys::PREVTAB: + if (focused_window && focused_window->getTab()) { + Tab *tab = focused_window->getTab(); + if (tab->prev()) { + screen->getCurrentWorkspace()->raiseWindow( + tab->prev()->getWindow()); + tab->prev()->getWindow()->setInputFocus(); + } else { + screen->getCurrentWorkspace()->raiseWindow( + tab->last()->getWindow()); + tab->last()->getWindow()->setInputFocus(); + } + } + break; + case Keys::FIRSTTAB: + if (focused_window && focused_window->getTab()) { + Tab *tab = focused_window->getTab(); + screen->getCurrentWorkspace()->raiseWindow( + tab->first()->getWindow()); + tab->first()->getWindow()->setInputFocus(); + } + break; + case Keys::LASTTAB: + if (focused_window && focused_window->getTab()) { + Tab *tab = focused_window->getTab(); + screen->getCurrentWorkspace()->raiseWindow( + tab->last()->getWindow()); + tab->last()->getWindow()->setInputFocus(); + } + break; + case Keys::MOVETABPREV: + if (focused_window && focused_window->getTab()) { + focused_window->getTab()->movePrev(); + } + break; + case Keys::MOVETABNEXT: + if (focused_window && focused_window->getTab()) { + focused_window->getTab()->moveNext(); + } + break; + case Keys::EXECUTE: //execute command on keypress + { +#ifndef __EMX__ + char displaystring[MAXPATHLEN]; + sprintf(displaystring, "DISPLAY=%s", + DisplayString(getXDisplay())); + sprintf(displaystring + strlen(displaystring) - 1, "%d", + screen->getScreenNumber()); #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Executing:"<<key->getExecCommand().c_str()<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): Executing:"<<key->getExecCommand().c_str()<<endl; #endif // DEBUG - bexec(key->getExecCommand().c_str(), displaystring); - #else - spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL); - #endif // !__EMX__ + bexec(key->getExecCommand().c_str(), displaystring); +#else + spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL); +#endif // !__EMX__ - } - break; - case Keys::ROOTMENU: //show root menu - { - ScreenList::iterator it = screenList.begin(); - ScreenList::iterator it_end = screenList.end(); + } + break; + case Keys::ROOTMENU: //show root menu + { + ScreenList::iterator it = screenList.begin(); + ScreenList::iterator it_end = screenList.end(); - for (; it != it_end; ++it) { + for (; it != it_end; ++it) { - BScreen *screen = (*it); - if (ke.window != screen->getRootWindow()) - continue; + BScreen *screen = (*it); + if (ke.window != screen->getRootWindow()) + continue; - //calculate placement of workspace menu - //and show/hide it - int mx = ke.x_root - - (screen->getRootmenu()->width() / 2); - int my = ke.y_root - - (screen->getRootmenu()->titleHeight() / 2); + //calculate placement of workspace menu + //and show/hide it + int mx = ke.x_root - + (screen->getRootmenu()->width() / 2); + int my = ke.y_root - + (screen->getRootmenu()->titleHeight() / 2); - if (mx < 0) mx = 0; - if (my < 0) my = 0; + if (mx < 0) mx = 0; + if (my < 0) my = 0; - if (mx + screen->getRootmenu()->width() > screen->getWidth()) { - mx = screen->getWidth() - - screen->getRootmenu()->width() - - screen->getBorderWidth(); - } + if (mx + screen->getRootmenu()->width() > screen->getWidth()) { + mx = screen->getWidth() - + screen->getRootmenu()->width() - + screen->getBorderWidth(); + } - if (my + screen->getRootmenu()->height() > - screen->getHeight()) { - my = screen->getHeight() - - screen->getRootmenu()->height() - - screen->getBorderWidth(); - } - screen->getRootmenu()->move(mx, my); + if (my + screen->getRootmenu()->height() > + screen->getHeight()) { + my = screen->getHeight() - + screen->getRootmenu()->height() - + screen->getBorderWidth(); + } + screen->getRootmenu()->move(mx, my); - if (! screen->getRootmenu()->isVisible()) { - checkMenu(); - screen->getRootmenu()->show(); - } - } - } - break; - default: //try to see if its a window action - doWindowAction(action, key->getParam()); - } - } + if (! screen->getRootmenu()->isVisible()) { + checkMenu(); + screen->getRootmenu()->show(); + } + } + } + break; + default: //try to see if its a window action + doWindowAction(action, key->getParam()); + } + } break; - } + } - default: + default: break; - } + } } void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) { - if (!focused_window) - return; + if (!focused_window) + return; - unsigned int t_placement = focused_window->getScreen()->getTabPlacement(); - unsigned int t_alignment = focused_window->getScreen()->getTabAlignment(); + unsigned int t_placement = focused_window->getScreen()->getTabPlacement(); + unsigned int t_alignment = focused_window->getScreen()->getTabAlignment(); - switch (action) { - case Keys::ICONIFY: - focused_window->iconify(); - break; - case Keys::RAISE: - if (focused_window->hasTab()) - focused_window->getTab()->raise(); //raise the tabs if we have any - focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->raiseWindow(focused_window); - break; - case Keys::LOWER: - focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->lowerWindow(focused_window); - if (focused_window->hasTab()) - focused_window->getTab()->lower(); //lower the tabs AND it's windows + switch (action) { + case Keys::ICONIFY: + focused_window->iconify(); + break; + case Keys::RAISE: + if (focused_window->hasTab()) + focused_window->getTab()->raise(); //raise the tabs if we have any + focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->raiseWindow(focused_window); + break; + case Keys::LOWER: + focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->lowerWindow(focused_window); + if (focused_window->hasTab()) + focused_window->getTab()->lower(); //lower the tabs AND it's windows - break; - case Keys::CLOSE: - focused_window->close(); - break; - case Keys::SHADE: - focused_window->shade(); // this has to be done in THIS order - if (focused_window->hasTab()) - focused_window->getTab()->shade(); - break; - case Keys::MAXIMIZE: - focused_window->maximize(0); - break; - case Keys::STICK: - focused_window->stick(); - break; - case Keys::VERTMAX: - if (focused_window->isResizable()) - focused_window->maximize(2); // maximize vertically, done with mouse2 - break; - case Keys::HORIZMAX: - if (focused_window->isResizable()) - focused_window->maximize(3); // maximize horisontally, done with mouse3 - break; - case Keys::NUDGERIGHT: - focused_window->configure( - focused_window->getXFrame()+param, focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::NUDGELEFT: - focused_window->configure( - focused_window->getXFrame()-param, focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::NUDGEUP: - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame()-param, - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::NUDGEDOWN: - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame()+param, - focused_window->getWidth(), focused_window->getHeight()); - break; - // NOTE !!! BIGNUDGExxxx is not needed, just use 10 as a parameter - case Keys::BIGNUDGERIGHT: - focused_window->configure( - focused_window->getXFrame()+10, focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::BIGNUDGELEFT: - focused_window->configure( - focused_window->getXFrame()-10, focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::BIGNUDGEUP: - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame()-10, - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::BIGNUDGEDOWN: - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame()+10, - focused_window->getWidth(), focused_window->getHeight()); - break; - case Keys::HORIZINC: - if (focused_window->isResizable()) - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame(), - focused_window->getWidth()+10, focused_window->getHeight()); + break; + case Keys::CLOSE: + focused_window->close(); + break; + case Keys::SHADE: + focused_window->shade(); // this has to be done in THIS order + if (focused_window->hasTab()) + focused_window->getTab()->shade(); + break; + case Keys::MAXIMIZE: + focused_window->maximize(0); + break; + case Keys::STICK: + focused_window->stick(); + break; + case Keys::VERTMAX: + if (focused_window->isResizable()) + focused_window->maximize(2); // maximize vertically, done with mouse2 + break; + case Keys::HORIZMAX: + if (focused_window->isResizable()) + focused_window->maximize(3); // maximize horisontally, done with mouse3 + break; + case Keys::NUDGERIGHT: + focused_window->configure( + focused_window->getXFrame()+param, focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::NUDGELEFT: + focused_window->configure( + focused_window->getXFrame()-param, focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::NUDGEUP: + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame()-param, + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::NUDGEDOWN: + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame()+param, + focused_window->getWidth(), focused_window->getHeight()); + break; + // NOTE !!! BIGNUDGExxxx is not needed, just use 10 as a parameter + case Keys::BIGNUDGERIGHT: + focused_window->configure( + focused_window->getXFrame()+10, focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::BIGNUDGELEFT: + focused_window->configure( + focused_window->getXFrame()-10, focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::BIGNUDGEUP: + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame()-10, + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::BIGNUDGEDOWN: + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame()+10, + focused_window->getWidth(), focused_window->getHeight()); + break; + case Keys::HORIZINC: + if (focused_window->isResizable()) + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame(), + focused_window->getWidth()+10, focused_window->getHeight()); - if (focused_window->hasTab() && - (t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) { - if (t_alignment == Tab::ARELATIVE) - focused_window->getTab()->calcIncrease(); - if (t_alignment != Tab::PLEFT) - focused_window->getTab()->setPosition(); - } - break; - case Keys::VERTINC: - if (focused_window->isResizable()) - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()+10); + if (focused_window->hasTab() && + (t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) { + if (t_alignment == Tab::ARELATIVE) + focused_window->getTab()->calcIncrease(); + if (t_alignment != Tab::PLEFT) + focused_window->getTab()->setPosition(); + } + break; + case Keys::VERTINC: + if (focused_window->isResizable()) + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()+10); - if (focused_window->hasTab() && - (t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) { - if (t_alignment == Tab::ARELATIVE) - focused_window->getTab()->calcIncrease(); - if (t_alignment != Tab::PRIGHT) - focused_window->getTab()->setPosition(); - } - break; - case Keys::HORIZDEC: - if (focused_window->isResizable()) - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame(), - focused_window->getWidth()-10, focused_window->getHeight()); + if (focused_window->hasTab() && + (t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) { + if (t_alignment == Tab::ARELATIVE) + focused_window->getTab()->calcIncrease(); + if (t_alignment != Tab::PRIGHT) + focused_window->getTab()->setPosition(); + } + break; + case Keys::HORIZDEC: + if (focused_window->isResizable()) + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame(), + focused_window->getWidth()-10, focused_window->getHeight()); - if (focused_window->hasTab() && - (t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) { - if (t_alignment == Tab::ARELATIVE) - focused_window->getTab()->calcIncrease(); - if (t_alignment != Tab::PLEFT) - focused_window->getTab()->setPosition(); - } - break; - case Keys::VERTDEC: - if (focused_window->isResizable()) - focused_window->configure( - focused_window->getXFrame(), focused_window->getYFrame(), - focused_window->getWidth(), focused_window->getHeight()-10); + if (focused_window->hasTab() && + (t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) { + if (t_alignment == Tab::ARELATIVE) + focused_window->getTab()->calcIncrease(); + if (t_alignment != Tab::PLEFT) + focused_window->getTab()->setPosition(); + } + break; + case Keys::VERTDEC: + if (focused_window->isResizable()) + focused_window->configure( + focused_window->getXFrame(), focused_window->getYFrame(), + focused_window->getWidth(), focused_window->getHeight()-10); - if (focused_window->hasTab() && - (t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) { - if (t_alignment == Tab::ARELATIVE) - focused_window->getTab()->calcIncrease(); - if (t_alignment != Tab::PRIGHT) - focused_window->getTab()->setPosition(); - } - break; - case Keys::TOGGLEDECOR: - focused_window->toggleDecoration(); - break; - case Keys::TOGGLETAB: - focused_window->setTab(!focused_window->hasTab()); - break; - default: //do nothing - break; - } + if (focused_window->hasTab() && + (t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) { + if (t_alignment == Tab::ARELATIVE) + focused_window->getTab()->calcIncrease(); + if (t_alignment != Tab::PRIGHT) + focused_window->getTab()->setPosition(); + } + break; + case Keys::TOGGLEDECOR: + focused_window->toggleDecoration(); + break; + case Keys::TOGGLETAB: + focused_window->setTab(!focused_window->hasTab()); + break; + default: //do nothing + break; + } } // handle system signals here void Fluxbox::handleSignal(int signum) { - I18n *i18n = I18n::instance(); - static int re_enter = 0; + I18n *i18n = I18n::instance(); + static int re_enter = 0; - switch (signum) { - case SIGCHLD: // we don't want the child process to kill us - waitpid(-1, 0, WNOHANG | WUNTRACED); - break; - case SIGHUP: - load_rc(); - break; - case SIGUSR1: - reload_rc(); - break; - case SIGUSR2: - rereadMenu(); - break; - case SIGSEGV: - abort(); - break; - case SIGFPE: - case SIGINT: - case SIGTERM: - shutdown(); - break; - default: - fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught, - "%s: signal %d caught\n"), - getApplicationName(), signum); + switch (signum) { + case SIGCHLD: // we don't want the child process to kill us + waitpid(-1, 0, WNOHANG | WUNTRACED); + break; + case SIGHUP: + load_rc(); + break; + case SIGUSR1: + reload_rc(); + break; + case SIGUSR2: + rereadMenu(); + break; + case SIGSEGV: + abort(); + break; + case SIGFPE: + case SIGINT: + case SIGTERM: + shutdown(); + break; + default: + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught, + "%s: signal %d caught\n"), + getApplicationName(), signum); - if (! isStartup() && ! re_enter) { - re_enter = 1; - fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown, - "shutting down\n")); - shutdown(); - } + if (! isStartup() && ! re_enter) { + re_enter = 1; + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown, + "shutting down\n")); + shutdown(); + } - fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting, - "aborting... dumping core\n")); - abort(); - break; - } + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting, + "aborting... dumping core\n")); + abort(); + break; + } } void Fluxbox::update(FbTk::Subject *changedsub) { //TODO: fix signaling, this does not look good - if (typeid(*changedsub) == typeid(FluxboxWindow)) { - FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); - FluxboxWindow &win = winsub->win(); - if ((&(win.hintSig())) == changedsub) { // hint signal + if (typeid(*changedsub) == typeid(FluxboxWindow)) { + FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub); + FluxboxWindow &win = winsub->win(); + if ((&(win.hintSig())) == changedsub) { // hint signal #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<") WINDOW hint signal from "<<&win<<endl; + cerr<<__FILE__<<"("<<__LINE__<<") WINDOW hint signal from "<<&win<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateHints(win); - } - } else if ((&(win.stateSig())) == changedsub) { // state signal + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateHints(win); + } + } else if ((&(win.stateSig())) == changedsub) { // state signal #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<") WINDOW state signal from "<<&win<<endl; + cerr<<__FILE__<<"("<<__LINE__<<") WINDOW state signal from "<<&win<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateState(win); - } - } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateState(win); + } + } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl; + cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateWorkspace(win); - } - } else { + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateWorkspace(win); + } + } else { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): WINDOW uncought signal from "<<&win<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): WINDOW uncought signal from "<<&win<<endl; #endif // DEBUG - } + } - } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { - BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); - BScreen &screen = subj->screen(); - if ((&(screen.workspaceCountSig())) == changedsub) { + } else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) { + BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub); + BScreen &screen = subj->screen(); + if ((&(screen.workspaceCountSig())) == changedsub) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace count signal"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace count signal"<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateWorkspaceCount(screen); - } - } else if ((&(screen.workspaceNamesSig())) == changedsub) { + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateWorkspaceCount(screen); + } + } else if ((&(screen.workspaceNamesSig())) == changedsub) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace names signal"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace names signal"<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateWorkspaceNames(screen); - } - } else if ((&(screen.currentWorkspaceSig())) == changedsub) { + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateWorkspaceNames(screen); + } + } else if ((&(screen.currentWorkspaceSig())) == changedsub) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN current workspace signal"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN current workspace signal"<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateCurrentWorkspace(screen); - } - } else if ((&(screen.clientListSig())) == changedsub) { + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateCurrentWorkspace(screen); + } + } else if ((&(screen.clientListSig())) == changedsub) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN client list signal"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN client list signal"<<endl; #endif // DEBUG - for (size_t i=0; i<m_atomhandler.size(); ++i) { - if (m_atomhandler[i]->update()) - m_atomhandler[i]->updateClientList(screen); - } - } - } + for (size_t i=0; i<m_atomhandler.size(); ++i) { + if (m_atomhandler[i]->update()) + m_atomhandler[i]->updateClientList(screen); + } + } + } } void Fluxbox::attachSignals(FluxboxWindow &win) { - win.hintSig().attach(this); - win.stateSig().attach(this); - win.workspaceSig().attach(this); - for (size_t i=0; i<m_atomhandler.size(); ++i) { - m_atomhandler[i]->setupWindow(win); - } + win.hintSig().attach(this); + win.stateSig().attach(this); + win.workspaceSig().attach(this); + for (size_t i=0; i<m_atomhandler.size(); ++i) { + m_atomhandler[i]->setupWindow(win); + } } BScreen *Fluxbox::searchScreen(Window window) { - BScreen *screen = (BScreen *) 0; - ScreenList::iterator it = screenList.begin(); - ScreenList::iterator it_end = screenList.end(); + BScreen *screen = (BScreen *) 0; + ScreenList::iterator it = screenList.begin(); + ScreenList::iterator it_end = screenList.end(); - for (; it != it_end; ++it) { - if (*it) { - if ((*it)->getRootWindow() == window) { - screen = (*it); - return screen; - } - } - } + for (; it != it_end; ++it) { + if (*it) { + if ((*it)->getRootWindow() == window) { + screen = (*it); + return screen; + } + } + } - return (BScreen *) 0; + return (BScreen *) 0; } FluxboxWindow *Fluxbox::searchWindow(Window window) { - std::map<Window, FluxboxWindow *>::iterator it = windowSearch.find(window); - return it == windowSearch.end() ? 0 : it->second; + std::map<Window, FluxboxWindow *>::iterator it = windowSearch.find(window); + return it == windowSearch.end() ? 0 : it->second; } FluxboxWindow *Fluxbox::searchGroup(Window window, FluxboxWindow *win) { - std::map<Window, FluxboxWindow *>::iterator it = groupSearch.find(window); - return it == groupSearch.end() ? 0 : it->second; + std::map<Window, FluxboxWindow *>::iterator it = groupSearch.find(window); + return it == groupSearch.end() ? 0 : it->second; } Basemenu *Fluxbox::searchMenu(Window window) { - std::map<Window, Basemenu *>::iterator it = menuSearch.find(window); - return it == menuSearch.end() ? 0 : it->second; + std::map<Window, Basemenu *>::iterator it = menuSearch.find(window); + return it == menuSearch.end() ? 0 : it->second; } Toolbar *Fluxbox::searchToolbar(Window window) { - std::map<Window, Toolbar *>::iterator it = toolbarSearch.find(window); - return it == toolbarSearch.end() ? 0 : it->second; + std::map<Window, Toolbar *>::iterator it = toolbarSearch.find(window); + return it == toolbarSearch.end() ? 0 : it->second; } Tab *Fluxbox::searchTab(Window window) { - std::map<Window, Tab *>::iterator it = tabSearch.find(window); - return it == tabSearch.end() ? 0 : it->second; + std::map<Window, Tab *>::iterator it = tabSearch.find(window); + return it == tabSearch.end() ? 0 : it->second; } #ifdef SLIT Slit *Fluxbox::searchSlit(Window window) { - std::map<Window, Slit *>::iterator it = slitSearch.find(window); - return it == slitSearch.end() ? 0 : it->second; + std::map<Window, Slit *>::iterator it = slitSearch.find(window); + return it == slitSearch.end() ? 0 : it->second; } #endif // SLIT void Fluxbox::saveWindowSearch(Window window, FluxboxWindow *data) { - windowSearch[window] = data; + windowSearch[window] = data; } void Fluxbox::saveGroupSearch(Window window, FluxboxWindow *data) { - groupSearch[window] = data; + groupSearch[window] = data; } void Fluxbox::saveMenuSearch(Window window, Basemenu *data) { - menuSearch[window] = data; + menuSearch[window] = data; } void Fluxbox::saveToolbarSearch(Window window, Toolbar *data) { - toolbarSearch[window] = data; + toolbarSearch[window] = data; } void Fluxbox::saveTabSearch(Window window, Tab *data) { - tabSearch[window] = data; + tabSearch[window] = data; } #ifdef SLIT void Fluxbox::saveSlitSearch(Window window, Slit *data) { - slitSearch[window] = data; + slitSearch[window] = data; } #endif // SLIT void Fluxbox::removeWindowSearch(Window window) { - windowSearch.erase(window); + windowSearch.erase(window); } void Fluxbox::removeGroupSearch(Window window) { - groupSearch.erase(window); + groupSearch.erase(window); } void Fluxbox::removeMenuSearch(Window window) { - menuSearch.erase(window); + menuSearch.erase(window); } void Fluxbox::removeToolbarSearch(Window window) { - toolbarSearch.erase(window); + toolbarSearch.erase(window); } void Fluxbox::removeTabSearch(Window window) { - tabSearch.erase(window); + tabSearch.erase(window); } #ifdef SLIT void Fluxbox::removeSlitSearch(Window window) { - slitSearch.erase(window); + slitSearch.erase(window); } #endif // SLIT void Fluxbox::restart(const char *prog) { - shutdown(); + shutdown(); - if (prog) { - execlp(prog, prog, NULL); - perror(prog); - } + if (prog) { + execlp(prog, prog, NULL); + perror(prog); + } - // fall back in case the above execlp doesn't work - execvp(argv[0], argv); - execvp(basename(argv[0]), argv); + // fall back in case the above execlp doesn't work + execvp(argv[0], argv); + execvp(basename(argv[0]), argv); } void Fluxbox::shutdown() { - BaseDisplay::shutdown(); + BaseDisplay::shutdown(); - XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime); + XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime); - //send shutdown to all screens - ScreenList::iterator it = screenList.begin(); - ScreenList::iterator it_end = screenList.end(); - for (; it != it_end; ++it) { - if(*it) - (*it)->shutdown(); - } + //send shutdown to all screens + ScreenList::iterator it = screenList.begin(); + ScreenList::iterator it_end = screenList.end(); + for (; it != it_end; ++it) { + if(*it) + (*it)->shutdown(); + } - XSync(getXDisplay(), False); + XSync(getXDisplay(), False); }

@@ -1844,167 +1844,167 @@ //saves resources

//---------------------- void Fluxbox::save_rc() { - XrmDatabase new_blackboxrc = 0; + XrmDatabase new_blackboxrc = 0; - char rc_string[1024]; + char rc_string[1024]; - string dbfile(getRcFilename()); + string dbfile(getRcFilename()); - if (dbfile.size() != 0) { - m_resourcemanager.save(dbfile.c_str(), dbfile.c_str()); - m_screen_rm.save(dbfile.c_str(), dbfile.c_str()); - } else - cerr<<"database filename is invalid!"<<endl; + if (dbfile.size() != 0) { + m_resourcemanager.save(dbfile.c_str(), dbfile.c_str()); + m_screen_rm.save(dbfile.c_str(), dbfile.c_str()); + } else + cerr<<"database filename is invalid!"<<endl; - sprintf(rc_string, "session.doubleClickInterval: %lu", - resource.double_click_interval); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.doubleClickInterval: %lu", + resource.double_click_interval); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.autoRaiseDelay: %lu", - ((resource.auto_raise_delay.tv_sec * 1000) + - (resource.auto_raise_delay.tv_usec / 1000))); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.autoRaiseDelay: %lu", + ((resource.auto_raise_delay.tv_sec * 1000) + + (resource.auto_raise_delay.tv_usec / 1000))); + XrmPutLineResource(&new_blackboxrc, rc_string); - ScreenList::iterator it = screenList.begin(); - ScreenList::iterator it_end = screenList.end(); + ScreenList::iterator it = screenList.begin(); + ScreenList::iterator it_end = screenList.end(); - //Save screen resources + //Save screen resources - for (; it != it_end; ++it) { - BScreen *screen = *it; - int screen_number = screen->getScreenNumber(); + for (; it != it_end; ++it) { + BScreen *screen = *it; + int screen_number = screen->getScreenNumber(); - #ifdef SLIT - string slit_placement; +#ifdef SLIT + string slit_placement; - switch (screen->getSlitPlacement()) { - case Slit::TOPLEFT: slit_placement = "TopLeft"; break; - case Slit::CENTERLEFT: slit_placement = "CenterLeft"; break; - case Slit::BOTTOMLEFT: slit_placement = "BottomLeft"; break; - case Slit::TOPCENTER: slit_placement = "TopCenter"; break; - case Slit::BOTTOMCENTER: slit_placement = "BottomCenter"; break; - case Slit::TOPRIGHT: slit_placement = "TopRight"; break; - case Slit::BOTTOMRIGHT: slit_placement = "BottomRight"; break; - case Slit::CENTERRIGHT: default: slit_placement = "CenterRight"; break; - } + switch (screen->getSlitPlacement()) { + case Slit::TOPLEFT: slit_placement = "TopLeft"; break; + case Slit::CENTERLEFT: slit_placement = "CenterLeft"; break; + case Slit::BOTTOMLEFT: slit_placement = "BottomLeft"; break; + case Slit::TOPCENTER: slit_placement = "TopCenter"; break; + case Slit::BOTTOMCENTER: slit_placement = "BottomCenter"; break; + case Slit::TOPRIGHT: slit_placement = "TopRight"; break; + case Slit::BOTTOMRIGHT: slit_placement = "BottomRight"; break; + case Slit::CENTERRIGHT: default: slit_placement = "CenterRight"; break; + } - sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number, - slit_placement.c_str()); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number, + slit_placement.c_str()); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number, - ((screen->getSlitDirection() == Slit::HORIZONTAL) ? "Horizontal" : - "Vertical")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number, + ((screen->getSlitDirection() == Slit::HORIZONTAL) ? "Horizontal" : + "Vertical")); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number, - ((screen->getSlit()->isOnTop()) ? "True" : "False")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number, + ((screen->getSlit()->isOnTop()) ? "True" : "False")); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number, - ((screen->getSlit()->doAutoHide()) ? "True" : "False")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number, + ((screen->getSlit()->doAutoHide()) ? "True" : "False")); + XrmPutLineResource(&new_blackboxrc, rc_string); - #ifdef XINERAMA - sprintf(rc_string, "session.screen%d.slit.onHead: %d", screen_number, - screen->getSlitOnHead()); - XrmPutLineResource(&new_blackboxrc, rc_string); - #endif // XINERAMA +#ifdef XINERAMA + sprintf(rc_string, "session.screen%d.slit.onHead: %d", screen_number, + screen->getSlitOnHead()); + XrmPutLineResource(&new_blackboxrc, rc_string); +#endif // XINERAMA - #endif // SLIT +#endif // SLIT - sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number, - ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ? - "LeftToRight" : "RightToLeft")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number, + ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ? + "LeftToRight" : "RightToLeft")); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.colPlacementDirection: %s", screen_number, - ((screen->getColPlacementDirection() == BScreen::TOPBOTTOM) ? - "TopToBottom" : "BottomToTop")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.colPlacementDirection: %s", screen_number, + ((screen->getColPlacementDirection() == BScreen::TOPBOTTOM) ? + "TopToBottom" : "BottomToTop")); + XrmPutLineResource(&new_blackboxrc, rc_string); - string placement; + string placement; - switch (screen->getPlacementPolicy()) { - case BScreen::CASCADEPLACEMENT: - placement = "CascadePlacement"; - break; + switch (screen->getPlacementPolicy()) { + case BScreen::CASCADEPLACEMENT: + placement = "CascadePlacement"; + break; - case BScreen::COLSMARTPLACEMENT: - placement = "ColSmartPlacement"; - break; + case BScreen::COLSMARTPLACEMENT: + placement = "ColSmartPlacement"; + break; - default: - case BScreen::ROWSMARTPLACEMENT: - placement = "RowSmartPlacement"; - break; - } + default: + case BScreen::ROWSMARTPLACEMENT: + placement = "RowSmartPlacement"; + break; + } - sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number, - placement.c_str()); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number, + placement.c_str()); + XrmPutLineResource(&new_blackboxrc, rc_string); - std::string focus_mode; - if (screen->isSloppyFocus() && screen->doAutoRaise()) - focus_mode = "AutoRaiseSloppyFocus"; - else if (screen->isSloppyFocus()) - focus_mode = "SloppyFocus"; - else if (screen->isSemiSloppyFocus() && screen->doAutoRaise()) - focus_mode = "AutoRaiseSemiSloppyFocus"; - else if (screen->isSemiSloppyFocus()) - focus_mode = "SemiSloppyFocus"; - else - focus_mode = "ClickToFocus"; + std::string focus_mode; + if (screen->isSloppyFocus() && screen->doAutoRaise()) + focus_mode = "AutoRaiseSloppyFocus"; + else if (screen->isSloppyFocus()) + focus_mode = "SloppyFocus"; + else if (screen->isSemiSloppyFocus() && screen->doAutoRaise()) + focus_mode = "AutoRaiseSemiSloppyFocus"; + else if (screen->isSemiSloppyFocus()) + focus_mode = "SemiSloppyFocus"; + else + focus_mode = "ClickToFocus"; - sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number, - focus_mode.c_str()); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number, + focus_mode.c_str()); + XrmPutLineResource(&new_blackboxrc, rc_string); // load_rc(screen); - // these are static, but may not be saved in the users resource file, - // writing these resources will allow the user to edit them at a later - // time... but loading the defaults before saving allows us to rewrite the - // users changes... + // these are static, but may not be saved in the users resource file, + // writing these resources will allow the user to edit them at a later + // time... but loading the defaults before saving allows us to rewrite the + // users changes... #ifdef HAVE_STRFTIME - sprintf(rc_string, "session.screen%d.strftimeFormat: %s", screen_number, - screen->getStrftimeFormat()); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.strftimeFormat: %s", screen_number, + screen->getStrftimeFormat()); + XrmPutLineResource(&new_blackboxrc, rc_string); #else // !HAVE_STRFTIME - sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number, - ((screen->getDateFormat() == B_EuropeanDate) ? - "European" : "American")); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number, + ((screen->getDateFormat() == B_EuropeanDate) ? + "European" : "American")); + XrmPutLineResource(&new_blackboxrc, rc_string); - sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number, - ((screen->isClock24Hour()) ? 24 : 12)); - XrmPutLineResource(&new_blackboxrc, rc_string); + sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number, + ((screen->isClock24Hour()) ? 24 : 12)); + XrmPutLineResource(&new_blackboxrc, rc_string); #endif // HAVE_STRFTIME - // write out the users workspace names - sprintf(rc_string, "session.screen%d.workspaceNames: ", screen_number); - string workspaces_string(rc_string); + // write out the users workspace names + sprintf(rc_string, "session.screen%d.workspaceNames: ", screen_number); + string workspaces_string(rc_string); - for (unsigned int workspace=0; workspace < screen->getCount(); workspace++) { - if (screen->getWorkspace(workspace)->name().size()!=0) - workspaces_string.append(screen->getWorkspace(workspace)->name()); - else - workspaces_string.append("Null"); - workspaces_string.append(","); - } + for (unsigned int workspace=0; workspace < screen->getCount(); workspace++) { + if (screen->getWorkspace(workspace)->name().size()!=0) + workspaces_string.append(screen->getWorkspace(workspace)->name()); + else + workspaces_string.append("Null"); + workspaces_string.append(","); + } - XrmPutLineResource(&new_blackboxrc, workspaces_string.c_str()); + XrmPutLineResource(&new_blackboxrc, workspaces_string.c_str()); - } + } - XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str()); + XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str()); - XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together - XrmPutFileDatabase(old_blackboxrc, dbfile.c_str()); - XrmDestroyDatabase(old_blackboxrc); + XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together + XrmPutFileDatabase(old_blackboxrc, dbfile.c_str()); + XrmDestroyDatabase(old_blackboxrc); #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; #endif // DEBUG }

@@ -2013,423 +2013,423 @@ // Returns filename of resource file

//------------------------------------ string Fluxbox::getRcFilename() { - if (rc_file.size() == 0) { // set default filename - string defaultfile(getenv("HOME")+string("/.")+RC_PATH+string("/")+RC_INIT_FILE); - return defaultfile; - } + if (rc_file.size() == 0) { // set default filename + string defaultfile(getenv("HOME")+string("/.")+RC_PATH+string("/")+RC_INIT_FILE); + return defaultfile; + } - return rc_file; + return rc_file; } //-------- getDefaultDataFilename ------------- // Provides default filename of data file //--------------------------------------------- void Fluxbox::getDefaultDataFilename(char *name, string &filename) { - filename = string(getenv("HOME")+string("/.")+RC_PATH+string("/")+name); + filename = string(getenv("HOME")+string("/.")+RC_PATH+string("/")+name); } void Fluxbox::load_rc() { - XrmDatabaseHelper database; + XrmDatabaseHelper database; - //get resource filename - string dbfile(getRcFilename()); + //get resource filename + string dbfile(getRcFilename()); - if (dbfile.size() != 0) { - if (!m_resourcemanager.load(dbfile.c_str())) { - cerr<<"Faild to load database:"<<dbfile<<endl; - cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; - if (!m_resourcemanager.load(DEFAULT_INITFILE)) - cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; - } - } else { - if (!m_resourcemanager.load(DEFAULT_INITFILE)) - cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; - } + if (dbfile.size() != 0) { + if (!m_resourcemanager.load(dbfile.c_str())) { + cerr<<"Faild to load database:"<<dbfile<<endl; + cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; + if (!m_resourcemanager.load(DEFAULT_INITFILE)) + cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; + } + } else { + if (!m_resourcemanager.load(DEFAULT_INITFILE)) + cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; + } - XrmValue value; - char *value_type; + XrmValue value; + char *value_type; - if (m_rc_menufile->size()) { - *m_rc_menufile = StringUtil::expandFilename(*m_rc_menufile); - if (!m_rc_menufile->size()) - m_rc_menufile.setDefaultValue(); - } else - m_rc_menufile.setDefaultValue(); + if (m_rc_menufile->size()) { + *m_rc_menufile = StringUtil::expandFilename(*m_rc_menufile); + if (!m_rc_menufile->size()) + m_rc_menufile.setDefaultValue(); + } else + m_rc_menufile.setDefaultValue(); - if (m_rc_slitlistfile->size() != 0) { - *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile); - } else { - string filename; - getDefaultDataFilename("slitlist", filename); - m_rc_slitlistfile.setFromString(filename.c_str()); - } + if (m_rc_slitlistfile->size() != 0) { + *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile); + } else { + string filename; + getDefaultDataFilename("slitlist", filename); + m_rc_slitlistfile.setFromString(filename.c_str()); + } - if (*m_rc_colors_per_channel < 2) - *m_rc_colors_per_channel = 2; - else if (*m_rc_colors_per_channel > 6) - *m_rc_colors_per_channel = 6; + if (*m_rc_colors_per_channel < 2) + *m_rc_colors_per_channel = 2; + else if (*m_rc_colors_per_channel > 6) + *m_rc_colors_per_channel = 6; - if (m_rc_stylefile->size() == 0) - *m_rc_stylefile = DEFAULTSTYLE; - else // expand tilde - *m_rc_stylefile = StringUtil::expandFilename(*m_rc_stylefile); + if (m_rc_stylefile->size() == 0) + *m_rc_stylefile = DEFAULTSTYLE; + else // expand tilde + *m_rc_stylefile = StringUtil::expandFilename(*m_rc_stylefile); - //load file - database = XrmGetFileDatabase(dbfile.c_str()); - if (database==0) { - cerr<<"Fluxbox: Cant open "<<dbfile<<" !"<<endl; - cerr<<"Using: "<<DEFAULT_INITFILE<<endl; - database = XrmGetFileDatabase(DEFAULT_INITFILE); - } + //load file + database = XrmGetFileDatabase(dbfile.c_str()); + if (database==0) { + cerr<<"Fluxbox: Cant open "<<dbfile<<" !"<<endl; + cerr<<"Using: "<<DEFAULT_INITFILE<<endl; + database = XrmGetFileDatabase(DEFAULT_INITFILE); + } - if (XrmGetResource(*database, "session.doubleClickInterval", - "Session.DoubleClickInterval", &value_type, &value)) { - if (sscanf(value.addr, "%lu", &resource.double_click_interval) != 1) - resource.double_click_interval = 250; - } else - resource.double_click_interval = 250; + if (XrmGetResource(*database, "session.doubleClickInterval", + "Session.DoubleClickInterval", &value_type, &value)) { + if (sscanf(value.addr, "%lu", &resource.double_click_interval) != 1) + resource.double_click_interval = 250; + } else + resource.double_click_interval = 250; - if (XrmGetResource(*database, "session.autoRaiseDelay", "Session.AutoRaiseDelay", - &value_type, &value)) { - if (sscanf(value.addr, "%lu", &resource.auto_raise_delay.tv_usec) != 1) - resource.auto_raise_delay.tv_usec = 250; - } else - resource.auto_raise_delay.tv_usec = 250; + if (XrmGetResource(*database, "session.autoRaiseDelay", "Session.AutoRaiseDelay", + &value_type, &value)) { + if (sscanf(value.addr, "%lu", &resource.auto_raise_delay.tv_usec) != 1) + resource.auto_raise_delay.tv_usec = 250; + } else + resource.auto_raise_delay.tv_usec = 250; - resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000; - resource.auto_raise_delay.tv_usec -= - (resource.auto_raise_delay.tv_sec * 1000); - resource.auto_raise_delay.tv_usec *= 1000; + resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000; + resource.auto_raise_delay.tv_usec -= + (resource.auto_raise_delay.tv_sec * 1000); + resource.auto_raise_delay.tv_usec *= 1000; - // expand tilde - *m_rc_groupfile = StringUtil::expandFilename(*m_rc_groupfile); + // expand tilde + *m_rc_groupfile = StringUtil::expandFilename(*m_rc_groupfile); #ifdef DEBUG - cerr<<__FILE__<<": Loading groups ("<<*m_rc_groupfile<<")"<<endl; + cerr<<__FILE__<<": Loading groups ("<<*m_rc_groupfile<<")"<<endl; #endif // DEBUG - if (!Workspace::loadGroups(*m_rc_groupfile)) { - cerr<<"Faild to load groupfile: "<<*m_rc_groupfile<<endl; - } + if (!Workspace::loadGroups(*m_rc_groupfile)) { + cerr<<"Faild to load groupfile: "<<*m_rc_groupfile<<endl; + } } void Fluxbox::load_rc(BScreen *screen) { - //get resource filename - string dbfile(getRcFilename()); - if (dbfile.size() != 0) { - if (!m_screen_rm.load(dbfile.c_str())) { - cerr<<"Faild to load database:"<<dbfile<<endl; - cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; - if (!m_screen_rm.load(DEFAULT_INITFILE)) - cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; - } - } else { - if (!m_screen_rm.load(DEFAULT_INITFILE)) - cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; - } + //get resource filename + string dbfile(getRcFilename()); + if (dbfile.size() != 0) { + if (!m_screen_rm.load(dbfile.c_str())) { + cerr<<"Faild to load database:"<<dbfile<<endl; + cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; + if (!m_screen_rm.load(DEFAULT_INITFILE)) + cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; + } + } else { + if (!m_screen_rm.load(DEFAULT_INITFILE)) + cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl; + } - XrmDatabaseHelper database; + XrmDatabaseHelper database; - database = XrmGetFileDatabase(dbfile.c_str()); - if (database==0) - database = XrmGetFileDatabase(DEFAULT_INITFILE); + database = XrmGetFileDatabase(dbfile.c_str()); + if (database==0) + database = XrmGetFileDatabase(DEFAULT_INITFILE); - XrmValue value; - char *value_type, name_lookup[1024], class_lookup[1024]; - int screen_number = screen->getScreenNumber(); + XrmValue value; + char *value_type, name_lookup[1024], class_lookup[1024]; + int screen_number = screen->getScreenNumber(); - sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); - sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "righttoleft", value.size)) - screen->saveRowPlacementDirection(BScreen::RIGHTLEFT); - else - screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); - } else - screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); + sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number); + sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "righttoleft", value.size)) + screen->saveRowPlacementDirection(BScreen::RIGHTLEFT); + else + screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); + } else + screen->saveRowPlacementDirection(BScreen::LEFTRIGHT); - sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number); - sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "bottomtotop", value.size)) - screen->saveColPlacementDirection(BScreen::BOTTOMTOP); - else - screen->saveColPlacementDirection(BScreen::TOPBOTTOM); - } else - screen->saveColPlacementDirection(BScreen::TOPBOTTOM); + sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number); + sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "bottomtotop", value.size)) + screen->saveColPlacementDirection(BScreen::BOTTOMTOP); + else + screen->saveColPlacementDirection(BScreen::TOPBOTTOM); + } else + screen->saveColPlacementDirection(BScreen::TOPBOTTOM); - screen->removeWorkspaceNames(); + screen->removeWorkspaceNames(); - sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); - sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { + sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number); + sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { #ifdef DEBUG - cerr<<__FILE__<<"("<<__LINE__<<"): Workspaces="<<screen->getNumberOfWorkspaces()<<endl; + cerr<<__FILE__<<"("<<__LINE__<<"): Workspaces="<<screen->getNumberOfWorkspaces()<<endl; #endif // DEBUG - char *search = StringUtil::strdup(value.addr); + char *search = StringUtil::strdup(value.addr); - int i; - for (i = 0; i < screen->getNumberOfWorkspaces(); i++) { - char *nn; + int i; + for (i = 0; i < screen->getNumberOfWorkspaces(); i++) { + char *nn; - if (! i) nn = strtok(search, ","); - else nn = strtok(0, ","); + if (! i) nn = strtok(search, ","); + else nn = strtok(0, ","); - if (nn) - screen->addWorkspaceName(nn); - else break; + if (nn) + screen->addWorkspaceName(nn); + else break; - } + } - delete [] search; - } + delete [] search; + } - sprintf(name_lookup, "session.screen%d.focusModel", screen_number); - sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "clicktofocus", value.size)) { - screen->saveAutoRaise(false); - screen->saveSloppyFocus(false); - screen->saveSemiSloppyFocus(false); + sprintf(name_lookup, "session.screen%d.focusModel", screen_number); + sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "clicktofocus", value.size)) { + screen->saveAutoRaise(false); + screen->saveSloppyFocus(false); + screen->saveSemiSloppyFocus(false); - } else if (! strncasecmp(value.addr, "autoraisesloppyfocus", value.size)) { - screen->saveSemiSloppyFocus(false); - screen->saveSloppyFocus(true); - screen->saveAutoRaise(true); - } else if (! strncasecmp(value.addr, "autoraisesemisloppyfocus", value.size)) { - screen->saveSloppyFocus(false); - screen->saveSemiSloppyFocus(true); - screen->saveAutoRaise(true); + } else if (! strncasecmp(value.addr, "autoraisesloppyfocus", value.size)) { + screen->saveSemiSloppyFocus(false); + screen->saveSloppyFocus(true); + screen->saveAutoRaise(true); + } else if (! strncasecmp(value.addr, "autoraisesemisloppyfocus", value.size)) { + screen->saveSloppyFocus(false); + screen->saveSemiSloppyFocus(true); + screen->saveAutoRaise(true); - } else if (! strncasecmp(value.addr, "semisloppyfocus", value.size)) { - screen->saveSloppyFocus(false); - screen->saveSemiSloppyFocus(true); - screen->saveAutoRaise(false); + } else if (! strncasecmp(value.addr, "semisloppyfocus", value.size)) { + screen->saveSloppyFocus(false); + screen->saveSemiSloppyFocus(true); + screen->saveAutoRaise(false); - } else { + } else { - screen->saveSemiSloppyFocus(false); - screen->saveSloppyFocus(true); - screen->saveAutoRaise(false); - } - } else { - screen->saveSemiSloppyFocus(false); - screen->saveSloppyFocus(true); - screen->saveAutoRaise(false); - } + screen->saveSemiSloppyFocus(false); + screen->saveSloppyFocus(true); + screen->saveAutoRaise(false); + } + } else { + screen->saveSemiSloppyFocus(false); + screen->saveSloppyFocus(true); + screen->saveAutoRaise(false); + } - sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); - sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "RowSmartPlacement", value.size)) - screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); - else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) - screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT); - else - screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT); - } else - screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); + sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number); + sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "RowSmartPlacement", value.size)) + screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); + else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) + screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT); + else + screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT); + } else + screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT); #ifdef SLIT - sprintf(name_lookup, "session.screen%d.slit.placement", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "TopLeft", value.size)) - screen->saveSlitPlacement(Slit::TOPLEFT); - else if (! strncasecmp(value.addr, "CenterLeft", value.size)) - screen->saveSlitPlacement(Slit::CENTERLEFT); - else if (! strncasecmp(value.addr, "BottomLeft", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMLEFT); - else if (! strncasecmp(value.addr, "TopCenter", value.size)) - screen->saveSlitPlacement(Slit::TOPCENTER); - else if (! strncasecmp(value.addr, "BottomCenter", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMCENTER); - else if (! strncasecmp(value.addr, "TopRight", value.size)) - screen->saveSlitPlacement(Slit::TOPRIGHT); - else if (! strncasecmp(value.addr, "BottomRight", value.size)) - screen->saveSlitPlacement(Slit::BOTTOMRIGHT); - else - screen->saveSlitPlacement(Slit::CENTERRIGHT); - } else - screen->saveSlitPlacement(Slit::CENTERRIGHT); + sprintf(name_lookup, "session.screen%d.slit.placement", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "TopLeft", value.size)) + screen->saveSlitPlacement(Slit::TOPLEFT); + else if (! strncasecmp(value.addr, "CenterLeft", value.size)) + screen->saveSlitPlacement(Slit::CENTERLEFT); + else if (! strncasecmp(value.addr, "BottomLeft", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMLEFT); + else if (! strncasecmp(value.addr, "TopCenter", value.size)) + screen->saveSlitPlacement(Slit::TOPCENTER); + else if (! strncasecmp(value.addr, "BottomCenter", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMCENTER); + else if (! strncasecmp(value.addr, "TopRight", value.size)) + screen->saveSlitPlacement(Slit::TOPRIGHT); + else if (! strncasecmp(value.addr, "BottomRight", value.size)) + screen->saveSlitPlacement(Slit::BOTTOMRIGHT); + else + screen->saveSlitPlacement(Slit::CENTERRIGHT); + } else + screen->saveSlitPlacement(Slit::CENTERRIGHT); - sprintf(name_lookup, "session.screen%d.slit.direction", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "Horizontal", value.size)) - screen->saveSlitDirection(Slit::HORIZONTAL); - else - screen->saveSlitDirection(Slit::VERTICAL); - } else - screen->saveSlitDirection(Slit::VERTICAL); + sprintf(name_lookup, "session.screen%d.slit.direction", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "Horizontal", value.size)) + screen->saveSlitDirection(Slit::HORIZONTAL); + else + screen->saveSlitDirection(Slit::VERTICAL); + } else + screen->saveSlitDirection(Slit::VERTICAL); - sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "True", value.size)) - screen->saveSlitOnTop(True); - else - screen->saveSlitOnTop(False); - } else - screen->saveSlitOnTop(False); + sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "True", value.size)) + screen->saveSlitOnTop(True); + else + screen->saveSlitOnTop(False); + } else + screen->saveSlitOnTop(False); - sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (! strncasecmp(value.addr, "True", value.size)) - screen->saveSlitAutoHide(True); - else - screen->saveSlitAutoHide(False); - } else - screen->saveSlitAutoHide(False); + sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (! strncasecmp(value.addr, "True", value.size)) + screen->saveSlitAutoHide(True); + else + screen->saveSlitAutoHide(False); + } else + screen->saveSlitAutoHide(False); - #ifdef XINERAMA - int tmp_head; - sprintf(name_lookup, "session.screen%d.slit.onHead", screen_number); - sprintf(class_lookup, "Session.Screen%d.Slit.OnHead", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (sscanf(value.addr, "%d", &tmp_head) != 1) - tmp_head = 0; - } else - tmp_head = 0; - screen->saveSlitOnHead(tmp_head); - #endif // XINERAMA +#ifdef XINERAMA + int tmp_head; + sprintf(name_lookup, "session.screen%d.slit.onHead", screen_number); + sprintf(class_lookup, "Session.Screen%d.Slit.OnHead", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (sscanf(value.addr, "%d", &tmp_head) != 1) + tmp_head = 0; + } else + tmp_head = 0; + screen->saveSlitOnHead(tmp_head); +#endif // XINERAMA #endif // SLIT #ifdef HAVE_STRFTIME - sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) - screen->saveStrftimeFormat(value.addr); - else - screen->saveStrftimeFormat("%I:%M %p"); + sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) + screen->saveStrftimeFormat(value.addr); + else + screen->saveStrftimeFormat("%I:%M %p"); #else // HAVE_STRFTIME - sprintf(name_lookup, "session.screen%d.dateFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - if (strncasecmp(value.addr, "european", value.size)) - screen->saveDateFormat(B_AmericanDate); - else - screen->saveDateFormat(B_EuropeanDate); - } else - screen->saveDateFormat(B_AmericanDate); + sprintf(name_lookup, "session.screen%d.dateFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + if (strncasecmp(value.addr, "european", value.size)) + screen->saveDateFormat(B_AmericanDate); + else + screen->saveDateFormat(B_EuropeanDate); + } else + screen->saveDateFormat(B_AmericanDate); - sprintf(name_lookup, "session.screen%d.clockFormat", screen_number); - sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number); - if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, - &value)) { - int clock; - if (sscanf(value.addr, "%d", &clock) != 1) - screen->saveClock24Hour(False); - else if (clock == 24) - screen->saveClock24Hour(True); - else - screen->saveClock24Hour(False); - } else - screen->saveClock24Hour(False); + sprintf(name_lookup, "session.screen%d.clockFormat", screen_number); + sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number); + if (XrmGetResource(*database, name_lookup, class_lookup, &value_type, + &value)) { + int clock; + if (sscanf(value.addr, "%d", &clock) != 1) + screen->saveClock24Hour(False); + else if (clock == 24) + screen->saveClock24Hour(True); + else + screen->saveClock24Hour(False); + } else + screen->saveClock24Hour(False); #endif // HAVE_STRFTIME - //check size on toolbarwidth percent - if (screen->getToolbarWidthPercent() <= 0 || - screen->getToolbarWidthPercent() > 100) - screen->saveToolbarWidthPercent(66); + //check size on toolbarwidth percent + if (screen->getToolbarWidthPercent() <= 0 || + screen->getToolbarWidthPercent() > 100) + screen->saveToolbarWidthPercent(66); - if (screen->getTabWidth()>512) - screen->saveTabWidth(512); - else if (screen->getTabWidth()<0) - screen->saveTabWidth(64); + if (screen->getTabWidth()>512) + screen->saveTabWidth(512); + else if (screen->getTabWidth()<0) + screen->saveTabWidth(64); - if (screen->getTabHeight()>512) - screen->saveTabHeight(512); - else if (screen->getTabHeight()<0) - screen->saveTabHeight(5); + if (screen->getTabHeight()>512) + screen->saveTabHeight(512); + else if (screen->getTabHeight()<0) + screen->saveTabHeight(5); } void Fluxbox::loadRootCommand(BScreen *screen) { - XrmDatabase database = (XrmDatabase) 0; + XrmDatabase database = (XrmDatabase) 0; - string dbfile(getRcFilename()); + string dbfile(getRcFilename()); - database = XrmGetFileDatabase(dbfile.c_str()); - if (!database) - database = XrmGetFileDatabase(DEFAULT_INITFILE); + database = XrmGetFileDatabase(dbfile.c_str()); + if (!database) + database = XrmGetFileDatabase(DEFAULT_INITFILE); - XrmValue value; - char *value_type, name_lookup[1024], class_lookup[1024]; - sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); - sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); - if (XrmGetResource(database, name_lookup, class_lookup, &value_type, - &value)) { - screen->saveRootCommand(value.addr==0 ? "": value.addr); - } else - screen->saveRootCommand(""); + XrmValue value; + char *value_type, name_lookup[1024], class_lookup[1024]; + sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber()); + sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber()); + if (XrmGetResource(database, name_lookup, class_lookup, &value_type, + &value)) { + screen->saveRootCommand(value.addr==0 ? "": value.addr); + } else + screen->saveRootCommand(""); } void Fluxbox::reload_rc() { - load_rc(); - reconfigure(); + load_rc(); + reconfigure(); } void Fluxbox::reconfigure() { - reconfigure_wait = true; + reconfigure_wait = true; - if (! timer.isTiming()) - timer.start(); + if (! timer.isTiming()) + timer.start(); } void Fluxbox::real_reconfigure() { - XrmDatabase new_blackboxrc = (XrmDatabase) 0; + XrmDatabase new_blackboxrc = (XrmDatabase) 0; - string dbfile(getRcFilename()); - XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str()); + string dbfile(getRcFilename()); + XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str()); - XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); - XrmPutFileDatabase(old_blackboxrc, dbfile.c_str()); + XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); + XrmPutFileDatabase(old_blackboxrc, dbfile.c_str()); - if (old_blackboxrc) - XrmDestroyDatabase(old_blackboxrc); + if (old_blackboxrc) + XrmDestroyDatabase(old_blackboxrc); - std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); - for (; it != it_end; ++it) { - MenuTimestamp *ts = *it; + std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); + std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); + for (; it != it_end; ++it) { + MenuTimestamp *ts = *it; - if (ts) { - if (ts->filename) - delete [] ts->filename; + if (ts) { + if (ts->filename) + delete [] ts->filename; - delete ts; - } - } - menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end()); + delete ts; + } + } + menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end()); - ScreenList::iterator sit = screenList.begin(); - ScreenList::iterator sit_end = screenList.end(); - for (; sit != sit_end; ++sit) - (*sit)->reconfigure(); + ScreenList::iterator sit = screenList.begin(); + ScreenList::iterator sit_end = screenList.end(); + for (; sit != sit_end; ++sit) + (*sit)->reconfigure(); - //reconfigure keys - key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str()); + //reconfigure keys + key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str()); - //reconfigure tabs - reconfigureTabs(); + //reconfigure tabs + reconfigureTabs(); }

@@ -2437,153 +2437,153 @@ //------------- reconfigureTabs ----------

// Reconfigure all tabs size and increase steps // --------------------------------------- void Fluxbox::reconfigureTabs() { - //tab reconfiguring - TabList::iterator it = tabSearch.begin(); - TabList::iterator it_end = tabSearch.end(); - //setting all to unconfigured - for (; it != it_end; ++it) { - it->second->setConfigured(false); - } - it = tabSearch.begin(); // resetting list and start configure tabs - //reconfiguring - for (; it != it_end; ++it) { - Tab *tab = it->second; - if (!tab->configured()) { - tab->setConfigured(true); - tab->resizeGroup(); - tab->calcIncrease(); - tab->setPosition(); - } - } + //tab reconfiguring + TabList::iterator it = tabSearch.begin(); + TabList::iterator it_end = tabSearch.end(); + //setting all to unconfigured + for (; it != it_end; ++it) { + it->second->setConfigured(false); + } + it = tabSearch.begin(); // resetting list and start configure tabs + //reconfiguring + for (; it != it_end; ++it) { + Tab *tab = it->second; + if (!tab->configured()) { + tab->setConfigured(true); + tab->resizeGroup(); + tab->calcIncrease(); + tab->setPosition(); + } + } } void Fluxbox::checkMenu() { - Bool reread = False; - std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); - for (; it != it_end && (! reread); ++it) { - struct stat buf; + Bool reread = False; + std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); + std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); + for (; it != it_end && (! reread); ++it) { + struct stat buf; - if (! stat((*it)->filename, &buf)) { - if ((*it)->timestamp != buf.st_ctime) - reread = True; - } else - reread = True; - } + if (! stat((*it)->filename, &buf)) { + if ((*it)->timestamp != buf.st_ctime) + reread = True; + } else + reread = True; + } - if (reread) rereadMenu(); + if (reread) rereadMenu(); } void Fluxbox::rereadMenu() { - reread_menu_wait = True; + reread_menu_wait = True; - if (! timer.isTiming()) timer.start(); + if (! timer.isTiming()) timer.start(); } void Fluxbox::real_rereadMenu() { - std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); - for (; it != it_end; ++it) { - MenuTimestamp *ts = *it; + std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); + std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); + for (; it != it_end; ++it) { + MenuTimestamp *ts = *it; - if (ts) { - if (ts->filename) - delete [] ts->filename; + if (ts) { + if (ts->filename) + delete [] ts->filename; - delete ts; - } - } - menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end()); + delete ts; + } + } + menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end()); - ScreenList::iterator sit = screenList.begin(); - ScreenList::iterator sit_end = screenList.end(); - for (; sit != sit_end; ++sit) { - (*sit)->rereadMenu(); - } + ScreenList::iterator sit = screenList.begin(); + ScreenList::iterator sit_end = screenList.end(); + for (; sit != sit_end; ++sit) { + (*sit)->rereadMenu(); + } } void Fluxbox::saveMenuFilename(const char *filename) { - Bool found = False; + Bool found = False; - std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); - for (; it != it_end; ++it) { - if (! strcmp((*it)->filename, filename)) found = True; - } + std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin(); + std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end(); + for (; it != it_end; ++it) { + if (! strcmp((*it)->filename, filename)) found = True; + } - if (! found) { - struct stat buf; + if (! found) { + struct stat buf; - if (! stat(filename, &buf)) { - MenuTimestamp *ts = new MenuTimestamp; + if (! stat(filename, &buf)) { + MenuTimestamp *ts = new MenuTimestamp; - ts->filename = StringUtil::strdup(filename); - ts->timestamp = buf.st_ctime; + ts->filename = StringUtil::strdup(filename); + ts->timestamp = buf.st_ctime; - menuTimestamps.push_back(ts); - } - } + menuTimestamps.push_back(ts); + } + } } void Fluxbox::timeout() { - if (reconfigure_wait) - real_reconfigure(); + if (reconfigure_wait) + real_reconfigure(); - if (reread_menu_wait) - real_rereadMenu(); + if (reread_menu_wait) + real_rereadMenu(); - reconfigure_wait = reread_menu_wait = false; + reconfigure_wait = reread_menu_wait = false; } // set focused window void Fluxbox::setFocusedWindow(FluxboxWindow *win) { - BScreen *old_screen = 0, *screen = 0; - FluxboxWindow *old_win = 0; - Toolbar *old_tbar = 0, *tbar = 0; - Workspace *old_wkspc = 0, *wkspc = 0; + BScreen *old_screen = 0, *screen = 0; + FluxboxWindow *old_win = 0; + Toolbar *old_tbar = 0, *tbar = 0; + Workspace *old_wkspc = 0, *wkspc = 0; - if (focused_window != 0) { - old_win = focused_window; - old_screen = old_win->getScreen(); + if (focused_window != 0) { + old_win = focused_window; + old_screen = old_win->getScreen(); - old_tbar = old_screen->getToolbar(); - old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); + old_tbar = old_screen->getToolbar(); + old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber()); - old_win->setFocusFlag(False); - old_wkspc->menu().setItemSelected(old_win->getWindowNumber(), false); + old_win->setFocusFlag(False); + old_wkspc->menu().setItemSelected(old_win->getWindowNumber(), false); - } + } - if (win && ! win->isIconic()) { - // make sure we have a valid win pointer with a valid screen - ScreenList::iterator winscreen = - std::find(screenList.begin(), screenList.end(), - win->getScreen()); - if (winscreen == screenList.end()) { - focused_window = 0; // the window pointer wasn't valid, mark no window focused - } else { - screen = *winscreen; - tbar = screen->getToolbar(); - wkspc = screen->getWorkspace(win->getWorkspaceNumber()); - focused_window = win; // update focused window - win->setFocusFlag(True); // set focus flag - // select this window in workspace menu - wkspc->menu().setItemSelected(win->getWindowNumber(), true); - } - } else - focused_window = 0; + if (win && ! win->isIconic()) { + // make sure we have a valid win pointer with a valid screen + ScreenList::iterator winscreen = + std::find(screenList.begin(), screenList.end(), + win->getScreen()); + if (winscreen == screenList.end()) { + focused_window = 0; // the window pointer wasn't valid, mark no window focused + } else { + screen = *winscreen; + tbar = screen->getToolbar(); + wkspc = screen->getWorkspace(win->getWorkspaceNumber()); + focused_window = win; // update focused window + win->setFocusFlag(True); // set focus flag + // select this window in workspace menu + wkspc->menu().setItemSelected(win->getWindowNumber(), true); + } + } else + focused_window = 0; - if (tbar != 0) - tbar->redrawWindowLabel(True); - if (screen != 0) - screen->updateNetizenWindowFocus(); + if (tbar != 0) + tbar->redrawWindowLabel(True); + if (screen != 0) + screen->updateNetizenWindowFocus(); - if (old_tbar && old_tbar != tbar) - old_tbar->redrawWindowLabel(True); - if (old_screen && old_screen != screen) - old_screen->updateNetizenWindowFocus(); + if (old_tbar && old_tbar != tbar) + old_tbar->redrawWindowLabel(True); + if (old_screen && old_screen != screen) + old_screen->updateNetizenWindowFocus(); }
M src/fluxbox.hhsrc/fluxbox.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: fluxbox.hh,v 1.34 2002/11/30 20:16:14 fluxgen Exp $ +// $Id: fluxbox.hh,v 1.35 2002/12/01 13:42:07 rathnor Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH

@@ -76,206 +76,206 @@ main class for the window manager.

singleton type */ class Fluxbox : public BaseDisplay, public TimeoutHandler, - public FbTk::SignalEventHandler, - public FbAtoms, - public FbTk::Observer { + public FbTk::SignalEventHandler, + public FbAtoms, + public FbTk::Observer { public: - Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); - virtual ~Fluxbox(); + Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); + virtual ~Fluxbox(); - static Fluxbox *instance() { return singleton; } + static Fluxbox *instance() { return singleton; } - inline bool useTabs() { return *m_rc_tabs; } - inline bool useIconBar() { return *m_rc_iconbar; } - inline void saveTabs(bool value) { *m_rc_tabs = value; } - inline void saveIconBar(bool value) { m_rc_iconbar = value; } + inline bool useTabs() { return *m_rc_tabs; } + inline bool useIconBar() { return *m_rc_iconbar; } + inline void saveTabs(bool value) { *m_rc_tabs = value; } + inline void saveIconBar(bool value) { m_rc_iconbar = value; } #ifdef HAVE_GETPID - inline Atom getFluxboxPidAtom() const { return fluxbox_pid; } - #ifdef KDE - //For KDE dock applets - inline Atom getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x - inline Atom getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x - #endif + inline Atom getFluxboxPidAtom() const { return fluxbox_pid; } +#ifdef KDE + //For KDE dock applets + inline Atom getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x + inline Atom getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x +#endif #endif // HAVE_GETPID - Basemenu *searchMenu(Window); + Basemenu *searchMenu(Window); - FluxboxWindow *searchGroup(Window, FluxboxWindow *); - FluxboxWindow *searchWindow(Window); - inline FluxboxWindow *getFocusedWindow() { return focused_window; } + FluxboxWindow *searchGroup(Window, FluxboxWindow *); + FluxboxWindow *searchWindow(Window); + inline FluxboxWindow *getFocusedWindow() { return focused_window; } - BScreen *searchScreen(Window w); + BScreen *searchScreen(Window w); - inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; } - inline const Time &getLastTime() const { return last_time; } + inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; } + inline const Time &getLastTime() const { return last_time; } - Toolbar *searchToolbar(Window w); - Tab *searchTab(Window); + Toolbar *searchToolbar(Window w); + Tab *searchTab(Window); - /// obsolete - enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; + /// obsolete + enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; - inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; } - inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; } - inline const char *getStyleFilename() const { return m_rc_stylefile->c_str(); } + inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; } + inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; } + inline const char *getStyleFilename() const { return m_rc_stylefile->c_str(); } - inline const char *getMenuFilename() const { return m_rc_menufile->c_str(); } - inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } - inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } + inline const char *getMenuFilename() const { return m_rc_menufile->c_str(); } + inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } + inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } - inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; } + inline const timeval &getAutoRaiseDelay() const { return resource.auto_raise_delay; } - inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } - inline unsigned int getCacheMax() const { return *m_rc_cache_max; } + inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } + inline unsigned int getCacheMax() const { return *m_rc_cache_max; } - inline void maskWindowEvents(Window w, FluxboxWindow *bw) - { masked = w; masked_window = bw; } - inline void setNoFocus(Bool f) { no_focus = f; } + inline void maskWindowEvents(Window w, FluxboxWindow *bw) + { masked = w; masked_window = bw; } + inline void setNoFocus(Bool f) { no_focus = f; } - void setFocusedWindow(FluxboxWindow *w); - void shutdown(); - void load_rc(BScreen *); - void loadRootCommand(BScreen *); - void loadTitlebar(); - void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } - void saveMenuFilename(const char *); - void saveTitlebarFilename(const char *); - void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); } - void saveMenuSearch(Window, Basemenu *); - void saveWindowSearch(Window, FluxboxWindow *); - void saveToolbarSearch(Window, Toolbar *); - void saveTabSearch(Window, Tab *); - void saveGroupSearch(Window, FluxboxWindow *); - void save_rc(); - void removeMenuSearch(Window); - void removeWindowSearch(Window); - void removeToolbarSearch(Window); - void removeTabSearch(Window); - void removeGroupSearch(Window); - void restart(const char * = 0); - void reconfigure(); - void reconfigureTabs(); - void rereadMenu(); - void checkMenu(); + void setFocusedWindow(FluxboxWindow *w); + void shutdown(); + void load_rc(BScreen *); + void loadRootCommand(BScreen *); + void loadTitlebar(); + void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } + void saveMenuFilename(const char *); + void saveTitlebarFilename(const char *); + void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); } + void saveMenuSearch(Window, Basemenu *); + void saveWindowSearch(Window, FluxboxWindow *); + void saveToolbarSearch(Window, Toolbar *); + void saveTabSearch(Window, Tab *); + void saveGroupSearch(Window, FluxboxWindow *); + void save_rc(); + void removeMenuSearch(Window); + void removeWindowSearch(Window); + void removeToolbarSearch(Window); + void removeTabSearch(Window); + void removeGroupSearch(Window); + void restart(const char * = 0); + void reconfigure(); + void reconfigureTabs(); + void rereadMenu(); + void checkMenu(); - /// handle any system signal sent to the application - void handleSignal(int signum); - void update(FbTk::Subject *changed); + /// handle any system signal sent to the application + void handleSignal(int signum); + void update(FbTk::Subject *changed); - void attachSignals(FluxboxWindow &win); + void attachSignals(FluxboxWindow &win); - virtual void timeout(); + virtual void timeout(); - inline const Cursor &getSessionCursor() const { return cursor.session; } - inline const Cursor &getMoveCursor() const { return cursor.move; } - inline const Cursor &getLowerLeftAngleCursor() const { return cursor.ll_angle; } - inline const Cursor &getLowerRightAngleCursor() const { return cursor.lr_angle; } + inline const Cursor &getSessionCursor() const { return cursor.session; } + inline const Cursor &getMoveCursor() const { return cursor.move; } + inline const Cursor &getLowerLeftAngleCursor() const { return cursor.ll_angle; } + inline const Cursor &getLowerRightAngleCursor() const { return cursor.lr_angle; } #ifdef SLIT - Slit *searchSlit(Window); + Slit *searchSlit(Window); - void saveSlitSearch(Window, Slit *); - void removeSlitSearch(Window); + void saveSlitSearch(Window, Slit *); + void removeSlitSearch(Window); #endif // SLIT #ifndef HAVE_STRFTIME - enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; + enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; #endif // HAVE_STRFTIME - typedef std::vector<Fluxbox::Titlebar> TitlebarList; + typedef std::vector<Fluxbox::Titlebar> TitlebarList; private: - struct cursor { - Cursor session, move, ll_angle, lr_angle; - } cursor; + struct cursor { + Cursor session, move, ll_angle, lr_angle; + } cursor; - typedef struct MenuTimestamp { - char *filename; - time_t timestamp; - } MenuTimestamp; + typedef struct MenuTimestamp { + char *filename; + time_t timestamp; + } MenuTimestamp; - struct resource { - Time double_click_interval; - timeval auto_raise_delay; - } resource; + struct resource { + Time double_click_interval; + timeval auto_raise_delay; + } resource; - std::string getRcFilename(); - void getDefaultDataFilename(char *, std::string &); - void load_rc(); + std::string getRcFilename(); + void getDefaultDataFilename(char *, std::string &); + void load_rc(); - void reload_rc(); - void real_rereadMenu(); - void real_reconfigure(); + void reload_rc(); + void real_rereadMenu(); + void real_reconfigure(); - void handleEvent(XEvent *xe); + void handleEvent(XEvent *xe); - void setupConfigFiles(); - void handleButtonEvent(XButtonEvent &be); - void handleUnmapNotify(XUnmapEvent &ue); - void handleClientMessage(XClientMessageEvent &ce); - void handleKeyEvent(XKeyEvent &ke); - void doWindowAction(Keys::KeyAction action, const int param); + void setupConfigFiles(); + void handleButtonEvent(XButtonEvent &be); + void handleUnmapNotify(XUnmapEvent &ue); + void handleClientMessage(XClientMessageEvent &ce); + void handleKeyEvent(XKeyEvent &ke); + void doWindowAction(Keys::KeyAction action, const int param); - ResourceManager m_resourcemanager, m_screen_rm; + ResourceManager m_resourcemanager, m_screen_rm; - //--- Resources - Resource<bool> m_rc_tabs, m_rc_iconbar; - Resource<int> m_rc_colors_per_channel; - Resource<std::string> m_rc_stylefile, - m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, - m_rc_groupfile; + //--- Resources + Resource<bool> m_rc_tabs, m_rc_iconbar; + Resource<int> m_rc_colors_per_channel; + Resource<std::string> m_rc_stylefile, + m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, + m_rc_groupfile; - Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right; - Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; + Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right; + Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; - void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); + void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); - std::map<Window, FluxboxWindow *> windowSearch; - std::map<Window, FluxboxWindow *> groupSearch; - std::map<Window, Basemenu *> menuSearch; - std::map<Window, Toolbar *> toolbarSearch; - typedef std::map<Window, Tab *> TabList; - TabList tabSearch; + std::map<Window, FluxboxWindow *> windowSearch; + std::map<Window, FluxboxWindow *> groupSearch; + std::map<Window, Basemenu *> menuSearch; + std::map<Window, Toolbar *> toolbarSearch; + typedef std::map<Window, Tab *> TabList; + TabList tabSearch; #ifdef SLIT - std::map<Window, Slit *> slitSearch; + std::map<Window, Slit *> slitSearch; #ifdef KDE - //For KDE dock applets - Atom kwm1_dockwindow; //KDE v1.x - Atom kwm2_dockwindow; //KDE v2.x + //For KDE dock applets + Atom kwm1_dockwindow; //KDE v1.x + Atom kwm2_dockwindow; //KDE v2.x #endif//KDE #endif // SLIT - std::list<MenuTimestamp *> menuTimestamps; - typedef std::list<BScreen *> ScreenList; - ScreenList screenList; + std::list<MenuTimestamp *> menuTimestamps; + typedef std::list<BScreen *> ScreenList; + ScreenList screenList; - FluxboxWindow *focused_window, *masked_window; - BTimer timer; + FluxboxWindow *focused_window, *masked_window; + BTimer timer; #ifdef HAVE_GETPID - Atom fluxbox_pid; + Atom fluxbox_pid; #endif // HAVE_GETPID - bool no_focus, reconfigure_wait, reread_menu_wait; - Time last_time; - Window masked; - std::string rc_file; ///< resource filename - char **argv; - int argc; - std::auto_ptr<Keys> key; - std::string slitlist_path; - //default arguments for titlebar left and right - static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; + bool no_focus, reconfigure_wait, reread_menu_wait; + Time last_time; + Window masked; + std::string rc_file; ///< resource filename + char **argv; + int argc; + std::auto_ptr<Keys> key; + std::string slitlist_path; + //default arguments for titlebar left and right + static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; - static Fluxbox *singleton; - std::vector<AtomHandler *> m_atomhandler; + static Fluxbox *singleton; + std::vector<AtomHandler *> m_atomhandler; };
M src/i18n.ccsrc/i18n.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: i18n.cc,v 1.6 2002/08/13 23:54:41 fluxgen Exp $ +// $Id: i18n.cc,v 1.7 2002/12/01 13:42:07 rathnor Exp $ //usr GNU extensions #ifndef _GNU_SOURCE

@@ -53,36 +53,36 @@ using std::endl;

using std::string; void NLSInit(const char *catalog) { - I18n *i18n = I18n::instance(); - i18n->openCatalog(catalog); + I18n *i18n = I18n::instance(); + i18n->openCatalog(catalog); } I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { #ifdef HAVE_SETLOCALE - //make sure we don't get 0 to m_locale string - char *temp = setlocale(LC_ALL, ""); - m_locale = ( temp ? temp : ""); - if (m_locale.size() == 0) { - cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; + //make sure we don't get 0 to m_locale string + char *temp = setlocale(LC_ALL, ""); + m_locale = ( temp ? temp : ""); + if (m_locale.size() == 0) { + cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; #endif // HAVE_SETLOCALE - m_locale = "C"; + m_locale = "C"; #ifdef HAVE_SETLOCALE - } else { - // MB_CUR_MAX returns the size of a char in the current locale - if (MB_CUR_MAX > 1) - m_multibyte = true; + } else { + // MB_CUR_MAX returns the size of a char in the current locale + if (MB_CUR_MAX > 1) + m_multibyte = true; - // truncate any encoding off the end of the locale + // truncate any encoding off the end of the locale - string::size_type index = m_locale.find('@'); - if (index != string::npos) - m_locale.erase(index); //erase all characters starting at index + string::size_type index = m_locale.find('@'); + if (index != string::npos) + m_locale.erase(index); //erase all characters starting at index - index = m_locale.find('.'); - if (index != string::npos) - m_locale.erase(index); //erase all characters starting at index - } + index = m_locale.find('.'); + if (index != string::npos) + m_locale.erase(index); //erase all characters starting at index + } #endif // HAVE_SETLOCALE }

@@ -90,37 +90,37 @@

I18n::~I18n() { #if defined(NLS) && defined(HAVE_CATCLOSE) - if (m_catalog_fd != (nl_catd)-1) - catclose(m_catalog_fd); + if (m_catalog_fd != (nl_catd)-1) + catclose(m_catalog_fd); #endif // HAVE_CATCLOSE } I18n *I18n::instance() { - static I18n singleton; //singleton object - return &singleton; + static I18n singleton; //singleton object + return &singleton; } void I18n::openCatalog(const char *catalog) { #if defined(NLS) && defined(HAVE_CATOPEN) - string catalog_filename = LOCALEPATH; - catalog_filename += '/'; - catalog_filename += m_locale; - catalog_filename += '/'; - catalog_filename += catalog; + string catalog_filename = LOCALEPATH; + catalog_filename += '/'; + catalog_filename += m_locale; + catalog_filename += '/'; + catalog_filename += catalog; #ifdef MCLoadBySet - m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); + m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); #else // !MCLoadBySet - m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); + m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); #endif // MCLoadBySet - if (m_catalog_fd == (nl_catd)-1) - cerr<<"Warning: Failed to open catalog, using default messages."<<endl; + if (m_catalog_fd == (nl_catd)-1) + cerr<<"Warning: Failed to open catalog, using default messages."<<endl; #else // !HAVE_CATOPEN - m_catalog_fd = (nl_catd)-1; + m_catalog_fd = (nl_catd)-1; #endif // HAVE_CATOPEN }

@@ -128,9 +128,9 @@

const char *I18n::getMessage(int set_number, int message_number, const char *default_message) { #if defined(NLS) && defined(HAVE_CATGETS) - if (m_catalog_fd != (nl_catd)-1) - return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); - else + if (m_catalog_fd != (nl_catd)-1) + return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); + else #endif // NLS && HAVE_CATGETS - return default_message; + return default_message; }
M src/i18n.hhsrc/i18n.hh

@@ -22,7 +22,7 @@ // 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. -// $Id: i18n.hh,v 1.9 2002/08/15 10:52:16 fluxgen Exp $ +// $Id: i18n.hh,v 1.10 2002/12/01 13:42:07 rathnor Exp $ #ifndef I18N_HH #define I18N_HH

@@ -54,19 +54,19 @@ #include <string>

class I18n { public: - static I18n *instance(); - inline const char *getLocale(void) const { return m_locale.c_str(); } - inline bool multibyte(void) const { return m_multibyte; } - inline const nl_catd &getCatalogFd(void) const { return m_catalog_fd; } + static I18n *instance(); + inline const char *getLocale(void) const { return m_locale.c_str(); } + inline bool multibyte(void) const { return m_multibyte; } + inline const nl_catd &getCatalogFd(void) const { return m_catalog_fd; } - const char *getMessage(int set_number, int message_number, const char *default_messsage = 0); - void openCatalog(const char *); + const char *getMessage(int set_number, int message_number, const char *default_messsage = 0); + void openCatalog(const char *); private: - I18n(); - ~I18n(); - std::string m_locale; - bool m_multibyte; - nl_catd m_catalog_fd; + I18n(); + ~I18n(); + std::string m_locale; + bool m_multibyte; + nl_catd m_catalog_fd; };
M src/main.ccsrc/main.cc

@@ -22,7 +22,7 @@ // 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. -// $Id: main.cc,v 1.8 2002/10/13 21:48:28 fluxgen Exp $ +// $Id: main.cc,v 1.9 2002/12/01 13:42:07 rathnor Exp $

@@ -68,151 +68,151 @@

#endif //!DEBUG_UDS const char *getNLSYesNoMsg(bool val) { - if (val) { - return I18n::instance()->getMessage( - FBNLS::CommonSet, FBNLS::CommonYes, - "yes"); - } + if (val) { + return I18n::instance()->getMessage( + FBNLS::CommonSet, FBNLS::CommonYes, + "yes"); + } - return I18n::instance()->getMessage( - FBNLS::CommonSet, FBNLS::CommonNo, - "no"); + return I18n::instance()->getMessage( + FBNLS::CommonSet, FBNLS::CommonNo, + "no"); } int main(int argc, char **argv) { - #ifdef DEBUG_UDS - uds::Init uds_init; - #endif //!DEBUG_UDS +#ifdef DEBUG_UDS + uds::Init uds_init; +#endif //!DEBUG_UDS - char *session_display = (char *) 0; - char *rc_file = (char *) 0; + char *session_display = (char *) 0; + char *rc_file = (char *) 0; - NLSInit("blackbox.cat"); - I18n *i18n = I18n::instance(); + NLSInit("blackbox.cat"); + I18n *i18n = I18n::instance(); - int i; - for (i = 1; i < argc; ++i) { - if (! strcmp(argv[i], "-rc")) { - // look for alternative rc file to use + int i; + for (i = 1; i < argc; ++i) { + if (! strcmp(argv[i], "-rc")) { + // look for alternative rc file to use - if ((++i) >= argc) { - fprintf(stderr, - i18n->getMessage( - FBNLS::mainSet, FBNLS::mainRCRequiresArg, - "error: '-rc' requires and argument\n")); - exit(1); - } + if ((++i) >= argc) { + fprintf(stderr, + i18n->getMessage( + FBNLS::mainSet, FBNLS::mainRCRequiresArg, + "error: '-rc' requires and argument\n")); + exit(1); + } - rc_file = argv[i]; - } else if (! strcmp(argv[i], "-display")) { - // check for -display option... to run on a display other than the one - // set by the environment variable DISPLAY + rc_file = argv[i]; + } else if (! strcmp(argv[i], "-display")) { + // check for -display option... to run on a display other than the one + // set by the environment variable DISPLAY - if ((++i) >= argc) { - fprintf(stderr, - i18n->getMessage( - FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, - "error: '-display' requires an argument\n")); - exit(1); - } + if ((++i) >= argc) { + fprintf(stderr, + i18n->getMessage( + FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, + "error: '-display' requires an argument\n")); + exit(1); + } - session_display = argv[i]; - char dtmp[255]; - sprintf(dtmp, "DISPLAY=%s", session_display); + session_display = argv[i]; + char dtmp[255]; + sprintf(dtmp, "DISPLAY=%s", session_display); - if (putenv(dtmp)) { - fprintf(stderr, - i18n-> - getMessage( - FBNLS::mainSet, FBNLS::mainWarnDisplaySet, - "warning: couldn't set environment variable 'DISPLAY'\n")); - perror("putenv()"); - } - } else if (strcmp(argv[i], "-version") == 0) { - // print current version string - printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n", - __fluxbox_version); - exit(0); - } else if (strcmp(argv[i], "-help") == 0) { - // print program usage and command line options - printf(i18n-> - getMessage( - FBNLS::mainSet, FBNLS::mainUsage, - "Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n" - " -display <string>\t\tuse display connection.\n" - " -rc <string>\t\t\tuse alternate resource file.\n" - " -version\t\t\tdisplay version and exit.\n" - " -help\t\t\t\tdisplay this help text and exit.\n\n"), - __fluxbox_version); + if (putenv(dtmp)) { + fprintf(stderr, + i18n-> + getMessage( + FBNLS::mainSet, FBNLS::mainWarnDisplaySet, + "warning: couldn't set environment variable 'DISPLAY'\n")); + perror("putenv()"); + } + } else if (strcmp(argv[i], "-version") == 0) { + // print current version string + printf("Fluxbox %s : (c) 2001-2002 Henrik Kinnunen \n\n", + __fluxbox_version); + exit(0); + } else if (strcmp(argv[i], "-help") == 0) { + // print program usage and command line options + printf(i18n-> + getMessage( + FBNLS::mainSet, FBNLS::mainUsage, + "Fluxbox %s : (c) 2001-2002 Henrik Kinnunen\n\n" + " -display <string>\t\tuse display connection.\n" + " -rc <string>\t\t\tuse alternate resource file.\n" + " -version\t\t\tdisplay version and exit.\n" + " -help\t\t\t\tdisplay this help text and exit.\n\n"), + __fluxbox_version); - // some people have requested that we print out command line options - // as well - printf(i18n-> - getMessage( - FBNLS::mainSet, FBNLS::mainCompileOptions, - "Compile time options:\n" - " Debugging:\t\t\t%s\n" - " Interlacing:\t\t\t%s\n" - " Shape:\t\t\t%s\n" - " Slit:\t\t\t\t%s\n" - " 8bpp Ordered Dithering:\t%s\n\n"), - #ifdef DEBUG - getNLSYesNoMsg(true), - #else // !DEBUG - getNLSYesNoMsg(false), - #endif // DEBUG + // some people have requested that we print out command line options + // as well + printf(i18n-> + getMessage( + FBNLS::mainSet, FBNLS::mainCompileOptions, + "Compile time options:\n" + " Debugging:\t\t\t%s\n" + " Interlacing:\t\t\t%s\n" + " Shape:\t\t\t%s\n" + " Slit:\t\t\t\t%s\n" + " 8bpp Ordered Dithering:\t%s\n\n"), +#ifdef DEBUG + getNLSYesNoMsg(true), +#else // !DEBUG + getNLSYesNoMsg(false), +#endif // DEBUG - #ifdef INTERLACE - getNLSYesNoMsg(true), - #else // !INTERLACE - getNLSYesNoMsg(false), - #endif // INTERLACE +#ifdef INTERLACE + getNLSYesNoMsg(true), +#else // !INTERLACE + getNLSYesNoMsg(false), +#endif // INTERLACE - #ifdef SHAPE - getNLSYesNoMsg(true), - #else // !SHAPE - getNLSYesNoMsg(false), - #endif // SHAPE +#ifdef SHAPE + getNLSYesNoMsg(true), +#else // !SHAPE + getNLSYesNoMsg(false), +#endif // SHAPE - #ifdef SLIT - getNLSYesNoMsg(true), - #else // !SLIT - getNLSYesNoMsg(false), - #endif // SLIT +#ifdef SLIT + getNLSYesNoMsg(true), +#else // !SLIT + getNLSYesNoMsg(false), +#endif // SLIT - #ifdef ORDEREDPSEUDO - getNLSYesNoMsg(true) - #else // !ORDEREDPSEUDO - getNLSYesNoMsg(false) - #endif // ORDEREDPSEUDO +#ifdef ORDEREDPSEUDO + getNLSYesNoMsg(true) +#else // !ORDEREDPSEUDO + getNLSYesNoMsg(false) +#endif // ORDEREDPSEUDO - ); + ); - ::exit(0); - } - } + ::exit(0); + } + } #ifdef __EMX__ - _chdir2(getenv("X11ROOT")); + _chdir2(getenv("X11ROOT")); #endif // __EMX__ - Fluxbox *fluxbox=0; - int exitcode=EXIT_SUCCESS; - try { + Fluxbox *fluxbox=0; + int exitcode=EXIT_SUCCESS; + try { - fluxbox = new Fluxbox(argc, argv, session_display, rc_file); - fluxbox->eventLoop(); + fluxbox = new Fluxbox(argc, argv, session_display, rc_file); + fluxbox->eventLoop(); - } catch (std::out_of_range oor) { - cerr<<"Fluxbox: Out of range: "<<oor.what()<<endl; - } catch (std::logic_error le) { - cerr<<"Fluxbox: Logic error: "<<le.what()<<endl; - } catch (std::runtime_error re) { - cerr<<"Fluxbox: Runtime error: "<<re.what()<<endl; - } catch (...) { - cerr<<"Fluxbox: Unknown error."<<endl; - } + } catch (std::out_of_range oor) { + cerr<<"Fluxbox: Out of range: "<<oor.what()<<endl; + } catch (std::logic_error le) { + cerr<<"Fluxbox: Logic error: "<<le.what()<<endl; + } catch (std::runtime_error re) { + cerr<<"Fluxbox: Runtime error: "<<re.what()<<endl; + } catch (...) { + cerr<<"Fluxbox: Unknown error."<<endl; + } - if (fluxbox) - delete fluxbox; - exit(exitcode); + if (fluxbox) + delete fluxbox; + exit(exitcode); }
M src/tests/Resourcetest.ccsrc/tests/Resourcetest.cc

@@ -41,35 +41,35 @@

template<> void Resource<TestEnum>:: setFromString(const char *str) { - if (strcasecmp(str, "TEST1")==0) - *this = TEST1; - else if (strcasecmp(str, "THIS_IS_TRUE")==0) - *this = THIS_IS_TRUE; - else if (strcasecmp(str, "USE_LOVE")==0) - *this = USE_LOVE; + if (strcasecmp(str, "TEST1")==0) + *this = TEST1; + else if (strcasecmp(str, "THIS_IS_TRUE")==0) + *this = THIS_IS_TRUE; + else if (strcasecmp(str, "USE_LOVE")==0) + *this = USE_LOVE; } template<> void Resource<int>:: setFromString(const char* strval) { - int val; - if (sscanf(strval, "%d", &val)==1) - *this = val; + int val; + if (sscanf(strval, "%d", &val)==1) + *this = val; } template<> void Resource<std::string>:: setFromString(const char *strval) { - *this = strval; + *this = strval; } template<> void Resource<bool>:: setFromString(char const *strval) { - if (strcasecmp(strval, "true")==0) - *this = true; - else - *this = false; + if (strcasecmp(strval, "true")==0) + *this = true; + else + *this = false; } //-----------------

@@ -78,29 +78,29 @@ //-----------------

template<> std::string Resource<TestEnum>:: getString() { - switch (m_value) { - case TEST1: - return string("TEST1"); - case THIS_IS_TRUE: - return string("THIS_IS_TRUE"); - case USE_LOVE: - return string("USE_LOVE"); - } - return string(""); + switch (m_value) { + case TEST1: + return string("TEST1"); + case THIS_IS_TRUE: + return string("THIS_IS_TRUE"); + case USE_LOVE: + return string("USE_LOVE"); + } + return string(""); } template<> std::string Resource<bool>:: getString() { - return std::string(**this == true ? "true" : "false"); + return std::string(**this == true ? "true" : "false"); } template<> std::string Resource<int>:: getString() { - char strval[256]; - sprintf(strval, "%d", **this); - return std::string(strval); + char strval[256]; + sprintf(strval, "%d", **this); + return std::string(strval); } template<>

@@ -109,32 +109,32 @@ getString() { return **this; }

int main(int argc, char **argv) { - ResourceManager rm; - // resources - Resource<int> val(rm, 123, "session.test", "Session.Test"); - Resource<bool> boolval(rm, true, "session.bool", "Session.Bool"); - Resource<string> strval(rm, "none", "string", "String"); - Resource<TestEnum> enumval(rm, TEST1, "enumval", "EnumVal"); + ResourceManager rm; + // resources + Resource<int> val(rm, 123, "session.test", "Session.Test"); + Resource<bool> boolval(rm, true, "session.bool", "Session.Bool"); + Resource<string> strval(rm, "none", "string", "String"); + Resource<TestEnum> enumval(rm, TEST1, "enumval", "EnumVal"); - const char *defaultfile_open = "res", - *defaultfile_save = "res_save"; + const char *defaultfile_open = "res", + *defaultfile_save = "res_save"; - if (argc>1) { - if(!rm.load(argv[1])) - cerr<<"Faild to load database: "<<argv[1]<<endl; - } else { - if (!rm.load(defaultfile_open)) - cerr<<"Faild to load database: "<<defaultfile_open<<endl; - } - cerr<<"Value="<<*val<<endl; - cerr<<"boolValue="<<boolval.getString()<<endl; - cerr<<"strValue="<<*strval<<endl; - cerr<<"enumValue="<<enumval.getString()<<endl; + if (argc>1) { + if(!rm.load(argv[1])) + cerr<<"Faild to load database: "<<argv[1]<<endl; + } else { + if (!rm.load(defaultfile_open)) + cerr<<"Faild to load database: "<<defaultfile_open<<endl; + } + cerr<<"Value="<<*val<<endl; + cerr<<"boolValue="<<boolval.getString()<<endl; + cerr<<"strValue="<<*strval<<endl; + cerr<<"enumValue="<<enumval.getString()<<endl; - if (!rm.save(defaultfile_save)) - cerr<<"Faild to save database to file:"<<defaultfile_save<<endl; + if (!rm.save(defaultfile_save)) + cerr<<"Faild to save database to file:"<<defaultfile_save<<endl; - if (!rm.save("I dont exist", "Not me either")) - cerr<<"faild to save and merge database."<<endl; - return 0; + if (!rm.save("I dont exist", "Not me either")) + cerr<<"faild to save and merge database."<<endl; + return 0; }
M src/tests/StringUtiltest.ccsrc/tests/StringUtiltest.cc

@@ -38,106 +38,106 @@

using namespace std; void testStringtok() { - vector<string> ls; - StringUtil::stringtok(ls, " arg1 arg2 \targ3\n arg4 arg5\t\t\t\targ6\n\n \n\n \t\t\narg7"); - cerr<<"Size: "<<ls.size()<<". Should be: 7."<<endl; - for (vector<string>::const_iterator i = ls.begin(); - i != ls.end(); ++i) { - cerr << ':' << (*i) << ":\n"; - } + vector<string> ls; + StringUtil::stringtok(ls, " arg1 arg2 \targ3\n arg4 arg5\t\t\t\targ6\n\n \n\n \t\t\narg7"); + cerr<<"Size: "<<ls.size()<<". Should be: 7."<<endl; + for (vector<string>::const_iterator i = ls.begin(); + i != ls.end(); ++i) { + cerr << ':' << (*i) << ":\n"; + } } void testExpandFilename() { - string filename(StringUtil::expandFilename("~/filename/~filename2/file3~/file4")); - cerr<<"test "; - string test = string(getenv("HOME"))+"/filename/~filename2/file3~/file4"; - if (test == filename) - cerr<<"ok."; - else - cerr<<"faild"; - cerr<<endl; + string filename(StringUtil::expandFilename("~/filename/~filename2/file3~/file4")); + cerr<<"test "; + string test = string(getenv("HOME"))+"/filename/~filename2/file3~/file4"; + if (test == filename) + cerr<<"ok."; + else + cerr<<"faild"; + cerr<<endl; } void testStrcasestr() { - cerr<<"test1 "; - if (StringUtil::strcasestr("Test", "TEST") == strcasestr("Test", "TEST")) - cerr<<"ok."<<endl; - else - cerr<<"faild."<<endl; + cerr<<"test1 "; + if (StringUtil::strcasestr("Test", "TEST") == strcasestr("Test", "TEST")) + cerr<<"ok."<<endl; + else + cerr<<"faild."<<endl; - cerr<<"test2 "; - if (StringUtil::strcasestr("Test", "ESTabc") == strcasestr("Test", "ESTabc")) - cerr<<"ok."<<endl; - else - cerr<<"faild."<<endl; + cerr<<"test2 "; + if (StringUtil::strcasestr("Test", "ESTabc") == strcasestr("Test", "ESTabc")) + cerr<<"ok."<<endl; + else + cerr<<"faild."<<endl; - cerr<<"test3 "; - if (StringUtil::strcasestr("TeSt", "abcTEStabc") == strcasestr("TeSt", "abcTEStabc")) - cerr<<"ok."<<endl; - else - cerr<<"faild."<<endl; + cerr<<"test3 "; + if (StringUtil::strcasestr("TeSt", "abcTEStabc") == strcasestr("TeSt", "abcTEStabc")) + cerr<<"ok."<<endl; + else + cerr<<"faild."<<endl; - cerr<<"test4 "; - if (StringUtil::strcasestr("TEST", "_TEST;_") == strcasestr("TEST", "_TEST;_")) - cerr<<"ok."<<endl; - else - cerr<<"faild."<<endl; + cerr<<"test4 "; + if (StringUtil::strcasestr("TEST", "_TEST;_") == strcasestr("TEST", "_TEST;_")) + cerr<<"ok."<<endl; + else + cerr<<"faild."<<endl; } void showError(int line, int pos, string& instr) { - cerr<<"Error on line: "<<line<<endl; - cerr<<instr<<endl; - for (int c=0; c<pos; c++) { - if (instr[c]=='\t') - cerr<<'\t'; - else - cerr<<" "; - } - cerr<<"^ here"<<endl; + cerr<<"Error on line: "<<line<<endl; + cerr<<instr<<endl; + for (int c=0; c<pos; c++) { + if (instr[c]=='\t') + cerr<<'\t'; + else + cerr<<" "; + } + cerr<<"^ here"<<endl; } void testGetStringBetween() { - string out; - vector<string> stringlist; - stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); - stringlist.push_back("(in\\)) {_ _ my_ _}"); - stringlist.push_back("(in) {_ _ my_ _}"); - stringlist.push_back("(in){_ _ my_ _}"); - stringlist.push_back("\t \t \t ( in ) {haha}"); - stringlist.push_back("\t \t \t (( in \\) ) {haha}"); - stringlist.push_back("\t \t \t (( in \\) ){hihi}"); - stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); - for (unsigned int i=0; i<stringlist.size(); i++) { - int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); - int total_pos = 0; - if (pos<0) { - showError(i+1, -pos, stringlist[i]); - continue; - } - cerr<<"string="<<stringlist[i]<<endl; - cerr<<"pos="<<pos<<" ::"<<out; - total_pos += pos; - pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); - if (pos<=0) { - pos=-pos; - showError(i+1, total_pos+pos, stringlist[i]); - continue; - } - cerr<<"::"<<out<<"::"<<endl; - total_pos += pos; - } + string out; + vector<string> stringlist; + stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); + stringlist.push_back("(in\\)) {_ _ my_ _}"); + stringlist.push_back("(in) {_ _ my_ _}"); + stringlist.push_back("(in){_ _ my_ _}"); + stringlist.push_back("\t \t \t ( in ) {haha}"); + stringlist.push_back("\t \t \t (( in \\) ) {haha}"); + stringlist.push_back("\t \t \t (( in \\) ){hihi}"); + stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); + for (unsigned int i=0; i<stringlist.size(); i++) { + int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); + int total_pos = 0; + if (pos<0) { + showError(i+1, -pos, stringlist[i]); + continue; + } + cerr<<"string="<<stringlist[i]<<endl; + cerr<<"pos="<<pos<<" ::"<<out; + total_pos += pos; + pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); + if (pos<=0) { + pos=-pos; + showError(i+1, total_pos+pos, stringlist[i]); + continue; + } + cerr<<"::"<<out<<"::"<<endl; + total_pos += pos; + } } int main() { - #ifdef UDS - uds::Init uds_init; - #endif - cerr<<"Testing stringtok."<<endl; - testStringtok(); - cerr<<"Testing expandFilename."<<endl; - testExpandFilename(); - cerr<<"Testing strcasestr."<<endl; - testStrcasestr(); +#ifdef UDS + uds::Init uds_init; +#endif + cerr<<"Testing stringtok."<<endl; + testStringtok(); + cerr<<"Testing expandFilename."<<endl; + testExpandFilename(); + cerr<<"Testing strcasestr."<<endl; + testStrcasestr(); }
M src/tests/main.ccsrc/tests/main.cc

@@ -33,110 +33,110 @@ bool loadMenu2(string filename);

void showError(int line, int pos, string& instr) { - cerr<<"Error on line: "<<line<<endl; - cerr<<instr<<endl; - for (int c=0; c<pos; c++) { - if (instr[c]=='\t') - cerr<<'\t'; - else - cerr<<" "; - } - cerr<<"^ here"<<endl; + cerr<<"Error on line: "<<line<<endl; + cerr<<instr<<endl; + for (int c=0; c<pos; c++) { + if (instr[c]=='\t') + cerr<<'\t'; + else + cerr<<" "; + } + cerr<<"^ here"<<endl; } int main(int argc, char **argv) { - string filename = "menu"; - if (argc>1) - filename = argv[1]; - if (loadMenu2(filename)) - cout<<"Load successfull"<<endl; - else - cout<<"Load failed"<<endl; + string filename = "menu"; + if (argc>1) + filename = argv[1]; + if (loadMenu2(filename)) + cout<<"Load successfull"<<endl; + else + cout<<"Load failed"<<endl; /* - string out; - vector<string> stringlist; - stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); - stringlist.push_back("(in\\)) {_ _ my_ _}"); - stringlist.push_back("(in) {_ _ my_ _}"); - stringlist.push_back("(in){_ _ my_ _}"); - stringlist.push_back("\t \t \t ( in ) {haha}"); - stringlist.push_back("\t \t \t (( in \\) ) {haha}"); - stringlist.push_back("\t \t \t (( in \\) ){hihi}"); - stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); - for (unsigned int i=0; i<stringlist.size(); i++) { - int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); - int total_pos = 0; - if (pos<0) { - showError(i+1, -pos, stringlist[i]); - continue; - } - cerr<<"string="<<stringlist[i]<<endl; - cerr<<"pos="<<pos<<" ::"<<out; - total_pos += pos; - pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); - if (pos<=0) { - pos=-pos; - showError(i+1, total_pos+pos, stringlist[i]); - continue; - } - cerr<<"::"<<out<<"::"<<endl; - total_pos += pos; - } + string out; + vector<string> stringlist; + stringlist.push_back(" \t\t\t \t[(in \\)\t haha )] \t\t "); + stringlist.push_back("(in\\)) {_ _ my_ _}"); + stringlist.push_back("(in) {_ _ my_ _}"); + stringlist.push_back("(in){_ _ my_ _}"); + stringlist.push_back("\t \t \t ( in ) {haha}"); + stringlist.push_back("\t \t \t (( in \\) ) {haha}"); + stringlist.push_back("\t \t \t (( in \\) ){hihi}"); + stringlist.push_back("\t \t \t (( in \\) )|{hihi}"); + for (unsigned int i=0; i<stringlist.size(); i++) { + int pos = StringUtil::getStringBetween(out, stringlist[i].c_str(), '(', ')'); + int total_pos = 0; + if (pos<0) { + showError(i+1, -pos, stringlist[i]); + continue; + } + cerr<<"string="<<stringlist[i]<<endl; + cerr<<"pos="<<pos<<" ::"<<out; + total_pos += pos; + pos = StringUtil::getStringBetween(out, stringlist[i].c_str()+total_pos, '{', '}'); + if (pos<=0) { + pos=-pos; + showError(i+1, total_pos+pos, stringlist[i]); + continue; + } + cerr<<"::"<<out<<"::"<<endl; + total_pos += pos; + } */ - return 0; + return 0; } bool loadMenu2(string filename) { - if (!filename.size()) - return false; + if (!filename.size()) + return false; - ifstream menufile(filename.c_str()); + ifstream menufile(filename.c_str()); - if (menufile) { - string instr; - vector<string> args; - int line=0; - while (!menufile.eof()) { - //read a line - getline(menufile, instr); - line++; - string arg; - int pos = StringUtil::getStringBetween(arg, instr.c_str(), '[', ']'); - if (pos<=0) { - showError(line, -pos, instr); - continue; - } + if (menufile) { + string instr; + vector<string> args; + int line=0; + while (!menufile.eof()) { + //read a line + getline(menufile, instr); + line++; + string arg; + int pos = StringUtil::getStringBetween(arg, instr.c_str(), '[', ']'); + if (pos<=0) { + showError(line, -pos, instr); + continue; + } - cerr<<"("<<line<<"):"<<arg<<"::"; - int total_pos = pos; - pos = StringUtil::getStringBetween(arg, instr.c_str()+pos, '(', ')'); - if (pos<=0) { - showError(line, total_pos+(-pos), instr); - continue; - } - cerr<<arg<<"::"; + cerr<<"("<<line<<"):"<<arg<<"::"; + int total_pos = pos; + pos = StringUtil::getStringBetween(arg, instr.c_str()+pos, '(', ')'); + if (pos<=0) { + showError(line, total_pos+(-pos), instr); + continue; + } + cerr<<arg<<"::"; - total_pos +=pos; - pos = StringUtil::getStringBetween(arg, instr.c_str()+total_pos, '{', '}'); - if (pos<=0) { - total_pos = total_pos+(-pos); - showError(line, total_pos, instr); - continue; - } - cerr<<arg<<":"<<endl; + total_pos +=pos; + pos = StringUtil::getStringBetween(arg, instr.c_str()+total_pos, '{', '}'); + if (pos<=0) { + total_pos = total_pos+(-pos); + showError(line, total_pos, instr); + continue; + } + cerr<<arg<<":"<<endl; - } + } - } else - return false; + } else + return false; - return true; + return true; }
M src/tests/signaltest.ccsrc/tests/signaltest.cc

@@ -28,48 +28,48 @@ using namespace FbTk;

class IntSig:public SignalHandler::EventHandler { public: - void handleSignal(int signum) { - assert(signum == SIGINT); - cerr<<"Signal SIGINT!"<<endl; - exit(0); - } + void handleSignal(int signum) { + assert(signum == SIGINT); + cerr<<"Signal SIGINT!"<<endl; + exit(0); + } }; class AllSig:public SignalHandler::EventHandler { public: - void handleSignal(int signum) { - switch (signum) { - case SIGTERM: - cerr<<"SIGTERM"; - break; - case SIGUSR1: - cerr<<"SIGUSR1"; - break; - case SIGUSR2: - cerr<<"SIGUSR2"; - break; - default: - cerr<<"signum = "<<signum; - } - cerr<<endl; - if (signum == SIGTERM) - exit(1); // end program - } + void handleSignal(int signum) { + switch (signum) { + case SIGTERM: + cerr<<"SIGTERM"; + break; + case SIGUSR1: + cerr<<"SIGUSR1"; + break; + case SIGUSR2: + cerr<<"SIGUSR2"; + break; + default: + cerr<<"signum = "<<signum; + } + cerr<<endl; + if (signum == SIGTERM) + exit(1); // end program + } }; int main(int argc, char **argv) { - SignalHandler *sigh = SignalHandler::instance(); - IntSig handler; - AllSig allhand; + SignalHandler *sigh = SignalHandler::instance(); + IntSig handler; + AllSig allhand; - sigh->registerHandler(SIGINT, &handler); - sigh->registerHandler(SIGTERM, &allhand); - sigh->registerHandler(SIGUSR1, &allhand); - sigh->registerHandler(SIGUSR2, &allhand); - cerr<<"Send signals to me :)"<<endl; - while (1) { + sigh->registerHandler(SIGINT, &handler); + sigh->registerHandler(SIGTERM, &allhand); + sigh->registerHandler(SIGUSR1, &allhand); + sigh->registerHandler(SIGUSR2, &allhand); + cerr<<"Send signals to me :)"<<endl; + while (1) { - } + } }
M src/tests/testFont.ccsrc/tests/testFont.cc

@@ -19,7 +19,7 @@ // 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. -// $Id: testFont.cc,v 1.4 2002/11/12 22:50:36 fluxgen Exp $ +// $Id: testFont.cc,v 1.5 2002/12/01 13:42:15 rathnor Exp $ #include "Font.hh" #include "BaseDisplay.hh"

@@ -34,99 +34,99 @@ using namespace std;

class App:public BaseDisplay { public: - App(const char *displayname):BaseDisplay("app", displayname) { + App(const char *displayname):BaseDisplay("app", displayname) { - // using screen 0 - m_win = XCreateSimpleWindow(getXDisplay(), - DefaultRootWindow(getXDisplay()), - 0, 0, - 640, 480, - 1, - 0, - 0xFFFF); - XSelectInput(getXDisplay(), m_win, KeyPressMask|ExposureMask); - XMapWindow(getXDisplay(), m_win); - } - ~App() { - XDestroyWindow(getXDisplay(), m_win); - } + // using screen 0 + m_win = XCreateSimpleWindow(getXDisplay(), + DefaultRootWindow(getXDisplay()), + 0, 0, + 640, 480, + 1, + 0, + 0xFFFF); + XSelectInput(getXDisplay(), m_win, KeyPressMask|ExposureMask); + XMapWindow(getXDisplay(), m_win); + } + ~App() { + XDestroyWindow(getXDisplay(), m_win); + } - void handleEvent(XEvent * const ev) { - switch (ev->type) { - case KeyPress: - KeySym ks; - char keychar[1]; - XLookupString(&ev->xkey, keychar, 1, &ks, 0); - if (ks == XK_Escape) - shutdown(); - else { // toggle antialias - m_font.setAntialias(!m_font.isAntialias()); - cerr<<boolalpha; - cerr<<"antialias: "<<m_font.isAntialias()<<endl; - redraw(); - } - break; - case Expose: - redraw(); - break; - } - } - void redraw() { - size_t text_w = m_font.textWidth(m_text.c_str(), m_text.size()); - size_t text_h = m_font.height(); - int x = 640/2 - text_w/2; - int y = 480/2 - text_h/2; - XClearWindow(getXDisplay(), m_win); - GC wingc = DefaultGC(getXDisplay(), 0); + void handleEvent(XEvent * const ev) { + switch (ev->type) { + case KeyPress: + KeySym ks; + char keychar[1]; + XLookupString(&ev->xkey, keychar, 1, &ks, 0); + if (ks == XK_Escape) + shutdown(); + else { // toggle antialias + m_font.setAntialias(!m_font.isAntialias()); + cerr<<boolalpha; + cerr<<"antialias: "<<m_font.isAntialias()<<endl; + redraw(); + } + break; + case Expose: + redraw(); + break; + } + } + void redraw() { + size_t text_w = m_font.textWidth(m_text.c_str(), m_text.size()); + size_t text_h = m_font.height(); + int x = 640/2 - text_w/2; + int y = 480/2 - text_h/2; + XClearWindow(getXDisplay(), m_win); + GC wingc = DefaultGC(getXDisplay(), 0); - XDrawLine(getXDisplay(), m_win, wingc, - x, y + m_font.descent(), x + text_w, y + m_font.descent()); - XSetForeground(getXDisplay(), wingc, 0xFF00FF); // don't care what color it is - XDrawLine(getXDisplay(), m_win, wingc, - x, y - text_h , x + text_w, y - text_h ); - XSetForeground(getXDisplay(), wingc, 0xFF0000); // don't care what color it is - XDrawLine(getXDisplay(), m_win, wingc, - x, y, x + text_w, y); + XDrawLine(getXDisplay(), m_win, wingc, + x, y + m_font.descent(), x + text_w, y + m_font.descent()); + XSetForeground(getXDisplay(), wingc, 0xFF00FF); // don't care what color it is + XDrawLine(getXDisplay(), m_win, wingc, + x, y - text_h , x + text_w, y - text_h ); + XSetForeground(getXDisplay(), wingc, 0xFF0000); // don't care what color it is + XDrawLine(getXDisplay(), m_win, wingc, + x, y, x + text_w, y); - XSetForeground(getXDisplay(), wingc, 0); - m_font.drawText(m_win, 0, wingc, + XSetForeground(getXDisplay(), wingc, 0); + m_font.drawText(m_win, 0, wingc, m_text.c_str(), m_text.size(), - x, y); + x, y); - } - Window win() const { return m_win; } - FbTk::Font &font() { return m_font; } - void setText(const std::string& text) { m_text = text; } + } + Window win() const { return m_win; } + FbTk::Font &font() { return m_font; } + void setText(const std::string& text) { m_text = text; } private: - Window m_win; - FbTk::Font m_font; - string m_text; + Window m_win; + FbTk::Font m_font; + string m_text; }; int main(int argc, char **argv) { - bool antialias = false; - string fontname("fixed"); - string displayname(""); - string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±"); - for (int a=1; a<argc; ++a) { - if (strcmp("-font", argv[a])==0 && a + 1 < argc) { - fontname = argv[++a]; - } else if (strcmp("-antialias", argv[a]) == 0) { - antialias = true; - } else if (strcmp("-display", argv[a]) == 0 && a + 1 < argc) { - displayname = argv[++a]; - } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) { - text = argv[++a]; - } - } + bool antialias = false; + string fontname("fixed"); + string displayname(""); + string text("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-_¯åäöÅÄÖ^~+=`\"!#¤%&/()=¡@£$½¥{[]}¶½§±"); + for (int a=1; a<argc; ++a) { + if (strcmp("-font", argv[a])==0 && a + 1 < argc) { + fontname = argv[++a]; + } else if (strcmp("-antialias", argv[a]) == 0) { + antialias = true; + } else if (strcmp("-display", argv[a]) == 0 && a + 1 < argc) { + displayname = argv[++a]; + } else if (strcmp("-text", argv[a]) == 0 && a + 1 < argc) { + text = argv[++a]; + } + } - App app(displayname.c_str()); - app.font().setAntialias(antialias); - if (!app.font().load(fontname.c_str())) - cerr<<"Failed to load: "<<fontname<<endl; + App app(displayname.c_str()); + app.font().setAntialias(antialias); + if (!app.font().load(fontname.c_str())) + cerr<<"Failed to load: "<<fontname<<endl; - app.setText(text); - app.redraw(); - app.eventLoop(); + app.setText(text); + app.redraw(); + app.eventLoop(); }
M src/tests/testKeys.ccsrc/tests/testKeys.cc

@@ -34,34 +34,34 @@

using namespace std; void testKeys(int argc, char **argv) { - Display *display = XOpenDisplay(0); + Display *display = XOpenDisplay(0); - if (display==0) { - cerr<<"Cant open display."<<endl; - return; - } + if (display==0) { + cerr<<"Cant open display."<<endl; + return; + } - Keys *keys = new Keys(display); - const char default_keyfile[] = "keys"; + Keys *keys = new Keys(display); + const char default_keyfile[] = "keys"; - if (argc>1) { - cerr<<"Loading file: "<<argv[1]<<endl; - keys->load(const_cast<char *>(argv[1])); - } else { - cerr<<"Using default file: "<<default_keyfile<<endl; - keys->load(const_cast<char *>(default_keyfile)); - } + if (argc>1) { + cerr<<"Loading file: "<<argv[1]<<endl; + keys->load(const_cast<char *>(argv[1])); + } else { + cerr<<"Using default file: "<<default_keyfile<<endl; + keys->load(const_cast<char *>(default_keyfile)); + } - keys->load(const_cast<char *>(default_keyfile)); + keys->load(const_cast<char *>(default_keyfile)); - delete keys; + delete keys; - XCloseDisplay(display); + XCloseDisplay(display); } int main(int argc, char **argv) { - #ifdef UDS - uds::Init uds_init; - #endif - testKeys(argc, argv); +#ifdef UDS + uds::Init uds_init; +#endif + testKeys(argc, argv); }