From 6c1f079fbd223946863ad445f8ffffbddf65f169 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 19 Mar 2002 00:07:00 +0000 Subject: indentation and timer --- src/Slit.cc | 47 +++++++-------- src/Slit.hh | 189 ++++++++++++++++++++++++++++++------------------------------ 2 files changed, 116 insertions(+), 120 deletions(-) diff --git a/src/Slit.cc b/src/Slit.cc index 19cce1a..ef16c2f 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -42,8 +42,7 @@ #include -Slit::Slit(BScreen *scr) { - screen = scr; +Slit::Slit(BScreen *scr):screen(scr), timer(this), slitmenu(this) { fluxbox = Fluxbox::instance(); on_top = screen->isSlitOnTop(); @@ -52,11 +51,9 @@ Slit::Slit(BScreen *scr) { display = screen->getBaseDisplay()->getXDisplay(); frame.window = frame.pixmap = None; - timer = new BTimer(fluxbox, this); - timer->setTimeout(fluxbox->getAutoRaiseDelay()); - timer->fireOnce(True); - - slitmenu = new Slitmenu(this); + + timer.setTimeout(fluxbox->getAutoRaiseDelay()); + timer.fireOnce(True); XSetWindowAttributes attrib; unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | @@ -86,10 +83,6 @@ Slit::Slit(BScreen *scr) { Slit::~Slit() { fluxbox->grab(); - delete timer; - - delete slitmenu; - screen->getImageControl()->removeImage(frame.pixmap); fluxbox->removeSlitSearch(frame.window); @@ -406,7 +399,7 @@ void Slit::reconfigure(void) { break; } - slitmenu->reconfigure(); + slitmenu.reconfigure(); } @@ -550,26 +543,26 @@ void Slit::buttonPressEvent(XButtonEvent *e) { } else if (e->button == Button2 && (! on_top)) { XLowerWindow(display, frame.window); } else if (e->button == Button3) { - if (! slitmenu->isVisible()) { + if (! slitmenu.isVisible()) { int x, y; - x = e->x_root - (slitmenu->getWidth() / 2); - y = e->y_root - (slitmenu->getHeight() / 2); + x = e->x_root - (slitmenu.getWidth() / 2); + y = e->y_root - (slitmenu.getHeight() / 2); if (x < 0) x = 0; - else if (x + slitmenu->getWidth() > screen->getWidth()) - x = screen->getWidth() - slitmenu->getWidth(); + else if (x + slitmenu.getWidth() > screen->getWidth()) + x = screen->getWidth() - slitmenu.getWidth(); if (y < 0) y = 0; - else if (y + slitmenu->getHeight() > screen->getHeight()) - y = screen->getHeight() - slitmenu->getHeight(); + else if (y + slitmenu.getHeight() > screen->getHeight()) + y = screen->getHeight() - slitmenu.getHeight(); - slitmenu->move(x, y); - slitmenu->show(); + slitmenu.move(x, y); + slitmenu.show(); } else - slitmenu->hide(); + slitmenu.hide(); } } @@ -579,9 +572,9 @@ void Slit::enterNotifyEvent(XCrossingEvent *) { return; if (hidden) { - if (! timer->isTiming()) timer->start(); + if (! timer.isTiming()) timer.start(); } else { - if (timer->isTiming()) timer->stop(); + if (timer.isTiming()) timer.stop(); } } @@ -591,9 +584,9 @@ void Slit::leaveNotifyEvent(XCrossingEvent *) { return; if (hidden) { - if (timer->isTiming()) timer->stop(); - } else if (! slitmenu->isVisible()) { - if (! timer->isTiming()) timer->start(); + if (timer.isTiming()) timer.stop(); + } else if (! slitmenu.isVisible()) { + if (! timer.isTiming()) timer.start(); } } diff --git a/src/Slit.hh b/src/Slit.hh index 2c29af6..d07cfe0 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -1,3 +1,6 @@ +// Slit.hh for Fluxbox +// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) +// // Slit.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // @@ -18,9 +21,9 @@ // 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. - -#ifndef SLIT_HH -#define SLIT_HH + +#ifndef SLIT_HH +#define SLIT_HH #include #include @@ -35,126 +38,126 @@ class Slitmenu; class Slitmenu : public Basemenu { private: - class Directionmenu : public Basemenu { - private: - Slitmenu *slitmenu; + class Directionmenu : public Basemenu { + private: + Slitmenu *slitmenu; - protected: - virtual void itemSelected(int, int); + protected: + virtual void itemSelected(int, int); - public: - Directionmenu(Slitmenu *); - }; + public: + Directionmenu(Slitmenu *); + }; - class Placementmenu : public Basemenu { - private: - Slitmenu *slitmenu; + class Placementmenu : public Basemenu { + private: + Slitmenu *slitmenu; - protected: - virtual void itemSelected(int, int); + protected: + virtual void itemSelected(int, int); - public: - Placementmenu(Slitmenu *); - }; + public: + Placementmenu(Slitmenu *); + }; - Directionmenu *directionmenu; - Placementmenu *placementmenu; + Directionmenu *directionmenu; + Placementmenu *placementmenu; - Slit *slit; + Slit *slit; - friend class Directionmenu; - friend class Placementmenu; - friend class Slit; + friend class Directionmenu; + friend class Placementmenu; + friend class Slit; protected: - virtual void itemSelected(int, int); - virtual void internal_hide(void); + virtual void itemSelected(int, int); + virtual void internal_hide(void); public: - Slitmenu(Slit *); - virtual ~Slitmenu(void); + explicit Slitmenu(Slit *); + virtual ~Slitmenu(void); - inline Basemenu *getDirectionmenu(void) { return directionmenu; } - inline Basemenu *getPlacementmenu(void) { return placementmenu; } + inline Basemenu *getDirectionmenu(void) { return directionmenu; } + inline Basemenu *getPlacementmenu(void) { return placementmenu; } - void reconfigure(void); + void reconfigure(void); }; class Slit : public TimeoutHandler { -private: - class SlitClient { - public: - Window window, client_window, icon_window; - - int x, y; - unsigned int width, height; - }; - - Bool on_top, hidden, do_auto_hide; - Display *display; - - Fluxbox *fluxbox; - BScreen *screen; - BTimer *timer; - - typedef std::list SlitClients; - - SlitClients clientList; - Slitmenu *slitmenu; - - struct frame { - Pixmap pixmap; - Window window; - - int x, y, x_hidden, y_hidden; - unsigned int width, height; - } frame; - - friend class Slitmenu; - friend class Slitmenu::Directionmenu; - friend class Slitmenu::Placementmenu; - - public: - Slit(BScreen *); - virtual ~Slit(); + explicit Slit(BScreen *); + virtual ~Slit(); + + inline const bool isOnTop(void) const { return on_top; } + inline const bool isHidden(void) const { return hidden; } + inline const bool doAutoHide(void) const { return do_auto_hide; } - inline const Bool &isOnTop(void) const { return on_top; } - inline const Bool &isHidden(void) const { return hidden; } - inline const Bool &doAutoHide(void) const { return do_auto_hide; } + Slitmenu &getMenu() { return slitmenu; } - inline Slitmenu *getMenu() { return slitmenu; } + inline const Window &getWindowID() const { return frame.window; } - inline const Window &getWindowID() const { return frame.window; } + inline const int getX(void) const + { return ((hidden) ? frame.x_hidden : frame.x); } + inline const int getY(void) const + { return ((hidden) ? frame.y_hidden : frame.y); } - inline const int &getX(void) const - { return ((hidden) ? frame.x_hidden : frame.x); } - inline const int &getY(void) const - { return ((hidden) ? frame.y_hidden : frame.y); } + inline const unsigned int getWidth(void) const { return frame.width; } + inline const unsigned int getHeight(void) const { return frame.height; } - inline const unsigned int &getWidth(void) const { return frame.width; } - inline const unsigned int &getHeight(void) const { return frame.height; } + void addClient(Window); + void removeClient(Window, bool = true); + void reconfigure(void); + void reposition(void); + void shutdown(void); - void addClient(Window); - void removeClient(SlitClient *, bool = true); - void removeClient(Window, bool = true); - void reconfigure(void); - void reposition(void); - void shutdown(void); + void buttonPressEvent(XButtonEvent *); + void enterNotifyEvent(XCrossingEvent *); + void leaveNotifyEvent(XCrossingEvent *); + void configureRequestEvent(XConfigureRequestEvent *); - void buttonPressEvent(XButtonEvent *); - void enterNotifyEvent(XCrossingEvent *); - void leaveNotifyEvent(XCrossingEvent *); - void configureRequestEvent(XConfigureRequestEvent *); + virtual void timeout(void); - virtual void timeout(void); + enum { VERTICAL = 1, HORIZONTAL }; + enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, + TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; - enum { VERTICAL = 1, HORIZONTAL }; - enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, - TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; +private: + class SlitClient { + public: + Window window, client_window, icon_window; + + int x, y; + unsigned int width, height; + }; + + void removeClient(SlitClient *, bool = true); + + Bool on_top, hidden, do_auto_hide; + Display *display; + + Fluxbox *fluxbox; + BScreen *screen; + BTimer timer; + + typedef std::list SlitClients; + + SlitClients clientList; + Slitmenu slitmenu; + + struct frame { + Pixmap pixmap; + Window window; + + int x, y, x_hidden, y_hidden; + unsigned int width, height; + } frame; + + friend class Slitmenu; + friend class Slitmenu::Directionmenu; + friend class Slitmenu::Placementmenu; }; -- cgit v0.11.2